From 1b72e883523830f699573560546a7d65f2e1681c Mon Sep 17 00:00:00 2001 From: Lin Sun Date: Thu, 2 Apr 2015 19:03:56 +0800 Subject: [PATCH] Add gyp flag use_minimum_resources and exclude unnecessary resources Remove following resources: 1. Resources for media player control bar, this part is not usually used, thus it could be overriden by web developers. 2. The ui resources are for aura/views, Android doesn't need it. This patch is the backport from Crosswalk-lite BUG=https://crosswalk-project.org/jira/browse/XWALK-3928 TEST=Build with/without flag use_minimum_resources and simple test on XWalkCoreShell.apk SIZE_REDUCED=212k(Release build on ARM) --- build/common.gypi | 10 ++++++++++ content/child/blink_platform_impl.cc | 2 ++ ui/resources/ui_resources.grd | 18 ++++++++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/build/common.gypi b/build/common.gypi index 1ec890c5e75ad..002857874502c 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -565,6 +565,9 @@ # Enable web audio hrtf by default. 'disable_webaudio_hrtf%': 0, + # Include all resources by default. + 'use_minimum_resources%': 0, + # Use native android functions in place of ICU. Not supported by most # components. 'use_icu_alternatives_on_android%': 0, @@ -1190,6 +1193,7 @@ 'disable_file_support%': '<(disable_file_support)', 'disable_ftp_support%': '<(disable_ftp_support)', 'disable_webaudio_hrtf%': '<(disable_webaudio_hrtf)', + 'use_minimum_resources%': '<(use_minimum_resources)', 'use_icu_alternatives_on_android%': '<(use_icu_alternatives_on_android)', 'enable_task_manager%': '<(enable_task_manager)', 'sas_dll_path%': '<(sas_dll_path)', @@ -2132,6 +2136,9 @@ ['disable_webaudio_hrtf==1', { 'grit_defines': ['-D', 'disable_webaudio_hrtf'], }], + ['use_minimum_resources==1', { + 'grit_defines': ['-D', 'use_minimum_resources'], + }], ['enable_media_router==1', { 'grit_defines': ['-D', 'enable_media_router'], }], @@ -2979,6 +2986,9 @@ ['disable_ftp_support==1', { 'defines': ['DISABLE_FTP_SUPPORT=1'], }], + ['use_minimum_resources==1', { + 'defines': ['USE_MINIMUM_RESOURCES=1'], + }], ['enable_supervised_users==1', { 'defines': ['ENABLE_SUPERVISED_USERS=1'], }], diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc index 73b4825e75419..d1ca23324a6f6 100644 --- a/content/child/blink_platform_impl.cc +++ b/content/child/blink_platform_impl.cc @@ -793,6 +793,7 @@ struct DataResource { const DataResource kDataResources[] = { {"missingImage", IDR_BROKENIMAGE, ui::SCALE_FACTOR_100P}, {"missingImage@2x", IDR_BROKENIMAGE, ui::SCALE_FACTOR_200P}, +#if !defined(USE_MINIMUM_RESOURCES) {"mediaplayerPause", IDR_MEDIAPLAYER_PAUSE_BUTTON, ui::SCALE_FACTOR_100P}, {"mediaplayerPauseHover", IDR_MEDIAPLAYER_PAUSE_BUTTON_HOVER, @@ -906,6 +907,7 @@ const DataResource kDataResources[] = { {"mediaplayerOverlayPlay", IDR_MEDIAPLAYER_OVERLAY_PLAY_BUTTON, ui::SCALE_FACTOR_100P}, +#endif {"panIcon", IDR_PAN_SCROLL_ICON, ui::SCALE_FACTOR_100P}, {"searchCancel", IDR_SEARCH_CANCEL, ui::SCALE_FACTOR_100P}, {"searchCancelPressed", IDR_SEARCH_CANCEL_PRESSED, ui::SCALE_FACTOR_100P}, diff --git a/ui/resources/ui_resources.grd b/ui/resources/ui_resources.grd index cc547b0a45d69..eea2e3e8f242d 100644 --- a/ui/resources/ui_resources.grd +++ b/ui/resources/ui_resources.grd @@ -12,6 +12,15 @@ + + + + + + + + + @@ -306,7 +315,6 @@ - @@ -324,7 +332,6 @@ - @@ -387,12 +394,6 @@ - - - - - - @@ -593,6 +594,7 @@ +