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

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

Issue 794843002: Revert of Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: Created 6 years 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
« no previous file with comments | « src/gpu/GrProcOptInfo.h ('k') | src/gpu/GrProcessor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "GrFragmentProcessor.h" 10 #include "GrFragmentProcessor.h"
11 #include "GrFragmentStage.h" 11 #include "GrFragmentStage.h"
12 #include "GrGeometryProcessor.h" 12 #include "GrGeometryProcessor.h"
13 13
14 void GrProcOptInfo::calcColorWithPrimProc(const GrPrimitiveProcessor* primProc,
15 const GrFragmentStage* stages,
16 int stageCount) {
17 GrInitInvariantOutput out;
18 primProc->getInvariantOutputColor(&out);
19 fInOut.reset(out);
20 this->internalCalc(stages, stageCount, primProc->willReadFragmentPosition()) ;
21 }
22
23 void GrProcOptInfo::calcCoverageWithPrimProc(const GrPrimitiveProcessor* primPro c,
24 const GrFragmentStage* stages,
25 int stageCount) {
26 GrInitInvariantOutput out;
27 primProc->getInvariantOutputCoverage(&out);
28 fInOut.reset(out);
29 this->internalCalc(stages, stageCount, primProc->willReadFragmentPosition()) ;
30 }
31
32 void GrProcOptInfo::calcWithInitialValues(const GrFragmentStage* stages, 14 void GrProcOptInfo::calcWithInitialValues(const GrFragmentStage* stages,
33 int stageCount, 15 int stageCount,
34 GrColor startColor, 16 GrColor startColor,
35 GrColorComponentFlags flags, 17 GrColorComponentFlags flags,
36 bool areCoverageStages) { 18 bool areCoverageStages,
37 GrInitInvariantOutput out; 19 const GrGeometryProcessor* gp) {
38 out.fIsSingleComponent = areCoverageStages; 20 fInOut.reset(startColor, flags, areCoverageStages);
39 out.fColor = startColor;
40 out.fValidFlags = flags;
41 this->internalCalc(stages, stageCount, false);
42 }
43
44 void GrProcOptInfo::internalCalc(const GrFragmentStage* stages,
45 int stageCount,
46 bool initWillReadFragmentPosition) {
47 fFirstEffectStageIndex = 0; 21 fFirstEffectStageIndex = 0;
48 fInputColorIsUsed = true; 22 fInputColorIsUsed = true;
49 fInputColor = fInOut.color(); 23 fInputColor = startColor;
50 fRemoveVertexAttrib = false; 24 fRemoveVertexAttrib = false;
51 fReadsDst = false; 25 fReadsDst = false;
52 fReadsFragPosition = initWillReadFragmentPosition; 26 fReadsFragPosition = false;
27
28 if (areCoverageStages && gp) {
29 gp->computeInvariantOutput(&fInOut);
30 }
53 31
54 for (int i = 0; i < stageCount; ++i) { 32 for (int i = 0; i < stageCount; ++i) {
55 const GrFragmentProcessor* processor = stages[i].getProcessor(); 33 const GrFragmentProcessor* processor = stages[i].getProcessor();
56 fInOut.resetWillUseInputColor(); 34 fInOut.resetWillUseInputColor();
57 processor->computeInvariantOutput(&fInOut); 35 processor->computeInvariantOutput(&fInOut);
58 SkDEBUGCODE(fInOut.validate()); 36 #ifdef SK_DEBUG
37 fInOut.validate();
38 #endif
59 if (!fInOut.willUseInputColor()) { 39 if (!fInOut.willUseInputColor()) {
60 fFirstEffectStageIndex = i; 40 fFirstEffectStageIndex = i;
61 fInputColorIsUsed = false; 41 fInputColorIsUsed = false;
62 // Reset these since we don't care if previous stages read these val ues 42 // Reset these since we don't care if previous stages read these val ues
63 fReadsDst = false; 43 fReadsDst = false;
64 fReadsFragPosition = initWillReadFragmentPosition; 44 fReadsFragPosition = false;
65 } 45 }
66 if (processor->willReadDstColor()) { 46 if (processor->willReadDstColor()) {
67 fReadsDst = true; 47 fReadsDst = true;
68 } 48 }
69 if (processor->willReadFragmentPosition()) { 49 if (processor->willReadFragmentPosition()) {
70 fReadsFragPosition = true; 50 fReadsFragPosition = true;
71 } 51 }
72 if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) { 52 if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) {
73 fFirstEffectStageIndex = i + 1; 53 fFirstEffectStageIndex = i + 1;
74 fInputColor = fInOut.color(); 54 fInputColor = fInOut.color();
75 fInputColorIsUsed = true; 55 fInputColorIsUsed = true;
76 fRemoveVertexAttrib = true; 56 fRemoveVertexAttrib = true;
77 // Since we are clearing all previous color stages we are in a state where we have found 57 // Since we are clearing all previous color stages we are in a state where we have found
78 // zero stages that don't multiply the inputColor. 58 // zero stages that don't multiply the inputColor.
79 fInOut.resetNonMulStageFound(); 59 fInOut.resetNonMulStageFound();
80 // Reset these since we don't care if previous stages read these val ues 60 // Reset these since we don't care if previous stages read these val ues
81 fReadsDst = false; 61 fReadsDst = false;
82 fReadsFragPosition = initWillReadFragmentPosition; 62 fReadsFragPosition = false;
83 } 63 }
84 } 64 }
85 } 65 }
66
OLDNEW
« no previous file with comments | « src/gpu/GrProcOptInfo.h ('k') | src/gpu/GrProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698