summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_view_linux.cc
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-24 01:19:37 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-24 01:19:37 +0000
commit6e282c938d74f513dc5a92c2d96cfd955ac05d9b (patch)
treea44afca80ab807fda393132971c52c8edcdb6cf2 /chrome/renderer/render_view_linux.cc
parent8c2b005ffdc22c871638d0cfd356441741247bd5 (diff)
downloadchromium_src-6e282c938d74f513dc5a92c2d96cfd955ac05d9b.zip
chromium_src-6e282c938d74f513dc5a92c2d96cfd955ac05d9b.tar.gz
chromium_src-6e282c938d74f513dc5a92c2d96cfd955ac05d9b.tar.bz2
Linux: splice together RendererPreferences and SkFontHost
Dan Erat has been working down, plumbing the user's font settings from XSETTINGS in the UI thread of the browser to RendererPreferences in the renderer. At the same time, I've been working upwards: implementing subpixel rendering support in Skia and adding an interface to it in WebCore. This patch joins the two together. It adds an API surface to the WebKit API for configuring the font preferences and adds code to translate from RendererPreferences to that API. It's a little unfortunate that we need four sets of enums around the code base for things like the hinting level, but each is supposed to be self contained and adding a dependancy would much more grevious. BUG=12179 http://codereview.chromium.org/159152 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21493 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_view_linux.cc')
-rw-r--r--chrome/renderer/render_view_linux.cc94
1 files changed, 94 insertions, 0 deletions
diff --git a/chrome/renderer/render_view_linux.cc b/chrome/renderer/render_view_linux.cc
new file mode 100644
index 0000000..0c6375f
--- /dev/null
+++ b/chrome/renderer/render_view_linux.cc
@@ -0,0 +1,94 @@
+// Copyright (c) 2009 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 "chrome/renderer/render_view.h"
+
+#include "chrome/common/renderer_preferences.h"
+#include "webkit/api/public/linux/WebFontRendering.h"
+
+using WebKit::WebFontRendering;
+
+static SkPaint::Hinting RendererPreferencesToSkiaHinting(
+ RendererPreferencesHintingEnum hinting) {
+ switch (hinting) {
+ case RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT:
+ return SkPaint::kNormal_Hinting;
+ case RENDERER_PREFERENCES_HINTING_NONE:
+ return SkPaint::kNo_Hinting;
+ case RENDERER_PREFERENCES_HINTING_SLIGHT:
+ return SkPaint::kSlight_Hinting;
+ case RENDERER_PREFERENCES_HINTING_MEDIUM:
+ 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(
+ const RendererPreferences& prefs) {
+ return prefs.should_antialias_text;
+}
+
+static bool RendererPreferencesToSubpixelGlyphsFlag(
+ const RendererPreferences& prefs) {
+ if (prefs.subpixel_rendering !=
+ RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT &&
+ prefs.subpixel_rendering !=
+ RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE) {
+ return true;
+ }
+
+ return false;
+}
+
+void RenderView::UpdateFontRenderingFromRendererPrefs() {
+ const RendererPreferences& prefs = renderer_preferences_;
+ WebFontRendering::setHinting(
+ RendererPreferencesToSkiaHinting(prefs.hinting));
+ WebFontRendering::setLCDOrder(
+ RendererPreferencesToSkiaLCDOrder(prefs.subpixel_rendering));
+ WebFontRendering::setLCDOrientation(
+ RendererPreferencesToSkiaLCDOrientation(prefs.subpixel_rendering));
+ WebFontRendering::setAntiAlias(RendererPreferencesToAntiAliasFlag(prefs));
+ WebFontRendering::setSubpixelGlyphs(
+ RendererPreferencesToSubpixelGlyphsFlag(prefs));
+}