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

Side by Side Diff: ui/base/resource/resource_bundle_win.cc

Issue 10103022: Revert 132517 - Metro/HiDPI: Move 1x icons into separate pak file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/resource/resource_bundle_mac.mm ('k') | ui/base/ui_base_paths.h » ('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 (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"
9 #include "ui/base/resource/resource_bundle.h" 8 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/base/resource/resource_data_dll_win.h" 9 #include "ui/base/resource/resource_data_dll_win.h"
11 #include "ui/base/win/dpi.h"
12 10
13 namespace ui { 11 namespace ui {
14 12
15 namespace { 13 namespace {
16 14
17 HINSTANCE resources_data_dll; 15 HINSTANCE resources_data_dll;
18 16
19 HINSTANCE GetCurrentResourceDLL() { 17 HINSTANCE GetCurrentResourceDLL() {
20 if (resources_data_dll) 18 if (resources_data_dll)
21 return resources_data_dll; 19 return resources_data_dll;
22 return GetModuleHandle(NULL); 20 return GetModuleHandle(NULL);
23 } 21 }
24 22
25 FilePath GetResourcesPakFilePath(const std::string& pak_name) {
26 FilePath path;
27 if (PathService::Get(base::DIR_MODULE, &path))
28 return path.AppendASCII(pak_name.c_str());
29 return FilePath();
30 }
31
32 } // end anonymous namespace 23 } // end anonymous namespace
33 24
34 void ResourceBundle::LoadCommonResources() { 25 void ResourceBundle::LoadCommonResources() {
35 // As a convenience, add the current resource module as a data packs. 26 // As a convenience, add the current resource module as a data packs.
36 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); 27 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL()));
37
38 bool use_hidpi_pak = false;
39 #if defined(ENABLE_HIDPI)
40 // 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 use_hidpi_pak = ui::GetDPIScale() > 1.5;
43 #endif
44
45 if (!use_hidpi_pak) {
46 AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"));
47 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
48 } else {
49 AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak"));
50 AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak"));
51 }
52 } 28 }
53 29
54 void ResourceBundle::LoadTestResources(const FilePath& path) { 30 void ResourceBundle::LoadTestResources(const FilePath& path) {
55 // On Windows, the test resources are normally compiled into the binary 31 // On Windows, the test resources are normally compiled into the binary
56 // itself. 32 // itself.
57 } 33 }
58 34
59 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { 35 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
60 // Flipped image is not used on Windows. 36 // Flipped image is not used on Windows.
61 DCHECK_EQ(rtl, RTL_DISABLED); 37 DCHECK_EQ(rtl, RTL_DISABLED);
62 38
63 // Windows only uses SkBitmap for gfx::Image, so this is the same as 39 // Windows only uses SkBitmap for gfx::Image, so this is the same as
64 // GetImageNamed. 40 // GetImageNamed.
65 return GetImageNamed(resource_id); 41 return GetImageNamed(resource_id);
66 } 42 }
67 43
68 void SetResourcesDataDLL(HINSTANCE handle) { 44 void SetResourcesDataDLL(HINSTANCE handle) {
69 resources_data_dll = handle; 45 resources_data_dll = handle;
70 } 46 }
71 47
72 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { 48 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) {
73 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); 49 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id));
74 } 50 }
75 51
76 } // namespace ui; 52 } // namespace ui;
OLDNEW
« no previous file with comments | « ui/base/resource/resource_bundle_mac.mm ('k') | ui/base/ui_base_paths.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698