Browse Source

Merge branch 'newv8' of https://github.com/kkoopa/node-canvas into nan-1.0.0

Conflicts:
	package.json
	src/Canvas.cc
	src/CanvasRenderingContext2d.cc
	src/JPEGStream.h
	src/closure.h
v1.x
Rod Vagg 11 years ago
parent
commit
746f2caa06
  1. 10
      src/Canvas.cc
  2. 2
      src/Canvas.h
  3. 2
      src/CanvasGradient.cc
  4. 2
      src/CanvasGradient.h
  5. 2
      src/CanvasPattern.h
  6. 30
      src/CanvasRenderingContext2d.cc
  7. 4
      src/FontFace.cc
  8. 2
      src/Image.cc
  9. 2
      src/Image.h
  10. 16
      src/JPEGStream.h
  11. 2
      src/PixelArray.cc
  12. 4
      src/closure.h

10
src/Canvas.cc

@ -67,7 +67,7 @@ NAN_METHOD(Canvas::New) {
canvas_type_t type = CANVAS_TYPE_IMAGE; canvas_type_t type = CANVAS_TYPE_IMAGE;
if (args[0]->IsNumber()) width = args[0]->Uint32Value(); if (args[0]->IsNumber()) width = args[0]->Uint32Value();
if (args[1]->IsNumber()) height = args[1]->Uint32Value(); if (args[1]->IsNumber()) height = args[1]->Uint32Value();
if (args[2]->IsString()) type = !strcmp("pdf", *String::AsciiValue(args[2])) if (args[2]->IsString()) type = !strcmp("pdf", *String::Utf8Value(args[2]))
? CANVAS_TYPE_PDF ? CANVAS_TYPE_PDF
: CANVAS_TYPE_IMAGE; : CANVAS_TYPE_IMAGE;
Canvas *canvas = new Canvas(width, height, type); Canvas *canvas = new Canvas(width, height, type);
@ -351,7 +351,7 @@ streamPNG(void *c, const uint8_t *data, unsigned len) {
NanNull() NanNull()
, buf , buf
, NanNew<Integer>(len) }; , NanNew<Integer>(len) };
NanMakeCallback(NanGetCurrentContext(), closure->fn, 3, argv); NanMakeCallback(NanGetCurrentContext()->Global(), closure->fn, 3, argv);
return CAIRO_STATUS_SUCCESS; return CAIRO_STATUS_SUCCESS;
} }
@ -420,13 +420,13 @@ NAN_METHOD(Canvas::StreamPNGSync) {
NanReturnValue(try_catch.ReThrow()); NanReturnValue(try_catch.ReThrow());
} else if (status) { } else if (status) {
Local<Value> argv[1] = { Canvas::Error(status) }; Local<Value> argv[1] = { Canvas::Error(status) };
NanMakeCallback(NanGetCurrentContext(), closure.fn, 1, argv); NanMakeCallback(NanGetCurrentContext()->Global(), closure.fn, 1, argv);
} else { } else {
Local<Value> argv[3] = { Local<Value> argv[3] = {
NanNull() NanNull()
, NanNull() , NanNull()
, NanNew<Integer>(0) }; , NanNew<Uint32>(0) };
NanMakeCallback(NanGetCurrentContext(), closure.fn, 3, argv); NanMakeCallback(NanGetCurrentContext()->Global(), closure.fn, 1, argv);
} }
NanReturnUndefined(); NanReturnUndefined();
} }

2
src/Canvas.h

@ -19,7 +19,7 @@
#include <cairo/cairo.h> #include <cairo/cairo.h>
#endif #endif
#include "nan.h" #include <nan.h>
using namespace v8; using namespace v8;
using namespace node; using namespace node;

2
src/CanvasGradient.cc

@ -77,7 +77,7 @@ NAN_METHOD(Gradient::AddColorStop) {
Gradient *grad = ObjectWrap::Unwrap<Gradient>(args.This()); Gradient *grad = ObjectWrap::Unwrap<Gradient>(args.This());
short ok; short ok;
String::AsciiValue str(args[1]); String::Utf8Value str(args[1]);
uint32_t rgba = rgba_from_string(*str, &ok); uint32_t rgba = rgba_from_string(*str, &ok);
if (ok) { if (ok) {

2
src/CanvasGradient.h

@ -8,7 +8,7 @@
#ifndef __NODE_GRADIENT_H__ #ifndef __NODE_GRADIENT_H__
#define __NODE_GRADIENT_H__ #define __NODE_GRADIENT_H__
#include "nan.h" #include <nan.h>
#include "Canvas.h" #include "Canvas.h"
class Gradient: public node::ObjectWrap { class Gradient: public node::ObjectWrap {

2
src/CanvasPattern.h

@ -8,7 +8,7 @@
#ifndef __NODE_PATTERN_H__ #ifndef __NODE_PATTERN_H__
#define __NODE_PATTERN_H__ #define __NODE_PATTERN_H__
#include "nan.h" #include <nan.h>
#include "Canvas.h" #include "Canvas.h"
class Pattern: public node::ObjectWrap { class Pattern: public node::ObjectWrap {

30
src/CanvasRenderingContext2d.cc

@ -764,7 +764,7 @@ NAN_GETTER(Context2d::GetGlobalCompositeOperation) {
NAN_SETTER(Context2d::SetPatternQuality) { NAN_SETTER(Context2d::SetPatternQuality) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
String::AsciiValue quality(value->ToString()); String::Utf8Value quality(value->ToString());
if (0 == strcmp("fast", *quality)) { if (0 == strcmp("fast", *quality)) {
context->state->patternQuality = CAIRO_FILTER_FAST; context->state->patternQuality = CAIRO_FILTER_FAST;
} else if (0 == strcmp("good", *quality)) { } else if (0 == strcmp("good", *quality)) {
@ -803,7 +803,7 @@ NAN_GETTER(Context2d::GetPatternQuality) {
NAN_SETTER(Context2d::SetGlobalCompositeOperation) { NAN_SETTER(Context2d::SetGlobalCompositeOperation) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_t *ctx = context->context(); cairo_t *ctx = context->context();
String::AsciiValue type(value->ToString()); String::Utf8Value type(value->ToString());
if (0 == strcmp("xor", *type)) { if (0 == strcmp("xor", *type)) {
cairo_set_operator(ctx, CAIRO_OPERATOR_XOR); cairo_set_operator(ctx, CAIRO_OPERATOR_XOR);
} else if (0 == strcmp("source-atop", *type)) { } else if (0 == strcmp("source-atop", *type)) {
@ -953,7 +953,7 @@ NAN_GETTER(Context2d::GetAntiAlias) {
*/ */
NAN_SETTER(Context2d::SetAntiAlias) { NAN_SETTER(Context2d::SetAntiAlias) {
String::AsciiValue str(value->ToString()); String::Utf8Value str(value->ToString());
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_t *ctx = context->context(); cairo_t *ctx = context->context();
cairo_antialias_t a; cairo_antialias_t a;
@ -994,7 +994,7 @@ NAN_GETTER(Context2d::GetTextDrawingMode) {
*/ */
NAN_SETTER(Context2d::SetTextDrawingMode) { NAN_SETTER(Context2d::SetTextDrawingMode) {
String::AsciiValue str(value->ToString()); String::Utf8Value str(value->ToString());
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
if (0 == strcmp("path", *str)) { if (0 == strcmp("path", *str)) {
context->state->textDrawingMode = TEXT_DRAW_PATHS; context->state->textDrawingMode = TEXT_DRAW_PATHS;
@ -1026,7 +1026,7 @@ NAN_GETTER(Context2d::GetFilter) {
*/ */
NAN_SETTER(Context2d::SetFilter) { NAN_SETTER(Context2d::SetFilter) {
String::AsciiValue str(value->ToString()); String::Utf8Value str(value->ToString());
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_filter_t filter; cairo_filter_t filter;
if (0 == strcmp("fast", *str)) { if (0 == strcmp("fast", *str)) {
@ -1110,7 +1110,7 @@ NAN_GETTER(Context2d::GetLineJoin) {
NAN_SETTER(Context2d::SetLineJoin) { NAN_SETTER(Context2d::SetLineJoin) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_t *ctx = context->context(); cairo_t *ctx = context->context();
String::AsciiValue type(value->ToString()); String::Utf8Value type(value->ToString());
if (0 == strcmp("round", *type)) { if (0 == strcmp("round", *type)) {
cairo_set_line_join(ctx, CAIRO_LINE_JOIN_ROUND); cairo_set_line_join(ctx, CAIRO_LINE_JOIN_ROUND);
} else if (0 == strcmp("bevel", *type)) { } else if (0 == strcmp("bevel", *type)) {
@ -1143,7 +1143,7 @@ NAN_GETTER(Context2d::GetLineCap) {
NAN_SETTER(Context2d::SetLineCap) { NAN_SETTER(Context2d::SetLineCap) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_t *ctx = context->context(); cairo_t *ctx = context->context();
String::AsciiValue type(value->ToString()); String::Utf8Value type(value->ToString());
if (0 == strcmp("round", *type)) { if (0 == strcmp("round", *type)) {
cairo_set_line_cap(ctx, CAIRO_LINE_CAP_ROUND); cairo_set_line_cap(ctx, CAIRO_LINE_CAP_ROUND);
} else if (0 == strcmp("square", *type)) { } else if (0 == strcmp("square", *type)) {
@ -1166,7 +1166,7 @@ NAN_METHOD(Context2d::IsPointInPath) {
, y = args[1]->NumberValue(); , y = args[1]->NumberValue();
NanReturnValue(NanNew<Boolean>(cairo_in_fill(ctx, x, y) || cairo_in_stroke(ctx, x, y))); NanReturnValue(NanNew<Boolean>(cairo_in_fill(ctx, x, y) || cairo_in_stroke(ctx, x, y)));
} }
NanReturnValue(False()); NanReturnValue(NanFalse());
} }
/* /*
@ -1220,7 +1220,7 @@ NAN_METHOD(Context2d::SetStrokePattern) {
NAN_SETTER(Context2d::SetShadowColor) { NAN_SETTER(Context2d::SetShadowColor) {
short ok; short ok;
String::AsciiValue str(value->ToString()); String::Utf8Value str(value->ToString());
uint32_t rgba = rgba_from_string(*str, &ok); uint32_t rgba = rgba_from_string(*str, &ok);
if (ok) { if (ok) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
@ -1248,7 +1248,7 @@ NAN_METHOD(Context2d::SetFillColor) {
NanScope(); NanScope();
short ok; short ok;
if (!args[0]->IsString()) NanReturnUndefined(); if (!args[0]->IsString()) NanReturnUndefined();
String::AsciiValue str(args[0]); String::Utf8Value str(args[0]);
uint32_t rgba = rgba_from_string(*str, &ok); uint32_t rgba = rgba_from_string(*str, &ok);
if (!ok) NanReturnUndefined(); if (!ok) NanReturnUndefined();
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
@ -1277,7 +1277,7 @@ NAN_METHOD(Context2d::SetStrokeColor) {
NanScope(); NanScope();
short ok; short ok;
if (!args[0]->IsString()) NanReturnUndefined(); if (!args[0]->IsString()) NanReturnUndefined();
String::AsciiValue str(args[0]); String::Utf8Value str(args[0]);
uint32_t rgba = rgba_from_string(*str, &ok); uint32_t rgba = rgba_from_string(*str, &ok);
if (!ok) NanReturnUndefined(); if (!ok) NanReturnUndefined();
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
@ -1763,11 +1763,11 @@ NAN_METHOD(Context2d::SetFont) {
|| !args[3]->IsString() || !args[3]->IsString()
|| !args[4]->IsString()) NanReturnUndefined(); || !args[4]->IsString()) NanReturnUndefined();
String::AsciiValue weight(args[0]); String::Utf8Value weight(args[0]);
String::AsciiValue style(args[1]); String::Utf8Value style(args[1]);
double size = args[2]->NumberValue(); double size = args[2]->NumberValue();
String::AsciiValue unit(args[3]); String::Utf8Value unit(args[3]);
String::AsciiValue family(args[4]); String::Utf8Value family(args[4]);
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());

4
src/FontFace.cc

@ -6,7 +6,7 @@
#include "FontFace.h" #include "FontFace.h"
#include "nan.h" #include <nan.h>
Persistent<FunctionTemplate> FontFace::constructor; Persistent<FunctionTemplate> FontFace::constructor;
@ -60,7 +60,7 @@ NAN_METHOD(FontFace::New) {
return NanThrowError("Wrong argument types passed to FontFace constructor"); return NanThrowError("Wrong argument types passed to FontFace constructor");
} }
String::AsciiValue filePath(args[0]); String::Utf8Value filePath(args[0]);
int faceIdx = int(args[1]->NumberValue()); int faceIdx = int(args[1]->NumberValue());
FT_Face ftFace; FT_Face ftFace;

2
src/Image.cc

@ -175,7 +175,7 @@ NAN_SETTER(Image::SetSource) {
// url string // url string
if (value->IsString()) { if (value->IsString()) {
String::AsciiValue src(value); String::Utf8Value src(value);
if (img->filename) free(img->filename); if (img->filename) free(img->filename);
img->filename = strdup(*src); img->filename = strdup(*src);
status = img->load(); status = img->load();

2
src/Image.h

@ -8,7 +8,7 @@
#ifndef __NODE_IMAGE_H__ #ifndef __NODE_IMAGE_H__
#define __NODE_IMAGE_H__ #define __NODE_IMAGE_H__
#include "nan.h" #include <nan.h>
#include "Canvas.h" #include "Canvas.h"
#ifdef HAVE_JPEG #ifdef HAVE_JPEG

16
src/JPEGStream.h

@ -6,7 +6,7 @@
#ifndef __NODE_JPEG_STREAM_H__ #ifndef __NODE_JPEG_STREAM_H__
#define __NODE_JPEG_STREAM_H__ #define __NODE_JPEG_STREAM_H__
#include "nan.h" #include <nan.h>
#include "Canvas.h" #include "Canvas.h"
#include <jpeglib.h> #include <jpeglib.h>
#include <jerror.h> #include <jerror.h>
@ -38,7 +38,7 @@ empty_closure_output_buffer(j_compress_ptr cinfo){
, NanNew<Value>(buf) , NanNew<Value>(buf)
, NanNew<Integer>(dest->bufsize) , NanNew<Integer>(dest->bufsize)
}; };
NanMakeCallback(NanGetCurrentContext(), dest->closure->fn, 3, argv); NanMakeCallback(NanGetCurrentContext()->Global(), dest->closure->fn, 3, argv);
cinfo->dest->next_output_byte = dest->buffer; cinfo->dest->next_output_byte = dest->buffer;
cinfo->dest->free_in_buffer = dest->bufsize; cinfo->dest->free_in_buffer = dest->bufsize;
return true; return true;
@ -53,21 +53,21 @@ term_closure_destination(j_compress_ptr cinfo){
Local<Object> buf = NanNewBufferHandle((char *)dest->buffer, remaining); Local<Object> buf = NanNewBufferHandle((char *)dest->buffer, remaining);
Local<Value> data_argv[3] = { Local<Value> data_argv[3] = {
NanNull() NanNew(NanNull())
, NanNew<Value>(buf) , NanNew(buf)
, NanNew<Integer>(remaining) , NanNew<Integer>(remaining)
}; };
NanMakeCallback(NanGetCurrentContext(), dest->closure->fn, 3, data_argv); NanMakeCallback(NanGetCurrentContext()->Global(), dest->closure->fn, 3, data_argv);
// emit "end" // emit "end"
Local<Value> end_argv[3] = { Local<Value> end_argv[3] = {
NanNull() NanNew(NanNull())
, NanNull() , NanNew(NanNull())
, NanNew<Integer>(0) , NanNew<Integer>(0)
}; };
NanMakeCallback(NanGetCurrentContext(), dest->closure->fn, 3, end_argv); NanMakeCallback(NanGetCurrentContext()->Global(), dest->closure->fn, 3, end_argv);
} }
void void

2
src/PixelArray.cc

@ -9,7 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "nan.h" #include <nan.h>
Persistent<FunctionTemplate> PixelArray::constructor; Persistent<FunctionTemplate> PixelArray::constructor;

4
src/closure.h

@ -16,7 +16,7 @@
#define PAGE_SIZE 4096 #define PAGE_SIZE 4096
#endif #endif
#include "nan.h" #include <nan.h>
/* /*
* PNG stream closure. * PNG stream closure.
@ -58,7 +58,7 @@ void
closure_destroy(closure_t *closure) { closure_destroy(closure_t *closure) {
if (closure->len) { if (closure->len) {
free(closure->data); free(closure->data);
NanAdjustExternalMemory(- (intptr_t) closure->max_len); NanAdjustExternalMemory(-((intptr_t) closure->max_len));
} }
} }

Loading…
Cancel
Save