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

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: Add size assert 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 return kIncompatible_CombinedState; 46 return kIncompatible_CombinedState;
47 } 47 }
48 } 48 }
49 for (int i = 0; i < a.numCoverageStages(); i++) { 49 for (int i = 0; i < a.numCoverageStages(); i++) {
50 if (!GrEffectStage::AreCompatible(a.getCoverageStage(i), b.getCoverageSt age(i), 50 if (!GrEffectStage::AreCompatible(a.getCoverageStage(i), b.getCoverageSt age(i),
51 explicitLocalCoords)) { 51 explicitLocalCoords)) {
52 return kIncompatible_CombinedState; 52 return kIncompatible_CombinedState;
53 } 53 }
54 } 54 }
55 55
56 SkASSERT(a.fVertexSize == b.fVertexSize);
56 SkASSERT(0 == memcmp(a.fFixedFunctionVertexAttribIndices, 57 SkASSERT(0 == memcmp(a.fFixedFunctionVertexAttribIndices,
57 b.fFixedFunctionVertexAttribIndices, 58 b.fFixedFunctionVertexAttribIndices,
58 sizeof(a.fFixedFunctionVertexAttribIndices))); 59 sizeof(a.fFixedFunctionVertexAttribIndices)));
59 60
60 if (usingVertexColors) { 61 if (usingVertexColors) {
61 // If one is opaque and the other is not then the combined state is not opaque. Moreover, 62 // If one is opaque and the other is not then the combined state is not opaque. Moreover,
62 // if the opaqueness affects the ability to get color/coverage blending correct then we 63 // if the opaqueness affects the ability to get color/coverage blending correct then we
63 // don't combine the draw states. 64 // don't combine the draw states.
64 bool aIsOpaque = (kVertexColorsAreOpaque_Hint & a.fHints); 65 bool aIsOpaque = (kVertexColorsAreOpaque_Hint & a.fHints);
65 bool bIsOpaque = (kVertexColorsAreOpaque_Hint & b.fHints); 66 bool bIsOpaque = (kVertexColorsAreOpaque_Hint & b.fHints);
(...skipping 39 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