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

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: rebase 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
« no previous file with comments | « src/record/SkRecordDraw.h ('k') | src/record/SkRecorder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 != SkRecords::kUnsetPopOffset &&
16 canvas->quickReject(pushCull.rect)) {
17 // We skip to the popCull, then the loop moves us just beyond it.
18 index += pushCull.popOffset;
19 } else {
20 canvas->pushCull(pushCull.rect);
21 }
22 }
21 23
22 #define CASE(T) template <> void SkRecordDraw::operator()(const SkRecords::T& r) 24 // Nothing fancy below here.
25
26 #define CASE(T) template <> void Draw::operator()(const SkRecords::T& r)
23 27
24 CASE(Restore) { canvas->restore(); } 28 CASE(Restore) { canvas->restore(); }
25 CASE(Save) { canvas->save(r.flags); } 29 CASE(Save) { canvas->save(r.flags); }
26 CASE(SaveLayer) { canvas->saveLayer(r.bounds, r.paint, r.flags); } 30 CASE(SaveLayer) { canvas->saveLayer(r.bounds, r.paint, r.flags); }
27 31
28 CASE(PushCull) { canvas->pushCull(r.rect); }
29 CASE(PopCull) { canvas->popCull(); } 32 CASE(PopCull) { canvas->popCull(); }
30 33
31 CASE(Concat) { canvas->concat(r.matrix); } 34 CASE(Concat) { canvas->concat(r.matrix); }
32 CASE(SetMatrix) { canvas->setMatrix(r.matrix); } 35 CASE(SetMatrix) { canvas->setMatrix(r.matrix); }
33 36
34 CASE(ClipPath) { canvas->clipPath(r.path, r.op, r.doAA); } 37 CASE(ClipPath) { canvas->clipPath(r.path, r.op, r.doAA); }
35 CASE(ClipRRect) { canvas->clipRRect(r.rrect, r.op, r.doAA); } 38 CASE(ClipRRect) { canvas->clipRRect(r.rrect, r.op, r.doAA); }
36 CASE(ClipRect) { canvas->clipRect(r.rect, r.op, r.doAA); } 39 CASE(ClipRect) { canvas->clipRect(r.rect, r.op, r.doAA); }
37 CASE(ClipRegion) { canvas->clipRegion(r.region, r.op); } 40 CASE(ClipRegion) { canvas->clipRegion(r.region, r.op); }
38 41
(...skipping 13 matching lines...) Expand all
52 CASE(DrawPosTextH) { canvas->drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.p aint); } 55 CASE(DrawPosTextH) { canvas->drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.p aint); }
53 CASE(DrawRRect) { canvas->drawRRect(r.rrect, r.paint); } 56 CASE(DrawRRect) { canvas->drawRRect(r.rrect, r.paint); }
54 CASE(DrawRect) { canvas->drawRect(r.rect, r.paint); } 57 CASE(DrawRect) { canvas->drawRect(r.rect, r.paint); }
55 CASE(DrawSprite) { canvas->drawSprite(r.bitmap, r.left, r.top, r.paint); } 58 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); } 59 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); } 60 CASE(DrawTextOnPath) { canvas->drawTextOnPath(r.text, r.byteLength, r.path, r.ma trix, r.paint); }
58 CASE(DrawVertices) { 61 CASE(DrawVertices) {
59 canvas->drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, 62 canvas->drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors,
60 r.xmode.get(), r.indices, r.indexCount, r.paint); 63 r.xmode.get(), r.indices, r.indexCount, r.paint);
61 } 64 }
62
63 #undef CASE 65 #undef CASE
64 66
65 #endif//SkRecordDraw_DEFINED 67 } // namespace
68
69 void SkRecordDraw(const SkRecord& record, SkCanvas* canvas) {
70 Draw draw;
71 draw.canvas = canvas;
72
73 for (draw.index = 0; draw.index < record.count(); draw.index++) {
74 record.visit(draw.index, draw);
75 }
76 }
77
78
OLDNEW
« no previous file with comments | « src/record/SkRecordDraw.h ('k') | src/record/SkRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698