• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "src/gpu/ganesh/GrCaps.h"
9 #include "src/gpu/ganesh/GrFragmentProcessor.h"
10 #include "src/gpu/ganesh/GrGeometryProcessor.h"
11 #include "src/gpu/ganesh/GrProcessorAnalysis.h"
12 
GrColorFragmentProcessorAnalysis(const GrProcessorAnalysisColor & input,std::unique_ptr<GrFragmentProcessor> const fps[],int count)13 GrColorFragmentProcessorAnalysis::GrColorFragmentProcessorAnalysis(
14         const GrProcessorAnalysisColor& input,
15         std::unique_ptr<GrFragmentProcessor> const fps[],
16         int count) {
17     fCompatibleWithCoverageAsAlpha = true;
18     fIsOpaque = input.isOpaque();
19     fUsesLocalCoords = false;
20     fWillReadDstColor = false;
21     fProcessorsToEliminate = 0;
22     fOutputColorKnown = input.isConstant(&fLastKnownOutputColor);
23     for (int i = 0; i < count; ++i) {
24         const GrFragmentProcessor* fp = fps[i].get();
25         if (fOutputColorKnown && fp->hasConstantOutputForConstantInput(fLastKnownOutputColor,
26                                                                        &fLastKnownOutputColor)) {
27             ++fProcessorsToEliminate;
28             fIsOpaque = fLastKnownOutputColor.isOpaque();
29             // We reset these flags since the earlier fragment processors are being eliminated.
30             fCompatibleWithCoverageAsAlpha = true;
31             fUsesLocalCoords = false;
32             fWillReadDstColor = false;
33             continue;
34         }
35 
36         fOutputColorKnown = false;
37         if (fIsOpaque && !fp->preservesOpaqueInput()) {
38             fIsOpaque = false;
39         }
40         if (fCompatibleWithCoverageAsAlpha && !fp->compatibleWithCoverageAsAlpha()) {
41             fCompatibleWithCoverageAsAlpha = false;
42         }
43         if (fp->usesSampleCoords()) {
44             fUsesLocalCoords = true;
45         }
46         if (fp->willReadDstColor()) {
47             fWillReadDstColor = true;
48         }
49     }
50 }
51 
requiresDstTexture(const GrCaps & caps) const52 bool GrColorFragmentProcessorAnalysis::requiresDstTexture(const GrCaps& caps) const {
53     return this->willReadDstColor() && !caps.shaderCaps()->fDstReadInShaderSupport;
54 }
55