aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-13 18:49:30 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-13 18:49:30 +0000
commit972265db219ce25b5159879c75e6c62efaf0fa79 (patch)
tree7e6315d9224f44c3a7df0f5cf941c4e4583cb69c /src
parentfedd09ba7e218116df8a676069726de6e9d35277 (diff)
releaseTextures portion of GrDrawState Ref textures CL (http://codereview.appspot.com/6251049/)
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrContext.cpp10
-rw-r--r--src/gpu/GrDefaultTextContext.cpp1
-rw-r--r--src/gpu/GrDrawState.h21
3 files changed, 31 insertions, 1 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 2e5bd7fccf..3cc2c89bfb 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -744,6 +744,7 @@ void GrContext::drawRect(const GrPaint& paint,
SK_TRACE_EVENT0("GrContext::drawRect");
GrDrawTarget* target = this->prepareToDraw(paint, kUnbuffered_DrawCategory);
+ GrDrawState::AutoTextureRelease atr(fDrawState);
int stageMask = paint.getActiveStageMask();
GrRect devRect = rect;
@@ -863,6 +864,7 @@ void GrContext::drawRectToRect(const GrPaint& paint,
#if GR_STATIC_RECT_VB
GrDrawTarget* target = this->prepareToDraw(paint, kUnbuffered_DrawCategory);
+ GrDrawState::AutoTextureRelease atr(fDrawState);
GrDrawState* drawState = target->drawState();
GrVertexLayout layout = PaintStageVertexLayoutBits(paint, NULL);
GrDrawState::AutoViewMatrixRestore avmr(drawState);
@@ -907,6 +909,7 @@ void GrContext::drawRectToRect(const GrPaint& paint,
#else
target = this->prepareToDraw(paint, kUnbuffered_DrawCategory);
#endif
+ GrDrawState::AutoTextureRelease atr(fDrawState);
const GrRect* srcRects[GrDrawState::kNumStages] = {NULL};
const GrMatrix* srcMatrices[GrDrawState::kNumStages] = {NULL};
@@ -930,6 +933,7 @@ void GrContext::drawVertices(const GrPaint& paint,
GrDrawTarget::AutoReleaseGeometry geo;
GrDrawTarget* target = this->prepareToDraw(paint, kUnbuffered_DrawCategory);
+ GrDrawState::AutoTextureRelease atr(fDrawState);
bool hasTexCoords[GrPaint::kTotalStages] = {
NULL != texCoords, // texCoordSrc provides explicit stage 0 coords
@@ -1034,6 +1038,7 @@ void GrContext::drawOval(const GrPaint& paint,
DrawCategory category = (DEFER_PATHS) ? kBuffered_DrawCategory :
kUnbuffered_DrawCategory;
GrDrawTarget* target = this->prepareToDraw(paint, category);
+ GrDrawState::AutoTextureRelease atr(fDrawState);
GrDrawState* drawState = target->drawState();
GrMatrix vm = drawState->getViewMatrix();
@@ -1139,6 +1144,7 @@ void GrContext::internalDrawPath(const GrPaint& paint, const SkPath& path,
DrawCategory category = (DEFER_PATHS) ? kBuffered_DrawCategory :
kUnbuffered_DrawCategory;
GrDrawTarget* target = this->prepareToDraw(paint, category);
+ GrDrawState::AutoTextureRelease atr(fDrawState);
GrDrawState::StageMask stageMask = paint.getActiveStageMask();
bool prAA = paint.fAntiAlias && !this->getRenderTarget()->isMultisampled();
@@ -1813,7 +1819,9 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture,
srcRect = dstRect;
SkTSwap(srcTexture, dstTexture);
// If temp2 is non-NULL, don't render back to origTexture
- if (temp2 && dstTexture == origTexture) dstTexture = temp2->texture();
+ if (temp2 && dstTexture == origTexture) {
+ dstTexture = temp2->texture();
+ }
}
SkIRect srcIRect;
diff --git a/src/gpu/GrDefaultTextContext.cpp b/src/gpu/GrDefaultTextContext.cpp
index d3d4e523a0..21cb99087e 100644
--- a/src/gpu/GrDefaultTextContext.cpp
+++ b/src/gpu/GrDefaultTextContext.cpp
@@ -61,6 +61,7 @@ void GrDefaultTextContext::flushGlyphs() {
4, 6);
fVertices = NULL;
this->INHERITED::reset();
+ drawState->setTexture(kGlyphMaskStage, NULL);
}
}
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 55bd04c87e..e77b63ad81 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -205,6 +205,27 @@ public:
return fTextures[stage];
}
+ /**
+ * Release all the textures referred to by this draw state
+ */
+ void releaseTextures() {
+ for (int i = 0; i < kNumStages; ++i) {
+ this->setTexture(i, NULL);
+ }
+ }
+
+ class AutoTextureRelease : public ::GrNoncopyable {
+ public:
+ AutoTextureRelease(GrDrawState* ds) : fDrawState(ds) {}
+ ~AutoTextureRelease() {
+ if (NULL != fDrawState) {
+ fDrawState->releaseTextures();
+ }
+ }
+ private:
+ GrDrawState* fDrawState;
+ };
+
/// @}
///////////////////////////////////////////////////////////////////////////