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)
const { | 207 SkFilterQuality fq, |
| 208 GrRenderTarget* dst)
const { |
208 // Fragment processor will only support SkXfermode::Mode modes currently. | 209 // Fragment processor will only support SkXfermode::Mode modes currently. |
209 SkXfermode::Mode mode; | 210 SkXfermode::Mode mode; |
210 if (!(SkXfermode::AsMode(fMode, &mode))) { | 211 if (!(SkXfermode::AsMode(fMode, &mode))) { |
211 return nullptr; | 212 return nullptr; |
212 } | 213 } |
213 | 214 |
214 switch (mode) { | 215 switch (mode) { |
215 case SkXfermode::kClear_Mode: | 216 case SkXfermode::kClear_Mode: |
216 return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK, | 217 return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK, |
217 GrConstColorProcessor::kIgnore_
InputMode); | 218 GrConstColorProcessor::kIgnore_
InputMode); |
218 break; | 219 break; |
219 case SkXfermode::kSrc_Mode: | 220 case SkXfermode::kSrc_Mode: |
220 return fShaderB->asFragmentProcessor(context, viewM, localMatrix, fq
); | 221 return fShaderB->asFragmentProcessor(context, viewM, localMatrix, fq
, dst); |
221 break; | 222 break; |
222 case SkXfermode::kDst_Mode: | 223 case SkXfermode::kDst_Mode: |
223 return fShaderA->asFragmentProcessor(context, viewM, localMatrix, fq
); | 224 return fShaderA->asFragmentProcessor(context, viewM, localMatrix, fq
, dst); |
224 break; | 225 break; |
225 default: | 226 default: |
226 SkAutoTUnref<const GrFragmentProcessor> fpA(fShaderA->asFragmentProc
essor(context, | 227 SkAutoTUnref<const GrFragmentProcessor> fpA(fShaderA->asFragmentProc
essor(context, |
227 viewM, localMatrix, fq))
; | 228 viewM, localMatrix, fq,
dst)); |
228 if (!fpA.get()) { | 229 if (!fpA.get()) { |
229 return nullptr; | 230 return nullptr; |
230 } | 231 } |
231 SkAutoTUnref<const GrFragmentProcessor> fpB(fShaderB->asFragmentProc
essor(context, | 232 SkAutoTUnref<const GrFragmentProcessor> fpB(fShaderB->asFragmentProc
essor(context, |
232 viewM, localMatrix, fq))
; | 233 viewM, localMatrix, fq,
dst)); |
233 if (!fpB.get()) { | 234 if (!fpB.get()) { |
234 return nullptr; | 235 return nullptr; |
235 } | 236 } |
236 return GrXfermodeFragmentProcessor::CreateFromTwoProcessors(fpB, fpA
, mode); | 237 return GrXfermodeFragmentProcessor::CreateFromTwoProcessors(fpB, fpA
, mode); |
237 } | 238 } |
238 } | 239 } |
239 #endif | 240 #endif |
240 | 241 |
241 #ifndef SK_IGNORE_TO_STRING | 242 #ifndef SK_IGNORE_TO_STRING |
242 void SkComposeShader::toString(SkString* str) const { | 243 void SkComposeShader::toString(SkString* str) const { |
243 str->append("SkComposeShader: ("); | 244 str->append("SkComposeShader: ("); |
244 | 245 |
245 str->append("ShaderA: "); | 246 str->append("ShaderA: "); |
246 fShaderA->toString(str); | 247 fShaderA->toString(str); |
247 str->append(" ShaderB: "); | 248 str->append(" ShaderB: "); |
248 fShaderB->toString(str); | 249 fShaderB->toString(str); |
249 if (fMode) { | 250 if (fMode) { |
250 str->append(" Xfermode: "); | 251 str->append(" Xfermode: "); |
251 fMode->toString(str); | 252 fMode->toString(str); |
252 } | 253 } |
253 | 254 |
254 this->INHERITED::toString(str); | 255 this->INHERITED::toString(str); |
255 | 256 |
256 str->append(")"); | 257 str->append(")"); |
257 } | 258 } |
258 #endif | 259 #endif |
OLD | NEW |