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_SKIA_PAINT_CANVAS_H_ | 5 #ifndef CC_PAINT_RECORD_PAINT_CANVAS_H_ |
6 #define CC_PAINT_SKIA_PAINT_CANVAS_H_ | 6 #define CC_PAINT_RECORD_PAINT_CANVAS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "cc/paint/paint_canvas.h" | 14 #include "cc/paint/paint_canvas.h" |
15 #include "cc/paint/paint_flags.h" | 15 #include "cc/paint/paint_flags.h" |
16 #include "cc/paint/paint_record.h" | 16 #include "cc/paint/paint_record.h" |
17 #include "third_party/skia/include/core/SkCanvas.h" | 17 #include "third_party/skia/include/utils/SkNoDrawCanvas.h" |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 class PaintOpBuffer; | |
21 class PaintFlags; | 22 class PaintFlags; |
22 | 23 |
23 // A PaintCanvas derived class that passes PaintCanvas APIs through to | 24 class CC_PAINT_EXPORT RecordPaintCanvas final : public PaintCanvas { |
24 // an SkCanvas. This is more efficient than recording to a PaintRecord | |
25 // and then playing back to an SkCanvas. | |
26 class CC_PAINT_EXPORT SkiaPaintCanvas final : public PaintCanvas { | |
27 public: | 25 public: |
28 explicit SkiaPaintCanvas(SkCanvas* canvas); | 26 explicit RecordPaintCanvas(PaintOpBuffer* buffer, const SkRect& cull_rect); |
29 explicit SkiaPaintCanvas(const SkBitmap& bitmap); | 27 ~RecordPaintCanvas() override; |
30 explicit SkiaPaintCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props); | |
31 explicit SkiaPaintCanvas(SkiaPaintCanvas&& other); | |
32 ~SkiaPaintCanvas() override; | |
33 | |
34 SkiaPaintCanvas& operator=(SkiaPaintCanvas&& other) = default; | |
35 | 28 |
36 SkMetaData& getMetaData() override; | 29 SkMetaData& getMetaData() override; |
37 SkImageInfo imageInfo() const override; | 30 SkImageInfo imageInfo() const override; |
38 | 31 |
39 void flush() override; | 32 void flush() override; |
40 | 33 |
41 SkISize getBaseLayerSize() const override; | 34 SkISize getBaseLayerSize() const override; |
42 bool writePixels(const SkImageInfo& info, | 35 bool writePixels(const SkImageInfo& info, |
43 const void* pixels, | 36 const void* pixels, |
44 size_t row_bytes, | 37 size_t row_bytes, |
45 int x, | 38 int x, |
46 int y) override; | 39 int y) override; |
47 int save() override; | 40 int save() override; |
48 int saveLayer(const SkRect* bounds, const PaintFlags* flags) override; | 41 int saveLayer(const SkRect* bounds, const PaintFlags* flags) override; |
49 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha) override; | 42 int saveLayerAlpha(const SkRect* bounds, uint8_t alpha) override; |
50 | 43 |
51 void restore() override; | 44 void restore() override; |
52 int getSaveCount() const override; | 45 int getSaveCount() const override; |
53 void restoreToCount(int save_count) override; | 46 void restoreToCount(int save_count) override; |
vmpstr
2017/04/12 21:47:12
Is there a plan to also rename these to chromium s
enne (OOO)
2017/04/12 22:41:30
My plan was to let this stick for a while (maybe a
| |
54 void translate(SkScalar dx, SkScalar dy) override; | 47 void translate(SkScalar dx, SkScalar dy) override; |
55 void scale(SkScalar sx, SkScalar sy) override; | 48 void scale(SkScalar sx, SkScalar sy) override; |
56 void rotate(SkScalar degrees) override; | 49 void rotate(SkScalar degrees) override; |
57 void concat(const SkMatrix& matrix) override; | 50 void concat(const SkMatrix& matrix) override; |
58 void setMatrix(const SkMatrix& matrix) override; | 51 void setMatrix(const SkMatrix& matrix) override; |
59 | 52 |
60 void clipRect(const SkRect& rect, SkClipOp op, bool do_anti_alias) override; | 53 void clipRect(const SkRect& rect, SkClipOp op, bool antialias) override; |
61 void clipRRect(const SkRRect& rrect, | 54 void clipRRect(const SkRRect& rrect, SkClipOp op, bool antialias) override; |
62 SkClipOp op, | 55 void clipPath(const SkPath& path, SkClipOp op, bool antialias) override; |
63 bool do_anti_alias) override; | |
64 void clipPath(const SkPath& path, SkClipOp op, bool do_anti_alias) override; | |
65 bool quickReject(const SkRect& rect) const override; | 56 bool quickReject(const SkRect& rect) const override; |
66 bool quickReject(const SkPath& path) const override; | 57 bool quickReject(const SkPath& path) const override; |
67 SkRect getLocalClipBounds() const override; | 58 SkRect getLocalClipBounds() const override; |
68 bool getLocalClipBounds(SkRect* bounds) const override; | 59 bool getLocalClipBounds(SkRect* bounds) const override; |
69 SkIRect getDeviceClipBounds() const override; | 60 SkIRect getDeviceClipBounds() const override; |
70 bool getDeviceClipBounds(SkIRect* bounds) const override; | 61 bool getDeviceClipBounds(SkIRect* bounds) const override; |
71 void drawColor(SkColor color, SkBlendMode mode) override; | 62 void drawColor(SkColor color, SkBlendMode mode) override; |
72 void clear(SkColor color) override; | 63 void clear(SkColor color) override; |
73 | 64 |
74 void drawLine(SkScalar x0, | 65 void drawLine(SkScalar x0, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 // Don't shadow non-virtual helper functions. | 138 // Don't shadow non-virtual helper functions. |
148 using PaintCanvas::clipRect; | 139 using PaintCanvas::clipRect; |
149 using PaintCanvas::clipRRect; | 140 using PaintCanvas::clipRRect; |
150 using PaintCanvas::clipPath; | 141 using PaintCanvas::clipPath; |
151 using PaintCanvas::drawBitmap; | 142 using PaintCanvas::drawBitmap; |
152 using PaintCanvas::drawColor; | 143 using PaintCanvas::drawColor; |
153 using PaintCanvas::drawImage; | 144 using PaintCanvas::drawImage; |
154 using PaintCanvas::drawPicture; | 145 using PaintCanvas::drawPicture; |
155 | 146 |
156 private: | 147 private: |
157 SkCanvas* canvas_; | 148 PaintOpBuffer* buffer_; |
158 std::unique_ptr<SkCanvas> owned_; | |
159 | 149 |
160 DISALLOW_COPY_AND_ASSIGN(SkiaPaintCanvas); | 150 // TODO(enne): Although RecordPaintCanvas is mostly a write-only interface |
151 // where paint commands are stored, occasionally users of PaintCanvas want | |
152 // to ask stateful questions mid-stream of clip and transform state. | |
153 // To avoid duplicating all this code (for now?), just forward to an SkCanvas | |
154 // that's not backed by anything but can answer these questions. | |
155 SkNoDrawCanvas canvas_; | |
161 }; | 156 }; |
162 | 157 |
163 } // namespace cc | 158 } // namespace cc |
164 | 159 |
165 #endif // CC_PAINT_SKIA_PAINT_CANVAS_H_ | 160 #endif // CC_PAINT_RECORD_PAINT_CANVAS_H_ |
OLD | NEW |