|
|
@ -16,16 +16,6 @@ |
|
|
|
|
|
|
|
Persistent<FunctionTemplate> Canvas::constructor; |
|
|
|
|
|
|
|
/*
|
|
|
|
* Buffer data pointer access. |
|
|
|
*/ |
|
|
|
|
|
|
|
#if NODE_VERSION_AT_LEAST(0,3,0) |
|
|
|
#define BUFFER_DATA(buf) Buffer::Data(buf->handle_) |
|
|
|
#else |
|
|
|
#define BUFFER_DATA(buf) buf->data() |
|
|
|
#endif |
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize Canvas. |
|
|
|
*/ |
|
|
@ -161,7 +151,7 @@ Canvas::EIO_AfterToBuffer(eio_req *req) { |
|
|
|
closure->pfn->Call(Context::GetCurrent()->Global(), 1, argv); |
|
|
|
} else { |
|
|
|
Buffer *buf = Buffer::New(closure->len); |
|
|
|
memcpy(BUFFER_DATA(buf), closure->data, closure->len); |
|
|
|
memcpy(Buffer::Data(buf->handle_), closure->data, closure->len); |
|
|
|
Local<Value> argv[2] = { Local<Value>::New(Null()), Local<Value>::New(buf->handle_) }; |
|
|
|
closure->pfn->Call(Context::GetCurrent()->Global(), 2, argv); |
|
|
|
} |
|
|
@ -207,7 +197,7 @@ Canvas::ToBuffer(const Arguments &args) { |
|
|
|
return ThrowException(Canvas::Error(status)); |
|
|
|
} else { |
|
|
|
Buffer *buf = Buffer::New(closure.len); |
|
|
|
memcpy(BUFFER_DATA(buf), closure.data, closure.len); |
|
|
|
memcpy(Buffer::Data(buf->handle_), closure.data, closure.len); |
|
|
|
return buf->handle_; |
|
|
|
} |
|
|
|
} |
|
|
@ -222,7 +212,7 @@ streamPNG(void *c, const uint8_t *data, unsigned len) { |
|
|
|
HandleScope scope; |
|
|
|
closure_t *closure = (closure_t *) c; |
|
|
|
Local<Buffer> buf = Buffer::New(len); |
|
|
|
memcpy(BUFFER_DATA(buf), data, len); |
|
|
|
memcpy(Buffer::Data(buf->handle_), data, len); |
|
|
|
Local<Value> argv[3] = { |
|
|
|
Local<Value>::New(Null()) |
|
|
|
, Local<Value>::New(buf->handle_) |
|
|
|