| 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 "SkBlitRow.h" | 8 #include "SkBlitRow.h" |
| 9 #include "SkColorFilter.h" | 9 #include "SkColorFilter.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| 11 #include "SkModeColorFilter.h" | 11 #include "SkModeColorFilter.h" |
| 12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
| 13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
| 14 #include "SkUtils.h" | 14 #include "SkUtils.h" |
| 15 #include "SkString.h" | 15 #include "SkString.h" |
| 16 #include "SkValidationUtils.h" | 16 #include "SkValidationUtils.h" |
| 17 #include "SkColorMatrixFilter.h" | 17 #include "SkColorMatrixFilter.h" |
| 18 | 18 |
| 19 bool SkModeColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) cons
t { | 19 bool SkModeColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) cons
t { |
| 20 if (color) { | 20 if (color) { |
| 21 *color = fColor; | 21 *color = fColor; |
| 22 } | 22 } |
| 23 if (mode) { | 23 if (mode) { |
| 24 *mode = fMode; | 24 *mode = fMode; |
| 25 } | 25 } |
| 26 return true; | 26 return true; |
| 27 } | 27 } |
| 28 | 28 |
| 29 uint32_t SkModeColorFilter::getFlags() const { | 29 uint32_t SkModeColorFilter::getFlags() const { |
| 30 uint32_t flags = 0; | 30 return fProc16 ? (kAlphaUnchanged_Flag | kHasFilter16_Flag) : 0; |
| 31 switch (fMode) { | |
| 32 case SkXfermode::kDst_Mode: //!< [Da, Dc] | |
| 33 case SkXfermode::kSrcATop_Mode: //!< [Da, Sc * Da + (1 - Sa) * Dc] | |
| 34 flags |= kAlphaUnchanged_Flag; | |
| 35 default: | |
| 36 break; | |
| 37 } | |
| 38 if (fProc16) { | |
| 39 flags |= kHasFilter16_Flag; | |
| 40 } | |
| 41 return flags; | |
| 42 } | 31 } |
| 43 | 32 |
| 44 void SkModeColorFilter::filterSpan(const SkPMColor shader[], int count, SkPMColo
r result[]) const { | 33 void SkModeColorFilter::filterSpan(const SkPMColor shader[], int count, SkPMColo
r result[]) const { |
| 45 SkPMColor color = fPMColor; | 34 SkPMColor color = fPMColor; |
| 46 SkXfermodeProc proc = fProc; | 35 SkXfermodeProc proc = fProc; |
| 47 | 36 |
| 48 for (int i = 0; i < count; i++) { | 37 for (int i = 0; i < count; i++) { |
| 49 result[i] = proc(color, shader[i]); | 38 result[i] = proc(color, shader[i]); |
| 50 } | 39 } |
| 51 } | 40 } |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 #endif | 383 #endif |
| 395 | 384 |
| 396 /////////////////////////////////////////////////////////////////////////////// | 385 /////////////////////////////////////////////////////////////////////////////// |
| 397 | 386 |
| 398 class Src_SkModeColorFilter : public SkModeColorFilter { | 387 class Src_SkModeColorFilter : public SkModeColorFilter { |
| 399 public: | 388 public: |
| 400 Src_SkModeColorFilter(SkColor color) : INHERITED(color, SkXfermode::kSrc_Mod
e) {} | 389 Src_SkModeColorFilter(SkColor color) : INHERITED(color, SkXfermode::kSrc_Mod
e) {} |
| 401 | 390 |
| 402 uint32_t getFlags() const SK_OVERRIDE { | 391 uint32_t getFlags() const SK_OVERRIDE { |
| 403 if (SkGetPackedA32(this->getPMColor()) == 0xFF) { | 392 if (SkGetPackedA32(this->getPMColor()) == 0xFF) { |
| 404 return kHasFilter16_Flag; | 393 return kAlphaUnchanged_Flag | kHasFilter16_Flag; |
| 405 } else { | 394 } else { |
| 406 return 0; | 395 return 0; |
| 407 } | 396 } |
| 408 } | 397 } |
| 409 | 398 |
| 410 virtual void filterSpan(const SkPMColor shader[], int count, | 399 virtual void filterSpan(const SkPMColor shader[], int count, |
| 411 SkPMColor result[]) const SK_OVERRIDE { | 400 SkPMColor result[]) const SK_OVERRIDE { |
| 412 sk_memset32(result, this->getPMColor(), count); | 401 sk_memset32(result, this->getPMColor(), count); |
| 413 } | 402 } |
| 414 | 403 |
| 415 virtual void filterSpan16(const uint16_t shader[], int count, | 404 virtual void filterSpan16(const uint16_t shader[], int count, |
| 416 uint16_t result[]) const SK_OVERRIDE { | 405 uint16_t result[]) const SK_OVERRIDE { |
| 417 SkASSERT(this->getFlags() & kHasFilter16_Flag); | 406 SkASSERT(this->getFlags() & kHasFilter16_Flag); |
| 418 sk_memset16(result, SkPixel32ToPixel16(this->getPMColor()), count); | 407 sk_memset16(result, SkPixel32ToPixel16(this->getPMColor()), count); |
| 419 } | 408 } |
| 420 | 409 |
| 421 private: | 410 private: |
| 422 typedef SkModeColorFilter INHERITED; | 411 typedef SkModeColorFilter INHERITED; |
| 423 }; | 412 }; |
| 424 | 413 |
| 425 class SrcOver_SkModeColorFilter : public SkModeColorFilter { | 414 class SrcOver_SkModeColorFilter : public SkModeColorFilter { |
| 426 public: | 415 public: |
| 427 SrcOver_SkModeColorFilter(SkColor color) | 416 SrcOver_SkModeColorFilter(SkColor color) |
| 428 : INHERITED(color, SkXfermode::kSrcOver_Mode) { | 417 : INHERITED(color, SkXfermode::kSrcOver_Mode) { |
| 429 fColor32Proc = SkBlitRow::ColorProcFactory(); | 418 fColor32Proc = SkBlitRow::ColorProcFactory(); |
| 430 } | 419 } |
| 431 | 420 |
| 432 uint32_t getFlags() const SK_OVERRIDE { | 421 uint32_t getFlags() const SK_OVERRIDE { |
| 433 if (SkGetPackedA32(this->getPMColor()) == 0xFF) { | 422 if (SkGetPackedA32(this->getPMColor()) == 0xFF) { |
| 434 return kHasFilter16_Flag; | 423 return kAlphaUnchanged_Flag | kHasFilter16_Flag; |
| 435 } else { | 424 } else { |
| 436 return 0; | 425 return 0; |
| 437 } | 426 } |
| 438 } | 427 } |
| 439 | 428 |
| 440 virtual void filterSpan(const SkPMColor shader[], int count, | 429 virtual void filterSpan(const SkPMColor shader[], int count, |
| 441 SkPMColor result[]) const SK_OVERRIDE { | 430 SkPMColor result[]) const SK_OVERRIDE { |
| 442 fColor32Proc(result, shader, count, this->getPMColor()); | 431 fColor32Proc(result, shader, count, this->getPMColor()); |
| 443 } | 432 } |
| 444 | 433 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 byte_to_scale(SkColorGetG(mul)), | 506 byte_to_scale(SkColorGetG(mul)), |
| 518 byte_to_scale(SkColorGetB(mul)), | 507 byte_to_scale(SkColorGetB(mul)), |
| 519 1); | 508 1); |
| 520 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)), | 509 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)), |
| 521 SkIntToScalar(SkColorGetG(add)), | 510 SkIntToScalar(SkColorGetG(add)), |
| 522 SkIntToScalar(SkColorGetB(add)), | 511 SkIntToScalar(SkColorGetB(add)), |
| 523 0); | 512 0); |
| 524 return SkColorMatrixFilter::Create(matrix); | 513 return SkColorMatrixFilter::Create(matrix); |
| 525 } | 514 } |
| 526 | 515 |
| OLD | NEW |