Bug 612840. Part 1: Remove CONTENT_NO_TEXT flag since it's not really used. Also remove ShouldRetainTransparentSurface and related code; we'll assume that when text is over opaque pixels in an RGBA surface we can always paint it with subpixel AA --- and make it so in later patches. r=vlad
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 20 Dec 2010 14:26:13 +1300
changeset 59479 ca873b14eb719c0bfed13b81a6b71007208f9278
parent 59478 dca9da098880338aba2eeed8e258d3d9a902640e
child 59480 53bc550efbccbf583419f1027de08c9b4e56b9ba
push id17638
push userrocallahan@mozilla.com
push dateMon, 20 Dec 2010 01:39:18 +0000
treeherdermozilla-central@302d1d3e2817 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad
bugs612840
milestone2.0b9pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 612840. Part 1: Remove CONTENT_NO_TEXT flag since it's not really used. Also remove ShouldRetainTransparentSurface and related code; we'll assume that when text is over opaque pixels in an RGBA surface we can always paint it with subpixel AA --- and make it so in later patches. r=vlad
gfx/layers/Layers.cpp
gfx/layers/Layers.h
gfx/layers/basic/BasicLayers.cpp
gfx/thebes/gfxASurface.h
gfx/thebes/gfxD2DSurface.h
gfx/thebes/gfxQuartzSurface.h
gfx/thebes/gfxWindowsSurface.h
gfx/thebes/gfxXlibSurface.h
layout/base/FrameLayerBuilder.cpp
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -438,19 +438,16 @@ Layer::PrintInfo(nsACString& aTo, const 
     AppendToString(aTo, mVisibleRegion, " [visible=", "]");
   }
   if (1.0 != mOpacity) {
     aTo.AppendPrintf(" [opacity=%g]", mOpacity);
   }
   if (GetContentFlags() & CONTENT_OPAQUE) {
     aTo += " [opaqueContent]";
   }
-  if (GetContentFlags() & CONTENT_NO_TEXT) {
-    aTo += " [noText]";
-  }
   if (GetContentFlags() & CONTENT_NO_TEXT_OVER_TRANSPARENT) {
     aTo += " [noTextOverTransparent]";
   }
 
   return aTo;
 }
 
 nsACString&
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -479,27 +479,20 @@ public:
      * If this is set, the caller is promising that by the end of this
      * transaction the entire visible region (as specified by
      * SetVisibleRegion) will be filled with opaque content.
      */
     CONTENT_OPAQUE = 0x01,
     /**
      * ThebesLayers only!
      * If this is set, the caller is promising that the visible region
-     * contains no text at all. If this is set,
-     * CONTENT_NO_TEXT_OVER_TRANSPARENT will also be set.
-     */
-    CONTENT_NO_TEXT = 0x02,
-    /**
-     * ThebesLayers only!
-     * If this is set, the caller is promising that the visible region
      * contains no text over transparent pixels (any text, if present,
      * is over fully opaque pixels).
      */
-    CONTENT_NO_TEXT_OVER_TRANSPARENT = 0x04
+    CONTENT_NO_TEXT_OVER_TRANSPARENT = 0x02
   };
   /**
    * CONSTRUCTION PHASE ONLY
    * This lets layout make some promises about what will be drawn into the
    * visible region of the ThebesLayer. This enables internal quality
    * and performance optimizations.
    */
   void SetContentFlags(PRUint32 aFlags)
--- a/gfx/layers/basic/BasicLayers.cpp
+++ b/gfx/layers/basic/BasicLayers.cpp
@@ -434,42 +434,16 @@ ClipToContain(gfxContext* aContext, cons
   gfxMatrix currentMatrix = aContext->CurrentMatrix();
   aContext->IdentityMatrix();
   aContext->NewPath();
   aContext->Rectangle(deviceRect);
   aContext->Clip();
   aContext->SetMatrix(currentMatrix);
 }
 
-static PRBool
-ShouldRetainTransparentSurface(PRUint32 aContentFlags,
-                               gfxASurface* aTargetSurface)
-{
-  if (aContentFlags & Layer::CONTENT_NO_TEXT)
-    return PR_TRUE;
-
-  switch (aTargetSurface->GetTextQualityInTransparentSurfaces()) {
-  case gfxASurface::TEXT_QUALITY_OK:
-    return PR_TRUE;
-  case gfxASurface::TEXT_QUALITY_OK_OVER_OPAQUE_PIXELS:
-    // Retain the buffer if all text is over opaque pixels. Otherwise,
-    // don't retain the buffer, in the hope that the backbuffer has
-    // opaque pixels where our layer does not.
-    return (aContentFlags & Layer::CONTENT_NO_TEXT_OVER_TRANSPARENT) != 0;
-  case gfxASurface::TEXT_QUALITY_BAD:
-    // If the backbuffer is opaque, then draw directly into it to get
-    // subpixel AA. If the backbuffer is not an opaque format, then we won't get
-    // subpixel AA by drawing into it, so we might as well retain.
-    return aTargetSurface->GetContentType() != gfxASurface::CONTENT_COLOR;
-  default:
-    NS_ERROR("Unknown quality type");
-    return PR_TRUE;
-  }
-}
-
 static nsIntRegion
 IntersectWithClip(const nsIntRegion& aRegion, gfxContext* aContext)
 {
   gfxRect clip = aContext->GetClipExtents();
   clip.RoundOut();
   nsIntRect r(clip.X(), clip.Y(), clip.Width(), clip.Height());
   nsIntRegion result;
   result.And(aRegion, r);
@@ -490,17 +464,17 @@ BasicThebesLayer::Paint(gfxContext* aCon
   PRBool canUseOpaqueSurface = CanUseOpaqueSurface();
   Buffer::ContentType contentType =
     canUseOpaqueSurface ? gfxASurface::CONTENT_COLOR :
                           gfxASurface::CONTENT_COLOR_ALPHA;
   float opacity = GetEffectiveOpacity();
 
   if (!BasicManager()->IsRetained() ||
       (opacity == 1.0 && !canUseOpaqueSurface &&
-       !ShouldRetainTransparentSurface(mContentFlags, targetSurface) &&
+       !(mContentFlags & CONTENT_NO_TEXT_OVER_TRANSPARENT) &&
        !MustRetainContent())) {
     mValidRegion.SetEmpty();
     mBuffer.Clear();
 
     nsIntRegion toDraw = IntersectWithClip(mVisibleRegion, target);
     if (!toDraw.IsEmpty()) {
       target->Save();
       gfxUtils::ClipToRegionSnapped(target, toDraw);
--- a/gfx/thebes/gfxASurface.h
+++ b/gfx/thebes/gfxASurface.h
@@ -155,49 +155,16 @@ public:
      * This will not copy image data, just wraps an image surface around
      * pixel data already available in memory.
      */
     virtual already_AddRefed<gfxImageSurface> GetAsImageSurface()
     {
       return nsnull;
     }
 
-    enum TextQuality {
-        /**
-         * TEXT_QUALITY_OK means that text is always rendered to a
-         * transparent surface just as well as it would be rendered to an
-         * opaque surface. This would normally only be true if
-         * subpixel antialiasing is disabled or if the platform's
-         * transparent surfaces support component alpha.
-         */
-        TEXT_QUALITY_OK,
-        /**
-         * TEXT_QUALITY_OK_OVER_OPAQUE_PIXELS means that text is rendered
-         * to a transparent surface just as well as it would be rendered to an
-         * opaque surface, but only if all the pixels the text is drawn
-         * over already have opaque alpha values.
-         */
-        TEXT_QUALITY_OK_OVER_OPAQUE_PIXELS,
-        /**
-         * TEXT_QUALITY_BAD means that text is rendered
-         * to a transparent surface worse than it would be rendered to an
-         * opaque surface, even if all the pixels the text is drawn
-         * over already have opaque alpha values.
-         */
-        TEXT_QUALITY_BAD
-    };
-    /**
-     * Determine how well text would be rendered in transparent surfaces that
-     * are similar to this surface.
-     */
-    virtual TextQuality GetTextQualityInTransparentSurfaces()
-    {
-        return TEXT_QUALITY_BAD;
-    }
-
     int CairoStatus();
 
     /* Make sure that the given dimensions don't overflow a 32-bit signed int
      * using 4 bytes per pixel; optionally, make sure that either dimension
      * doesn't exceed the given limit.
      */
     static PRBool CheckSurfaceSize(const gfxIntSize& sz, PRInt32 limit = 0);
 
--- a/gfx/thebes/gfxD2DSurface.h
+++ b/gfx/thebes/gfxD2DSurface.h
@@ -56,23 +56,16 @@ public:
     gfxD2DSurface(HANDLE handle, gfxContentType aContent);
 
     gfxD2DSurface(ID3D10Texture2D *texture, gfxContentType aContent);
 
     gfxD2DSurface(cairo_surface_t *csurf);
 
     virtual ~gfxD2DSurface();
 
-    virtual TextQuality GetTextQualityInTransparentSurfaces()
-    {
-      // D2D always draws text in transparent surfaces with grayscale-AA,
-      // even if the text is over opaque pixels.
-      return TEXT_QUALITY_BAD;
-    }
-
     void Present();
     void Scroll(const nsIntPoint &aDelta, const nsIntRect &aClip);
 
     HDC GetDC(PRBool aRetainContents);
     void ReleaseDC(const nsIntRect *aUpdatedRect);
 };
 
 #endif /* GFX_D2DSURFACE_H */
--- a/gfx/thebes/gfxQuartzSurface.h
+++ b/gfx/thebes/gfxQuartzSurface.h
@@ -52,20 +52,16 @@ public:
     gfxQuartzSurface(CGContextRef context, const gfxSize& size, PRBool aForPrinting = PR_FALSE);
     gfxQuartzSurface(cairo_surface_t *csurf, PRBool aForPrinting = PR_FALSE);
     gfxQuartzSurface(unsigned char *data, const gfxSize& size, long stride, gfxImageFormat format, PRBool aForPrinting = PR_FALSE);
 
     virtual ~gfxQuartzSurface();
 
     virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType,
                                                                const gfxIntSize& aSize);
-    virtual TextQuality GetTextQualityInTransparentSurfaces()
-    {
-      return TEXT_QUALITY_OK_OVER_OPAQUE_PIXELS;
-    }
 
     virtual const gfxIntSize GetSize() const { return gfxIntSize(mSize.width, mSize.height); }
 
     CGContextRef GetCGContext() { return mCGContext; }
 
     CGContextRef GetCGContextWithClip(gfxContext *ctx);
 
     virtual PRInt32 GetDefaultContextFlags() const;
--- a/gfx/thebes/gfxWindowsSurface.h
+++ b/gfx/thebes/gfxWindowsSurface.h
@@ -76,21 +76,16 @@ public:
     HDC GetDCWithClip(gfxContext *);
 
     already_AddRefed<gfxImageSurface> GetAsImageSurface();
 
     already_AddRefed<gfxWindowsSurface> OptimizeToDDB(HDC dc,
                                                       const gfxIntSize& size,
                                                       gfxImageFormat format);
 
-    virtual TextQuality GetTextQualityInTransparentSurfaces()
-    {
-      return TEXT_QUALITY_OK_OVER_OPAQUE_PIXELS;
-    }
-
     nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
     nsresult EndPrinting();
     nsresult AbortPrinting();
     nsresult BeginPage();
     nsresult EndPage();
 
     virtual PRInt32 GetDefaultContextFlags() const;
 
--- a/gfx/thebes/gfxXlibSurface.h
+++ b/gfx/thebes/gfxXlibSurface.h
@@ -72,21 +72,16 @@ public:
     Create(Screen* screen, XRenderPictFormat *format, const gfxIntSize& size,
            Drawable relatedDrawable = None);
 
     virtual ~gfxXlibSurface();
 
     virtual already_AddRefed<gfxASurface>
     CreateSimilarSurface(gfxContentType aType, const gfxIntSize& aSize);
 
-    virtual TextQuality GetTextQualityInTransparentSurfaces()
-    {
-      return TEXT_QUALITY_OK_OVER_OPAQUE_PIXELS;
-    }
-
     virtual const gfxIntSize GetSize() const { return mSize; }
 
     Display* XDisplay() { return mDisplay; }
     Screen* XScreen();
     Drawable XDrawable() { return mDrawable; }
     XRenderPictFormat* XRenderFormat();
 
     static int DepthOfVisual(const Screen* screen, const Visual* visual);
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -161,17 +161,17 @@ protected:
    * makes it more likely a display item will be rendered to an opaque
    * layer, giving us the best chance of getting subpixel AA.
    */
   class ThebesLayerData {
   public:
     ThebesLayerData() :
       mActiveScrolledRoot(nsnull), mLayer(nsnull),
       mIsSolidColorInVisibleRegion(PR_FALSE),
-      mHasText(PR_FALSE), mHasTextOverTransparent(PR_FALSE),
+      mHasTextOverTransparent(PR_FALSE),
       mForceTransparentSurface(PR_FALSE) {}
     /**
      * Record that an item has been added to the ThebesLayer, so we
      * need to update our regions.
      * @param aVisibleRect the area of the item that's visible
      * @param aDrawRect the area of the item that would be drawn if it
      * was completely visible
      * @param aOpaqueRect if non-null, the area of the item that's opaque.
@@ -232,20 +232,16 @@ protected:
      * region.
      */
     nscolor      mSolidColor;
     /**
      * True if every pixel in mVisibleRegion will have color mSolidColor.
      */
     PRPackedBool mIsSolidColorInVisibleRegion;
     /**
-     * True if there is any text visible in the layer.
-     */
-    PRPackedBool mHasText;
-    /**
      * True if there is any text visible in the layer that's over
      * transparent pixels in the layer.
      */
     PRPackedBool mHasTextOverTransparent;
     /**
      * Set if the layer should be treated as transparent, even if its entire
      * area is covered by opaque display items. For example, this needs to
      * be set if something is going to "punch holes" in the layer by clearing
@@ -866,17 +862,16 @@ ContainerState::PopThebesLayerData()
       // Invalidate the entire target ThebesLayer since we're changing
       // the background color
       data->mLayer->InvalidateRegion(data->mLayer->GetValidRegion());
     }
     userData->mForcedBackgroundColor = backgroundColor;
   }
   PRUint32 flags =
     ((isOpaque && !data->mForceTransparentSurface) ? Layer::CONTENT_OPAQUE : 0) |
-    (data->mHasText ? 0 : Layer::CONTENT_NO_TEXT) |
     (data->mHasTextOverTransparent ? 0 : Layer::CONTENT_NO_TEXT_OVER_TRANSPARENT);
   layer->SetContentFlags(flags);
 
   if (lastIndex > 0) {
     // Since we're going to pop off the last ThebesLayerData, the
     // mVisibleAboveRegion of the second-to-last item will need to include
     // the regions of the last item.
     ThebesLayerData* nextData = mThebesLayerDataStack[lastIndex - 1];
@@ -929,17 +924,16 @@ ContainerState::ThebesLayerData::Accumul
     // a canvas background), so we need to make sure that the first rect
     // we see doesn't get discarded.
     nsIntRegion tmp;
     tmp.Or(mOpaqueRegion, aDrawRect);
     if (tmp.GetNumRects() <= 4) {
       mOpaqueRegion = tmp;
     }
   } else if (aItem->HasText()) {
-    mHasText = PR_TRUE;
     if (!mOpaqueRegion.Contains(aVisibleRect)) {
       mHasTextOverTransparent = PR_TRUE;
     }
   }
   mForceTransparentSurface = mForceTransparentSurface || forceTransparentSurface;
 }
 
 already_AddRefed<ThebesLayer>