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

Unified Diff: src/gpu/GrDrawState.cpp

Issue 12462008: Add GrEllipseEdgeEffect (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: rebase again 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawState.cpp
===================================================================
--- src/gpu/GrDrawState.cpp (revision 8091)
+++ src/gpu/GrDrawState.cpp (working copy)
@@ -133,6 +133,85 @@
////////////////////////////////////////////////////////////////////////////////
+bool GrDrawState::validateVertexAttribs() const {
+ // color and coverage can set indices beyond the standard count
+ static const int kMaxValidAttribIndex = kVertexAttribCnt+2;
+ int attributeTypes[kMaxValidAttribIndex];
+ for (int i = 0; i < kMaxValidAttribIndex; ++i) {
+ attributeTypes[i] = -1;
+ }
+
+ // sentinel to make sure effects don't try to use built-in attributes
+ static const int kBuiltInAttributeType = 10000;
+
+ // check our built-in indices
+ if (fAttribIndices[kPosition_AttribIndex] >= kVertexAttribCnt) {
+ return false;
+ }
+ attributeTypes[fAttribIndices[kPosition_AttribIndex]] = kBuiltInAttributeType;
+ for (int j = kColor_AttribIndex; j <= kCoverage_AttribIndex; ++j) {
+ if (fCommon.fAttribBindings & kAttribIndexMasks[j]) {
+ int attributeIndex = fAttribIndices[j];
+ if (attributeIndex >= kMaxValidAttribIndex) {
+ return false;
+ }
+ // they should not be shared at all
+ if (attributeTypes[attributeIndex] != -1) {
+ return false;
+ }
+ attributeTypes[attributeIndex] = kBuiltInAttributeType;
+ }
+ }
+ for (int j = kEdge_AttribIndex; j < kAttribIndexCount; ++j) {
+ if (fCommon.fAttribBindings & kAttribIndexMasks[j]) {
+ int attributeIndex = fAttribIndices[j];
+ if (attributeIndex >= kVertexAttribCnt) {
+ return false;
+ }
+ // they should not be shared at all
+ if (attributeTypes[attributeIndex] != -1) {
+ return false;
+ }
+ attributeTypes[attributeIndex] = kBuiltInAttributeType;
+ }
+ }
+
+ // now those set by effects
+ for (int s = 0; s < kNumStages; ++s) {
+ const GrEffectStage& stage = fStages[s];
+ const GrEffectRef* effect = stage.getEffect();
+ if (effect == NULL) {
+ continue;
+ }
+
+ // make sure that the count in the stage and the effect matches
+ int numAttributes = stage.getVertexAttribIndexCount();
+ if (numAttributes != effect->get()->numVertexAttribs()) {
+ return false;
+ }
+
+ // make sure that any shared indices have the same type
+ const int* attributeIndices = stage.getVertexAttribIndices();
+ for (int i = 0; i < numAttributes; ++i) {
+ int attributeIndex = attributeIndices[i];
+ if (attributeIndex >= kVertexAttribCnt) {
+ return false;
+ }
+
+ GrSLType attributeType = effect->get()->vertexAttribType(i);
+ if (attributeTypes[attributeIndex] != -1 &&
+ attributeTypes[attributeIndex] != attributeType) {
+ return false;
+ }
+ attributeTypes[attributeIndex] = attributeType;
+ }
+ }
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
bool GrDrawState::AttributesBindExplicitTexCoords(GrAttribBindings attribBindings) {
return SkToBool(kTexCoord_AttribBindingsMask & attribBindings);
}
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698