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

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

Issue 854713003: More old files deletion. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix tryjobs? Created 5 years, 11 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
« no previous file with comments | « ui/gfx/font_render_params_mac.cc ('k') | ui/gfx/font_unittest.cc » ('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 2014 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(bool for_web_contents) {
23 if (params_)
24 return *params_;
25
26 params_.reset(new FontRenderParams());
27 params_->antialiasing = false;
28 params_->subpixel_positioning = false;
29 params_->autohinter = false;
30 params_->use_bitmaps = false;
31 params_->hinting = FontRenderParams::HINTING_MEDIUM;
32 params_->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE;
33
34 BOOL enabled = false;
35 if (SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &enabled, 0) && enabled) {
36 params_->antialiasing = true;
37 // Subpixel positioning is not yet implemented for UI. crbug.com/389649
38 params_->subpixel_positioning = for_web_contents;
39
40 UINT type = 0;
41 if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &type, 0) &&
42 type == FE_FONTSMOOTHINGCLEARTYPE) {
43 params_->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB;
44 }
45 }
46 gfx::SingletonHwnd::GetInstance()->AddObserver(this);
47 return *params_;
48 }
49
50 private:
51 friend struct DefaultSingletonTraits<CachedFontRenderParams>;
52
53 CachedFontRenderParams() {}
54 virtual ~CachedFontRenderParams() {
55 // Can't remove the SingletonHwnd observer here since SingletonHwnd may have
56 // been destroyed already (both singletons).
57 }
58
59 virtual void OnWndProc(HWND hwnd,
60 UINT message,
61 WPARAM wparam,
62 LPARAM lparam) override {
63 if (message == WM_SETTINGCHANGE) {
64 params_.reset();
65 gfx::SingletonHwnd::GetInstance()->RemoveObserver(this);
66 }
67 }
68
69 scoped_ptr<FontRenderParams> params_;
70
71 DISALLOW_COPY_AND_ASSIGN(CachedFontRenderParams);
72 };
73
74 } // namespace
75
76 FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
77 std::string* family_out) {
78 if (family_out)
79 NOTIMPLEMENTED();
80 // Customized font rendering settings are not supported, only defaults.
81 return CachedFontRenderParams::GetInstance()->GetParams(
82 query.for_web_contents);
83 }
84
85 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_render_params_mac.cc ('k') | ui/gfx/font_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698