OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkComposeShader.h" | 10 #include "SkComposeShader.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 #if SK_SUPPORT_GPU | 197 #if SK_SUPPORT_GPU |
198 | 198 |
199 #include "effects/GrConstColorProcessor.h" | 199 #include "effects/GrConstColorProcessor.h" |
200 #include "effects/GrXfermodeFragmentProcessor.h" | 200 #include "effects/GrXfermodeFragmentProcessor.h" |
201 | 201 |
202 ///////////////////////////////////////////////////////////////////// | 202 ///////////////////////////////////////////////////////////////////// |
203 | 203 |
204 const GrFragmentProcessor* SkComposeShader::asFragmentProcessor(GrContext* conte
xt, | 204 const GrFragmentProcessor* SkComposeShader::asFragmentProcessor(GrContext* conte
xt, |
205 const SkMatrix& view
M, | 205 const SkMatrix& view
M, |
206 const SkMatrix* loca
lMatrix, | 206 const SkMatrix* loca
lMatrix, |
207 SkFilterQuality fq, | 207 SkFilterQuality fq)
const { |
208 GrProcessorDataManag
er* procDataManager | |
209 ) const { | |
210 // Fragment processor will only support SkXfermode::Mode modes currently. | 208 // Fragment processor will only support SkXfermode::Mode modes currently. |
211 SkXfermode::Mode mode; | 209 SkXfermode::Mode mode; |
212 if (!(SkXfermode::AsMode(fMode, &mode))) { | 210 if (!(SkXfermode::AsMode(fMode, &mode))) { |
213 return nullptr; | 211 return nullptr; |
214 } | 212 } |
215 | 213 |
216 switch (mode) { | 214 switch (mode) { |
217 case SkXfermode::kClear_Mode: | 215 case SkXfermode::kClear_Mode: |
218 return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK, | 216 return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK, |
219 GrConstColorProcessor::kIgnore_
InputMode); | 217 GrConstColorProcessor::kIgnore_
InputMode); |
220 break; | 218 break; |
221 case SkXfermode::kSrc_Mode: | 219 case SkXfermode::kSrc_Mode: |
222 return fShaderB->asFragmentProcessor(context, viewM, localMatrix, fq
, procDataManager); | 220 return fShaderB->asFragmentProcessor(context, viewM, localMatrix, fq
); |
223 break; | 221 break; |
224 case SkXfermode::kDst_Mode: | 222 case SkXfermode::kDst_Mode: |
225 return fShaderA->asFragmentProcessor(context, viewM, localMatrix, fq
, procDataManager); | 223 return fShaderA->asFragmentProcessor(context, viewM, localMatrix, fq
); |
226 break; | 224 break; |
227 default: | 225 default: |
228 SkAutoTUnref<const GrFragmentProcessor> fpA(fShaderA->asFragmentProc
essor(context, | 226 SkAutoTUnref<const GrFragmentProcessor> fpA(fShaderA->asFragmentProc
essor(context, |
229 viewM, localMatrix, fq,
procDataManager)); | 227 viewM, localMatrix, fq))
; |
230 if (!fpA.get()) { | 228 if (!fpA.get()) { |
231 return nullptr; | 229 return nullptr; |
232 } | 230 } |
233 SkAutoTUnref<const GrFragmentProcessor> fpB(fShaderB->asFragmentProc
essor(context, | 231 SkAutoTUnref<const GrFragmentProcessor> fpB(fShaderB->asFragmentProc
essor(context, |
234 viewM, localMatrix, fq,
procDataManager)); | 232 viewM, localMatrix, fq))
; |
235 if (!fpB.get()) { | 233 if (!fpB.get()) { |
236 return nullptr; | 234 return nullptr; |
237 } | 235 } |
238 return GrXfermodeFragmentProcessor::CreateFromTwoProcessors(fpB, fpA
, mode); | 236 return GrXfermodeFragmentProcessor::CreateFromTwoProcessors(fpB, fpA
, mode); |
239 } | 237 } |
240 } | 238 } |
241 #endif | 239 #endif |
242 | 240 |
243 #ifndef SK_IGNORE_TO_STRING | 241 #ifndef SK_IGNORE_TO_STRING |
244 void SkComposeShader::toString(SkString* str) const { | 242 void SkComposeShader::toString(SkString* str) const { |
245 str->append("SkComposeShader: ("); | 243 str->append("SkComposeShader: ("); |
246 | 244 |
247 str->append("ShaderA: "); | 245 str->append("ShaderA: "); |
248 fShaderA->toString(str); | 246 fShaderA->toString(str); |
249 str->append(" ShaderB: "); | 247 str->append(" ShaderB: "); |
250 fShaderB->toString(str); | 248 fShaderB->toString(str); |
251 if (fMode) { | 249 if (fMode) { |
252 str->append(" Xfermode: "); | 250 str->append(" Xfermode: "); |
253 fMode->toString(str); | 251 fMode->toString(str); |
254 } | 252 } |
255 | 253 |
256 this->INHERITED::toString(str); | 254 this->INHERITED::toString(str); |
257 | 255 |
258 str->append(")"); | 256 str->append(")"); |
259 } | 257 } |
260 #endif | 258 #endif |
OLD | NEW |