- Revision
- 134348
- Author
- [email protected]
- Date
- 2012-11-12 20:26:35 -0800 (Mon, 12 Nov 2012)
Log Message
Zoomed-in scrolling is very slow when deviceScaleFactor > 1
https://bugs.webkit.org/show_bug.cgi?id=101787
Reviewed by Simon Fraser.
Source/WebCore:
This patch adds a new member to the GraphicsContextState that tracks
whether or not fonts should be subpixel-quantized. We want to default
to sibpixel-quantizing, but we'll turn it off if we're scrolling
content that cannot be scrolled on the scrolling thread.
State has a new bool shouldSubpixelQuantizeFonts. It defaults to true
since normally we do want to quantize.
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::setShouldSubpixelQuantizeFonts):
(WebCore::GraphicsContext::shouldSubpixelQuantizeFonts):
* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContextState::GraphicsContextState):
(GraphicsContextState):
(GraphicsContext):
wkSetCGFontRenderingMode now takes a BOOL parameter which indicates
whether or not it should try to subpixel-quantize the fonts.
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::drawGlyphs):
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:
Disable subpixel-quantization for overflow areas, subframes, and
content that is scrolling on the main thread.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::paintLayerContents):
WebKitLibraries:
wkSetCGFontRenderingMode now takes a BOOL parameter.
* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLion.a:
* libWebKitSystemInterfaceMountainLion.a:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (134347 => 134348)
--- trunk/Source/WebCore/ChangeLog 2012-11-13 04:05:18 UTC (rev 134347)
+++ trunk/Source/WebCore/ChangeLog 2012-11-13 04:26:35 UTC (rev 134348)
@@ -1,3 +1,37 @@
+2012-11-12 Beth Dakin <[email protected]>
+
+ Zoomed-in scrolling is very slow when deviceScaleFactor > 1
+ https://bugs.webkit.org/show_bug.cgi?id=101787
+
+ Reviewed by Simon Fraser.
+
+ This patch adds a new member to the GraphicsContextState that tracks
+ whether or not fonts should be subpixel-quantized. We want to default
+ to sibpixel-quantizing, but we'll turn it off if we're scrolling
+ content that cannot be scrolled on the scrolling thread.
+
+ State has a new bool shouldSubpixelQuantizeFonts. It defaults to true
+ since normally we do want to quantize.
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::setShouldSubpixelQuantizeFonts):
+ (WebCore::GraphicsContext::shouldSubpixelQuantizeFonts):
+ * platform/graphics/GraphicsContext.h:
+ (WebCore::GraphicsContextState::GraphicsContextState):
+ (GraphicsContextState):
+ (GraphicsContext):
+
+ wkSetCGFontRenderingMode now takes a BOOL parameter which indicates
+ whether or not it should try to subpixel-quantize the fonts.
+ * platform/graphics/mac/FontMac.mm:
+ (WebCore::Font::drawGlyphs):
+ * platform/mac/WebCoreSystemInterface.h:
+ * platform/mac/WebCoreSystemInterface.mm:
+
+ Disable subpixel-quantization for overflow areas, subframes, and
+ content that is scrolling on the main thread.
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::paintLayerContents):
+
2012-11-12 Timothy Hatcher <[email protected]>
Expose InspectorFrontendClientLocal::setAttachedWindow as public.
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (134347 => 134348)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2012-11-13 04:05:18 UTC (rev 134347)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2012-11-13 04:26:35 UTC (rev 134348)
@@ -256,6 +256,16 @@
return m_state.shouldSmoothFonts;
}
+void GraphicsContext::setShouldSubpixelQuantizeFonts(bool b)
+{
+ m_state.shouldSubpixelQuantizeFonts = b;
+}
+
+bool GraphicsContext::shouldSubpixelQuantizeFonts() const
+{
+ return m_state.shouldSubpixelQuantizeFonts;
+}
+
const GraphicsContextState& GraphicsContext::state() const
{
return m_state;
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (134347 => 134348)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2012-11-13 04:05:18 UTC (rev 134347)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2012-11-13 04:26:35 UTC (rev 134348)
@@ -167,6 +167,7 @@
, compositeOperator(CompositeSourceOver)
, shouldAntialias(true)
, shouldSmoothFonts(true)
+ , shouldSubpixelQuantizeFonts(true)
, paintingDisabled(false)
, shadowsIgnoreTransforms(false)
#if USE(CG)
@@ -205,6 +206,7 @@
bool shouldAntialias : 1;
bool shouldSmoothFonts : 1;
+ bool shouldSubpixelQuantizeFonts : 1;
bool paintingDisabled : 1;
bool shadowsIgnoreTransforms : 1;
#if USE(CG)
@@ -257,6 +259,11 @@
void setShouldSmoothFonts(bool);
bool shouldSmoothFonts() const;
+ // Normally CG enables subpixel-quantization because it improves the performance of aligning glyphs.
+ // In some cases we have to disable to to ensure a high-quality output of the glyphs.
+ void setShouldSubpixelQuantizeFonts(bool);
+ bool shouldSubpixelQuantizeFonts() const;
+
const GraphicsContextState& state() const;
#if USE(CG)
Modified: trunk/Source/WebCore/platform/graphics/mac/FontMac.mm (134347 => 134348)
--- trunk/Source/WebCore/platform/graphics/mac/FontMac.mm 2012-11-13 04:05:18 UTC (rev 134347)
+++ trunk/Source/WebCore/platform/graphics/mac/FontMac.mm 2012-11-13 04:26:35 UTC (rev 134348)
@@ -211,7 +211,7 @@
matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 1, 0, 0));
CGContextSetTextMatrix(cgContext, matrix);
- wkSetCGFontRenderingMode(cgContext, drawFont);
+ wkSetCGFontRenderingMode(cgContext, drawFont, context->shouldSubpixelQuantizeFonts());
if (drawFont)
CGContextSetFontSize(cgContext, 1.0f);
else
Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h (134347 => 134348)
--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h 2012-11-13 04:05:18 UTC (rev 134347)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h 2012-11-13 04:26:35 UTC (rev 134348)
@@ -192,7 +192,7 @@
extern NSArray *(*wkQTGetSitesInMediaDownloadCache)();
extern void (*wkQTClearMediaDownloadCacheForSite)(NSString *site);
extern void (*wkQTClearMediaDownloadCache)();
-extern void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*);
+extern void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*, BOOL);
extern void (*wkSetDragImage)(NSImage*, NSPoint offset);
extern void (*wkSetNSURLConnectionDefersCallbacks)(NSURLConnection *, BOOL);
extern void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL);
Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm (134347 => 134348)
--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm 2012-11-13 04:05:18 UTC (rev 134347)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm 2012-11-13 04:26:35 UTC (rev 134348)
@@ -85,7 +85,7 @@
void (*wkQTClearMediaDownloadCacheForSite)(NSString *site);
void (*wkQTClearMediaDownloadCache)();
-void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*);
+void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*, BOOL);
void (*wkSetDragImage)(NSImage*, NSPoint offset);
void (*wkSetBaseCTM)(CGContextRef, CGAffineTransform);
void (*wkSetPatternPhaseInUserSpace)(CGContextRef, CGPoint point);
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (134347 => 134348)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2012-11-13 04:05:18 UTC (rev 134347)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2012-11-13 04:26:35 UTC (rev 134348)
@@ -90,6 +90,7 @@
#include "ScrollAnimator.h"
#include "Scrollbar.h"
#include "ScrollbarTheme.h"
+#include "ScrollingCoordinator.h"
#include "Settings.h"
#include "SourceGraphic.h"
#include "StylePropertySet.h"
@@ -3183,6 +3184,26 @@
// Ensure our lists are up-to-date.
updateLayerListsIfNeeded();
+ bool didQuantizeFonts = true;
+ bool scrollingOnMainThread = true;
+ Frame* frame = renderer()->frame();
+#if ENABLE(THREADED_SCROLLING)
+ if (frame) {
+ if (Page* page = frame->page()) {
+ if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
+ scrollingOnMainThread = scrollingCoordinator->shouldUpdateScrollLayerPositionOnMainThread();
+ }
+ }
+#endif
+
+ // FIXME: We shouldn't have to disable subpixel quantization for overflow clips or subframes once we scroll those
+ // things on the scrolling thread.
+ bool needToAdjustSubpixelQuantization = scrollingOnMainThread || (renderer()->hasOverflowClip() && !usesCompositedScrolling()) || (frame && frame->ownerElement());
+ if (needToAdjustSubpixelQuantization) {
+ didQuantizeFonts = context->shouldSubpixelQuantizeFonts();
+ context->setShouldSubpixelQuantizeFonts(false);
+ }
+
// Apply clip-path to context.
bool hasClipPath = false;
RenderStyle* style = renderer()->style();
@@ -3376,6 +3397,10 @@
m_usedTransparency = false;
}
+ // Re-set this to whatever it was before we painted the layer.
+ if (needToAdjustSubpixelQuantization)
+ context->setShouldSubpixelQuantizeFonts(didQuantizeFonts);
+
if (hasClipPath)
context->restore();
}
Modified: trunk/WebKitLibraries/ChangeLog (134347 => 134348)
--- trunk/WebKitLibraries/ChangeLog 2012-11-13 04:05:18 UTC (rev 134347)
+++ trunk/WebKitLibraries/ChangeLog 2012-11-13 04:26:35 UTC (rev 134348)
@@ -1,3 +1,15 @@
+2012-11-12 Beth Dakin <[email protected]>
+
+ Zoomed-in scrolling is very slow when deviceScaleFactor > 1
+ https://bugs.webkit.org/show_bug.cgi?id=101787
+
+ Reviewed by Simon Fraser.
+
+ wkSetCGFontRenderingMode now takes a BOOL parameter.
+ * WebKitSystemInterface.h:
+ * libWebKitSystemInterfaceLion.a:
+ * libWebKitSystemInterfaceMountainLion.a:
+
2012-11-08 Anders Carlsson <[email protected]>
Roll WebKitSystemInterface DEPS.
Modified: trunk/WebKitLibraries/WebKitSystemInterface.h (134347 => 134348)
--- trunk/WebKitLibraries/WebKitSystemInterface.h 2012-11-13 04:05:18 UTC (rev 134347)
+++ trunk/WebKitLibraries/WebKitSystemInterface.h 2012-11-13 04:26:35 UTC (rev 134348)
@@ -140,7 +140,7 @@
BOOL WKGetGlyphTransformedAdvances(CGFontRef, NSFont*, CGAffineTransform *m, ATSGlyphRef *glyph, CGSize *advance);
NSFont *WKGetFontInLanguageForRange(NSFont *font, NSString *string, NSRange range);
NSFont *WKGetFontInLanguageForCharacter(NSFont *font, UniChar ch);
-void WKSetCGFontRenderingMode(CGContextRef cgContext, NSFont *font);
+void WKSetCGFontRenderingMode(CGContextRef cgContext, NSFont *font, BOOL shouldSubpixelQuantize);
BOOL WKCGContextGetShouldSmoothFonts(CGContextRef cgContext);