diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 0a3ab422b6..213731935d 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -769,13 +769,12 @@ void GrContext::setupOffscreenAAPass1(GrDrawTarget* target, GrRenderTarget* offRT = record->fOffscreen.texture()->asRenderTarget(); GrAssert(NULL != offRT); - GrDrawState* drawState = target->drawState(); GrMatrix vm = drawState->getViewMatrix(); drawState->reset(); *drawState->viewMatrix() = vm; drawState->setRenderTarget(offRT); - + #if PREFER_MSAA_OFFSCREEN_AA drawState->enableState(GrDrawState::kHWAntialias_StateBit); #endif @@ -796,6 +795,8 @@ void GrContext::setupOffscreenAAPass1(GrDrawTarget* target, GrIRect clear = SkIRect::MakeWH(record->fScale * w, record->fScale * h); target->setClip(GrClip(clear)); + drawState->enableState(GrDrawState::kClip_StateBit); + #if 0 // visualize tile boundaries by setting edges of offscreen to white // and interior to tranparent. black. diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h index c736f1e3df..18dd6bf406 100644 --- a/src/gpu/GrDrawState.h +++ b/src/gpu/GrDrawState.h @@ -49,7 +49,11 @@ struct GrDrawState { GrDrawState() { this->reset(); } - + + GrDrawState(const GrDrawState& state) { + *this = state; + } + /** * Resets to the default state. Sampler states will not be modified. */ diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index fa266d1cef..d68aa3957d 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -512,11 +512,11 @@ const GrClip& GrDrawTarget::getClip() const { } void GrDrawTarget::saveCurrentDrawState(SavedDrawState* state) const { - state->fState = fCurrDrawState; + state->fState.set(fCurrDrawState); } void GrDrawTarget::restoreDrawState(const SavedDrawState& state) { - fCurrDrawState = state.fState; + fCurrDrawState = *state.fState.get(); } void GrDrawTarget::copyDrawState(const GrDrawTarget& srcTarget) { diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 5fc420d416..6962a18859 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -21,6 +21,7 @@ #include "GrTexture.h" #include "SkXfermode.h" +#include "SkTLazy.h" class GrTexture; class GrClipIterator; @@ -139,7 +140,7 @@ public: */ struct SavedDrawState { private: - GrDrawState fState; + SkTLazy fState; friend class GrDrawTarget; }; @@ -926,10 +927,12 @@ protected: // Helpers for GrDrawTarget subclasses that won't have private access to // SavedDrawState but need to peek at the state values. - static GrDrawState& accessSavedDrawState(SavedDrawState& sds) - { return sds.fState; } - static const GrDrawState& accessSavedDrawState(const SavedDrawState& sds) - { return sds.fState; } + static GrDrawState& accessSavedDrawState(SavedDrawState& sds) { + return *sds.fState.get(); + } + static const GrDrawState& accessSavedDrawState(const SavedDrawState& sds){ + return *sds.fState.get(); + } // implemented by subclass to allocate space for reserved geom virtual bool onReserveVertexSpace(GrVertexLayout vertexLayout,