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

Side by Side Diff: src/core/SkLiteDL.cpp

Issue 2247353003: SkLiteDL: thread the original canvas matrix through for SetMatrix::Draw(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « src/core/SkLiteDL.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkImageFilter.h" 10 #include "SkImageFilter.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 int optimizeFor(GrContext*) { sk_throw(); return 0;} 85 int optimizeFor(GrContext*) { sk_throw(); return 0;}
86 int makeThreadsafe() { sk_throw(); return 0;} 86 int makeThreadsafe() { sk_throw(); return 0;}
87 87
88 uint32_t type : 8; 88 uint32_t type : 8;
89 uint32_t skip : 24; 89 uint32_t skip : 24;
90 }; 90 };
91 static_assert(sizeof(Op) == 4, ""); 91 static_assert(sizeof(Op) == 4, "");
92 92
93 struct Save final : Op { 93 struct Save final : Op {
94 static const auto kType = Type::Save; 94 static const auto kType = Type::Save;
95 void draw(SkCanvas* c) { c->save(); } 95 void draw(SkCanvas* c, const SkMatrix&) { c->save(); }
96 }; 96 };
97 struct Restore final : Op { 97 struct Restore final : Op {
98 static const auto kType = Type::Restore; 98 static const auto kType = Type::Restore;
99 void draw(SkCanvas* c) { c->restore(); } 99 void draw(SkCanvas* c, const SkMatrix&) { c->restore(); }
100 }; 100 };
101 struct SaveLayer final : Op { 101 struct SaveLayer final : Op {
102 static const auto kType = Type::SaveLayer; 102 static const auto kType = Type::SaveLayer;
103 SaveLayer(const SkRect* bounds, const SkPaint* paint, 103 SaveLayer(const SkRect* bounds, const SkPaint* paint,
104 const SkImageFilter* backdrop, SkCanvas::SaveLayerFlags flags) { 104 const SkImageFilter* backdrop, SkCanvas::SaveLayerFlags flags) {
105 if (bounds) { this->bounds = *bounds; } 105 if (bounds) { this->bounds = *bounds; }
106 if (paint) { this->paint = *paint; } 106 if (paint) { this->paint = *paint; }
107 this->backdrop = sk_ref_sp(backdrop); 107 this->backdrop = sk_ref_sp(backdrop);
108 this->flags = flags; 108 this->flags = flags;
109 } 109 }
110 SkRect bounds = kUnset; 110 SkRect bounds = kUnset;
111 SkPaint paint; 111 SkPaint paint;
112 sk_sp<const SkImageFilter> backdrop; 112 sk_sp<const SkImageFilter> backdrop;
113 SkCanvas::SaveLayerFlags flags; 113 SkCanvas::SaveLayerFlags flags;
114 void draw(SkCanvas* c) { 114 void draw(SkCanvas* c, const SkMatrix&) {
115 c->saveLayer({ maybe_unset(bounds), &paint, backdrop.get(), flags }) ; 115 c->saveLayer({ maybe_unset(bounds), &paint, backdrop.get(), flags }) ;
116 } 116 }
117 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 117 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
118 }; 118 };
119 119
120 struct Concat final : Op { 120 struct Concat final : Op {
121 static const auto kType = Type::Concat; 121 static const auto kType = Type::Concat;
122 Concat(const SkMatrix& matrix) : matrix(matrix) {} 122 Concat(const SkMatrix& matrix) : matrix(matrix) {}
123 SkMatrix matrix; 123 SkMatrix matrix;
124 void draw(SkCanvas* c) { c->concat(matrix); } 124 void draw(SkCanvas* c, const SkMatrix&) { c->concat(matrix); }
125 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); } 125 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); }
126 }; 126 };
127 struct SetMatrix final : Op { 127 struct SetMatrix final : Op {
128 static const auto kType = Type::SetMatrix; 128 static const auto kType = Type::SetMatrix;
129 SetMatrix(const SkMatrix& matrix) : matrix(matrix) {} 129 SetMatrix(const SkMatrix& matrix) : matrix(matrix) {}
130 SkMatrix matrix; 130 SkMatrix matrix;
131 void draw(SkCanvas* c) { c->setMatrix(matrix); } 131 void draw(SkCanvas* c, const SkMatrix& original) {
reed1 2016/08/16 23:31:50 Crazy idea (to avoid having to pass 2 params to ev
132 c->setMatrix(SkMatrix::Concat(original, matrix));
133 }
132 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); } 134 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); }
133 }; 135 };
134 struct TranslateZ final : Op { 136 struct TranslateZ final : Op {
135 static const auto kType = Type::TranslateZ; 137 static const auto kType = Type::TranslateZ;
136 TranslateZ(SkScalar dz) : dz(dz) {} 138 TranslateZ(SkScalar dz) : dz(dz) {}
137 SkScalar dz; 139 SkScalar dz;
138 void draw(SkCanvas* c) { 140 void draw(SkCanvas* c, const SkMatrix&) {
139 #ifdef SK_EXPERIMENTAL_SHADOWING 141 #ifdef SK_EXPERIMENTAL_SHADOWING
140 c->translateZ(dz); 142 c->translateZ(dz);
141 #endif 143 #endif
142 } 144 }
143 }; 145 };
144 146
145 struct ClipPath final : Op { 147 struct ClipPath final : Op {
146 static const auto kType = Type::ClipPath; 148 static const auto kType = Type::ClipPath;
147 ClipPath(const SkPath& path, SkRegion::Op op, bool aa) : path(path), op( op), aa(aa) {} 149 ClipPath(const SkPath& path, SkRegion::Op op, bool aa) : path(path), op( op), aa(aa) {}
148 SkPath path; 150 SkPath path;
149 SkRegion::Op op; 151 SkRegion::Op op;
150 bool aa; 152 bool aa;
151 void draw(SkCanvas* c) { c->clipPath(path, op, aa); } 153 void draw(SkCanvas* c, const SkMatrix&) { c->clipPath(path, op, aa); }
152 void makeThreadsafe() { make_threadsafe(&path, nullptr); } 154 void makeThreadsafe() { make_threadsafe(&path, nullptr); }
153 }; 155 };
154 struct ClipRect final : Op { 156 struct ClipRect final : Op {
155 static const auto kType = Type::ClipRect; 157 static const auto kType = Type::ClipRect;
156 ClipRect(const SkRect& rect, SkRegion::Op op, bool aa) : rect(rect), op( op), aa(aa) {} 158 ClipRect(const SkRect& rect, SkRegion::Op op, bool aa) : rect(rect), op( op), aa(aa) {}
157 SkRect rect; 159 SkRect rect;
158 SkRegion::Op op; 160 SkRegion::Op op;
159 bool aa; 161 bool aa;
160 void draw(SkCanvas* c) { c->clipRect(rect, op, aa); } 162 void draw(SkCanvas* c, const SkMatrix&) { c->clipRect(rect, op, aa); }
161 }; 163 };
162 struct ClipRRect final : Op { 164 struct ClipRRect final : Op {
163 static const auto kType = Type::ClipRRect; 165 static const auto kType = Type::ClipRRect;
164 ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool aa) : rrect(rrect) , op(op), aa(aa) {} 166 ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool aa) : rrect(rrect) , op(op), aa(aa) {}
165 SkRRect rrect; 167 SkRRect rrect;
166 SkRegion::Op op; 168 SkRegion::Op op;
167 bool aa; 169 bool aa;
168 void draw(SkCanvas* c) { c->clipRRect(rrect, op, aa); } 170 void draw(SkCanvas* c, const SkMatrix&) { c->clipRRect(rrect, op, aa); }
169 }; 171 };
170 struct ClipRegion final : Op { 172 struct ClipRegion final : Op {
171 static const auto kType = Type::ClipRegion; 173 static const auto kType = Type::ClipRegion;
172 ClipRegion(const SkRegion& region, SkRegion::Op op) : region(region), op (op) {} 174 ClipRegion(const SkRegion& region, SkRegion::Op op) : region(region), op (op) {}
173 SkRegion region; 175 SkRegion region;
174 SkRegion::Op op; 176 SkRegion::Op op;
175 void draw(SkCanvas* c) { c->clipRegion(region, op); } 177 void draw(SkCanvas* c, const SkMatrix&) { c->clipRegion(region, op); }
176 }; 178 };
177 179
178 struct DrawPaint final : Op { 180 struct DrawPaint final : Op {
179 static const auto kType = Type::DrawPaint; 181 static const auto kType = Type::DrawPaint;
180 DrawPaint(const SkPaint& paint) : paint(paint) {} 182 DrawPaint(const SkPaint& paint) : paint(paint) {}
181 SkPaint paint; 183 SkPaint paint;
182 void draw(SkCanvas* c) { c->drawPaint(paint); } 184 void draw(SkCanvas* c, const SkMatrix&) { c->drawPaint(paint); }
183 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 185 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
184 }; 186 };
185 struct DrawPath final : Op { 187 struct DrawPath final : Op {
186 static const auto kType = Type::DrawPath; 188 static const auto kType = Type::DrawPath;
187 DrawPath(const SkPath& path, const SkPaint& paint) : path(path), paint(p aint) {} 189 DrawPath(const SkPath& path, const SkPaint& paint) : path(path), paint(p aint) {}
188 SkPath path; 190 SkPath path;
189 SkPaint paint; 191 SkPaint paint;
190 void draw(SkCanvas* c) { c->drawPath(path, paint); } 192 void draw(SkCanvas* c, const SkMatrix&) { c->drawPath(path, paint); }
191 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 193 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
192 void makeThreadsafe() { make_threadsafe(&path, nullptr); } 194 void makeThreadsafe() { make_threadsafe(&path, nullptr); }
193 }; 195 };
194 struct DrawRect final : Op { 196 struct DrawRect final : Op {
195 static const auto kType = Type::DrawRect; 197 static const auto kType = Type::DrawRect;
196 DrawRect(const SkRect& rect, const SkPaint& paint) : rect(rect), paint(p aint) {} 198 DrawRect(const SkRect& rect, const SkPaint& paint) : rect(rect), paint(p aint) {}
197 SkRect rect; 199 SkRect rect;
198 SkPaint paint; 200 SkPaint paint;
199 void draw(SkCanvas* c) { c->drawRect(rect, paint); } 201 void draw(SkCanvas* c, const SkMatrix&) { c->drawRect(rect, paint); }
200 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 202 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
201 }; 203 };
202 struct DrawOval final : Op { 204 struct DrawOval final : Op {
203 static const auto kType = Type::DrawOval; 205 static const auto kType = Type::DrawOval;
204 DrawOval(const SkRect& oval, const SkPaint& paint) : oval(oval), paint(p aint) {} 206 DrawOval(const SkRect& oval, const SkPaint& paint) : oval(oval), paint(p aint) {}
205 SkRect oval; 207 SkRect oval;
206 SkPaint paint; 208 SkPaint paint;
207 void draw(SkCanvas* c) { c->drawOval(oval, paint); } 209 void draw(SkCanvas* c, const SkMatrix&) { c->drawOval(oval, paint); }
208 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 210 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
209 }; 211 };
210 struct DrawRRect final : Op { 212 struct DrawRRect final : Op {
211 static const auto kType = Type::DrawRRect; 213 static const auto kType = Type::DrawRRect;
212 DrawRRect(const SkRRect& rrect, const SkPaint& paint) : rrect(rrect), pa int(paint) {} 214 DrawRRect(const SkRRect& rrect, const SkPaint& paint) : rrect(rrect), pa int(paint) {}
213 SkRRect rrect; 215 SkRRect rrect;
214 SkPaint paint; 216 SkPaint paint;
215 void draw(SkCanvas* c) { c->drawRRect(rrect, paint); } 217 void draw(SkCanvas* c, const SkMatrix&) { c->drawRRect(rrect, paint); }
216 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 218 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
217 }; 219 };
218 struct DrawDRRect final : Op { 220 struct DrawDRRect final : Op {
219 static const auto kType = Type::DrawDRRect; 221 static const auto kType = Type::DrawDRRect;
220 DrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& pa int) 222 DrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& pa int)
221 : outer(outer), inner(inner), paint(paint) {} 223 : outer(outer), inner(inner), paint(paint) {}
222 SkRRect outer, inner; 224 SkRRect outer, inner;
223 SkPaint paint; 225 SkPaint paint;
224 void draw(SkCanvas* c) { c->drawDRRect(outer, inner, paint); } 226 void draw(SkCanvas* c, const SkMatrix&) { c->drawDRRect(outer, inner, pa int); }
225 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 227 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
226 }; 228 };
227 229
228 struct DrawAnnotation final : Op { 230 struct DrawAnnotation final : Op {
229 static const auto kType = Type::DrawAnnotation; 231 static const auto kType = Type::DrawAnnotation;
230 DrawAnnotation(const SkRect& rect, SkData* value) : rect(rect), value(sk _ref_sp(value)) {} 232 DrawAnnotation(const SkRect& rect, SkData* value) : rect(rect), value(sk _ref_sp(value)) {}
231 SkRect rect; 233 SkRect rect;
232 sk_sp<SkData> value; 234 sk_sp<SkData> value;
233 void draw(SkCanvas* c) { c->drawAnnotation(rect, pod<char>(this), value. get()); } 235 void draw(SkCanvas* c, const SkMatrix&) {
236 c->drawAnnotation(rect, pod<char>(this), value.get());
237 }
234 }; 238 };
235 struct DrawDrawable final : Op { 239 struct DrawDrawable final : Op {
236 static const auto kType = Type::DrawDrawable; 240 static const auto kType = Type::DrawDrawable;
237 DrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) : drawable(sk _ref_sp(drawable)) { 241 DrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) : drawable(sk _ref_sp(drawable)) {
238 if (matrix) { this->matrix = *matrix; } 242 if (matrix) { this->matrix = *matrix; }
239 } 243 }
240 sk_sp<SkDrawable> drawable; 244 sk_sp<SkDrawable> drawable;
241 sk_sp<const SkPicture> snapped; 245 sk_sp<const SkPicture> snapped;
242 SkMatrix matrix = SkMatrix::I(); 246 SkMatrix matrix = SkMatrix::I();
243 void draw(SkCanvas* c) { 247 void draw(SkCanvas* c, const SkMatrix&) {
244 snapped ? c->drawPicture(snapped.get(), &matrix, nullptr) 248 snapped ? c->drawPicture(snapped.get(), &matrix, nullptr)
245 : c->drawDrawable(drawable.get(), &matrix); 249 : c->drawDrawable(drawable.get(), &matrix);
246 } 250 }
247 void makeThreadsafe() { 251 void makeThreadsafe() {
248 snapped.reset(drawable->newPictureSnapshot()); 252 snapped.reset(drawable->newPictureSnapshot());
249 make_threadsafe(nullptr, &matrix); 253 make_threadsafe(nullptr, &matrix);
250 } 254 }
251 }; 255 };
252 struct DrawPicture final : Op { 256 struct DrawPicture final : Op {
253 static const auto kType = Type::DrawPicture; 257 static const auto kType = Type::DrawPicture;
254 DrawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPa int* paint) 258 DrawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPa int* paint)
255 : picture(sk_ref_sp(picture)) { 259 : picture(sk_ref_sp(picture)) {
256 if (matrix) { this->matrix = *matrix; } 260 if (matrix) { this->matrix = *matrix; }
257 if (paint) { this->paint = *paint; has_paint = true; } 261 if (paint) { this->paint = *paint; has_paint = true; }
258 } 262 }
259 sk_sp<const SkPicture> picture; 263 sk_sp<const SkPicture> picture;
260 SkMatrix matrix = SkMatrix::I(); 264 SkMatrix matrix = SkMatrix::I();
261 SkPaint paint; 265 SkPaint paint;
262 bool has_paint = false; // TODO: why is a default pai nt not the same? 266 bool has_paint = false; // TODO: why is a default pai nt not the same?
263 void draw(SkCanvas* c) { 267 void draw(SkCanvas* c, const SkMatrix&) {
264 c->drawPicture(picture.get(), &matrix, has_paint ? &paint : nullptr) ; 268 c->drawPicture(picture.get(), &matrix, has_paint ? &paint : nullptr) ;
265 } 269 }
266 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 270 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
267 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); } 271 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); }
268 }; 272 };
269 struct DrawShadowedPicture final : Op { 273 struct DrawShadowedPicture final : Op {
270 static const auto kType = Type::DrawShadowedPicture; 274 static const auto kType = Type::DrawShadowedPicture;
271 DrawShadowedPicture(const SkPicture* picture, const SkMatrix* matrix, co nst SkPaint* paint) 275 DrawShadowedPicture(const SkPicture* picture, const SkMatrix* matrix, co nst SkPaint* paint)
272 : picture(sk_ref_sp(picture)) { 276 : picture(sk_ref_sp(picture)) {
273 if (matrix) { this->matrix = *matrix; } 277 if (matrix) { this->matrix = *matrix; }
274 if (paint) { this->paint = *paint; } 278 if (paint) { this->paint = *paint; }
275 } 279 }
276 sk_sp<const SkPicture> picture; 280 sk_sp<const SkPicture> picture;
277 SkMatrix matrix = SkMatrix::I(); 281 SkMatrix matrix = SkMatrix::I();
278 SkPaint paint; 282 SkPaint paint;
279 void draw(SkCanvas* c) { 283 void draw(SkCanvas* c, const SkMatrix&) {
280 #ifdef SK_EXPERIMENTAL_SHADOWING 284 #ifdef SK_EXPERIMENTAL_SHADOWING
281 c->drawShadowedPicture(picture.get(), &matrix, &paint); 285 c->drawShadowedPicture(picture.get(), &matrix, &paint);
282 #endif 286 #endif
283 } 287 }
284 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 288 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
285 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); } 289 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); }
286 }; 290 };
287 291
288 struct DrawImage final : Op { 292 struct DrawImage final : Op {
289 static const auto kType = Type::DrawImage; 293 static const auto kType = Type::DrawImage;
290 DrawImage(sk_sp<const SkImage>&& image, SkScalar x, SkScalar y, const Sk Paint* paint) 294 DrawImage(sk_sp<const SkImage>&& image, SkScalar x, SkScalar y, const Sk Paint* paint)
291 : image(std::move(image)), x(x), y(y) { 295 : image(std::move(image)), x(x), y(y) {
292 if (paint) { this->paint = *paint; } 296 if (paint) { this->paint = *paint; }
293 } 297 }
294 sk_sp<const SkImage> image; 298 sk_sp<const SkImage> image;
295 SkScalar x,y; 299 SkScalar x,y;
296 SkPaint paint; 300 SkPaint paint;
297 void draw(SkCanvas* c) { c->drawImage(image.get(), x,y, &paint); } 301 void draw(SkCanvas* c, const SkMatrix&) { c->drawImage(image.get(), x,y, &paint); }
298 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint, &image); } 302 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint, &image); }
299 }; 303 };
300 struct DrawImageNine final : Op { 304 struct DrawImageNine final : Op {
301 static const auto kType = Type::DrawImageNine; 305 static const auto kType = Type::DrawImageNine;
302 DrawImageNine(sk_sp<const SkImage>&& image, 306 DrawImageNine(sk_sp<const SkImage>&& image,
303 const SkIRect& center, const SkRect& dst, const SkPaint* p aint) 307 const SkIRect& center, const SkRect& dst, const SkPaint* p aint)
304 : image(std::move(image)), center(center), dst(dst) { 308 : image(std::move(image)), center(center), dst(dst) {
305 if (paint) { this->paint = *paint; } 309 if (paint) { this->paint = *paint; }
306 } 310 }
307 sk_sp<const SkImage> image; 311 sk_sp<const SkImage> image;
308 SkIRect center; 312 SkIRect center;
309 SkRect dst; 313 SkRect dst;
310 SkPaint paint; 314 SkPaint paint;
311 void draw(SkCanvas* c) { c->drawImageNine(image.get(), center, dst, &pai nt); } 315 void draw(SkCanvas* c, const SkMatrix&) {
316 c->drawImageNine(image.get(), center, dst, &paint);
317 }
312 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint, &image); } 318 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint, &image); }
313 }; 319 };
314 struct DrawImageRect final : Op { 320 struct DrawImageRect final : Op {
315 static const auto kType = Type::DrawImageRect; 321 static const auto kType = Type::DrawImageRect;
316 DrawImageRect(sk_sp<const SkImage>&& image, const SkRect* src, const SkR ect& dst, 322 DrawImageRect(sk_sp<const SkImage>&& image, const SkRect* src, const SkR ect& dst,
317 const SkPaint* paint, SkCanvas::SrcRectConstraint constrai nt) 323 const SkPaint* paint, SkCanvas::SrcRectConstraint constrai nt)
318 : image(std::move(image)), dst(dst), constraint(constraint) { 324 : image(std::move(image)), dst(dst), constraint(constraint) {
319 this->src = src ? *src : SkRect::MakeIWH(image->width(), image->heig ht()); 325 this->src = src ? *src : SkRect::MakeIWH(image->width(), image->heig ht());
320 if (paint) { this->paint = *paint; } 326 if (paint) { this->paint = *paint; }
321 } 327 }
322 sk_sp<const SkImage> image; 328 sk_sp<const SkImage> image;
323 SkRect src, dst; 329 SkRect src, dst;
324 SkPaint paint; 330 SkPaint paint;
325 SkCanvas::SrcRectConstraint constraint; 331 SkCanvas::SrcRectConstraint constraint;
326 void draw(SkCanvas* c) { 332 void draw(SkCanvas* c, const SkMatrix&) {
327 c->drawImageRect(image.get(), src, dst, &paint, constraint); 333 c->drawImageRect(image.get(), src, dst, &paint, constraint);
328 } 334 }
329 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint, &image); } 335 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint, &image); }
330 }; 336 };
331 struct DrawImageLattice final : Op { 337 struct DrawImageLattice final : Op {
332 static const auto kType = Type::DrawImageLattice; 338 static const auto kType = Type::DrawImageLattice;
333 DrawImageLattice(sk_sp<const SkImage>&& image, int xs, int ys, 339 DrawImageLattice(sk_sp<const SkImage>&& image, int xs, int ys,
334 const SkRect& dst, const SkPaint* paint) 340 const SkRect& dst, const SkPaint* paint)
335 : image(std::move(image)), xs(xs), ys(ys), dst(dst) { 341 : image(std::move(image)), xs(xs), ys(ys), dst(dst) {
336 if (paint) { this->paint = *paint; } 342 if (paint) { this->paint = *paint; }
337 } 343 }
338 sk_sp<const SkImage> image; 344 sk_sp<const SkImage> image;
339 int xs, ys; 345 int xs, ys;
340 SkRect dst; 346 SkRect dst;
341 SkPaint paint; 347 SkPaint paint;
342 void draw(SkCanvas* c) { 348 void draw(SkCanvas* c, const SkMatrix&) {
343 auto xdivs = pod<int>(this, 0), 349 auto xdivs = pod<int>(this, 0),
344 ydivs = pod<int>(this, xs*sizeof(int)); 350 ydivs = pod<int>(this, xs*sizeof(int));
345 c->drawImageLattice(image.get(), {xdivs, xs, ydivs, ys}, dst, &paint ); 351 c->drawImageLattice(image.get(), {xdivs, xs, ydivs, ys}, dst, &paint );
346 } 352 }
347 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint, &image); } 353 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint, &image); }
348 }; 354 };
349 355
350 struct DrawText final : Op { 356 struct DrawText final : Op {
351 static const auto kType = Type::DrawText; 357 static const auto kType = Type::DrawText;
352 DrawText(size_t bytes, SkScalar x, SkScalar y, const SkPaint& paint) 358 DrawText(size_t bytes, SkScalar x, SkScalar y, const SkPaint& paint)
353 : bytes(bytes), x(x), y(y), paint(paint) {} 359 : bytes(bytes), x(x), y(y), paint(paint) {}
354 size_t bytes; 360 size_t bytes;
355 SkScalar x,y; 361 SkScalar x,y;
356 SkPaint paint; 362 SkPaint paint;
357 void draw(SkCanvas* c) { c->drawText(pod<void>(this), bytes, x,y, paint) ; } 363 void draw(SkCanvas* c, const SkMatrix&) {
364 c->drawText(pod<void>(this), bytes, x,y, paint);
365 }
358 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 366 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
359 }; 367 };
360 struct DrawPosText final : Op { 368 struct DrawPosText final : Op {
361 static const auto kType = Type::DrawPosText; 369 static const auto kType = Type::DrawPosText;
362 DrawPosText(size_t bytes, const SkPaint& paint, int n) 370 DrawPosText(size_t bytes, const SkPaint& paint, int n)
363 : bytes(bytes), paint(paint), n(n) {} 371 : bytes(bytes), paint(paint), n(n) {}
364 size_t bytes; 372 size_t bytes;
365 SkPaint paint; 373 SkPaint paint;
366 int n; 374 int n;
367 void draw(SkCanvas* c) { 375 void draw(SkCanvas* c, const SkMatrix&) {
368 auto points = pod<SkPoint>(this); 376 auto points = pod<SkPoint>(this);
369 auto text = pod<void>(this, n*sizeof(SkPoint)); 377 auto text = pod<void>(this, n*sizeof(SkPoint));
370 c->drawPosText(text, bytes, points, paint); 378 c->drawPosText(text, bytes, points, paint);
371 } 379 }
372 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 380 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
373 }; 381 };
374 struct DrawPosTextH final : Op { 382 struct DrawPosTextH final : Op {
375 static const auto kType = Type::DrawPosTextH; 383 static const auto kType = Type::DrawPosTextH;
376 DrawPosTextH(size_t bytes, SkScalar y, const SkPaint& paint, int n) 384 DrawPosTextH(size_t bytes, SkScalar y, const SkPaint& paint, int n)
377 : bytes(bytes), y(y), paint(paint), n(n) {} 385 : bytes(bytes), y(y), paint(paint), n(n) {}
378 size_t bytes; 386 size_t bytes;
379 SkScalar y; 387 SkScalar y;
380 SkPaint paint; 388 SkPaint paint;
381 int n; 389 int n;
382 void draw(SkCanvas* c) { 390 void draw(SkCanvas* c, const SkMatrix&) {
383 auto xs = pod<SkScalar>(this); 391 auto xs = pod<SkScalar>(this);
384 auto text = pod<void>(this, n*sizeof(SkScalar)); 392 auto text = pod<void>(this, n*sizeof(SkScalar));
385 c->drawPosTextH(text, bytes, xs, y, paint); 393 c->drawPosTextH(text, bytes, xs, y, paint);
386 } 394 }
387 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 395 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
388 }; 396 };
389 struct DrawTextOnPath final : Op { 397 struct DrawTextOnPath final : Op {
390 static const auto kType = Type::DrawTextOnPath; 398 static const auto kType = Type::DrawTextOnPath;
391 DrawTextOnPath(size_t bytes, const SkPath& path, 399 DrawTextOnPath(size_t bytes, const SkPath& path,
392 const SkMatrix* matrix, const SkPaint& paint) 400 const SkMatrix* matrix, const SkPaint& paint)
393 : bytes(bytes), path(path), paint(paint) { 401 : bytes(bytes), path(path), paint(paint) {
394 if (matrix) { this->matrix = *matrix; } 402 if (matrix) { this->matrix = *matrix; }
395 } 403 }
396 size_t bytes; 404 size_t bytes;
397 SkPath path; 405 SkPath path;
398 SkMatrix matrix = SkMatrix::I(); 406 SkMatrix matrix = SkMatrix::I();
399 SkPaint paint; 407 SkPaint paint;
400 void draw(SkCanvas* c) { 408 void draw(SkCanvas* c, const SkMatrix&) {
401 c->drawTextOnPath(pod<void>(this), bytes, path, &matrix, paint); 409 c->drawTextOnPath(pod<void>(this), bytes, path, &matrix, paint);
402 } 410 }
403 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 411 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
404 void makeThreadsafe() { make_threadsafe(&path, &matrix); } 412 void makeThreadsafe() { make_threadsafe(&path, &matrix); }
405 }; 413 };
406 struct DrawTextRSXform final : Op { 414 struct DrawTextRSXform final : Op {
407 static const auto kType = Type::DrawTextRSXform; 415 static const auto kType = Type::DrawTextRSXform;
408 DrawTextRSXform(size_t bytes, const SkRect* cull, const SkPaint& paint) 416 DrawTextRSXform(size_t bytes, const SkRect* cull, const SkPaint& paint)
409 : bytes(bytes), paint(paint) { 417 : bytes(bytes), paint(paint) {
410 if (cull) { this->cull = *cull; } 418 if (cull) { this->cull = *cull; }
411 } 419 }
412 size_t bytes; 420 size_t bytes;
413 SkRect cull = kUnset; 421 SkRect cull = kUnset;
414 SkPaint paint; 422 SkPaint paint;
415 void draw(SkCanvas* c) { 423 void draw(SkCanvas* c, const SkMatrix&) {
416 c->drawTextRSXform(pod<void>(this), bytes, pod<SkRSXform>(this, byte s), 424 c->drawTextRSXform(pod<void>(this), bytes, pod<SkRSXform>(this, byte s),
417 maybe_unset(cull), paint); 425 maybe_unset(cull), paint);
418 } 426 }
419 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 427 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
420 }; 428 };
421 struct DrawTextBlob final : Op { 429 struct DrawTextBlob final : Op {
422 static const auto kType = Type::DrawTextBlob; 430 static const auto kType = Type::DrawTextBlob;
423 DrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPai nt& paint) 431 DrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPai nt& paint)
424 : blob(sk_ref_sp(blob)), x(x), y(y), paint(paint) {} 432 : blob(sk_ref_sp(blob)), x(x), y(y), paint(paint) {}
425 sk_sp<const SkTextBlob> blob; 433 sk_sp<const SkTextBlob> blob;
426 SkScalar x,y; 434 SkScalar x,y;
427 SkPaint paint; 435 SkPaint paint;
428 void draw(SkCanvas* c) { c->drawTextBlob(blob.get(), x,y, paint); } 436 void draw(SkCanvas* c, const SkMatrix&) {
437 c->drawTextBlob(blob.get(), x,y, paint);
438 }
429 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 439 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
430 }; 440 };
431 441
432 struct DrawPatch final : Op { 442 struct DrawPatch final : Op {
433 static const auto kType = Type::DrawPatch; 443 static const auto kType = Type::DrawPatch;
434 DrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoi nt texs[4], 444 DrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoi nt texs[4],
435 SkXfermode* xfermode, const SkPaint& paint) 445 SkXfermode* xfermode, const SkPaint& paint)
436 : xfermode(sk_ref_sp(xfermode)), paint(paint) { 446 : xfermode(sk_ref_sp(xfermode)), paint(paint) {
437 copy_v(this->cubics, cubics, 12); 447 copy_v(this->cubics, cubics, 12);
438 if (colors) { copy_v(this->colors, colors, 4); has_colors = true; } 448 if (colors) { copy_v(this->colors, colors, 4); has_colors = true; }
439 if (texs ) { copy_v(this->texs , texs , 4); has_texs = true; } 449 if (texs ) { copy_v(this->texs , texs , 4); has_texs = true; }
440 } 450 }
441 SkPoint cubics[12]; 451 SkPoint cubics[12];
442 SkColor colors[4]; 452 SkColor colors[4];
443 SkPoint texs[4]; 453 SkPoint texs[4];
444 sk_sp<SkXfermode> xfermode; 454 sk_sp<SkXfermode> xfermode;
445 SkPaint paint; 455 SkPaint paint;
446 bool has_colors = false; 456 bool has_colors = false;
447 bool has_texs = false; 457 bool has_texs = false;
448 void draw(SkCanvas* c) { 458 void draw(SkCanvas* c, const SkMatrix&) {
449 c->drawPatch(cubics, has_colors ? colors : nullptr, has_texs ? texs : nullptr, 459 c->drawPatch(cubics, has_colors ? colors : nullptr, has_texs ? texs : nullptr,
450 xfermode.get(), paint); 460 xfermode.get(), paint);
451 } 461 }
452 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 462 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
453 }; 463 };
454 struct DrawPoints final : Op { 464 struct DrawPoints final : Op {
455 static const auto kType = Type::DrawPoints; 465 static const auto kType = Type::DrawPoints;
456 DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPaint& paint) 466 DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPaint& paint)
457 : mode(mode), count(count), paint(paint) {} 467 : mode(mode), count(count), paint(paint) {}
458 SkCanvas::PointMode mode; 468 SkCanvas::PointMode mode;
459 size_t count; 469 size_t count;
460 SkPaint paint; 470 SkPaint paint;
461 void draw(SkCanvas* c) { c->drawPoints(mode, count, pod<SkPoint>(this), paint); } 471 void draw(SkCanvas* c, const SkMatrix&) {
472 c->drawPoints(mode, count, pod<SkPoint>(this), paint);
473 }
462 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); } 474 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint); }
463 }; 475 };
464 struct DrawVertices final : Op { 476 struct DrawVertices final : Op {
465 static const auto kType = Type::DrawVertices; 477 static const auto kType = Type::DrawVertices;
466 DrawVertices(SkCanvas::VertexMode mode, int count, SkXfermode* xfermode, int nindices, 478 DrawVertices(SkCanvas::VertexMode mode, int count, SkXfermode* xfermode, int nindices,
467 const SkPaint& paint, bool has_texs, bool has_colors, bool has_indices) 479 const SkPaint& paint, bool has_texs, bool has_colors, bool has_indices)
468 : mode(mode), count(count), xfermode(sk_ref_sp(xfermode)), nindices( nindices) 480 : mode(mode), count(count), xfermode(sk_ref_sp(xfermode)), nindices( nindices)
469 , paint(paint), has_texs(has_texs), has_colors(has_colors), has_indi ces(has_indices) {} 481 , paint(paint), has_texs(has_texs), has_colors(has_colors), has_indi ces(has_indices) {}
470 SkCanvas::VertexMode mode; 482 SkCanvas::VertexMode mode;
471 int count; 483 int count;
472 sk_sp<SkXfermode> xfermode; 484 sk_sp<SkXfermode> xfermode;
473 int nindices; 485 int nindices;
474 SkPaint paint; 486 SkPaint paint;
475 bool has_texs; 487 bool has_texs;
476 bool has_colors; 488 bool has_colors;
477 bool has_indices; 489 bool has_indices;
478 void draw(SkCanvas* c) { 490 void draw(SkCanvas* c, const SkMatrix&) {
479 SkPoint* vertices = pod<SkPoint>(this, 0); 491 SkPoint* vertices = pod<SkPoint>(this, 0);
480 size_t offset = count*sizeof(SkPoint); 492 size_t offset = count*sizeof(SkPoint);
481 493
482 SkPoint* texs = nullptr; 494 SkPoint* texs = nullptr;
483 if (has_texs) { 495 if (has_texs) {
484 texs = pod<SkPoint>(this, offset); 496 texs = pod<SkPoint>(this, offset);
485 offset += count*sizeof(SkPoint); 497 offset += count*sizeof(SkPoint);
486 } 498 }
487 499
488 SkColor* colors = nullptr; 500 SkColor* colors = nullptr;
(...skipping 18 matching lines...) Expand all
507 : atlas(sk_ref_sp(atlas)), count(count), xfermode(xfermode), has_col ors(has_colors) { 519 : atlas(sk_ref_sp(atlas)), count(count), xfermode(xfermode), has_col ors(has_colors) {
508 if (cull) { this->cull = *cull; } 520 if (cull) { this->cull = *cull; }
509 if (paint) { this->paint = *paint; } 521 if (paint) { this->paint = *paint; }
510 } 522 }
511 sk_sp<const SkImage> atlas; 523 sk_sp<const SkImage> atlas;
512 int count; 524 int count;
513 SkXfermode::Mode xfermode; 525 SkXfermode::Mode xfermode;
514 SkRect cull = kUnset; 526 SkRect cull = kUnset;
515 SkPaint paint; 527 SkPaint paint;
516 bool has_colors; 528 bool has_colors;
517 void draw(SkCanvas* c) { 529 void draw(SkCanvas* c, const SkMatrix&) {
518 auto xforms = pod<SkRSXform>(this, 0); 530 auto xforms = pod<SkRSXform>(this, 0);
519 auto texs = pod<SkRect>(this, count*sizeof(SkRSXform)); 531 auto texs = pod<SkRect>(this, count*sizeof(SkRSXform));
520 auto colors = has_colors 532 auto colors = has_colors
521 ? pod<SkColor>(this, count*(sizeof(SkRSXform) + sizeof(SkRect))) 533 ? pod<SkColor>(this, count*(sizeof(SkRSXform) + sizeof(SkRect)))
522 : nullptr; 534 : nullptr;
523 c->drawAtlas(atlas.get(), xforms, texs, colors, count, xfermode, 535 c->drawAtlas(atlas.get(), xforms, texs, colors, count, xfermode,
524 maybe_unset(cull), &paint); 536 maybe_unset(cull), &paint);
525 } 537 }
526 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint, &atlas); } 538 void optimizeFor(GrContext* ctx) { optimize_for(ctx, &paint, &atlas); }
527 }; 539 };
(...skipping 11 matching lines...) Expand all
539 } 551 }
540 SkASSERT(fUsed + skip <= fReserved); 552 SkASSERT(fUsed + skip <= fReserved);
541 auto op = (T*)(fBytes.get() + fUsed); 553 auto op = (T*)(fBytes.get() + fUsed);
542 fUsed += skip; 554 fUsed += skip;
543 new (op) T{ std::forward<Args>(args)... }; 555 new (op) T{ std::forward<Args>(args)... };
544 op->type = (uint32_t)T::kType; 556 op->type = (uint32_t)T::kType;
545 op->skip = skip; 557 op->skip = skip;
546 return op+1; 558 return op+1;
547 } 559 }
548 560
549 template <typename... Args> 561 template <typename Fn, typename... Args>
550 inline void SkLiteDL::map(void (*const fns[])(void*, Args...), Args... args) { 562 inline void SkLiteDL::map(const Fn fns[], Args... args) {
551 auto end = fBytes.get() + fUsed; 563 auto end = fBytes.get() + fUsed;
552 for (uint8_t* ptr = fBytes.get(); ptr < end; ) { 564 for (uint8_t* ptr = fBytes.get(); ptr < end; ) {
553 auto op = (Op*)ptr; 565 auto op = (Op*)ptr;
554 auto type = op->type; 566 auto type = op->type;
555 auto skip = op->skip; 567 auto skip = op->skip;
556 if (auto fn = fns[type]) { // We replace no-op functions with nullptrs 568 if (auto fn = fns[type]) { // We replace no-op functions with nullptrs
557 fn(op, args...); // to avoid the overhead of a pointless call . 569 fn(op, args...); // to avoid the overhead of a pointless call .
558 } 570 }
559 ptr += skip; 571 ptr += skip;
560 } 572 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 if (colors) { 735 if (colors) {
724 bytes += count*sizeof(SkColor); 736 bytes += count*sizeof(SkColor);
725 } 737 }
726 void* pod = this->push<DrawAtlas>(bytes, 738 void* pod = this->push<DrawAtlas>(bytes,
727 atlas, count, xfermode, cull, paint, color s != nullptr); 739 atlas, count, xfermode, cull, paint, color s != nullptr);
728 copy_v(pod, xforms, count, 740 copy_v(pod, xforms, count,
729 texs, count, 741 texs, count,
730 colors, colors ? count : 0); 742 colors, colors ? count : 0);
731 } 743 }
732 744
733 typedef void(* skcanvas_fn)(void*, SkCanvas*); 745 typedef void(* draw_fn)(void*, SkCanvas*, const SkMatrix&);
734 typedef void(*grcontext_fn)(void*, GrContext*); 746 typedef void(*grcontext_fn)(void*, GrContext*);
735 typedef void(* void_fn)(void*); 747 typedef void(* void_fn)(void*);
736 748
737 // All ops implement draw(). 749 // All ops implement draw().
738 #define M(T) [](void* op, SkCanvas* c) { ((T*)op)->draw(c); }, 750 #define M(T) [](void* op, SkCanvas* c, const SkMatrix& original) { ((T*)op)->dra w(c, original); },
739 static const skcanvas_fn draw_fns[] = { TYPES(M) }; 751 static const draw_fn draw_fns[] = { TYPES(M) };
740 #undef M 752 #undef M
741 753
742 // Ops that implement optimizeFor() or makeThreadsafe() return void from those f unctions; 754 // Ops that implement optimizeFor() or makeThreadsafe() return void from those f unctions;
743 // the (throwing) defaults return int. 755 // the (throwing) defaults return int.
744 #define M(T) std::is_void<decltype(((T*)nullptr)->optimizeFor(nullptr))>::value \ 756 #define M(T) std::is_void<decltype(((T*)nullptr)->optimizeFor(nullptr))>::value \
745 ? [](void* op, GrContext* ctx) { ((T*)op)->optimizeFor(ctx); } : (grcontext_ fn)nullptr, 757 ? [](void* op, GrContext* ctx) { ((T*)op)->optimizeFor(ctx); } : (grcontext_ fn)nullptr,
746 static const grcontext_fn optimize_for_fns[] = { TYPES(M) }; 758 static const grcontext_fn optimize_for_fns[] = { TYPES(M) };
747 #undef M 759 #undef M
748 760
749 #define M(T) std::is_void<decltype(((T*)nullptr)->makeThreadsafe())>::value \ 761 #define M(T) std::is_void<decltype(((T*)nullptr)->makeThreadsafe())>::value \
750 ? [](void* op) { ((T*)op)->makeThreadsafe(); } : (void_fn)nullptr, 762 ? [](void* op) { ((T*)op)->makeThreadsafe(); } : (void_fn)nullptr,
751 static const void_fn make_threadsafe_fns[] = { TYPES(M) }; 763 static const void_fn make_threadsafe_fns[] = { TYPES(M) };
752 #undef M 764 #undef M
753 765
754 // Older libstdc++ has pre-standard std::has_trivial_destructor. 766 // Older libstdc++ has pre-standard std::has_trivial_destructor.
755 #if defined(__GLIBCXX__) && (__GLIBCXX__ < 20130000) 767 #if defined(__GLIBCXX__) && (__GLIBCXX__ < 20130000)
756 template <typename T> using can_skip_destructor = std::has_trivial_destructo r<T>; 768 template <typename T> using can_skip_destructor = std::has_trivial_destructo r<T>;
757 #else 769 #else
758 template <typename T> using can_skip_destructor = std::is_trivially_destruct ible<T>; 770 template <typename T> using can_skip_destructor = std::is_trivially_destruct ible<T>;
759 #endif 771 #endif
760 772
761 // Most state ops (matrix, clip, save, restore) have a trivial destructor. 773 // Most state ops (matrix, clip, save, restore) have a trivial destructor.
762 #define M(T) !can_skip_destructor<T>::value ? [](void* op) { ((T*)op)->~T(); } : (void_fn)nullptr, 774 #define M(T) !can_skip_destructor<T>::value ? [](void* op) { ((T*)op)->~T(); } : (void_fn)nullptr,
763 static const void_fn dtor_fns[] = { TYPES(M) }; 775 static const void_fn dtor_fns[] = { TYPES(M) };
764 #undef M 776 #undef M
765 777
766 void SkLiteDL::onDraw (SkCanvas* canvas) { this->map(draw_fns, canvas); } 778 void SkLiteDL::onDraw(SkCanvas* canvas) {
767 void SkLiteDL::optimizeFor (GrContext* ctx) { this->map(optimize_for_fns, ct x); } 779 SkMatrix original = canvas->getTotalMatrix();
768 void SkLiteDL::makeThreadsafe() { this->map(make_threadsafe_fns) ; } 780 this->map(draw_fns, canvas, original);
781 }
782 void SkLiteDL::optimizeFor (GrContext* ctx) { this->map(optimize_for_fns, ctx) ; }
783 void SkLiteDL::makeThreadsafe() { this->map(make_threadsafe_fns); }
769 784
770 SkRect SkLiteDL::onGetBounds() { 785 SkRect SkLiteDL::onGetBounds() {
771 return fBounds; 786 return fBounds;
772 } 787 }
773 788
774 bool SkLiteDL::empty() const { 789 bool SkLiteDL::empty() const {
775 return fUsed == 0; 790 return fUsed == 0;
776 } 791 }
777 792
778 SkLiteDL:: SkLiteDL(SkRect bounds) : fUsed(0), fReserved(0), fBounds(bounds) {} 793 SkLiteDL:: SkLiteDL(SkRect bounds) : fUsed(0), fReserved(0), fBounds(bounds) {}
779 794
780 SkLiteDL::~SkLiteDL() { 795 SkLiteDL::~SkLiteDL() {
781 this->reset(SkRect::MakeEmpty()); 796 this->reset(SkRect::MakeEmpty());
782 } 797 }
783 798
784 sk_sp<SkLiteDL> SkLiteDL::New(SkRect bounds) { 799 sk_sp<SkLiteDL> SkLiteDL::New(SkRect bounds) {
785 return sk_sp<SkLiteDL>(new SkLiteDL(bounds)); 800 return sk_sp<SkLiteDL>(new SkLiteDL(bounds));
786 } 801 }
787 802
788 void SkLiteDL::reset(SkRect bounds) { 803 void SkLiteDL::reset(SkRect bounds) {
789 SkASSERT(this->unique()); 804 SkASSERT(this->unique());
790 this->map(dtor_fns); 805 this->map(dtor_fns);
791 806
792 // Leave fBytes and fReserved alone. 807 // Leave fBytes and fReserved alone.
793 fUsed = 0; 808 fUsed = 0;
794 fBounds = bounds; 809 fBounds = bounds;
795 } 810 }
OLDNEW
« no previous file with comments | « src/core/SkLiteDL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698