aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-01-18 19:51:55 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-01-18 19:51:55 +0000
commit46f7afb9867200b568c21736da8a8bbb56b20e30 (patch)
tree76eb71f275e70dae61dfc4ae07041771572e9ae7
parentb90113dd3de76eef48679f74a9134dcb73d32a7c (diff)
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
-rw-r--r--src/gpu/GrContext.cpp5
-rw-r--r--src/gpu/GrDrawState.h6
-rw-r--r--src/gpu/GrDrawTarget.cpp4
-rw-r--r--src/gpu/GrDrawTarget.h13
4 files changed, 18 insertions, 10 deletions
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<GrDrawState> 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,