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

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

Issue 12379052: Remove constructors from GrVertexAttrib (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
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 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 GrAssert(count <= GrDrawState::kAttribIndexCount); 115 GrAssert(count <= GrDrawState::kAttribIndexCount);
116 fVertexAttribs.reset(); 116 fVertexAttribs.reset();
117 for (int index = 0; index < count; ++index) { 117 for (int index = 0; index < count; ++index) {
118 fVertexAttribs.push_back(attribs[index]); 118 fVertexAttribs.push_back(attribs[index]);
119 } 119 }
120 } 120 }
121 121
122 //////////////////////////////////////////////////////////////////////////////// 122 ////////////////////////////////////////////////////////////////////////////////
123 123
124 void GrDrawState::setDefaultVertexAttribs() { 124 void GrDrawState::setDefaultVertexAttribs() {
125 static const GrVertexAttrib kPositionAttrib = {kVec2f_GrVertexAttribType, 0} ;
125 fVertexAttribs.reset(); 126 fVertexAttribs.reset();
126 fVertexAttribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, 0)); 127 fVertexAttribs.push_back(kPositionAttrib);
127 128
128 fCommon.fAttribBindings = kDefault_AttribBindings; 129 fCommon.fAttribBindings = kDefault_AttribBindings;
129 130
130 fAttribIndices[kPosition_AttribIndex] = 0; 131 fAttribIndices[kPosition_AttribIndex] = 0;
131 } 132 }
132 133
133 //////////////////////////////////////////////////////////////////////////////// 134 ////////////////////////////////////////////////////////////////////////////////
134 135
135 bool GrDrawState::AttributesBindExplicitTexCoords(GrAttribBindings attribBinding s) { 136 bool GrDrawState::AttributesBindExplicitTexCoords(GrAttribBindings attribBinding s) {
136 return SkToBool(kTexCoord_AttribBindingsMask & attribBindings); 137 return SkToBool(kTexCoord_AttribBindingsMask & attribBindings);
137 } 138 }
138 139
139 //////////////////////////////////////////////////////////////////////////////// 140 ////////////////////////////////////////////////////////////////////////////////
140 141
141 void GrDrawState::VertexAttributesUnitTest() { 142 void GrDrawState::VertexAttributesUnitTest() {
142 // Ensure that our tex coord mask is correct 143 // Ensure that our tex coord mask is correct
143 GrAttribBindings texCoordMask; 144 GrAttribBindings texCoordMask;
144 gen_tex_coord_mask(&texCoordMask); 145 gen_tex_coord_mask(&texCoordMask);
145 GrAssert(texCoordMask == kTexCoord_AttribBindingsMask); 146 GrAssert(texCoordMask == kTexCoord_AttribBindingsMask);
146 147
147 // not necessarily exhaustive 148 // not necessarily exhaustive
148 static bool run; 149 static bool run;
149 if (!run) { 150 if (!run) {
150 run = true; 151 run = true;
151 152
152 GrVertexAttribArray<6> attribs; 153 GrVertexAttribArray<6> attribs;
153 GrAssert(0 == vertex_size(attribs.begin(), attribs.count())); 154 GrAssert(0 == vertex_size(attribs.begin(), attribs.count()));
154 155
155 attribs.push_back(GrVertexAttrib(kFloat_GrVertexAttribType, 0)); 156 GrVertexAttrib currAttrib = {kFloat_GrVertexAttribType, 0};
157 attribs.push_back(currAttrib);
156 GrAssert(sizeof(float) == vertex_size(attribs.begin(), attribs.count())) ; 158 GrAssert(sizeof(float) == vertex_size(attribs.begin(), attribs.count())) ;
157 attribs[0].fType = kVec2f_GrVertexAttribType; 159 attribs[0].fType = kVec2f_GrVertexAttribType;
158 GrAssert(2*sizeof(float) == vertex_size(attribs.begin(), attribs.count() )); 160 GrAssert(2*sizeof(float) == vertex_size(attribs.begin(), attribs.count() ));
159 attribs[0].fType = kVec3f_GrVertexAttribType; 161 attribs[0].fType = kVec3f_GrVertexAttribType;
160 GrAssert(3*sizeof(float) == vertex_size(attribs.begin(), attribs.count() )); 162 GrAssert(3*sizeof(float) == vertex_size(attribs.begin(), attribs.count() ));
161 attribs[0].fType = kVec4f_GrVertexAttribType; 163 attribs[0].fType = kVec4f_GrVertexAttribType;
162 GrAssert(4*sizeof(float) == vertex_size(attribs.begin(), attribs.count() )); 164 GrAssert(4*sizeof(float) == vertex_size(attribs.begin(), attribs.count() ));
163 attribs[0].fType = kVec4ub_GrVertexAttribType; 165 attribs[0].fType = kVec4ub_GrVertexAttribType;
164 GrAssert(4*sizeof(char) == vertex_size(attribs.begin(), attribs.count()) ); 166 GrAssert(4*sizeof(char) == vertex_size(attribs.begin(), attribs.count()) );
165 167
166 attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, attribs[0].f Offset + 4*sizeof(char))); 168 currAttrib.set(kVec2f_GrVertexAttribType, attribs[0].fOffset + 4*sizeof( char));
169 attribs.push_back(currAttrib);
167 GrAssert(4*sizeof(char) + 2*sizeof(float) == vertex_size(attribs.begin() , attribs.count())); 170 GrAssert(4*sizeof(char) + 2*sizeof(float) == vertex_size(attribs.begin() , attribs.count()));
168 attribs.push_back(GrVertexAttrib(kVec3f_GrVertexAttribType, attribs[1].f Offset + 2*sizeof(float))); 171 currAttrib.set(kVec3f_GrVertexAttribType, attribs[1].fOffset + 2*sizeof( float));
172 attribs.push_back(currAttrib);
169 GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) == 173 GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) ==
170 vertex_size(attribs.begin(), attribs.count())); 174 vertex_size(attribs.begin(), attribs.count()));
171 attribs.push_back(GrVertexAttrib(kFloat_GrVertexAttribType, attribs[2].f Offset + 3*sizeof(float))); 175 currAttrib.set(kFloat_GrVertexAttribType, attribs[2].fOffset + 3*sizeof( float));
176 attribs.push_back(currAttrib);
172 GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) + sizeof(flo at) == 177 GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) + sizeof(flo at) ==
173 vertex_size(attribs.begin(), attribs.count())); 178 vertex_size(attribs.begin(), attribs.count()));
174 attribs.push_back(GrVertexAttrib(kVec4f_GrVertexAttribType, attribs[3].f Offset + sizeof(float))); 179 currAttrib.set(kVec4f_GrVertexAttribType, attribs[3].fOffset + sizeof(fl oat));
180 attribs.push_back(currAttrib);
175 GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) + sizeof(flo at) + 4*sizeof(float) == 181 GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) + sizeof(flo at) + 4*sizeof(float) ==
176 vertex_size(attribs.begin(), attribs.count())); 182 vertex_size(attribs.begin(), attribs.count()));
177 183
178 GrAttribBindings tcMask = 0; 184 GrAttribBindings tcMask = 0;
179 GrAssert(!AttributesBindExplicitTexCoords(0)); 185 GrAssert(!AttributesBindExplicitTexCoords(0));
180 for (int s = 0; s < GrDrawState::kNumStages; ++s) { 186 for (int s = 0; s < GrDrawState::kNumStages; ++s) {
181 tcMask |= ExplicitTexCoordAttribBindingsBit(s); 187 tcMask |= ExplicitTexCoordAttribBindingsBit(s);
182 GrAssert(AttributesBindExplicitTexCoords(tcMask)); 188 GrAssert(AttributesBindExplicitTexCoords(tcMask));
183 GrAssert(StageBindsExplicitTexCoords(tcMask, s)); 189 GrAssert(StageBindsExplicitTexCoords(tcMask, s));
184 for (int s2 = s + 1; s2 < GrDrawState::kNumStages; ++s2) { 190 for (int s2 = s + 1; s2 < GrDrawState::kNumStages; ++s2) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 } 483 }
478 fRestoreMask |= (1 << s); 484 fRestoreMask |= (1 << s);
479 GrEffectStage* stage = drawState->fStages + s; 485 GrEffectStage* stage = drawState->fStages + s;
480 stage->saveCoordChange(&fSavedCoordChanges[s]); 486 stage->saveCoordChange(&fSavedCoordChanges[s]);
481 stage->preConcatCoordChange(invVM); 487 stage->preConcatCoordChange(invVM);
482 } 488 }
483 } 489 }
484 drawState->viewMatrix()->reset(); 490 drawState->viewMatrix()->reset();
485 return true; 491 return true;
486 } 492 }
OLDNEW
« src/gpu/GrContext.cpp ('K') | « src/gpu/GrDrawState.h ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698