|
|
@ -29,7 +29,7 @@ Canvas::Initialize(Handle<Object> target) { |
|
|
|
HandleScope scope; |
|
|
|
|
|
|
|
// Constructor
|
|
|
|
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Canvas::New)); |
|
|
|
constructor = Persistent<FunctionTemplate>::New(Isolate::GetCurrent(), FunctionTemplate::New(Canvas::New)); |
|
|
|
constructor->InstanceTemplate()->SetInternalFieldCount(1); |
|
|
|
constructor->SetClassName(String::NewSymbol("Canvas")); |
|
|
|
|
|
|
@ -202,9 +202,9 @@ Canvas::EIO_AfterToBuffer(eio_req *req) { |
|
|
|
Local<Value> argv[1] = { Canvas::Error(closure->status) }; |
|
|
|
closure->pfn->Call(Context::GetCurrent()->Global(), 1, argv); |
|
|
|
} else { |
|
|
|
Buffer *buf = Buffer::New(closure->len); |
|
|
|
Local<Object> buf = Buffer::New(closure->len); |
|
|
|
memcpy(Buffer::Data(buf), closure->data, closure->len); |
|
|
|
Local<Value> argv[2] = { Local<Value>::New(Null()), Local<Value>::New(buf->handle_) }; |
|
|
|
Local<Value> argv[2] = { Local<Value>::New(Null()), Local<Value>::New(buf) }; |
|
|
|
closure->pfn->Call(Context::GetCurrent()->Global(), 2, argv); |
|
|
|
} |
|
|
|
|
|
|
@ -233,9 +233,9 @@ Canvas::ToBuffer(const Arguments &args) { |
|
|
|
if (canvas->isPDF()) { |
|
|
|
cairo_surface_finish(canvas->surface()); |
|
|
|
closure_t *closure = (closure_t *) canvas->closure(); |
|
|
|
Buffer *buf = Buffer::New(closure->len); |
|
|
|
Local<Object> buf = Buffer::New(closure->len); |
|
|
|
memcpy(Buffer::Data(buf), closure->data, closure->len); |
|
|
|
return buf->handle_; |
|
|
|
return buf; |
|
|
|
} |
|
|
|
|
|
|
|
// Async
|
|
|
@ -252,7 +252,7 @@ Canvas::ToBuffer(const Arguments &args) { |
|
|
|
|
|
|
|
// TODO: only one callback fn in closure
|
|
|
|
canvas->Ref(); |
|
|
|
closure->pfn = Persistent<Function>::New(Handle<Function>::Cast(args[0])); |
|
|
|
closure->pfn = Persistent<Function>::New(Isolate::GetCurrent(), Handle<Function>::Cast(args[0])); |
|
|
|
|
|
|
|
#if NODE_VERSION_AT_LEAST(0, 6, 0) |
|
|
|
uv_work_t* req = new uv_work_t; |
|
|
@ -285,10 +285,10 @@ Canvas::ToBuffer(const Arguments &args) { |
|
|
|
closure_destroy(&closure); |
|
|
|
return ThrowException(Canvas::Error(status)); |
|
|
|
} else { |
|
|
|
Buffer *buf = Buffer::New(closure.len); |
|
|
|
Local<Object> buf = Buffer::New(closure.len); |
|
|
|
memcpy(Buffer::Data(buf), closure.data, closure.len); |
|
|
|
closure_destroy(&closure); |
|
|
|
return buf->handle_; |
|
|
|
return buf; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -301,11 +301,11 @@ static cairo_status_t |
|
|
|
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->handle_), data, len); |
|
|
|
Local<Object> buf = Buffer::New(len); |
|
|
|
memcpy(Buffer::Data(buf), data, len); |
|
|
|
Local<Value> argv[3] = { |
|
|
|
Local<Value>::New(Null()) |
|
|
|
, Local<Value>::New(buf->handle_) |
|
|
|
, Local<Value>::New(buf) |
|
|
|
, Integer::New(len) }; |
|
|
|
closure->fn->Call(Context::GetCurrent()->Global(), 3, argv); |
|
|
|
return CAIRO_STATUS_SUCCESS; |
|
|
|