Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: cc/paint/record_paint_canvas.h

Issue 2768143002: Back PaintRecord with PaintOpBuffer instead of SkPicture (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 int save() override; 34 int save() override;
42 int saveLayer(const SkRect* bounds, const PaintFlags* flags) override; 35 int saveLayer(const SkRect* bounds, const PaintFlags* flags) override;
43 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha) override; 36 int saveLayerAlpha(const SkRect* bounds, uint8_t alpha) override;
44 37
45 void restore() override; 38 void restore() override;
46 int getSaveCount() const override; 39 int getSaveCount() const override;
47 void restoreToCount(int save_count) override; 40 void restoreToCount(int save_count) override;
48 void translate(SkScalar dx, SkScalar dy) override; 41 void translate(SkScalar dx, SkScalar dy) override;
49 void scale(SkScalar sx, SkScalar sy) override; 42 void scale(SkScalar sx, SkScalar sy) override;
50 void rotate(SkScalar degrees) override; 43 void rotate(SkScalar degrees) override;
51 void concat(const SkMatrix& matrix) override; 44 void concat(const SkMatrix& matrix) override;
52 void setMatrix(const SkMatrix& matrix) override; 45 void setMatrix(const SkMatrix& matrix) override;
53 46
54 void clipRect(const SkRect& rect, SkClipOp op, bool do_anti_alias) override; 47 void clipRect(const SkRect& rect, SkClipOp op, bool antialias) override;
55 void clipRRect(const SkRRect& rrect, 48 void clipRRect(const SkRRect& rrect, SkClipOp op, bool antialias) override;
56 SkClipOp op, 49 void clipPath(const SkPath& path, SkClipOp op, bool antialias) override;
57 bool do_anti_alias) override;
58 void clipPath(const SkPath& path, SkClipOp op, bool do_anti_alias) override;
59 bool quickReject(const SkRect& rect) const override; 50 bool quickReject(const SkRect& rect) const override;
60 bool quickReject(const SkPath& path) const override; 51 bool quickReject(const SkPath& path) const override;
61 SkRect getLocalClipBounds() const override; 52 SkRect getLocalClipBounds() const override;
62 bool getLocalClipBounds(SkRect* bounds) const override; 53 bool getLocalClipBounds(SkRect* bounds) const override;
63 SkIRect getDeviceClipBounds() const override; 54 SkIRect getDeviceClipBounds() const override;
64 bool getDeviceClipBounds(SkIRect* bounds) const override; 55 bool getDeviceClipBounds(SkIRect* bounds) const override;
65 void drawColor(SkColor color, SkBlendMode mode) override; 56 void drawColor(SkColor color, SkBlendMode mode) override;
66 void clear(SkColor color) override; 57 void clear(SkColor color) override;
67 58
68 void drawLine(SkScalar x0, 59 void drawLine(SkScalar x0,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // Don't shadow non-virtual helper functions. 129 // Don't shadow non-virtual helper functions.
139 using PaintCanvas::clipRect; 130 using PaintCanvas::clipRect;
140 using PaintCanvas::clipRRect; 131 using PaintCanvas::clipRRect;
141 using PaintCanvas::clipPath; 132 using PaintCanvas::clipPath;
142 using PaintCanvas::drawBitmap; 133 using PaintCanvas::drawBitmap;
143 using PaintCanvas::drawColor; 134 using PaintCanvas::drawColor;
144 using PaintCanvas::drawImage; 135 using PaintCanvas::drawImage;
145 using PaintCanvas::drawPicture; 136 using PaintCanvas::drawPicture;
146 137
147 private: 138 private:
148 SkCanvas* canvas_; 139 PaintOpBuffer* buffer_;
149 std::unique_ptr<SkCanvas> owned_;
150 140
151 DISALLOW_COPY_AND_ASSIGN(SkiaPaintCanvas); 141 // TODO(enne): Although RecordPaintCanvas is mostly a write-only interface
142 // where paint commands are stored, occasionally users of PaintCanvas want
143 // to ask stateful questions mid-stream of clip and transform state.
144 // To avoid duplicating all this code (for now?), just forward to an SkCanvas
145 // that's not backed by anything but can answer these questions.
146 SkNoDrawCanvas canvas_;
152 }; 147 };
153 148
154 } // namespace cc 149 } // namespace cc
155 150
156 #endif // CC_PAINT_SKIA_PAINT_CANVAS_H_ 151 #endif // CC_PAINT_RECORD_PAINT_CANVAS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698