aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrInOrderDrawBuffer.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-28 23:08:28 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-28 23:08:28 +0000
commitaf3a3b9fb1f3be46082013a2d1977d12faf1f61c (patch)
tree7fafb55c8e8b5043478d11e0f0e48fd2ef5c7007 /src/gpu/GrInOrderDrawBuffer.cpp
parent2b1b8c083b969a2a798b03d1754a3fc99ea054df (diff)
Revert r7901 & r7899 to allow DEPS roll
git-svn-id: http://skia.googlecode.com/svn/trunk@7909 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrInOrderDrawBuffer.cpp')
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp68
1 files changed, 25 insertions, 43 deletions
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index b2705a4b9b..00aaadbe98 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -78,20 +78,9 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
const SkMatrix* srcMatrix,
int stage) {
- GrAttribBindings bindings = GrDrawState::kDefault_AttribBindings;
+ GrVertexLayout layout = 0;
GrDrawState::AutoColorRestore acr;
-
- GrDrawState* drawState = this->drawState();
-
- GrColor color = drawState->getColor();
- GrVertexAttribArray<3> attribs;
- size_t currentOffset = 0;
- int colorOffset = -1, texOffset = -1;
-
- // set position attrib
- drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, attribs.count());
- attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, currentOffset));
- currentOffset += sizeof(GrPoint);
+ GrColor color = this->drawState()->getColor();
// Using per-vertex colors allows batching across colors. (A lot of rects in a row differing
// only in color is a common occurrence in tables). However, having per-vertex colors disables
@@ -100,31 +89,22 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
// dual-source blending isn't available. This comes into play when there is coverage. If colors
// were a stage it could take a hint that every vertex's color will be opaque.
if (this->getCaps().dualSourceBlendingSupport() ||
- drawState->hasSolidCoverage(drawState->getAttribBindings())) {
- bindings |= GrDrawState::kColor_AttribBindingsBit;
- drawState->setAttribIndex(GrDrawState::kColor_AttribIndex, attribs.count());
- attribs.push_back(GrVertexAttrib(kVec4ub_GrVertexAttribType, currentOffset));
- colorOffset = currentOffset;
- currentOffset += sizeof(GrColor);
+ this->getDrawState().hasSolidCoverage(this->getDrawState().getVertexLayout())) {
+ layout |= GrDrawState::kColor_VertexLayoutBit;;
// We set the draw state's color to white here. This is done so that any batching performed
// in our subclass's onDraw() won't get a false from GrDrawState::op== due to a color
// mismatch. TODO: Once vertex layout is owned by GrDrawState it should skip comparing the
// constant color in its op== when the kColor layout bit is set and then we can remove this.
- acr.set(drawState, 0xFFFFFFFF);
+ acr.set(this->drawState(), 0xFFFFFFFF);
}
uint32_t explicitCoordMask = 0;
if (NULL != srcRect) {
- bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(stage);
- drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, attribs.count());
- attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, currentOffset));
- texOffset = currentOffset;
- currentOffset += sizeof(GrPoint);
+ layout |= GrDrawState::StageTexCoordVertexLayoutBit(stage);
explicitCoordMask = (1 << stage);
}
- drawState->setVertexAttribs(attribs.begin(), attribs.count());
- drawState->setAttribBindings(bindings);
+ this->drawState()->setVertexLayout(layout);
AutoReleaseGeometry geo(this, 4, 0);
if (!geo.succeeded()) {
GrPrintf("Failed to get space for vertices!\n");
@@ -138,17 +118,18 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
} else {
combinedMatrix.reset();
}
- combinedMatrix.postConcat(drawState->getViewMatrix());
+ combinedMatrix.postConcat(this->drawState()->getViewMatrix());
// When the caller has provided an explicit source rect for a stage then we don't want to
// modify that stage's matrix. Otherwise if the effect is generating its source rect from
// the vertex positions then we have to account for the view matrix change.
- GrDrawState::AutoDeviceCoordDraw adcd(drawState, explicitCoordMask);
+ GrDrawState::AutoDeviceCoordDraw adcd(this->drawState(), explicitCoordMask);
if (!adcd.succeeded()) {
return;
}
- size_t vsize = drawState->getVertexSize();
- GrAssert(vsize == currentOffset);
+ int stageOffsets[GrDrawState::kNumStages], colorOffset;
+ int vsize = GrDrawState::VertexSizeAndOffsetsByStage(layout, stageOffsets,
+ &colorOffset, NULL, NULL);
geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vsize);
combinedMatrix.mapPointsWithStride(geo.positions(), vsize, 4);
@@ -158,15 +139,19 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
// unnecessary clipping in our onDraw().
get_vertex_bounds(geo.vertices(), vsize, 4, &devBounds);
- if (texOffset >= 0) {
- GrAssert(explicitCoordMask != 0);
- GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(geo.vertices()) +
- texOffset);
- coords->setRectFan(srcRect->fLeft, srcRect->fTop,
- srcRect->fRight, srcRect->fBottom,
- vsize);
- if (NULL != srcMatrix) {
- srcMatrix->mapPointsWithStride(coords, vsize, 4);
+ for (int i = 0; i < GrDrawState::kNumStages; ++i) {
+ if (explicitCoordMask & (1 << i)) {
+ GrAssert(0 != stageOffsets[i]);
+ GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(geo.vertices()) +
+ stageOffsets[i]);
+ coords->setRectFan(srcRect->fLeft, srcRect->fTop,
+ srcRect->fRight, srcRect->fBottom,
+ vsize);
+ if (NULL != srcMatrix) {
+ srcMatrix->mapPointsWithStride(coords, vsize, 4);
+ }
+ } else {
+ GrAssert(0 == stageOffsets[i]);
}
}
@@ -180,9 +165,6 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
this->setIndexSourceToBuffer(this->getContext()->getQuadIndexBuffer());
this->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds);
-
- // to ensure that stashing the drawState ptr is valid
- GrAssert(this->drawState() == drawState);
}
bool GrInOrderDrawBuffer::quickInsideClip(const SkRect& devBounds) {