| 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 "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/base/resource/resource_data_dll_win.h" | 10 #include "ui/base/resource/resource_data_dll_win.h" |
| 11 #include "ui/base/win/dpi.h" | 11 #include "ui/base/win/dpi.h" |
| 12 #include "ui/base/win/metro.h" |
| 12 | 13 |
| 13 namespace ui { | 14 namespace ui { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 HINSTANCE resources_data_dll; | 18 HINSTANCE resources_data_dll; |
| 18 | 19 |
| 19 HINSTANCE GetCurrentResourceDLL() { | 20 HINSTANCE GetCurrentResourceDLL() { |
| 20 if (resources_data_dll) | 21 if (resources_data_dll) |
| 21 return resources_data_dll; | 22 return resources_data_dll; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 // As a convenience, add the current resource module as a data packs. | 36 // As a convenience, add the current resource module as a data packs. |
| 36 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); | 37 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); |
| 37 | 38 |
| 38 bool use_hidpi_pak = false; | 39 bool use_hidpi_pak = false; |
| 39 #if defined(ENABLE_HIDPI) | 40 #if defined(ENABLE_HIDPI) |
| 40 // If we're running in HiDPI mode then use the 2x resource for DPI greater | 41 // If we're running in HiDPI mode then use the 2x resource for DPI greater |
| 41 // than 1.5. Otherwise use the 1x resource. | 42 // than 1.5. Otherwise use the 1x resource. |
| 42 use_hidpi_pak = ui::GetDPIScale() > 1.5; | 43 use_hidpi_pak = ui::GetDPIScale() > 1.5; |
| 43 #endif | 44 #endif |
| 44 | 45 |
| 45 if (!use_hidpi_pak) { | 46 bool use_metro_pak = false; |
| 47 #if defined(ENABLE_METRO) |
| 48 use_metro_pak = ui::IsInMetroMode(); |
| 49 #endif |
| 50 |
| 51 if (use_metro_pak) { |
| 52 AddDataPack(GetResourcesPakFilePath("theme_resources_metro_1x.pak")); |
| 53 } else if (use_hidpi_pak) { |
| 54 AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak")); |
| 55 } else { |
| 46 AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak")); | 56 AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak")); |
| 57 } |
| 58 |
| 59 if (use_hidpi_pak) { |
| 60 AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak")); |
| 61 } else { |
| 47 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak")); | 62 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak")); |
| 48 } else { | |
| 49 AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak")); | |
| 50 AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak")); | |
| 51 } | 63 } |
| 52 } | 64 } |
| 53 | 65 |
| 54 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { | 66 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { |
| 55 // Flipped image is not used on Windows. | 67 // Flipped image is not used on Windows. |
| 56 DCHECK_EQ(rtl, RTL_DISABLED); | 68 DCHECK_EQ(rtl, RTL_DISABLED); |
| 57 | 69 |
| 58 // Windows only uses SkBitmap for gfx::Image, so this is the same as | 70 // Windows only uses SkBitmap for gfx::Image, so this is the same as |
| 59 // GetImageNamed. | 71 // GetImageNamed. |
| 60 return GetImageNamed(resource_id); | 72 return GetImageNamed(resource_id); |
| 61 } | 73 } |
| 62 | 74 |
| 63 void SetResourcesDataDLL(HINSTANCE handle) { | 75 void SetResourcesDataDLL(HINSTANCE handle) { |
| 64 resources_data_dll = handle; | 76 resources_data_dll = handle; |
| 65 } | 77 } |
| 66 | 78 |
| 67 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { | 79 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { |
| 68 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); | 80 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); |
| 69 } | 81 } |
| 70 | 82 |
| 71 } // namespace ui; | 83 } // namespace ui; |
| OLD | NEW |