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

content: Remove RendererPreferences font-rendering enums.

Make the RendererPreferences message struct use enums from
gfx::FontRenderParams instead of defining its own.

This also drops the SYSTEM_DEFAULT values for hinting and
subpixel rendering. They weren't getting used anywhere.

BUG=393243

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285145 0039d316-1c4b-4281-b951-d872f2087c98
parent 7685f64a
...@@ -29,46 +29,6 @@ namespace android_webview { ...@@ -29,46 +29,6 @@ namespace android_webview {
namespace { namespace {
// TODO(boliu): Deduplicate with chrome/ code.
content::RendererPreferencesHintingEnum GetRendererPreferencesHintingEnum(
gfx::FontRenderParams::Hinting hinting) {
switch (hinting) {
case gfx::FontRenderParams::HINTING_NONE:
return content::RENDERER_PREFERENCES_HINTING_NONE;
case gfx::FontRenderParams::HINTING_SLIGHT:
return content::RENDERER_PREFERENCES_HINTING_SLIGHT;
case gfx::FontRenderParams::HINTING_MEDIUM:
return content::RENDERER_PREFERENCES_HINTING_MEDIUM;
case gfx::FontRenderParams::HINTING_FULL:
return content::RENDERER_PREFERENCES_HINTING_FULL;
default:
NOTREACHED() << "Unhandled hinting style " << hinting;
return content::RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT;
}
}
// TODO(boliu): Deduplicate with chrome/ code.
content::RendererPreferencesSubpixelRenderingEnum
GetRendererPreferencesSubpixelRenderingEnum(
gfx::FontRenderParams::SubpixelRendering subpixel_rendering) {
switch (subpixel_rendering) {
case gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE:
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_RGB:
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR:
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB:
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR:
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR;
default:
NOTREACHED() << "Unhandled subpixel rendering style "
<< subpixel_rendering;
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT;
}
}
void PopulateFixedRendererPreferences(RendererPreferences* prefs) { void PopulateFixedRendererPreferences(RendererPreferences* prefs) {
prefs->tap_multiple_targets_strategy = prefs->tap_multiple_targets_strategy =
content::TAP_MULTIPLE_TARGETS_STRATEGY_NONE; content::TAP_MULTIPLE_TARGETS_STRATEGY_NONE;
...@@ -77,11 +37,10 @@ void PopulateFixedRendererPreferences(RendererPreferences* prefs) { ...@@ -77,11 +37,10 @@ void PopulateFixedRendererPreferences(RendererPreferences* prefs) {
const gfx::FontRenderParams& params = gfx::GetDefaultWebKitFontRenderParams(); const gfx::FontRenderParams& params = gfx::GetDefaultWebKitFontRenderParams();
prefs->should_antialias_text = params.antialiasing; prefs->should_antialias_text = params.antialiasing;
prefs->use_subpixel_positioning = params.subpixel_positioning; prefs->use_subpixel_positioning = params.subpixel_positioning;
prefs->hinting = GetRendererPreferencesHintingEnum(params.hinting); prefs->hinting = params.hinting;
prefs->use_autohinter = params.autohinter; prefs->use_autohinter = params.autohinter;
prefs->use_bitmaps = params.use_bitmaps; prefs->use_bitmaps = params.use_bitmaps;
prefs->subpixel_rendering = prefs->subpixel_rendering = params.subpixel_rendering;
GetRendererPreferencesSubpixelRenderingEnum(params.subpixel_rendering);
} }
void PopulateFixedWebPreferences(WebPreferences* web_prefs) { void PopulateFixedWebPreferences(WebPreferences* web_prefs) {
......
...@@ -26,50 +26,6 @@ ...@@ -26,50 +26,6 @@
namespace renderer_preferences_util { namespace renderer_preferences_util {
namespace {
#if defined(OS_LINUX) || defined(OS_ANDROID)
content::RendererPreferencesHintingEnum GetRendererPreferencesHintingEnum(
gfx::FontRenderParams::Hinting hinting) {
switch (hinting) {
case gfx::FontRenderParams::HINTING_NONE:
return content::RENDERER_PREFERENCES_HINTING_NONE;
case gfx::FontRenderParams::HINTING_SLIGHT:
return content::RENDERER_PREFERENCES_HINTING_SLIGHT;
case gfx::FontRenderParams::HINTING_MEDIUM:
return content::RENDERER_PREFERENCES_HINTING_MEDIUM;
case gfx::FontRenderParams::HINTING_FULL:
return content::RENDERER_PREFERENCES_HINTING_FULL;
default:
NOTREACHED() << "Unhandled hinting style " << hinting;
return content::RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT;
}
}
content::RendererPreferencesSubpixelRenderingEnum
GetRendererPreferencesSubpixelRenderingEnum(
gfx::FontRenderParams::SubpixelRendering subpixel_rendering) {
switch (subpixel_rendering) {
case gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE:
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_RGB:
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR:
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB:
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR:
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR;
default:
NOTREACHED() << "Unhandled subpixel rendering style "
<< subpixel_rendering;
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT;
}
}
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
} // namespace
void UpdateFromSystemSettings( void UpdateFromSystemSettings(
content::RendererPreferences* prefs, Profile* profile) { content::RendererPreferences* prefs, Profile* profile) {
const PrefService* pref_service = profile->GetPrefs(); const PrefService* pref_service = profile->GetPrefs();
...@@ -134,11 +90,10 @@ void UpdateFromSystemSettings( ...@@ -134,11 +90,10 @@ void UpdateFromSystemSettings(
const gfx::FontRenderParams& params = gfx::GetDefaultWebKitFontRenderParams(); const gfx::FontRenderParams& params = gfx::GetDefaultWebKitFontRenderParams();
prefs->should_antialias_text = params.antialiasing; prefs->should_antialias_text = params.antialiasing;
prefs->use_subpixel_positioning = params.subpixel_positioning; prefs->use_subpixel_positioning = params.subpixel_positioning;
prefs->hinting = GetRendererPreferencesHintingEnum(params.hinting); prefs->hinting = params.hinting;
prefs->use_autohinter = params.autohinter; prefs->use_autohinter = params.autohinter;
prefs->use_bitmaps = params.use_bitmaps; prefs->use_bitmaps = params.use_bitmaps;
prefs->subpixel_rendering = prefs->subpixel_rendering = params.subpixel_rendering;
GetRendererPreferencesSubpixelRenderingEnum(params.subpixel_rendering);
#endif #endif
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
......
...@@ -79,8 +79,8 @@ IPC_ENUM_TRAITS(content::FileChooserParams::Mode) ...@@ -79,8 +79,8 @@ IPC_ENUM_TRAITS(content::FileChooserParams::Mode)
IPC_ENUM_TRAITS(content::MenuItem::Type) IPC_ENUM_TRAITS(content::MenuItem::Type)
IPC_ENUM_TRAITS(content::NavigationGesture) IPC_ENUM_TRAITS(content::NavigationGesture)
IPC_ENUM_TRAITS(content::PageZoom) IPC_ENUM_TRAITS(content::PageZoom)
IPC_ENUM_TRAITS(content::RendererPreferencesHintingEnum) IPC_ENUM_TRAITS(gfx::FontRenderParams::Hinting)
IPC_ENUM_TRAITS(content::RendererPreferencesSubpixelRenderingEnum) IPC_ENUM_TRAITS(gfx::FontRenderParams::SubpixelRendering)
IPC_ENUM_TRAITS_MAX_VALUE(content::TapMultipleTargetsStrategy, IPC_ENUM_TRAITS_MAX_VALUE(content::TapMultipleTargetsStrategy,
content::TAP_MULTIPLE_TARGETS_STRATEGY_MAX) content::TAP_MULTIPLE_TARGETS_STRATEGY_MAX)
IPC_ENUM_TRAITS(content::StopFindAction) IPC_ENUM_TRAITS(content::StopFindAction)
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "content/public/common/renderer_preferences.h" #include "content/public/common/renderer_preferences.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/font_render_params.h"
namespace { namespace {
// The touchpad / touchscreen fling profiles are a matched set // The touchpad / touchscreen fling profiles are a matched set
...@@ -21,12 +22,11 @@ namespace content { ...@@ -21,12 +22,11 @@ namespace content {
RendererPreferences::RendererPreferences() RendererPreferences::RendererPreferences()
: can_accept_load_drops(true), : can_accept_load_drops(true),
should_antialias_text(true), should_antialias_text(true),
hinting(RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT), hinting(gfx::FontRenderParams::HINTING_MEDIUM),
use_autohinter(false), use_autohinter(false),
use_bitmaps(false), use_bitmaps(false),
subpixel_rendering( subpixel_rendering(gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE),
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT), use_subpixel_positioning(true),
use_subpixel_positioning(false),
focus_ring_color(SkColorSetARGB(255, 229, 151, 0)), focus_ring_color(SkColorSetARGB(255, 229, 151, 0)),
thumb_active_color(SkColorSetRGB(244, 244, 244)), thumb_active_color(SkColorSetRGB(244, 244, 244)),
thumb_inactive_color(SkColorSetRGB(234, 234, 234)), thumb_inactive_color(SkColorSetRGB(234, 234, 234)),
......
...@@ -17,26 +17,10 @@ ...@@ -17,26 +17,10 @@
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/font_render_params.h"
namespace content { namespace content {
enum RendererPreferencesHintingEnum {
RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT = 0,
RENDERER_PREFERENCES_HINTING_NONE,
RENDERER_PREFERENCES_HINTING_SLIGHT,
RENDERER_PREFERENCES_HINTING_MEDIUM,
RENDERER_PREFERENCES_HINTING_FULL,
};
enum RendererPreferencesSubpixelRenderingEnum {
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT = 0,
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE,
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB,
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR,
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB,
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR,
};
enum TapMultipleTargetsStrategy { enum TapMultipleTargetsStrategy {
TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM = 0, TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM = 0,
TAP_MULTIPLE_TARGETS_STRATEGY_POPUP, TAP_MULTIPLE_TARGETS_STRATEGY_POPUP,
...@@ -59,7 +43,7 @@ struct CONTENT_EXPORT RendererPreferences { ...@@ -59,7 +43,7 @@ struct CONTENT_EXPORT RendererPreferences {
// The level of hinting to use when rendering text. // The level of hinting to use when rendering text.
// Currently only used by Linux. // Currently only used by Linux.
RendererPreferencesHintingEnum hinting; gfx::FontRenderParams::Hinting hinting;
// Whether auto hinter should be used. Currently only used by Linux. // Whether auto hinter should be used. Currently only used by Linux.
bool use_autohinter; bool use_autohinter;
...@@ -70,7 +54,7 @@ struct CONTENT_EXPORT RendererPreferences { ...@@ -70,7 +54,7 @@ struct CONTENT_EXPORT RendererPreferences {
// The type of subpixel rendering to use for text. // The type of subpixel rendering to use for text.
// Currently only used by Linux. // Currently only used by Linux.
RendererPreferencesSubpixelRenderingEnum subpixel_rendering; gfx::FontRenderParams::SubpixelRendering subpixel_rendering;
// Whether subpixel positioning should be used, permitting fractional X // Whether subpixel positioning should be used, permitting fractional X
// positions for glyphs. Currently only used by Linux. // positions for glyphs. Currently only used by Linux.
......
...@@ -11,19 +11,20 @@ using blink::WebFontRendering; ...@@ -11,19 +11,20 @@ using blink::WebFontRendering;
namespace content { namespace content {
static SkPaint::Hinting RendererPreferencesToSkiaHinting( namespace {
SkPaint::Hinting RendererPreferencesToSkiaHinting(
const RendererPreferences& prefs) { const RendererPreferences& prefs) {
if (!prefs.should_antialias_text) { if (!prefs.should_antialias_text) {
// When anti-aliasing is off, GTK maps all non-zero hinting settings to // When anti-aliasing is off, GTK maps all non-zero hinting settings to
// 'Normal' hinting so we do the same. Otherwise, folks who have 'Slight' // 'Normal' hinting so we do the same. Otherwise, folks who have 'Slight'
// hinting selected will see readable text in everything expect Chromium. // hinting selected will see readable text in everything expect Chromium.
switch (prefs.hinting) { switch (prefs.hinting) {
case RENDERER_PREFERENCES_HINTING_NONE: case gfx::FontRenderParams::HINTING_NONE:
return SkPaint::kNo_Hinting; return SkPaint::kNo_Hinting;
case RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT: case gfx::FontRenderParams::HINTING_SLIGHT:
case RENDERER_PREFERENCES_HINTING_SLIGHT: case gfx::FontRenderParams::HINTING_MEDIUM:
case RENDERER_PREFERENCES_HINTING_MEDIUM: case gfx::FontRenderParams::HINTING_FULL:
case RENDERER_PREFERENCES_HINTING_FULL:
return SkPaint::kNormal_Hinting; return SkPaint::kNormal_Hinting;
default: default:
NOTREACHED(); NOTREACHED();
...@@ -32,85 +33,62 @@ static SkPaint::Hinting RendererPreferencesToSkiaHinting( ...@@ -32,85 +33,62 @@ static SkPaint::Hinting RendererPreferencesToSkiaHinting(
} }
switch (prefs.hinting) { switch (prefs.hinting) {
case RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT: case gfx::FontRenderParams::HINTING_NONE: return SkPaint::kNo_Hinting;
return SkPaint::kNormal_Hinting; case gfx::FontRenderParams::HINTING_SLIGHT: return SkPaint::kSlight_Hinting;
case RENDERER_PREFERENCES_HINTING_NONE: case gfx::FontRenderParams::HINTING_MEDIUM: return SkPaint::kNormal_Hinting;
return SkPaint::kNo_Hinting; case gfx::FontRenderParams::HINTING_FULL: return SkPaint::kFull_Hinting;
case RENDERER_PREFERENCES_HINTING_SLIGHT: default:
return SkPaint::kSlight_Hinting; NOTREACHED();
case RENDERER_PREFERENCES_HINTING_MEDIUM: return SkPaint::kNormal_Hinting;
return SkPaint::kNormal_Hinting; }
case RENDERER_PREFERENCES_HINTING_FULL:
return SkPaint::kFull_Hinting;
default:
NOTREACHED();
return SkPaint::kNormal_Hinting;
}
}
static SkFontHost::LCDOrder RendererPreferencesToSkiaLCDOrder(
RendererPreferencesSubpixelRenderingEnum subpixel) {
switch (subpixel) {
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT:
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE:
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB:
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB:
return SkFontHost::kRGB_LCDOrder;
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR:
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR:
return SkFontHost::kBGR_LCDOrder;
default:
NOTREACHED();
return SkFontHost::kRGB_LCDOrder;
}
}
static SkFontHost::LCDOrientation
RendererPreferencesToSkiaLCDOrientation(
RendererPreferencesSubpixelRenderingEnum subpixel) {
switch (subpixel) {
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT:
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE:
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB:
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR:
return SkFontHost::kHorizontal_LCDOrientation;
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB:
case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR:
return SkFontHost::kVertical_LCDOrientation;
default:
NOTREACHED();
return SkFontHost::kHorizontal_LCDOrientation;
}
} }
static bool RendererPreferencesToAntiAliasFlag( SkFontHost::LCDOrder RendererPreferencesToSkiaLCDOrder(
const RendererPreferences& prefs) { const RendererPreferences& prefs) {
return prefs.should_antialias_text; switch (prefs.subpixel_rendering) {
case gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE:
case gfx::FontRenderParams::SUBPIXEL_RENDERING_RGB:
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB:
return SkFontHost::kRGB_LCDOrder;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR:
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR:
return SkFontHost::kBGR_LCDOrder;
default:
NOTREACHED();
return SkFontHost::kRGB_LCDOrder;
}
} }
static bool RendererPreferencesToSubpixelRenderingFlag( SkFontHost::LCDOrientation RendererPreferencesToSkiaLCDOrientation(
const RendererPreferences& prefs) { const RendererPreferences& prefs) {
if (prefs.subpixel_rendering != switch (prefs.subpixel_rendering) {
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT && case gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE:
prefs.subpixel_rendering != case gfx::FontRenderParams::SUBPIXEL_RENDERING_RGB:
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE) { case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR:
return true; return SkFontHost::kHorizontal_LCDOrientation;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB:
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR:
return SkFontHost::kVertical_LCDOrientation;
default:
NOTREACHED();
return SkFontHost::kHorizontal_LCDOrientation;
} }
return false;
} }
} // namespace
void RenderViewImpl::UpdateFontRenderingFromRendererPrefs() { void RenderViewImpl::UpdateFontRenderingFromRendererPrefs() {
const RendererPreferences& prefs = renderer_preferences_; const RendererPreferences& prefs = renderer_preferences_;
WebFontRendering::setHinting(RendererPreferencesToSkiaHinting(prefs)); WebFontRendering::setHinting(RendererPreferencesToSkiaHinting(prefs));
WebFontRendering::setAutoHint(prefs.use_autohinter); WebFontRendering::setAutoHint(prefs.use_autohinter);
WebFontRendering::setUseBitmaps(prefs.use_bitmaps); WebFontRendering::setUseBitmaps(prefs.use_bitmaps);
WebFontRendering::setLCDOrder( WebFontRendering::setLCDOrder(RendererPreferencesToSkiaLCDOrder(prefs));
RendererPreferencesToSkiaLCDOrder(prefs.subpixel_rendering));
WebFontRendering::setLCDOrientation( WebFontRendering::setLCDOrientation(
RendererPreferencesToSkiaLCDOrientation(prefs.subpixel_rendering)); RendererPreferencesToSkiaLCDOrientation(prefs));
WebFontRendering::setAntiAlias(RendererPreferencesToAntiAliasFlag(prefs)); WebFontRendering::setAntiAlias(prefs.should_antialias_text);
WebFontRendering::setSubpixelRendering( WebFontRendering::setSubpixelRendering(
RendererPreferencesToSubpixelRenderingFlag(prefs)); prefs.subpixel_rendering !=
gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE);
WebFontRendering::setSubpixelPositioning(prefs.use_subpixel_positioning); WebFontRendering::setSubpixelPositioning(prefs.use_subpixel_positioning);
} }
......
...@@ -9,10 +9,10 @@ namespace gfx { ...@@ -9,10 +9,10 @@ namespace gfx {
FontRenderParams::FontRenderParams() FontRenderParams::FontRenderParams()
: antialiasing(true), : antialiasing(true),
subpixel_positioning(true), subpixel_positioning(true),
autohinter(true), autohinter(false),
use_bitmaps(true), use_bitmaps(false),
hinting(HINTING_SLIGHT), hinting(HINTING_MEDIUM),
subpixel_rendering(SUBPIXEL_RENDERING_RGB) { subpixel_rendering(SUBPIXEL_RENDERING_NONE) {
} }
FontRenderParams::~FontRenderParams() {} FontRenderParams::~FontRenderParams() {}
......
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