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 | |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 8 | #include "GrProcessorAnalysis.h" |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 9 | #include "GrGeometryProcessor.h" |
Brian Salomon | 8952743 | 2016-12-16 09:52:16 -0500 | [diff] [blame] | 10 | #include "ops/GrDrawOp.h" |
joshualitt | 7441782 | 2015-08-07 11:42:16 -0700 | [diff] [blame] | 11 | |
Brian Salomon | c0b642c | 2017-03-27 13:09:36 -0400 | [diff] [blame] | 12 | void GrColorFragmentProcessorAnalysis::analyzeProcessors( |
| 13 | const GrFragmentProcessor* const* processors, int cnt) { |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 14 | for (int i = 0; i < cnt; ++i) { |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 15 | bool knowCurrentOutput = fProcessorsVisitedWithKnownOutput == fTotalProcessorsVisited; |
Brian Salomon | bfafcba | 2017-03-02 08:49:19 -0500 | [diff] [blame] | 16 | if (fUsesLocalCoords && !knowCurrentOutput && |
| 17 | !fAllProcessorsCompatibleWithCoverageAsAlpha && !fIsOpaque) { |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 18 | fTotalProcessorsVisited += cnt - i; |
| 19 | return; |
egdaniel | b6cbc38 | 2014-11-13 11:00:34 -0800 | [diff] [blame] | 20 | } |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 21 | const GrFragmentProcessor* fp = processors[i]; |
Brian Salomon | c0b642c | 2017-03-27 13:09:36 -0400 | [diff] [blame] | 22 | if (knowCurrentOutput && |
| 23 | fp->hasConstantOutputForConstantInput(fLastKnownOutputColor, &fLastKnownOutputColor)) { |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 24 | ++fProcessorsVisitedWithKnownOutput; |
| 25 | fIsOpaque = fLastKnownOutputColor.isOpaque(); |
Brian Salomon | bfafcba | 2017-03-02 08:49:19 -0500 | [diff] [blame] | 26 | // We reset these since the caller is expected to not use the earlier fragment |
| 27 | // processors. |
| 28 | fAllProcessorsCompatibleWithCoverageAsAlpha = true; |
| 29 | fUsesLocalCoords = false; |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 30 | } else if (fIsOpaque && !fp->preservesOpaqueInput()) { |
| 31 | fIsOpaque = false; |
| 32 | } |
Brian Salomon | f3b995b | 2017-02-15 10:22:23 -0500 | [diff] [blame] | 33 | if (fAllProcessorsCompatibleWithCoverageAsAlpha && !fp->compatibleWithCoverageAsAlpha()) { |
| 34 | fAllProcessorsCompatibleWithCoverageAsAlpha = false; |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 35 | } |
Brian Salomon | bfafcba | 2017-03-02 08:49:19 -0500 | [diff] [blame] | 36 | if (fp->usesLocalCoords()) { |
| 37 | fUsesLocalCoords = true; |
| 38 | } |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 39 | ++fTotalProcessorsVisited; |
egdaniel | b6cbc38 | 2014-11-13 11:00:34 -0800 | [diff] [blame] | 40 | } |
| 41 | } |