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

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

Issue 785763002: Disable subpixel positioning if DirectWrite isn't initialized (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years 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 | « no previous file | ui/gfx/render_text_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
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 "ui/gfx/font_render_params.h" 5 #include "ui/gfx/font_render_params.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "ui/gfx/win/direct_write.h"
9 #include "ui/gfx/win/singleton_hwnd.h" 10 #include "ui/gfx/win/singleton_hwnd.h"
10 11
11 namespace gfx { 12 namespace gfx {
12 13
13 namespace { 14 namespace {
14 15
15 // Caches font render params and updates them on system notifications. 16 // Caches font render params and updates them on system notifications.
16 class CachedFontRenderParams : public gfx::SingletonHwnd::Observer { 17 class CachedFontRenderParams : public gfx::SingletonHwnd::Observer {
17 public: 18 public:
18 static CachedFontRenderParams* GetInstance() { 19 static CachedFontRenderParams* GetInstance() {
19 return Singleton<CachedFontRenderParams>::get(); 20 return Singleton<CachedFontRenderParams>::get();
20 } 21 }
21 22
22 const FontRenderParams& GetParams() { 23 const FontRenderParams& GetParams() {
23 if (params_) 24 if (params_)
24 return *params_; 25 return *params_;
25 26
26 params_.reset(new FontRenderParams()); 27 params_.reset(new FontRenderParams());
27 params_->antialiasing = false; 28 params_->antialiasing = false;
28 params_->subpixel_positioning = false; 29 params_->subpixel_positioning = false;
29 params_->autohinter = false; 30 params_->autohinter = false;
30 params_->use_bitmaps = false; 31 params_->use_bitmaps = false;
31 params_->hinting = FontRenderParams::HINTING_MEDIUM; 32 params_->hinting = FontRenderParams::HINTING_MEDIUM;
32 params_->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE; 33 params_->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE;
33 34
34 BOOL enabled = false; 35 BOOL enabled = false;
35 if (SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &enabled, 0) && enabled) { 36 if (SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &enabled, 0) && enabled) {
36 params_->antialiasing = true; 37 params_->antialiasing = true;
37 params_->subpixel_positioning = true; 38 // GDI does not support subpixel positioning.
39 params_->subpixel_positioning = win::IsDirectWriteEnabled();
38 40
39 UINT type = 0; 41 UINT type = 0;
40 if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &type, 0) && 42 if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &type, 0) &&
41 type == FE_FONTSMOOTHINGCLEARTYPE) { 43 type == FE_FONTSMOOTHINGCLEARTYPE) {
42 params_->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB; 44 params_->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB;
43 } 45 }
44 } 46 }
45 gfx::SingletonHwnd::GetInstance()->AddObserver(this); 47 gfx::SingletonHwnd::GetInstance()->AddObserver(this);
46 return *params_; 48 return *params_;
47 } 49 }
(...skipping 26 matching lines...) Expand all
74 76
75 FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query, 77 FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
76 std::string* family_out) { 78 std::string* family_out) {
77 if (family_out) 79 if (family_out)
78 NOTIMPLEMENTED(); 80 NOTIMPLEMENTED();
79 // Customized font rendering settings are not supported, only defaults. 81 // Customized font rendering settings are not supported, only defaults.
80 return CachedFontRenderParams::GetInstance()->GetParams(); 82 return CachedFontRenderParams::GetInstance()->GetParams();
81 } 83 }
82 84
83 } // namespace gfx 85 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698