OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 } | 40 } |
41 | 41 |
42 // No explicit ClearType settings, default to RGB. | 42 // No explicit ClearType settings, default to RGB. |
43 return FontRenderParams::SUBPIXEL_RENDERING_RGB; | 43 return FontRenderParams::SUBPIXEL_RENDERING_RGB; |
44 } | 44 } |
45 | 45 |
46 // Caches font render params and updates them on system notifications. | 46 // Caches font render params and updates them on system notifications. |
47 class CachedFontRenderParams { | 47 class CachedFontRenderParams { |
48 public: | 48 public: |
49 static CachedFontRenderParams* GetInstance() { | 49 static CachedFontRenderParams* GetInstance() { |
50 return Singleton<CachedFontRenderParams>::get(); | 50 return base::Singleton<CachedFontRenderParams>::get(); |
51 } | 51 } |
52 | 52 |
53 const FontRenderParams& GetParams() { | 53 const FontRenderParams& GetParams() { |
54 if (params_) | 54 if (params_) |
55 return *params_; | 55 return *params_; |
56 | 56 |
57 params_.reset(new FontRenderParams()); | 57 params_.reset(new FontRenderParams()); |
58 params_->antialiasing = false; | 58 params_->antialiasing = false; |
59 params_->subpixel_positioning = false; | 59 params_->subpixel_positioning = false; |
60 params_->autohinter = false; | 60 params_->autohinter = false; |
(...skipping 13 matching lines...) Expand all Loading... |
74 params_->subpixel_rendering = GetSubpixelRenderingGeometry(); | 74 params_->subpixel_rendering = GetSubpixelRenderingGeometry(); |
75 } | 75 } |
76 } | 76 } |
77 singleton_hwnd_observer_.reset(new SingletonHwndObserver( | 77 singleton_hwnd_observer_.reset(new SingletonHwndObserver( |
78 base::Bind(&CachedFontRenderParams::OnWndProc, | 78 base::Bind(&CachedFontRenderParams::OnWndProc, |
79 base::Unretained(this)))); | 79 base::Unretained(this)))); |
80 return *params_; | 80 return *params_; |
81 } | 81 } |
82 | 82 |
83 private: | 83 private: |
84 friend struct DefaultSingletonTraits<CachedFontRenderParams>; | 84 friend struct base::DefaultSingletonTraits<CachedFontRenderParams>; |
85 | 85 |
86 CachedFontRenderParams() {} | 86 CachedFontRenderParams() {} |
87 ~CachedFontRenderParams() {} | 87 ~CachedFontRenderParams() {} |
88 | 88 |
89 void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { | 89 void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { |
90 if (message == WM_SETTINGCHANGE) { | 90 if (message == WM_SETTINGCHANGE) { |
91 params_.reset(); | 91 params_.reset(); |
92 singleton_hwnd_observer_.reset(nullptr); | 92 singleton_hwnd_observer_.reset(nullptr); |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 scoped_ptr<FontRenderParams> params_; | 96 scoped_ptr<FontRenderParams> params_; |
97 scoped_ptr<SingletonHwndObserver> singleton_hwnd_observer_; | 97 scoped_ptr<SingletonHwndObserver> singleton_hwnd_observer_; |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(CachedFontRenderParams); | 99 DISALLOW_COPY_AND_ASSIGN(CachedFontRenderParams); |
100 }; | 100 }; |
101 | 101 |
102 } // namespace | 102 } // namespace |
103 | 103 |
104 FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query, | 104 FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query, |
105 std::string* family_out) { | 105 std::string* family_out) { |
106 if (family_out) | 106 if (family_out) |
107 NOTIMPLEMENTED(); | 107 NOTIMPLEMENTED(); |
108 // Customized font rendering settings are not supported, only defaults. | 108 // Customized font rendering settings are not supported, only defaults. |
109 return CachedFontRenderParams::GetInstance()->GetParams(); | 109 return CachedFontRenderParams::GetInstance()->GetParams(); |
110 } | 110 } |
111 | 111 |
112 } // namespace gfx | 112 } // namespace gfx |
OLD | NEW |