From 19fe22a1c69fbe7cda934b1b873aff8b24cf07e9 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 8 Nov 2010 09:39:10 -0800 Subject: [PATCH] Added Context2d::setSourceRGBA() --- src/CanvasRenderingContext2d.cc | 18 +++++++++++++++--- src/CanvasRenderingContext2d.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index b0c4db5..a7fa463 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -1069,13 +1069,11 @@ Context2d::FillRect(const Arguments &args) { } context->shadowStart(); - cairo_rectangle(ctx, x, y, width, height); - SET_SOURCE_RGBA(context->state->shadow); + context->setSourceRGBA(context->state->shadow); cairo_fill(ctx); context->shadowApply(); - cairo_rectangle(ctx, x, y, width, height); cairo_fill(ctx); return Undefined(); @@ -1195,6 +1193,20 @@ Context2d::Arc(const Arguments &args) { return Undefined(); } +/* + * Set source RGBA. + */ + +void +Context2d::setSourceRGBA(rgba_t color) { + cairo_set_source_rgba( + _context + , color.r + , color.g + , color.b + , color.a * state->globalAlpha); +} + /* * Start shadow context. */ diff --git a/src/CanvasRenderingContext2d.h b/src/CanvasRenderingContext2d.h index 2abcf2d..8f6ce9d 100644 --- a/src/CanvasRenderingContext2d.h +++ b/src/CanvasRenderingContext2d.h @@ -101,6 +101,7 @@ class Context2d: public node::ObjectWrap { inline cairo_t *getContext(){ return _context; } inline Canvas *getCanvas(){ return _canvas; } inline bool hasShadow(); + void inline setSourceRGBA(rgba_t color); void setTextPath(const char *str, double x, double y); void shadowStart(); void shadowApply();