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" | |
6 #include "SkCanvas.h" | 5 #include "SkCanvas.h" |
7 | 6 |
8 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. | 7 // Draw an SkRecord into an SkCanvas. |
9 | 8 void SkRecordDraw(const SkRecord&, SkCanvas*); |
10 struct SkRecordDraw { | |
11 explicit SkRecordDraw(SkCanvas* canvas) : canvas(canvas) {} | |
12 | |
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); | |
15 | |
16 SkCanvas* canvas; | |
17 }; | |
18 | |
19 // Nothing fancy here. | |
20 // The structs in SkRecord are completely isomorphic to their corresponding SkCa
nvas calls. | |
21 | |
22 #define CASE(T) template <> void SkRecordDraw::operator()(const SkRecords::T& r) | |
23 | |
24 CASE(Restore) { canvas->restore(); } | |
25 CASE(Save) { canvas->save(r.flags); } | |
26 CASE(SaveLayer) { canvas->saveLayer(r.bounds, r.paint, r.flags); } | |
27 | |
28 CASE(PushCull) { canvas->pushCull(r.rect); } | |
29 CASE(PopCull) { canvas->popCull(); } | |
30 | |
31 CASE(Concat) { canvas->concat(r.matrix); } | |
32 CASE(SetMatrix) { canvas->setMatrix(r.matrix); } | |
33 | |
34 CASE(ClipPath) { canvas->clipPath(r.path, r.op, r.doAA); } | |
35 CASE(ClipRRect) { canvas->clipRRect(r.rrect, r.op, r.doAA); } | |
36 CASE(ClipRect) { canvas->clipRect(r.rect, r.op, r.doAA); } | |
37 CASE(ClipRegion) { canvas->clipRegion(r.region, r.op); } | |
38 | |
39 CASE(Clear) { canvas->clear(r.color); } | |
40 CASE(DrawBitmap) { canvas->drawBitmap(r.bitmap, r.left, r.top, r.paint); } | |
41 CASE(DrawBitmapMatrix) { canvas->drawBitmapMatrix(r.bitmap, r.matrix, r.paint);
} | |
42 CASE(DrawBitmapNine) { canvas->drawBitmapNine(r.bitmap, r.center, r.dst, r.paint
); } | |
43 CASE(DrawBitmapRectToRect) { | |
44 canvas->drawBitmapRectToRect(r.bitmap, r.src, r.dst, r.paint, r.flags); | |
45 } | |
46 CASE(DrawDRRect) { canvas->drawDRRect(r.outer, r.inner, r.paint); } | |
47 CASE(DrawOval) { canvas->drawOval(r.oval, r.paint); } | |
48 CASE(DrawPaint) { canvas->drawPaint(r.paint); } | |
49 CASE(DrawPath) { canvas->drawPath(r.path, r.paint); } | |
50 CASE(DrawPoints) { canvas->drawPoints(r.mode, r.count, r.pts, r.paint); } | |
51 CASE(DrawPosText) { canvas->drawPosText(r.text, r.byteLength, r.pos, r.paint); } | |
52 CASE(DrawPosTextH) { canvas->drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.p
aint); } | |
53 CASE(DrawRRect) { canvas->drawRRect(r.rrect, r.paint); } | |
54 CASE(DrawRect) { canvas->drawRect(r.rect, r.paint); } | |
55 CASE(DrawSprite) { canvas->drawSprite(r.bitmap, r.left, r.top, r.paint); } | |
56 CASE(DrawText) { canvas->drawText(r.text, r.byteLength, r.x, r.y, r.paint); } | |
57 CASE(DrawTextOnPath) { canvas->drawTextOnPath(r.text, r.byteLength, r.path, r.ma
trix, r.paint); } | |
58 CASE(DrawVertices) { | |
59 canvas->drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, | |
60 r.xmode.get(), r.indices, r.indexCount, r.paint); | |
61 } | |
62 | |
63 #undef CASE | |
64 | 9 |
65 #endif//SkRecordDraw_DEFINED | 10 #endif//SkRecordDraw_DEFINED |
OLD | NEW |