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

Side by Side Diff: ui/gfx/font_render_params_win.cc

Issue 385463002: Support FontRenderParams on Win; fix RenderTextHarfBuzz. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix header guards. Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | ui/gfx/font_smoothing_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gfx/font_render_params.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/singleton.h"
9 #include "ui/gfx/win/singleton_hwnd.h"
10
11 namespace gfx {
12
13 namespace {
14
15 // Caches font render params and updates them on system notifications.
16 class CachedFontRenderParams : public gfx::SingletonHwnd::Observer {
17 public:
18 static CachedFontRenderParams* GetInstance() {
19 return Singleton<CachedFontRenderParams>::get();
20 }
21
22 const FontRenderParams& GetParams() {
23 if (params_)
24 return *params_;
25
26 params_.reset(new FontRenderParams());
27 params_->antialiasing = false;
28 params_->subpixel_positioning = false;
29 params_->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE;
30
31 BOOL enabled = false;
32 if (SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &enabled, 0) && enabled) {
33 params_->antialiasing = true;
34 params_->subpixel_positioning = true;
35
36 UINT type = 0;
37 if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &type, 0) &&
38 type == FE_FONTSMOOTHINGCLEARTYPE) {
39 params_->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB;
40 }
41 }
42 gfx::SingletonHwnd::GetInstance()->AddObserver(this);
43 return *params_;
44 }
45
46 private:
47 friend struct DefaultSingletonTraits<CachedFontRenderParams>;
48
49 CachedFontRenderParams() {}
50 virtual ~CachedFontRenderParams() {
51 // Can't remove the SingletonHwnd observer here since SingletonHwnd may have
52 // been destroyed already (both singletons).
53 }
54
55 virtual void OnWndProc(HWND hwnd,
56 UINT message,
57 WPARAM wparam,
58 LPARAM lparam) OVERRIDE {
59 if (message == WM_SETTINGCHANGE) {
60 params_.reset();
61 gfx::SingletonHwnd::GetInstance()->RemoveObserver(this);
Alexei Svitkine (slow) 2014/07/14 15:00:53 Wait, what if the settings change again? Wouldn't
ckocagil 2014/07/14 16:13:47 There's no need to invalidate the already invalida
Alexei Svitkine (slow) 2014/07/14 16:32:21 Ah, got it!
62 }
63 }
64
65 scoped_ptr<FontRenderParams> params_;
66
67 DISALLOW_COPY_AND_ASSIGN(CachedFontRenderParams);
68 };
69
70 } // namespace
71
72 const FontRenderParams& GetDefaultFontRenderParams() {
73 return CachedFontRenderParams::GetInstance()->GetParams();
74 }
75
76 const FontRenderParams& GetDefaultWebKitFontRenderParams() {
77 return GetDefaultFontRenderParams();
78 }
79
80 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | ui/gfx/font_smoothing_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698