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

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

Issue 2752593002: cc: Make PaintCanvas abstract (Closed)
Patch Set: Separate files Created 3 years, 9 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
(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_SKIA_PAINT_CANVAS_H_
6 #define CC_PAINT_SKIA_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/core/SkCanvas.h"
18
19 namespace cc {
20
21 class PaintFlags;
22
23 // A PaintCanvas derived class that passes PaintCanvas APIs through to
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:
28 explicit SkiaPaintCanvas(SkCanvas* canvas);
29 explicit SkiaPaintCanvas(const SkBitmap& bitmap);
30 explicit SkiaPaintCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props);
31 ~SkiaPaintCanvas();
32
33 SkMetaData& getMetaData() override;
34 SkImageInfo imageInfo() const override;
35 bool getProps(SkSurfaceProps* props) const override;
36
37 void flush() override;
38
39 SkISize getBaseLayerSize() const override;
40 bool peekPixels(SkPixmap* pixmap) override;
41 bool readPixels(const SkImageInfo& dest_info,
42 void* dest_pixels,
43 size_t dest_row_bytes,
44 int src_x,
45 int src_y) override;
46 bool readPixels(SkBitmap* bitmap, int src_x, int src_y) override;
47 bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap) override;
48 bool writePixels(const SkImageInfo& info,
49 const void* pixels,
50 size_t row_bytes,
51 int x,
52 int y) override;
53 int save() override;
54 int saveLayer(const SkRect* bounds, const PaintFlags* flags) override;
55 int saveLayer(const SkRect& bounds, const PaintFlags* flags) override;
56 int saveLayerPreserveLCDTextRequests(const SkRect* bounds,
57 const PaintFlags* flags) override;
58 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha) override;
59
60 void restore() override;
61 int getSaveCount() const override;
62 void restoreToCount(int save_count) override;
63 void translate(SkScalar dx, SkScalar dy) override;
64 void scale(SkScalar sx, SkScalar sy) override;
65 void rotate(SkScalar degrees) override;
66 void rotate(SkScalar degrees, SkScalar px, SkScalar py) override;
67 void skew(SkScalar sx, SkScalar sy) override;
68 void concat(const SkMatrix& matrix) override;
69 void setMatrix(const SkMatrix& matrix) override;
70 void resetMatrix() override;
71 void clipRect(const SkRect& rect,
72 SkClipOp op,
73 bool do_anti_alias = false) override;
74 void clipRect(const SkRect& rect, bool do_anti_alias = false) override;
75 void clipRRect(const SkRRect& rrect,
76 SkClipOp op,
77 bool do_anti_alias) override;
78 void clipRRect(const SkRRect& rrect, SkClipOp op) override;
79 void clipRRect(const SkRRect& rrect, bool do_anti_alias = false) override;
80 void clipPath(const SkPath& path, SkClipOp op, bool do_anti_alias) override;
81 void clipPath(const SkPath& path, SkClipOp op) override;
82 void clipPath(const SkPath& path, bool do_anti_alias = false) override;
83 void clipRegion(const SkRegion& device_region,
84 SkClipOp op = SkClipOp::kIntersect) override;
85 bool quickReject(const SkRect& rect) const override;
86 bool quickReject(const SkPath& path) const override;
87 SkRect getLocalClipBounds() const override;
88 bool getLocalClipBounds(SkRect* bounds) const override;
89 SkIRect getDeviceClipBounds() const override;
90 bool getDeviceClipBounds(SkIRect* bounds) const override;
91 void drawColor(SkColor color,
92 SkBlendMode mode = SkBlendMode::kSrcOver) override;
93 void clear(SkColor color) override;
94 void discard() override;
95
96 void drawLine(SkScalar x0,
97 SkScalar y0,
98 SkScalar x1,
99 SkScalar y1,
100 const PaintFlags& flags) override;
101 void drawRect(const SkRect& rect, const PaintFlags& flags) override;
102 void drawIRect(const SkIRect& rect, const PaintFlags& flags) override;
103 void drawOval(const SkRect& oval, const PaintFlags& flags) override;
104 void drawRRect(const SkRRect& rrect, const PaintFlags& flags) override;
105 void drawDRRect(const SkRRect& outer,
106 const SkRRect& inner,
107 const PaintFlags& flags) override;
108 void drawCircle(SkScalar cx,
109 SkScalar cy,
110 SkScalar radius,
111 const PaintFlags& flags) override;
112 void drawArc(const SkRect& oval,
113 SkScalar start_angle,
114 SkScalar sweep_angle,
115 bool use_center,
116 const PaintFlags& flags) override;
117 void drawRoundRect(const SkRect& rect,
118 SkScalar rx,
119 SkScalar ry,
120 const PaintFlags& flags) override;
121 void drawPath(const SkPath& path, const PaintFlags& flags) override;
122 void drawImage(const SkImage* image,
123 SkScalar left,
124 SkScalar top,
125 const PaintFlags* flags = nullptr) override;
126 void drawImage(const sk_sp<SkImage>& image,
127 SkScalar left,
128 SkScalar top,
129 const PaintFlags* flags = nullptr) override;
130
131 void drawImageRect(
132 const SkImage* image,
133 const SkRect& src,
134 const SkRect& dst,
135 const PaintFlags* flags,
136 SrcRectConstraint constraint = kStrict_SrcRectConstraint) override;
137 void drawImageRect(
138 const SkImage* image,
139 const SkIRect& isrc,
140 const SkRect& dst,
141 const PaintFlags* flags,
142 SrcRectConstraint constraint = kStrict_SrcRectConstraint) override;
143 void drawImageRect(
144 const SkImage* image,
145 const SkRect& dst,
146 const PaintFlags* flags,
147 SrcRectConstraint constraint = kStrict_SrcRectConstraint) override;
148 void drawImageRect(
149 const sk_sp<SkImage>& image,
150 const SkRect& src,
151 const SkRect& dst,
152 const PaintFlags* flags,
153 SrcRectConstraint constraint = kStrict_SrcRectConstraint) override;
154 void drawImageRect(
155 const sk_sp<SkImage>& image,
156 const SkIRect& isrc,
157 const SkRect& dst,
158 const PaintFlags* flags,
159 SrcRectConstraint cons = kStrict_SrcRectConstraint) override;
160 void drawImageRect(
161 const sk_sp<SkImage>& image,
162 const SkRect& dst,
163 const PaintFlags* flags,
164 SrcRectConstraint cons = kStrict_SrcRectConstraint) override;
165 void drawBitmap(const SkBitmap& bitmap,
166 SkScalar left,
167 SkScalar top,
168 const PaintFlags* flags = nullptr) override;
169 void drawBitmapRect(
170 const SkBitmap& bitmap,
171 const SkRect& src,
172 const SkRect& dst,
173 const PaintFlags* flags,
174 SrcRectConstraint constraint = kStrict_SrcRectConstraint) override;
175 void drawBitmapRect(
176 const SkBitmap& bitmap,
177 const SkIRect& isrc,
178 const SkRect& dst,
179 const PaintFlags* flags,
180 SrcRectConstraint constraint = kStrict_SrcRectConstraint) override;
181 void drawBitmapRect(
182 const SkBitmap& bitmap,
183 const SkRect& dst,
184 const PaintFlags* flags,
185 SrcRectConstraint constraint = kStrict_SrcRectConstraint) override;
186
187 void drawText(const void* text,
188 size_t byte_length,
189 SkScalar x,
190 SkScalar y,
191 const PaintFlags& flags) override;
192 void drawPosText(const void* text,
193 size_t byte_length,
194 const SkPoint pos[],
195 const PaintFlags& flags) override;
196 void drawTextBlob(const SkTextBlob* blob,
197 SkScalar x,
198 SkScalar y,
199 const PaintFlags& flags) override;
200 void drawTextBlob(const sk_sp<SkTextBlob>& blob,
201 SkScalar x,
202 SkScalar y,
203 const PaintFlags& flags) override;
204
205 void drawPicture(const PaintRecord* record) override;
206 void drawPicture(const PaintRecord* record,
207 const SkMatrix* matrix,
208 const PaintFlags* flags) override;
209 void drawPicture(sk_sp<PaintRecord> record) override;
210
211 bool isClipEmpty() const override;
212 bool isClipRect() const override;
213 const SkMatrix& getTotalMatrix() const override;
214
215 void temporary_internal_describeTopLayer(SkMatrix* matrix,
216 SkIRect* clip_bounds) override;
217
218 bool ToPixmap(SkPixmap* output) override;
219 void AnnotateRectWithURL(const SkRect& rect, SkData* data) override;
220 void AnnotateNamedDestination(const SkPoint& point, SkData* data) override;
221 void AnnotateLinkToDestination(const SkRect& rect, SkData* data) override;
222
223 private:
224 SkCanvas* canvas_;
225 std::unique_ptr<SkCanvas> owned_;
226 };
227
228 } // namespace cc
229
230 #endif // CC_PAINT_SKIA_PAINT_CANVAS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698