| 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.h" | 5 #include "ui/base/resource/resource_bundle.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "ui/base/layout.h" | 10 #include "ui/base/layout.h" |
| 11 #include "ui/base/resource/resource_handle.h" | 11 #include "ui/base/resource/resource_handle.h" |
| 12 #include "ui/base/ui_base_paths.h" | 12 #include "ui/base/ui_base_paths.h" |
| 13 #include "ui/base/ui_base_switches.h" | 13 #include "ui/base/ui_base_switches.h" |
| 14 #include "ui/gfx/display.h" | 14 #include "ui/gfx/display.h" |
| 15 #include "ui/gfx/image/image.h" | 15 #include "ui/gfx/image/image.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 FilePath GetResourcesPakFilePath(const std::string& pak_name) { | 19 FilePath GetResourcesPakFilePath(const std::string& pak_name) { |
| 20 FilePath path; | 20 FilePath path; |
| 21 if (PathService::Get(base::DIR_MODULE, &path)) | 21 if (PathService::Get(base::DIR_MODULE, &path)) |
| 22 return path.AppendASCII(pak_name.c_str()); | 22 return path.AppendASCII(pak_name.c_str()); |
| 23 | 23 |
| 24 // Return just the name of the pack file. | 24 // Return just the name of the pack file. |
| 25 return FilePath(pak_name.c_str()); | 25 return FilePath(pak_name.c_str()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool ShouldLoad2xResources() { | 28 bool ShouldLoad2xResources() { |
| 29 return (gfx::Display::GetDefaultDeviceScaleFactor() > 1.0f || | 29 return gfx::Display::GetForcedDeviceScaleFactor() > 1.0f || |
| 30 CommandLine::ForCurrentProcess()->HasSwitch(switches::kLoad2xResources)); | 30 CommandLine::ForCurrentProcess()->HasSwitch(switches::kLoad2xResources); |
| 31 } | 31 } |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 namespace ui { | 35 namespace ui { |
| 36 | 36 |
| 37 void ResourceBundle::LoadCommonResources() { | 37 void ResourceBundle::LoadCommonResources() { |
| 38 // Always load the 1x data pack first as the 2x data pack contains both 1x and | 38 // Always load the 1x data pack first as the 2x data pack contains both 1x and |
| 39 // 2x images. The 1x data pack only has 1x images, thus passes in an accurate | 39 // 2x images. The 1x data pack only has 1x images, thus passes in an accurate |
| 40 // scale factor to gfx::ImageSkia::AddBitmapForScale. | 40 // scale factor to gfx::ImageSkia::AddBitmapForScale. |
| 41 // TODO(pkotwicz): Fix this in cases where it is intended for the 2x bitmap | |
| 42 // not to be 2 * size of the 1x bitmap for HDA. | |
| 43 // TODO(oshima): Fix this where it is unintended. | |
| 44 | 41 |
| 45 AddDataPack(GetResourcesPakFilePath("chrome.pak"), | 42 AddDataPack(GetResourcesPakFilePath("chrome.pak"), |
| 46 SCALE_FACTOR_100P); | 43 SCALE_FACTOR_100P); |
| 47 | 44 |
| 48 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { | 45 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { |
| 49 // 1x touch | 46 // 1x touch |
| 50 AddDataPack(GetResourcesPakFilePath("theme_resources_touch_1x.pak"), | 47 AddDataPack(GetResourcesPakFilePath("theme_resources_touch_1x.pak"), |
| 51 SCALE_FACTOR_100P); | 48 SCALE_FACTOR_100P); |
| 52 AddDataPack(GetResourcesPakFilePath("ui_resources_touch.pak"), | 49 AddDataPack(GetResourcesPakFilePath("ui_resources_touch.pak"), |
| 53 SCALE_FACTOR_100P); | 50 SCALE_FACTOR_100P); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 74 } | 71 } |
| 75 } | 72 } |
| 76 | 73 |
| 77 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { | 74 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { |
| 78 // Flipped image is not used on ChromeOS. | 75 // Flipped image is not used on ChromeOS. |
| 79 DCHECK_EQ(rtl, RTL_DISABLED); | 76 DCHECK_EQ(rtl, RTL_DISABLED); |
| 80 return GetImageNamed(resource_id); | 77 return GetImageNamed(resource_id); |
| 81 } | 78 } |
| 82 | 79 |
| 83 } // namespace ui | 80 } // namespace ui |
| OLD | NEW |