| 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_record.h" |
| 13 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 | 17 |
| 17 class DisplayItemList; | 18 class DisplayItemList; |
| 18 class PaintFlags; | 19 class PaintFlags; |
| 19 class PaintOpBuffer; | |
| 20 | |
| 21 using PaintRecord = PaintOpBuffer; | |
| 22 | 20 |
| 23 class CC_PAINT_EXPORT PaintCanvas { | 21 class CC_PAINT_EXPORT PaintCanvas { |
| 24 public: | 22 public: |
| 25 virtual ~PaintCanvas() {} | 23 virtual ~PaintCanvas() {} |
| 26 | 24 |
| 27 virtual SkMetaData& getMetaData() = 0; | 25 virtual SkMetaData& getMetaData() = 0; |
| 28 | |
| 29 // TODO(enne): this only appears to mostly be used to determine if this is | |
| 30 // recording or not, so could be simplified or removed. | |
| 31 virtual SkImageInfo imageInfo() const = 0; | 26 virtual SkImageInfo imageInfo() const = 0; |
| 32 | 27 |
| 33 // TODO(enne): It would be nice to get rid of flush() entirely, as it | 28 // TODO(enne): It would be nice to get rid of flush() entirely, as it |
| 34 // doesn't really make sense for recording. However, this gets used by | 29 // doesn't really make sense for recording. However, this gets used by |
| 35 // SkCanvasVideoRenderer which takes a PaintCanvas to paint both | 30 // SkCanvasVideoRenderer which takes a PaintCanvas to paint both |
| 36 // software and hardware video. This is super entangled with ImageBuffer | 31 // software and hardware video. This is super entangled with ImageBuffer |
| 37 // and canvas/video painting in Blink where the same paths are used for | 32 // and canvas/video painting in Blink where the same paths are used for |
| 38 // both recording and gpu work. | 33 // both recording and gpu work. |
| 39 virtual void flush() = 0; | 34 virtual void flush() = 0; |
| 40 | 35 |
| 41 virtual SkISize getBaseLayerSize() const = 0; | 36 virtual SkISize getBaseLayerSize() const = 0; |
| 42 virtual bool writePixels(const SkImageInfo& info, | 37 virtual bool writePixels(const SkImageInfo& info, |
| 43 const void* pixels, | 38 const void* pixels, |
| 44 size_t row_bytes, | 39 size_t row_bytes, |
| 45 int x, | 40 int x, |
| 46 int y) = 0; | 41 int y) = 0; |
| 47 virtual int save() = 0; | 42 virtual int save() = 0; |
| 48 virtual int saveLayer(const SkRect* bounds, const PaintFlags* flags) = 0; | 43 virtual int saveLayer(const SkRect* bounds, const PaintFlags* flags) = 0; |
| 49 virtual int saveLayerAlpha(const SkRect* bounds, uint8_t alpha) = 0; | 44 virtual int saveLayerAlpha(const SkRect* bounds, U8CPU alpha) = 0; |
| 50 | 45 |
| 51 virtual void restore() = 0; | 46 virtual void restore() = 0; |
| 52 virtual int getSaveCount() const = 0; | 47 virtual int getSaveCount() const = 0; |
| 53 virtual void restoreToCount(int save_count) = 0; | 48 virtual void restoreToCount(int save_count) = 0; |
| 54 virtual void translate(SkScalar dx, SkScalar dy) = 0; | 49 virtual void translate(SkScalar dx, SkScalar dy) = 0; |
| 55 virtual void scale(SkScalar sx, SkScalar sy) = 0; | 50 virtual void scale(SkScalar sx, SkScalar sy) = 0; |
| 56 virtual void rotate(SkScalar degrees) = 0; | 51 virtual void rotate(SkScalar degrees) = 0; |
| 57 virtual void concat(const SkMatrix& matrix) = 0; | 52 virtual void concat(const SkMatrix& matrix) = 0; |
| 58 virtual void setMatrix(const SkMatrix& matrix) = 0; | 53 virtual void setMatrix(const SkMatrix& matrix) = 0; |
| 59 | 54 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 90 } | 85 } |
| 91 | 86 |
| 92 virtual bool quickReject(const SkRect& rect) const = 0; | 87 virtual bool quickReject(const SkRect& rect) const = 0; |
| 93 virtual bool quickReject(const SkPath& path) const = 0; | 88 virtual bool quickReject(const SkPath& path) const = 0; |
| 94 virtual SkRect getLocalClipBounds() const = 0; | 89 virtual SkRect getLocalClipBounds() const = 0; |
| 95 virtual bool getLocalClipBounds(SkRect* bounds) const = 0; | 90 virtual bool getLocalClipBounds(SkRect* bounds) const = 0; |
| 96 virtual SkIRect getDeviceClipBounds() const = 0; | 91 virtual SkIRect getDeviceClipBounds() const = 0; |
| 97 virtual bool getDeviceClipBounds(SkIRect* bounds) const = 0; | 92 virtual bool getDeviceClipBounds(SkIRect* bounds) const = 0; |
| 98 virtual void drawColor(SkColor color, SkBlendMode mode) = 0; | 93 virtual void drawColor(SkColor color, SkBlendMode mode) = 0; |
| 99 void drawColor(SkColor color) { drawColor(color, SkBlendMode::kSrcOver); } | 94 void drawColor(SkColor color) { drawColor(color, SkBlendMode::kSrcOver); } |
| 100 | |
| 101 // TODO(enne): This is a synonym for drawColor with kSrc. Remove it. | |
| 102 virtual void clear(SkColor color) = 0; | 95 virtual void clear(SkColor color) = 0; |
| 103 | 96 |
| 104 virtual void drawLine(SkScalar x0, | 97 virtual void drawLine(SkScalar x0, |
| 105 SkScalar y0, | 98 SkScalar y0, |
| 106 SkScalar x1, | 99 SkScalar x1, |
| 107 SkScalar y1, | 100 SkScalar y1, |
| 108 const PaintFlags& flags) = 0; | 101 const PaintFlags& flags) = 0; |
| 109 virtual void drawRect(const SkRect& rect, const PaintFlags& flags) = 0; | 102 virtual void drawRect(const SkRect& rect, const PaintFlags& flags) = 0; |
| 110 virtual void drawIRect(const SkIRect& rect, const PaintFlags& flags) = 0; | 103 virtual void drawIRect(const SkIRect& rect, const PaintFlags& flags) = 0; |
| 111 virtual void drawOval(const SkRect& oval, const PaintFlags& flags) = 0; | 104 virtual void drawOval(const SkRect& oval, const PaintFlags& flags) = 0; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // Following routines are used in print preview workflow to mark the | 234 // Following routines are used in print preview workflow to mark the |
| 242 // preview metafile. | 235 // preview metafile. |
| 243 #if defined(OS_MACOSX) | 236 #if defined(OS_MACOSX) |
| 244 CC_PAINT_EXPORT void SetIsPreviewMetafile(PaintCanvas* canvas, bool is_preview); | 237 CC_PAINT_EXPORT void SetIsPreviewMetafile(PaintCanvas* canvas, bool is_preview); |
| 245 CC_PAINT_EXPORT bool IsPreviewMetafile(PaintCanvas* canvas); | 238 CC_PAINT_EXPORT bool IsPreviewMetafile(PaintCanvas* canvas); |
| 246 #endif | 239 #endif |
| 247 | 240 |
| 248 } // namespace cc | 241 } // namespace cc |
| 249 | 242 |
| 250 #endif // CC_PAINT_PAINT_CANVAS_H_ | 243 #endif // CC_PAINT_PAINT_CANVAS_H_ |
| OLD | NEW |