Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Unified Diff: ui/gfx/font_render_params_win.cc

Issue 1021643002: Retrieve and pass subpixel lcd geometry on windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ws Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/font_render_params_win.cc
diff --git a/ui/gfx/font_render_params_win.cc b/ui/gfx/font_render_params_win.cc
index 9f8409c4eb146996fe2c2714819401e76bb6c848..7f359211acdf02824cebf1f570b524d1666a0e6c 100644
--- a/ui/gfx/font_render_params_win.cc
+++ b/ui/gfx/font_render_params_win.cc
@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/gfx/font_render_params.h"
-
+#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
+#include "base/win/registry.h"
+#include "ui/gfx/font_render_params.h"
#include "ui/gfx/win/direct_write.h"
#include "ui/gfx/win/singleton_hwnd.h"
@@ -13,6 +14,32 @@ namespace gfx {
namespace {
+FontRenderParams::SubpixelRendering GetSubpixelRenderingGeometry() {
+ DISPLAY_DEVICE display_device = {sizeof(DISPLAY_DEVICE), 0};
+ for (int i = 0; EnumDisplayDevices(nullptr, i, &display_device, 0); ++i) {
+ // TODO(scottmg): We only support the primary device currently.
+ if (display_device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
+ base::FilePath trimmed =
+ base::FilePath(display_device.DeviceName).BaseName();
+ base::win::RegKey key(
+ HKEY_LOCAL_MACHINE,
+ (L"SOFTWARE\\Microsoft\\Avalon.Graphics\\" + trimmed.value()).c_str(),
msw 2015/03/26 20:41:25 Hmm, I wonder why I don't have "Avalon.Graphics" i
scottmg 2015/03/26 21:16:17 Oh, good catch. I just confirmed on a clean Win7 V
+ KEY_READ);
+ DWORD pixel_structure;
+ if (key.ReadValueDW(L"PixelStructure", &pixel_structure) ==
+ ERROR_SUCCESS) {
+ if (pixel_structure == 1)
+ return FontRenderParams::SUBPIXEL_RENDERING_RGB;
+ else if (pixel_structure == 2)
msw 2015/03/26 20:41:25 nit: no else after return.
scottmg 2015/03/26 21:16:17 Done.
+ return FontRenderParams::SUBPIXEL_RENDERING_BGR;
+ }
msw 2015/03/26 20:41:25 nit: can you break the loop of enumerating devices
scottmg 2015/03/26 21:16:17 Done.
+ }
+ }
+
+ // ClearType is not enabled, or retrieval failed.
msw 2015/03/26 20:41:25 nit: I have ClearType on but don't have this key..
scottmg 2015/03/26 21:16:17 Done.
+ return FontRenderParams::SUBPIXEL_RENDERING_NONE;
+}
+
// Caches font render params and updates them on system notifications.
class CachedFontRenderParams : public gfx::SingletonHwnd::Observer {
public:
@@ -41,7 +68,7 @@ class CachedFontRenderParams : public gfx::SingletonHwnd::Observer {
UINT type = 0;
if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &type, 0) &&
type == FE_FONTSMOOTHINGCLEARTYPE) {
- params_->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB;
+ params_->subpixel_rendering = GetSubpixelRenderingGeometry();
}
}
gfx::SingletonHwnd::GetInstance()->AddObserver(this);

Powered by Google App Engine
This is Rietveld 408576698