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

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

Issue 2752593002: cc: Make PaintCanvas abstract (Closed)
Patch Set: Remove default parameters on virtual functions 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
« no previous file with comments | « cc/paint/paint_surface.h ('k') | cc/paint/skia_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_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
36 void flush() override;
37
38 SkISize getBaseLayerSize() const override;
39 bool peekPixels(SkPixmap* pixmap) override;
40 bool readPixels(const SkImageInfo& dest_info,
41 void* dest_pixels,
42 size_t dest_row_bytes,
43 int src_x,
44 int src_y) override;
45 bool readPixels(SkBitmap* bitmap, int src_x, int src_y) override;
46 bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap) override;
47 bool writePixels(const SkImageInfo& info,
48 const void* pixels,
49 size_t row_bytes,
50 int x,
51 int y) override;
52 int save() override;
53 int saveLayer(const SkRect* bounds, const PaintFlags* flags) override;
54 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha) override;
55
56 void restore() override;
57 int getSaveCount() const override;
58 void restoreToCount(int save_count) override;
59 void translate(SkScalar dx, SkScalar dy) override;
60 void scale(SkScalar sx, SkScalar sy) override;
61 void rotate(SkScalar degrees) override;
62 void rotate(SkScalar degrees, SkScalar px, SkScalar py) override;
63 void concat(const SkMatrix& matrix) override;
64 void setMatrix(const SkMatrix& matrix) override;
65 void resetMatrix() override;
66
67 void clipRect(const SkRect& rect, SkClipOp op, bool do_anti_alias) override;
68 void clipRRect(const SkRRect& rrect,
69 SkClipOp op,
70 bool do_anti_alias) override;
71 void clipPath(const SkPath& path, SkClipOp op, bool do_anti_alias) override;
72 bool quickReject(const SkRect& rect) const override;
73 bool quickReject(const SkPath& path) const override;
74 SkRect getLocalClipBounds() const override;
75 bool getLocalClipBounds(SkRect* bounds) const override;
76 SkIRect getDeviceClipBounds() const override;
77 bool getDeviceClipBounds(SkIRect* bounds) const override;
78 void drawColor(SkColor color, SkBlendMode mode) override;
79 void clear(SkColor color) override;
80
81 void drawLine(SkScalar x0,
82 SkScalar y0,
83 SkScalar x1,
84 SkScalar y1,
85 const PaintFlags& flags) override;
86 void drawRect(const SkRect& rect, const PaintFlags& flags) override;
87 void drawIRect(const SkIRect& rect, const PaintFlags& flags) override;
88 void drawOval(const SkRect& oval, const PaintFlags& flags) override;
89 void drawRRect(const SkRRect& rrect, const PaintFlags& flags) override;
90 void drawDRRect(const SkRRect& outer,
91 const SkRRect& inner,
92 const PaintFlags& flags) override;
93 void drawCircle(SkScalar cx,
94 SkScalar cy,
95 SkScalar radius,
96 const PaintFlags& flags) override;
97 void drawArc(const SkRect& oval,
98 SkScalar start_angle,
99 SkScalar sweep_angle,
100 bool use_center,
101 const PaintFlags& flags) override;
102 void drawRoundRect(const SkRect& rect,
103 SkScalar rx,
104 SkScalar ry,
105 const PaintFlags& flags) override;
106 void drawPath(const SkPath& path, const PaintFlags& flags) override;
107 void drawImage(const SkImage* image,
108 SkScalar left,
109 SkScalar top,
110 const PaintFlags* flags) override;
111 void drawImage(const sk_sp<SkImage>& image,
112 SkScalar left,
113 SkScalar top,
114 const PaintFlags* flags) override;
115
116 void drawImageRect(const SkImage* image,
117 const SkRect& src,
118 const SkRect& dst,
119 const PaintFlags* flags,
120 SrcRectConstraint constraint) override;
121 void drawBitmap(const SkBitmap& bitmap,
122 SkScalar left,
123 SkScalar top,
124 const PaintFlags* flags) override;
125
126 void drawText(const void* text,
127 size_t byte_length,
128 SkScalar x,
129 SkScalar y,
130 const PaintFlags& flags) override;
131 void drawPosText(const void* text,
132 size_t byte_length,
133 const SkPoint pos[],
134 const PaintFlags& flags) override;
135 void drawTextBlob(const SkTextBlob* blob,
136 SkScalar x,
137 SkScalar y,
138 const PaintFlags& flags) override;
139 void drawTextBlob(const sk_sp<SkTextBlob>& blob,
140 SkScalar x,
141 SkScalar y,
142 const PaintFlags& flags) override;
143
144 void drawPicture(const PaintRecord* record) override;
145 void drawPicture(const PaintRecord* record,
146 const SkMatrix* matrix,
147 const PaintFlags* flags) override;
148 void drawPicture(sk_sp<PaintRecord> record) override;
149
150 bool isClipEmpty() const override;
151 bool isClipRect() const override;
152 const SkMatrix& getTotalMatrix() const override;
153
154 void temporary_internal_describeTopLayer(SkMatrix* matrix,
155 SkIRect* clip_bounds) override;
156
157 bool ToPixmap(SkPixmap* output) override;
158 void AnnotateRectWithURL(const SkRect& rect, SkData* data) override;
159 void AnnotateNamedDestination(const SkPoint& point, SkData* data) override;
160 void AnnotateLinkToDestination(const SkRect& rect, SkData* data) override;
161
162 // Don't shadow non-virtual helper functions.
163 using PaintCanvas::clipRect;
164 using PaintCanvas::clipRRect;
165 using PaintCanvas::clipPath;
166 using PaintCanvas::drawBitmap;
167 using PaintCanvas::drawColor;
168 using PaintCanvas::drawImage;
169
170 private:
171 SkCanvas* canvas_;
172 std::unique_ptr<SkCanvas> owned_;
173 };
174
175 } // namespace cc
176
177 #endif // CC_PAINT_SKIA_PAINT_CANVAS_H_
OLDNEW
« no previous file with comments | « cc/paint/paint_surface.h ('k') | cc/paint/skia_paint_canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698