| 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 return fProc16 ? (kAlphaUnchanged_Flag | kHasFilter16_Flag) : 0; | 30 uint32_t flags = 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; |
| 31 } | 42 } |
| 32 | 43 |
| 33 void SkModeColorFilter::filterSpan(const SkPMColor shader[], int count, SkPMColo
r result[]) const { | 44 void SkModeColorFilter::filterSpan(const SkPMColor shader[], int count, SkPMColo
r result[]) const { |
| 34 SkPMColor color = fPMColor; | 45 SkPMColor color = fPMColor; |
| 35 SkXfermodeProc proc = fProc; | 46 SkXfermodeProc proc = fProc; |
| 36 | 47 |
| 37 for (int i = 0; i < count; i++) { | 48 for (int i = 0; i < count; i++) { |
| 38 result[i] = proc(color, shader[i]); | 49 result[i] = proc(color, shader[i]); |
| 39 } | 50 } |
| 40 } | 51 } |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 #endif | 394 #endif |
| 384 | 395 |
| 385 /////////////////////////////////////////////////////////////////////////////// | 396 /////////////////////////////////////////////////////////////////////////////// |
| 386 | 397 |
| 387 class Src_SkModeColorFilter : public SkModeColorFilter { | 398 class Src_SkModeColorFilter : public SkModeColorFilter { |
| 388 public: | 399 public: |
| 389 Src_SkModeColorFilter(SkColor color) : INHERITED(color, SkXfermode::kSrc_Mod
e) {} | 400 Src_SkModeColorFilter(SkColor color) : INHERITED(color, SkXfermode::kSrc_Mod
e) {} |
| 390 | 401 |
| 391 uint32_t getFlags() const SK_OVERRIDE { | 402 uint32_t getFlags() const SK_OVERRIDE { |
| 392 if (SkGetPackedA32(this->getPMColor()) == 0xFF) { | 403 if (SkGetPackedA32(this->getPMColor()) == 0xFF) { |
| 393 return kAlphaUnchanged_Flag | kHasFilter16_Flag; | 404 return kHasFilter16_Flag; |
| 394 } else { | 405 } else { |
| 395 return 0; | 406 return 0; |
| 396 } | 407 } |
| 397 } | 408 } |
| 398 | 409 |
| 399 virtual void filterSpan(const SkPMColor shader[], int count, | 410 virtual void filterSpan(const SkPMColor shader[], int count, |
| 400 SkPMColor result[]) const SK_OVERRIDE { | 411 SkPMColor result[]) const SK_OVERRIDE { |
| 401 sk_memset32(result, this->getPMColor(), count); | 412 sk_memset32(result, this->getPMColor(), count); |
| 402 } | 413 } |
| 403 | 414 |
| 404 virtual void filterSpan16(const uint16_t shader[], int count, | 415 virtual void filterSpan16(const uint16_t shader[], int count, |
| 405 uint16_t result[]) const SK_OVERRIDE { | 416 uint16_t result[]) const SK_OVERRIDE { |
| 406 SkASSERT(this->getFlags() & kHasFilter16_Flag); | 417 SkASSERT(this->getFlags() & kHasFilter16_Flag); |
| 407 sk_memset16(result, SkPixel32ToPixel16(this->getPMColor()), count); | 418 sk_memset16(result, SkPixel32ToPixel16(this->getPMColor()), count); |
| 408 } | 419 } |
| 409 | 420 |
| 410 private: | 421 private: |
| 411 typedef SkModeColorFilter INHERITED; | 422 typedef SkModeColorFilter INHERITED; |
| 412 }; | 423 }; |
| 413 | 424 |
| 414 class SrcOver_SkModeColorFilter : public SkModeColorFilter { | 425 class SrcOver_SkModeColorFilter : public SkModeColorFilter { |
| 415 public: | 426 public: |
| 416 SrcOver_SkModeColorFilter(SkColor color) | 427 SrcOver_SkModeColorFilter(SkColor color) |
| 417 : INHERITED(color, SkXfermode::kSrcOver_Mode) { | 428 : INHERITED(color, SkXfermode::kSrcOver_Mode) { |
| 418 fColor32Proc = SkBlitRow::ColorProcFactory(); | 429 fColor32Proc = SkBlitRow::ColorProcFactory(); |
| 419 } | 430 } |
| 420 | 431 |
| 421 uint32_t getFlags() const SK_OVERRIDE { | 432 uint32_t getFlags() const SK_OVERRIDE { |
| 422 if (SkGetPackedA32(this->getPMColor()) == 0xFF) { | 433 if (SkGetPackedA32(this->getPMColor()) == 0xFF) { |
| 423 return kAlphaUnchanged_Flag | kHasFilter16_Flag; | 434 return kHasFilter16_Flag; |
| 424 } else { | 435 } else { |
| 425 return 0; | 436 return 0; |
| 426 } | 437 } |
| 427 } | 438 } |
| 428 | 439 |
| 429 virtual void filterSpan(const SkPMColor shader[], int count, | 440 virtual void filterSpan(const SkPMColor shader[], int count, |
| 430 SkPMColor result[]) const SK_OVERRIDE { | 441 SkPMColor result[]) const SK_OVERRIDE { |
| 431 fColor32Proc(result, shader, count, this->getPMColor()); | 442 fColor32Proc(result, shader, count, this->getPMColor()); |
| 432 } | 443 } |
| 433 | 444 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 byte_to_scale(SkColorGetG(mul)), | 517 byte_to_scale(SkColorGetG(mul)), |
| 507 byte_to_scale(SkColorGetB(mul)), | 518 byte_to_scale(SkColorGetB(mul)), |
| 508 1); | 519 1); |
| 509 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)), | 520 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)), |
| 510 SkIntToScalar(SkColorGetG(add)), | 521 SkIntToScalar(SkColorGetG(add)), |
| 511 SkIntToScalar(SkColorGetB(add)), | 522 SkIntToScalar(SkColorGetB(add)), |
| 512 0); | 523 0); |
| 513 return SkColorMatrixFilter::Create(matrix); | 524 return SkColorMatrixFilter::Create(matrix); |
| 514 } | 525 } |
| 515 | 526 |
| OLD | NEW |