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