2010-09-09 Alexey Marinichev <amarinichev@chromium.org>
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Sep 2010 04:02:24 +0000 (04:02 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Sep 2010 04:02:24 +0000 (04:02 +0000)
        Reviewed by James Robinson.

        [chromium] Disable subpixel rendering in Linux when GPU compositor is active
        https://bugs.webkit.org/show_bug.cgi?id=45087

        This extends windows-only logic to chromium linux as well.

        * platform/graphics/chromium/ContentLayerChromium.cpp:
        (WebCore::ContentLayerChromium::updateContents):
        * platform/graphics/chromium/FontLinux.cpp:
        (WebCore::adjustTextRenderMode): Added a check to see if the compositor is active.
        (WebCore::Font::drawGlyphs):
        (WebCore::Font::drawComplexText):
        * platform/graphics/chromium/LayerRendererChromium.cpp:
        (WebCore::LayerRendererChromium::setRootLayerCanvasSize):
        * platform/graphics/chromium/VideoLayerChromium.cpp:
        (WebCore::VideoLayerChromium::updateContents):
        * platform/graphics/skia/ImageBufferSkia.cpp:
        (WebCore::ImageBuffer::ImageBuffer):
        (WebCore::ImageBuffer::clip):
        * platform/graphics/skia/PlatformContextSkia.cpp:
        Made setDrawingToImageBuffer and isDrawingToImageBuffer available to
        Linux; removed all #if OS(WINDOWS) || OS(LINUX).
        (WebCore::PlatformContextSkia::State::State):
        (WebCore::PlatformContextSkia::PlatformContextSkia):
        (WebCore::PlatformContextSkia::isDrawingToImageBuffer):
        (WebCore::PlatformContextSkia::save):
        (WebCore::PlatformContextSkia::beginLayerClippedToImage):
        (WebCore::PlatformContextSkia::restore):
        (WebCore::PlatformContextSkia::applyClipFromImage):
        * platform/graphics/skia/PlatformContextSkia.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67161 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
WebCore/platform/graphics/chromium/FontLinux.cpp
WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
WebCore/platform/graphics/chromium/VideoLayerChromium.cpp
WebCore/platform/graphics/skia/ImageBufferSkia.cpp
WebCore/platform/graphics/skia/PlatformContextSkia.cpp
WebCore/platform/graphics/skia/PlatformContextSkia.h

index 63c4338695fd4f9766edc80ff4c117932b495055..cbfefcb6a47681625a06288e470cea4e06f92f30 100644 (file)
@@ -1,3 +1,37 @@
+2010-09-09  Alexey Marinichev  <amarinichev@chromium.org>
+
+        Reviewed by James Robinson.
+
+        [chromium] Disable subpixel rendering in Linux when GPU compositor is active
+        https://bugs.webkit.org/show_bug.cgi?id=45087
+
+        This extends windows-only logic to chromium linux as well.
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::updateContents):
+        * platform/graphics/chromium/FontLinux.cpp:
+        (WebCore::adjustTextRenderMode): Added a check to see if the compositor is active.
+        (WebCore::Font::drawGlyphs):
+        (WebCore::Font::drawComplexText):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::setRootLayerCanvasSize):
+        * platform/graphics/chromium/VideoLayerChromium.cpp:
+        (WebCore::VideoLayerChromium::updateContents):
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        (WebCore::ImageBuffer::clip):
+        * platform/graphics/skia/PlatformContextSkia.cpp:
+        Made setDrawingToImageBuffer and isDrawingToImageBuffer available to
+        Linux; removed all #if OS(WINDOWS) || OS(LINUX).
+        (WebCore::PlatformContextSkia::State::State):
+        (WebCore::PlatformContextSkia::PlatformContextSkia):
+        (WebCore::PlatformContextSkia::isDrawingToImageBuffer):
+        (WebCore::PlatformContextSkia::save):
+        (WebCore::PlatformContextSkia::beginLayerClippedToImage):
+        (WebCore::PlatformContextSkia::restore):
+        (WebCore::PlatformContextSkia::applyClipFromImage):
+        * platform/graphics/skia/PlatformContextSkia.h:
+
 2010-09-09  Kinuko Yasuda  <kinuko@chromium.org>
 
         Unreviewed, Windows build fix.
index 5c8b8693da7de63a239998282d9acfcbebce1b83..48119bbbfd30db609dc3388803838a3dde86120b 100644 (file)
@@ -176,14 +176,9 @@ void ContentLayerChromium::updateContents()
     canvas.set(new skia::PlatformCanvas(dirtyRect.width(), dirtyRect.height(), false));
     skiaContext.set(new PlatformContextSkia(canvas.get()));
 
-#if OS(WINDOWS)
-    // This is needed to get text to show up correctly. Without it,
-    // GDI renders with zero alpha and the text becomes invisible.
-    // Unfortunately, setting this to true disables cleartype.
+    // This is needed to get text to show up correctly.
     // FIXME: Does this take us down a very slow text rendering path?
-    // FIXME: why is this is a windows-only call ?
     skiaContext->setDrawingToImageBuffer(true);
-#endif
 
     graphicsContext.set(new GraphicsContext(reinterpret_cast<PlatformGraphicsContext*>(skiaContext.get())));
 
index ab3045e422382f192c58c98261e369cafae7eb93..696cd9cea0d110e47b08a4b97f2bae3dee2764d2 100644 (file)
@@ -65,13 +65,13 @@ static bool isCanvasMultiLayered(SkCanvas* canvas)
     return !layerIterator.done();
 }
 
-static void adjustTextRenderMode(SkPaint* paint, bool isCanvasMultiLayered)
+static void adjustTextRenderMode(SkPaint* paint, PlatformContextSkia* skiaContext)
 {
     // Our layers only have a single alpha channel. This means that subpixel
     // rendered text cannot be compositied correctly when the layer is
     // collapsed. Therefore, subpixel text is disabled when we are drawing
-    // onto a layer.
-    if (isCanvasMultiLayered)
+    // onto a layer or when the compositor is being used.
+    if (isCanvasMultiLayered(skiaContext->canvas()) || skiaContext->isDrawingToImageBuffer())
         paint->setLCDRenderText(false);
 }
 
@@ -104,14 +104,13 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
 
     SkCanvas* canvas = gc->platformContext()->canvas();
     int textMode = gc->platformContext()->getTextDrawingMode();
-    bool haveMultipleLayers = isCanvasMultiLayered(canvas);
 
     // We draw text up to two times (once for fill, once for stroke).
     if (textMode & cTextFill) {
         SkPaint paint;
         gc->platformContext()->setupPaintForFilling(&paint);
         font->platformData().setupPaint(&paint);
-        adjustTextRenderMode(&paint, haveMultipleLayers);
+        adjustTextRenderMode(&paint, gc->platformContext());
         paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
         paint.setColor(gc->fillColor().rgb());
         canvas->drawPosText(glyphs, numGlyphs << 1, pos, paint);
@@ -124,7 +123,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
         SkPaint paint;
         gc->platformContext()->setupPaintForStroking(&paint, 0, 0);
         font->platformData().setupPaint(&paint);
-        adjustTextRenderMode(&paint, haveMultipleLayers);
+        adjustTextRenderMode(&paint, gc->platformContext());
         paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
         paint.setColor(gc->strokeColor().rgb());
 
@@ -646,7 +645,6 @@ void Font::drawComplexText(GraphicsContext* gc, const TextRun& run,
     }
 
     TextRunWalker walker(run, point.x(), this);
-    bool haveMultipleLayers = isCanvasMultiLayered(canvas);
     walker.setWordSpacingAdjustment(wordSpacing());
     walker.setLetterSpacingAdjustment(letterSpacing());
     walker.setPadding(run.padding());
@@ -654,13 +652,13 @@ void Font::drawComplexText(GraphicsContext* gc, const TextRun& run,
     while (walker.nextScriptRun()) {
         if (fill) {
             walker.fontPlatformDataForScriptRun()->setupPaint(&fillPaint);
-            adjustTextRenderMode(&fillPaint, haveMultipleLayers);
+            adjustTextRenderMode(&fillPaint, gc->platformContext());
             canvas->drawPosTextH(walker.glyphs(), walker.length() << 1, walker.xPositions(), point.y(), fillPaint);
         }
 
         if (stroke) {
             walker.fontPlatformDataForScriptRun()->setupPaint(&strokePaint);
-            adjustTextRenderMode(&strokePaint, haveMultipleLayers);
+            adjustTextRenderMode(&strokePaint, gc->platformContext());
             canvas->drawPosTextH(walker.glyphs(), walker.length() << 1, walker.xPositions(), point.y(), strokePaint);
         }
     }
index 789298aed8ce9763020cfe0ae2248e3733df2c8c..4708310349797f987b210c98d08647d3f915eb32 100644 (file)
@@ -125,10 +125,7 @@ void LayerRendererChromium::setRootLayerCanvasSize(const IntSize& size)
     // the old ones.
     m_rootLayerCanvas = new skia::PlatformCanvas(size.width(), size.height(), false);
     m_rootLayerSkiaContext = new PlatformContextSkia(m_rootLayerCanvas.get());
-#if OS(WINDOWS)
-    // FIXME: why is this is a windows-only call ?
     m_rootLayerSkiaContext->setDrawingToImageBuffer(true);
-#endif
     m_rootLayerGraphicsContext = new GraphicsContext(reinterpret_cast<PlatformGraphicsContext*>(m_rootLayerSkiaContext.get()));
 #elif PLATFORM(CG)
     // Release the previous CGBitmapContext before reallocating the backing store as a precaution.
index 7ff98b93fd03ada2da68fc4d1f6e29b5740ff4be..c0da28567b3fe9c1dde69172268cf65d7292427f 100644 (file)
@@ -96,14 +96,9 @@ void VideoLayerChromium::updateContents()
         m_canvas = new skia::PlatformCanvas(dirtyRect.width(), dirtyRect.height(), true);
         m_skiaContext = new PlatformContextSkia(m_canvas.get());
 
-#if OS(WINDOWS)
-        // This is needed to get text to show up correctly. Without it,
-        // GDI renders with zero alpha and the text becomes invisible.
-        // Unfortunately, setting this to true disables cleartype.
+        // This is needed to get text to show up correctly.
         // FIXME: Does this take us down a very slow text rendering path?
-        // FIXME: Why is this is a windows-only call?
         m_skiaContext->setDrawingToImageBuffer(true);
-#endif
         m_graphicsContext = new GraphicsContext(reinterpret_cast<PlatformGraphicsContext*>(m_skiaContext.get()));
     }
 
index 9c96673a656d05d2d92c709a5672e8735893fe08..2be7dc57a62f0c08229ab7ccb923ab1ad2175f65 100644 (file)
@@ -69,9 +69,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, ImageColorSpace imageColorSpace, b
 
     m_data.m_platformContext.setCanvas(&m_data.m_canvas);
     m_context.set(new GraphicsContext(&m_data.m_platformContext));
-#if OS(WINDOWS)
     m_context->platformContext()->setDrawingToImageBuffer(true);
-#endif
 
     // Make the background transparent. It would be nice if this wasn't
     // required, but the canvas is currently filled with the magic transparency
@@ -102,9 +100,7 @@ PassRefPtr<Image> ImageBuffer::copyImage() const
 
 void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const
 {
-#if OS(LINUX) || OS(WINDOWS)
     context->platformContext()->beginLayerClippedToImage(rect, this);
-#endif
 }
 
 void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
index dfcbd9ae6b5439ce02e49a66422038e28bce4265..88fbcdd6c0ab2909ac29752fffa3cabc80c17f9d 100755 (executable)
@@ -97,12 +97,10 @@ struct PlatformContextSkia::State {
     // color to produce a new output color.
     SkColor applyAlpha(SkColor) const;
 
-#if OS(LINUX) || OS(WINDOWS)
     // If non-empty, the current State is clipped to this image.
     SkBitmap m_imageBufferClip;
     // If m_imageBufferClip is non-empty, this is the region the image is clipped to.
     FloatRect m_clip;
-#endif
 
     // This is a list of clipping paths which are currently active, in the
     // order in which they were pushed.
@@ -158,10 +156,8 @@ PlatformContextSkia::State::State(const State& other)
     , m_lineJoin(other.m_lineJoin)
     , m_dash(other.m_dash)
     , m_textDrawingMode(other.m_textDrawingMode)
-#if OS(LINUX) || OS(WINDOWS)
     , m_imageBufferClip(other.m_imageBufferClip)
     , m_clip(other.m_clip)
-#endif
     , m_antiAliasClipPaths(other.m_antiAliasClipPaths)
     , m_interpolationQuality(other.m_interpolationQuality)
     , m_canvasClipApplied(other.m_canvasClipApplied)
@@ -209,9 +205,7 @@ SkColor PlatformContextSkia::State::applyAlpha(SkColor c) const
 // Danger: canvas can be NULL.
 PlatformContextSkia::PlatformContextSkia(skia::PlatformCanvas* canvas)
     : m_canvas(canvas)
-#if OS(WINDOWS)
     , m_drawingToImageBuffer(false)
-#endif
     , m_useGPU(false)
     , m_gpuCanvas(0)
     , m_backingStoreState(None)
@@ -231,7 +225,6 @@ void PlatformContextSkia::setCanvas(skia::PlatformCanvas* canvas)
     m_canvas = canvas;
 }
 
-#if OS(WINDOWS)
 void PlatformContextSkia::setDrawingToImageBuffer(bool value)
 {
     m_drawingToImageBuffer = value;
@@ -241,7 +234,6 @@ bool PlatformContextSkia::isDrawingToImageBuffer() const
 {
     return m_drawingToImageBuffer;
 }
-#endif
 
 void PlatformContextSkia::save()
 {
@@ -250,17 +242,14 @@ void PlatformContextSkia::save()
     m_stateStack.append(m_state->cloneInheritedProperties());
     m_state = &m_stateStack.last();
 
-#if OS(LINUX) || OS(WINDOWS)
     // The clip image only needs to be applied once. Reset the image so that we
     // don't attempt to clip multiple times.
     m_state->m_imageBufferClip.reset();
-#endif
 
     // Save our native canvas.
     canvas()->save();
 }
 
-#if OS(LINUX) || OS(WINDOWS)
 void PlatformContextSkia::beginLayerClippedToImage(const FloatRect& rect,
                                                    const ImageBuffer* imageBuffer)
 {
@@ -289,7 +278,6 @@ void PlatformContextSkia::beginLayerClippedToImage(const FloatRect& rect,
         m_state->m_imageBufferClip = *bitmap;
     }
 }
-#endif
 
 void PlatformContextSkia::clipPathAntiAliased(const SkPath& clipPath)
 {
@@ -308,12 +296,10 @@ void PlatformContextSkia::clipPathAntiAliased(const SkPath& clipPath)
 
 void PlatformContextSkia::restore()
 {
-#if OS(LINUX) || OS(WINDOWS)
     if (!m_state->m_imageBufferClip.empty()) {
         applyClipFromImage(m_state->m_clip, m_state->m_imageBufferClip);
         canvas()->restore();
     }
-#endif
 
     if (!m_state->m_antiAliasClipPaths.isEmpty())
         applyAntiAliasedClipPaths(m_state->m_antiAliasClipPaths);
@@ -638,7 +624,6 @@ bool PlatformContextSkia::hasImageResamplingHint() const
     return !m_imageResamplingHintSrcSize.isEmpty() && !m_imageResamplingHintDstSize.isEmpty();
 }
 
-#if OS(LINUX) || OS(WINDOWS)
 void PlatformContextSkia::applyClipFromImage(const FloatRect& rect, const SkBitmap& imageBuffer)
 {
     // NOTE: this assumes the image mask contains opaque black for the portions that are to be shown, as such we
@@ -647,7 +632,6 @@ void PlatformContextSkia::applyClipFromImage(const FloatRect& rect, const SkBitm
     paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
     m_canvas->drawBitmap(imageBuffer, SkFloatToScalar(rect.x()), SkFloatToScalar(rect.y()), &paint);
 }
-#endif
 
 void PlatformContextSkia::applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths)
 {
index e6d58750a03a8ffa52a03c63d171a9307c2f2706..4ba85d1601ec60451ed764c087e757af95a1461e 100644 (file)
@@ -78,7 +78,6 @@ public:
     // to the constructor.
     void setCanvas(skia::PlatformCanvas*);
 
-#if OS(WINDOWS)
     // If false we're rendering to a GraphicsContext for a web page, if false
     // we're not (as is the case when rendering to a canvas object).
     // If this is true the contents have not been marked up with the magic
@@ -86,7 +85,6 @@ public:
     // correctly updated.
     void setDrawingToImageBuffer(bool);
     bool isDrawingToImageBuffer() const;
-#endif
 
     void save();
     void restore();
@@ -95,9 +93,7 @@ public:
     // |rect|. This layer is implicitly restored when the next restore is
     // invoked.
     // NOTE: |imageBuffer| may be deleted before the |restore| is invoked.
-#if OS(LINUX) || OS(WINDOWS)
     void beginLayerClippedToImage(const FloatRect&, const ImageBuffer*);
-#endif
     void clipPathAntiAliased(const SkPath&);
 
     // Sets up the common flags on a paint for antialiasing, effects, etc.
@@ -197,11 +193,9 @@ public:
     void markDirtyRect(const IntRect& rect);
 
 private:
-#if OS(LINUX) || OS(WINDOWS)
     // Used when restoring and the state has an image clip. Only shows the pixels in
     // m_canvas that are also in imageBuffer.
     void applyClipFromImage(const FloatRect&, const SkBitmap&);
-#endif
     void applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths);
 
     void uploadSoftwareToHardware(CompositeOperator) const;
@@ -227,9 +221,7 @@ private:
     // Values are used in ImageSkia.cpp
     IntSize m_imageResamplingHintSrcSize;
     FloatSize m_imageResamplingHintDstSize;
-#if OS(WINDOWS)
     bool m_drawingToImageBuffer;
-#endif
     bool m_useGPU;
     OwnPtr<GLES2Canvas> m_gpuCanvas;
     mutable enum { None, Software, Mixed, Hardware } m_backingStoreState;