| 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/layout.h" | 9 #include "ui/base/layout.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 bool use_hidpi = false; | 39 bool use_hidpi = false; |
| 40 #if defined(ENABLE_HIDPI) | 40 #if defined(ENABLE_HIDPI) |
| 41 // If we're running in HiDPI mode at a scale larger than 150%, we switch | 41 // If we're running in HiDPI mode at a scale larger than 150%, we switch |
| 42 // to 2x resources for desktop layouts. | 42 // to 2x resources for desktop layouts. |
| 43 use_hidpi = ui::GetDPIScale() > 1.5; | 43 use_hidpi = ui::GetDPIScale() > 1.5; |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 switch (ui::GetDisplayLayout()) { | 46 switch (ui::GetDisplayLayout()) { |
| 47 case ui::LAYOUT_TOUCH: | 47 case ui::LAYOUT_TOUCH: |
| 48 AddDataPack(GetResourcesPakFilePath("theme_resources_metro_1x.pak"), | 48 AddDataPack("theme_resources_metro_1x", |
| 49 GetResourcesPakFilePath("theme_resources_metro_1x.pak"), |
| 49 ResourceHandle::kScaleFactor100x); | 50 ResourceHandle::kScaleFactor100x); |
| 50 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), | 51 AddDataPack("ui_resources_standard", |
| 52 GetResourcesPakFilePath("ui_resources_standard.pak"), |
| 51 ResourceHandle::kScaleFactor100x); | 53 ResourceHandle::kScaleFactor100x); |
| 52 break; | 54 break; |
| 53 default: | 55 default: |
| 54 if (use_hidpi) { | 56 if (use_hidpi) { |
| 55 AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak"), | 57 AddDataPack("theme_resources_2x", |
| 56 ResourceHandle::kScaleFactor200x); | 58 GetResourcesPakFilePath("theme_resources_2x.pak"), |
| 57 AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak"), | 59 ResourceHandle::kScaleFactor200x); |
| 58 ResourceHandle::kScaleFactor200x); | 60 AddDataPack("ui_resources_2x", |
| 61 GetResourcesPakFilePath("ui_resources_2x.pak"), |
| 62 ResourceHandle::kScaleFactor200x); |
| 59 } else { | 63 } else { |
| 60 AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"), | 64 AddDataPack("theme_resources_standard", |
| 61 ResourceHandle::kScaleFactor100x); | 65 GetResourcesPakFilePath("theme_resources_standard.pak"), |
| 62 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), | 66 ResourceHandle::kScaleFactor100x); |
| 63 ResourceHandle::kScaleFactor100x); | 67 AddDataPack("ui_resources_standard", |
| 68 GetResourcesPakFilePath("ui_resources_standard.pak"), |
| 69 ResourceHandle::kScaleFactor100x); |
| 64 } | 70 } |
| 65 break; | 71 break; |
| 66 } | 72 } |
| 67 } | 73 } |
| 68 | 74 |
| 69 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { | 75 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { |
| 70 // Flipped image is not used on Windows. | 76 // Flipped image is not used on Windows. |
| 71 DCHECK_EQ(rtl, RTL_DISABLED); | 77 DCHECK_EQ(rtl, RTL_DISABLED); |
| 72 | 78 |
| 73 // Windows only uses SkBitmap for gfx::Image, so this is the same as | 79 // Windows only uses SkBitmap for gfx::Image, so this is the same as |
| 74 // GetImageNamed. | 80 // GetImageNamed. |
| 75 return GetImageNamed(resource_id); | 81 return GetImageNamed(resource_id); |
| 76 } | 82 } |
| 77 | 83 |
| 78 void SetResourcesDataDLL(HINSTANCE handle) { | 84 void SetResourcesDataDLL(HINSTANCE handle) { |
| 79 resources_data_dll = handle; | 85 resources_data_dll = handle; |
| 80 } | 86 } |
| 81 | 87 |
| 82 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { | 88 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { |
| 83 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); | 89 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); |
| 84 } | 90 } |
| 85 | 91 |
| 86 } // namespace ui; | 92 } // namespace ui; |
| OLD | NEW |