diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-23 11:44:08 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-23 11:44:08 +0000 |
commit | 49d9fd5fdb9ffd48538c8fc5a2f6f2d43a2e4fe9 (patch) | |
tree | d9ac469c4bc3a933872276d3047d67b616efb507 /src/gpu | |
parent | af46cff4ee6099cebf3aa395805748af7d193a31 (diff) |
Plumbing to propagate save & restore from SkCanvas down to GrContext & lower
http://codereview.appspot.com/6203067/
git-svn-id: http://skia.googlecode.com/svn/trunk@4034 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrClipMaskManager.h | 11 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 8 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.h | 5 | ||||
-rw-r--r-- | src/gpu/GrGpu.h | 7 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.cpp | 8 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.h | 2 |
7 files changed, 35 insertions, 9 deletions
diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h index aa2c0880a5..e4c9fb5dc7 100644 --- a/src/gpu/GrClipMaskManager.h +++ b/src/gpu/GrClipMaskManager.h @@ -300,6 +300,17 @@ public: fClipMaskInStencil = false; } + void postClipPush() { + // TODO: make sure that, if the clip stack is unaltered, the + // prior clip mask is reused (i.e., a push w/ no change to the + // clip stack) + fAACache.push(); + } + + void preClipPop() { + fAACache.pop(); + } + void setContext(GrContext* context) { fAACache.setContext(context); } diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index bd6d829095..b45970bdad 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -2216,4 +2216,12 @@ GrTexture* GrContext::applyMorphology(GrTexture* srcTexture, return srcTexture; } +void GrContext::postClipPush() { + fGpu->postClipPush(); +} + +void GrContext::preClipPop() { + fGpu->preClipPop(); +}; + /////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 715799c95f..35d50e9e77 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -1103,9 +1103,6 @@ GrVertexLayout GrDrawTarget::GetRectVertexLayout(StageMask stageMask, return layout; } -void GrDrawTarget::clipWillBeSet(const GrClip& clip) { -} - void GrDrawTarget::SetRectVertices(const GrRect& rect, const GrMatrix* matrix, const GrRect* srcRects[], diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index bf6e41bb2e..a6ab6755d0 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -190,6 +190,9 @@ public: return 1 << (stage + (texCoordIdx * GrDrawState::kNumStages)); } + virtual void postClipPush() {}; + virtual void preClipPop() {}; + private: static const int TEX_COORD_BIT_CNT = GrDrawState::kNumStages * GrDrawState::kMaxTexCoords; @@ -1041,7 +1044,7 @@ protected: int vertexCount) = 0; // subclass overrides to be notified when clip is set. Must call // INHERITED::clipwillBeSet - virtual void clipWillBeSet(const GrClip& clip); + virtual void clipWillBeSet(const GrClip& clip) {} // Helpers for drawRect, protected so subclasses that override drawRect // can use them. diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index ba73f7da06..500673bd30 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -365,6 +365,13 @@ public: // clipping. }; + virtual void postClipPush() SK_OVERRIDE { + fClipMaskManager.postClipPush(); + } + virtual void preClipPop() SK_OVERRIDE { + fClipMaskManager.preClipPop(); + } + protected: // prepares clip flushes gpu state before a draw bool setupClipAndFlushState(GrPrimitiveType type); diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 553bacca59..7b3b04f75b 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -223,7 +223,7 @@ void GrInOrderDrawBuffer::drawIndexedInstances(GrPrimitiveType type, bool clipChanged = this->needsNewClip(); bool stateChanged = this->needsNewState(); if (clipChanged) { - this->pushClip(); + this->storeClip(); } if (stateChanged) { this->pushState(); @@ -342,7 +342,7 @@ void GrInOrderDrawBuffer::onDrawIndexed(GrPrimitiveType primitiveType, draw.fClipChanged = this->needsNewClip(); if (draw.fClipChanged) { - this->pushClip(); + this->storeClip(); } draw.fStateChanged = this->needsNewState(); @@ -409,7 +409,7 @@ void GrInOrderDrawBuffer::onDrawNonIndexed(GrPrimitiveType primitiveType, draw.fClipChanged = this->needsNewClip(); if (draw.fClipChanged) { - this->pushClip(); + this->storeClip(); } draw.fStateChanged = this->needsNewState(); @@ -801,7 +801,7 @@ bool GrInOrderDrawBuffer::needsNewClip() const { return false; } -void GrInOrderDrawBuffer::pushClip() { +void GrInOrderDrawBuffer::storeClip() { fClips.push_back() = fClip; fClipSet = false; } diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h index 3b27d70f3d..fa3e0a2613 100644 --- a/src/gpu/GrInOrderDrawBuffer.h +++ b/src/gpu/GrInOrderDrawBuffer.h @@ -167,7 +167,7 @@ private: bool needsNewClip() const; void pushState(); - void pushClip(); + void storeClip(); // call this to invalidate the tracking data that is used to concatenate // multiple draws into a single draw. |