- Revision
- 95697
- Author
- bda...@apple.com
- Date
- 2011-09-21 20:29:50 -0700 (Wed, 21 Sep 2011)
Log Message
https://bugs.webkit.org/show_bug.cgi?id=67415
Text drawn via -webkit-background-clip:text is blurry at device scale factors >1.0
-and corresponding-
<rdar://problem/10060379>
Reviewed by Darin Adler.
New helper function RenderBoxModelObject scales the mask image by the
deviceScaleFactor to get an image of the appropriate resolution. It also scales
the image's GraphicsContext so that the clip is set up on the same scale. Back in
paintFillLayerExtended() we still clip the image to the original maskRect to get
everything scaled back to the appropriate size.
* rendering/RenderBoxModelObject.cpp:
(WebCore::createDeviceScaledImageBuffer):
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
Make the deviceScaleFactor convenience function just a namespace-level function in
Page rather than a static member or Page.
* page/Page.cpp:
(WebCore::deviceScaleFactor):
* page/Page.h:
Pre-existing callers of Page::deviceScaleFactor(Frame*) must now use
WebCore::deviceScaleFactor(Frame*)
* editing/DeleteButtonController.cpp:
(WebCore::DeleteButtonController::createDeletionUI):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::imageSizeForError):
(WebCore::RenderImage::paintReplaced):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::drawPlatformResizerImage):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (95696 => 95697)
--- trunk/Source/WebCore/ChangeLog 2011-09-22 02:14:36 UTC (rev 95696)
+++ trunk/Source/WebCore/ChangeLog 2011-09-22 03:29:50 UTC (rev 95697)
@@ -1,3 +1,37 @@
+2011-09-21 Beth Dakin <bda...@apple.com>
+
+ https://bugs.webkit.org/show_bug.cgi?id=67415
+ Text drawn via -webkit-background-clip:text is blurry at device scale factors >1.0
+ -and corresponding-
+ <rdar://problem/10060379>
+
+ Reviewed by Darin Adler.
+
+ New helper function RenderBoxModelObject scales the mask image by the
+ deviceScaleFactor to get an image of the appropriate resolution. It also scales
+ the image's GraphicsContext so that the clip is set up on the same scale. Back in
+ paintFillLayerExtended() we still clip the image to the original maskRect to get
+ everything scaled back to the appropriate size.
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::createDeviceScaledImageBuffer):
+ (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+
+ Make the deviceScaleFactor convenience function just a namespace-level function in
+ Page rather than a static member or Page.
+ * page/Page.cpp:
+ (WebCore::deviceScaleFactor):
+ * page/Page.h:
+
+ Pre-existing callers of Page::deviceScaleFactor(Frame*) must now use
+ WebCore::deviceScaleFactor(Frame*)
+ * editing/DeleteButtonController.cpp:
+ (WebCore::DeleteButtonController::createDeletionUI):
+ * rendering/RenderImage.cpp:
+ (WebCore::RenderImage::imageSizeForError):
+ (WebCore::RenderImage::paintReplaced):
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::drawPlatformResizerImage):
+
2011-09-21 Tim Horton <timothy_hor...@apple.com>
[CG] ImageBufferData::getData has an invariant comparison in the inner part of a loop which doesn't get optimized out
Modified: trunk/Source/WebCore/editing/DeleteButtonController.cpp (95696 => 95697)
--- trunk/Source/WebCore/editing/DeleteButtonController.cpp 2011-09-22 02:14:36 UTC (rev 95696)
+++ trunk/Source/WebCore/editing/DeleteButtonController.cpp 2011-09-22 03:29:50 UTC (rev 95697)
@@ -255,7 +255,7 @@
style->setProperty(CSSPropertyHeight, String::number(buttonHeight) + "px");
style->setProperty(CSSPropertyVisibility, CSSValueVisible);
- float deviceScaleFactor = Page::deviceScaleFactor(m_frame);
+ float deviceScaleFactor = WebCore::deviceScaleFactor(m_frame);
RefPtr<Image> buttonImage;
if (deviceScaleFactor >= 2)
buttonImage = Image::loadPlatformResource("deleteButton@2x");
Modified: trunk/Source/WebCore/page/Page.cpp (95696 => 95697)
--- trunk/Source/WebCore/page/Page.cpp 2011-09-22 02:14:36 UTC (rev 95696)
+++ trunk/Source/WebCore/page/Page.cpp 2011-09-22 03:29:50 UTC (rev 95697)
@@ -109,6 +109,16 @@
frames[i]->document()->dispatchWindowEvent(Event::create(eventName, false, false));
}
+float deviceScaleFactor(Frame* frame)
+{
+ if (!frame)
+ return 1;
+ Page* page = frame->page();
+ if (!page)
+ return 1;
+ return page->deviceScaleFactor();
+}
+
Page::Page(PageClients& pageClients)
: m_chrome(adoptPtr(new Chrome(this, pageClients.chromeClient)))
, m_dragCaretController(adoptPtr(new DragCaretController))
@@ -656,16 +666,6 @@
backForward()->markPagesForFullStyleRecalc();
}
-float Page::deviceScaleFactor(Frame* frame)
-{
- if (!frame)
- return 1;
- Page* page = frame->page();
- if (!page)
- return 1;
- return page->deviceScaleFactor();
-}
-
void Page::didMoveOnscreen()
{
for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
Modified: trunk/Source/WebCore/page/Page.h (95696 => 95697)
--- trunk/Source/WebCore/page/Page.h 2011-09-22 02:14:36 UTC (rev 95696)
+++ trunk/Source/WebCore/page/Page.h 2011-09-22 03:29:50 UTC (rev 95697)
@@ -94,6 +94,8 @@
enum FindDirection { FindDirectionForward, FindDirectionBackward };
+ float deviceScaleFactor(Frame*);
+
class Page {
WTF_MAKE_NONCOPYABLE(Page);
friend class Settings;
@@ -249,7 +251,6 @@
float deviceScaleFactor() const { return m_deviceScaleFactor; }
void setDeviceScaleFactor(float);
- static float deviceScaleFactor(Frame*);
// Notifications when the Page starts and stops being presented via a native window.
void didMoveOnscreen();
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (95696 => 95697)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2011-09-22 02:14:36 UTC (rev 95696)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2011-09-22 03:29:50 UTC (rev 95697)
@@ -595,6 +595,24 @@
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)
{
@@ -688,7 +706,7 @@
maskRect.intersect(paintInfo.rect);
// Now create the mask.
- OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(maskRect.size());
+ OwnPtr<ImageBuffer> maskImage = createDeviceScaledImageBuffer(maskRect.size(), WebCore::deviceScaleFactor(frame()));
if (!maskImage)
return;
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (95696 => 95697)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2011-09-22 02:14:36 UTC (rev 95696)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2011-09-22 03:29:50 UTC (rev 95697)
@@ -86,7 +86,7 @@
IntSize imageSize;
if (newImage->willPaintBrokenImage()) {
- float deviceScaleFactor = Page::deviceScaleFactor(frame());
+ float deviceScaleFactor = WebCore::deviceScaleFactor(frame());
pair<Image*, float> brokenImageAndImageScaleFactor = newImage->brokenImage(deviceScaleFactor);
imageSize = brokenImageAndImageScaleFactor.first->size();
imageSize.scale(1 / brokenImageAndImageScaleFactor.second);
@@ -277,7 +277,7 @@
RefPtr<Image> image = m_imageResource->image();
if (m_imageResource->errorOccurred() && !image->isNull() && usableWidth >= image->width() && usableHeight >= image->height()) {
- float deviceScaleFactor = Page::deviceScaleFactor(frame());
+ float deviceScaleFactor = WebCore::deviceScaleFactor(frame());
// Call brokenImage() explicitly to ensure we get the broken image icon at the appropriate resolution.
pair<Image*, float> brokenImageAndImageScaleFactor = m_imageResource->cachedImage()->brokenImage(deviceScaleFactor);
image = brokenImageAndImageScaleFactor.first;
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (95696 => 95697)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2011-09-22 02:14:36 UTC (rev 95696)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2011-09-22 03:29:50 UTC (rev 95697)
@@ -2416,7 +2416,7 @@
void RenderLayer::drawPlatformResizerImage(GraphicsContext* context, LayoutRect resizerCornerRect)
{
- float deviceScaleFactor = Page::deviceScaleFactor(renderer()->frame());
+ float deviceScaleFactor = WebCore::deviceScaleFactor(renderer()->frame());
RefPtr<Image> resizeCornerImage;
IntSize cornerResizerSize;