Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: src/gpu/GrProcOptInfo.cpp

Issue 1734163002: Replace fWillReadFragmentPosition with a bitfield (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrProcOptInfo.h" 8 #include "GrProcOptInfo.h"
9 9
10 #include "GrGeometryProcessor.h" 10 #include "GrGeometryProcessor.h"
11 11
12 #include "batches/GrDrawBatch.h" 12 #include "batches/GrDrawBatch.h"
13 13
14 void GrProcOptInfo::calcWithInitialValues(const GrFragmentProcessor * const proc essors[], 14 void GrProcOptInfo::calcWithInitialValues(const GrFragmentProcessor * const proc essors[],
15 int cnt, 15 int cnt,
16 GrColor startColor, 16 GrColor startColor,
17 GrColorComponentFlags flags, 17 GrColorComponentFlags flags,
18 bool areCoverageStages, 18 bool areCoverageStages,
19 bool isLCD) { 19 bool isLCD) {
20 GrInitInvariantOutput out; 20 GrInitInvariantOutput out;
21 out.fIsSingleComponent = areCoverageStages; 21 out.fIsSingleComponent = areCoverageStages;
22 out.fColor = startColor; 22 out.fColor = startColor;
23 out.fValidFlags = flags; 23 out.fValidFlags = flags;
24 out.fIsLCDCoverage = isLCD; 24 out.fIsLCDCoverage = isLCD;
25 fInOut.reset(out); 25 fInOut.reset(out);
26 this->internalCalc(processors, cnt, false); 26 this->internalCalc(processors, cnt);
27 } 27 }
28 28
29 void GrProcOptInfo::initUsingInvariantOutput(GrInitInvariantOutput invOutput) { 29 void GrProcOptInfo::initUsingInvariantOutput(GrInitInvariantOutput invOutput) {
30 fInOut.reset(invOutput); 30 fInOut.reset(invOutput);
31 } 31 }
32 32
33 void GrProcOptInfo::completeCalculations(const GrFragmentProcessor * const proce ssors[], int cnt) { 33 void GrProcOptInfo::completeCalculations(const GrFragmentProcessor * const proce ssors[], int cnt) {
34 this->internalCalc(processors, cnt, false); 34 this->internalCalc(processors, cnt);
35 } 35 }
36 36
37 void GrProcOptInfo::internalCalc(const GrFragmentProcessor* const processors[], 37 void GrProcOptInfo::internalCalc(const GrFragmentProcessor* const processors[], int cnt) {
38 int cnt,
39 bool initWillReadFragmentPosition) {
40 fFirstEffectiveProcessorIndex = 0; 38 fFirstEffectiveProcessorIndex = 0;
41 fInputColorIsUsed = true; 39 fInputColorIsUsed = true;
42 fInputColor = fInOut.color(); 40 fInputColor = fInOut.color();
43 fReadsFragPosition = initWillReadFragmentPosition; 41 fBuiltInState = GrProcessor::kNone_BuiltInState;
44 42
45 for (int i = 0; i < cnt; ++i) { 43 for (int i = 0; i < cnt; ++i) {
46 const GrFragmentProcessor* processor = processors[i]; 44 const GrFragmentProcessor* processor = processors[i];
47 fInOut.resetWillUseInputColor(); 45 fInOut.resetWillUseInputColor();
48 processor->computeInvariantOutput(&fInOut); 46 processor->computeInvariantOutput(&fInOut);
49 SkDEBUGCODE(fInOut.validate()); 47 SkDEBUGCODE(fInOut.validate());
50 if (!fInOut.willUseInputColor()) { 48 if (!fInOut.willUseInputColor()) {
51 fFirstEffectiveProcessorIndex = i; 49 fFirstEffectiveProcessorIndex = i;
52 fInputColorIsUsed = false; 50 fInputColorIsUsed = false;
53 // Reset these since we don't care if previous stages read these val ues 51 // Reset these since we will be removing any previous stages that re ad these values.
54 fReadsFragPosition = initWillReadFragmentPosition; 52 fBuiltInState = GrProcessor::kNone_BuiltInState;
55 } 53 }
56 if (processor->willReadFragmentPosition()) { 54 fBuiltInState |= processor->builtInState();
57 fReadsFragPosition = true;
58 }
59 if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) { 55 if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) {
60 fFirstEffectiveProcessorIndex = i + 1; 56 fFirstEffectiveProcessorIndex = i + 1;
61 fInputColor = fInOut.color(); 57 fInputColor = fInOut.color();
62 fInputColorIsUsed = true; 58 fInputColorIsUsed = true;
63 // Since we are clearing all previous color stages we are in a state where we have found 59 // Since we are clearing all previous color stages we are in a state where we have found
64 // zero stages that don't multiply the inputColor. 60 // zero stages that don't multiply the inputColor.
65 fInOut.resetNonMulStageFound(); 61 fInOut.resetNonMulStageFound();
66 // Reset these since we don't care if previous stages read these val ues 62 // Reset these since we will be removing all processors.
67 fReadsFragPosition = initWillReadFragmentPosition; 63 fBuiltInState = GrProcessor::kNone_BuiltInState;
Chris Dalton 2016/02/25 19:19:03 FYI, this is bad news for a processor that modifie
joshualitt 2016/02/25 20:50:27 Yea, we don't actually remove processors from the
bsalomon 2016/02/25 21:11:03 Yeah, querying willModifySampleMask could be the i
68 } 64 }
69 } 65 }
70 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698