OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GFX_CANVAS_H_ | 5 #ifndef GFX_CANVAS_H_ |
6 #define GFX_CANVAS_H_ | 6 #define GFX_CANVAS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 TileMode_Mirror | 200 TileMode_Mirror |
201 }; | 201 }; |
202 | 202 |
203 // Creates a linear gradient brush. | 203 // Creates a linear gradient brush. |
204 // |start_point| and |end_point| are the pixel positions of the start and end | 204 // |start_point| and |end_point| are the pixel positions of the start and end |
205 // points of the gradient. | 205 // points of the gradient. |
206 // |colors| is a list of color stops. | 206 // |colors| is a list of color stops. |
207 // |positions| is a list of positions corresponding to the color stops, an | 207 // |positions| is a list of positions corresponding to the color stops, an |
208 // array of floats of increasing value ranging from 0.0f to 1.0f. | 208 // array of floats of increasing value ranging from 0.0f to 1.0f. |
209 // |position_count| is the size of the |colors| and |positions| arrays. | 209 // |position_count| is the size of the |colors| and |positions| arrays. |
210 // |tile_mode| | 210 // |tile_mode| specifies how the gradient brush repeats outside its natural |
211 // Returns an encapsulated platform shader object which the caller must | 211 // bounds. |
212 // delete. | 212 // Returns an encapsulated platform brush object which the caller must delete. |
213 virtual Brush* CreateLinearGradientBrush( | 213 virtual Brush* CreateLinearGradientBrush( |
214 const gfx::Point& start_point, | 214 const gfx::Point& start_point, |
215 const gfx::Point& end_point, | 215 const gfx::Point& end_point, |
216 const SkColor colors[], | 216 const SkColor colors[], |
217 const float positions[], | 217 const float positions[], |
218 size_t position_count, | 218 size_t position_count, |
219 TileMode tile_mode) = 0; | 219 TileMode tile_mode) = 0; |
220 | 220 |
| 221 // Creates a radial gradient brush. |
| 222 // |center_point| is the center of the circle in the brush's coordinate space. |
| 223 // |radius| is the radius of the circle. |
| 224 // |colors| is a list of color stops. |
| 225 // |positions| is a list of positions corresponding to the color stops, an |
| 226 // array of floats of increasing value ranging from 0.0f to 1.0f. |
| 227 // |position_count| is the size of the |colors| and |positions| arrays. |
| 228 // |tile_mode| specifies how the gradient brush repeats outside its natural |
| 229 // bounds. |
| 230 // Returns an encapsulated platform brush object which the caller must delete. |
| 231 virtual Brush* CreateRadialGradientBrush( |
| 232 const gfx::Point& center_point, |
| 233 float radius, |
| 234 const SkColor colors[], |
| 235 const float positions[], |
| 236 size_t position_count, |
| 237 TileMode tile_mode) = 0; |
| 238 |
| 239 // Creates a bitmap brush. |
| 240 // |bitmap| is the bitmap to be used for the brush. |
| 241 // |tile_mode_x,y| - specifies how the brush tiles the areas beyond those |
| 242 // filled by its bitmap along each axis. |
| 243 // Returns an encapsulated platform brush object which the caller must delete. |
| 244 virtual Brush* CreateBitmapBrush( |
| 245 const SkBitmap& bitmap, |
| 246 TileMode tile_mode_x, |
| 247 TileMode tile_mode_y) = 0; |
| 248 |
221 // TODO(beng): remove this once we don't need to use any skia-specific methods | 249 // TODO(beng): remove this once we don't need to use any skia-specific methods |
222 // through this interface. | 250 // through this interface. |
223 // A quick and dirty way to obtain the underlying SkCanvas. | 251 // A quick and dirty way to obtain the underlying SkCanvas. |
224 virtual CanvasSkia* AsCanvasSkia() { return NULL; } | 252 virtual CanvasSkia* AsCanvasSkia() { return NULL; } |
225 virtual const CanvasSkia* AsCanvasSkia() const { return NULL; } | 253 virtual const CanvasSkia* AsCanvasSkia() const { return NULL; } |
226 }; | 254 }; |
227 | 255 |
228 class CanvasPaint { | 256 class CanvasPaint { |
229 public: | 257 public: |
230 virtual ~CanvasPaint() {} | 258 virtual ~CanvasPaint() {} |
231 | 259 |
232 // Creates a canvas that paints to |view| when it is destroyed. The canvas is | 260 // Creates a canvas that paints to |view| when it is destroyed. The canvas is |
233 // sized to the client area of |view|. | 261 // sized to the client area of |view|. |
234 static CanvasPaint* CreateCanvasPaint(gfx::NativeView view); | 262 static CanvasPaint* CreateCanvasPaint(gfx::NativeView view); |
235 | 263 |
236 // Returns true if the canvas has an invalid rect that needs to be repainted. | 264 // Returns true if the canvas has an invalid rect that needs to be repainted. |
237 virtual bool IsValid() const = 0; | 265 virtual bool IsValid() const = 0; |
238 | 266 |
239 // Returns the rectangle that is invalid. | 267 // Returns the rectangle that is invalid. |
240 virtual gfx::Rect GetInvalidRect() const = 0; | 268 virtual gfx::Rect GetInvalidRect() const = 0; |
241 | 269 |
242 // Returns the underlying Canvas. | 270 // Returns the underlying Canvas. |
243 virtual Canvas* AsCanvas() = 0; | 271 virtual Canvas* AsCanvas() = 0; |
244 }; | 272 }; |
245 | 273 |
246 } // namespace gfx; | 274 } // namespace gfx; |
247 | 275 |
248 #endif // GFX_CANVAS_H_ | 276 #endif // GFX_CANVAS_H_ |
OLD | NEW |