Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/base/resource/resource_bundle_win.h" | 5 #include "ui/base/resource/resource_bundle_win.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "ui/base/layout.h" | 10 #include "ui/base/layout.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 } | 34 } |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 void ResourceBundle::LoadCommonResources() { | 38 void ResourceBundle::LoadCommonResources() { |
| 39 // As a convenience, add the current resource module as a data packs. | 39 // As a convenience, add the current resource module as a data packs. |
| 40 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); | 40 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); |
| 41 | 41 |
| 42 bool use_hidpi = false; | 42 bool use_hidpi = false; |
| 43 #if defined(ENABLE_HIDPI) | 43 #if defined(ENABLE_HIDPI) |
| 44 // If we're running in HiDPI mode at a scale larger than 150%, we switch | 44 // Have high-DPI resources for 140% and 180% scaling on Windows based on |
| 45 // to 2x resources for desktop layouts. | 45 // default scaling for Metro mode. If high-DPI mode is enabled, load resource |
| 46 use_hidpi = ui::GetDPIScale() > 1.5; | 46 // pak closest to the desired scale factor. |
| 47 use_hidpi = ui::GetDPIScale() > 1.2; | |
|
pkotwicz
2013/01/23 18:13:12
For the purpose of this CL, you actually do not ne
kevers
2013/01/23 20:02:19
Backing this change out for the time being. Will
| |
| 47 #endif | 48 #endif |
| 48 | 49 |
| 49 switch (ui::GetDisplayLayout()) { | 50 if (use_hidpi) { |
| 50 case ui::LAYOUT_TOUCH: | 51 float scale = ui::GetDPIScale(); |
| 51 AddDataPackFromPath( | 52 if (scale > 1.6f) { |
| 52 GetResourcesPakFilePath("chrome_touch_100_percent.pak"), | 53 AddDataPackFromPath(GetResourcesPakFilePath( |
| 53 SCALE_FACTOR_100P); | 54 "chrome_touch_180_percent.pak"), |
| 54 break; | 55 SCALE_FACTOR_180P); |
| 55 default: | 56 } else { |
|
pkotwicz
2013/01/23 18:13:12
Nit: Put a comment that we will be using 1.4x reso
kevers
2013/01/23 20:02:19
Backing out change for now.
| |
| 56 if (use_hidpi) { | 57 AddDataPackFromPath(GetResourcesPakFilePath( |
| 57 AddDataPackFromPath(GetResourcesPakFilePath( | 58 "chrome_touch_140_percent.pak"), |
| 58 "chrome_200_percent.pak"), | 59 SCALE_FACTOR_140P); |
| 59 SCALE_FACTOR_200P); | 60 } |
| 60 AddDataPackFromPath(GetResourcesPakFilePath( | 61 |
| 61 "webkit_resources_200_percent.pak"), | 62 // Currently missing some scaled assets. 100% resources required as |
| 62 SCALE_FACTOR_200P); | 63 // fallback. |
| 63 } else { | 64 AddDataPackFromPath( |
| 64 AddDataPackFromPath( | 65 GetResourcesPakFilePath("chrome_100_percent.pak"), |
| 65 GetResourcesPakFilePath("chrome_100_percent.pak"), | 66 SCALE_FACTOR_100P); |
| 66 SCALE_FACTOR_100P); | 67 |
| 67 } | 68 } else if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { |
| 68 break; | 69 AddDataPackFromPath( |
| 70 GetResourcesPakFilePath("chrome_touch_100_percent.pak"), | |
| 71 SCALE_FACTOR_100P); | |
| 72 } else { | |
| 73 AddDataPackFromPath( | |
| 74 GetResourcesPakFilePath("chrome_100_percent.pak"), | |
| 75 SCALE_FACTOR_100P); | |
| 69 } | 76 } |
| 70 } | 77 } |
| 71 | 78 |
| 72 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { | 79 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { |
| 73 // Flipped image is not used on Windows. | 80 // Flipped image is not used on Windows. |
| 74 DCHECK_EQ(rtl, RTL_DISABLED); | 81 DCHECK_EQ(rtl, RTL_DISABLED); |
| 75 | 82 |
| 76 // Windows only uses SkBitmap for gfx::Image, so this is the same as | 83 // Windows only uses SkBitmap for gfx::Image, so this is the same as |
| 77 // GetImageNamed. | 84 // GetImageNamed. |
| 78 return GetImageNamed(resource_id); | 85 return GetImageNamed(resource_id); |
| 79 } | 86 } |
| 80 | 87 |
| 81 void SetResourcesDataDLL(HINSTANCE handle) { | 88 void SetResourcesDataDLL(HINSTANCE handle) { |
| 82 resources_data_dll = handle; | 89 resources_data_dll = handle; |
| 83 } | 90 } |
| 84 | 91 |
| 85 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { | 92 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { |
| 86 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); | 93 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); |
| 87 } | 94 } |
| 88 | 95 |
| 89 } // namespace ui; | 96 } // namespace ui; |
| OLD | NEW |