Index: src/gpu/SkGr.cpp |
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp |
index 78df53e38ae7c3a3b706b21773c6b448052cbc12..6f6bf71a603582fb382740293ff578db8a1736c9 100644 |
--- a/src/gpu/SkGr.cpp |
+++ b/src/gpu/SkGr.cpp |
@@ -378,6 +378,20 @@ void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, bool ju |
} |
} |
robertphillips
2014/05/20 14:36:16
Should this be in GrContext like the other two?
|
+class AutoMatrix { |
+public: |
+ AutoMatrix(GrContext* context) { |
+ fMatrix = context->getMatrix(); |
+ fContext = context; |
+ } |
+ ~AutoMatrix() { |
robertphillips
2014/05/20 14:36:16
Don't we usually have a "if (NULL != fContext)" gu
|
+ fContext->setMatrix(fMatrix); |
+ } |
+private: |
+ GrContext* fContext; |
+ SkMatrix fMatrix; |
+}; |
+ |
void SkPaint2GrPaintShader(GrContext* context, const SkPaint& skPaint, |
bool constantColor, GrPaint* grPaint) { |
SkShader* shader = skPaint.getShader(); |
@@ -386,9 +400,12 @@ void SkPaint2GrPaintShader(GrContext* context, const SkPaint& skPaint, |
return; |
} |
- // SkShader::asNewEffect() may do offscreen rendering. Setup default drawing state and require |
- // the shader to set a render target. |
- GrContext::AutoWideOpenIdentityDraw awo(context, NULL); |
+ // SkShader::asNewEffect() may do offscreen rendering. Save off the current RT, clip, and |
+ // matrix. We don't reset the matrix on the context because SkShader::asNewEffect may use |
+ // GrContext::getMatrix() to know the transformation from local coords to device space. |
+ GrContext::AutoRenderTarget art(context, NULL); |
+ GrContext::AutoClip ac(context, GrContext::AutoClip::kWideOpen_InitialClip); |
+ AutoMatrix am(context); |
// setup the shader as the first color effect on the paint |
SkAutoTUnref<GrEffectRef> effect(shader->asNewEffect(context, skPaint, NULL)); |