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 "SkComposeShader.h" | 8 #include "SkComposeShader.h" |
9 #include "SkColorFilter.h" | 9 #include "SkColorFilter.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 #if SK_SUPPORT_GPU | 179 #if SK_SUPPORT_GPU |
180 | 180 |
181 #include "effects/GrConstColorProcessor.h" | 181 #include "effects/GrConstColorProcessor.h" |
182 #include "effects/GrXfermodeFragmentProcessor.h" | 182 #include "effects/GrXfermodeFragmentProcessor.h" |
183 | 183 |
184 ///////////////////////////////////////////////////////////////////// | 184 ///////////////////////////////////////////////////////////////////// |
185 | 185 |
186 sk_sp<GrFragmentProcessor> SkComposeShader::asFragmentProcessor( | 186 sk_sp<GrFragmentProcessor> SkComposeShader::asFragmentProcessor(const AsFPArgs&
args) const { |
187 GrContext* context, | |
188 const SkMatrix& viewM, | |
189 const SkMatrix* localMatrix
, | |
190 SkFilterQuality fq, | |
191 SkSourceGammaTreatment gamm
aTreatment) const { | |
192 // Fragment processor will only support SkXfermode::Mode modes currently. | 187 // Fragment processor will only support SkXfermode::Mode modes currently. |
193 SkXfermode::Mode mode; | 188 SkXfermode::Mode mode; |
194 if (!(SkXfermode::AsMode(fMode, &mode))) { | 189 if (!(SkXfermode::AsMode(fMode, &mode))) { |
195 return nullptr; | 190 return nullptr; |
196 } | 191 } |
197 | 192 |
198 switch (mode) { | 193 switch (mode) { |
199 case SkXfermode::kClear_Mode: | 194 case SkXfermode::kClear_Mode: |
200 return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK, | 195 return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK, |
201 GrConstColorProcessor::kIgnore_In
putMode); | 196 GrConstColorProcessor::kIgnore_In
putMode); |
202 break; | 197 break; |
203 case SkXfermode::kSrc_Mode: | 198 case SkXfermode::kSrc_Mode: |
204 return fShaderB->asFragmentProcessor(context, viewM, localMatrix, fq
, gammaTreatment); | 199 return fShaderB->asFragmentProcessor(args); |
205 break; | 200 break; |
206 case SkXfermode::kDst_Mode: | 201 case SkXfermode::kDst_Mode: |
207 return fShaderA->asFragmentProcessor(context, viewM, localMatrix, fq
, gammaTreatment); | 202 return fShaderA->asFragmentProcessor(args); |
208 break; | 203 break; |
209 default: | 204 default: |
210 sk_sp<GrFragmentProcessor> fpA(fShaderA->asFragmentProcessor(context
, | 205 sk_sp<GrFragmentProcessor> fpA(fShaderA->asFragmentProcessor(args)); |
211 viewM, localMatrix, fq, gammaTreatmen
t)); | |
212 if (!fpA) { | 206 if (!fpA) { |
213 return nullptr; | 207 return nullptr; |
214 } | 208 } |
215 sk_sp<GrFragmentProcessor> fpB(fShaderB->asFragmentProcessor(context
, | 209 sk_sp<GrFragmentProcessor> fpB(fShaderB->asFragmentProcessor(args)); |
216 viewM, localMatrix, fq, gammaTreatmen
t)); | |
217 if (!fpB) { | 210 if (!fpB) { |
218 return nullptr; | 211 return nullptr; |
219 } | 212 } |
220 return GrXfermodeFragmentProcessor::MakeFromTwoProcessors(std::move(
fpB), | 213 return GrXfermodeFragmentProcessor::MakeFromTwoProcessors(std::move(
fpB), |
221 std::move(
fpA), mode); | 214 std::move(
fpA), mode); |
222 } | 215 } |
223 } | 216 } |
224 #endif | 217 #endif |
225 | 218 |
226 #ifndef SK_IGNORE_TO_STRING | 219 #ifndef SK_IGNORE_TO_STRING |
(...skipping 22 matching lines...) Expand all Loading... |
249 if (!dst || !src) { | 242 if (!dst || !src) { |
250 return nullptr; | 243 return nullptr; |
251 } | 244 } |
252 return sk_make_sp<SkComposeShader>(std::move(dst), std::move(src), std::move
(xfer)); | 245 return sk_make_sp<SkComposeShader>(std::move(dst), std::move(src), std::move
(xfer)); |
253 } | 246 } |
254 | 247 |
255 sk_sp<SkShader> SkShader::MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader>
src, | 248 sk_sp<SkShader> SkShader::MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader>
src, |
256 SkXfermode::Mode mode) { | 249 SkXfermode::Mode mode) { |
257 return MakeComposeShader(std::move(dst), std::move(src), SkXfermode::Make(mo
de)); | 250 return MakeComposeShader(std::move(dst), std::move(src), SkXfermode::Make(mo
de)); |
258 } | 251 } |
OLD | NEW |