| 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 |
| 2380 bool SkPaint::nothingToDraw() const { | 2392 bool SkPaint::nothingToDraw() const { |
| 2381 if (fLooper) { | 2393 if (fLooper) { |
| 2382 return false; | 2394 return false; |
| 2383 } | 2395 } |
| 2384 SkXfermode::Mode mode; | 2396 SkXfermode::Mode mode; |
| 2385 if (SkXfermode::AsMode(fXfermode, &mode)) { | 2397 if (SkXfermode::AsMode(fXfermode, &mode)) { |
| 2386 switch (mode) { | 2398 switch (mode) { |
| 2387 case SkXfermode::kSrcOver_Mode: | 2399 case SkXfermode::kSrcOver_Mode: |
| 2388 case SkXfermode::kSrcATop_Mode: | 2400 case SkXfermode::kSrcATop_Mode: |
| 2389 case SkXfermode::kDstOut_Mode: | 2401 case SkXfermode::kDstOut_Mode: |
| 2390 case SkXfermode::kDstOver_Mode: | 2402 case SkXfermode::kDstOver_Mode: |
| 2391 case SkXfermode::kPlus_Mode: | 2403 case SkXfermode::kPlus_Mode: |
| 2392 return 0 == this->getAlpha(); | 2404 if (0 == this->getAlpha()) { |
| 2405 return !affects_alpha(fColorFilter) && !affects_alpha(fImage
Filter); |
| 2406 } |
| 2407 break; |
| 2393 case SkXfermode::kDst_Mode: | 2408 case SkXfermode::kDst_Mode: |
| 2394 return true; | 2409 return true; |
| 2395 default: | 2410 default: |
| 2396 break; | 2411 break; |
| 2397 } | 2412 } |
| 2398 } | 2413 } |
| 2399 return false; | 2414 return false; |
| 2400 } | 2415 } |
| 2401 | 2416 |
| 2402 uint32_t SkPaint::getHash() const { | 2417 uint32_t SkPaint::getHash() const { |
| 2403 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2418 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
| 2404 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2419 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
| 2405 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), | 2420 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), |
| 2406 SkPaint_notPackedTightly); | 2421 SkPaint_notPackedTightly); |
| 2407 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2422 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
| 2408 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2423 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
| 2409 } | 2424 } |
| OLD | NEW |