OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkAnnotation.h" |
8 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkColorFilter.h" |
| 11 #include "SkDrawLooper.h" |
| 12 #include "SkImageFilter.h" |
| 13 #include "SkMaskFilter.h" |
9 #include "SkPath.h" | 14 #include "SkPath.h" |
| 15 #include "SkPathEffect.h" |
| 16 #include "SkRasterizer.h" |
10 #include "SkRect.h" | 17 #include "SkRect.h" |
11 #include "SkRemote.h" | 18 #include "SkRemote.h" |
12 #include "SkShader.h" | 19 #include "SkShader.h" |
13 #include "SkTHash.h" | 20 #include "SkTHash.h" |
14 | 21 |
15 namespace SkRemote { | 22 namespace SkRemote { |
16 | 23 |
17 Misc Misc::CreateFrom(const SkPaint& paint) { | 24 Misc Misc::CreateFrom(const SkPaint& paint) { |
18 Misc misc = { | 25 Misc misc = { |
19 paint.getColor(), | 26 paint.getColor(), |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 103 } |
97 AutoID& operator=(AutoID&&) = delete; | 104 AutoID& operator=(AutoID&&) = delete; |
98 | 105 |
99 operator ID () const { return fID; } | 106 operator ID () const { return fID; } |
100 | 107 |
101 private: | 108 private: |
102 Encoder* fEncoder; | 109 Encoder* fEncoder; |
103 const ID fID; | 110 const ID fID; |
104 }; | 111 }; |
105 | 112 |
| 113 // Like AutoID, but for CommonIDs. |
| 114 class AutoCommonIDs : ::SkNoncopyable { |
| 115 public: |
| 116 explicit AutoCommonIDs(Encoder* encoder, const SkPaint& paint) |
| 117 : fEncoder(encoder) { |
| 118 fIDs.misc = fEncoder->define(Misc::CreateFrom(paint)); |
| 119 fIDs.patheffect = fEncoder->define(paint.getPathEffect()); |
| 120 fIDs.shader = fEncoder->define(paint.getShader()); |
| 121 fIDs.xfermode = fEncoder->define(paint.getXfermode()); |
| 122 fIDs.maskfilter = fEncoder->define(paint.getMaskFilter()); |
| 123 fIDs.colorfilter = fEncoder->define(paint.getColorFilter()); |
| 124 fIDs.rasterizer = fEncoder->define(paint.getRasterizer()); |
| 125 fIDs.looper = fEncoder->define(paint.getLooper()); |
| 126 fIDs.imagefilter = fEncoder->define(paint.getImageFilter()); |
| 127 fIDs.annotation = fEncoder->define(paint.getAnnotation()); |
| 128 } |
| 129 ~AutoCommonIDs() { |
| 130 if (fEncoder) { |
| 131 fEncoder->undefine(fIDs.misc); |
| 132 fEncoder->undefine(fIDs.patheffect); |
| 133 fEncoder->undefine(fIDs.shader); |
| 134 fEncoder->undefine(fIDs.xfermode); |
| 135 fEncoder->undefine(fIDs.maskfilter); |
| 136 fEncoder->undefine(fIDs.colorfilter); |
| 137 fEncoder->undefine(fIDs.rasterizer); |
| 138 fEncoder->undefine(fIDs.looper); |
| 139 fEncoder->undefine(fIDs.imagefilter); |
| 140 fEncoder->undefine(fIDs.annotation); |
| 141 } |
| 142 } |
| 143 |
| 144 AutoCommonIDs(AutoCommonIDs&& o) : fEncoder(o.fEncoder), fIDs(o.fIDs
) { |
| 145 o.fEncoder = nullptr; |
| 146 } |
| 147 AutoID& operator=(AutoID&&) = delete; |
| 148 |
| 149 operator Encoder::CommonIDs () const { return fIDs; } |
| 150 |
| 151 private: |
| 152 Encoder* fEncoder; |
| 153 Encoder::CommonIDs fIDs; |
| 154 }; |
| 155 |
106 template <typename T> | 156 template <typename T> |
107 AutoID id(const T& val) { return AutoID(fEncoder, val); } | 157 AutoID id(const T& val) { return AutoID(fEncoder, val); } |
108 | 158 |
| 159 AutoCommonIDs commonIDs(const SkPaint& paint) { return AutoCommonIDs(fEn
coder, paint); } |
| 160 |
109 void willSave() override { fEncoder-> save(); } | 161 void willSave() override { fEncoder-> save(); } |
110 void didRestore() override { fEncoder->restore(); } | 162 void didRestore() override { fEncoder->restore(); } |
111 | 163 |
112 void didConcat(const SkMatrix&) override { this->didSetMatrix(this->g
etTotalMatrix()); } | 164 void didConcat(const SkMatrix&) override { this->didSetMatrix(this->g
etTotalMatrix()); } |
113 void didSetMatrix(const SkMatrix& matrix) override { | 165 void didSetMatrix(const SkMatrix& matrix) override { |
114 fEncoder->setMatrix(this->id(matrix)); | 166 fEncoder->setMatrix(this->id(matrix)); |
115 } | 167 } |
116 | 168 |
117 void onDrawOval(const SkRect& oval, const SkPaint& paint) override { | 169 void onDrawOval(const SkRect& oval, const SkPaint& paint) override { |
118 SkPath path; | 170 SkPath path; |
(...skipping 15 matching lines...) Expand all Loading... |
134 | 186 |
135 void onDrawDRRect(const SkRRect& outside, const SkRRect& inside, | 187 void onDrawDRRect(const SkRRect& outside, const SkRRect& inside, |
136 const SkPaint& paint) override { | 188 const SkPaint& paint) override { |
137 SkPath path; | 189 SkPath path; |
138 path.addRRect(outside); | 190 path.addRRect(outside); |
139 path.addRRect(inside, SkPath::kCCW_Direction); | 191 path.addRRect(inside, SkPath::kCCW_Direction); |
140 this->onDrawPath(path, paint); | 192 this->onDrawPath(path, paint); |
141 } | 193 } |
142 | 194 |
143 void onDrawPath(const SkPath& path, const SkPaint& paint) override { | 195 void onDrawPath(const SkPath& path, const SkPaint& paint) override { |
144 auto p = this->id(path), | 196 auto common = this->commonIDs(paint); |
145 m = this->id(Misc::CreateFrom(paint)), | 197 auto p = this->id(path); |
146 s = this->id(paint.getShader()), | |
147 x = this->id(paint.getXfermode()); | |
148 | 198 |
149 if (paint.getStyle() == SkPaint::kFill_Style) { | 199 if (paint.getStyle() == SkPaint::kFill_Style) { |
150 fEncoder->fillPath(p, m, s, x); | 200 fEncoder->fillPath(p, common); |
151 } else { | 201 } else { |
152 // TODO: handle kStrokeAndFill_Style | 202 // TODO: handle kStrokeAndFill_Style |
153 fEncoder->strokePath(p, m, s, x, this->id(Stroke::CreateFrom(pai
nt))); | 203 fEncoder->strokePath(p, common, this->id(Stroke::CreateFrom(pain
t))); |
154 } | 204 } |
155 } | 205 } |
156 | 206 |
157 void onDrawPaint(const SkPaint& paint) override { | 207 void onDrawPaint(const SkPaint& paint) override { |
158 SkPath path; | 208 SkPath path; |
159 path.setFillType(SkPath::kInverseWinding_FillType); // Either inver
se FillType is fine. | 209 path.setFillType(SkPath::kInverseWinding_FillType); // Either inver
se FillType is fine. |
160 this->onDrawPath(path, paint); | 210 this->onDrawPath(path, paint); |
161 } | 211 } |
162 | 212 |
163 void onDrawText(const void* text, size_t byteLength, | 213 void onDrawText(const void* text, size_t byteLength, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 explicit Decoder(SkCanvas* canvas) : fCanvas(canvas) {} | 266 explicit Decoder(SkCanvas* canvas) : fCanvas(canvas) {} |
217 | 267 |
218 private: | 268 private: |
219 template <typename Map, typename T> | 269 template <typename Map, typename T> |
220 ID define(Type type, Map* map, const T& val) { | 270 ID define(Type type, Map* map, const T& val) { |
221 ID id(type, fNextID++); | 271 ID id(type, fNextID++); |
222 map->set(id, val); | 272 map->set(id, val); |
223 return id; | 273 return id; |
224 } | 274 } |
225 | 275 |
226 ID define(const SkMatrix& v) override {return this->define(Type::kMatrix
, &fMatrix, v);} | 276 #define O override |
227 ID define(const Misc& v) override {return this->define(Type::kMisc,
&fMisc, v);} | 277 ID define(const SkMatrix& v) O {return this->define(Type::kMatrix,
&fMatrix, v);} |
228 ID define(const SkPath& v) override {return this->define(Type::kPath,
&fPath, v);} | 278 ID define(const Misc& v) O {return this->define(Type::kMisc,
&fMisc, v);} |
229 ID define(const Stroke& v) override {return this->define(Type::kStroke
, &fStroke, v);} | 279 ID define(const SkPath& v) O {return this->define(Type::kPath,
&fPath, v);} |
230 ID define(SkShader* v) override {return this->define(Type::kShader
, &fShader, v);} | 280 ID define(const Stroke& v) O {return this->define(Type::kStroke,
&fStroke, v);} |
231 ID define(SkXfermode* v) override {return this->define(Type::kXfermo
de, &fXfermode, v);} | 281 ID define(SkPathEffect* v) O {return this->define(Type::kPathEffect,
&fPathEffect, v);} |
| 282 ID define(SkShader* v) O {return this->define(Type::kShader,
&fShader, v);} |
| 283 ID define(SkXfermode* v) O {return this->define(Type::kXfermode,
&fXfermode, v);} |
| 284 ID define(SkMaskFilter* v) O {return this->define(Type::kMaskFilter,
&fMaskFilter, v);} |
| 285 ID define(SkColorFilter* v) O {return this->define(Type::kColorFilter,
&fColorFilter, v);} |
| 286 ID define(SkRasterizer* v) O {return this->define(Type::kRasterizer,
&fRasterizer, v);} |
| 287 ID define(SkDrawLooper* v) O {return this->define(Type::kDrawLooper,
&fDrawLooper, v);} |
| 288 ID define(SkImageFilter* v) O {return this->define(Type::kImageFilter,
&fImageFilter, v);} |
| 289 ID define(SkAnnotation* v) O {return this->define(Type::kAnnotation,
&fAnnotation, v);} |
| 290 #undef O |
| 291 |
232 | 292 |
233 void undefine(ID id) override { | 293 void undefine(ID id) override { |
234 switch(id.type()) { | 294 switch(id.type()) { |
235 case Type::kMatrix: return fMatrix .remove(id); | 295 case Type::kMatrix: return fMatrix .remove(id); |
236 case Type::kMisc: return fMisc .remove(id); | 296 case Type::kMisc: return fMisc .remove(id); |
237 case Type::kPath: return fPath .remove(id); | 297 case Type::kPath: return fPath .remove(id); |
238 case Type::kStroke: return fStroke .remove(id); | 298 case Type::kStroke: return fStroke .remove(id); |
239 case Type::kShader: return fShader .remove(id); | 299 case Type::kPathEffect: return fPathEffect .remove(id); |
240 case Type::kXfermode: return fXfermode.remove(id); | 300 case Type::kShader: return fShader .remove(id); |
| 301 case Type::kXfermode: return fXfermode .remove(id); |
| 302 case Type::kMaskFilter: return fMaskFilter .remove(id); |
| 303 case Type::kColorFilter: return fColorFilter.remove(id); |
| 304 case Type::kRasterizer: return fRasterizer .remove(id); |
| 305 case Type::kDrawLooper: return fDrawLooper .remove(id); |
| 306 case Type::kImageFilter: return fImageFilter.remove(id); |
| 307 case Type::kAnnotation: return fAnnotation .remove(id); |
241 }; | 308 }; |
242 } | 309 } |
243 | 310 |
| 311 void applyCommon(const CommonIDs& common, SkPaint* paint) const { |
| 312 fMisc.find(common.misc).applyTo(paint); |
| 313 paint->setPathEffect (fPathEffect .find(common.patheffect)); |
| 314 paint->setShader (fShader .find(common.shader)); |
| 315 paint->setXfermode (fXfermode .find(common.xfermode)); |
| 316 paint->setMaskFilter (fMaskFilter .find(common.maskfilter)); |
| 317 paint->setColorFilter(fColorFilter.find(common.colorfilter)); |
| 318 paint->setRasterizer (fRasterizer .find(common.rasterizer)); |
| 319 paint->setLooper (fDrawLooper .find(common.looper)); |
| 320 paint->setImageFilter(fImageFilter.find(common.imagefilter)); |
| 321 paint->setAnnotation (fAnnotation .find(common.annotation)); |
| 322 } |
| 323 |
244 void save() override { fCanvas->save(); } | 324 void save() override { fCanvas->save(); } |
245 void restore() override { fCanvas->restore(); } | 325 void restore() override { fCanvas->restore(); } |
246 | 326 |
247 void setMatrix(ID matrix) override { fCanvas->setMatrix(fMatrix.find(mat
rix)); } | 327 void setMatrix(ID matrix) override { fCanvas->setMatrix(fMatrix.find(mat
rix)); } |
248 | 328 |
249 void clipPath(ID path, SkRegion::Op op, bool aa) override { | 329 void clipPath(ID path, SkRegion::Op op, bool aa) override { |
250 fCanvas->clipPath(fPath.find(path), op, aa); | 330 fCanvas->clipPath(fPath.find(path), op, aa); |
251 } | 331 } |
252 void fillPath(ID path, ID misc, ID shader, ID xfermode) override { | 332 void fillPath(ID path, CommonIDs common) override { |
253 SkPaint paint; | 333 SkPaint paint; |
254 paint.setStyle(SkPaint::kFill_Style); | 334 paint.setStyle(SkPaint::kFill_Style); |
255 fMisc.find(misc).applyTo(&paint); | 335 this->applyCommon(common, &paint); |
256 paint.setShader (fShader .find(shader)); | |
257 paint.setXfermode(fXfermode.find(xfermode)); | |
258 fCanvas->drawPath(fPath.find(path), paint); | 336 fCanvas->drawPath(fPath.find(path), paint); |
259 } | 337 } |
260 void strokePath(ID path, ID misc, ID shader, ID xfermode, ID stroke) ove
rride { | 338 void strokePath(ID path, CommonIDs common, ID stroke) override { |
261 SkPaint paint; | 339 SkPaint paint; |
262 paint.setStyle(SkPaint::kStroke_Style); | 340 paint.setStyle(SkPaint::kStroke_Style); |
263 fMisc .find(misc ).applyTo(&paint); | 341 this->applyCommon(common, &paint); |
264 fStroke.find(stroke).applyTo(&paint); | 342 fStroke.find(stroke).applyTo(&paint); |
265 paint.setShader (fShader .find(shader)); | |
266 paint.setXfermode(fXfermode.find(xfermode)); | |
267 fCanvas->drawPath(fPath.find(path), paint); | 343 fCanvas->drawPath(fPath.find(path), paint); |
268 } | 344 } |
269 | 345 |
270 // Maps ID -> T. | 346 // Maps ID -> T. |
271 template <typename T, Type kType> | 347 template <typename T, Type kType> |
272 class IDMap { | 348 class IDMap { |
273 public: | 349 public: |
274 ~IDMap() { | 350 ~IDMap() { |
275 // A well-behaved client always cleans up its definitions. | 351 // A well-behaved client always cleans up its definitions. |
276 SkASSERT(fMap.count() == 0); | 352 SkASSERT(fMap.count() == 0); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 T** val = fMap.find(id); | 401 T** val = fMap.find(id); |
326 SkASSERT(val); | 402 SkASSERT(val); |
327 return *val; | 403 return *val; |
328 } | 404 } |
329 | 405 |
330 private: | 406 private: |
331 SkTHashMap<ID, T*> fMap; | 407 SkTHashMap<ID, T*> fMap; |
332 }; | 408 }; |
333 | 409 |
334 | 410 |
335 IDMap<SkMatrix , Type::kMatrix> fMatrix; | 411 IDMap<SkMatrix , Type::kMatrix > fMatrix; |
336 IDMap<Misc , Type::kMisc > fMisc; | 412 IDMap<Misc , Type::kMisc > fMisc; |
337 IDMap<SkPath , Type::kPath > fPath; | 413 IDMap<SkPath , Type::kPath > fPath; |
338 IDMap<Stroke , Type::kStroke> fStroke; | 414 IDMap<Stroke , Type::kStroke > fStroke; |
339 ReffedIDMap<SkShader , Type::kShader> fShader; | 415 ReffedIDMap<SkPathEffect , Type::kPathEffect > fPathEffect; |
340 ReffedIDMap<SkXfermode, Type::kXfermode> fXfermode; | 416 ReffedIDMap<SkShader , Type::kShader > fShader; |
| 417 ReffedIDMap<SkXfermode , Type::kXfermode > fXfermode; |
| 418 ReffedIDMap<SkMaskFilter , Type::kMaskFilter > fMaskFilter; |
| 419 ReffedIDMap<SkColorFilter, Type::kColorFilter> fColorFilter; |
| 420 ReffedIDMap<SkRasterizer , Type::kRasterizer > fRasterizer; |
| 421 ReffedIDMap<SkDrawLooper , Type::kDrawLooper > fDrawLooper; |
| 422 ReffedIDMap<SkImageFilter, Type::kImageFilter> fImageFilter; |
| 423 ReffedIDMap<SkAnnotation , Type::kAnnotation > fAnnotation; |
341 | 424 |
342 SkCanvas* fCanvas; | 425 SkCanvas* fCanvas; |
343 uint64_t fNextID = 0; | 426 uint64_t fNextID = 0; |
344 }; | 427 }; |
345 | 428 |
346 Encoder* NewDecoder(SkCanvas* canvas) { return new Decoder(canvas); } | 429 Encoder* NewDecoder(SkCanvas* canvas) { return new Decoder(canvas); } |
347 | 430 |
348 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // | 431 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // |
349 | 432 |
350 class CachingEncoder final : public Encoder { | 433 class CachingEncoder final : public Encoder { |
351 public: | 434 public: |
352 explicit CachingEncoder(Encoder* wrapped) : fWrapped(wrapped) {} | 435 explicit CachingEncoder(Encoder* wrapped) : fWrapped(wrapped) {} |
353 | 436 |
354 private: | 437 private: |
355 struct Undef { | 438 struct Undef { |
356 Encoder* fEncoder; | 439 Encoder* fEncoder; |
357 template <typename T> | 440 template <typename T> |
358 void operator()(const T&, ID* id) const { fEncoder->undefine(*id); } | 441 void operator()(const T&, ID* id) const { fEncoder->undefine(*id); } |
359 }; | 442 }; |
360 | 443 |
361 ~CachingEncoder() override { | 444 ~CachingEncoder() override { |
362 Undef undef{fWrapped}; | 445 Undef undef{fWrapped}; |
363 fMatrix .foreach(undef); | 446 fMatrix .foreach(undef); |
364 fMisc .foreach(undef); | 447 fMisc .foreach(undef); |
365 fPath .foreach(undef); | 448 fPath .foreach(undef); |
366 fStroke .foreach(undef); | 449 fPathEffect .foreach(undef); |
367 fShader .foreach(undef); | 450 fStroke .foreach(undef); |
368 fXfermode.foreach(undef); | 451 fShader .foreach(undef); |
| 452 fXfermode .foreach(undef); |
| 453 fMaskFilter .foreach(undef); |
| 454 fColorFilter.foreach(undef); |
| 455 fRasterizer .foreach(undef); |
| 456 fDrawLooper .foreach(undef); |
| 457 fImageFilter.foreach(undef); |
| 458 fAnnotation .foreach(undef); |
369 } | 459 } |
370 | 460 |
371 template <typename Map, typename T> | 461 template <typename Map, typename T> |
372 ID define(Map* map, const T& v) { | 462 ID define(Map* map, const T& v) { |
373 if (const ID* id = map->find(v)) { | 463 if (const ID* id = map->find(v)) { |
374 return *id; | 464 return *id; |
375 } | 465 } |
376 ID id = fWrapped->define(v); | 466 ID id = fWrapped->define(v); |
377 map->set(v, id); | 467 map->set(v, id); |
378 return id; | 468 return id; |
379 } | 469 } |
380 | 470 |
381 ID define(const SkMatrix& v) override { return this->define(&fMatrix,
v); } | 471 ID define(const SkMatrix& v) override { return this->define(&fMatrix
, v); } |
382 ID define(const Misc& v) override { return this->define(&fMisc,
v); } | 472 ID define(const Misc& v) override { return this->define(&fMisc
, v); } |
383 ID define(const SkPath& v) override { return this->define(&fPath,
v); } | 473 ID define(const SkPath& v) override { return this->define(&fPath
, v); } |
384 ID define(const Stroke& v) override { return this->define(&fStroke,
v); } | 474 ID define(const Stroke& v) override { return this->define(&fStroke
, v); } |
385 ID define(SkShader* v) override { return this->define(&fShader,
v); } | 475 ID define(SkPathEffect* v) override { return this->define(&fPathEffect
, v); } |
386 ID define(SkXfermode* v) override { return this->define(&fXfermode,
v); } | 476 ID define(SkShader* v) override { return this->define(&fShader
, v); } |
| 477 ID define(SkXfermode* v) override { return this->define(&fXfermode
, v); } |
| 478 ID define(SkMaskFilter* v) override { return this->define(&fMaskFilter
, v); } |
| 479 ID define(SkColorFilter* v) override { return this->define(&fColorFilte
r, v); } |
| 480 ID define(SkRasterizer* v) override { return this->define(&fRasterizer
, v); } |
| 481 ID define(SkDrawLooper* v) override { return this->define(&fDrawLooper
, v); } |
| 482 ID define(SkImageFilter* v) override { return this->define(&fImageFilte
r, v); } |
| 483 ID define(SkAnnotation* v) override { return this->define(&fAnnotation
, v); } |
387 | 484 |
388 void undefine(ID) override {} | 485 void undefine(ID) override {} |
389 | 486 |
390 void save() override { fWrapped-> save(); } | 487 void save() override { fWrapped-> save(); } |
391 void restore() override { fWrapped->restore(); } | 488 void restore() override { fWrapped->restore(); } |
392 | 489 |
393 void setMatrix(ID matrix) override { fWrapped->setMatrix(matrix); } | 490 void setMatrix(ID matrix) override { fWrapped->setMatrix(matrix); } |
394 | 491 |
395 void clipPath(ID path, SkRegion::Op op, bool aa) override { | 492 void clipPath(ID path, SkRegion::Op op, bool aa) override { |
396 fWrapped->clipPath(path, op, aa); | 493 fWrapped->clipPath(path, op, aa); |
397 } | 494 } |
398 void fillPath(ID path, ID misc, ID shader, ID xfermode) override { | 495 void fillPath(ID path, CommonIDs common) override { |
399 fWrapped->fillPath(path, misc, shader, xfermode); | 496 fWrapped->fillPath(path, common); |
400 } | 497 } |
401 void strokePath(ID path, ID misc, ID shader, ID xfermode, ID stroke) ove
rride { | 498 void strokePath(ID path, CommonIDs common, ID stroke) override { |
402 fWrapped->strokePath(path, misc, shader, xfermode, stroke); | 499 fWrapped->strokePath(path, common, stroke); |
403 } | 500 } |
404 | 501 |
405 // Maps const T* -> ID, and refs the key. | 502 // Maps const T* -> ID, and refs the key. |
406 template <typename T, Type kType> | 503 template <typename T, Type kType> |
407 class RefKeyMap { | 504 class RefKeyMap { |
408 public: | 505 public: |
409 RefKeyMap() {} | 506 RefKeyMap() {} |
410 ~RefKeyMap() { fMap.foreach([](const T* key, ID*) { SkSafeUnref(key)
; }); } | 507 ~RefKeyMap() { fMap.foreach([](const T* key, ID*) { SkSafeUnref(key)
; }); } |
411 | 508 |
412 void set(const T* key, ID id) { | 509 void set(const T* key, ID id) { |
(...skipping 11 matching lines...) Expand all Loading... |
424 } | 521 } |
425 | 522 |
426 template <typename Fn> | 523 template <typename Fn> |
427 void foreach(const Fn& fn) { | 524 void foreach(const Fn& fn) { |
428 fMap.foreach(fn); | 525 fMap.foreach(fn); |
429 } | 526 } |
430 private: | 527 private: |
431 SkTHashMap<const T*, ID> fMap; | 528 SkTHashMap<const T*, ID> fMap; |
432 }; | 529 }; |
433 | 530 |
434 SkTHashMap<SkMatrix, ID> fMatrix; | 531 SkTHashMap<SkMatrix, ID> fMatrix; |
435 SkTHashMap<Misc, ID, MiscHash> fMisc; | 532 SkTHashMap<Misc, ID, MiscHash> fMisc; |
436 SkTHashMap<SkPath, ID> fPath; | 533 SkTHashMap<SkPath, ID> fPath; |
437 SkTHashMap<Stroke, ID> fStroke; | 534 SkTHashMap<Stroke, ID> fStroke; |
438 RefKeyMap<SkShader, Type::kShader> fShader; | 535 RefKeyMap<SkPathEffect , Type::kPathEffect > fPathEffect; |
439 RefKeyMap<SkXfermode, Type::kXfermode> fXfermode; | 536 RefKeyMap<SkShader , Type::kShader > fShader; |
| 537 RefKeyMap<SkXfermode , Type::kXfermode > fXfermode; |
| 538 RefKeyMap<SkMaskFilter , Type::kMaskFilter > fMaskFilter; |
| 539 RefKeyMap<SkColorFilter, Type::kColorFilter> fColorFilter; |
| 540 RefKeyMap<SkRasterizer , Type::kRasterizer > fRasterizer; |
| 541 RefKeyMap<SkDrawLooper , Type::kDrawLooper > fDrawLooper; |
| 542 RefKeyMap<SkImageFilter, Type::kImageFilter> fImageFilter; |
| 543 RefKeyMap<SkAnnotation , Type::kAnnotation > fAnnotation; |
440 | 544 |
441 Encoder* fWrapped; | 545 Encoder* fWrapped; |
442 }; | 546 }; |
443 | 547 |
444 Encoder* NewCachingEncoder(Encoder* wrapped) { return new CachingEncoder(wra
pped); } | 548 Encoder* NewCachingEncoder(Encoder* wrapped) { return new CachingEncoder(wra
pped); } |
445 | 549 |
446 } // namespace SkRemote | 550 } // namespace SkRemote |
OLD | NEW |