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

Side by Side Diff: tests/RecordPatternTest.cpp

Issue 269543025: Partially restore small-T optimization for very small (empty) T. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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
« src/record/SkRecord.h ('K') | « tests/RecordOptsTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "Test.h" 1 #include "Test.h"
2 2
3 #include "SkRecord.h" 3 #include "SkRecord.h"
4 #include "SkRecordPattern.h" 4 #include "SkRecordPattern.h"
5 #include "SkRecorder.h" 5 #include "SkRecorder.h"
6 #include "SkRecords.h" 6 #include "SkRecords.h"
7 7
8 using namespace SkRecords; 8 using namespace SkRecords;
9 typedef Pattern3<Is<Save>, 9 typedef Pattern3<Is<Save>,
10 Is<ClipRect>, 10 Is<ClipRect>,
(...skipping 12 matching lines...) Expand all
23 recorder.save(); 23 recorder.save();
24 REPORTER_ASSERT(r, !pattern.match(&record, 0)); 24 REPORTER_ASSERT(r, !pattern.match(&record, 0));
25 25
26 recorder.clipRect(SkRect::MakeWH(300, 200)); 26 recorder.clipRect(SkRect::MakeWH(300, 200));
27 REPORTER_ASSERT(r, !pattern.match(&record, 0)); 27 REPORTER_ASSERT(r, !pattern.match(&record, 0));
28 28
29 recorder.restore(); 29 recorder.restore();
30 REPORTER_ASSERT(r, pattern.match(&record, 0)); 30 REPORTER_ASSERT(r, pattern.match(&record, 0));
31 REPORTER_ASSERT(r, pattern.first<Save>() != NULL); 31 REPORTER_ASSERT(r, pattern.first<Save>() != NULL);
32 REPORTER_ASSERT(r, pattern.second<ClipRect>() != NULL); 32 REPORTER_ASSERT(r, pattern.second<ClipRect>() != NULL);
33 REPORTER_ASSERT(r, pattern.third<Restore>() != NULL);
34 } 33 }
35 34
36 DEF_TEST(RecordPattern_StartingIndex, r) { 35 DEF_TEST(RecordPattern_StartingIndex, r) {
37 SaveClipRectRestore pattern; 36 SaveClipRectRestore pattern;
38 37
39 SkRecord record; 38 SkRecord record;
40 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1200); 39 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1200);
41 40
42 // There will be two save-clipRect-restore blocks [0,3) and [3,6). 41 // There will be two save-clipRect-restore blocks [0,3) and [3,6).
43 for (int i = 0; i < 2; i++) { 42 for (int i = 0; i < 2; i++) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 recorder.restore(); 114 recorder.restore();
116 115
117 recorder.save(); 116 recorder.save();
118 paint.setColor(0xFACEFACE); 117 paint.setColor(0xFACEFACE);
119 recorder.drawPaint(paint); 118 recorder.drawPaint(paint);
120 recorder.restore(); 119 recorder.restore();
121 120
122 REPORTER_ASSERT(r, pattern.match(&record, 3)); 121 REPORTER_ASSERT(r, pattern.match(&record, 3));
123 REPORTER_ASSERT(r, pattern.first<Save>() != NULL); 122 REPORTER_ASSERT(r, pattern.first<Save>() != NULL);
124 REPORTER_ASSERT(r, pattern.second<SkPaint>()->getColor() == 0xEEAA8822); 123 REPORTER_ASSERT(r, pattern.second<SkPaint>()->getColor() == 0xEEAA8822);
125 REPORTER_ASSERT(r, pattern.third<Restore>() != NULL);
126 124
127 REPORTER_ASSERT(r, pattern.match(&record, 6)); 125 REPORTER_ASSERT(r, pattern.match(&record, 6));
128 REPORTER_ASSERT(r, pattern.first<Save>() != NULL); 126 REPORTER_ASSERT(r, pattern.first<Save>() != NULL);
129 REPORTER_ASSERT(r, pattern.second<SkPaint>()->getColor() == 0xFACEFACE); 127 REPORTER_ASSERT(r, pattern.second<SkPaint>()->getColor() == 0xFACEFACE);
130 REPORTER_ASSERT(r, pattern.third<Restore>() != NULL);
131 } 128 }
132 129
133 DEF_TEST(RecordPattern_Complex, r) { 130 DEF_TEST(RecordPattern_Complex, r) {
134 Pattern3<Is<Save>, 131 Pattern3<Is<Save>,
135 Star<Not<Or3<Is<Save>, 132 Star<Not<Or3<Is<Save>,
136 Is<Restore>, 133 Is<Restore>,
137 IsDraw> > >, 134 IsDraw> > >,
138 Is<Restore> > pattern; 135 Is<Restore> > pattern;
139 136
140 SkRecord record; 137 SkRecord record;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 190
194 DEF_TEST(RecordPattern_SaveLayerIsNotADraw, r) { 191 DEF_TEST(RecordPattern_SaveLayerIsNotADraw, r) {
195 Pattern1<IsDraw> pattern; 192 Pattern1<IsDraw> pattern;
196 193
197 SkRecord record; 194 SkRecord record;
198 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1200); 195 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1200);
199 recorder.saveLayer(NULL, NULL); 196 recorder.saveLayer(NULL, NULL);
200 197
201 REPORTER_ASSERT(r, !pattern.match(&record, 0)); 198 REPORTER_ASSERT(r, !pattern.match(&record, 0));
202 } 199 }
OLDNEW
« src/record/SkRecord.h ('K') | « tests/RecordOptsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698