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

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

Issue 231933003: SkRecordDraw: don't bother clipping an empty clip down further (Closed) Base URL: https://skia.googlesource.com/skia.git@clipping
Patch Set: add test 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 | « no previous file | tests/RecordDrawTest.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 #include "SkRecordDraw.h" 1 #include "SkRecordDraw.h"
2 2
3 namespace { 3 namespace {
4 4
5 // 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.
6 class Draw : SkNoncopyable { 6 class Draw : SkNoncopyable {
7 public: 7 public:
8 explicit Draw(SkCanvas* canvas) : fCanvas(canvas), fIndex(0), fClipEmpty(fal se) {} 8 explicit Draw(SkCanvas* canvas) : fCanvas(canvas), fIndex(0), fClipEmpty(fal se) {}
9 9
10 unsigned index() const { return fIndex; } 10 unsigned index() const { return fIndex; }
(...skipping 19 matching lines...) Expand all
30 } else { 30 } else {
31 fCanvas->pushCull(r.rect); 31 fCanvas->pushCull(r.rect);
32 } 32 }
33 } 33 }
34 34
35 // These commands might change the clip. 35 // These commands might change the clip.
36 #define CASE(T, call) \ 36 #define CASE(T, call) \
37 template <> void Draw::operator()(const SkRecords::T& r) { fCanvas->call; th is->updateClip(); } 37 template <> void Draw::operator()(const SkRecords::T& r) { fCanvas->call; th is->updateClip(); }
38 CASE(Restore, restore()); 38 CASE(Restore, restore());
39 CASE(SaveLayer, saveLayer(r.bounds, r.paint, r.flags)); 39 CASE(SaveLayer, saveLayer(r.bounds, r.paint, r.flags));
40 #undef CASE
41
42 // These certainly do change the clip,
43 // but we can skip them if they're intersecting with a clip that's already empty .
44 #define CASE(T, call) template <> void Draw::operator()(const SkRecords::T& r) { \
45 if (!(fClipEmpty && SkRegion::kIntersect_Op == r.op)) { fCanvas->call; this- >updateClip(); } \
46 }
40 CASE(ClipPath, clipPath(r.path, r.op, r.doAA)); 47 CASE(ClipPath, clipPath(r.path, r.op, r.doAA));
41 CASE(ClipRRect, clipRRect(r.rrect, r.op, r.doAA)); 48 CASE(ClipRRect, clipRRect(r.rrect, r.op, r.doAA));
42 CASE(ClipRect, clipRect(r.rect, r.op, r.doAA)); 49 CASE(ClipRect, clipRect(r.rect, r.op, r.doAA));
43 CASE(ClipRegion, clipRegion(r.region, r.op)); 50 CASE(ClipRegion, clipRegion(r.region, r.op));
44 #undef CASE 51 #undef CASE
45 52
46 // Commands which must run regardless of the clip. 53 // Commands which must run regardless of the clip, but don't change it themselve s.
47 #define CASE(T, call) \ 54 #define CASE(T, call) \
48 template <> void Draw::operator()(const SkRecords::T& r) { fCanvas->call; } 55 template <> void Draw::operator()(const SkRecords::T& r) { fCanvas->call; }
49 CASE(Save, save(r.flags)); 56 CASE(Save, save(r.flags));
50 CASE(Clear, clear(r.color)); 57 CASE(Clear, clear(r.color));
51 CASE(PopCull, popCull()); 58 CASE(PopCull, popCull());
52 #undef CASE 59 #undef CASE
53 60
54 // Nothing fancy below here. These commands respect and don't change the clip. 61 // Nothing fancy below here. These commands respect and don't change the clip.
55 #define CASE(T, call) \ 62 #define CASE(T, call) \
56 template <> void Draw::operator()(const SkRecords::T& r) { if (!fClipEmpty) fCanvas->call; } 63 template <> void Draw::operator()(const SkRecords::T& r) { if (!fClipEmpty) fCanvas->call; }
(...skipping 20 matching lines...) Expand all
77 r.xmode.get(), r.indices, r.indexCount, r.paint) ); 84 r.xmode.get(), r.indices, r.indexCount, r.paint) );
78 #undef CASE 85 #undef CASE
79 86
80 } // namespace 87 } // namespace
81 88
82 void SkRecordDraw(const SkRecord& record, SkCanvas* canvas) { 89 void SkRecordDraw(const SkRecord& record, SkCanvas* canvas) {
83 for (Draw draw(canvas); draw.index() < record.count(); draw.next()) { 90 for (Draw draw(canvas); draw.index() < record.count(); draw.next()) {
84 record.visit(draw.index(), draw); 91 record.visit(draw.index(), draw);
85 } 92 }
86 } 93 }
OLDNEW
« no previous file with comments | « no previous file | tests/RecordDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698