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

Side by Side Diff: tests/RecordOptsTest.cpp

Issue 577673003: Turn disable or delete optimizations that don't have any effect. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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/core/SkRecordOpts.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 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 #include "RecordTestUtils.h" 9 #include "RecordTestUtils.h"
10 10
11 #include "SkRecord.h" 11 #include "SkRecord.h"
12 #include "SkRecordOpts.h" 12 #include "SkRecordOpts.h"
13 #include "SkRecorder.h" 13 #include "SkRecorder.h"
14 #include "SkRecords.h" 14 #include "SkRecords.h"
15 #include "SkXfermode.h" 15 #include "SkXfermode.h"
16 16
17 static const int W = 1920, H = 1080; 17 static const int W = 1920, H = 1080;
18 18
19 static void draw_pos_text(SkCanvas* canvas, const char* text, bool constantY) {
20 const size_t len = strlen(text);
21 SkAutoTMalloc<SkPoint> pos(len);
22 for (size_t i = 0; i < len; i++) {
23 pos[i].fX = (SkScalar)i;
24 pos[i].fY = constantY ? SK_Scalar1 : (SkScalar)i;
25 }
26 canvas->drawPosText(text, len, pos, SkPaint());
27 }
28
29 DEF_TEST(RecordOpts_StrengthReduction, r) {
30 SkRecord record;
31 SkRecorder recorder(&record, W, H);
32
33 // We can convert a drawPosText into a drawPosTextH when all the Ys are the same.
34 draw_pos_text(&recorder, "This will be reduced to drawPosTextH.", true);
35 draw_pos_text(&recorder, "This cannot be reduced to drawPosTextH.", false);
36
37 SkRecordReduceDrawPosTextStrength(&record);
38
39 assert_type<SkRecords::DrawPosTextH>(r, record, 0);
40 assert_type<SkRecords::DrawPosText>(r, record, 1);
41 }
42
43 DEF_TEST(RecordOpts_NoopDrawSaveRestore, r) { 19 DEF_TEST(RecordOpts_NoopDrawSaveRestore, r) {
44 SkRecord record; 20 SkRecord record;
45 SkRecorder recorder(&record, W, H); 21 SkRecorder recorder(&record, W, H);
46 22
47 // The save and restore are pointless if there's only draw commands in the m iddle. 23 // The save and restore are pointless if there's only draw commands in the m iddle.
48 recorder.save(); 24 recorder.save();
49 recorder.drawRect(SkRect::MakeWH(200, 200), SkPaint()); 25 recorder.drawRect(SkRect::MakeWH(200, 200), SkPaint());
50 recorder.drawRect(SkRect::MakeWH(300, 300), SkPaint()); 26 recorder.drawRect(SkRect::MakeWH(300, 300), SkPaint());
51 recorder.drawRect(SkRect::MakeWH(100, 100), SkPaint()); 27 recorder.drawRect(SkRect::MakeWH(100, 100), SkPaint());
52 recorder.restore(); 28 recorder.restore();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // SaveLayer/Restore removed: we can fold in the alpha! 157 // SaveLayer/Restore removed: we can fold in the alpha!
182 recorder.saveLayer(NULL, &goodLayerPaint); 158 recorder.saveLayer(NULL, &goodLayerPaint);
183 recorder.drawRect(draw, goodDrawPaint); 159 recorder.drawRect(draw, goodDrawPaint);
184 recorder.restore(); 160 recorder.restore();
185 assert_savelayer_restore(r, &record, 15, true); 161 assert_savelayer_restore(r, &record, 15, true);
186 162
187 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re cord, 16); 163 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re cord, 16);
188 REPORTER_ASSERT(r, drawRect != NULL); 164 REPORTER_ASSERT(r, drawRect != NULL);
189 REPORTER_ASSERT(r, drawRect->paint.getColor() == 0x03020202); 165 REPORTER_ASSERT(r, drawRect->paint.getColor() == 0x03020202);
190 } 166 }
OLDNEW
« no previous file with comments | « src/core/SkRecordOpts.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698