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