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

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

Issue 10024050: Metro/HiDPI: Move 1x icons into separate pak file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clobber build 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
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"
8 #include "ui/base/resource/resource_bundle.h" 9 #include "ui/base/resource/resource_bundle.h"
9 #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"
10 12
11 namespace ui { 13 namespace ui {
12 14
13 namespace { 15 namespace {
14 16
15 HINSTANCE resources_data_dll; 17 HINSTANCE resources_data_dll;
16 18
17 HINSTANCE GetCurrentResourceDLL() { 19 HINSTANCE GetCurrentResourceDLL() {
18 if (resources_data_dll) 20 if (resources_data_dll)
19 return resources_data_dll; 21 return resources_data_dll;
20 return GetModuleHandle(NULL); 22 return GetModuleHandle(NULL);
21 } 23 }
22 24
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
23 } // end anonymous namespace 32 } // end anonymous namespace
24 33
25 void ResourceBundle::LoadCommonResources() { 34 void ResourceBundle::LoadCommonResources() {
26 // As a convenience, add the current resource module as a data packs. 35 // As a convenience, add the current resource module as a data packs.
27 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); 36 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 }
28 } 52 }
29 53
30 void ResourceBundle::LoadTestResources(const FilePath& path) { 54 void ResourceBundle::LoadTestResources(const FilePath& path) {
31 // On Windows, the test resources are normally compiled into the binary 55 // On Windows, the test resources are normally compiled into the binary
32 // itself. 56 // itself.
33 } 57 }
34 58
35 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { 59 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
36 // Flipped image is not used on Windows. 60 // Flipped image is not used on Windows.
37 DCHECK_EQ(rtl, RTL_DISABLED); 61 DCHECK_EQ(rtl, RTL_DISABLED);
38 62
39 // Windows only uses SkBitmap for gfx::Image, so this is the same as 63 // Windows only uses SkBitmap for gfx::Image, so this is the same as
40 // GetImageNamed. 64 // GetImageNamed.
41 return GetImageNamed(resource_id); 65 return GetImageNamed(resource_id);
42 } 66 }
43 67
44 void SetResourcesDataDLL(HINSTANCE handle) { 68 void SetResourcesDataDLL(HINSTANCE handle) {
45 resources_data_dll = handle; 69 resources_data_dll = handle;
46 } 70 }
47 71
48 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { 72 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) {
49 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); 73 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id));
50 } 74 }
51 75
52 } // namespace ui; 76 } // namespace ui;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698