diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-23 22:23:59 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-23 22:23:59 +0000 |
commit | 0f4fe844bd7ca7f0fa512a2e786d9debb2831526 (patch) | |
tree | f803b71c036a9fb0286298a366e682f65325d58d /gfx/canvas.h | |
parent | 04dd9d9de68e20da43e7e2f13a550ea7c8ca6fa3 (diff) | |
download | chromium_src-0f4fe844bd7ca7f0fa512a2e786d9debb2831526.zip chromium_src-0f4fe844bd7ca7f0fa512a2e786d9debb2831526.tar.gz chromium_src-0f4fe844bd7ca7f0fa512a2e786d9debb2831526.tar.bz2 |
Add support for brushes to gfx::Canvas... right now just LinearGradientBrush.
A native brush is created by gfx::Canvas::CreateLinearGradientBrush wrapped in a gfx::Brush. When gfx::Brush is deleted the platform wrapper frees the native brush.
BUG=none
TEST=see unittest.
Review URL: http://codereview.chromium.org/3038019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53534 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx/canvas.h')
-rw-r--r-- | gfx/canvas.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gfx/canvas.h b/gfx/canvas.h index 49c67f2..d7f18fc 100644 --- a/gfx/canvas.h +++ b/gfx/canvas.h @@ -7,14 +7,17 @@ #include <string> +#include "gfx/brush.h" #include "gfx/native_widget_types.h" // TODO(beng): remove this include when we no longer depend on SkTypes. #include "skia/ext/platform_canvas.h" namespace gfx { +class Brush; class CanvasSkia; class Font; +class Point; class Rect; // TODO(beng): documentation. @@ -103,6 +106,10 @@ class Canvas { virtual void FillRectInt(const SkColor& color, int x, int y, int w, int h) = 0; + // Fills the specified region with the specified brush. + virtual void FillRectInt(const gfx::Brush* brush, int x, int y, int w, + int h) = 0; + // Draws a single pixel rect in the specified region with the specified // color, using a transfer mode of SkXfermode::kSrcOver_Mode. // @@ -185,6 +192,31 @@ class Canvas { // returned by BeginPlatformPaint(). virtual void EndPlatformPaint() = 0; + // Defines how a brush paints the area outside its normal content area. + enum TileMode { + TileMode_Clamp, + TileMode_Repeat, + TileMode_Mirror + }; + + // Creates a linear gradient brush. + // |start_point| and |end_point| are the pixel positions of the start and end + // points of the gradient. + // |colors| is a list of color stops. + // |positions| is a list of positions corresponding to the color stops, an + // array of floats of increasing value ranging from 0.0f to 1.0f. + // |position_count| is the size of the |colors| and |positions| arrays. + // |tile_mode| + // Returns an encapsulated platform shader object which the caller must + // delete. + virtual Brush* CreateLinearGradientBrush( + const gfx::Point& start_point, + const gfx::Point& end_point, + const SkColor colors[], + const float positions[], + size_t position_count, + TileMode tile_mode) = 0; + // TODO(beng): remove this once we don't need to use any skia-specific methods // through this interface. // A quick and dirty way to obtain the underlying SkCanvas. |