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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 // Apply transformation on the canvas. | 402 // Apply transformation on the canvas. |
403 void Transform(const Transform& transform); | 403 void Transform(const Transform& transform); |
404 | 404 |
405 // Draws the given string with a fade gradient at the end. | 405 // Draws the given string with a fade gradient at the end. |
406 void DrawFadedString(const base::string16& text, | 406 void DrawFadedString(const base::string16& text, |
407 const FontList& font_list, | 407 const FontList& font_list, |
408 SkColor color, | 408 SkColor color, |
409 const Rect& display_rect, | 409 const Rect& display_rect, |
410 int flags); | 410 int flags); |
411 | 411 |
412 skia::PlatformCanvas* platform_canvas() { return owned_canvas_.get(); } | 412 SkCanvas* platform_canvas() { return owned_canvas_.get(); } |
413 SkCanvas* sk_canvas() { return canvas_; } | 413 SkCanvas* sk_canvas() { return canvas_; } |
414 float image_scale() const { return image_scale_; } | 414 float image_scale() const { return image_scale_; } |
415 | 415 |
416 private: | 416 private: |
417 // Test whether the provided rectangle intersects the current clip rect. | 417 // Test whether the provided rectangle intersects the current clip rect. |
418 bool IntersectsClipRectInt(int x, int y, int w, int h); | 418 bool IntersectsClipRectInt(int x, int y, int w, int h); |
419 bool IntersectsClipRect(const Rect& rect); | 419 bool IntersectsClipRect(const Rect& rect); |
420 | 420 |
421 // Helper for the DrawImageInt functions declared above. The | 421 // Helper for the DrawImageInt functions declared above. The |
422 // |remove_image_scale| parameter indicates if the scale of the |image_rep| | 422 // |remove_image_scale| parameter indicates if the scale of the |image_rep| |
423 // should be removed when drawing the image, to avoid double-scaling it. | 423 // should be removed when drawing the image, to avoid double-scaling it. |
424 void DrawImageIntHelper(const ImageSkiaRep& image_rep, | 424 void DrawImageIntHelper(const ImageSkiaRep& image_rep, |
425 int src_x, | 425 int src_x, |
426 int src_y, | 426 int src_y, |
427 int src_w, | 427 int src_w, |
428 int src_h, | 428 int src_h, |
429 int dest_x, | 429 int dest_x, |
430 int dest_y, | 430 int dest_y, |
431 int dest_w, | 431 int dest_w, |
432 int dest_h, | 432 int dest_h, |
433 bool filter, | 433 bool filter, |
434 const SkPaint& paint, | 434 const SkPaint& paint, |
435 bool remove_image_scale); | 435 bool remove_image_scale); |
436 | 436 |
437 // The device scale factor at which drawing on this canvas occurs. | 437 // The device scale factor at which drawing on this canvas occurs. |
438 // An additional scale can be applied via Canvas::Scale(). However, | 438 // An additional scale can be applied via Canvas::Scale(). However, |
439 // Canvas::Scale() does not affect |image_scale_|. | 439 // Canvas::Scale() does not affect |image_scale_|. |
440 float image_scale_; | 440 float image_scale_; |
441 | 441 |
442 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; | 442 skia::RefPtr<SkCanvas> owned_canvas_; |
443 SkCanvas* canvas_; | 443 SkCanvas* canvas_; |
444 | 444 |
445 DISALLOW_COPY_AND_ASSIGN(Canvas); | 445 DISALLOW_COPY_AND_ASSIGN(Canvas); |
446 }; | 446 }; |
447 | 447 |
448 } // namespace gfx | 448 } // namespace gfx |
449 | 449 |
450 #endif // UI_GFX_CANVAS_H_ | 450 #endif // UI_GFX_CANVAS_H_ |
OLD | NEW |