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

Side by Side Diff: tests/RecordOptsTest.cpp

Issue 849243002: Why are we afraid of saveLayer() bounds? (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 SkPaint goodLayerPaint, badLayerPaint, worseLayerPaint; 121 SkPaint goodLayerPaint, badLayerPaint, worseLayerPaint;
122 goodLayerPaint.setColor(0x03000000); // Only alpha. 122 goodLayerPaint.setColor(0x03000000); // Only alpha.
123 badLayerPaint.setColor( 0x03040506); // Not only alpha. 123 badLayerPaint.setColor( 0x03040506); // Not only alpha.
124 worseLayerPaint.setXfermodeMode(SkXfermode::kDstIn_Mode); // Any effect wil l do. 124 worseLayerPaint.setXfermodeMode(SkXfermode::kDstIn_Mode); // Any effect wil l do.
125 125
126 SkPaint goodDrawPaint, badDrawPaint; 126 SkPaint goodDrawPaint, badDrawPaint;
127 goodDrawPaint.setColor(0xFF020202); // Opaque. 127 goodDrawPaint.setColor(0xFF020202); // Opaque.
128 badDrawPaint.setColor( 0x0F020202); // Not opaque. 128 badDrawPaint.setColor( 0x0F020202); // Not opaque.
129 129
130 // No change: optimization can't handle bounds. 130 // SaveLayer/Restore removed: No paint = no point.
131 recorder.saveLayer(NULL, NULL);
132 recorder.drawRect(draw, goodDrawPaint);
133 recorder.restore();
134 assert_savelayer_restore(r, &record, 0, true);
135
136 // Bounds don't matter.
131 recorder.saveLayer(&bounds, NULL); 137 recorder.saveLayer(&bounds, NULL);
132 recorder.drawRect(draw, goodDrawPaint); 138 recorder.drawRect(draw, goodDrawPaint);
133 recorder.restore(); 139 recorder.restore();
134 if (!SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds()) {
135 assert_savelayer_restore(r, &record, 0, false);
136 }
137
138 // SaveLayer/Restore removed: no bounds + no paint = no point.
139 recorder.saveLayer(NULL, NULL);
140 recorder.drawRect(draw, goodDrawPaint);
141 recorder.restore();
142 assert_savelayer_restore(r, &record, 3, true); 140 assert_savelayer_restore(r, &record, 3, true);
143 141
144 // TODO(mtklein): test case with null draw paint 142 // TODO(mtklein): test case with null draw paint
145 143
146 // No change: layer paint isn't alpha-only. 144 // No change: layer paint isn't alpha-only.
147 recorder.saveLayer(NULL, &badLayerPaint); 145 recorder.saveLayer(NULL, &badLayerPaint);
148 recorder.drawRect(draw, goodDrawPaint); 146 recorder.drawRect(draw, goodDrawPaint);
149 recorder.restore(); 147 recorder.restore();
150 assert_savelayer_restore(r, &record, 6, false); 148 assert_savelayer_restore(r, &record, 6, false);
151 149
(...skipping 12 matching lines...) Expand all
164 // SaveLayer/Restore removed: we can fold in the alpha! 162 // SaveLayer/Restore removed: we can fold in the alpha!
165 recorder.saveLayer(NULL, &goodLayerPaint); 163 recorder.saveLayer(NULL, &goodLayerPaint);
166 recorder.drawRect(draw, goodDrawPaint); 164 recorder.drawRect(draw, goodDrawPaint);
167 recorder.restore(); 165 recorder.restore();
168 assert_savelayer_restore(r, &record, 15, true); 166 assert_savelayer_restore(r, &record, 15, true);
169 167
170 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re cord, 16); 168 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re cord, 16);
171 REPORTER_ASSERT(r, drawRect != NULL); 169 REPORTER_ASSERT(r, drawRect != NULL);
172 REPORTER_ASSERT(r, drawRect->paint.getColor() == 0x03020202); 170 REPORTER_ASSERT(r, drawRect->paint.getColor() == 0x03020202);
173 } 171 }
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