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 <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "skia/ext/platform_canvas.h" | 15 #include "skia/ext/platform_canvas.h" |
16 #include "skia/ext/refptr.h" | 16 #include "third_party/skia/include/core/SkRefCnt.h" |
17 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
18 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
19 #include "ui/gfx/shadow_value.h" | 19 #include "ui/gfx/shadow_value.h" |
20 #include "ui/gfx/text_constants.h" | 20 #include "ui/gfx/text_constants.h" |
21 | 21 |
22 namespace gfx { | 22 namespace gfx { |
23 | 23 |
24 class Rect; | 24 class Rect; |
25 class RectF; | 25 class RectF; |
26 class FontList; | 26 class FontList; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // being returned. | 82 // being returned. |
83 Canvas(const Size& size, float image_scale, bool is_opaque); | 83 Canvas(const Size& size, float image_scale, bool is_opaque); |
84 | 84 |
85 // Constructs a canvas with the size and the image_scale of the provided | 85 // Constructs a canvas with the size and the image_scale of the provided |
86 // |image_rep|, and draws the |image_rep| into it. | 86 // |image_rep|, and draws the |image_rep| into it. |
87 Canvas(const ImageSkiaRep& image_rep, bool is_opaque); | 87 Canvas(const ImageSkiaRep& image_rep, bool is_opaque); |
88 | 88 |
89 // Creates a Canvas backed by an |sk_canvas| with |image_scale_|. | 89 // Creates a Canvas backed by an |sk_canvas| with |image_scale_|. |
90 // |sk_canvas| is assumed to be already scaled based on |image_scale| | 90 // |sk_canvas| is assumed to be already scaled based on |image_scale| |
91 // so no additional scaling is applied. | 91 // so no additional scaling is applied. |
92 Canvas(const skia::RefPtr<SkCanvas>& sk_canvas, float image_scale); | 92 Canvas(sk_sp<SkCanvas> sk_canvas, float image_scale); |
93 | 93 |
94 virtual ~Canvas(); | 94 virtual ~Canvas(); |
95 | 95 |
96 // Recreates the backing platform canvas with DIP |size| and |image_scale_|. | 96 // Recreates the backing platform canvas with DIP |size| and |image_scale_|. |
97 // If the canvas is not opaque, it is explicitly cleared. | 97 // If the canvas is not opaque, it is explicitly cleared. |
98 // This method is public so that canvas_skia_paint can recreate the platform | 98 // This method is public so that canvas_skia_paint can recreate the platform |
99 // canvas after having initialized the canvas. | 99 // canvas after having initialized the canvas. |
100 // TODO(pkotwicz): Push the image_scale into skia::PlatformCanvas such that | 100 // TODO(pkotwicz): Push the image_scale into skia::PlatformCanvas such that |
101 // this method can be private. | 101 // this method can be private. |
102 void RecreateBackingCanvas(const Size& size, | 102 void RecreateBackingCanvas(const Size& size, |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 int dest_h, | 442 int dest_h, |
443 bool filter, | 443 bool filter, |
444 const SkPaint& paint, | 444 const SkPaint& paint, |
445 bool remove_image_scale); | 445 bool remove_image_scale); |
446 | 446 |
447 // The device scale factor at which drawing on this canvas occurs. | 447 // The device scale factor at which drawing on this canvas occurs. |
448 // An additional scale can be applied via Canvas::Scale(). However, | 448 // An additional scale can be applied via Canvas::Scale(). However, |
449 // Canvas::Scale() does not affect |image_scale_|. | 449 // Canvas::Scale() does not affect |image_scale_|. |
450 float image_scale_; | 450 float image_scale_; |
451 | 451 |
452 skia::RefPtr<SkCanvas> canvas_; | 452 sk_sp<SkCanvas> canvas_; |
453 | 453 |
454 DISALLOW_COPY_AND_ASSIGN(Canvas); | 454 DISALLOW_COPY_AND_ASSIGN(Canvas); |
455 }; | 455 }; |
456 | 456 |
457 } // namespace gfx | 457 } // namespace gfx |
458 | 458 |
459 #endif // UI_GFX_CANVAS_H_ | 459 #endif // UI_GFX_CANVAS_H_ |
OLD | NEW |