Browse Source

Remove unused fields in Pattern class

v1.x
rhysd 9 years ago
parent
commit
a14dd69430
  1. 11
      src/CanvasPattern.cc
  2. 3
      src/CanvasPattern.h

11
src/CanvasPattern.cc

@ -41,8 +41,6 @@ NAN_METHOD(Pattern::New) {
return Nan::ThrowTypeError("Class constructors cannot be invoked without 'new'"); return Nan::ThrowTypeError("Class constructors cannot be invoked without 'new'");
} }
int w = 0
, h = 0;
cairo_surface_t *surface; cairo_surface_t *surface;
Local<Object> obj = info[0]->ToObject(); Local<Object> obj = info[0]->ToObject();
@ -53,15 +51,11 @@ NAN_METHOD(Pattern::New) {
if (!img->isComplete()) { if (!img->isComplete()) {
return Nan::ThrowError("Image given has not completed loading"); return Nan::ThrowError("Image given has not completed loading");
} }
w = img->width;
h = img->height;
surface = img->surface(); surface = img->surface();
// Canvas // Canvas
} else if (Nan::New(Canvas::constructor)->HasInstance(obj)) { } else if (Nan::New(Canvas::constructor)->HasInstance(obj)) {
Canvas *canvas = Nan::ObjectWrap::Unwrap<Canvas>(obj); Canvas *canvas = Nan::ObjectWrap::Unwrap<Canvas>(obj);
w = canvas->width;
h = canvas->height;
surface = canvas->surface(); surface = canvas->surface();
// Invalid // Invalid
@ -69,7 +63,7 @@ NAN_METHOD(Pattern::New) {
return Nan::ThrowTypeError("Image or Canvas expected"); return Nan::ThrowTypeError("Image or Canvas expected");
} }
Pattern *pattern = new Pattern(surface,w,h); Pattern *pattern = new Pattern(surface);
pattern->Wrap(info.This()); pattern->Wrap(info.This());
info.GetReturnValue().Set(info.This()); info.GetReturnValue().Set(info.This());
} }
@ -79,8 +73,7 @@ NAN_METHOD(Pattern::New) {
* Initialize linear gradient. * Initialize linear gradient.
*/ */
Pattern::Pattern(cairo_surface_t *surface, int w, int h): Pattern::Pattern(cairo_surface_t *surface) {
_width(w), _height(h) {
_pattern = cairo_pattern_create_for_surface(surface); _pattern = cairo_pattern_create_for_surface(surface);
} }

3
src/CanvasPattern.h

@ -15,12 +15,11 @@ class Pattern: public Nan::ObjectWrap {
static Nan::Persistent<FunctionTemplate> constructor; static Nan::Persistent<FunctionTemplate> constructor;
static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target); static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
static NAN_METHOD(New); static NAN_METHOD(New);
Pattern(cairo_surface_t *surface, int w, int h); Pattern(cairo_surface_t *surface);
inline cairo_pattern_t *pattern(){ return _pattern; } inline cairo_pattern_t *pattern(){ return _pattern; }
private: private:
~Pattern(); ~Pattern();
int _width, _height;
// TODO REPEAT/REPEAT_X/REPEAT_Y // TODO REPEAT/REPEAT_X/REPEAT_Y
cairo_pattern_t *_pattern; cairo_pattern_t *_pattern;
}; };

Loading…
Cancel
Save