OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 CC_PAINT_PAINT_CANVAS_H_ | 5 #ifndef CC_PAINT_PAINT_CANVAS_H_ |
6 #define CC_PAINT_PAINT_CANVAS_H_ | 6 #define CC_PAINT_PAINT_CANVAS_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "cc/paint/paint_export.h" | 12 #include "cc/paint/paint_export.h" |
13 #include "cc/paint/paint_image.h" | 13 #include "cc/paint/paint_image.h" |
14 #include "cc/paint/paint_record.h" | |
15 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
16 | 15 |
17 namespace cc { | 16 namespace cc { |
18 | 17 |
19 class DisplayItemList; | 18 class DisplayItemList; |
20 class PaintFlags; | 19 class PaintFlags; |
| 20 class PaintOpBuffer; |
| 21 |
| 22 using PaintRecord = PaintOpBuffer; |
21 | 23 |
22 class CC_PAINT_EXPORT PaintCanvas { | 24 class CC_PAINT_EXPORT PaintCanvas { |
23 public: | 25 public: |
24 virtual ~PaintCanvas() {} | 26 virtual ~PaintCanvas() {} |
25 | 27 |
26 virtual SkMetaData& getMetaData() = 0; | 28 virtual SkMetaData& getMetaData() = 0; |
| 29 |
| 30 // TODO(enne): this only appears to mostly be used to determine if this is |
| 31 // recording or not, so could be simplified or removed. |
27 virtual SkImageInfo imageInfo() const = 0; | 32 virtual SkImageInfo imageInfo() const = 0; |
28 | 33 |
29 // TODO(enne): It would be nice to get rid of flush() entirely, as it | 34 // TODO(enne): It would be nice to get rid of flush() entirely, as it |
30 // doesn't really make sense for recording. However, this gets used by | 35 // doesn't really make sense for recording. However, this gets used by |
31 // SkCanvasVideoRenderer which takes a PaintCanvas to paint both | 36 // SkCanvasVideoRenderer which takes a PaintCanvas to paint both |
32 // software and hardware video. This is super entangled with ImageBuffer | 37 // software and hardware video. This is super entangled with ImageBuffer |
33 // and canvas/video painting in Blink where the same paths are used for | 38 // and canvas/video painting in Blink where the same paths are used for |
34 // both recording and gpu work. | 39 // both recording and gpu work. |
35 virtual void flush() = 0; | 40 virtual void flush() = 0; |
36 | 41 |
37 virtual int save() = 0; | 42 virtual int save() = 0; |
38 virtual int saveLayer(const SkRect* bounds, const PaintFlags* flags) = 0; | 43 virtual int saveLayer(const SkRect* bounds, const PaintFlags* flags) = 0; |
39 virtual int saveLayerAlpha(const SkRect* bounds, U8CPU alpha) = 0; | 44 virtual int saveLayerAlpha(const SkRect* bounds, uint8_t alpha) = 0; |
40 | 45 |
41 virtual void restore() = 0; | 46 virtual void restore() = 0; |
42 virtual int getSaveCount() const = 0; | 47 virtual int getSaveCount() const = 0; |
43 virtual void restoreToCount(int save_count) = 0; | 48 virtual void restoreToCount(int save_count) = 0; |
44 virtual void translate(SkScalar dx, SkScalar dy) = 0; | 49 virtual void translate(SkScalar dx, SkScalar dy) = 0; |
45 virtual void scale(SkScalar sx, SkScalar sy) = 0; | 50 virtual void scale(SkScalar sx, SkScalar sy) = 0; |
46 virtual void rotate(SkScalar degrees) = 0; | 51 virtual void rotate(SkScalar degrees) = 0; |
47 virtual void concat(const SkMatrix& matrix) = 0; | 52 virtual void concat(const SkMatrix& matrix) = 0; |
48 virtual void setMatrix(const SkMatrix& matrix) = 0; | 53 virtual void setMatrix(const SkMatrix& matrix) = 0; |
49 | 54 |
(...skipping 30 matching lines...) Expand all Loading... |
80 } | 85 } |
81 | 86 |
82 virtual bool quickReject(const SkRect& rect) const = 0; | 87 virtual bool quickReject(const SkRect& rect) const = 0; |
83 virtual bool quickReject(const SkPath& path) const = 0; | 88 virtual bool quickReject(const SkPath& path) const = 0; |
84 virtual SkRect getLocalClipBounds() const = 0; | 89 virtual SkRect getLocalClipBounds() const = 0; |
85 virtual bool getLocalClipBounds(SkRect* bounds) const = 0; | 90 virtual bool getLocalClipBounds(SkRect* bounds) const = 0; |
86 virtual SkIRect getDeviceClipBounds() const = 0; | 91 virtual SkIRect getDeviceClipBounds() const = 0; |
87 virtual bool getDeviceClipBounds(SkIRect* bounds) const = 0; | 92 virtual bool getDeviceClipBounds(SkIRect* bounds) const = 0; |
88 virtual void drawColor(SkColor color, SkBlendMode mode) = 0; | 93 virtual void drawColor(SkColor color, SkBlendMode mode) = 0; |
89 void drawColor(SkColor color) { drawColor(color, SkBlendMode::kSrcOver); } | 94 void drawColor(SkColor color) { drawColor(color, SkBlendMode::kSrcOver); } |
| 95 |
| 96 // TODO(enne): This is a synonym for drawColor with kSrc. Remove it. |
90 virtual void clear(SkColor color) = 0; | 97 virtual void clear(SkColor color) = 0; |
91 | 98 |
92 virtual void drawLine(SkScalar x0, | 99 virtual void drawLine(SkScalar x0, |
93 SkScalar y0, | 100 SkScalar y0, |
94 SkScalar x1, | 101 SkScalar x1, |
95 SkScalar y1, | 102 SkScalar y1, |
96 const PaintFlags& flags) = 0; | 103 const PaintFlags& flags) = 0; |
97 virtual void drawRect(const SkRect& rect, const PaintFlags& flags) = 0; | 104 virtual void drawRect(const SkRect& rect, const PaintFlags& flags) = 0; |
98 virtual void drawIRect(const SkIRect& rect, const PaintFlags& flags) = 0; | 105 virtual void drawIRect(const SkIRect& rect, const PaintFlags& flags) = 0; |
99 virtual void drawOval(const SkRect& oval, const PaintFlags& flags) = 0; | 106 virtual void drawOval(const SkRect& oval, const PaintFlags& flags) = 0; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // Following routines are used in print preview workflow to mark the | 226 // Following routines are used in print preview workflow to mark the |
220 // preview metafile. | 227 // preview metafile. |
221 #if defined(OS_MACOSX) | 228 #if defined(OS_MACOSX) |
222 CC_PAINT_EXPORT void SetIsPreviewMetafile(PaintCanvas* canvas, bool is_preview); | 229 CC_PAINT_EXPORT void SetIsPreviewMetafile(PaintCanvas* canvas, bool is_preview); |
223 CC_PAINT_EXPORT bool IsPreviewMetafile(PaintCanvas* canvas); | 230 CC_PAINT_EXPORT bool IsPreviewMetafile(PaintCanvas* canvas); |
224 #endif | 231 #endif |
225 | 232 |
226 } // namespace cc | 233 } // namespace cc |
227 | 234 |
228 #endif // CC_PAINT_PAINT_CANVAS_H_ | 235 #endif // CC_PAINT_PAINT_CANVAS_H_ |
OLD | NEW |