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" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 /////////////////////////////////////////////////////////////////////////////// | 65 /////////////////////////////////////////////////////////////////////////////// |
66 #if SK_SUPPORT_GPU | 66 #if SK_SUPPORT_GPU |
67 #include "GrBlend.h" | 67 #include "GrBlend.h" |
68 #include "GrInvariantOutput.h" | 68 #include "GrInvariantOutput.h" |
69 #include "effects/GrXfermodeFragmentProcessor.h" | 69 #include "effects/GrXfermodeFragmentProcessor.h" |
70 #include "effects/GrConstColorProcessor.h" | 70 #include "effects/GrConstColorProcessor.h" |
71 #include "SkGr.h" | 71 #include "SkGr.h" |
72 | 72 |
73 bool SkModeColorFilter::asFragmentProcessors(GrContext*, GrProcessorDataManager*
, | 73 const GrFragmentProcessor* SkModeColorFilter::asFragmentProcessor(GrContext*, |
74 SkTDArray<const GrFragmentProcessor
*>* array) const { | 74 GrProcessorDat
aManager*) const { |
75 if (SkXfermode::kDst_Mode != fMode) { | 75 if (SkXfermode::kDst_Mode == fMode) { |
76 SkAutoTUnref<const GrFragmentProcessor> constFP( | 76 return nullptr; |
77 GrConstColorProcessor::Create(SkColorToPremulGrColor(fColor), | 77 } |
78 GrConstColorProcessor::kIgnore_InputMo
de)); | 78 |
79 const GrFragmentProcessor* fp = | 79 SkAutoTUnref<const GrFragmentProcessor> constFP( |
80 GrXfermodeFragmentProcessor::CreateFromSrcProcessor(constFP, fMode); | 80 GrConstColorProcessor::Create(SkColorToPremulGrColor(fColor), |
81 if (fp) { | 81 GrConstColorProcessor::kIgnore_InputMode
)); |
| 82 const GrFragmentProcessor* fp = |
| 83 GrXfermodeFragmentProcessor::CreateFromSrcProcessor(constFP, fMode); |
| 84 if (!fp) { |
| 85 return nullptr; |
| 86 } |
82 #ifdef SK_DEBUG | 87 #ifdef SK_DEBUG |
83 // With a solid color input this should always be able to compute th
e blended color | 88 // With a solid color input this should always be able to compute the blende
d color |
84 // (at least for coeff modes) | 89 // (at least for coeff modes) |
85 if (fMode <= SkXfermode::kLastCoeffMode) { | 90 if (fMode <= SkXfermode::kLastCoeffMode) { |
86 static SkRandom gRand; | 91 static SkRandom gRand; |
87 GrInvariantOutput io(GrPremulColor(gRand.nextU()), kRGBA_GrColor
ComponentFlags, | 92 GrInvariantOutput io(GrPremulColor(gRand.nextU()), kRGBA_GrColorComponen
tFlags, |
88 false); | 93 false); |
89 fp->computeInvariantOutput(&io); | 94 fp->computeInvariantOutput(&io); |
90 SkASSERT(io.validFlags() == kRGBA_GrColorComponentFlags); | 95 SkASSERT(io.validFlags() == kRGBA_GrColorComponentFlags); |
91 } | 96 } |
92 #endif | 97 #endif |
93 if (array) { | 98 return fp; |
94 *array->append() = fp; | |
95 } else { | |
96 fp->unref(); | |
97 SkDEBUGCODE(fp = nullptr;) | |
98 } | |
99 return true; | |
100 } | |
101 } | |
102 return false; | |
103 } | 99 } |
104 | 100 |
105 #endif | 101 #endif |
106 | 102 |
107 /////////////////////////////////////////////////////////////////////////////// | 103 /////////////////////////////////////////////////////////////////////////////// |
108 | 104 |
109 class Src_SkModeColorFilter : public SkModeColorFilter { | 105 class Src_SkModeColorFilter : public SkModeColorFilter { |
110 public: | 106 public: |
111 Src_SkModeColorFilter(SkColor color) : INHERITED(color, SkXfermode::kSrc_Mod
e) {} | 107 Src_SkModeColorFilter(SkColor color) : INHERITED(color, SkXfermode::kSrc_Mod
e) {} |
112 | 108 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 byte_to_scale(SkColorGetG(mul)), | 188 byte_to_scale(SkColorGetG(mul)), |
193 byte_to_scale(SkColorGetB(mul)), | 189 byte_to_scale(SkColorGetB(mul)), |
194 1); | 190 1); |
195 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)), | 191 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)), |
196 SkIntToScalar(SkColorGetG(add)), | 192 SkIntToScalar(SkColorGetG(add)), |
197 SkIntToScalar(SkColorGetB(add)), | 193 SkIntToScalar(SkColorGetB(add)), |
198 0); | 194 0); |
199 return SkColorMatrixFilter::Create(matrix); | 195 return SkColorMatrixFilter::Create(matrix); |
200 } | 196 } |
201 | 197 |
OLD | NEW |