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

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

Issue 560443004: Revert of Attach GrOptDrawState into shader building pipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@opt2
Patch Set: Created 6 years, 3 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
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | src/gpu/GrRODrawState.h » ('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 "GrOptDrawState.h" 8 #include "GrOptDrawState.h"
9 9
10 #include "GrDrawState.h" 10 #include "GrDrawState.h"
11 11
12 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, 12 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState) : INHERITED(drawSta te) {
13 BlendOptFlags blendOptFlags,
14 GrBlendCoeff optSrcCoeff,
15 GrBlendCoeff optDstCoeff) : INHERITED(drawState) {
16 fColor = drawState.getColor(); 13 fColor = drawState.getColor();
17 fCoverage = drawState.getCoverage(); 14 fCoverage = drawState.getCoverage();
18 fViewMatrix = drawState.getViewMatrix(); 15 fViewMatrix = drawState.getViewMatrix();
19 fBlendConstant = drawState.getBlendConstant(); 16 fBlendConstant = drawState.getBlendConstant();
20 fFlagBits = drawState.getFlagBits(); 17 fFlagBits = drawState.getFlagBits();
21 fVAPtr = drawState.getVertexAttribs(); 18 fVAPtr = drawState.getVertexAttribs();
22 fVACount = drawState.getVertexAttribCount(); 19 fVACount = drawState.getVertexAttribCount();
23 fVAStride = drawState.getVertexStride(); 20 fVAStride = drawState.getVertexStride();
24 fStencilSettings = drawState.getStencil(); 21 fStencilSettings = drawState.getStencil();
25 fDrawFace = drawState.getDrawFace(); 22 fDrawFace = drawState.getDrawFace();
26 fBlendOptFlags = blendOptFlags; 23
27 fSrcBlend = optSrcCoeff; 24 fBlendOptFlags = drawState.getBlendOpts(false, &fSrcBlend, &fDstBlend);
28 fDstBlend = optDstCoeff;
29 25
30 memcpy(fFixedFunctionVertexAttribIndices, 26 memcpy(fFixedFunctionVertexAttribIndices,
31 drawState.getFixedFunctionVertexAttribIndices(), 27 drawState.getFixedFunctionVertexAttribIndices(),
32 sizeof(fFixedFunctionVertexAttribIndices)); 28 sizeof(fFixedFunctionVertexAttribIndices));
33 29
34
35 fInputColorIsUsed = true; 30 fInputColorIsUsed = true;
36 fInputCoverageIsUsed = true; 31 fInputCoverageIsUsed = true;
37 32
38 if (drawState.hasGeometryProcessor()) { 33 if (drawState.hasGeometryProcessor()) {
39 fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*drawState.getGeomet ryProcessor()))); 34 fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*drawState.getGeomet ryProcessor())));
40 } else { 35 } else {
41 fGeometryProcessor.reset(NULL); 36 fGeometryProcessor.reset(NULL);
42 } 37 }
43 38
44 this->copyEffectiveColorStages(drawState); 39 this->copyEffectiveColorStages(drawState);
45 this->copyEffectiveCoverageStages(drawState); 40 this->copyEffectiveCoverageStages(drawState);
46 this->adjustFromBlendOpts();
47 }; 41 };
48 42
49 void GrOptDrawState::adjustFromBlendOpts() {
50
51 switch (fBlendOptFlags) {
52 case kNone_BlendOpt:
53 case kSkipDraw_BlendOptFlag:
54 break;
55 case kCoverageAsAlpha_BlendOptFlag:
56 fFlagBits |= kCoverageDrawing_StateBit;
57 break;
58 case kEmitCoverage_BlendOptFlag:
59 fColor = 0xffffffff;
60 fInputColorIsUsed = true;
61 fColorStages.reset();
62 this->removeFixedFunctionVertexAttribs(0x1 << kColor_GrVertexAttribB inding);
63 break;
64 case kEmitTransBlack_BlendOptFlag:
65 fColor = 0;
66 fCoverage = 0xff;
67 fInputColorIsUsed = true;
68 fInputCoverageIsUsed = true;
69 fColorStages.reset();
70 fCoverageStages.reset();
71 this->removeFixedFunctionVertexAttribs(0x1 << kColor_GrVertexAttribB inding |
72 0x1 << kCoverage_GrVertexAttr ibBinding);
73 break;
74 default:
75 SkFAIL("Unknown BlendOptFlag");
76
77 }
78 }
79
80 void GrOptDrawState::removeFixedFunctionVertexAttribs(uint8_t removeVAFlag) { 43 void GrOptDrawState::removeFixedFunctionVertexAttribs(uint8_t removeVAFlag) {
81 int numToRemove = 0; 44 int numToRemove = 0;
82 uint8_t maskCheck = 0x1; 45 uint8_t maskCheck = 0x1;
83 // Count the number of vertex attributes that we will actually remove 46 // Count the number of vertex attributes that we will actually remove
84 for (int i = 0; i < kGrFixedFunctionVertexAttribBindingCnt; ++i) { 47 for (int i = 0; i < kGrFixedFunctionVertexAttribBindingCnt; ++i) {
85 if ((maskCheck & removeVAFlag) && -1 != fFixedFunctionVertexAttribIndice s[i]) { 48 if ((maskCheck & removeVAFlag) && -1 != fFixedFunctionVertexAttribIndice s[i]) {
86 ++numToRemove; 49 ++numToRemove;
87 } 50 }
88 maskCheck <<= 1; 51 maskCheck <<= 1;
89 } 52 }
90
91 fOptVA.reset(fVACount - numToRemove); 53 fOptVA.reset(fVACount - numToRemove);
92 54
93 GrVertexAttrib* dst = fOptVA.get(); 55 GrVertexAttrib* dst = fOptVA.get();
94 const GrVertexAttrib* src = fVAPtr; 56 const GrVertexAttrib* src = fVAPtr;
95 57
96 for (int i = 0, newIdx = 0; i < fVACount; ++i, ++src) { 58 for (int i = 0, newIdx = 0; i < fVACount; ++i, ++src) {
97 const GrVertexAttrib& currAttrib = *src; 59 const GrVertexAttrib& currAttrib = *src;
98 if (currAttrib.fBinding < kGrFixedFunctionVertexAttribBindingCnt) { 60 if (currAttrib.fBinding < kGrFixedFunctionVertexAttribBindingCnt) {
99 uint8_t maskCheck = 0x1 << currAttrib.fBinding; 61 uint8_t maskCheck = 0x1 << currAttrib.fBinding;
100 if (maskCheck & removeVAFlag) { 62 if (maskCheck & removeVAFlag) {
101 SkASSERT(-1 != fFixedFunctionVertexAttribIndices[currAttrib.fBin ding]); 63 SkASSERT(-1 != fFixedFunctionVertexAttribIndices[currAttrib.fBin ding]);
102 fFixedFunctionVertexAttribIndices[currAttrib.fBinding] = -1; 64 fFixedFunctionVertexAttribIndices[currAttrib.fBinding] = -1;
103 continue; 65 continue;
104 } 66 }
105 fFixedFunctionVertexAttribIndices[currAttrib.fBinding] = newIdx;
106 } 67 }
107 memcpy(dst, src, sizeof(GrVertexAttrib)); 68 memcpy(dst, src, sizeof(GrVertexAttrib));
69 fFixedFunctionVertexAttribIndices[currAttrib.fBinding] = newIdx;
108 ++newIdx; 70 ++newIdx;
109 ++dst; 71 ++dst;
110 } 72 }
111 fVACount -= numToRemove; 73 fVACount -= numToRemove;
112 fVAPtr = fOptVA.get(); 74 fVAPtr = fOptVA.get();
113 } 75 }
114 76
115 void GrOptDrawState::copyEffectiveColorStages(const GrDrawState& ds) { 77 void GrOptDrawState::copyEffectiveColorStages(const GrDrawState& ds) {
116 int firstColorStage = 0; 78 int firstColorStage = 0;
117 79
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 ds.numCoverageStages() - firstCoverageStage); 138 ds.numCoverageStages() - firstCoverageStage);
177 } else { 139 } else {
178 fCoverageStages.reset(); 140 fCoverageStages.reset();
179 } 141 }
180 } 142 }
181 143
182 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { 144 bool GrOptDrawState::operator== (const GrOptDrawState& that) const {
183 return this->isEqual(that); 145 return this->isEqual(that);
184 } 146 }
185 147
OLDNEW
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | src/gpu/GrRODrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698