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

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

Issue 2810363004: Revert of Back PaintRecord with PaintOpBuffer instead of SkPicture (Closed)
Patch Set: 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
« no previous file with comments | « cc/paint/paint_recorder.cc ('k') | cc/paint/record_paint_canvas.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_PAINT_RECORD_PAINT_CANVAS_H_
6 #define CC_PAINT_RECORD_PAINT_CANVAS_H_
7
8 #include <memory>
9
10 #include "base/compiler_specific.h"
11 #include "base/logging.h"
12 #include "base/macros.h"
13 #include "build/build_config.h"
14 #include "cc/paint/paint_canvas.h"
15 #include "cc/paint/paint_flags.h"
16 #include "cc/paint/paint_record.h"
17 #include "third_party/skia/include/utils/SkNoDrawCanvas.h"
18
19 namespace cc {
20
21 class PaintOpBuffer;
22 class PaintFlags;
23
24 class CC_PAINT_EXPORT RecordPaintCanvas final : public PaintCanvas {
25 public:
26 explicit RecordPaintCanvas(PaintOpBuffer* buffer, const SkRect& cull_rect);
27 ~RecordPaintCanvas() override;
28
29 SkMetaData& getMetaData() override;
30 SkImageInfo imageInfo() const override;
31
32 void flush() override;
33
34 SkISize getBaseLayerSize() const override;
35 bool writePixels(const SkImageInfo& info,
36 const void* pixels,
37 size_t row_bytes,
38 int x,
39 int y) override;
40 int save() override;
41 int saveLayer(const SkRect* bounds, const PaintFlags* flags) override;
42 int saveLayerAlpha(const SkRect* bounds, uint8_t alpha) override;
43
44 void restore() override;
45 int getSaveCount() const override;
46 void restoreToCount(int save_count) override;
47 void translate(SkScalar dx, SkScalar dy) override;
48 void scale(SkScalar sx, SkScalar sy) override;
49 void rotate(SkScalar degrees) override;
50 void concat(const SkMatrix& matrix) override;
51 void setMatrix(const SkMatrix& matrix) override;
52
53 void clipRect(const SkRect& rect, SkClipOp op, bool antialias) override;
54 void clipRRect(const SkRRect& rrect, SkClipOp op, bool antialias) override;
55 void clipPath(const SkPath& path, SkClipOp op, bool antialias) override;
56 bool quickReject(const SkRect& rect) const override;
57 bool quickReject(const SkPath& path) const override;
58 SkRect getLocalClipBounds() const override;
59 bool getLocalClipBounds(SkRect* bounds) const override;
60 SkIRect getDeviceClipBounds() const override;
61 bool getDeviceClipBounds(SkIRect* bounds) const override;
62 void drawColor(SkColor color, SkBlendMode mode) override;
63 void clear(SkColor color) override;
64
65 void drawLine(SkScalar x0,
66 SkScalar y0,
67 SkScalar x1,
68 SkScalar y1,
69 const PaintFlags& flags) override;
70 void drawRect(const SkRect& rect, const PaintFlags& flags) override;
71 void drawIRect(const SkIRect& rect, const PaintFlags& flags) override;
72 void drawOval(const SkRect& oval, const PaintFlags& flags) override;
73 void drawRRect(const SkRRect& rrect, const PaintFlags& flags) override;
74 void drawDRRect(const SkRRect& outer,
75 const SkRRect& inner,
76 const PaintFlags& flags) override;
77 void drawCircle(SkScalar cx,
78 SkScalar cy,
79 SkScalar radius,
80 const PaintFlags& flags) override;
81 void drawArc(const SkRect& oval,
82 SkScalar start_angle,
83 SkScalar sweep_angle,
84 bool use_center,
85 const PaintFlags& flags) override;
86 void drawRoundRect(const SkRect& rect,
87 SkScalar rx,
88 SkScalar ry,
89 const PaintFlags& flags) override;
90 void drawPath(const SkPath& path, const PaintFlags& flags) override;
91 void drawImage(sk_sp<const SkImage> image,
92 SkScalar left,
93 SkScalar top,
94 const PaintFlags* flags) override;
95 void drawImageRect(sk_sp<const SkImage> image,
96 const SkRect& src,
97 const SkRect& dst,
98 const PaintFlags* flags,
99 SrcRectConstraint constraint) override;
100 void drawBitmap(const SkBitmap& bitmap,
101 SkScalar left,
102 SkScalar top,
103 const PaintFlags* flags) override;
104
105 void drawText(const void* text,
106 size_t byte_length,
107 SkScalar x,
108 SkScalar y,
109 const PaintFlags& flags) override;
110 void drawPosText(const void* text,
111 size_t byte_length,
112 const SkPoint pos[],
113 const PaintFlags& flags) override;
114 void drawTextBlob(sk_sp<SkTextBlob> blob,
115 SkScalar x,
116 SkScalar y,
117 const PaintFlags& flags) override;
118
119 void drawDisplayItemList(
120 scoped_refptr<DisplayItemList> display_item_list) override;
121
122 void drawPicture(sk_sp<const PaintRecord> record) override;
123
124 bool isClipEmpty() const override;
125 bool isClipRect() const override;
126 const SkMatrix& getTotalMatrix() const override;
127
128 void temporary_internal_describeTopLayer(SkMatrix* matrix,
129 SkIRect* clip_bounds) override;
130
131 bool ToPixmap(SkPixmap* output) override;
132 void Annotate(AnnotationType type,
133 const SkRect& rect,
134 sk_sp<SkData> data) override;
135
136 void PlaybackPaintRecord(sk_sp<const PaintRecord> record) override;
137
138 // Don't shadow non-virtual helper functions.
139 using PaintCanvas::clipRect;
140 using PaintCanvas::clipRRect;
141 using PaintCanvas::clipPath;
142 using PaintCanvas::drawBitmap;
143 using PaintCanvas::drawColor;
144 using PaintCanvas::drawImage;
145 using PaintCanvas::drawPicture;
146
147 private:
148 PaintOpBuffer* buffer_;
149
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_;
156 };
157
158 } // namespace cc
159
160 #endif // CC_PAINT_RECORD_PAINT_CANVAS_H_
OLDNEW
« no previous file with comments | « cc/paint/paint_recorder.cc ('k') | cc/paint/record_paint_canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698