Skip to content

Fix 2.0 regression, warnings, v8 memory dealloc hint #917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Canvas: public Nan::ObjectWrap {

inline uint8_t *data(){ return cairo_image_surface_get_data(surface()); }
inline int stride(){ return cairo_image_surface_get_stride(surface()); }
inline int nBytes(){ return backend()->getWidth() * stride(); }
inline int nBytes(){ return getHeight() * stride(); }

inline int getWidth() { return backend()->getWidth(); }
inline int getHeight() { return backend()->getHeight(); }
Expand Down
4 changes: 2 additions & 2 deletions src/CanvasRenderingContext2d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,8 @@ NAN_METHOD(Context2d::GetImageData) {
Local<Int32> shHandle = Nan::New(sh);
Local<Value> argv[argc] = { clampedArray, swHandle, shHandle };

Local<Function> constructor = Nan::GetFunction(Nan::New(ImageData::constructor)).ToLocalChecked();
Local<Object> instance = Nan::NewInstance(constructor, argc, argv).ToLocalChecked();
Local<Function> ctor = Nan::GetFunction(Nan::New(ImageData::constructor)).ToLocalChecked();
Local<Object> instance = Nan::NewInstance(ctor, argc, argv).ToLocalChecked();

info.GetReturnValue().Set(instance);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ Image::decodeJPEGBufferIntoMimeSurface(uint8_t *buf, unsigned len) {

void
clearMimeData(void *closure) {
Nan::AdjustExternalMemory(-((read_closure_t *)closure)->len);
Nan::AdjustExternalMemory(-static_cast<int>(((read_closure_t *)closure)->len));
free(((read_closure_t *) closure)->buf);
free(closure);
}
Expand Down
12 changes: 6 additions & 6 deletions src/backend/Backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Backend::~Backend()
}


void Backend::setCanvas(Canvas* canvas)
void Backend::setCanvas(Canvas* _canvas)
{
this->canvas = canvas;
this->canvas = _canvas;
}


Expand Down Expand Up @@ -53,19 +53,19 @@ int Backend::getWidth()
{
return this->width;
}
void Backend::setWidth(int width)
void Backend::setWidth(int width_)
{
this->width = width;
this->width = width_;
this->recreateSurface();
}

int Backend::getHeight()
{
return this->height;
}
void Backend::setHeight(int height)
void Backend::setHeight(int height_)
{
this->height = height;
this->height = height_;
this->recreateSurface();
}

Expand Down
4 changes: 2 additions & 2 deletions src/toBuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

cairo_status_t
toBuffer(void *c, const uint8_t *data, unsigned len) {
toBuffer(void *c, const uint8_t *odata, unsigned len) {
closure_t *closure = (closure_t *) c;

if (closure->len + len > closure->max_len) {
Expand All @@ -26,7 +26,7 @@ toBuffer(void *c, const uint8_t *data, unsigned len) {
closure->max_len = max;
}

memcpy(closure->data + closure->len, data, len);
memcpy(closure->data + closure->len, odata, len);
closure->len += len;

return CAIRO_STATUS_SUCCESS;
Expand Down
26 changes: 13 additions & 13 deletions test/canvas.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Canvas', function () {
});

it('.version', function () {
assert.ok(/^\d+\.\d+\.\d+$/.test(Canvas.version));
assert.ok(/^\d+\.\d+\.\d+(-(alpha|beta)\.\d+)?$/.test(Canvas.version));
});

it('.cairoVersion', function () {
Expand Down Expand Up @@ -386,10 +386,10 @@ describe('Canvas', function () {
});

describe('#toBuffer("raw")', function() {
var canvas = new Canvas(10, 10)
var canvas = new Canvas(11, 10)
, ctx = canvas.getContext('2d');

ctx.clearRect(0, 0, 10, 10);
ctx.clearRect(0, 0, 11, 10);

ctx.fillStyle = 'rgba(200, 200, 200, 0.505)';
ctx.fillRect(0, 0, 5, 5);
Expand All @@ -404,16 +404,16 @@ describe('Canvas', function () {
ctx.fillRect(5, 5, 4, 5);

/** Output:
* *****RRRRR
* *****RRRRR
* *****RRRRR
* *****RRRRR
* *****RRRRR
* GGGGGBBBB-
* GGGGGBBBB-
* GGGGGBBBB-
* GGGGGBBBB-
* GGGGGBBBB-
* *****RRRRR-
* *****RRRRR-
* *****RRRRR-
* *****RRRRR-
* *****RRRRR-
* GGGGGBBBB--
* GGGGGBBBB--
* GGGGGBBBB--
* GGGGGBBBB--
* GGGGGBBBB--
*/

var buf = canvas.toBuffer('raw');
Expand Down