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

Side by Side Diff: tests/PaintTest.cpp

Issue 239393002: remove legacy filter-flags, and store FilterLevel directly (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 | Annotate | Revision Log
« src/core/SkPaint.cpp ('K') | « src/core/SkPaint.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 2011 Google Inc. 2 * Copyright 2011 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 "SkBlurMask.h" 8 #include "SkBlurMask.h"
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkLayerDrawLooper.h" 10 #include "SkLayerDrawLooper.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 SkScalar miter = SkMaxScalar(SK_Scalar1, paint.getStrokeMiter()); 221 SkScalar miter = SkMaxScalar(SK_Scalar1, paint.getStrokeMiter());
222 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ? 222 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ?
223 SkScalarMul(paint.getStrokeWidth(), miter) : 223 SkScalarMul(paint.getStrokeWidth(), miter) :
224 paint.getStrokeWidth(); 224 paint.getStrokeWidth();
225 maxR.inset(-inset, -inset); 225 maxR.inset(-inset, -inset);
226 226
227 // test that our stroke didn't explode 227 // test that our stroke didn't explode
228 REPORTER_ASSERT(reporter, maxR.contains(strokeR)); 228 REPORTER_ASSERT(reporter, maxR.contains(strokeR));
229 } 229 }
230 230
231 static void test_filter_flags(skiatest::Reporter* reporter) {
232 const SkPaint::FilterLevel levels[] = {
233 SkPaint::kNone_FilterLevel,
234 SkPaint::kLow_FilterLevel,
235 SkPaint::kMedium_FilterLevel,
236 SkPaint::kHigh_FilterLevel,
237 };
238
239 const SkPaint::Hinting hinting[] = {
240 SkPaint::kNo_Hinting,
241 SkPaint::kSlight_Hinting,
242 SkPaint::kNormal_Hinting,
243 SkPaint::kFull_Hinting,
244 };
245
246 for (size_t i = 0; i < SK_ARRAY_COUNT(levels); ++i) {
247 for (size_t j = 0; j < SK_ARRAY_COUNT(hinting); ++j) {
248 SkPaint paint;
249 paint.setFilterLevel(levels[i]);
250 paint.setHinting(hinting[j]);
251 REPORTER_ASSERT(reporter, paint.getFilterLevel() == levels[i]);
252 REPORTER_ASSERT(reporter, paint.getHinting() == hinting[j]);
253
254 SkWriteBuffer writer;
255 paint.flatten(writer);
256
257 const uint32_t* written = writer.getWriter32()->contiguousArray();
258 SkReadBuffer reader(written, writer.bytesWritten());
259
260 SkPaint paint2;
261 paint2.unflatten(reader);
262 REPORTER_ASSERT(reporter, paint2.getFilterLevel() == levels[i]);
263 REPORTER_ASSERT(reporter, paint2.getHinting() == hinting[j]);
264 }
265 }
266 }
267
231 // found and fixed for android: not initializing rect for string's of length 0 268 // found and fixed for android: not initializing rect for string's of length 0
232 DEF_TEST(Paint_regression_measureText, reporter) { 269 DEF_TEST(Paint_regression_measureText, reporter) {
233 270
234 SkPaint paint; 271 SkPaint paint;
235 paint.setTextSize(12.0f); 272 paint.setTextSize(12.0f);
236 273
237 SkRect r; 274 SkRect r;
238 r.setLTRB(SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN); 275 r.setLTRB(SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN);
239 276
240 // test that the rect was reset 277 // test that the rect was reset
(...skipping 29 matching lines...) Expand all
270 ASSERT(other.getColor() == paint.getColor()); 307 ASSERT(other.getColor() == paint.getColor());
271 ASSERT(other.getTextScaleX() == paint.getTextScaleX()); 308 ASSERT(other.getTextScaleX() == paint.getTextScaleX());
272 ASSERT(other.getTextSize() == paint.getTextSize()); 309 ASSERT(other.getTextSize() == paint.getTextSize());
273 ASSERT(other.getLooper() == paint.getLooper()); 310 ASSERT(other.getLooper() == paint.getLooper());
274 311
275 // We have to be a little looser and compare just the modes. Pointers might not be the same. 312 // We have to be a little looser and compare just the modes. Pointers might not be the same.
276 SkXfermode::Mode otherMode, paintMode; 313 SkXfermode::Mode otherMode, paintMode;
277 ASSERT(other.getXfermode()->asMode(&otherMode)); 314 ASSERT(other.getXfermode()->asMode(&otherMode));
278 ASSERT(paint.getXfermode()->asMode(&paintMode)); 315 ASSERT(paint.getXfermode()->asMode(&paintMode));
279 ASSERT(otherMode == paintMode); 316 ASSERT(otherMode == paintMode);
317
318 test_filter_flags(r);
280 } 319 }
OLDNEW
« src/core/SkPaint.cpp ('K') | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698