Skip to content

Commit

Permalink
Fix ASSERTs and low quality assets on high dpi screens
Browse files Browse the repository at this point in the history
Right now we're shipping only assets with 100% scale factor. This
patch address the issue by making sure that we at least support
better assets when the scale factor is not 100%.

This will require a change in app-tools as well.
  • Loading branch information
darktears committed Apr 28, 2016
1 parent e5e0a17 commit f827a69
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 9 deletions.
1 change: 1 addition & 0 deletions build/android/generate_xwalk_core_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def CopyBinaries(out_dir, out_project_dir, src_package, shared):
# 'natives_blob.bin',
# 'snapshot_blob.bin',
'xwalk.pak',
'xwalk_100_percent.pak',
]

pak_list_xml = Document()
Expand Down
1 change: 1 addition & 0 deletions runtime/android/core/src/org/xwalk/core/XWalkUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ public interface XWalkBackgroundUpdateListener {
"classes.dex",
"icudtl.dat",
"xwalk.pak",
"xwalk_100_percent",
};

private static final String TAG = "XWalkLib";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class XWalkViewDelegate {
private static final String[] MANDATORY_PAKS = {
"xwalk.pak",
"icudtl.dat",
"xwalk_100_percent.pak",
// Please refer to XWALK-3516, disable v8 use external startup data,
// reopen it if needed later.
// "natives_blob.bin",
Expand Down
3 changes: 3 additions & 0 deletions runtime/app/android/xwalk_main_delegate_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ void XWalkMainDelegateAndroid::InitResourceBundle() {
pak_dir = pak_dir.Append(FILE_PATH_LITERAL("paks"));
pak_file = pak_dir.Append(FILE_PATH_LITERAL(kXWalkPakFilePath));
ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
pak_file = pak_dir.Append(FILE_PATH_LITERAL("xwalk_100_percent.pak"));
ResourceBundle::GetSharedInstance().AddDataPackFromPath(
pak_file, ui::SCALE_FACTOR_100P);
}

} // namespace xwalk
17 changes: 12 additions & 5 deletions runtime/app/xwalk_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,30 @@ void XWalkMainDelegate::ZygoteStarting(
// static
void XWalkMainDelegate::InitializeResourceBundle() {
base::FilePath pak_file;
base::FilePath pak_dir;
#if defined(OS_MACOSX)
pak_file = GetResourcesPakFilePath();
pak_dir = pak_file.DirName();
#else
base::FilePath pak_dir;
PathService::Get(base::DIR_MODULE, &pak_dir);
DCHECK(!pak_dir.empty());

pak_file = pak_dir.Append(FILE_PATH_LITERAL("xwalk.pak"));
#endif

#if !defined(OS_ANDROID)
ui::ResourceBundle::InitSharedInstanceWithLocale(
"en-US", nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
pak_file = pak_dir.Append(FILE_PATH_LITERAL("xwalk.pak"));
ResourceBundle::GetSharedInstance().AddDataPackFromPath(
pak_file, ui::SCALE_FACTOR_NONE);
#else
ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
pak_file = pak_dir.Append(FILE_PATH_LITERAL("xwalk_100_percent.pak"));
ResourceBundle::GetSharedInstance().AddDataPackFromPath(
pak_file, ui::SCALE_FACTOR_100P);
pak_file = pak_dir.Append(FILE_PATH_LITERAL("xwalk_200_percent.pak"));
ResourceBundle::GetSharedInstance().AddDataPackFromPath(
pak_file, ui::SCALE_FACTOR_200P);
pak_file = pak_dir.Append(FILE_PATH_LITERAL("xwalk_300_percent.pak"));
ResourceBundle::GetSharedInstance().AddDataPackFromPath(
pak_file, ui::SCALE_FACTOR_300P);
#endif
}

Expand Down
55 changes: 51 additions & 4 deletions xwalk.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -659,15 +659,11 @@
'<(SHARED_INTERMEDIATE_DIR)/xwalk/xwalk_application_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/xwalk/xwalk_extensions_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/xwalk/xwalk_sysapps_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/strings/app_locale_settings_en-US.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/strings/ui_strings_en-US.pak',
'<(SHARED_INTERMEDIATE_DIR)/components/components_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/components/components_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_image_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/app/strings/content_strings_en-US.pak',
],
Expand All @@ -682,6 +678,21 @@
],
},
}],
],
'includes': ['../build/repack_action.gypi'],
},
{
'action_name': 'repack_xwalk_resources_100_percent',
'variables': {
'pak_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/components/components_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_image_resources_100_percent.pak',
],
'pak_output': '<(PRODUCT_DIR)/xwalk_100_percent.pak',
},
'conditions': [
['toolkit_views==1', {
'variables': {
'pak_inputs+': [
Expand All @@ -692,6 +703,39 @@
],
'includes': ['../build/repack_action.gypi'],
},
{
'action_name': 'repack_xwalk_resources_200_percent',
'variables': {
'pak_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_200_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_200_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/components/components_resources_200_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_image_resources_200_percent.pak',
],
'pak_output': '<(PRODUCT_DIR)/xwalk_200_percent.pak',
},
'conditions': [
['toolkit_views==1', {
'variables': {
'pak_inputs+': [
'<(SHARED_INTERMEDIATE_DIR)/ui/views/resources/views_resources_200_percent.pak',
],
},
}],
],
'includes': ['../build/repack_action.gypi'],
},
{
'action_name': 'repack_xwalk_resources_300_percent',
'variables': {
'pak_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_300_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/components/components_resources_300_percent.pak',
],
'pak_output': '<(PRODUCT_DIR)/xwalk_300_percent.pak',
},
'includes': ['../build/repack_action.gypi'],
},
],
},
{
Expand Down Expand Up @@ -885,6 +929,9 @@
'mac_bundle_resources': [
'runtime/app/English.lproj/MainMenu.xib',
'<(PRODUCT_DIR)/xwalk.pak',
'<(PRODUCT_DIR)/xwalk_100_percent.pak',
'<(PRODUCT_DIR)/xwalk_200_percent.pak',
'<(PRODUCT_DIR)/xwalk_300_percent.pak',
'<(PRODUCT_DIR)/snapshot_blob.bin',
'<(PRODUCT_DIR)/natives_blob.bin',
],
Expand Down
3 changes: 3 additions & 0 deletions xwalk_android.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
'<(PRODUCT_DIR)/xwalk_runtime_lib/assets/jsapi/messaging_api.js',
'<(PRODUCT_DIR)/xwalk_runtime_lib/assets/jsapi/wifidirect_api.js',
'<(PRODUCT_DIR)/xwalk_runtime_lib/assets/xwalk.pak',
'<(PRODUCT_DIR)/xwalk_runtime_lib/assets/xwalk_100_percent.pak',
],
'conditions': [
['icu_use_data_file_flag==1', {
Expand Down Expand Up @@ -288,6 +289,7 @@
'base_inputs': [
'<(dex_path)',
'<(PRODUCT_DIR)/xwalk_runtime_lib/assets/xwalk.pak',
'<(PRODUCT_DIR)/xwalk_runtime_lib/assets/xwalk_100_percent.pak',
'<(PRODUCT_DIR)/xwalk_runtime_lib/assets/icudtl.dat',
],
'build_system_inputs': [
Expand Down Expand Up @@ -327,6 +329,7 @@
'destination': '<(PRODUCT_DIR)/xwalk_runtime_lib/assets',
'files': [
'<(PRODUCT_DIR)/xwalk.pak',
'<(PRODUCT_DIR)/xwalk_100_percent.pak',
],
'conditions': [
['icu_use_data_file_flag==1', {
Expand Down
8 changes: 8 additions & 0 deletions xwalk_android_tests.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'<(PRODUCT_DIR)/xwalk_xwview/assets/www/request_focus_right_frame.html',
'<(PRODUCT_DIR)/xwalk_xwview/assets/www/request_focus_right_frame1.html',
'<(PRODUCT_DIR)/xwalk_xwview/assets/xwalk.pak',
'<(PRODUCT_DIR)/xwalk_xwview/assets/xwalk_100_percent.pak',
'<(PRODUCT_DIR)/xwalk_xwview/assets/jsapi/contacts_api.js',
'<(PRODUCT_DIR)/xwalk_xwview/assets/jsapi/device_capabilities_api.js',
'<(PRODUCT_DIR)/xwalk_xwview/assets/jsapi/launch_screen_api.js',
Expand Down Expand Up @@ -103,6 +104,7 @@
'destination': '<(PRODUCT_DIR)/xwalk_xwview/assets',
'files': [
'<(PRODUCT_DIR)/xwalk.pak',
'<(PRODUCT_DIR)/xwalk_100_percent.pak',
],
'conditions': [
['icu_use_data_file_flag==1', {
Expand Down Expand Up @@ -352,6 +354,7 @@
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/xwalk-extensions/myextension/myextension.json',
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/sampapp-icon-helloworld.png',
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/xwalk.pak',
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/xwalk_100_percent.pak',
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/www/manifest_self.json',
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/www/manifest_inline_script.json',
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/www/cross_origin.html',
Expand Down Expand Up @@ -423,6 +426,7 @@
'destination': '<(PRODUCT_DIR)/runtime_client_embedded_shell/assets',
'files': [
'<(PRODUCT_DIR)/xwalk.pak',
'<(PRODUCT_DIR)/xwalk_100_percent.pak',
],
'conditions': [
['icu_use_data_file_flag==1', {
Expand Down Expand Up @@ -578,6 +582,7 @@
'<(PRODUCT_DIR)/sample/assets/new_window.html',
'<(PRODUCT_DIR)/sample/assets/pause_timers.html',
'<(PRODUCT_DIR)/sample/assets/xwalk.pak',
'<(PRODUCT_DIR)/sample/assets/xwalk_100_percent.pak',
],
'conditions': [
['icu_use_data_file_flag==1', {
Expand Down Expand Up @@ -610,6 +615,7 @@
'runtime/android/sample/assets/pause_timers.html',
'test/android/data/echo_java.html',
'<(PRODUCT_DIR)/xwalk.pak',
'<(PRODUCT_DIR)/xwalk_100_percent.pak',
],
'conditions': [
['icu_use_data_file_flag==1', {
Expand Down Expand Up @@ -646,6 +652,7 @@
'additional_input_paths': [
'<(PRODUCT_DIR)/xwalk_internal_xwview/assets/www/index.html',
'<(PRODUCT_DIR)/xwalk_internal_xwview/assets/xwalk.pak',
'<(PRODUCT_DIR)/xwalk_internal_xwview/assets/xwalk_100_percent.pak',
],
'conditions': [
['icu_use_data_file_flag==1', {
Expand Down Expand Up @@ -683,6 +690,7 @@
'destination': '<(PRODUCT_DIR)/xwalk_internal_xwview/assets',
'files': [
'<(PRODUCT_DIR)/xwalk.pak',
'<(PRODUCT_DIR)/xwalk_100_percent.pak',
],
'conditions': [
['icu_use_data_file_flag==1', {
Expand Down
3 changes: 3 additions & 0 deletions xwalk_win_zip.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
'<(PRODUCT_DIR)/snapshot_blob.bin',
'<(PRODUCT_DIR)/xwalk.exe',
'<(PRODUCT_DIR)/xwalk.pak',
'<(PRODUCT_DIR)/xwalk_100_percent.pak',
'<(PRODUCT_DIR)/xwalk_200_percent.pak',
'<(PRODUCT_DIR)/xwalk_300_percent.pak',
'<(PRODUCT_DIR)/xwalk_dotnet_bridge.dll',
],
},
Expand Down

0 comments on commit f827a69

Please sign in to comment.