Commit 36264605 authored by derat@chromium.org's avatar derat@chromium.org

linux: Pass subpixel positioning setting to WebKit.

This makes us configure renderers appropriately based on
--enable-text-subpixel-positioning.  It also updates
SandboxIPCProcess to pass the flag through so the results
returned by its calls to WebFontInfo::renderStyleForStrike()
will reflect the setting.

BUG=125066
TEST=manual: both regular and web fonts within the renderer use subpixel positioning when --enable-text-subpixel-positioning is set


Review URL: https://chromiumcodereview.appspot.com/10540038

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141246 0039d316-1c4b-4281-b951-d872f2087c98
parent b56ccebe
......@@ -12,6 +12,9 @@
#if defined(TOOLKIT_GTK)
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
#elif defined(USE_ASH)
#include "base/command_line.h"
#include "ui/base/ui_base_switches.h"
#endif
namespace renderer_preferences_util {
......@@ -36,6 +39,12 @@ void UpdateFromSystemSettings(
prefs->inactive_selection_fg_color =
theme_service->get_inactive_selection_fg_color();
#elif defined(USE_ASH)
// TODO(derat): This code and GetCairoFontOptions() from ui/gfx/pango_util.cc
// should get their settings from the same place.
prefs->use_subpixel_positioning =
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableTextSubpixelPositioning);
// This color is 0x544d90fe modulated with 0xffffff.
prefs->active_selection_bg_color = SkColorSetRGB(0xCB, 0xE4, 0xFA);
prefs->active_selection_fg_color = SK_ColorBLACK;
......
......@@ -34,6 +34,7 @@
#include "third_party/npapi/bindings/npapi_extensions.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontInfo.h"
#include "ui/base/ui_base_switches.h"
using WebKit::WebCString;
using WebKit::WebFontInfo;
......@@ -62,6 +63,12 @@ class SandboxIPCProcess {
sandbox_cmd_.push_back(sandbox_cmd);
sandbox_cmd_.push_back(base::kFindInodeSwitch);
}
// FontConfig doesn't provide a standard property to control subpixel
// positioning, so we pass a UI flag through to WebKit.
WebFontInfo::setSubpixelPositioning(
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableTextSubpixelPositioning));
}
~SandboxIPCProcess();
......@@ -300,7 +307,8 @@ class SandboxIPCProcess {
reply.WriteInt(style.useHinting);
reply.WriteInt(style.hintStyle);
reply.WriteInt(style.useAntiAlias);
reply.WriteInt(style.useSubpixel);
reply.WriteInt(style.useSubpixelRendering);
reply.WriteInt(style.useSubpixelPositioning);
SendRendererReply(fds, reply, -1);
}
......
......@@ -65,19 +65,22 @@ void GetRenderStyleForStrike(const char* family, int sizeAndStyle,
Pickle reply(reinterpret_cast<char*>(buf), n);
PickleIterator pickle_iter(reply);
int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias, useSubpixel;
int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias;
int useSubpixelRendering, useSubpixelPositioning;
if (reply.ReadInt(&pickle_iter, &useBitmaps) &&
reply.ReadInt(&pickle_iter, &useAutoHint) &&
reply.ReadInt(&pickle_iter, &useHinting) &&
reply.ReadInt(&pickle_iter, &hintStyle) &&
reply.ReadInt(&pickle_iter, &useAntiAlias) &&
reply.ReadInt(&pickle_iter, &useSubpixel)) {
reply.ReadInt(&pickle_iter, &useSubpixelRendering) &&
reply.ReadInt(&pickle_iter, &useSubpixelPositioning)) {
out->useBitmaps = useBitmaps;
out->useAutoHint = useAutoHint;
out->useHinting = useHinting;
out->hintStyle = hintStyle;
out->useAntiAlias = useAntiAlias;
out->useSubpixel = useSubpixel;
out->useSubpixelRendering = useSubpixelRendering;
out->useSubpixelPositioning = useSubpixelPositioning;
}
}
......
......@@ -296,6 +296,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::RendererPreferences)
IPC_STRUCT_TRAITS_MEMBER(should_antialias_text)
IPC_STRUCT_TRAITS_MEMBER(hinting)
IPC_STRUCT_TRAITS_MEMBER(subpixel_rendering)
IPC_STRUCT_TRAITS_MEMBER(use_subpixel_positioning)
IPC_STRUCT_TRAITS_MEMBER(focus_ring_color)
IPC_STRUCT_TRAITS_MEMBER(thumb_active_color)
IPC_STRUCT_TRAITS_MEMBER(thumb_inactive_color)
......
......@@ -12,6 +12,7 @@ RendererPreferences::RendererPreferences()
hinting(RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT),
subpixel_rendering(
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT),
use_subpixel_positioning(false),
focus_ring_color(0),
thumb_active_color(0),
thumb_inactive_color(0),
......
......@@ -54,6 +54,10 @@ struct CONTENT_EXPORT RendererPreferences {
// Currently only used by Linux.
RendererPreferencesSubpixelRenderingEnum subpixel_rendering;
// Whether subpixel positioning should be used, permitting fractional X
// positions for glyphs. Currently only used by Linux.
bool use_subpixel_positioning;
// The color of the focus ring. Currently only used on Linux.
SkColor focus_ring_color;
......
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/render_view_impl.h"
#include "content/public/common/renderer_preferences.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRendering.h"
using WebKit::WebFontInfo;
using WebKit::WebFontRendering;
static SkPaint::Hinting RendererPreferencesToSkiaHinting(
......@@ -86,7 +88,7 @@ static bool RendererPreferencesToAntiAliasFlag(
return prefs.should_antialias_text;
}
static bool RendererPreferencesToSubpixelGlyphsFlag(
static bool RendererPreferencesToSubpixelRenderingFlag(
const content::RendererPreferences& prefs) {
if (prefs.subpixel_rendering !=
content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT &&
......@@ -94,18 +96,19 @@ static bool RendererPreferencesToSubpixelGlyphsFlag(
content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE) {
return true;
}
return false;
}
void RenderViewImpl::UpdateFontRenderingFromRendererPrefs() {
const content::RendererPreferences& prefs = renderer_preferences_;
WebFontRendering::setHinting(RendererPreferencesToSkiaHinting(prefs));
WebFontRendering::setLCDOrder(RendererPreferencesToSkiaLCDOrder(
prefs.subpixel_rendering));
WebFontRendering::setLCDOrientation(RendererPreferencesToSkiaLCDOrientation(
prefs.subpixel_rendering));
WebFontRendering::setLCDOrder(
RendererPreferencesToSkiaLCDOrder(prefs.subpixel_rendering));
WebFontRendering::setLCDOrientation(
RendererPreferencesToSkiaLCDOrientation(prefs.subpixel_rendering));
WebFontRendering::setAntiAlias(RendererPreferencesToAntiAliasFlag(prefs));
WebFontRendering::setSubpixelGlyphs(RendererPreferencesToSubpixelGlyphsFlag(
prefs));
WebFontRendering::setSubpixelRendering(
RendererPreferencesToSubpixelRenderingFlag(prefs));
WebFontRendering::setSubpixelPositioning(prefs.use_subpixel_positioning);
WebFontInfo::setSubpixelPositioning(prefs.use_subpixel_positioning);
}
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