From 047c0683929c6d3befe012d65c8c8e9f9e3fa577 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Sat, 6 Nov 2010 11:04:54 -0700 Subject: [PATCH] Shadow related props within state --- src/CanvasRenderingContext2d.cc | 16 ++++++++-------- src/CanvasRenderingContext2d.h | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index fb8f17a..e6859c3 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -153,8 +153,8 @@ Context2d::Context2d(Canvas *canvas): ObjectWrap() { _canvas = canvas; _context = cairo_create(canvas->getSurface()); cairo_set_line_width(_context, 1); - shadowBlur = shadowOffsetX = shadowOffsetY = 0; state = states[stateno = 0] = (canvas_state_t *) malloc(sizeof(canvas_state_t)); + state->shadowBlur = state->shadowOffsetX = state->shadowOffsetY = 0; state->globalAlpha = 1; state->textAlignment = -1; state->fillPattern = state->strokePattern = NULL; @@ -305,7 +305,7 @@ Context2d::SetGlobalCompositeOperation(Local prop, Local val, con Handle Context2d::GetShadowOffsetX(Local prop, const AccessorInfo &info) { Context2d *context = ObjectWrap::Unwrap(info.This()); - return Number::New(context->shadowOffsetX); + return Number::New(context->state->shadowOffsetX); } /* @@ -315,7 +315,7 @@ Context2d::GetShadowOffsetX(Local prop, const AccessorInfo &info) { void Context2d::SetShadowOffsetX(Local prop, Local val, const AccessorInfo &info) { Context2d *context = ObjectWrap::Unwrap(info.This()); - context->shadowOffsetX = val->NumberValue(); + context->state->shadowOffsetX = val->NumberValue(); } /* @@ -325,7 +325,7 @@ Context2d::SetShadowOffsetX(Local prop, Local val, const Accessor Handle Context2d::GetShadowOffsetY(Local prop, const AccessorInfo &info) { Context2d *context = ObjectWrap::Unwrap(info.This()); - return Number::New(context->shadowOffsetY); + return Number::New(context->state->shadowOffsetY); } /* @@ -335,7 +335,7 @@ Context2d::GetShadowOffsetY(Local prop, const AccessorInfo &info) { void Context2d::SetShadowOffsetY(Local prop, Local val, const AccessorInfo &info) { Context2d *context = ObjectWrap::Unwrap(info.This()); - context->shadowOffsetY = val->NumberValue(); + context->state->shadowOffsetY = val->NumberValue(); } /* @@ -345,7 +345,7 @@ Context2d::SetShadowOffsetY(Local prop, Local val, const Accessor Handle Context2d::GetShadowBlur(Local prop, const AccessorInfo &info) { Context2d *context = ObjectWrap::Unwrap(info.This()); - return Number::New(context->shadowBlur); + return Number::New(context->state->shadowBlur); } /* @@ -357,7 +357,7 @@ Context2d::SetShadowBlur(Local prop, Local val, const AccessorInf double n = val->NumberValue(); if (n > 0) { Context2d *context = ObjectWrap::Unwrap(info.This()); - context->shadowBlur = n; + context->state->shadowBlur = n; } } @@ -531,7 +531,7 @@ Context2d::SetShadowRGBA(const Arguments &args) { HandleScope scope; RGBA_ARGS(0); Context2d *context = ObjectWrap::Unwrap(args.This()); - RGBA(context->shadow,r,g,b,a); + RGBA(context->state->shadow,r,g,b,a); return Undefined(); } diff --git a/src/CanvasRenderingContext2d.h b/src/CanvasRenderingContext2d.h index b468537..2cd10e9 100644 --- a/src/CanvasRenderingContext2d.h +++ b/src/CanvasRenderingContext2d.h @@ -34,6 +34,10 @@ typedef struct { float globalAlpha; short textAlignment; short textBaseline; + rgba_t shadow; + double shadowBlur; + double shadowOffsetX; + double shadowOffsetY; } canvas_state_t; class Context2d: public node::ObjectWrap { @@ -41,10 +45,6 @@ class Context2d: public node::ObjectWrap { short stateno; canvas_state_t *states[CANVAS_MAX_STATES]; canvas_state_t *state; - rgba_t shadow; - double shadowBlur; - double shadowOffsetX; - double shadowOffsetY; static void Initialize(Handle target); static Handle New(const Arguments &args); static Handle Save(const Arguments &args);