Skip to content
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
4 changes: 2 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
'WarningLevel': 4,
'ExceptionHandling': 1,
'DisableSpecificWarnings': [
4100, 4127, 4201, 4244, 4267, 4506, 4611, 4714, 4512
4100, 4611
]
}
}
Expand All @@ -116,7 +116,7 @@
'WarningLevel': 4,
'ExceptionHandling': 1,
'DisableSpecificWarnings': [
4100, 4127, 4201, 4244, 4267, 4506, 4611, 4714, 4512
4100, 4611
]
}
}
Expand Down
10 changes: 3 additions & 7 deletions src/Backends.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#ifndef __NODE_BACKENDS_H__
#define __NODE_BACKENDS_H__

#include <nan.h>
#pragma once

#include "backend/Backend.h"

#include <nan.h>
#include <v8.h>

class Backends : public Nan::ObjectWrap {
public:
static void Initialize(v8::Handle<v8::Object> target);
};

#endif
38 changes: 19 additions & 19 deletions src/Canvas.cc
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
//
// Canvas.cc
//
// Copyright (c) 2010 LearnBoost <[email protected]>
//

#include "Canvas.h"

#include <algorithm> // std::min
#include <assert.h>
#include <stdlib.h>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <unordered_set>
#include <node_buffer.h>
#include <node_version.h>
#include <glib.h>
#include <cairo-pdf.h>
#include <cairo-svg.h>
#include <ctime>
#include "Util.h"
#include "Canvas.h"
#include "PNG.h"
#include "CanvasRenderingContext2d.h"
#include "closure.h"
#include <cstring>
#include <cctype>
#include <ctime>
#include <glib.h>
#include "PNG.h"
#include "register_font.h"
#include <sstream>
#include <stdlib.h>
#include <string>
#include <unordered_set>
#include "Util.h"
#include <vector>

#ifdef HAVE_JPEG
#include "JPEGStream.h"
Expand All @@ -37,6 +34,9 @@
"with at least a family (string) and optionally weight (string/number) " \
"and style (string)."

using namespace v8;
using namespace std;

Nan::Persistent<FunctionTemplate> Canvas::constructor;

std::vector<FontFace> font_face_list;
Expand Down Expand Up @@ -305,7 +305,7 @@ static void parseJPEGArgs(Local<Value> arg, JpegClosure& jpegargs) {
static uint32_t getSafeBufSize(Canvas* canvas) {
// Don't allow the buffer size to exceed the size of the canvas (#674)
// TODO not sure if this is really correct, but it fixed #674
return min(canvas->getWidth() * canvas->getHeight() * 4, static_cast<int>(PAGE_SIZE));
return (std::min)(canvas->getWidth() * canvas->getHeight() * 4, static_cast<int>(PAGE_SIZE));
}

#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 16, 0)
Expand Down Expand Up @@ -377,7 +377,7 @@ NAN_METHOD(Canvas::ToBuffer) {
Canvas *canvas = Nan::ObjectWrap::Unwrap<Canvas>(info.This());

// Vector canvases, sync only
const string name = canvas->backend()->getName();
const std::string name = canvas->backend()->getName();
if (name == "pdf" || name == "svg") {
// mime type may be present, but it's not checked
PdfSvgClosure* closure;
Expand Down
33 changes: 9 additions & 24 deletions src/Canvas.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@

//
// Canvas.h
//
// Copyright (c) 2010 LearnBoost <[email protected]>
//

#ifndef __NODE_CANVAS_H__
#define __NODE_CANVAS_H__
#pragma once

#include <node.h>
#include <v8.h>
#include <node_object_wrap.h>
#include <node_version.h>
#include <pango/pangocairo.h>
#include "backend/Backend.h"
#include <cairo.h>
#include <nan.h>

#include "dll_visibility.h"
#include "backend/Backend.h"


using namespace node;
using namespace v8;
#include <nan.h>
#include <pango/pangocairo.h>
#include <v8.h>
#include <vector>

/*
* Maxmimum states per context.
Expand All @@ -48,7 +35,7 @@ class FontFace {

class Canvas: public Nan::ObjectWrap {
public:
static Nan::Persistent<FunctionTemplate> constructor;
static Nan::Persistent<v8::FunctionTemplate> constructor;
static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
static NAN_METHOD(New);
static NAN_METHOD(ToBuffer);
Expand All @@ -62,7 +49,7 @@ class Canvas: public Nan::ObjectWrap {
static NAN_METHOD(StreamPDFSync);
static NAN_METHOD(StreamJPEGSync);
static NAN_METHOD(RegisterFont);
static Local<Value> Error(cairo_status_t status);
static v8::Local<v8::Value> Error(cairo_status_t status);
static void ToPngBufferAsync(uv_work_t *req);
static void ToJpegBufferAsync(uv_work_t *req);
static void ToBufferAsyncAfter(uv_work_t *req);
Expand All @@ -82,11 +69,9 @@ class Canvas: public Nan::ObjectWrap {
DLL_PUBLIC inline int getHeight() { return backend()->getHeight(); }

Canvas(Backend* backend);
void resurface(Local<Object> canvas);
void resurface(v8::Local<v8::Object> canvas);

private:
~Canvas();
Backend* _backend;
};

#endif
13 changes: 5 additions & 8 deletions src/CanvasError.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __CANVAS_ERROR_H__
#define __CANVAS_ERROR_H__
#pragma once

#include <string>

Expand All @@ -9,11 +8,11 @@ class CanvasError {
std::string syscall;
std::string path;
int cerrno = 0;
void set(char *iMessage = NULL, char *iSyscall = NULL, int iErrno = 0, char *iPath = NULL) {
if (iMessage) message = std::string(iMessage);
if (iSyscall) syscall = std::string(iSyscall);
void set(const char* iMessage = NULL, const char* iSyscall = NULL, int iErrno = 0, const char* iPath = NULL) {
if (iMessage) message.assign(iMessage);
if (iSyscall) syscall.assign(iSyscall);
cerrno = iErrno;
if (iPath) path = std::string(iPath);
if (iPath) path.assign(iPath);
}
void reset() {
message.clear();
Expand All @@ -22,5 +21,3 @@ class CanvasError {
cerrno = 0;
}
};

#endif
12 changes: 5 additions & 7 deletions src/CanvasGradient.cc
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//
// Gradient.cc
//
// Copyright (c) 2010 LearnBoost <[email protected]>
//

#include "color.h"
#include "Canvas.h"
#include "CanvasGradient.h"

#include "Canvas.h"
#include "color.h"

using namespace v8;

Nan::Persistent<FunctionTemplate> Gradient::constructor;

/*
Expand Down
16 changes: 5 additions & 11 deletions src/CanvasGradient.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@

//
// CanvasGradient.h
//
// Copyright (c) 2010 LearnBoost <[email protected]>
//

#ifndef __NODE_GRADIENT_H__
#define __NODE_GRADIENT_H__
#pragma once

#include "Canvas.h"
#include <nan.h>
#include <v8.h>
#include <cairo.h>

class Gradient: public Nan::ObjectWrap {
public:
static Nan::Persistent<FunctionTemplate> constructor;
static Nan::Persistent<v8::FunctionTemplate> constructor;
static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
static NAN_METHOD(New);
static NAN_METHOD(AddColorStop);
Expand All @@ -24,5 +20,3 @@ class Gradient: public Nan::ObjectWrap {
~Gradient();
cairo_pattern_t *_pattern;
};

#endif
10 changes: 4 additions & 6 deletions src/CanvasPattern.cc
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@

//
// Pattern.cc
//
// Copyright (c) 2010 LearnBoost <[email protected]>
//

#include "CanvasPattern.h"

#include "Canvas.h"
#include "Image.h"
#include "CanvasPattern.h"

using namespace v8;

const cairo_user_data_key_t *pattern_repeat_key;

Expand Down
16 changes: 5 additions & 11 deletions src/CanvasPattern.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@

//
// CanvasPattern.h
//
// Copyright (c) 2011 LearnBoost <[email protected]>
//

#ifndef __NODE_PATTERN_H__
#define __NODE_PATTERN_H__
#pragma once

#include "Canvas.h"
#include <cairo.h>
#include <nan.h>
#include <v8.h>

/*
* Canvas types.
Expand All @@ -25,7 +21,7 @@ extern const cairo_user_data_key_t *pattern_repeat_key;

class Pattern: public Nan::ObjectWrap {
public:
static Nan::Persistent<FunctionTemplate> constructor;
static Nan::Persistent<v8::FunctionTemplate> constructor;
static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
static NAN_METHOD(New);
static repeat_type_t get_repeat_type_for_cairo_pattern(cairo_pattern_t *pattern);
Expand All @@ -36,5 +32,3 @@ class Pattern: public Nan::ObjectWrap {
cairo_pattern_t *_pattern;
repeat_type_t _repeat;
};

#endif
36 changes: 15 additions & 21 deletions src/CanvasRenderingContext2d.cc
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@

//
// CanvasRenderingContext2d.cc
//
// Copyright (c) 2010 LearnBoost <[email protected]>
//

#include "CanvasRenderingContext2d.h"

#include <algorithm>
#include "backend/ImageBackend.h"
#include <cairo/cairo-pdf.h>
#include "Canvas.h"
#include "CanvasGradient.h"
#include "CanvasPattern.h"
#include <cmath>
#include <cstdlib>
#include "Image.h"
#include "ImageData.h"
#include <limits>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#include "Util.h"
#include "Canvas.h"
#include "Point.h"
#include "Image.h"
#include "ImageData.h"
#include "CanvasRenderingContext2d.h"
#include "CanvasGradient.h"
#include "CanvasPattern.h"
#include "backend/ImageBackend.h"
#include <cairo/cairo-pdf.h>
#include <string>
#include "Util.h"
#include <vector>

using namespace v8;

// Windows doesn't support the C99 names for these
#ifdef _MSC_VER
Expand Down Expand Up @@ -1766,7 +1763,6 @@ NAN_GETTER(Context2d::GetFillStyle) {

NAN_SETTER(Context2d::SetFillStyle) {
Context2d *context = Nan::ObjectWrap::Unwrap<Context2d>(info.This());
Local<Context> ctx = Nan::GetCurrentContext();

if (Nan::New(Gradient::constructor)->HasInstance(value) ||
Nan::New(Pattern::constructor)->HasInstance(value)) {
Expand Down Expand Up @@ -1813,8 +1809,6 @@ NAN_GETTER(Context2d::GetStrokeStyle) {

NAN_SETTER(Context2d::SetStrokeStyle) {
Context2d *context = Nan::ObjectWrap::Unwrap<Context2d>(info.This());
Isolate *iso = Isolate::GetCurrent();
Local<Context> ctx = Nan::GetCurrentContext();

if (Nan::New(Gradient::constructor)->HasInstance(value) ||
Nan::New(Pattern::constructor)->HasInstance(value)) {
Expand Down
Loading