return (kColorIsKnown_Flag & fFlags) ? fColor == that.fColor : true;
}
+ /** The returned value reflects the common properties of the two inputs. */
+ static GrPipelineAnalysisColor Combine(const GrPipelineAnalysisColor& a,
+ const GrPipelineAnalysisColor& b) {
+ GrPipelineAnalysisColor result;
+ uint32_t commonFlags = a.fFlags & b.fFlags;
+ if ((kColorIsKnown_Flag & commonFlags) && a.fColor == b.fColor) {
+ result.fColor = a.fColor;
+ result.fFlags = a.fFlags;
+ } else if (kIsOpaque_Flag & commonFlags) {
+ result.fFlags = kIsOpaque_Flag;
+ }
+ return result;
+ }
+
private:
enum Flags {
kColorIsKnown_Flag = 0x1,
*/
#include "InstancedRendering.h"
-
+#include "GrAppliedClip.h"
#include "GrCaps.h"
#include "GrOpFlushState.h"
#include "GrPipeline.h"
op->fInfo.setAAType(aaType);
op->fInfo.fShapeTypes = GetShapeFlag(type);
op->fInfo.fCannotDiscard = true;
- op->fDrawColorsAreOpaque = GrColorIsOpaque(color);
- op->fDrawColorsAreSame = true;
Instance& instance = op->getSingleInstance();
instance.fInfo = (int)type << kShapeType_InfoBit;
}
fProcessors.analyzeAndEliminateFragmentProcessors(&analysis, this->getSingleInstance().fColor,
coverageInput, clip, caps);
+ fAnalysisColor = analysis.outputColor();
+
Draw& draw = this->getSingleDraw(); // This will assert if we have > 1 command.
SkASSERT(draw.fGeometry.isEmpty());
SkASSERT(SkIsPow2(fInfo.fShapeTypes));
this->joinBounds(*that);
fInfo = combinedInfo;
fPixelLoad += that->fPixelLoad;
- fDrawColorsAreOpaque = fDrawColorsAreOpaque && that->fDrawColorsAreOpaque;
- fDrawColorsAreSame = fDrawColorsAreSame && that->fDrawColorsAreSame &&
- fHeadDraw->fInstance.fColor == that->fHeadDraw->fInstance.fColor;
+ fAnalysisColor = GrPipelineAnalysisColor::Combine(fAnalysisColor, that->fAnalysisColor);
// Adopt the other op's draws.
fNumDraws += that->fNumDraws;
fNumChangesInGeometry += that->fNumChangesInGeometry;
state->gpu()->handleDirtyContext();
- // TODO: Don't reanalyze the processors.
- GrProcessorSet::FragmentProcessorAnalysis analysis;
- GrPipelineAnalysisCoverage coverageInput;
+ const GrAppliedClip* clip = state->drawOpArgs().fAppliedClip;
+ GrPipelineAnalysisCoverage coverage;
if (GrAAType::kCoverage == fInfo.aaType() ||
+ (clip && clip->clipCoverageFragmentProcessor()) ||
(GrAAType::kNone == fInfo.aaType() && !fInfo.isSimpleRects() && fInfo.fCannotDiscard)) {
- coverageInput = GrPipelineAnalysisCoverage::kSingleChannel;
+ coverage = GrPipelineAnalysisCoverage::kSingleChannel;
} else {
- coverageInput = GrPipelineAnalysisCoverage::kNone;
+ coverage = GrPipelineAnalysisCoverage::kNone;
}
- GrPipelineAnalysisColor colorInput;
- if (fDrawColorsAreSame) {
- colorInput = fHeadDraw->fInstance.fColor;
- } else if (fDrawColorsAreOpaque) {
- colorInput = GrPipelineAnalysisColor::Opaque::kYes;
- }
- const GrAppliedClip* clip = state->drawOpArgs().fAppliedClip;
- analysis.init(colorInput, coverageInput, fProcessors, clip, state->caps());
GrPipeline pipeline;
GrPipeline::InitArgs args;
- args.fInputColor = analysis.outputColor();
- args.fInputCoverage = analysis.outputCoverage();
+ args.fInputColor = fAnalysisColor;
+ args.fInputCoverage = coverage;
args.fAppliedClip = clip;
args.fCaps = &state->caps();
args.fProcessors = &fProcessors;