Diff
Modified: trunk/LayoutTests/ChangeLog (97480 => 97481)
--- trunk/LayoutTests/ChangeLog 2011-10-14 18:00:35 UTC (rev 97480)
+++ trunk/LayoutTests/ChangeLog 2011-10-14 18:14:57 UTC (rev 97481)
@@ -1,3 +1,15 @@
+2011-10-14 Beth Dakin <[email protected]>
+
+ Text drawn via -webkit-background-clip:text should be non-blurry with all scaling
+ techniques
+ https://bugs.webkit.org/show_bug.cgi?id=68641
+
+ Reviewed by Simon Fraser.
+
+ * fast/css/clip-text-in-scaled-div-expected.png: Added.
+ * fast/css/clip-text-in-scaled-div-expected.txt: Added.
+ * fast/css/clip-text-in-scaled-div.html: Added.
+
2011-10-14 Csaba Osztrogonác <[email protected]>
[Qt] Unreviewed gardening.
Added: trunk/LayoutTests/fast/css/clip-text-in-scaled-div-expected.png
(Binary files differ)
Property changes on: trunk/LayoutTests/fast/css/clip-text-in-scaled-div-expected.png
___________________________________________________________________
Added: svn:mime-type
Added: trunk/LayoutTests/fast/css/clip-text-in-scaled-div-expected.txt (0 => 97481)
--- trunk/LayoutTests/fast/css/clip-text-in-scaled-div-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/clip-text-in-scaled-div-expected.txt 2011-10-14 18:14:57 UTC (rev 97481)
@@ -0,0 +1,11 @@
+layer at (0,0) size 1576x585
+ 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 784x18
+ RenderBlock {DIV} at (0,0) size 784x18
+ RenderInline {SPAN} at (0,0) size 219x18 [bgcolor=#FF0000]
+ RenderText {#text} at (0,0) size 219x18
+ text run at (0,0) width 219: "This text should be nice and sharp."
+ RenderText {#text} at (0,0) size 0x0
Added: trunk/LayoutTests/fast/css/clip-text-in-scaled-div.html (0 => 97481)
--- trunk/LayoutTests/fast/css/clip-text-in-scaled-div.html (rev 0)
+++ trunk/LayoutTests/fast/css/clip-text-in-scaled-div.html 2011-10-14 18:14:57 UTC (rev 97481)
@@ -0,0 +1,18 @@
+<html>
+<style>
+ .scaled {
+ -webkit-transform:scale(2);
+ -webkit-transform-origin: top left;
+ }
+ .clip-text {
+ background-color:red;
+ -webkit-background-clip:text;
+ -webkit-text-fill-color:transparent
+ }
+</style>
+<body>
+ <div class="scaled">
+ <span class="clip-text">This text should be nice and sharp.</span>
+ </div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (97480 => 97481)
--- trunk/Source/WebCore/ChangeLog 2011-10-14 18:00:35 UTC (rev 97480)
+++ trunk/Source/WebCore/ChangeLog 2011-10-14 18:14:57 UTC (rev 97481)
@@ -1,3 +1,21 @@
+2011-10-14 Darin Adler <[email protected]>
+
+ Text drawn via -webkit-background-clip:text should be non-blurry with all scaling
+ techniques
+ https://bugs.webkit.org/show_bug.cgi?id=68641
+
+ Reviewed by Simon Fraser. Committed by Beth Dakin.
+
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::createCompatibleBuffer): Allocate a buffer based on the
+ scale
+ factor of the context.
+ * platform/graphics/GraphicsContext.h: Added createCompatibleBuffer.
+
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::paintFillLayerExtended): Use
+ createCompatibleBuffer.
+
2011-10-14 Ryosuke Niwa <[email protected]>
Move selectionStartStyle and selectionHasStyle to EditingStyle
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (97480 => 97481)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2011-10-14 18:00:35 UTC (rev 97480)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2011-10-14 18:14:57 UTC (rev 97481)
@@ -745,4 +745,23 @@
}
}
+PassOwnPtr<ImageBuffer> GraphicsContext::createCompatibleBuffer(const IntSize& size) const
+{
+ // Make the buffer larger if the context's transform is scaling it so we need a higher
+ // resolution than one pixel per unit. Also set up a corresponding scale factor on the
+ // graphics context.
+
+ AffineTransform transform = getCTM();
+ IntSize scaledSize(size.width() * transform.xScale(), size.height() * transform.yScale());
+
+ OwnPtr<ImageBuffer> buffer = ImageBuffer::create(scaledSize);
+ if (!buffer)
+ return nullptr;
+
+ buffer->context()->scale(FloatSize(static_cast<float>(scaledSize.width()) / size.width(),
+ static_cast<float>(scaledSize.height()) / size.height()));
+
+ return buffer.release();
}
+
+}
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (97480 => 97481)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2011-10-14 18:00:35 UTC (rev 97480)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2011-10-14 18:14:57 UTC (rev 97481)
@@ -409,6 +409,10 @@
void setCTM(const AffineTransform&);
AffineTransform getCTM() const;
+ // Create an image buffer compatible with this context, with suitable resolution
+ // for drawing into the buffer and then into this context.
+ PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&) const;
+
#if OS(WINCE) && !PLATFORM(QT)
void setBitmap(PassRefPtr<SharedBitmap>);
const AffineTransform& affineTransform() const;
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (97480 => 97481)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2011-10-14 18:00:35 UTC (rev 97480)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2011-10-14 18:14:57 UTC (rev 97481)
@@ -594,24 +594,6 @@
return adjustedRect;
}
-static PassOwnPtr<ImageBuffer> createDeviceScaledImageBuffer(IntSize imageSize, float deviceScaleFactor)
-{
- // To create an image of the appropriate resolution, we need to scale imageRect's size
- // by the device scale factor.
- IntSize scaledImageSize = imageSize;
- scaledImageSize.scale(deviceScaleFactor);
-
- OwnPtr<ImageBuffer> scaledImageBuffer = ImageBuffer::create(scaledImageSize);
- if (!scaledImageBuffer)
- return nullptr;
-
- // Scale the whole context by the device scale factor so that all of the clips set up at
- // the appropriate size.
- scaledImageBuffer->context()->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
-
- return scaledImageBuffer.release();
-}
-
void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, const Color& color, const FillLayer* bgLayer, const LayoutRect& rect,
BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSize& boxSize, CompositeOperator op, RenderObject* backgroundObject)
{
@@ -705,7 +687,7 @@
maskRect.intersect(paintInfo.rect);
// Now create the mask.
- OwnPtr<ImageBuffer> maskImage = createDeviceScaledImageBuffer(maskRect.size(), WebCore::deviceScaleFactor(frame()));
+ OwnPtr<ImageBuffer> maskImage = context->createCompatibleBuffer(maskRect.size());
if (!maskImage)
return;