OLD | NEW |
1 #ifndef SkRecordDraw_DEFINED | 1 #ifndef SkRecordDraw_DEFINED |
2 #define SkRecordDraw_DEFINED | 2 #define SkRecordDraw_DEFINED |
3 | 3 |
4 #include "SkRecord.h" | 4 #include "SkRecord.h" |
5 #include "SkRecords.h" | 5 #include "SkRecords.h" |
6 #include "SkCanvas.h" | 6 #include "SkCanvas.h" |
7 | 7 |
8 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. | 8 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. |
9 | 9 |
10 struct SkRecordDraw { | 10 struct SkRecordDraw { |
11 explicit SkRecordDraw(SkCanvas* canvas) : canvas(canvas) {} | 11 explicit SkRecordDraw(SkCanvas* canvas) : canvas(canvas) {} |
12 | 12 |
13 // No base case, so we'll be compile-time checked that we implemented all po
ssibilities below. | 13 // No base case, so we'll be compile-time checked that we implemented all po
ssibilities below. |
14 template <typename T> void operator()(const T& record); | 14 template <typename T> void operator()(const T& record); |
15 | 15 |
16 SkCanvas* canvas; | 16 SkCanvas* canvas; |
17 }; | 17 }; |
18 | 18 |
19 // Nothing fancy here. | 19 // Nothing fancy here. |
20 // The structs in SkRecord are completely isomorphic to their corresponding SkCa
nvas calls. | 20 // The structs in SkRecord are completely isomorphic to their corresponding SkCa
nvas calls. |
21 | 21 |
22 #define CASE(T) template <> void SkRecordDraw::operator()(const SkRecords::T& r) | 22 #define CASE(T) template <> void SkRecordDraw::operator()(const SkRecords::T& r) |
23 | 23 |
24 CASE(Restore) { canvas->restore(); } | 24 CASE(Restore) { canvas->restore(); } |
25 CASE(Save) { canvas->save(r.flags); } | 25 CASE(Save) { canvas->save(r.flags); } |
26 CASE(SaveLayer) { canvas->saveLayer(r.bounds, r.paint, r.flags); } | 26 CASE(SaveLayer) { canvas->saveLayer(r.bounds, r.paint, r.flags); } |
27 | 27 |
| 28 CASE(PushCull) { canvas->pushCull(r.rect); } |
| 29 CASE(PopCull) { canvas->popCull(); } |
| 30 |
28 CASE(Concat) { canvas->concat(r.matrix); } | 31 CASE(Concat) { canvas->concat(r.matrix); } |
29 CASE(SetMatrix) { canvas->setMatrix(r.matrix); } | 32 CASE(SetMatrix) { canvas->setMatrix(r.matrix); } |
30 | 33 |
31 CASE(ClipPath) { canvas->clipPath(r.path, r.op, r.doAA); } | 34 CASE(ClipPath) { canvas->clipPath(r.path, r.op, r.doAA); } |
32 CASE(ClipRRect) { canvas->clipRRect(r.rrect, r.op, r.doAA); } | 35 CASE(ClipRRect) { canvas->clipRRect(r.rrect, r.op, r.doAA); } |
33 CASE(ClipRect) { canvas->clipRect(r.rect, r.op, r.doAA); } | 36 CASE(ClipRect) { canvas->clipRect(r.rect, r.op, r.doAA); } |
34 CASE(ClipRegion) { canvas->clipRegion(r.region, r.op); } | 37 CASE(ClipRegion) { canvas->clipRegion(r.region, r.op); } |
35 | 38 |
36 CASE(Clear) { canvas->clear(r.color); } | 39 CASE(Clear) { canvas->clear(r.color); } |
37 CASE(DrawBitmap) { canvas->drawBitmap(r.bitmap, r.left, r.top, r.paint); } | 40 CASE(DrawBitmap) { canvas->drawBitmap(r.bitmap, r.left, r.top, r.paint); } |
(...skipping 15 matching lines...) Expand all Loading... |
53 CASE(DrawText) { canvas->drawText(r.text, r.byteLength, r.x, r.y, r.paint); } | 56 CASE(DrawText) { canvas->drawText(r.text, r.byteLength, r.x, r.y, r.paint); } |
54 CASE(DrawTextOnPath) { canvas->drawTextOnPath(r.text, r.byteLength, r.path, r.ma
trix, r.paint); } | 57 CASE(DrawTextOnPath) { canvas->drawTextOnPath(r.text, r.byteLength, r.path, r.ma
trix, r.paint); } |
55 CASE(DrawVertices) { | 58 CASE(DrawVertices) { |
56 canvas->drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, | 59 canvas->drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, |
57 r.xmode.get(), r.indices, r.indexCount, r.paint); | 60 r.xmode.get(), r.indices, r.indexCount, r.paint); |
58 } | 61 } |
59 | 62 |
60 #undef CASE | 63 #undef CASE |
61 | 64 |
62 #endif//SkRecordDraw_DEFINED | 65 #endif//SkRecordDraw_DEFINED |
OLD | NEW |