OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_GFX_CANVAS_H_ | 5 #ifndef UI_GFX_CANVAS_H_ |
6 #define UI_GFX_CANVAS_H_ | 6 #define UI_GFX_CANVAS_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 int src_y, | 313 int src_y, |
314 int src_w, | 314 int src_w, |
315 int src_h, | 315 int src_h, |
316 int dest_x, | 316 int dest_x, |
317 int dest_y, | 317 int dest_y, |
318 int dest_w, | 318 int dest_w, |
319 int dest_h, | 319 int dest_h, |
320 bool filter, | 320 bool filter, |
321 const SkPaint& paint); | 321 const SkPaint& paint); |
322 | 322 |
| 323 // Same as the DrawImageInt functions above. Difference being this does not |
| 324 // do any scaling, i.e. it assumes that the source/destination/image, etc are |
| 325 // in pixels. It does translate the destination rectangle to ensure that the |
| 326 // image is displayed at the correct pixel coordinates. |
| 327 void DrawImageIntInPixel(const ImageSkia& image, |
| 328 int src_x, |
| 329 int src_y, |
| 330 int src_w, |
| 331 int src_h, |
| 332 int dest_x, |
| 333 int dest_y, |
| 334 int dest_w, |
| 335 int dest_h, |
| 336 bool filter, |
| 337 const SkPaint& paint); |
| 338 |
323 // Draws an |image| with the top left corner at |x| and |y|, clipped to | 339 // Draws an |image| with the top left corner at |x| and |y|, clipped to |
324 // |path|. | 340 // |path|. |
325 // Parameters are specified relative to current canvas scale not in pixels. | 341 // Parameters are specified relative to current canvas scale not in pixels. |
326 // Thus, x is 2 pixels if canvas scale = 2 & |x| = 1. | 342 // Thus, x is 2 pixels if canvas scale = 2 & |x| = 1. |
327 void DrawImageInPath(const ImageSkia& image, | 343 void DrawImageInPath(const ImageSkia& image, |
328 int x, | 344 int x, |
329 int y, | 345 int y, |
330 const SkPath& path, | 346 const SkPath& path, |
331 const SkPaint& paint); | 347 const SkPaint& paint); |
332 | 348 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 bool IntersectsClipRect(const Rect& rect); | 444 bool IntersectsClipRect(const Rect& rect); |
429 | 445 |
430 // Returns the image rep which best matches the canvas |image_scale_|. | 446 // Returns the image rep which best matches the canvas |image_scale_|. |
431 // Returns a null image rep if |image| contains no image reps. | 447 // Returns a null image rep if |image| contains no image reps. |
432 // Builds mip map for returned image rep if necessary. | 448 // Builds mip map for returned image rep if necessary. |
433 // | 449 // |
434 // An optional additional user defined scale can be provided. | 450 // An optional additional user defined scale can be provided. |
435 const ImageSkiaRep& GetImageRepToPaint(const ImageSkia& image) const; | 451 const ImageSkiaRep& GetImageRepToPaint(const ImageSkia& image) const; |
436 const ImageSkiaRep& GetImageRepToPaint( | 452 const ImageSkiaRep& GetImageRepToPaint( |
437 const ImageSkia& image, | 453 const ImageSkia& image, |
| 454 float image_scale, |
438 float user_defined_scale_factor_x, | 455 float user_defined_scale_factor_x, |
439 float user_defined_scale_factor_y) const; | 456 float user_defined_scale_factor_y) const; |
440 | 457 |
| 458 // Helper for the DrawImageInt functions declared above. The |pixel| |
| 459 // parameter if true indicates that the bounds and the image are to |
| 460 // be assumed to be in pixels, i.e. no scaling needs to be performed. |
| 461 void DrawImageIntHelper(const ImageSkia& image, |
| 462 int src_x, |
| 463 int src_y, |
| 464 int src_w, |
| 465 int src_h, |
| 466 int dest_x, |
| 467 int dest_y, |
| 468 int dest_w, |
| 469 int dest_h, |
| 470 bool filter, |
| 471 const SkPaint& paint, |
| 472 float image_scale, |
| 473 bool pixel); |
| 474 |
441 // The device scale factor at which drawing on this canvas occurs. | 475 // The device scale factor at which drawing on this canvas occurs. |
442 // An additional scale can be applied via Canvas::Scale(). However, | 476 // An additional scale can be applied via Canvas::Scale(). However, |
443 // Canvas::Scale() does not affect |image_scale_|. | 477 // Canvas::Scale() does not affect |image_scale_|. |
444 float image_scale_; | 478 float image_scale_; |
445 | 479 |
446 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; | 480 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; |
447 SkCanvas* canvas_; | 481 SkCanvas* canvas_; |
448 | 482 |
449 DISALLOW_COPY_AND_ASSIGN(Canvas); | 483 DISALLOW_COPY_AND_ASSIGN(Canvas); |
450 }; | 484 }; |
451 | 485 |
452 } // namespace gfx | 486 } // namespace gfx |
453 | 487 |
454 #endif // UI_GFX_CANVAS_H_ | 488 #endif // UI_GFX_CANVAS_H_ |
OLD | NEW |