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

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

Issue 498483002: Store vertex size in DrawState when setVertexAttribs is called (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 6 years, 4 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/GrDrawState.h ('k') | no next file » | 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 2012 Google Inc. 2 * Copyright 2012 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 "GrDrawState.h" 8 #include "GrDrawState.h"
9 #include "GrPaint.h" 9 #include "GrPaint.h"
10 #include "GrDrawTargetCaps.h" 10 #include "GrDrawTargetCaps.h"
(...skipping 10 matching lines...) Expand all
21 21
22 if (a.fRenderTarget.get() != b.fRenderTarget.get() || 22 if (a.fRenderTarget.get() != b.fRenderTarget.get() ||
23 a.fColorStages.count() != b.fColorStages.count() || 23 a.fColorStages.count() != b.fColorStages.count() ||
24 a.fCoverageStages.count() != b.fCoverageStages.count() || 24 a.fCoverageStages.count() != b.fCoverageStages.count() ||
25 !a.fViewMatrix.cheapEqualTo(b.fViewMatrix) || 25 !a.fViewMatrix.cheapEqualTo(b.fViewMatrix) ||
26 a.fSrcBlend != b.fSrcBlend || 26 a.fSrcBlend != b.fSrcBlend ||
27 a.fDstBlend != b.fDstBlend || 27 a.fDstBlend != b.fDstBlend ||
28 a.fBlendConstant != b.fBlendConstant || 28 a.fBlendConstant != b.fBlendConstant ||
29 a.fFlagBits != b.fFlagBits || 29 a.fFlagBits != b.fFlagBits ||
30 a.fVACount != b.fVACount || 30 a.fVACount != b.fVACount ||
31 a.fVertexSize != b.fVertexSize ||
bsalomon 2014/08/21 19:28:30 Do we need this? Or is this making the current cod
egdaniel 2014/08/21 21:30:30 It is not necessary for the current drawstate. Giv
31 memcmp(a.fVAPtr, b.fVAPtr, a.fVACount * sizeof(GrVertexAttrib)) || 32 memcmp(a.fVAPtr, b.fVAPtr, a.fVACount * sizeof(GrVertexAttrib)) ||
32 a.fStencilSettings != b.fStencilSettings || 33 a.fStencilSettings != b.fStencilSettings ||
33 a.fDrawFace != b.fDrawFace) { 34 a.fDrawFace != b.fDrawFace) {
34 return kIncompatible_CombinedState; 35 return kIncompatible_CombinedState;
35 } 36 }
36 37
37 bool usingVertexCoverage = a.hasCoverageVertexAttribute(); 38 bool usingVertexCoverage = a.hasCoverageVertexAttribute();
38 if (!usingVertexCoverage && a.fCoverage != b.fCoverage) { 39 if (!usingVertexCoverage && a.fCoverage != b.fCoverage) {
39 return kIncompatible_CombinedState; 40 return kIncompatible_CombinedState;
40 } 41 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); 106 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages());
106 this->setRenderTarget(that.fRenderTarget.get()); 107 this->setRenderTarget(that.fRenderTarget.get());
107 fColor = that.fColor; 108 fColor = that.fColor;
108 fViewMatrix = that.fViewMatrix; 109 fViewMatrix = that.fViewMatrix;
109 fSrcBlend = that.fSrcBlend; 110 fSrcBlend = that.fSrcBlend;
110 fDstBlend = that.fDstBlend; 111 fDstBlend = that.fDstBlend;
111 fBlendConstant = that.fBlendConstant; 112 fBlendConstant = that.fBlendConstant;
112 fFlagBits = that.fFlagBits; 113 fFlagBits = that.fFlagBits;
113 fVACount = that.fVACount; 114 fVACount = that.fVACount;
114 fVAPtr = that.fVAPtr; 115 fVAPtr = that.fVAPtr;
116 fVertexSize = that.fVertexSize;
115 fStencilSettings = that.fStencilSettings; 117 fStencilSettings = that.fStencilSettings;
116 fCoverage = that.fCoverage; 118 fCoverage = that.fCoverage;
117 fDrawFace = that.fDrawFace; 119 fDrawFace = that.fDrawFace;
118 fColorStages = that.fColorStages; 120 fColorStages = that.fColorStages;
119 fCoverageStages = that.fCoverageStages; 121 fCoverageStages = that.fCoverageStages;
120 fOptSrcBlend = that.fOptSrcBlend; 122 fOptSrcBlend = that.fOptSrcBlend;
121 fOptDstBlend = that.fOptDstBlend; 123 fOptDstBlend = that.fOptDstBlend;
122 fBlendOptFlags = that.fBlendOptFlags; 124 fBlendOptFlags = that.fBlendOptFlags;
123 125
124 fHints = that.fHints; 126 fHints = that.fHints;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 uint32_t mask = (1 << dwordCount)-1; 231 uint32_t mask = (1 << dwordCount)-1;
230 size_t offsetShift = attribs[index].fOffset >> 2; 232 size_t offsetShift = attribs[index].fOffset >> 2;
231 SkASSERT(!(overlapCheck & (mask << offsetShift))); 233 SkASSERT(!(overlapCheck & (mask << offsetShift)));
232 overlapCheck |= (mask << offsetShift); 234 overlapCheck |= (mask << offsetShift);
233 #endif 235 #endif
234 } 236 }
235 return size; 237 return size;
236 } 238 }
237 239
238 size_t GrDrawState::getVertexSize() const { 240 size_t GrDrawState::getVertexSize() const {
239 return vertex_size(fVAPtr, fVACount); 241 return fVertexSize;
240 } 242 }
241 243
242 //////////////////////////////////////////////////////////////////////////////// 244 ////////////////////////////////////////////////////////////////////////////////
243 245
244 void GrDrawState::setVertexAttribs(const GrVertexAttrib* attribs, int count) { 246 void GrDrawState::setVertexAttribs(const GrVertexAttrib* attribs, int count) {
245 SkASSERT(count <= kMaxVertexAttribCnt); 247 SkASSERT(count <= kMaxVertexAttribCnt);
246 248
247 fVAPtr = attribs; 249 fVAPtr = attribs;
248 fVACount = count; 250 fVACount = count;
251 fVertexSize = vertex_size(fVAPtr, fVACount);
249 252
250 // Set all the indices to -1 253 // Set all the indices to -1
251 memset(fFixedFunctionVertexAttribIndices, 254 memset(fFixedFunctionVertexAttribIndices,
252 0xff, 255 0xff,
253 sizeof(fFixedFunctionVertexAttribIndices)); 256 sizeof(fFixedFunctionVertexAttribIndices));
254 #ifdef SK_DEBUG 257 #ifdef SK_DEBUG
255 uint32_t overlapCheck = 0; 258 uint32_t overlapCheck = 0;
256 #endif 259 #endif
257 for (int i = 0; i < count; ++i) { 260 for (int i = 0; i < count; ++i) {
258 if (attribs[i].fBinding < kGrFixedFunctionVertexAttribBindingCnt) { 261 if (attribs[i].fBinding < kGrFixedFunctionVertexAttribBindingCnt) {
(...skipping 17 matching lines...) Expand all
276 } 279 }
277 280
278 //////////////////////////////////////////////////////////////////////////////// 281 ////////////////////////////////////////////////////////////////////////////////
279 282
280 void GrDrawState::setDefaultVertexAttribs() { 283 void GrDrawState::setDefaultVertexAttribs() {
281 static const GrVertexAttrib kPositionAttrib = 284 static const GrVertexAttrib kPositionAttrib =
282 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}; 285 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding};
283 286
284 fVAPtr = &kPositionAttrib; 287 fVAPtr = &kPositionAttrib;
285 fVACount = 1; 288 fVACount = 1;
289 fVertexSize = GrVertexAttribTypeSize(kVec2f_GrVertexAttribType);
286 290
287 // set all the fixed function indices to -1 except position. 291 // set all the fixed function indices to -1 except position.
288 memset(fFixedFunctionVertexAttribIndices, 292 memset(fFixedFunctionVertexAttribIndices,
289 0xff, 293 0xff,
290 sizeof(fFixedFunctionVertexAttribIndices)); 294 sizeof(fFixedFunctionVertexAttribIndices));
291 fFixedFunctionVertexAttribIndices[kPosition_GrVertexAttribBinding] = 0; 295 fFixedFunctionVertexAttribIndices[kPosition_GrVertexAttribBinding] = 0;
292 this->invalidateBlendOptFlags(); 296 this->invalidateBlendOptFlags();
293 } 297 }
294 298
295 //////////////////////////////////////////////////////////////////////////////// 299 ////////////////////////////////////////////////////////////////////////////////
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]); 703 fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]);
700 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix); 704 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix);
701 } 705 }
702 706
703 int numCoverageStages = fDrawState->numCoverageStages(); 707 int numCoverageStages = fDrawState->numCoverageStages();
704 for (int s = 0; s < numCoverageStages; ++s, ++i) { 708 for (int s = 0; s < numCoverageStages; ++s, ++i) {
705 fDrawState->getCoverageStage(s).saveCoordChange(&fSavedCoordChanges[i]); 709 fDrawState->getCoverageStage(s).saveCoordChange(&fSavedCoordChanges[i]);
706 fDrawState->fCoverageStages[s].localCoordChange(coordChangeMatrix); 710 fDrawState->fCoverageStages[s].localCoordChange(coordChangeMatrix);
707 } 711 }
708 } 712 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698