Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Unified Diff: src/gpu/SkGr.cpp

Issue 298713002: Preserve GrContext's matrix when calling SkShader::asNewEffect. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Add comment and assert Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGr.cpp
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 78df53e38ae7c3a3b706b21773c6b448052cbc12..6bd04dec3a841ac8186b8644ab212aca6512fba8 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -378,6 +378,26 @@ void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, bool ju
}
}
+/**
+ * Unlike GrContext::AutoMatrix, this doesn't require setting a new matrix. GrContext::AutoMatrix
+ * likes to set the new matrix in its constructor because it is usually necessary to simulataneously
+ * update a GrPaint. This AutoMatrix is used while initially setting up GrPaint, however.
+ */
+class AutoMatrix {
+public:
+ AutoMatrix(GrContext* context) {
+ fMatrix = context->getMatrix();
+ fContext = context;
+ }
+ ~AutoMatrix() {
+ SkASSERT(NULL != fContext);
+ 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 +406,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));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698