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

Side by Side Diff: src/record/SkRecordDraw.cpp

Issue 229523002: SkRecord: make culling work if SkRecordAnnotateCullingPairs is called. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 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
OLDNEW
1 #ifndef SkRecordDraw_DEFINED 1 #include "SkRecordDraw.h"
2 #define SkRecordDraw_DEFINED
3 2
4 #include "SkRecord.h" 3 namespace {
5 #include "SkRecords.h"
6 #include "SkCanvas.h"
7 4
8 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. 5 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas.
9 6 struct Draw {
10 struct SkRecordDraw { 7 unsigned index;
11 explicit SkRecordDraw(SkCanvas* canvas) : canvas(canvas) {} 8 SkCanvas* canvas;
12 9
13 // No base case, so we'll be compile-time checked that we implemented all po ssibilities below. 10 // 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); 11 template <typename T> void operator()(const T&);
15
16 SkCanvas* canvas;
17 }; 12 };
18 13
19 // Nothing fancy here. 14 template <> void Draw::operator()(const SkRecords::PushCull& pushCull) {
20 // The structs in SkRecord are completely isomorphic to their corresponding SkCa nvas calls. 15 if (pushCull.popOffset > 0 && canvas->quickReject(pushCull.rect)) {
16 // We skip to the popCull, then the loop moves us just beyond it.
17 index += pushCull.popOffset;
18 } else {
19 canvas->pushCull(pushCull.rect);
20 }
21 }
21 22
22 #define CASE(T) template <> void SkRecordDraw::operator()(const SkRecords::T& r) 23 // Nothing fancy below here.
24
25 #define CASE(T) template <> void Draw::operator()(const SkRecords::T& r)
23 26
24 CASE(Restore) { canvas->restore(); } 27 CASE(Restore) { canvas->restore(); }
25 CASE(Save) { canvas->save(r.flags); } 28 CASE(Save) { canvas->save(r.flags); }
26 CASE(SaveLayer) { canvas->saveLayer(r.bounds, r.paint, r.flags); } 29 CASE(SaveLayer) { canvas->saveLayer(r.bounds, r.paint, r.flags); }
27 30
28 CASE(PushCull) { canvas->pushCull(r.rect); }
29 CASE(PopCull) { canvas->popCull(); } 31 CASE(PopCull) { canvas->popCull(); }
30 32
31 CASE(Concat) { canvas->concat(r.matrix); } 33 CASE(Concat) { canvas->concat(r.matrix); }
32 CASE(SetMatrix) { canvas->setMatrix(r.matrix); } 34 CASE(SetMatrix) { canvas->setMatrix(r.matrix); }
33 35
34 CASE(ClipPath) { canvas->clipPath(r.path, r.op, r.doAA); } 36 CASE(ClipPath) { canvas->clipPath(r.path, r.op, r.doAA); }
35 CASE(ClipRRect) { canvas->clipRRect(r.rrect, r.op, r.doAA); } 37 CASE(ClipRRect) { canvas->clipRRect(r.rrect, r.op, r.doAA); }
36 CASE(ClipRect) { canvas->clipRect(r.rect, r.op, r.doAA); } 38 CASE(ClipRect) { canvas->clipRect(r.rect, r.op, r.doAA); }
37 CASE(ClipRegion) { canvas->clipRegion(r.region, r.op); } 39 CASE(ClipRegion) { canvas->clipRegion(r.region, r.op); }
38 40
(...skipping 13 matching lines...) Expand all
52 CASE(DrawPosTextH) { canvas->drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.p aint); } 54 CASE(DrawPosTextH) { canvas->drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.p aint); }
53 CASE(DrawRRect) { canvas->drawRRect(r.rrect, r.paint); } 55 CASE(DrawRRect) { canvas->drawRRect(r.rrect, r.paint); }
54 CASE(DrawRect) { canvas->drawRect(r.rect, r.paint); } 56 CASE(DrawRect) { canvas->drawRect(r.rect, r.paint); }
55 CASE(DrawSprite) { canvas->drawSprite(r.bitmap, r.left, r.top, r.paint); } 57 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); } 58 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); } 59 CASE(DrawTextOnPath) { canvas->drawTextOnPath(r.text, r.byteLength, r.path, r.ma trix, r.paint); }
58 CASE(DrawVertices) { 60 CASE(DrawVertices) {
59 canvas->drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, 61 canvas->drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors,
60 r.xmode.get(), r.indices, r.indexCount, r.paint); 62 r.xmode.get(), r.indices, r.indexCount, r.paint);
61 } 63 }
62
63 #undef CASE 64 #undef CASE
64 65
65 #endif//SkRecordDraw_DEFINED 66 } // namespace
67
68 void SkRecordDraw(const SkRecord& record, SkCanvas* canvas) {
69 Draw draw;
70 draw.canvas = canvas;
71
72 for (draw.index = 0; draw.index < record.count(); draw.index++) {
73 record.visit(draw.index, draw);
74 }
75 }
76
77
OLDNEW
« no previous file with comments | « src/record/SkRecordDraw.h ('k') | src/record/SkRecorder.cpp » ('j') | src/record/SkRecorder.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698