From f5179a4c490bc787190321bd8ffdb0e6a4efa9ac Mon Sep 17 00:00:00 2001 From: bsalomon Date: Wed, 8 Jul 2015 07:55:59 -0700 Subject: Makes GrPipelineInfo a class with query functions used by GrBatch subclasses. Review URL: https://codereview.chromium.org/1213383005 --- src/gpu/GrPipeline.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'src/gpu/GrPipeline.cpp') diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp index 4feddb00ab..7bdc3000d5 100644 --- a/src/gpu/GrPipeline.cpp +++ b/src/gpu/GrPipeline.cpp @@ -30,7 +30,7 @@ GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder, overrideColor = colorPOI.inputColorToEffectiveStage(); } - GrXferProcessor::OptFlags optFlags; + GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; if (xferProcessor) { fXferProcessor.reset(xferProcessor.get()); @@ -41,6 +41,11 @@ GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder, caps); } + // No need to have an override color if it isn't even going to be used. + if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag)) { + overrideColor = GrColor_ILLEGAL; + } + // When path rendering the stencil settings are not always set on the GrPipelineBuilder // so we must check the draw type. In cases where we will skip drawing we simply return a // null GrPipeline. @@ -98,13 +103,25 @@ GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder, pipelineBuilder.fCoverageStages[i].processor()->usesLocalCoords(); } - // let the GP init the batch tracker - fInitBT.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag); - fInitBT.fOverrideColor = fInitBT.fColorIgnored ? GrColor_ILLEGAL : overrideColor; - fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag); - fInitBT.fUsesLocalCoords = usesLocalCoords; - fInitBT.fCanTweakAlphaForCoverage = - SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag); + // Setup info we need to pass to GrPrimitiveProcessors that are used with this GrPipeline. + fInfoForPrimitiveProcessor.fFlags = 0; + if (!SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag)) { + fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsColor_GrPipelineInfoFlag; + } + if (GrColor_ILLEGAL != overrideColor) { + fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kUseOverrideColor_GrPipelineInfoFlag; + fInfoForPrimitiveProcessor.fOverrideColor = overrideColor; + } + if (!SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag)) { + fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsCoverage_GrPipelineInfoFlag; + } + if (usesLocalCoords) { + fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsLocalCoords_GrPipelineInfoFlag; + } + if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag)) { + fInfoForPrimitiveProcessor.fFlags |= + GrPipelineInfo::kCanTweakAlphaForCoverage_GrPipelineInfoFlag; + } } void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelineBuilder, -- cgit v1.2.3