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

Side by Side Diff: src/gpu/GrInOrderDrawBuffer.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "GrInOrderDrawBuffer.h" 10 #include "GrInOrderDrawBuffer.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 GrDrawState* drawState = this->drawState(); 84 GrDrawState* drawState = this->drawState();
85 85
86 GrColor color = drawState->getColor(); 86 GrColor color = drawState->getColor();
87 GrVertexAttribArray<3> attribs; 87 GrVertexAttribArray<3> attribs;
88 size_t currentOffset = 0; 88 size_t currentOffset = 0;
89 int colorOffset = -1, texOffset = -1; 89 int colorOffset = -1, texOffset = -1;
90 90
91 // set position attrib 91 // set position attrib
92 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, attribs.count( )); 92 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, attribs.count( ));
93 attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, currentOffset)); 93 GrVertexAttrib currAttrib = {kVec2f_GrVertexAttribType, currentOffset};
94 attribs.push_back(currAttrib);
94 currentOffset += sizeof(GrPoint); 95 currentOffset += sizeof(GrPoint);
95 96
96 // Using per-vertex colors allows batching across colors. (A lot of rects in a row differing 97 // Using per-vertex colors allows batching across colors. (A lot of rects in a row differing
97 // only in color is a common occurrence in tables). However, having per-vert ex colors disables 98 // only in color is a common occurrence in tables). However, having per-vert ex colors disables
98 // blending optimizations because we don't know if the color will be solid o r not. These 99 // blending optimizations because we don't know if the color will be solid o r not. These
99 // optimizations help determine whether coverage and color can be blended co rrectly when 100 // optimizations help determine whether coverage and color can be blended co rrectly when
100 // dual-source blending isn't available. This comes into play when there is coverage. If colors 101 // dual-source blending isn't available. This comes into play when there is coverage. If colors
101 // were a stage it could take a hint that every vertex's color will be opaqu e. 102 // were a stage it could take a hint that every vertex's color will be opaqu e.
102 if (this->getCaps().dualSourceBlendingSupport() || 103 if (this->getCaps().dualSourceBlendingSupport() ||
103 drawState->hasSolidCoverage(drawState->getAttribBindings())) { 104 drawState->hasSolidCoverage(drawState->getAttribBindings())) {
104 bindings |= GrDrawState::kColor_AttribBindingsBit; 105 bindings |= GrDrawState::kColor_AttribBindingsBit;
105 drawState->setAttribIndex(GrDrawState::kColor_AttribIndex, attribs.count ()); 106 drawState->setAttribIndex(GrDrawState::kColor_AttribIndex, attribs.count ());
106 attribs.push_back(GrVertexAttrib(kVec4ub_GrVertexAttribType, currentOffs et)); 107 currAttrib.set(kVec4ub_GrVertexAttribType, currentOffset);
108 attribs.push_back(currAttrib);
107 colorOffset = currentOffset; 109 colorOffset = currentOffset;
108 currentOffset += sizeof(GrColor); 110 currentOffset += sizeof(GrColor);
109 // We set the draw state's color to white here. This is done so that any batching performed 111 // We set the draw state's color to white here. This is done so that any batching performed
110 // in our subclass's onDraw() won't get a false from GrDrawState::op== d ue to a color 112 // in our subclass's onDraw() won't get a false from GrDrawState::op== d ue to a color
111 // mismatch. TODO: Once vertex layout is owned by GrDrawState it should skip comparing the 113 // mismatch. TODO: Once vertex layout is owned by GrDrawState it should skip comparing the
112 // constant color in its op== when the kColor layout bit is set and then we can remove this. 114 // constant color in its op== when the kColor layout bit is set and then we can remove this.
113 acr.set(drawState, 0xFFFFFFFF); 115 acr.set(drawState, 0xFFFFFFFF);
114 } 116 }
115 117
116 uint32_t explicitCoordMask = 0; 118 uint32_t explicitCoordMask = 0;
117 if (NULL != srcRect) { 119 if (NULL != srcRect) {
118 bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(stage); 120 bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(stage);
119 drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, attribs.co unt()); 121 drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, attribs.co unt());
120 attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, currentOffse t)); 122 currAttrib.set(kVec2f_GrVertexAttribType, currentOffset);
123 attribs.push_back(currAttrib);
121 texOffset = currentOffset; 124 texOffset = currentOffset;
122 currentOffset += sizeof(GrPoint); 125 currentOffset += sizeof(GrPoint);
123 explicitCoordMask = (1 << stage); 126 explicitCoordMask = (1 << stage);
124 } 127 }
125 128
126 drawState->setVertexAttribs(attribs.begin(), attribs.count()); 129 drawState->setVertexAttribs(attribs.begin(), attribs.count());
127 drawState->setAttribBindings(bindings); 130 drawState->setAttribBindings(bindings);
128 AutoReleaseGeometry geo(this, 4, 0); 131 AutoReleaseGeometry geo(this, 4, 0);
129 if (!geo.succeeded()) { 132 if (!geo.succeeded()) {
130 GrPrintf("Failed to get space for vertices!\n"); 133 GrPrintf("Failed to get space for vertices!\n");
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 GrInOrderDrawBuffer::Clear* GrInOrderDrawBuffer::recordClear() { 763 GrInOrderDrawBuffer::Clear* GrInOrderDrawBuffer::recordClear() {
761 fCmds.push_back(kClear_Cmd); 764 fCmds.push_back(kClear_Cmd);
762 return &fClears.push_back(); 765 return &fClears.push_back();
763 } 766 }
764 767
765 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { 768 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) {
766 INHERITED::clipWillBeSet(newClipData); 769 INHERITED::clipWillBeSet(newClipData);
767 fClipSet = true; 770 fClipSet = true;
768 fClipProxyState = kUnknown_ClipProxyState; 771 fClipProxyState = kUnknown_ClipProxyState;
769 } 772 }
OLDNEW
« src/gpu/GrContext.cpp ('K') | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698