OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkPaint.h" | 8 #include "SkPaint.h" |
9 #include "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
10 #include "SkAutoKern.h" | 10 #include "SkAutoKern.h" |
(...skipping 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2370 if (xpos) { | 2370 if (xpos) { |
2371 *xpos = fXPos; | 2371 *xpos = fXPos; |
2372 } | 2372 } |
2373 return true; | 2373 return true; |
2374 } | 2374 } |
2375 return false; | 2375 return false; |
2376 } | 2376 } |
2377 | 2377 |
2378 /////////////////////////////////////////////////////////////////////////////// | 2378 /////////////////////////////////////////////////////////////////////////////// |
2379 | 2379 |
2380 // return true if the filter exists, and may affect alpha | |
2381 static bool affects_alpha(const SkColorFilter* cf) { | |
2382 return cf && !(cf->getFlags() & SkColorFilter::kAlphaUnchanged_Flag); | |
2383 } | |
2384 | |
2385 // return true if the filter exists, and may affect alpha | |
2386 static bool affects_alpha(const SkImageFilter* imf) { | |
2387 // TODO: check if we should allow imagefilters to broadcast that they don't
affect alpha | |
2388 // ala colorfilters | |
2389 return imf != NULL; | |
2390 } | |
2391 | |
2392 bool SkPaint::nothingToDraw() const { | 2380 bool SkPaint::nothingToDraw() const { |
2393 if (fLooper) { | 2381 if (fLooper) { |
2394 return false; | 2382 return false; |
2395 } | 2383 } |
2396 SkXfermode::Mode mode; | 2384 SkXfermode::Mode mode; |
2397 if (SkXfermode::AsMode(fXfermode, &mode)) { | 2385 if (SkXfermode::AsMode(fXfermode, &mode)) { |
2398 switch (mode) { | 2386 switch (mode) { |
2399 case SkXfermode::kSrcOver_Mode: | 2387 case SkXfermode::kSrcOver_Mode: |
2400 case SkXfermode::kSrcATop_Mode: | 2388 case SkXfermode::kSrcATop_Mode: |
2401 case SkXfermode::kDstOut_Mode: | 2389 case SkXfermode::kDstOut_Mode: |
2402 case SkXfermode::kDstOver_Mode: | 2390 case SkXfermode::kDstOver_Mode: |
2403 case SkXfermode::kPlus_Mode: | 2391 case SkXfermode::kPlus_Mode: |
2404 if (0 == this->getAlpha()) { | 2392 return 0 == this->getAlpha(); |
2405 return !affects_alpha(fColorFilter) && !affects_alpha(fImage
Filter); | |
2406 } | |
2407 break; | |
2408 case SkXfermode::kDst_Mode: | 2393 case SkXfermode::kDst_Mode: |
2409 return true; | 2394 return true; |
2410 default: | 2395 default: |
2411 break; | 2396 break; |
2412 } | 2397 } |
2413 } | 2398 } |
2414 return false; | 2399 return false; |
2415 } | 2400 } |
2416 | 2401 |
2417 uint32_t SkPaint::getHash() const { | 2402 uint32_t SkPaint::getHash() const { |
2418 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2403 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2419 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2404 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2420 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), | 2405 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), |
2421 SkPaint_notPackedTightly); | 2406 SkPaint_notPackedTightly); |
2422 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2407 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2423 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2408 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2424 } | 2409 } |
OLD | NEW |