@@ -262,15 +262,17 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
262262
263263 // Setup the initial color considering the shader, the SkPaint color, and the presence or not
264264 // of per-vertex colors.
265- std::unique_ptr<GrFragmentProcessor> shaderFP ;
265+ std::unique_ptr<GrFragmentProcessor> paintFP ;
266266 if (!primColorMode || blend_requires_shader (*primColorMode)) {
267267 fpArgs.fInputColorIsOpaque = origColor.isOpaque ();
268268 if (shaderProcessor) {
269- shaderFP = std::move (*shaderProcessor);
270- } else if (const auto * shader = as_SB (skPaint.getShader ())) {
271- shaderFP = shader->asFragmentProcessor (fpArgs);
272- if (!shaderFP) {
273- return false ;
269+ paintFP = std::move (*shaderProcessor);
270+ } else {
271+ if (const SkShaderBase* shader = as_SB (skPaint.getShader ())) {
272+ paintFP = shader->asFragmentProcessor (fpArgs);
273+ if (paintFP == nullptr ) {
274+ return false ;
275+ }
274276 }
275277 }
276278 }
@@ -279,7 +281,7 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
279281 // a known constant value. In that case we can simply apply a color filter during this
280282 // conversion without converting the color filter to a GrFragmentProcessor.
281283 bool applyColorFilterToPaintColor = false ;
282- if (shaderFP ) {
284+ if (paintFP ) {
283285 if (primColorMode) {
284286 // There is a blend between the primitive color and the shader color. The shader sees
285287 // the opaque paint color. The shader's output is blended using the provided mode by
@@ -289,61 +291,55 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
289291 // the GrPaint color will be ignored.
290292
291293 SkPMColor4f shaderInput = origColor.makeOpaque ().premul ();
292- shaderFP = GrFragmentProcessor::OverrideInput (std::move (shaderFP ), shaderInput);
293- shaderFP = GrXfermodeFragmentProcessor::MakeFromSrcProcessor (std::move (shaderFP ),
294- *primColorMode);
294+ paintFP = GrFragmentProcessor::OverrideInput (std::move (paintFP ), shaderInput);
295+ paintFP = GrXfermodeFragmentProcessor::MakeFromSrcProcessor (std::move (paintFP ),
296+ *primColorMode);
295297
296298 // We can ignore origColor here - alpha is unchanged by gamma
297299 float paintAlpha = skPaint.getColor4f ().fA ;
298300 if (1 .0f != paintAlpha) {
299301 // No gamut conversion - paintAlpha is a (linear) alpha value, splatted to all
300302 // color channels. It's value should be treated as the same in ANY color space.
301- shaderFP = GrConstColorProcessor::Make (
302- std::move (shaderFP ), { paintAlpha, paintAlpha, paintAlpha, paintAlpha },
303+ paintFP = GrConstColorProcessor::Make (
304+ std::move (paintFP ), { paintAlpha, paintAlpha, paintAlpha, paintAlpha },
303305 GrConstColorProcessor::InputMode::kModulateRGBA );
304306 }
305-
306- // The above may return null if compose results in a pass through of the prim color.
307- if (shaderFP) {
308- grPaint->addColorFragmentProcessor (std::move (shaderFP));
309- }
310307 } else {
311308 // The shader's FP sees the paint *unpremul* color
312309 SkPMColor4f origColorAsPM = { origColor.fR , origColor.fG , origColor.fB , origColor.fA };
313310 grPaint->setColor4f (origColorAsPM);
314- grPaint->addColorFragmentProcessor (std::move (shaderFP));
315311 }
316312 } else {
317313 if (primColorMode) {
318314 // There is a blend between the primitive color and the paint color. The blend considers
319315 // the opaque paint color. The paint's alpha is applied to the post-blended color.
320316 SkPMColor4f opaqueColor = origColor.makeOpaque ().premul ();
321- auto processor = GrConstColorProcessor::Make (/* inputFP=*/ nullptr , opaqueColor,
322- GrConstColorProcessor::InputMode::kIgnore );
323- processor = GrXfermodeFragmentProcessor::MakeFromSrcProcessor (std::move (processor ),
324- *primColorMode);
317+ paintFP = GrConstColorProcessor::Make (/* inputFP=*/ nullptr , opaqueColor,
318+ GrConstColorProcessor::InputMode::kIgnore );
319+ paintFP = GrXfermodeFragmentProcessor::MakeFromSrcProcessor (std::move (paintFP ),
320+ *primColorMode);
325321 grPaint->setColor4f (opaqueColor);
326322
327323 // We can ignore origColor here - alpha is unchanged by gamma
328324 float paintAlpha = skPaint.getColor4f ().fA ;
329325 if (1 .0f != paintAlpha) {
330326 // No gamut conversion - paintAlpha is a (linear) alpha value, splatted to all
331327 // color channels. It's value should be treated as the same in ANY color space.
332- processor = GrConstColorProcessor::Make (
333- std::move (processor ), { paintAlpha, paintAlpha, paintAlpha, paintAlpha },
328+ paintFP = GrConstColorProcessor::Make (
329+ std::move (paintFP ), { paintAlpha, paintAlpha, paintAlpha, paintAlpha },
334330 GrConstColorProcessor::InputMode::kModulateRGBA );
335331 }
336-
337- if (processor) {
338- grPaint->addColorFragmentProcessor (std::move (processor));
339- }
340332 } else {
341333 // No shader, no primitive color.
342334 grPaint->setColor4f (origColor.premul ());
343335 applyColorFilterToPaintColor = true ;
344336 }
345337 }
346338
339+ if (paintFP) {
340+ grPaint->addColorFragmentProcessor (std::move (paintFP));
341+ }
342+
347343 SkColorFilter* colorFilter = skPaint.getColorFilter ();
348344 if (colorFilter) {
349345 if (applyColorFilterToPaintColor) {
0 commit comments