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

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

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