[chromium] Pass canPaintLCDText to WebContentLayerClient::paintContents
authoralokp@chromium.org <alokp@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2012 04:16:11 +0000 (04:16 +0000)
committeralokp@chromium.org <alokp@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2012 04:16:11 +0000 (04:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=99083

Reviewed by James Robinson.

Use LCD text setting passed to WebContentLayerClient::paintContents instead of turning it off for all composited layers.

Source/Platform:

* chromium/public/WebContentLayerClient.h:
(WebContentLayerClient):
(WebKit::WebContentLayerClient::paintContents):

Source/WebCore:

No new tests needed. This patch does not change anything functionally.

* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::GraphicsLayerChromium::setContentsOpaque):
(WebCore::GraphicsLayerChromium::paint):
* platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp:
(WebCore::OpaqueRectTrackingContentLayerDelegate::paintContents):
* platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h:
(OpaqueRectTrackingContentLayerDelegate):

Source/WebKit/chromium:

* src/LinkHighlight.cpp:
(WebKit::LinkHighlight::paintContents):
* src/LinkHighlight.h:
(LinkHighlight):
* src/NonCompositedContentHost.cpp:
(WebKit::NonCompositedContentHost::NonCompositedContentHost):
(WebKit::NonCompositedContentHost::setOpaque):
(WebKit::NonCompositedContentHost::paintContents):
* src/NonCompositedContentHost.h:
(NonCompositedContentHost):
* tests/OpaqueRectTrackingContentLayerDelegateTest.cpp:
(WebCore::TEST_F):

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

12 files changed:
Source/Platform/ChangeLog
Source/Platform/chromium/public/WebContentLayerClient.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp
Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/LinkHighlight.cpp
Source/WebKit/chromium/src/LinkHighlight.h
Source/WebKit/chromium/src/NonCompositedContentHost.cpp
Source/WebKit/chromium/src/NonCompositedContentHost.h
Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp

index 934cb9f..b36f45a 100644 (file)
@@ -1,3 +1,16 @@
+2012-10-31  Alok Priyadarshi  <alokp@chromium.org>
+
+        [chromium] Pass canPaintLCDText to WebContentLayerClient::paintContents
+        https://bugs.webkit.org/show_bug.cgi?id=99083
+
+        Reviewed by James Robinson.
+
+        Use LCD text setting passed to WebContentLayerClient::paintContents instead of turning it off for all composited layers.
+
+        * chromium/public/WebContentLayerClient.h:
+        (WebContentLayerClient):
+        (WebKit::WebContentLayerClient::paintContents):
+
 2012-10-30  W. James MacLean  <wjmaclean@chromium.org>
 
         [chromium] Transform mouse/gesture event coordinates to account for pinch-zoom in compositor.
index 5469bd2..8274d9e 100644 (file)
@@ -43,7 +43,8 @@ public:
     // optimizations.
 #define WEBCONTENTLAYERCLIENT_HAS_OPAQUE 1
 #define WEBCONTENTLAYERCLIENT_FLOAT_OPAQUE_RECT 1
-    virtual void paintContents(WebCanvas*, const WebRect& clip, WebFloatRect& opaque) = 0;
+#define WEBCONTENTLAYERCLIENT_HAS_CANPAINTLCDTEXT 1
+    virtual void paintContents(WebCanvas*, const WebRect& clip, bool canPaintLCDText, WebFloatRect& opaque) = 0;
 
 protected:
     virtual ~WebContentLayerClient() { }
index 72b7515..037b563 100644 (file)
@@ -1,3 +1,22 @@
+2012-10-31  Alok Priyadarshi  <alokp@chromium.org>
+
+        [chromium] Pass canPaintLCDText to WebContentLayerClient::paintContents
+        https://bugs.webkit.org/show_bug.cgi?id=99083
+
+        Reviewed by James Robinson.
+
+        Use LCD text setting passed to WebContentLayerClient::paintContents instead of turning it off for all composited layers.
+
+        No new tests needed. This patch does not change anything functionally.
+
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        (WebCore::GraphicsLayerChromium::setContentsOpaque):
+        (WebCore::GraphicsLayerChromium::paint):
+        * platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp:
+        (WebCore::OpaqueRectTrackingContentLayerDelegate::paintContents):
+        * platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h:
+        (OpaqueRectTrackingContentLayerDelegate):
+
 2012-10-31  Chris Evans  <cevans@google.com>
 
         RenderArena has a memory leak and poor efficiency
index dc46dc3..e486d2f 100644 (file)
@@ -300,6 +300,7 @@ void GraphicsLayerChromium::setContentsOpaque(bool opaque)
 {
     GraphicsLayer::setContentsOpaque(opaque);
     m_layer->layer()->setOpaque(m_contentsOpaque);
+    m_opaqueRectTrackingContentLayerDelegate->setOpaque(m_contentsOpaque);
 }
 
 static bool copyWebCoreFilterOperationsToWebFilterOperations(const FilterOperations& filters, WebFilterOperations& webFilters)
@@ -864,7 +865,6 @@ bool GraphicsLayerChromium::appliesPageScale() const
 
 void GraphicsLayerChromium::paint(GraphicsContext& context, const IntRect& clip)
 {
-    context.platformContext()->setDrawingToImageBuffer(true);
     paintGraphicsLayerContents(context, clip);
 }
 
index a06ac66..62edced 100644 (file)
@@ -49,7 +49,7 @@ OpaqueRectTrackingContentLayerDelegate::~OpaqueRectTrackingContentLayerDelegate(
 {
 }
 
-void OpaqueRectTrackingContentLayerDelegate::paintContents(SkCanvas* canvas, const WebRect& clip, WebFloatRect& opaque)
+void OpaqueRectTrackingContentLayerDelegate::paintContents(SkCanvas* canvas, const WebRect& clip, bool canPaintLCDText, WebFloatRect& opaque)
 {
     PlatformContextSkia platformContext(canvas);
 #if defined(SK_SUPPORT_HINTING_SCALE_FACTOR)
@@ -57,6 +57,10 @@ void OpaqueRectTrackingContentLayerDelegate::paintContents(SkCanvas* canvas, con
         platformContext.setHintingScaleFactor(canvas->getTotalMatrix().getScaleX());
 #endif
     platformContext.setTrackOpaqueRegion(!m_opaque);
+    // FIXME: Rename PlatformContextSkia::setDrawingToImageBuffer to setCanPaintLCDText.
+    // I also suspect that a function on PlatformContextSkia is not really needed.
+    // GraphicsContext::setAllowsFontSmoothing can be used for this purpose.
+    platformContext.setDrawingToImageBuffer(!(canPaintLCDText && m_opaque));
     GraphicsContext context(&platformContext);
 
     // Record transform prior to painting, as all opaque tracking will be
index bb5c2ae..451b647 100644 (file)
@@ -55,7 +55,7 @@ public:
     void setOpaque(bool opaque) { m_opaque = opaque; }
 
     // WebKit::WebContentLayerClient implementation.
-    virtual void paintContents(SkCanvas*, const WebKit::WebRect& clip, WebKit::WebFloatRect& opaque) OVERRIDE;
+    virtual void paintContents(SkCanvas*, const WebKit::WebRect& clip, bool canPaintLCDText, WebKit::WebFloatRect& opaque) OVERRIDE;
 
 private:
     GraphicsContextPainter* m_painter;
index 5c32309..ff24b81 100644 (file)
@@ -1,3 +1,25 @@
+2012-10-31  Alok Priyadarshi  <alokp@chromium.org>
+
+        [chromium] Pass canPaintLCDText to WebContentLayerClient::paintContents
+        https://bugs.webkit.org/show_bug.cgi?id=99083
+
+        Reviewed by James Robinson.
+
+        Use LCD text setting passed to WebContentLayerClient::paintContents instead of turning it off for all composited layers.
+
+        * src/LinkHighlight.cpp:
+        (WebKit::LinkHighlight::paintContents):
+        * src/LinkHighlight.h:
+        (LinkHighlight):
+        * src/NonCompositedContentHost.cpp:
+        (WebKit::NonCompositedContentHost::NonCompositedContentHost):
+        (WebKit::NonCompositedContentHost::setOpaque):
+        (WebKit::NonCompositedContentHost::paintContents):
+        * src/NonCompositedContentHost.h:
+        (NonCompositedContentHost):
+        * tests/OpaqueRectTrackingContentLayerDelegateTest.cpp:
+        (WebCore::TEST_F):
+
 2012-10-31  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed.  Rolled DEPS.
index 56ca8ab..57cf6cf 100644 (file)
@@ -226,7 +226,7 @@ bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositin
     return pathHasChanged;
 }
 
-void LinkHighlight::paintContents(WebCanvas* canvas, const WebRect& webClipRect, WebFloatRect&)
+void LinkHighlight::paintContents(WebCanvas* canvas, const WebRect& webClipRect, bool, WebFloatRect&)
 {
     if (!m_node || !m_node->renderer())
         return;
index c51f635..06d8c90 100644 (file)
@@ -58,7 +58,7 @@ public:
     void updateGeometry();
 
     // WebContentLayerClient implementation.
-    virtual void paintContents(WebCanvas*, const WebRect& clipRect, WebFloatRect& opaque) OVERRIDE;
+    virtual void paintContents(WebCanvas*, const WebRect& clipRect, bool canPaintLCDText, WebFloatRect& opaque) OVERRIDE;
 
     // WebAnimationDelegate implementation.
     virtual void notifyAnimationStarted(double time) OVERRIDE;
index 21b9725..6921368 100644 (file)
@@ -41,7 +41,6 @@ namespace WebKit {
 
 NonCompositedContentHost::NonCompositedContentHost(WebViewImpl* webView)
     : m_webView(webView)
-    , m_opaque(true)
     , m_showDebugBorders(false)
 {
     m_graphicsLayer = WebCore::GraphicsLayer::create(0, this);
@@ -50,9 +49,10 @@ NonCompositedContentHost::NonCompositedContentHost(WebViewImpl* webView)
 #endif
     m_graphicsLayer->setDrawsContent(true);
     m_graphicsLayer->setAppliesPageScale(!m_webView->page()->settings()->applyPageScaleFactorInCompositor());
+    m_graphicsLayer->setContentsOpaque(true);
+    // FIXME: Remove LCD text setting after it is implemented in chromium.
     WebContentLayer* layer = static_cast<WebCore::GraphicsLayerChromium*>(m_graphicsLayer.get())->contentLayer();
     layer->setUseLCDText(true);
-    layer->layer()->setOpaque(true);
 #if !OS(ANDROID)
     layer->setDrawCheckerboardForMissingTiles(true);
 #endif
@@ -69,8 +69,7 @@ void NonCompositedContentHost::setBackgroundColor(const WebCore::Color& color)
 
 void NonCompositedContentHost::setOpaque(bool opaque)
 {
-    m_opaque = opaque;
-    m_graphicsLayer->platformLayer()->setOpaque(opaque);
+    m_graphicsLayer->setContentsOpaque(opaque);
 }
 
 void NonCompositedContentHost::setScrollLayer(WebCore::GraphicsLayer* layer)
@@ -173,10 +172,11 @@ void NonCompositedContentHost::notifyFlushRequired(const WebCore::GraphicsLayer*
 
 void NonCompositedContentHost::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext& context, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect)
 {
+    // FIXME: Remove LCD text setting after it is implemented in chromium.
     // On non-android platforms, we want to render text with subpixel antialiasing on the root layer
     // so long as the root is opaque. On android all text is grayscale.
 #if !OS(ANDROID)
-    if (m_opaque)
+    if (m_graphicsLayer->contentsOpaque())
         context.platformContext()->setDrawingToImageBuffer(false);
 #endif
     context.translate(-m_layerAdjust);
index 08e9c69..bd3a528 100644 (file)
@@ -82,7 +82,6 @@ private:
     WebCore::IntSize m_viewportSize;
     WebCore::IntSize m_layerAdjust;
 
-    bool m_opaque;
     bool m_showDebugBorders;
 };
 
index 0cf8249..39e36a9 100644 (file)
@@ -145,7 +145,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testOpaqueRectPresentAfterOpa
     OpaqueRectTrackingContentLayerDelegate delegate(&painter);
 
     WebFloatRect opaqueRect;
-    delegate.paintContents(skCanvas(), canvasRect(), opaqueRect);
+    delegate.paintContents(skCanvas(), canvasRect(), false, opaqueRect);
     EXPECT_EQ_RECT(WebFloatRect(0, 0, 400, 400), opaqueRect);
 }
 
@@ -156,7 +156,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testOpaqueRectNotPresentAfter
     OpaqueRectTrackingContentLayerDelegate delegate(&painter);
 
     WebFloatRect opaqueRect;
-    delegate.paintContents(skCanvas(), canvasRect(), opaqueRect);
+    delegate.paintContents(skCanvas(), canvasRect(), false, opaqueRect);
     EXPECT_EQ_RECT(WebFloatRect(0, 0, 0, 0), opaqueRect);
 }
 
@@ -169,7 +169,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testOpaqueRectNotPresentForOp
     delegate.setOpaque(true);
 
     WebFloatRect opaqueRect;
-    delegate.paintContents(skCanvas(), canvasRect(), opaqueRect);
+    delegate.paintContents(skCanvas(), canvasRect(), false, opaqueRect);
     EXPECT_EQ_RECT(WebFloatRect(0, 0, 0, 0), opaqueRect);
 }
 
@@ -182,7 +182,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testOpaqueRectNotPresentForOp
     delegate.setOpaque(true);
 
     WebFloatRect opaqueRect;
-    delegate.paintContents(skCanvas(), canvasRect(), opaqueRect);
+    delegate.paintContents(skCanvas(), canvasRect(), false, opaqueRect);
     EXPECT_EQ_RECT(WebFloatRect(0, 0, 0, 0), opaqueRect);
 }
 
@@ -194,7 +194,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testPartialOpaqueRectNoTransf
     OpaqueRectTrackingContentLayerDelegate delegate(&painter);
 
     WebFloatRect opaqueRect;
-    delegate.paintContents(skCanvas(), canvasRect(), opaqueRect);
+    delegate.paintContents(skCanvas(), canvasRect(), false, opaqueRect);
     EXPECT_EQ_RECT(WebFloatRect(partialRect.x(), partialRect.y(), partialRect.width(), partialRect.height()), opaqueRect);
 }
 
@@ -207,7 +207,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testPartialOpaqueRectTranslat
 
     WebFloatRect opaqueRect;
     WebRect contentRect(11, 12, 389, 388);
-    delegate.paintContents(skCanvas(), contentRect, opaqueRect);
+    delegate.paintContents(skCanvas(), contentRect, false, opaqueRect);
     EXPECT_EQ_RECT(WebFloatRect(partialRect.x(), partialRect.y(), partialRect.width(), partialRect.height()), opaqueRect);
 }
 
@@ -225,7 +225,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testHintingScaleFactorSet)
 
     IntRect rectA;
     WebFloatRect rectB;
-    delegate.paintContents(&canvas, rectA, rectB);
+    delegate.paintContents(&canvas, rectA, false, rectB);
     EXPECT_EQ(callback.hintingScale, hintingScale);
 }
 #endif