/src/skia/src/gpu/ganesh/GrProcessorAnalysis.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
13 | | GrColorFragmentProcessorAnalysis::GrColorFragmentProcessorAnalysis( |
14 | | const GrProcessorAnalysisColor& input, |
15 | | std::unique_ptr<GrFragmentProcessor> const fps[], |
16 | 133k | int count) { |
17 | 133k | fCompatibleWithCoverageAsAlpha = true; |
18 | 133k | fIsOpaque = input.isOpaque(); |
19 | 133k | fUsesLocalCoords = false; |
20 | 133k | fWillReadDstColor = false; |
21 | 133k | fProcessorsToEliminate = 0; |
22 | 133k | fOutputColorKnown = input.isConstant(&fLastKnownOutputColor); |
23 | 226k | for (int i = 0; i < count; ++i) { |
24 | 93.1k | const GrFragmentProcessor* fp = fps[i].get(); |
25 | 93.1k | if (fOutputColorKnown && fp->hasConstantOutputForConstantInput(fLastKnownOutputColor, |
26 | 89.8k | &fLastKnownOutputColor)) { |
27 | 5 | ++fProcessorsToEliminate; |
28 | 5 | fIsOpaque = fLastKnownOutputColor.isOpaque(); |
29 | | // We reset these flags since the earlier fragment processors are being eliminated. |
30 | 5 | fCompatibleWithCoverageAsAlpha = true; |
31 | 5 | fUsesLocalCoords = false; |
32 | 5 | fWillReadDstColor = false; |
33 | 5 | continue; |
34 | 5 | } |
35 | | |
36 | 93.0k | fOutputColorKnown = false; |
37 | 93.0k | if (fIsOpaque && !fp->preservesOpaqueInput()) { |
38 | 76.3k | fIsOpaque = false; |
39 | 76.3k | } |
40 | 93.0k | if (fCompatibleWithCoverageAsAlpha && !fp->compatibleWithCoverageAsAlpha()) { |
41 | 41.1k | fCompatibleWithCoverageAsAlpha = false; |
42 | 41.1k | } |
43 | 93.0k | if (fp->usesSampleCoords()) { |
44 | 89.6k | fUsesLocalCoords = true; |
45 | 89.6k | } |
46 | 93.0k | if (fp->willReadDstColor()) { |
47 | 0 | fWillReadDstColor = true; |
48 | 0 | } |
49 | 93.0k | } |
50 | 133k | } |
51 | | |
52 | 115k | bool GrColorFragmentProcessorAnalysis::requiresDstTexture(const GrCaps& caps) const { |
53 | 115k | return this->willReadDstColor() && !caps.shaderCaps()->fDstReadInShaderSupport; |
54 | 115k | } |