Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Metro/HiDPI: Move 1x icons into separate pak file
Browse files Browse the repository at this point in the history
Currently all 1x art files are repacked into chrome.pak files.

This is a problem on Windows where we want to choose which pak file to load based on metro and DPI scale.

As a first step this CL does the following:
 - add a new enable_hidpi build flag. This allows us to test HiDPI mode on Windows Chrome.
 - stop packing theme_resources_standard.pak and ui_resources_standard.pak into chrome.pak
 - update the Mac and Windows installer code to package the extra pak files.

Note, I'll be updating the Linux installer script in a separate CL. I'm still looking into the ChromeOS situation.

BUG=114311
TEST=Ran on Windows, and Mac and Linux.

Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=132517

Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=132760

Review URL: https://chromiumcodereview.appspot.com/10024050

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133613 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sail@chromium.org committed Apr 24, 2012
1 parent 82f6998 commit 598e496
Show file tree
Hide file tree
Showing 18 changed files with 192 additions and 62 deletions.
14 changes: 14 additions & 0 deletions build/common.gypi
Expand Up @@ -40,6 +40,9 @@

# Disable viewport meta tag by default.
'enable_viewport%': 0,

# Enable HiDPI support.
'enable_hidpi%': 0,
},
# Copy conditionally-set variables out one scope.
'chromeos%': '<(chromeos)',
Expand All @@ -49,6 +52,7 @@
'use_openssl%': '<(use_openssl)',
'use_virtual_keyboard%': '<(use_virtual_keyboard)',
'enable_viewport%': '<(enable_viewport)',
'enable_hidpi%': '<(enable_hidpi)',

# Compute the architecture that we're building on.
'conditions': [
Expand Down Expand Up @@ -82,6 +86,11 @@
}, {
'toolkit_views%': 0,
}],

# Enable HiDPI on Mac OS.
['OS=="mac"', {
'enable_hidpi%': 1,
}],
],
},

Expand All @@ -95,6 +104,7 @@
'use_openssl%': '<(use_openssl)',
'use_virtual_keyboard%': '<(use_virtual_keyboard)',
'enable_viewport%': '<(enable_viewport)',
'enable_hidpi%': '<(enable_hidpi)',

# We used to provide a variable for changing how libraries were built.
# This variable remains until we can clean up all the users.
Expand Down Expand Up @@ -492,6 +502,7 @@
'chromeos%': '<(chromeos)',
'use_virtual_keyboard%': '<(use_virtual_keyboard)',
'enable_viewport%': '<(enable_viewport)',
'enable_hidpi%': '<(enable_hidpi)',
'use_xi2_mt%':'<(use_xi2_mt)',
'file_manager_extension%': '<(file_manager_extension)',
'webui_task_manager%': '<(webui_task_manager)',
Expand Down Expand Up @@ -1287,6 +1298,9 @@
['notifications==1', {
'defines': ['ENABLE_NOTIFICATIONS'],
}],
['enable_hidpi==1', {
'defines': ['ENABLE_HIDPI=1'],
}],
['fastbuild!=0', {

'conditions': [
Expand Down
18 changes: 10 additions & 8 deletions chrome/chrome_dll.gypi
Expand Up @@ -100,7 +100,6 @@
'<(SHARED_INTERMEDIATE_DIR)/chrome/extensions_api_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/chrome/theme_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/chrome/theme_resources_standard.rc',
'<(SHARED_INTERMEDIATE_DIR)/content/content_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc',
Expand Down Expand Up @@ -304,8 +303,10 @@
'app/theme/star.pdf',
'app/theme/star_lit.pdf',
'browser/mac/install.sh',
'<(SHARED_INTERMEDIATE_DIR)/repack/chrome.pak',
'<(SHARED_INTERMEDIATE_DIR)/repack/resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/repack/chrome.pak',
'<(SHARED_INTERMEDIATE_DIR)/repack/resources.pak',
'<(grit_out_dir)/theme_resources_standard.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.pak',
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(locales))',
# Note: pseudo_locales are generated via the packed_resources
# dependency but not copied to the final target. See
Expand Down Expand Up @@ -354,11 +355,6 @@
],
'repack_path': '../tools/grit/grit/format/repack.py',
},
'actions': [
{
'includes': ['chrome_repack_theme_resources_2x.gypi']
},
],
'postbuilds': [
{
# This step causes an error to be raised if the .order file
Expand Down Expand Up @@ -537,6 +533,12 @@
'../pdf/pdf.gyp:pdf',
],
}],
['enable_hidpi==1', {
'mac_bundle_resources': [
'<(grit_out_dir)/theme_resources_2x.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_2x/ui_resources_2x.pak',
],
}],
], # conditions
}], # OS=="mac"
], # conditions
Expand Down
2 changes: 0 additions & 2 deletions chrome/chrome_repack_chrome.gypi
Expand Up @@ -9,11 +9,9 @@
'<(grit_out_dir)/common_resources.pak',
'<(grit_out_dir)/renderer_resources.pak',
'<(grit_out_dir)/theme_resources.pak',
'<(grit_out_dir)/theme_resources_standard.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.pak',
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.pak',
],
Expand Down
21 changes: 0 additions & 21 deletions chrome/chrome_repack_theme_resources_2x.gypi

This file was deleted.

46 changes: 43 additions & 3 deletions chrome/chrome_resources.gyp
Expand Up @@ -193,7 +193,7 @@
'includes': [ '../build/grit_target.gypi' ],
},
{
'target_name': 'theme_resources',
'target_name': 'theme_resources_gen',
'type': 'none',
'actions': [
{
Expand All @@ -220,6 +220,48 @@
],
'includes': [ '../build/grit_target.gypi' ],
},
{
'target_name': 'theme_resources',
'type': 'none',
'dependencies': [
'theme_resources_gen',
'<(DEPTH)/ui/ui.gyp:ui_resources_2x',
'<(DEPTH)/ui/ui.gyp:ui_resources_standard',
],
'conditions': [
['OS != "mac"', {
# Copy pak files to the product directory. These files will be picked
# up by the following installer scripts:
# - Windows: chrome/installer/mini_installer/chrome.release
# - Linux: chrome/installer/linux/internal/common/installer.include
# Ensure that the above scripts are updated when adding or removing
# pak files.
# Coping files to the product directory is not needed on the Mac
# since the framework build phase will copy them into the framework
# bundle directly.
'copies': [
{
'destination': '<(PRODUCT_DIR)',
'files': [
'<(grit_out_dir)/theme_resources_standard.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.pak',
],
},
],
}],
['OS != "mac" and enable_hidpi == 1', {
'copies': [
{
'destination': '<(PRODUCT_DIR)',
'files': [
'<(grit_out_dir)/theme_resources_2x.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_2x/ui_resources_2x.pak',
],
},
],
}],
],
},
{
'target_name': 'packed_extra_resources',
'type': 'none',
Expand Down Expand Up @@ -269,8 +311,6 @@
'<(DEPTH)/ui/base/strings/ui_strings.gyp:ui_strings',
'<(DEPTH)/ui/ui.gyp:gfx_resources',
'<(DEPTH)/ui/ui.gyp:ui_resources',
'<(DEPTH)/ui/ui.gyp:ui_resources_2x',
'<(DEPTH)/ui/ui.gyp:ui_resources_standard',
'<(DEPTH)/webkit/support/webkit_support.gyp:webkit_resources',
'<(DEPTH)/webkit/support/webkit_support.gyp:webkit_strings',
],
Expand Down
6 changes: 6 additions & 0 deletions chrome/installer/mini_installer/chrome.release
Expand Up @@ -13,6 +13,8 @@ nacl_irt_x86_32.nexe: %(VersionDir)s\
nacl_irt_x86_64.nexe: %(VersionDir)s\
icudt.dll: %(VersionDir)s\
resources.pak: %(VersionDir)s\
theme_resources_standard.pak: %(VersionDir)s\
ui_resources_standard.pak: %(VersionDir)s\
locales\*.pak: %(VersionDir)s\Locales
locales\*.dll: %(VersionDir)s\Locales
npchrome_frame.dll: %(VersionDir)s\
Expand All @@ -30,6 +32,10 @@ xinput1_3.dll: %(VersionDir)s\
default_apps\*.crx: %(VersionDir)s\default_apps\
default_apps\external_extensions.json: %(VersionDir)s\default_apps\

[HIDPI]
theme_resources_2x.pak: %(VersionDir)s\
ui_resources_2x.pak: %(VersionDir)s\

[GOOGLE_CHROME]
splash-620x300.png: %(ChromeDir)s\
Logo.png: %(ChromeDir)s\
Expand Down
10 changes: 10 additions & 0 deletions chrome/tools/build/chromeos/FILES.cfg
Expand Up @@ -84,6 +84,16 @@ FILES = [
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'theme_resources_standard.pak',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'ui_resources_standard.pak',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'session',
'arch': ['32bit', '64bit'],
Expand Down
10 changes: 10 additions & 0 deletions chrome/tools/build/linux/FILES.cfg
Expand Up @@ -86,6 +86,16 @@ FILES = [
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'theme_resources_standard.pak',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'ui_resources_standard.pak',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'session',
'arch': ['32bit', '64bit'],
Expand Down
20 changes: 20 additions & 0 deletions chrome/tools/build/win/FILES.cfg
Expand Up @@ -346,6 +346,26 @@ FILES = [
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'theme_resources_standard.pak',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'theme_resources_2x.pak',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'ui_resources_standard.pak',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'ui_resources_2x.pak',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'wow_helper.exe',
'arch': ['32bit', '64bit'],
Expand Down
13 changes: 10 additions & 3 deletions chrome/tools/build/win/create_installer_archive.py
Expand Up @@ -89,7 +89,8 @@ def CompressUsingLZMA(build_dir, compressed_file, input_file):
RunSystemCommand(cmd)


def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir):
def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir,
enable_hidpi):
"""Copies the files required for installer archive.
Copies all common files required for various distributions of Chromium and
also files for the specific Chromium build specified by distribution.
Expand All @@ -100,6 +101,8 @@ def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir):
distribution = distribution[1:]
CopySectionFilesToStagingDir(config, distribution.upper(),
staging_dir, build_dir)
if enable_hidpi == '1':
CopySectionFilesToStagingDir(config, 'HIDPI', staging_dir, build_dir)


def CopySectionFilesToStagingDir(config, section, staging_dir, build_dir):
Expand Down Expand Up @@ -324,11 +327,13 @@ def main(options):
# building the optimized mini_installer.
if options.build_dir != options.output_dir:
CopyAllFilesToStagingDir(config, options.distribution,
staging_dir, options.output_dir)
staging_dir, options.output_dir,
options.enable_hidpi)

# Now copy the remainder of the files from the build dir.
CopyAllFilesToStagingDir(config, options.distribution,
staging_dir, options.build_dir)
staging_dir, options.build_dir,
options.enable_hidpi)

version_numbers = current_version.split('.')
current_build_number = version_numbers[2] + '.' + version_numbers[3]
Expand Down Expand Up @@ -380,6 +385,8 @@ def _ParseOptions():
'{BSDIFF|COURGETTE}.')
parser.add_option('-n', '--output_name', default='chrome',
help='Name used to prefix names of generated archives.')
parser.add_option('--enable_hidpi', default='0',
help='Whether to include HiDPI resource files.')

options, args = parser.parse_args()
if not options.build_dir:
Expand Down
2 changes: 1 addition & 1 deletion chrome/tools/build/win/release.rules
Expand Up @@ -7,7 +7,7 @@
<CustomBuildRule
Name="Create Installer Archive"
DisplayName="Create Installer Archive"
CommandLine="$(SolutionDir)..\third_party\python_24\python.exe $(SolutionDir)tools\build\win\create_installer_archive.py --output_dir=&quot;$(OutDir)&quot; --input_file=&quot;$(InputPath)&quot; --distribution=$(CHROMIUM_BUILD) [LastChromeInstaller] [SkipRebuildArchive] [SetupExeFormat] [DiffAlgorithm]"
CommandLine="$(SolutionDir)..\third_party\python_24\python.exe $(SolutionDir)tools\build\win\create_installer_archive.py --output_dir=&quot;$(OutDir)&quot; --input_file=&quot;$(InputPath)&quot; --distribution=$(CHROMIUM_BUILD) --enable_hidpi=$(ENABLE_HIDPI) [LastChromeInstaller] [SkipRebuildArchive] [SetupExeFormat] [DiffAlgorithm]"
Outputs="$(OutDir)/$(InputName).7z;$(OutDir)/$(InputName).packed.7z;$(OutDir)/setup.ex_;$(OutDir)/packed_files.txt;"
AdditionalDependencies="$(SolutionDir)\tools\build\win\create_installer_archive.py;$(OutDir)\chrome.exe;$(OutDir)\crash_reporter.exe;$(OutDir)\chrome.dll;$(OutDir)\locales\en-US.dll;$(OutDir)\icudt38.dll"
FileExtensions="*.release"
Expand Down
19 changes: 14 additions & 5 deletions ui/base/resource/resource_bundle_android.cc
Expand Up @@ -12,14 +12,23 @@
#include "base/path_service.h"
#include "base/stringprintf.h"

namespace {

FilePath GetResourcesPakFilePath(const std::string& pak_name) {
FilePath path;
PathService::Get(base::DIR_ANDROID_APP_DATA, &path);
DCHECK(!path.empty());
return path.AppendASCII("paks").AppendASCII(pak_name.c_str());
}

} // namespace

namespace ui {

void ResourceBundle::LoadCommonResources() {
FilePath data_path;
PathService::Get(base::DIR_ANDROID_APP_DATA, &data_path);
DCHECK(!data_path.empty());
data_path = data_path.AppendASCII("paks").AppendASCII("chrome.pak");
AddDataPack(data_path);
AddDataPack(GetResourcesPakFilePath("chrome.pak"));
AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"));
AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
}

gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
Expand Down
17 changes: 14 additions & 3 deletions ui/base/resource/resource_bundle_linux.cc
Expand Up @@ -7,12 +7,23 @@
#include "base/path_service.h"
#include "ui/base/ui_base_paths.h"

namespace {

FilePath GetResourcesPakFilePath(const std::string& pak_name) {
FilePath path;
if (PathService::Get(base::DIR_MODULE, &path))
return path.AppendASCII(pak_name.c_str());
return FilePath();
}

} // namespace

namespace ui {

void ResourceBundle::LoadCommonResources() {
FilePath path;
PathService::Get(ui::FILE_RESOURCES_PAK, &path);
AddDataPack(path);
AddDataPack(GetResourcesPakFilePath("chrome.pak"));
AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"));
AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
}

} // namespace ui

0 comments on commit 598e496

Please sign in to comment.