Bug 602757. Part 1: Create gfxContextAutoDisableSubpixelAntialiasing helper. r=vlad,a=blocking
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 03 Jan 2011 14:48:09 +1300
changeset 59777 5b0756d80fe89399a80bcff2260bbf3bac45355a
parent 59776 58aa602af75c43a9887d5ef949b12876a5fac30d
child 59778 841881532933099ede2d76bcf7b11daeca160c9c
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersvlad, blocking
bugs602757
milestone2.0b9pre
Bug 602757. Part 1: Create gfxContextAutoDisableSubpixelAntialiasing helper. r=vlad,a=blocking
gfx/thebes/gfxContext.h
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -786,9 +786,32 @@ public:
         return mMatrix;
     }
 
 private:
     gfxContext *mContext;
     gfxMatrix   mMatrix;
 };
 
+
+class THEBES_API gfxContextAutoDisableSubpixelAntialiasing {
+public:
+    gfxContextAutoDisableSubpixelAntialiasing(gfxContext *aContext, PRBool aDisable)
+    {
+        if (aDisable) {
+            mSurface = aContext->CurrentSurface();
+            mSubpixelAntialiasingEnabled = mSurface->GetSubpixelAntialiasingEnabled();
+            mSurface->SetSubpixelAntialiasingEnabled(PR_FALSE);
+        }
+    }
+    ~gfxContextAutoDisableSubpixelAntialiasing()
+    {
+        if (mSurface) {
+            mSurface->SetSubpixelAntialiasingEnabled(mSubpixelAntialiasingEnabled);
+        }
+    }
+
+private:
+    nsRefPtr<gfxASurface> mSurface;
+    PRPackedBool mSubpixelAntialiasingEnabled;
+};
+
 #endif /* GFX_CONTEXT_H */