Extend texture release on GrDrawState to also handle custom stages.
Add asserts to GrContext::setPaint() to make sure we're keeping things
cleaned up.
Remove double-call of setPaint() during text context initialization.
http://codereview.appspot.com/6324046/
git-svn-id: http://skia.googlecode.com/svn/trunk@4313 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index c426405..61f37ff 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -784,7 +784,7 @@
SK_TRACE_EVENT0("GrContext::drawRect");
GrDrawTarget* target = this->prepareToDraw(paint, kUnbuffered_DrawCategory);
- GrDrawState::AutoTextureRelease atr(fDrawState);
+ GrDrawState::AutoStageDisable atr(fDrawState);
int stageMask = paint.getActiveStageMask();
GrRect devRect = rect;
@@ -904,7 +904,7 @@
#if GR_STATIC_RECT_VB
GrDrawTarget* target = this->prepareToDraw(paint, kUnbuffered_DrawCategory);
- GrDrawState::AutoTextureRelease atr(fDrawState);
+ GrDrawState::AutoStageDisable atr(fDrawState);
GrDrawState* drawState = target->drawState();
GrVertexLayout layout = PaintStageVertexLayoutBits(paint, NULL);
GrDrawState::AutoViewMatrixRestore avmr(drawState);
@@ -949,7 +949,7 @@
#else
target = this->prepareToDraw(paint, kUnbuffered_DrawCategory);
#endif
- GrDrawState::AutoTextureRelease atr(fDrawState);
+ GrDrawState::AutoStageDisable atr(fDrawState);
const GrRect* srcRects[GrDrawState::kNumStages] = {NULL};
const GrMatrix* srcMatrices[GrDrawState::kNumStages] = {NULL};
@@ -973,7 +973,7 @@
GrDrawTarget::AutoReleaseGeometry geo;
GrDrawTarget* target = this->prepareToDraw(paint, kUnbuffered_DrawCategory);
- GrDrawState::AutoTextureRelease atr(fDrawState);
+ GrDrawState::AutoStageDisable atr(fDrawState);
bool hasTexCoords[GrPaint::kTotalStages] = {
NULL != texCoords, // texCoordSrc provides explicit stage 0 coords
@@ -1078,7 +1078,7 @@
DrawCategory category = (DEFER_PATHS) ? kBuffered_DrawCategory :
kUnbuffered_DrawCategory;
GrDrawTarget* target = this->prepareToDraw(paint, category);
- GrDrawState::AutoTextureRelease atr(fDrawState);
+ GrDrawState::AutoStageDisable atr(fDrawState);
GrDrawState* drawState = target->drawState();
GrMatrix vm = drawState->getViewMatrix();
@@ -1187,7 +1187,7 @@
DrawCategory category = (DEFER_PATHS) ? kBuffered_DrawCategory :
kUnbuffered_DrawCategory;
GrDrawTarget* target = this->prepareToDraw(paint, category);
- GrDrawState::AutoTextureRelease atr(fDrawState);
+ GrDrawState::AutoStageDisable atr(fDrawState);
GrDrawState::StageMask stageMask = paint.getActiveStageMask();
bool prAA = paint.fAntiAlias && !this->getRenderTarget()->isMultisampled();
@@ -1588,6 +1588,7 @@
////////////////////////////////////////////////////////////////////////////////
void GrContext::setPaint(const GrPaint& paint) {
+ GrAssert(fDrawState->stagesDisabled());
for (int i = 0; i < GrPaint::kMaxTextures; ++i) {
int s = i + GrPaint::kFirstTextureStage;