Bug 926023 - Use the value of SetPermitSubpixelAA for DrawTargetCairo. r=Bas, a=bajaj
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 05 Nov 2013 17:50:56 +1300
changeset 167511 5ec49fda7a689769e2188d547a8b410b8687e55a
parent 167510 00232fdf3afb690a44a8be65108b9d5b22388203
child 167512 7b9f04910402e59331e2757adb77ef5e2802d77d
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, bajaj
bugs926023
milestone27.0a2
Bug 926023 - Use the value of SetPermitSubpixelAA for DrawTargetCairo. r=Bas, a=bajaj
gfx/2d/2D.h
gfx/2d/DrawTargetCairo.cpp
gfx/2d/DrawTargetCairo.h
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -887,17 +887,17 @@ public:
   void SetOpaqueRect(const IntRect &aRect) {
     mOpaqueRect = aRect;
   }
 
   const IntRect &GetOpaqueRect() const {
     return mOpaqueRect;
   }
 
-  void SetPermitSubpixelAA(bool aPermitSubpixelAA) {
+  virtual void SetPermitSubpixelAA(bool aPermitSubpixelAA) {
     mPermitSubpixelAA = aPermitSubpixelAA;
   }
 
   bool GetPermitSubpixelAA() {
     return mPermitSubpixelAA;
   }
 
   virtual GenericRefCountedBase* GetGLContext() const {
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -823,16 +823,24 @@ DrawTargetCairo::Fill(const Path *aPath,
 
   PathCairo* path = const_cast<PathCairo*>(static_cast<const PathCairo*>(aPath));
   path->SetPathOnContext(mContext);
 
   DrawPattern(aPattern, StrokeOptions(), aOptions, DRAW_FILL);
 }
 
 void
+DrawTargetCairo::SetPermitSubpixelAA(bool aPermitSubpixelAA)
+{
+  DrawTarget::SetPermitSubpixelAA(aPermitSubpixelAA);
+  cairo_surface_set_subpixel_antialiasing(mSurface,
+    aPermitSubpixelAA ? CAIRO_SUBPIXEL_ANTIALIASING_ENABLED : CAIRO_SUBPIXEL_ANTIALIASING_DISABLED);
+}
+
+void
 DrawTargetCairo::FillGlyphs(ScaledFont *aFont,
                             const GlyphBuffer &aBuffer,
                             const Pattern &aPattern,
                             const DrawOptions &aOptions,
                             const GlyphRenderingOptions*)
 {
   AutoPrepareForDrawing prep(this, mContext);
   AutoClearDeviceOffset clear(aPattern);
@@ -1080,16 +1088,23 @@ DrawTargetCairo::CreateSimilarDrawTarget
 bool
 DrawTargetCairo::InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize)
 {
   mContext = cairo_create(aSurface);
   mSurface = aSurface;
   mSize = aSize;
   mFormat = CairoContentToGfxFormat(cairo_surface_get_content(aSurface));
 
+  if (mFormat == FORMAT_B8G8R8A8 ||
+      mFormat == FORMAT_R8G8B8A8) {
+    SetPermitSubpixelAA(false);
+  } else {
+    SetPermitSubpixelAA(true);
+  }
+
   return true;
 }
 
 TemporaryRef<DrawTarget>
 DrawTargetCairo::CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat,
                                         float aSigma) const
 {
   cairo_surface_t* similar = cairo_surface_create_similar(cairo_get_target(mContext),
--- a/gfx/2d/DrawTargetCairo.h
+++ b/gfx/2d/DrawTargetCairo.h
@@ -55,16 +55,18 @@ public:
 
   DrawTargetCairo();
   virtual ~DrawTargetCairo();
 
   virtual BackendType GetType() const { return BACKEND_CAIRO; }
   virtual TemporaryRef<SourceSurface> Snapshot();
   virtual IntSize GetSize();
 
+  virtual void SetPermitSubpixelAA(bool aPermitSubpixelAA);
+
   virtual bool LockBits(uint8_t** aData, IntSize* aSize,
                         int32_t* aStride, SurfaceFormat* aFormat);
   virtual void ReleaseBits(uint8_t* aData);
 
   virtual void Flush();
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,