OLD | NEW |
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 Loading... |
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 |
OLD | NEW |