diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-29 18:17:04 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-29 18:17:04 +0000 |
commit | 2caf4d005cb3b86b61ae559f08f2493e19129e3f (patch) | |
tree | 95e9eb1d2ec77fc179f5fdc26573db1449a5afb4 /gfx/canvas_skia.cc | |
parent | 797794bd42c10ff1dfecc25f91ec32a17d991b15 (diff) | |
download | chromium_src-2caf4d005cb3b86b61ae559f08f2493e19129e3f.zip chromium_src-2caf4d005cb3b86b61ae559f08f2493e19129e3f.tar.gz chromium_src-2caf4d005cb3b86b61ae559f08f2493e19129e3f.tar.bz2 |
Add support for Radial Gradient Brush and Bitmap Brush to gfx::Canvas.
BUG=none
TEST=see unittest
Review URL: http://codereview.chromium.org/3058012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx/canvas_skia.cc')
-rw-r--r-- | gfx/canvas_skia.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gfx/canvas_skia.cc b/gfx/canvas_skia.cc index fbdc0a9..f2c344c 100644 --- a/gfx/canvas_skia.cc +++ b/gfx/canvas_skia.cc @@ -18,6 +18,12 @@ namespace { +SkPoint PointToSkPoint(const gfx::Point point) { + SkPoint sk_point; + sk_point.set(SkIntToScalar(point.x()), SkIntToScalar(point.y())); + return sk_point; +} + SkShader::TileMode TileModeToSkShaderTileMode(gfx::Canvas::TileMode tile_mode) { switch (tile_mode) { case gfx::Canvas::TileMode_Clamp: @@ -364,6 +370,34 @@ Brush* CanvasSkia::CreateLinearGradientBrush( return new SkiaShader(shader); } +Brush* CanvasSkia::CreateRadialGradientBrush( + const gfx::Point& center_point, + float radius, + const SkColor colors[], + const float positions[], + size_t position_count, + TileMode tile_mode) { + SkShader* shader = SkGradientShader::CreateRadial( + PointToSkPoint(center_point), + radius, + colors, + positions, + position_count, + TileModeToSkShaderTileMode(tile_mode)); + return new SkiaShader(shader); +} + +Brush* CanvasSkia::CreateBitmapBrush( + const SkBitmap& bitmap, + TileMode tile_mode_x, + TileMode tile_mode_y) { + SkShader* shader = SkShader::CreateBitmapShader( + bitmap, + TileModeToSkShaderTileMode(tile_mode_x), + TileModeToSkShaderTileMode(tile_mode_y)); + return new SkiaShader(shader); +} + CanvasSkia* CanvasSkia::AsCanvasSkia() { return this; } |