egdaniel | b6cbc38 | 2014-11-13 11:00:34 -0800 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/gpu/GrGeometryProcessor.h" |
| 9 | #include "src/gpu/GrProcessorAnalysis.h" |
| 10 | #include "src/gpu/ops/GrDrawOp.h" |
joshualitt | 7441782 | 2015-08-07 11:42:16 -0700 | [diff] [blame] | 11 | |
Brian Salomon | 650ced0 | 2017-07-20 16:46:46 -0400 | [diff] [blame] | 12 | GrColorFragmentProcessorAnalysis::GrColorFragmentProcessorAnalysis( |
| 13 | const GrProcessorAnalysisColor& input, |
Brian Salomon | 64f4206 | 2020-02-14 10:42:45 -0500 | [diff] [blame] | 14 | std::unique_ptr<GrFragmentProcessor> const fps[], |
John Stiles | 053eb1b | 2021-06-03 12:19:39 -0400 | [diff] [blame] | 15 | int count) { |
Brian Salomon | 650ced0 | 2017-07-20 16:46:46 -0400 | [diff] [blame] | 16 | fCompatibleWithCoverageAsAlpha = true; |
| 17 | fIsOpaque = input.isOpaque(); |
| 18 | fUsesLocalCoords = false; |
| 19 | fProcessorsToEliminate = 0; |
John Stiles | 053eb1b | 2021-06-03 12:19:39 -0400 | [diff] [blame] | 20 | fOutputColorKnown = input.isConstant(&fLastKnownOutputColor); |
| 21 | for (int i = 0; i < count; ++i) { |
| 22 | const GrFragmentProcessor* fp = fps[i].get(); |
| 23 | if (fOutputColorKnown && fp->hasConstantOutputForConstantInput(fLastKnownOutputColor, |
| 24 | &fLastKnownOutputColor)) { |
Brian Salomon | 650ced0 | 2017-07-20 16:46:46 -0400 | [diff] [blame] | 25 | ++fProcessorsToEliminate; |
Brian Osman | f28e55d | 2018-10-03 16:35:54 -0400 | [diff] [blame] | 26 | fIsOpaque = fLastKnownOutputColor.isOpaque(); |
John Stiles | 053eb1b | 2021-06-03 12:19:39 -0400 | [diff] [blame] | 27 | // We reset these flags since the earlier fragment processors are being eliminated. |
Brian Salomon | 650ced0 | 2017-07-20 16:46:46 -0400 | [diff] [blame] | 28 | fCompatibleWithCoverageAsAlpha = true; |
Brian Salomon | bfafcba | 2017-03-02 08:49:19 -0500 | [diff] [blame] | 29 | fUsesLocalCoords = false; |
John Stiles | 053eb1b | 2021-06-03 12:19:39 -0400 | [diff] [blame] | 30 | continue; |
| 31 | } |
| 32 | |
| 33 | fOutputColorKnown = false; |
| 34 | if (fIsOpaque && !fp->preservesOpaqueInput()) { |
| 35 | fIsOpaque = false; |
| 36 | } |
| 37 | if (fCompatibleWithCoverageAsAlpha && !fp->compatibleWithCoverageAsAlpha()) { |
| 38 | fCompatibleWithCoverageAsAlpha = false; |
| 39 | } |
| 40 | if (fp->usesVaryingCoords()) { |
| 41 | fUsesLocalCoords = true; |
Brian Salomon | bfafcba | 2017-03-02 08:49:19 -0500 | [diff] [blame] | 42 | } |
egdaniel | b6cbc38 | 2014-11-13 11:00:34 -0800 | [diff] [blame] | 43 | } |
| 44 | } |