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 analyzeProcessors(const GrFragmentProcessor * const * processors,int cnt)12void GrColorFragmentProcessorAnalysis::analyzeProcessors( 13 const GrFragmentProcessor* const* processors, int cnt) { 14 for (int i = 0; i < cnt; ++i) { 15 bool knowCurrentOutput = fProcessorsVisitedWithKnownOutput == fTotalProcessorsVisited; 16 if (fUsesLocalCoords && !knowCurrentOutput && 17 !fAllProcessorsCompatibleWithCoverageAsAlpha && !fIsOpaque) { 18 fTotalProcessorsVisited += cnt - i; 19 return; 20 } 21 const GrFragmentProcessor* fp = processors[i]; 22 if (knowCurrentOutput && 23 fp->hasConstantOutputForConstantInput(fLastKnownOutputColor, &fLastKnownOutputColor)) { 24 ++fProcessorsVisitedWithKnownOutput; 25 fIsOpaque = fLastKnownOutputColor.isOpaque(); 26 // We reset these since the caller is expected to not use the earlier fragment 27 // processors. 28 fAllProcessorsCompatibleWithCoverageAsAlpha = true; 29 fUsesLocalCoords = false; 30 } else { 31 if (fIsOpaque && !fp->preservesOpaqueInput()) { 32 fIsOpaque = false; 33 } 34 if (fAllProcessorsCompatibleWithCoverageAsAlpha && 35 !fp->compatibleWithCoverageAsAlpha()) { 36 fAllProcessorsCompatibleWithCoverageAsAlpha = false; 37 } 38 if (fp->usesLocalCoords()) { 39 fUsesLocalCoords = true; 40 } 41 } 42 ++fTotalProcessorsVisited; 43 } 44 } 45