https://bugs.webkit.org/show_bug.cgi?id=92327
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jul 2012 20:33:56 +0000 (20:33 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jul 2012 20:33:56 +0000 (20:33 +0000)
-webkit-background-clip:text is blurry in WebKit 1 apps when
deviceScaleFactor > 1
-and corresponding-
<rdar://problem/11683788>

Reviewed by Simon Fraser.

Source/WebCore:

The bug here is that the code to make createCompatibleBuffer() HiDPI-savvy
assumed that the deviceScaleFactor would always be baked into the CTM of the
GraphicsContext. But that is NOT the case in WebKit 1.

createCompatibleBuffer() is used for clip text and gradients.

Now getCTM() takes a parameter indicating whether the result should definitely
include the device scale, or if it should possibly included the device scale,
which is the option that matches old behavior.
* platform/graphics/GraphicsContext.h:
(GraphicsContext):
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::getCTM):
* platform/graphics/openvg/GraphicsContextOpenVG.cpp:
(WebCore::GraphicsContext::getCTM):
* platform/graphics/qt/GraphicsContextQt.cpp:
(WebCore::GraphicsContext::getCTM):
* platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContext::getCTM):
* platform/graphics/wince/GraphicsContextWinCE.cpp:
(WebCore::GraphicsContext::getCTM):
* platform/graphics/wx/GraphicsContextWx.cpp:
(WebCore::GraphicsContext::getCTM):

Actually use the new parameter in the CG implementation. Use CG API to get a
matrix that definitely includes the device scale when that is required.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::getCTM):

Remove some symbol cruft that doesn't seem to require a replacement.
* WebCore.exp.in:

Use DefinitelyIncludeDeviceScale when getting the CTM in the buggy spot.
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::createCompatibleBuffer):

The ImageBuffer for gradients is created using createCompatibleBuffer(), and since
createCompatibleBuffer() now uses getCTM(DefinitelyIncludeDeviceScale) to
determine appropriate sizing, drawPattern() should use that same matrix to
determine pattern sizing.
* platform/graphics/GeneratorGeneratedImage.cpp:
(WebCore::GeneratorGeneratedImage::drawPattern):

LayoutTests:

* fast/hidpi/gradient-with-scaled-ancestor.html: Added.
* platform/mac/fast/hidpi/gradient-with-scaled-ancestor-expected.png: Added.
* platform/mac/fast/hidpi/gradient-with-scaled-ancestor-expected.txt: Added.

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/hidpi/gradient-with-scaled-ancestor.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/hidpi/gradient-with-scaled-ancestor-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/hidpi/gradient-with-scaled-ancestor-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp
Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp
Source/WebCore/platform/graphics/wx/GraphicsContextWx.cpp

index c5ef4d4..ecd9f26 100644 (file)
@@ -1,3 +1,17 @@
+2012-07-27  Beth Dakin  <bdakin@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=92327
+        -webkit-background-clip:text is blurry in WebKit 1 apps when
+        deviceScaleFactor > 1
+        -and corresponding-
+        <rdar://problem/11683788>
+
+        Reviewed by Simon Fraser.
+
+        * fast/hidpi/gradient-with-scaled-ancestor.html: Added.
+        * platform/mac/fast/hidpi/gradient-with-scaled-ancestor-expected.png: Added.
+        * platform/mac/fast/hidpi/gradient-with-scaled-ancestor-expected.txt: Added.
+
 2012-07-27  Brian Weinstein  <bweinstein@apple.com>
 
         Add Mac results for fast/table/table-row-outline-paint.html.
diff --git a/LayoutTests/fast/hidpi/gradient-with-scaled-ancestor.html b/LayoutTests/fast/hidpi/gradient-with-scaled-ancestor.html
new file mode 100644 (file)
index 0000000..02f77fb
--- /dev/null
@@ -0,0 +1,3 @@
+<div style="-webkit-transform:scale(1.5); -webkit-transform-origin:top left;">
+<div style="height:300px;width:300px;background-image:-webkit-repeating-linear-gradient(top left, red 10%, blue 30%);border:1px solid">
+</div>
diff --git a/LayoutTests/platform/mac/fast/hidpi/gradient-with-scaled-ancestor-expected.png b/LayoutTests/platform/mac/fast/hidpi/gradient-with-scaled-ancestor-expected.png
new file mode 100644 (file)
index 0000000..12029d9
Binary files /dev/null and b/LayoutTests/platform/mac/fast/hidpi/gradient-with-scaled-ancestor-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/hidpi/gradient-with-scaled-ancestor-expected.txt b/LayoutTests/platform/mac/fast/hidpi/gradient-with-scaled-ancestor-expected.txt
new file mode 100644 (file)
index 0000000..4f99e6c
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 1184x585
+  RenderView at (0,0) size 800x585
+layer at (0,0) size 800x585
+  RenderBlock {HTML} at (0,0) size 800x585
+    RenderBody {BODY} at (8,8) size 784x569
+layer at (8,8) size 784x302
+  RenderBlock {DIV} at (0,0) size 784x302
+    RenderBlock {DIV} at (0,0) size 302x302 [border: (1px solid #000000)]
index ddaf4d8..3d3eb78 100644 (file)
@@ -1,3 +1,56 @@
+2012-07-27  Beth Dakin  <bdakin@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=92327
+        -webkit-background-clip:text is blurry in WebKit 1 apps when
+        deviceScaleFactor > 1
+        -and corresponding-
+        <rdar://problem/11683788>
+
+        Reviewed by Simon Fraser.
+
+        The bug here is that the code to make createCompatibleBuffer() HiDPI-savvy 
+        assumed that the deviceScaleFactor would always be baked into the CTM of the
+        GraphicsContext. But that is NOT the case in WebKit 1.
+
+        createCompatibleBuffer() is used for clip text and gradients.
+
+        Now getCTM() takes a parameter indicating whether the result should definitely
+        include the device scale, or if it should possibly included the device scale, 
+        which is the option that matches old behavior.
+        * platform/graphics/GraphicsContext.h:
+        (GraphicsContext):
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::getCTM):
+        * platform/graphics/openvg/GraphicsContextOpenVG.cpp:
+        (WebCore::GraphicsContext::getCTM):
+        * platform/graphics/qt/GraphicsContextQt.cpp:
+        (WebCore::GraphicsContext::getCTM):
+        * platform/graphics/skia/GraphicsContextSkia.cpp:
+        (WebCore::GraphicsContext::getCTM):
+        * platform/graphics/wince/GraphicsContextWinCE.cpp:
+        (WebCore::GraphicsContext::getCTM):
+        * platform/graphics/wx/GraphicsContextWx.cpp:
+        (WebCore::GraphicsContext::getCTM):
+
+        Actually use the new parameter in the CG implementation. Use CG API to get a
+        matrix that definitely includes the device scale when that is required. 
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::getCTM):
+
+        Remove some symbol cruft that doesn't seem to require a replacement.
+        * WebCore.exp.in:
+
+        Use DefinitelyIncludeDeviceScale when getting the CTM in the buggy spot.
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::createCompatibleBuffer):
+
+        The ImageBuffer for gradients is created using createCompatibleBuffer(), and since 
+        createCompatibleBuffer() now uses getCTM(DefinitelyIncludeDeviceScale) to 
+        determine appropriate sizing, drawPattern() should use that same matrix to 
+        determine pattern sizing.
+        * platform/graphics/GeneratorGeneratedImage.cpp:
+        (WebCore::GeneratorGeneratedImage::drawPattern):
+
 2012-07-27  Tony Chang  <tony@chromium.org>
 
         flex-wrap: wrap not wrapping for % sized items in column flow
index 7d2c2cc..dbc961c 100644 (file)
@@ -1178,7 +1178,6 @@ __ZNK7WebCore15FocusController18focusedOrMainFrameEv
 __ZNK7WebCore15GraphicsContext15platformContextEv
 __ZNK7WebCore15GraphicsContext16paintingDisabledEv
 __ZNK7WebCore15GraphicsContext20updatingControlTintsEv
-__ZNK7WebCore15GraphicsContext6getCTMEv
 __ZNK7WebCore15ProgressTracker17estimatedProgressEv
 __ZNK7WebCore15ProtectionSpace10serverTypeEv
 __ZNK7WebCore15ProtectionSpace26receivesCredentialSecurelyEv
index e64d16a..c98603a 100644 (file)
@@ -53,7 +53,7 @@ void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const Fl
     m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
 
     // Factor in the destination context's scale to generate at the best resolution
-    AffineTransform destContextCTM = destContext->getCTM();
+    AffineTransform destContextCTM = destContext->getCTM(GraphicsContext::DefinitelyIncludeDeviceScale);
     double xScale = fabs(destContextCTM.xScale());
     double yScale = fabs(destContextCTM.yScale());
     AffineTransform adjustedPatternCTM = patternTransform;
index 6664b86..caef7ad 100644 (file)
@@ -769,7 +769,7 @@ PassOwnPtr<ImageBuffer> GraphicsContext::createCompatibleBuffer(const IntSize& s
     // resolution than one pixel per unit. Also set up a corresponding scale factor on the
     // graphics context.
 
-    AffineTransform transform = getCTM();
+    AffineTransform transform = getCTM(DefinitelyIncludeDeviceScale);
     IntSize scaledSize(static_cast<int>(ceil(size.width() * transform.xScale())), static_cast<int>(ceil(size.height() * transform.yScale())));
 
     OwnPtr<ImageBuffer> buffer = ImageBuffer::create(scaledSize, 1, ColorSpaceDeviceRGB, isAcceleratedContext() ? Accelerated : Unaccelerated);
index da442cf..a2f4d68 100644 (file)
@@ -413,7 +413,9 @@ namespace WebCore {
 
         void concatCTM(const AffineTransform&);
         void setCTM(const AffineTransform&);
-        AffineTransform getCTM() const;
+
+        enum IncludeDeviceScale { DefinitelyIncludeDeviceScale, PossiblyIncludeDeviceScale };
+        AffineTransform getCTM(IncludeDeviceScale includeScale = PossiblyIncludeDeviceScale) const;
 
 #if ENABLE(3D_RENDERING) && USE(TEXTURE_MAPPER)
         // This is needed when using accelerated-compositing in software mode, like in TextureMapper.
index bd1c9ba..74f0c3a 100644 (file)
@@ -192,7 +192,7 @@ void GraphicsContext::platformDestroy()
     delete m_data;
 }
 
-AffineTransform GraphicsContext::getCTM() const
+AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
 {
     if (paintingDisabled())
         return AffineTransform();
index cca3de0..4d781a9 100644 (file)
@@ -1411,12 +1411,18 @@ void GraphicsContext::setCTM(const AffineTransform& transform)
     m_data->m_userToDeviceTransformKnownToBeIdentity = false;
 }
 
-AffineTransform GraphicsContext::getCTM() const
+AffineTransform GraphicsContext::getCTM(IncludeDeviceScale includeScale) const
 {
     if (paintingDisabled())
         return AffineTransform();
 
-    return AffineTransform(CGContextGetCTM(platformContext()));
+    // The CTM usually includes the deviceScaleFactor except in WebKit 1 when the
+    // content is non-composited, since the scale factor is integrated at a lower
+    // level. To guarantee the deviceScale is included, we can use this CG API.
+    if (includeScale == DefinitelyIncludeDeviceScale)
+        return CGContextGetUserSpaceToDeviceSpaceTransform(platformContext());
+
+    return CGContextGetCTM(platformContext());
 }
 
 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode roundingMode)
index b7dfc2f..babaa0f 100644 (file)
@@ -67,7 +67,7 @@ PlatformGraphicsContext* GraphicsContext::platformContext() const
     return m_data->baseSurface();
 }
 
-AffineTransform GraphicsContext::getCTM() const
+AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
 {
     if (paintingDisabled())
         return AffineTransform();
index 6a3effa..d3f507d 100644 (file)
@@ -287,7 +287,7 @@ PlatformGraphicsContext* GraphicsContext::platformContext() const
     return m_data->p();
 }
 
-AffineTransform GraphicsContext::getCTM() const
+AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
 {
     if (paintingDisabled())
         return AffineTransform();
index 0af779c..24f6645 100644 (file)
@@ -754,7 +754,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect,
     platformContext()->didDrawPath(path, paint);
 }
 
-AffineTransform GraphicsContext::getCTM() const
+AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
 {
     if (paintingDisabled())
         return AffineTransform();
index 92e02a0..46e2ce8 100644 (file)
@@ -1492,7 +1492,7 @@ void GraphicsContext::fillRect(const FloatRect& r, const Gradient* gradient)
     GradientFill(dc, tv.data(), tv.size(), mesh.data(), mesh.size(), vertical ? GRADIENT_FILL_RECT_V : GRADIENT_FILL_RECT_H);
 }
 
-AffineTransform GraphicsContext::getCTM() const
+AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
 {
     if (paintingDisabled())
         return AffineTransform();
index 78e6089..9d54870 100644 (file)
@@ -477,7 +477,7 @@ void GraphicsContext::canvasClip(const Path& path)
     clip(path);
 }
 
-AffineTransform GraphicsContext::getCTM() const
+AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
 { 
     if (paintingDisabled())
         return AffineTransform();