1 /* 2 * Copyright 2014 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "GrProcessorAnalysis.h" 9 #include "GrGeometryProcessor.h" 10 #include "ops/GrDrawOp.h" 11 12 GrColorFragmentProcessorAnalysis::GrColorFragmentProcessorAnalysis( 13 const GrProcessorAnalysisColor& input, 14 const GrFragmentProcessor* const* processors, 15 int cnt) { 16 fCompatibleWithCoverageAsAlpha = true; 17 fIsOpaque = input.isOpaque(); 18 fUsesLocalCoords = false; 19 fProcessorsToEliminate = 0; 20 fKnowOutputColor = input.isConstant(&fLastKnownOutputColor); 21 for (int i = 0; i < cnt; ++i) { 22 if (fUsesLocalCoords && !fKnowOutputColor && !fCompatibleWithCoverageAsAlpha && 23 !fIsOpaque) { 24 break; 25 } 26 const GrFragmentProcessor* fp = processors[i]; 27 if (fKnowOutputColor && 28 fp->hasConstantOutputForConstantInput(fLastKnownOutputColor, &fLastKnownOutputColor)) { 29 ++fProcessorsToEliminate; 30 fIsOpaque = fLastKnownOutputColor.isOpaque(); 31 // We reset these since the caller is expected to not use the earlier fragment 32 // processors. 33 fCompatibleWithCoverageAsAlpha = true; 34 fUsesLocalCoords = false; 35 } else { 36 fKnowOutputColor = false; 37 if (fIsOpaque && !fp->preservesOpaqueInput()) { 38 fIsOpaque = false; 39 } 40 if (fCompatibleWithCoverageAsAlpha && !fp->compatibleWithCoverageAsAlpha()) { 41 fCompatibleWithCoverageAsAlpha = false; 42 } 43 if (fp->usesLocalCoords()) { 44 fUsesLocalCoords = true; 45 } 46 } 47 } 48 } 49