Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: gfx/canvas_skia.cc

Issue 3058012: Add support for Radial Gradient Brush and Bitmap Brush to gfx::Canvas.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gfx/canvas_skia.h ('k') | gfx/gfx.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gfx/canvas_skia.cc
===================================================================
--- gfx/canvas_skia.cc (revision 54142)
+++ gfx/canvas_skia.cc (working copy)
@@ -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 @@
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;
}
« no previous file with comments | « gfx/canvas_skia.h ('k') | gfx/gfx.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698