Commit 667a78a3 authored by eae@chromium.org's avatar eae@chromium.org

[Linux] Enable subpixel text on high-dpi regardless of hinting

Expose deviceScaleFactor on GraphicsContext and use to selectively
enable subpixel text regardless of the system font hinting settings for
high-dpi systems.

BUG=373441
R=derat@chromium.org, tkent@chromium.org

Review URL: https://codereview.chromium.org/407553002

git-svn-id: svn://svn.chromium.org/blink/trunk@178485 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4ca6283b
......@@ -1809,7 +1809,7 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti
bool shouldPaintContent = m_hasVisibleContent && isSelfPaintingLayer && !isPaintingOverlayScrollbars;
float deviceScaleFactor = WebCore::deviceScaleFactor(renderer()->frame());
context->setUseHighResMarkers(deviceScaleFactor > 1.5f);
context->setDeviceScaleFactor(deviceScaleFactor);
GraphicsContext* transparencyLayerContext = context;
......
......@@ -35,6 +35,7 @@
#include "platform/LayoutTestSupport.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/fonts/harfbuzz/FontPlatformDataHarfBuzz.h"
#include "platform/graphics/GraphicsContext.h"
#include "public/platform/linux/WebFontInfo.h"
#include "public/platform/linux/WebFontRenderStyle.h"
#include "public/platform/linux/WebSandboxSupport.h"
......@@ -72,7 +73,8 @@ void FontPlatformData::setSubpixelRendering(bool useSubpixelRendering)
useSkiaSubpixelRendering = useSubpixelRendering;
}
void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext*) const
void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext* context)
const
{
paint->setAntiAlias(m_style.useAntiAlias);
paint->setHinting(static_cast<SkPaint::Hinting>(m_style.hintStyle));
......@@ -81,10 +83,13 @@ void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext*) const
if (m_style.useAntiAlias)
paint->setLCDRenderText(m_style.useSubpixelRendering);
// Do not enable subpixel text on low-dpi if full hinting is requested.
bool useSubpixelText = RuntimeEnabledFeatures::subpixelFontScalingEnabled()
&& context && (paint->getHinting() != SkPaint::kFull_Hinting
|| context->deviceScaleFactor() > 1.0f);
// TestRunner specifically toggles the subpixel positioning flag.
if (RuntimeEnabledFeatures::subpixelFontScalingEnabled()
&& paint->getHinting() != SkPaint::kFull_Hinting
&& !LayoutTestSupport::isRunningLayoutTest())
if (useSubpixelText && !LayoutTestSupport::isRunningLayoutTest())
paint->setSubpixelText(true);
else
paint->setSubpixelText(m_style.useSubpixelPositioning);
......
......@@ -123,9 +123,9 @@ GraphicsContext::GraphicsContext(SkCanvas* canvas, DisabledMode disableContextOr
, m_disableDestructionChecks(false)
#endif
, m_disabledState(disableContextOrPainting)
, m_deviceScaleFactor(1.0f)
, m_trackOpaqueRegion(false)
, m_trackTextRegion(false)
, m_useHighResMarker(false)
, m_updatingControlTints(false)
, m_accelerated(false)
, m_isCertainlyOpaque(true)
......@@ -725,7 +725,8 @@ void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& pt, float widt
if (contextDisabled())
return;
int deviceScaleFactor = m_useHighResMarker ? 2 : 1;
// Use 2x resources for a device scale factor of 1.5 or above.
int deviceScaleFactor = m_deviceScaleFactor > 1.5f ? 2 : 1;
// Create the pattern we'll use to draw the underline.
int index = style == DocumentMarkerGrammarLineStyle ? 1 : 0;
......
......@@ -197,9 +197,10 @@ public:
CompositeOperator compositeOperation() const { return immutableState()->compositeOperator(); }
blink::WebBlendMode blendModeOperation() const { return immutableState()->blendMode(); }
// Change the way document markers are rendered.
// Any deviceScaleFactor higher than 1.5 is enough to justify setting this flag.
void setUseHighResMarkers(bool isHighRes) { m_useHighResMarker = isHighRes; }
// Speicy the device scale factor which may change the way document markers
// and fonts are rendered.
void setDeviceScaleFactor(float factor) { m_deviceScaleFactor = factor; }
float deviceScaleFactor() const { return m_deviceScaleFactor; }
// If true we are (most likely) rendering to a web page and the
// canvas has been prepared with an opaque background. If false,
......@@ -513,12 +514,12 @@ private:
unsigned m_disabledState;
float m_deviceScaleFactor;
// Activation for the above region tracking features
bool m_trackOpaqueRegion : 1;
bool m_trackTextRegion : 1;
// Are we on a high DPI display? If so, spelling and grammar markers are larger.
bool m_useHighResMarker : 1;
// FIXME: Make this go away: crbug.com/236892
bool m_updatingControlTints : 1;
bool m_accelerated : 1;
......
......@@ -90,7 +90,7 @@ void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas*
GraphicsContext gc(canvas);
gc.setCertainlyOpaque(background == Opaque);
gc.applyDeviceScaleFactor(page->deviceScaleFactor());
gc.setUseHighResMarkers(page->deviceScaleFactor() > 1.5f);
gc.setDeviceScaleFactor(page->deviceScaleFactor());
IntRect dirtyRect(rect);
gc.save(); // Needed to save the canvas, not the GraphicsContext.
FrameView* view = mainFrameView(page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment