Turn clipping back on in OSAA pass 1. Skip default cons on GrDrawState when saving off a GrDrawTarget's state.
Review URL: http://codereview.appspot.com/5553051/
git-svn-id: http://skia.googlecode.com/svn/trunk@3067 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 0a3ab42..2137319 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -769,13 +769,12 @@
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 @@
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 c736f1e..18dd6bf 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -49,7 +49,11 @@
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 fa266d1..d68aa39 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -512,11 +512,11 @@
}
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 5fc420d..6962a18 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 @@
*/
struct SavedDrawState {
private:
- GrDrawState fState;
+ SkTLazy<GrDrawState> fState;
friend class GrDrawTarget;
};
@@ -926,10 +927,12 @@
// 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,