[chromium] Fix PlatformContextSkia::setDrawingToImageBuffer abuse
authoralokp@chromium.org <alokp@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jan 2013 22:05:33 +0000 (22:05 +0000)
committeralokp@chromium.org <alokp@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jan 2013 22:05:33 +0000 (22:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104956

Reviewed by James Robinson.

Replaced PlatformContextSkia::SetDrawingToImageBuffer with GraphicsContext::setShouldSmoothFonts.

Source/WebCore:

No new tests needed. No change in functionality.

* platform/graphics/chromium/CompositorHUDFontAtlas.cpp:
(WebCore::CompositorHUDFontAtlas::generateFontAtlas):
* platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp:
(WebCore::OpaqueRectTrackingContentLayerDelegate::paintContents):
* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/skia/PlatformContextSkia.cpp:
(WebCore::PlatformContextSkia::couldUseLCDRenderedText):
(WebCore):

Source/WebKit/chromium:

* src/NonCompositedContentHost.cpp:
(WebKit::NonCompositedContentHost::paintContents):
(WebKit):
(WebKit::NonCompositedContentHost::setShowDebugBorders):
* src/PageWidgetDelegate.cpp:
(WebKit::PageWidgetDelegate::paint):
* src/WebFontImpl.cpp:
(WebKit::WebFontImpl::drawText):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.cpp
Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp
Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/NonCompositedContentHost.cpp
Source/WebKit/chromium/src/PageWidgetDelegate.cpp
Source/WebKit/chromium/src/WebFontImpl.cpp

index 769721b..dd053ca 100644 (file)
@@ -1,3 +1,24 @@
+2013-01-07  Alok Priyadarshi  <alokp@chromium.org>
+
+        [chromium] Fix PlatformContextSkia::setDrawingToImageBuffer abuse
+        https://bugs.webkit.org/show_bug.cgi?id=104956
+
+        Reviewed by James Robinson.
+
+        Replaced PlatformContextSkia::SetDrawingToImageBuffer with GraphicsContext::setShouldSmoothFonts.
+
+        No new tests needed. No change in functionality.
+
+        * platform/graphics/chromium/CompositorHUDFontAtlas.cpp:
+        (WebCore::CompositorHUDFontAtlas::generateFontAtlas):
+        * platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp:
+        (WebCore::OpaqueRectTrackingContentLayerDelegate::paintContents):
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        * platform/graphics/skia/PlatformContextSkia.cpp:
+        (WebCore::PlatformContextSkia::couldUseLCDRenderedText):
+        (WebCore):
+
 2013-01-07  Enrica Casucci  <enrica@apple.com>
 
         Some characters are not rotated properly in vertical text
index 6edf3c5..d8f010e 100644 (file)
@@ -60,8 +60,8 @@ SkBitmap CompositorHUDFontAtlas::generateFontAtlas(WebRect asciiToRectTable[128]
     OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(ATLAS_SIZE, ATLAS_SIZE, false /* opaque */));
 
     PlatformContextSkia platformContext(canvas.get());
-    platformContext.setDrawingToImageBuffer(true);
     GraphicsContext atlasContext(&platformContext);
+    atlasContext.setShouldSmoothFonts(false);
 
     // Clear the entire texture atlas to transparent before drawing fonts.
     atlasContext.setFillColor(Color(0, 0, 0, 0), ColorSpaceDeviceRGB);
index 62edced..81da4ab 100644 (file)
@@ -57,11 +57,8 @@ 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);
+    context.setShouldSmoothFonts(canPaintLCDText && m_opaque);
 
     // Record transform prior to painting, as all opaque tracking will be
     // relative to this current value.
index fbf7359..e3c2c1c 100644 (file)
@@ -138,7 +138,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace,
     m_data.m_canvas = adoptPtr(new SkCanvas(device));
     m_data.m_platformContext.setCanvas(m_data.m_canvas.get());
     m_context = adoptPtr(new GraphicsContext(&m_data.m_platformContext));
-    m_context->platformContext()->setDrawingToImageBuffer(true);
+    m_context->setShouldSmoothFonts(false);
     m_context->scale(FloatSize(m_resolutionScale, m_resolutionScale));
 
     success = true;
@@ -168,7 +168,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace,
     m_data.m_canvas = canvas.release();
     m_data.m_platformContext.setCanvas(m_data.m_canvas.get());
     m_context = adoptPtr(new GraphicsContext(&m_data.m_platformContext));
-    m_context->platformContext()->setDrawingToImageBuffer(true);
+    m_context->setShouldSmoothFonts(false);
     m_context->scale(FloatSize(m_resolutionScale, m_resolutionScale));
 
     // Make the background transparent. It would be nice if this wasn't
index f79d923..0400a7c 100644 (file)
@@ -629,9 +629,7 @@ bool PlatformContextSkia::couldUseLCDRenderedText()
     if (isDrawingToLayer())
         return false;
 
-    // If this text is not in an image buffer and so won't be externally
-    // composited, then subpixel antialiasing is fine.
-    return !isDrawingToImageBuffer();
+    return m_gc->shouldSmoothFonts();
 }
 
 } // namespace WebCore
index e4121ba..1275430 100644 (file)
@@ -1,3 +1,21 @@
+2013-01-07  Alok Priyadarshi  <alokp@chromium.org>
+
+        [chromium] Fix PlatformContextSkia::setDrawingToImageBuffer abuse
+        https://bugs.webkit.org/show_bug.cgi?id=104956
+
+        Reviewed by James Robinson.
+
+        Replaced PlatformContextSkia::SetDrawingToImageBuffer with GraphicsContext::setShouldSmoothFonts.
+
+        * src/NonCompositedContentHost.cpp:
+        (WebKit::NonCompositedContentHost::paintContents):
+        (WebKit):
+        (WebKit::NonCompositedContentHost::setShowDebugBorders):
+        * src/PageWidgetDelegate.cpp:
+        (WebKit::PageWidgetDelegate::paint):
+        * src/WebFontImpl.cpp:
+        (WebKit::WebFontImpl::drawText):
+
 2013-01-07  Mike West  <mkwst@chromium.org>
 
         Make the IFRAME_SEAMLESS flag runtime-enabled.
index 05a4c15..46dcbec 100644 (file)
@@ -172,13 +172,6 @@ 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_graphicsLayer->contentsOpaque())
-        context.platformContext()->setDrawingToImageBuffer(false);
-#endif
     context.translate(-m_layerAdjust);
     WebCore::IntRect adjustedClipRect = clipRect;
     adjustedClipRect.move(m_layerAdjust);
index 1898591..96f09a6 100644 (file)
@@ -87,7 +87,7 @@ void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas*
         return;
     GraphicsContextBuilder builder(canvas);
     GraphicsContext& gc = builder.context();
-    gc.platformContext()->setDrawingToImageBuffer(background == Opaque ? false : true);
+    gc.setShouldSmoothFonts(background == Opaque);
     if (applyDeviceScale) {
         gc.applyDeviceScaleFactor(page->deviceScaleFactor());
         gc.platformContext()->setDeviceScaleFactor(page->deviceScaleFactor());
index c4f5ac1..b34cf43 100644 (file)
@@ -98,9 +98,8 @@ void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFl
     GraphicsContextBuilder builder(canvas);
     GraphicsContext& gc = builder.context();
 
-    gc.platformContext()->setDrawingToImageBuffer(!canvasIsOpaque);
-
     gc.save();
+    gc.setShouldSmoothFonts(canvasIsOpaque);
     gc.setFillColor(color, ColorSpaceDeviceRGB);
     gc.clip(WebCore::FloatRect(clip));
     m_font.drawText(&gc, run, leftBaseline, from, to);