| 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" |
| 14 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 | 18 |
| 18 class DisplayItemList; | 19 class DisplayItemList; |
| 19 class PaintFlags; | 20 class PaintFlags; |
| 20 class PaintOpBuffer; | |
| 21 | |
| 22 using PaintRecord = PaintOpBuffer; | |
| 23 | 21 |
| 24 class CC_PAINT_EXPORT PaintCanvas { | 22 class CC_PAINT_EXPORT PaintCanvas { |
| 25 public: | 23 public: |
| 26 PaintCanvas() {} | |
| 27 virtual ~PaintCanvas() {} | 24 virtual ~PaintCanvas() {} |
| 28 | 25 |
| 29 virtual SkMetaData& getMetaData() = 0; | 26 virtual SkMetaData& getMetaData() = 0; |
| 30 | |
| 31 // TODO(enne): this only appears to mostly be used to determine if this is | |
| 32 // recording or not, so could be simplified or removed. | |
| 33 virtual SkImageInfo imageInfo() const = 0; | 27 virtual SkImageInfo imageInfo() const = 0; |
| 34 | 28 |
| 35 // TODO(enne): It would be nice to get rid of flush() entirely, as it | 29 // TODO(enne): It would be nice to get rid of flush() entirely, as it |
| 36 // doesn't really make sense for recording. However, this gets used by | 30 // doesn't really make sense for recording. However, this gets used by |
| 37 // SkCanvasVideoRenderer which takes a PaintCanvas to paint both | 31 // SkCanvasVideoRenderer which takes a PaintCanvas to paint both |
| 38 // software and hardware video. This is super entangled with ImageBuffer | 32 // software and hardware video. This is super entangled with ImageBuffer |
| 39 // and canvas/video painting in Blink where the same paths are used for | 33 // and canvas/video painting in Blink where the same paths are used for |
| 40 // both recording and gpu work. | 34 // both recording and gpu work. |
| 41 virtual void flush() = 0; | 35 virtual void flush() = 0; |
| 42 | 36 |
| 43 virtual int save() = 0; | 37 virtual int save() = 0; |
| 44 virtual int saveLayer(const SkRect* bounds, const PaintFlags* flags) = 0; | 38 virtual int saveLayer(const SkRect* bounds, const PaintFlags* flags) = 0; |
| 45 virtual int saveLayerAlpha(const SkRect* bounds, uint8_t alpha) = 0; | 39 virtual int saveLayerAlpha(const SkRect* bounds, U8CPU alpha) = 0; |
| 46 | 40 |
| 47 virtual void restore() = 0; | 41 virtual void restore() = 0; |
| 48 virtual int getSaveCount() const = 0; | 42 virtual int getSaveCount() const = 0; |
| 49 virtual void restoreToCount(int save_count) = 0; | 43 virtual void restoreToCount(int save_count) = 0; |
| 50 virtual void translate(SkScalar dx, SkScalar dy) = 0; | 44 virtual void translate(SkScalar dx, SkScalar dy) = 0; |
| 51 virtual void scale(SkScalar sx, SkScalar sy) = 0; | 45 virtual void scale(SkScalar sx, SkScalar sy) = 0; |
| 52 virtual void rotate(SkScalar degrees) = 0; | 46 virtual void rotate(SkScalar degrees) = 0; |
| 53 virtual void concat(const SkMatrix& matrix) = 0; | 47 virtual void concat(const SkMatrix& matrix) = 0; |
| 54 virtual void setMatrix(const SkMatrix& matrix) = 0; | 48 virtual void setMatrix(const SkMatrix& matrix) = 0; |
| 55 | 49 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 86 } | 80 } |
| 87 | 81 |
| 88 virtual bool quickReject(const SkRect& rect) const = 0; | 82 virtual bool quickReject(const SkRect& rect) const = 0; |
| 89 virtual bool quickReject(const SkPath& path) const = 0; | 83 virtual bool quickReject(const SkPath& path) const = 0; |
| 90 virtual SkRect getLocalClipBounds() const = 0; | 84 virtual SkRect getLocalClipBounds() const = 0; |
| 91 virtual bool getLocalClipBounds(SkRect* bounds) const = 0; | 85 virtual bool getLocalClipBounds(SkRect* bounds) const = 0; |
| 92 virtual SkIRect getDeviceClipBounds() const = 0; | 86 virtual SkIRect getDeviceClipBounds() const = 0; |
| 93 virtual bool getDeviceClipBounds(SkIRect* bounds) const = 0; | 87 virtual bool getDeviceClipBounds(SkIRect* bounds) const = 0; |
| 94 virtual void drawColor(SkColor color, SkBlendMode mode) = 0; | 88 virtual void drawColor(SkColor color, SkBlendMode mode) = 0; |
| 95 void drawColor(SkColor color) { drawColor(color, SkBlendMode::kSrcOver); } | 89 void drawColor(SkColor color) { drawColor(color, SkBlendMode::kSrcOver); } |
| 96 | |
| 97 // TODO(enne): This is a synonym for drawColor with kSrc. Remove it. | |
| 98 virtual void clear(SkColor color) = 0; | 90 virtual void clear(SkColor color) = 0; |
| 99 | 91 |
| 100 virtual void drawLine(SkScalar x0, | 92 virtual void drawLine(SkScalar x0, |
| 101 SkScalar y0, | 93 SkScalar y0, |
| 102 SkScalar x1, | 94 SkScalar x1, |
| 103 SkScalar y1, | 95 SkScalar y1, |
| 104 const PaintFlags& flags) = 0; | 96 const PaintFlags& flags) = 0; |
| 105 virtual void drawRect(const SkRect& rect, const PaintFlags& flags) = 0; | 97 virtual void drawRect(const SkRect& rect, const PaintFlags& flags) = 0; |
| 106 virtual void drawIRect(const SkIRect& rect, const PaintFlags& flags) = 0; | 98 virtual void drawIRect(const SkIRect& rect, const PaintFlags& flags) = 0; |
| 107 virtual void drawOval(const SkRect& oval, const PaintFlags& flags) = 0; | 99 virtual void drawOval(const SkRect& oval, const PaintFlags& flags) = 0; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 const SkRect& rect, | 173 const SkRect& rect, |
| 182 sk_sp<SkData> data) = 0; | 174 sk_sp<SkData> data) = 0; |
| 183 | 175 |
| 184 // TODO(enne): maybe this should live on PaintRecord, but that's not | 176 // TODO(enne): maybe this should live on PaintRecord, but that's not |
| 185 // possible when PaintRecord is a typedef. | 177 // possible when PaintRecord is a typedef. |
| 186 virtual void PlaybackPaintRecord(sk_sp<const PaintRecord> record) = 0; | 178 virtual void PlaybackPaintRecord(sk_sp<const PaintRecord> record) = 0; |
| 187 | 179 |
| 188 protected: | 180 protected: |
| 189 friend class PaintSurface; | 181 friend class PaintSurface; |
| 190 friend class PaintRecorder; | 182 friend class PaintRecorder; |
| 191 | |
| 192 private: | |
| 193 DISALLOW_COPY_AND_ASSIGN(PaintCanvas); | |
| 194 }; | 183 }; |
| 195 | 184 |
| 196 class CC_PAINT_EXPORT PaintCanvasAutoRestore { | 185 class CC_PAINT_EXPORT PaintCanvasAutoRestore { |
| 197 public: | 186 public: |
| 198 PaintCanvasAutoRestore(PaintCanvas* canvas, bool save) : canvas_(canvas) { | 187 PaintCanvasAutoRestore(PaintCanvas* canvas, bool save) : canvas_(canvas) { |
| 199 if (canvas_) { | 188 if (canvas_) { |
| 200 save_count_ = canvas_->getSaveCount(); | 189 save_count_ = canvas_->getSaveCount(); |
| 201 if (save) { | 190 if (save) { |
| 202 canvas_->save(); | 191 canvas_->save(); |
| 203 } | 192 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 230 // Following routines are used in print preview workflow to mark the | 219 // Following routines are used in print preview workflow to mark the |
| 231 // preview metafile. | 220 // preview metafile. |
| 232 #if defined(OS_MACOSX) | 221 #if defined(OS_MACOSX) |
| 233 CC_PAINT_EXPORT void SetIsPreviewMetafile(PaintCanvas* canvas, bool is_preview); | 222 CC_PAINT_EXPORT void SetIsPreviewMetafile(PaintCanvas* canvas, bool is_preview); |
| 234 CC_PAINT_EXPORT bool IsPreviewMetafile(PaintCanvas* canvas); | 223 CC_PAINT_EXPORT bool IsPreviewMetafile(PaintCanvas* canvas); |
| 235 #endif | 224 #endif |
| 236 | 225 |
| 237 } // namespace cc | 226 } // namespace cc |
| 238 | 227 |
| 239 #endif // CC_PAINT_PAINT_CANVAS_H_ | 228 #endif // CC_PAINT_PAINT_CANVAS_H_ |
| OLD | NEW |