From d7b4eb6e2c5f373e76acbafdb881eedfc575295a Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Sat, 6 Nov 2010 11:25:33 -0700 Subject: [PATCH] Implemented shadow coloring --- src/CanvasRenderingContext2d.cc | 9 +++------ src/CanvasRenderingContext2d.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index 333f728..ba2b0b1 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -1052,21 +1052,18 @@ Context2d::FillRect(const Arguments &args) { return Undefined(); } + cairo_save(ctx); cairo_translate( ctx , context->state->shadowOffsetX , context->state->shadowOffsetY); cairo_rectangle(ctx, x, y, width, height); - SET_SOURCE(context->state->fill); + SET_SOURCE_RGBA(context->state->shadow); cairo_fill(ctx); Canvas::blur(context->getCanvas()->getSurface(), context->state->shadowBlur); - cairo_translate( - ctx - , -context->state->shadowOffsetX - , -context->state->shadowOffsetY); - + cairo_restore(ctx); context->restorePath(); cairo_fill(ctx); return Undefined(); diff --git a/src/CanvasRenderingContext2d.h b/src/CanvasRenderingContext2d.h index 2b65615..f9229ac 100644 --- a/src/CanvasRenderingContext2d.h +++ b/src/CanvasRenderingContext2d.h @@ -100,7 +100,7 @@ class Context2d: public node::ObjectWrap { static void SetShadowBlur(Local prop, Local val, const AccessorInfo &info); inline cairo_t *getContext(){ return _context; } inline Canvas *getCanvas(){ return _canvas; } - bool hasShadow(); + inline bool hasShadow(); void setTextPath(const char *str, double x, double y); void savePath(); void restorePath();