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

Side by Side Diff: tests/PaintTest.cpp

Issue 683003003: modify nothingToDraw to notice filters (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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/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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 REPORTER_ASSERT(r, paint.getHash() != defaultHash); 337 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
338 paint.setTypeface(NULL); 338 paint.setTypeface(NULL);
339 REPORTER_ASSERT(r, paint.getHash() == defaultHash); 339 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
340 340
341 // This is part of fBitfields, the last field we hash. 341 // This is part of fBitfields, the last field we hash.
342 paint.setHinting(SkPaint::kSlight_Hinting); 342 paint.setHinting(SkPaint::kSlight_Hinting);
343 REPORTER_ASSERT(r, paint.getHash() != defaultHash); 343 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
344 paint.setHinting(SkPaint::kNormal_Hinting); 344 paint.setHinting(SkPaint::kNormal_Hinting);
345 REPORTER_ASSERT(r, paint.getHash() == defaultHash); 345 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
346 } 346 }
347
348 #include "SkColorMatrixFilter.h"
349
350 DEF_TEST(Paint_nothingToDraw, r) {
351 SkPaint paint;
352
353 REPORTER_ASSERT(r, !paint.nothingToDraw());
354 paint.setAlpha(0);
355 REPORTER_ASSERT(r, paint.nothingToDraw());
356
357 paint.setAlpha(0xFF);
358 paint.setXfermodeMode(SkXfermode::kDst_Mode);
359 REPORTER_ASSERT(r, paint.nothingToDraw());
360
361 paint.setAlpha(0);
362 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
363
364 SkColorMatrix cm;
365 cm.setIdentity(); // does not change alpha
366 paint.setColorFilter(SkColorMatrixFilter::Create(cm))->unref();
367 REPORTER_ASSERT(r, paint.nothingToDraw());
368
369 cm.postTranslate(0, 0, 0, 1); // wacks alpha
370 paint.setColorFilter(SkColorMatrixFilter::Create(cm))->unref();
371 REPORTER_ASSERT(r, !paint.nothingToDraw());
372 }
373
OLDNEW
« no previous file with comments | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698