diff options
author | Torne (Richard Coles) <torne@google.com> | 2014-06-25 10:30:53 +0100 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2014-06-25 10:30:53 +0100 |
commit | 6d86b77056ed63eb6871182f42a9fd5f07550f90 (patch) | |
tree | 4bd56255660f52e406fbd45083c006cd6ddb2877 /cc | |
parent | e9f930807da3850e29ecc641d2becc0403b5709c (diff) | |
download | chromium_org-6d86b77056ed63eb6871182f42a9fd5f07550f90.tar.gz |
Merge from Chromium at DEPS revision 278856
This commit was generated by merge_to_master.py.
Change-Id: If3807744d3e5d3ee84b897bd2d099a2b7ed2e7a3
Diffstat (limited to 'cc')
105 files changed, 867 insertions, 2630 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn index 1a1e7366fa..d284456eda 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn @@ -344,8 +344,6 @@ component("cc") { "resources/prioritized_resource.h", "resources/prioritized_resource_manager.cc", "resources/prioritized_resource_manager.h", - "resources/prioritized_tile_set.cc", - "resources/prioritized_tile_set.h", "resources/priority_calculator.cc", "resources/priority_calculator.h", "resources/raster_mode.cc", @@ -712,7 +710,6 @@ test("cc_unittests") { "resources/picture_pile_unittest.cc", "resources/picture_unittest.cc", "resources/prioritized_resource_unittest.cc", - "resources/prioritized_tile_set_unittest.cc", "resources/raster_worker_pool_unittest.cc", "resources/resource_provider_unittest.cc", "resources/resource_update_controller_unittest.cc", @@ -371,8 +371,6 @@ 'resources/prioritized_resource.h', 'resources/prioritized_resource_manager.cc', 'resources/prioritized_resource_manager.h', - 'resources/prioritized_tile_set.cc', - 'resources/prioritized_tile_set.h', 'resources/priority_calculator.cc', 'resources/priority_calculator.h', 'resources/raster_mode.cc', diff --git a/cc/cc.target.darwin-arm.mk b/cc/cc.target.darwin-arm.mk index cf8d707865..1478a4bedc 100644 --- a/cc/cc.target.darwin-arm.mk +++ b/cc/cc.target.darwin-arm.mk @@ -183,7 +183,6 @@ LOCAL_SRC_FILES := \ cc/resources/pixel_buffer_raster_worker_pool.cc \ cc/resources/prioritized_resource.cc \ cc/resources/prioritized_resource_manager.cc \ - cc/resources/prioritized_tile_set.cc \ cc/resources/priority_calculator.cc \ cc/resources/raster_mode.cc \ cc/resources/raster_worker_pool.cc \ @@ -294,6 +293,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -310,6 +310,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -434,6 +435,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -450,6 +452,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc.target.darwin-arm64.mk b/cc/cc.target.darwin-arm64.mk index cf3a19c04a..25c1c32cf1 100644 --- a/cc/cc.target.darwin-arm64.mk +++ b/cc/cc.target.darwin-arm64.mk @@ -183,7 +183,6 @@ LOCAL_SRC_FILES := \ cc/resources/pixel_buffer_raster_worker_pool.cc \ cc/resources/prioritized_resource.cc \ cc/resources/prioritized_resource_manager.cc \ - cc/resources/prioritized_tile_set.cc \ cc/resources/priority_calculator.cc \ cc/resources/raster_mode.cc \ cc/resources/raster_worker_pool.cc \ @@ -284,6 +283,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -300,6 +300,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -413,6 +414,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -429,6 +431,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc.target.darwin-mips.mk b/cc/cc.target.darwin-mips.mk index f5cf3eff2c..b281f2d16f 100644 --- a/cc/cc.target.darwin-mips.mk +++ b/cc/cc.target.darwin-mips.mk @@ -183,7 +183,6 @@ LOCAL_SRC_FILES := \ cc/resources/pixel_buffer_raster_worker_pool.cc \ cc/resources/prioritized_resource.cc \ cc/resources/prioritized_resource_manager.cc \ - cc/resources/prioritized_tile_set.cc \ cc/resources/priority_calculator.cc \ cc/resources/raster_mode.cc \ cc/resources/raster_worker_pool.cc \ @@ -288,6 +287,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -304,6 +304,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -422,6 +423,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -438,6 +440,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc.target.darwin-x86.mk b/cc/cc.target.darwin-x86.mk index 00925e6276..fead8a28a2 100644 --- a/cc/cc.target.darwin-x86.mk +++ b/cc/cc.target.darwin-x86.mk @@ -183,7 +183,6 @@ LOCAL_SRC_FILES := \ cc/resources/pixel_buffer_raster_worker_pool.cc \ cc/resources/prioritized_resource.cc \ cc/resources/prioritized_resource_manager.cc \ - cc/resources/prioritized_tile_set.cc \ cc/resources/priority_calculator.cc \ cc/resources/raster_mode.cc \ cc/resources/raster_worker_pool.cc \ @@ -289,6 +288,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -305,6 +305,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -423,6 +424,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -439,6 +441,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc.target.darwin-x86_64.mk b/cc/cc.target.darwin-x86_64.mk index 1d32942d47..93b6abc5be 100644 --- a/cc/cc.target.darwin-x86_64.mk +++ b/cc/cc.target.darwin-x86_64.mk @@ -183,7 +183,6 @@ LOCAL_SRC_FILES := \ cc/resources/pixel_buffer_raster_worker_pool.cc \ cc/resources/prioritized_resource.cc \ cc/resources/prioritized_resource_manager.cc \ - cc/resources/prioritized_tile_set.cc \ cc/resources/priority_calculator.cc \ cc/resources/raster_mode.cc \ cc/resources/raster_worker_pool.cc \ @@ -288,6 +287,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -304,6 +304,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -421,6 +422,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -437,6 +439,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc.target.linux-arm.mk b/cc/cc.target.linux-arm.mk index cf8d707865..1478a4bedc 100644 --- a/cc/cc.target.linux-arm.mk +++ b/cc/cc.target.linux-arm.mk @@ -183,7 +183,6 @@ LOCAL_SRC_FILES := \ cc/resources/pixel_buffer_raster_worker_pool.cc \ cc/resources/prioritized_resource.cc \ cc/resources/prioritized_resource_manager.cc \ - cc/resources/prioritized_tile_set.cc \ cc/resources/priority_calculator.cc \ cc/resources/raster_mode.cc \ cc/resources/raster_worker_pool.cc \ @@ -294,6 +293,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -310,6 +310,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -434,6 +435,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -450,6 +452,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc.target.linux-arm64.mk b/cc/cc.target.linux-arm64.mk index cf3a19c04a..25c1c32cf1 100644 --- a/cc/cc.target.linux-arm64.mk +++ b/cc/cc.target.linux-arm64.mk @@ -183,7 +183,6 @@ LOCAL_SRC_FILES := \ cc/resources/pixel_buffer_raster_worker_pool.cc \ cc/resources/prioritized_resource.cc \ cc/resources/prioritized_resource_manager.cc \ - cc/resources/prioritized_tile_set.cc \ cc/resources/priority_calculator.cc \ cc/resources/raster_mode.cc \ cc/resources/raster_worker_pool.cc \ @@ -284,6 +283,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -300,6 +300,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -413,6 +414,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -429,6 +431,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc.target.linux-mips.mk b/cc/cc.target.linux-mips.mk index f5cf3eff2c..b281f2d16f 100644 --- a/cc/cc.target.linux-mips.mk +++ b/cc/cc.target.linux-mips.mk @@ -183,7 +183,6 @@ LOCAL_SRC_FILES := \ cc/resources/pixel_buffer_raster_worker_pool.cc \ cc/resources/prioritized_resource.cc \ cc/resources/prioritized_resource_manager.cc \ - cc/resources/prioritized_tile_set.cc \ cc/resources/priority_calculator.cc \ cc/resources/raster_mode.cc \ cc/resources/raster_worker_pool.cc \ @@ -288,6 +287,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -304,6 +304,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -422,6 +423,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -438,6 +440,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc.target.linux-x86.mk b/cc/cc.target.linux-x86.mk index 00925e6276..fead8a28a2 100644 --- a/cc/cc.target.linux-x86.mk +++ b/cc/cc.target.linux-x86.mk @@ -183,7 +183,6 @@ LOCAL_SRC_FILES := \ cc/resources/pixel_buffer_raster_worker_pool.cc \ cc/resources/prioritized_resource.cc \ cc/resources/prioritized_resource_manager.cc \ - cc/resources/prioritized_tile_set.cc \ cc/resources/priority_calculator.cc \ cc/resources/raster_mode.cc \ cc/resources/raster_worker_pool.cc \ @@ -289,6 +288,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -305,6 +305,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -423,6 +424,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -439,6 +441,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc.target.linux-x86_64.mk b/cc/cc.target.linux-x86_64.mk index 1d32942d47..93b6abc5be 100644 --- a/cc/cc.target.linux-x86_64.mk +++ b/cc/cc.target.linux-x86_64.mk @@ -183,7 +183,6 @@ LOCAL_SRC_FILES := \ cc/resources/pixel_buffer_raster_worker_pool.cc \ cc/resources/prioritized_resource.cc \ cc/resources/prioritized_resource_manager.cc \ - cc/resources/prioritized_tile_set.cc \ cc/resources/priority_calculator.cc \ cc/resources/raster_mode.cc \ cc/resources/raster_worker_pool.cc \ @@ -288,6 +287,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -304,6 +304,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -421,6 +422,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_IMPLEMENTATION=1' \ '-DMEDIA_DISABLE_LIBVPX' \ @@ -437,6 +439,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc_surfaces.target.darwin-arm.mk b/cc/cc_surfaces.target.darwin-arm.mk index 8460098683..e8dca7745a 100644 --- a/cc/cc_surfaces.target.darwin-arm.mk +++ b/cc/cc_surfaces.target.darwin-arm.mk @@ -95,6 +95,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -110,6 +111,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -231,6 +233,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -246,6 +249,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc_surfaces.target.darwin-arm64.mk b/cc/cc_surfaces.target.darwin-arm64.mk index bf3845dcf9..bec94df010 100644 --- a/cc/cc_surfaces.target.darwin-arm64.mk +++ b/cc/cc_surfaces.target.darwin-arm64.mk @@ -85,6 +85,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -100,6 +101,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -210,6 +212,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -225,6 +228,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc_surfaces.target.darwin-mips.mk b/cc/cc_surfaces.target.darwin-mips.mk index 3b5aa354fd..ef6c0ae44e 100644 --- a/cc/cc_surfaces.target.darwin-mips.mk +++ b/cc/cc_surfaces.target.darwin-mips.mk @@ -89,6 +89,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -104,6 +105,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -219,6 +221,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -234,6 +237,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc_surfaces.target.darwin-x86.mk b/cc/cc_surfaces.target.darwin-x86.mk index 6709d723a2..b1994e628f 100644 --- a/cc/cc_surfaces.target.darwin-x86.mk +++ b/cc/cc_surfaces.target.darwin-x86.mk @@ -90,6 +90,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -105,6 +106,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -220,6 +222,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -235,6 +238,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc_surfaces.target.darwin-x86_64.mk b/cc/cc_surfaces.target.darwin-x86_64.mk index 634023f743..418765376d 100644 --- a/cc/cc_surfaces.target.darwin-x86_64.mk +++ b/cc/cc_surfaces.target.darwin-x86_64.mk @@ -89,6 +89,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -104,6 +105,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -218,6 +220,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -233,6 +236,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc_surfaces.target.linux-arm.mk b/cc/cc_surfaces.target.linux-arm.mk index 8460098683..e8dca7745a 100644 --- a/cc/cc_surfaces.target.linux-arm.mk +++ b/cc/cc_surfaces.target.linux-arm.mk @@ -95,6 +95,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -110,6 +111,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -231,6 +233,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -246,6 +249,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc_surfaces.target.linux-arm64.mk b/cc/cc_surfaces.target.linux-arm64.mk index bf3845dcf9..bec94df010 100644 --- a/cc/cc_surfaces.target.linux-arm64.mk +++ b/cc/cc_surfaces.target.linux-arm64.mk @@ -85,6 +85,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -100,6 +101,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -210,6 +212,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -225,6 +228,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc_surfaces.target.linux-mips.mk b/cc/cc_surfaces.target.linux-mips.mk index 3b5aa354fd..ef6c0ae44e 100644 --- a/cc/cc_surfaces.target.linux-mips.mk +++ b/cc/cc_surfaces.target.linux-mips.mk @@ -89,6 +89,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -104,6 +105,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -219,6 +221,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -234,6 +237,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc_surfaces.target.linux-x86.mk b/cc/cc_surfaces.target.linux-x86.mk index 6709d723a2..b1994e628f 100644 --- a/cc/cc_surfaces.target.linux-x86.mk +++ b/cc/cc_surfaces.target.linux-x86.mk @@ -90,6 +90,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -105,6 +106,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -220,6 +222,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -235,6 +238,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc_surfaces.target.linux-x86_64.mk b/cc/cc_surfaces.target.linux-x86_64.mk index 634023f743..418765376d 100644 --- a/cc/cc_surfaces.target.linux-x86_64.mk +++ b/cc/cc_surfaces.target.linux-x86_64.mk @@ -89,6 +89,7 @@ MY_DEFS_Debug := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -104,6 +105,7 @@ MY_DEFS_Debug := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -218,6 +220,7 @@ MY_DEFS_Release := \ '-DDATA_REDUCTION_DEV_HOST="http://proxy-dev.googlezip.net:80/"' \ '-DSPDY_PROXY_AUTH_ORIGIN="https://proxy.googlezip.net:443/"' \ '-DDATA_REDUCTION_PROXY_PROBE_URL="http://check.googlezip.net/connect"' \ + '-DDATA_REDUCTION_PROXY_WARMUP_URL="http://www.gstatic.com/generate_204"' \ '-DVIDEO_HOLE=1' \ '-DCC_SURFACES_IMPLEMENTATION=1' \ '-DSK_ENABLE_INST_COUNT=0' \ @@ -233,6 +236,7 @@ MY_DEFS_Release := \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ + '-DSK_IGNORE_GPU_DITHER' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index af160850bc..ce114fd5ea 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -75,7 +75,6 @@ 'resources/picture_pile_unittest.cc', 'resources/picture_unittest.cc', 'resources/prioritized_resource_unittest.cc', - 'resources/prioritized_tile_set_unittest.cc', 'resources/raster_worker_pool_unittest.cc', 'resources/resource_provider_unittest.cc', 'resources/resource_update_controller_unittest.cc', diff --git a/cc/layers/delegated_renderer_layer_impl_unittest.cc b/cc/layers/delegated_renderer_layer_impl_unittest.cc index fbaf8bbf24..41c301aad3 100644 --- a/cc/layers/delegated_renderer_layer_impl_unittest.cc +++ b/cc/layers/delegated_renderer_layer_impl_unittest.cc @@ -530,7 +530,8 @@ class DelegatedRendererLayerImplTestTransform child_pass_clip_rect, child_pass_clipped, 1.f, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<SolidColorDrawQuad> color_quad; color_quad = SolidColorDrawQuad::Create(); @@ -570,7 +571,8 @@ class DelegatedRendererLayerImplTestTransform root_pass_clip_rect, root_pass_clipped, 1.f, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<RenderPassDrawQuad> render_pass_quad = RenderPassDrawQuad::Create(); @@ -973,7 +975,8 @@ class DelegatedRendererLayerImplTestClip child_pass_clip_rect, child_pass_clipped, 1.f, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<SolidColorDrawQuad> color_quad; color_quad = SolidColorDrawQuad::Create(); @@ -1011,7 +1014,8 @@ class DelegatedRendererLayerImplTestClip root_pass_clip_rect, root_pass_clipped, 1.f, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<RenderPassDrawQuad> render_pass_quad = RenderPassDrawQuad::Create(); diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index 6149a06be0..a8553f2e75 100644 --- a/cc/layers/heads_up_display_layer_impl.cc +++ b/cc/layers/heads_up_display_layer_impl.cc @@ -456,7 +456,7 @@ SkRect HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas* canvas, int right, int top, int width) const { - if (!memory_entry_.bytes_total()) + if (!memory_entry_.total_bytes_used) return SkRect::MakeEmpty(); const int kPadding = 4; @@ -466,7 +466,7 @@ SkRect HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas* canvas, const int left = bounds().width() - width - right; const SkRect area = SkRect::MakeXYWH(left, top, width, height); - const double megabyte = 1024.0 * 1024.0; + const double kMegabyte = 1024.0 * 1024.0; SkPaint paint = CreatePaint(); DrawGraphBackground(canvas, &paint, area); @@ -485,20 +485,14 @@ SkRect HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas* canvas, kFontHeight, title_pos); - std::string text = - base::StringPrintf("%6.1f MB used", - (memory_entry_.bytes_unreleasable + - memory_entry_.bytes_allocated) / megabyte); + std::string text = base::StringPrintf( + "%6.1f MB used", memory_entry_.total_bytes_used / kMegabyte); DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat1_pos); - if (memory_entry_.bytes_over) { + if (!memory_entry_.had_enough_memory) paint.setColor(SK_ColorRED); - text = base::StringPrintf("%6.1f MB over", - memory_entry_.bytes_over / megabyte); - } else { - text = base::StringPrintf("%6.1f MB max ", - memory_entry_.total_budget_in_bytes / megabyte); - } + text = base::StringPrintf("%6.1f MB max ", + memory_entry_.total_budget_in_bytes / kMegabyte); DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat2_pos); return area; diff --git a/cc/layers/io_surface_layer_impl.cc b/cc/layers/io_surface_layer_impl.cc index 6d94c91e88..65fb6b2230 100644 --- a/cc/layers/io_surface_layer_impl.cc +++ b/cc/layers/io_surface_layer_impl.cc @@ -69,7 +69,8 @@ void IOSurfaceLayerImpl::AppendQuads(QuadSink* quad_sink, SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); PopulateSharedQuadState(shared_quad_state); - AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); + AppendDebugBorderQuad( + quad_sink, content_bounds(), shared_quad_state, append_quads_data); gfx::Rect quad_rect(content_bounds()); gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index 67664e088b..e00d2c5b90 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -42,6 +42,7 @@ Layer::Layer() // Layer IDs start from 1. layer_id_(g_next_layer_id.GetNext() + 1), ignore_set_needs_commit_(false), + sorting_context_id_(0), parent_(NULL), layer_tree_host_(NULL), scroll_clip_layer_id_(INVALID_ID), @@ -61,7 +62,6 @@ Layer::Layer() use_parent_backface_visibility_(false), draw_checkerboard_for_missing_tiles_(false), force_render_surface_(false), - is_3d_sorted_(false), transform_is_invertible_(true), background_color_(0), opacity_(1.f), @@ -756,11 +756,11 @@ void Layer::SetDoubleSided(bool double_sided) { SetNeedsCommit(); } -void Layer::SetIs3dSorted(bool sorted) { +void Layer::Set3dSortingContextId(int id) { DCHECK(IsPropertyChangeAllowed()); - if (is_3d_sorted_ == sorted) + if (id == sorting_context_id_) return; - is_3d_sorted_ = sorted; + sorting_context_id_ = id; SetNeedsCommit(); } @@ -894,11 +894,11 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { IsContainerForFixedPositionLayers()); layer->SetPositionConstraint(position_constraint_); layer->SetShouldFlattenTransform(should_flatten_transform_); - layer->SetIs3dSorted(is_3d_sorted_); layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); + layer->Set3dSortingContextId(sorting_context_id_); layer->SetScrollClipLayer(scroll_clip_layer_id_); layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); diff --git a/cc/layers/layer.h b/cc/layers/layer.h index 9e94b53505..ab897a8ac9 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -320,8 +320,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, void SetShouldFlattenTransform(bool flatten); bool should_flatten_transform() const { return should_flatten_transform_; } - void SetIs3dSorted(bool sorted); - bool is_3d_sorted() const { return is_3d_sorted_; } + bool Is3dSorted() const { return sorting_context_id_ != 0; } void set_use_parent_backface_visibility(bool use) { use_parent_backface_visibility_ = use; @@ -458,6 +457,9 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, virtual void RunMicroBenchmark(MicroBenchmark* benchmark); + void Set3dSortingContextId(int id); + int sorting_context_id() const { return sorting_context_id_; } + protected: friend class LayerImpl; friend class TreeSynchronizer; @@ -530,6 +532,11 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, // will be handled implicitly after the update completes. bool ignore_set_needs_commit_; + // Layers that share a sorting context id will be sorted together in 3d + // space. 0 is a special value that means this layer will not be sorted and + // will be drawn in paint order. + int sorting_context_id_; + private: friend class base::RefCounted<Layer>; @@ -588,7 +595,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, bool use_parent_backface_visibility_ : 1; bool draw_checkerboard_for_missing_tiles_ : 1; bool force_render_surface_ : 1; - bool is_3d_sorted_ : 1; bool transform_is_invertible_ : 1; Region non_fast_scrollable_region_; Region touch_event_handler_region_; diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 52a15eef2c..fa68275bd7 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -61,13 +61,13 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) force_render_surface_(false), transform_is_invertible_(true), is_container_for_fixed_position_layers_(false), - is_3d_sorted_(false), background_color_(0), opacity_(1.0), blend_mode_(SkXfermode::kSrcOver_Mode), draw_depth_(0.f), needs_push_properties_(false), num_dependents_need_push_properties_(0), + sorting_context_id_(0), current_draw_mode_(DRAW_MODE_NONE) { DCHECK_GT(layer_id_, 0); DCHECK(layer_tree_impl_); @@ -248,7 +248,8 @@ void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { draw_properties_.clip_rect, draw_properties_.is_clipped, draw_properties_.opacity, - blend_mode_); + blend_mode_, + sorting_context_id_); } bool LayerImpl::WillDraw(DrawMode draw_mode, @@ -288,16 +289,22 @@ void LayerImpl::GetDebugBorderProperties(SkColor* color, float* width) const { void LayerImpl::AppendDebugBorderQuad( QuadSink* quad_sink, + const gfx::Size& content_bounds, const SharedQuadState* shared_quad_state, AppendQuadsData* append_quads_data) const { SkColor color; float width; GetDebugBorderProperties(&color, &width); - AppendDebugBorderQuad( - quad_sink, shared_quad_state, append_quads_data, color, width); + AppendDebugBorderQuad(quad_sink, + content_bounds, + shared_quad_state, + append_quads_data, + color, + width); } void LayerImpl::AppendDebugBorderQuad(QuadSink* quad_sink, + const gfx::Size& content_bounds, const SharedQuadState* shared_quad_state, AppendQuadsData* append_quads_data, SkColor color, @@ -305,7 +312,7 @@ void LayerImpl::AppendDebugBorderQuad(QuadSink* quad_sink, if (!ShowDebugBorders()) return; - gfx::Rect quad_rect(content_bounds()); + gfx::Rect quad_rect(content_bounds); gfx::Rect visible_quad_rect(quad_rect); scoped_ptr<DebugBorderDrawQuad> debug_border_quad = DebugBorderDrawQuad::Create(); @@ -512,7 +519,6 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { is_container_for_fixed_position_layers_); layer->SetPositionConstraint(position_constraint_); layer->SetShouldFlattenTransform(should_flatten_transform_); - layer->SetIs3dSorted(is_3d_sorted_); layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); @@ -523,6 +529,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { layer->SetScrollOffsetAndDelta( scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); layer->SetSentScrollDelta(gfx::Vector2d()); + layer->Set3dSortingContextId(sorting_context_id_); LayerImpl* scroll_parent = NULL; if (scroll_parent_) { @@ -631,7 +638,7 @@ base::DictionaryValue* LayerImpl::LayerTreeAsJson() const { result->Set("DrawTransform", list); result->SetBoolean("DrawsContent", draws_content_); - result->SetBoolean("Is3DSorted", is_3d_sorted_); + result->SetBoolean("Is3dSorted", Is3dSorted()); result->SetDouble("Opacity", opacity()); result->SetBoolean("ContentsOpaque", contents_opaque_); @@ -974,11 +981,10 @@ void LayerImpl::SetShouldFlattenTransform(bool flatten) { NoteLayerPropertyChangedForSubtree(); } -void LayerImpl::SetIs3dSorted(bool sorted) { - if (is_3d_sorted_ == sorted) +void LayerImpl::Set3dSortingContextId(int id) { + if (id == sorting_context_id_) return; - - is_3d_sorted_ = sorted; + sorting_context_id_ = id; NoteLayerPropertyChangedForSubtree(); } diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index b93a504259..cb18604ad8 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -188,7 +188,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, virtual RenderPass::Id FirstContributingRenderPassId() const; virtual RenderPass::Id NextContributingRenderPassId(RenderPass::Id id) const; - virtual void UpdateTilePriorities() {} + virtual void UpdateTiles() {} virtual void NotifyTileStateChanged(const Tile* tile) {} virtual ScrollbarLayerImplBase* ToScrollbarLayer(); @@ -267,8 +267,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, void SetShouldFlattenTransform(bool flatten); bool should_flatten_transform() const { return should_flatten_transform_; } - void SetIs3dSorted(bool sorted); - bool is_3d_sorted() const { return is_3d_sorted_; } + bool Is3dSorted() const { return sorting_context_id_ != 0; } void SetUseParentBackfaceVisibility(bool use) { use_parent_backface_visibility_ = use; @@ -531,6 +530,9 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, bool IsDrawnRenderSurfaceLayerListMember() const; + void Set3dSortingContextId(int id); + int sorting_context_id() { return sorting_context_id_; } + protected: LayerImpl(LayerTreeImpl* layer_impl, int id); @@ -538,9 +540,11 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, virtual void GetDebugBorderProperties(SkColor* color, float* width) const; void AppendDebugBorderQuad(QuadSink* quad_sink, + const gfx::Size& content_bounds, const SharedQuadState* shared_quad_state, AppendQuadsData* append_quads_data) const; void AppendDebugBorderQuad(QuadSink* quad_sink, + const gfx::Size& content_bounds, const SharedQuadState* shared_quad_state, AppendQuadsData* append_quads_data, SkColor color, @@ -618,7 +622,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, // Set for the layer that other layers are fixed to. bool is_container_for_fixed_position_layers_ : 1; - bool is_3d_sorted_ : 1; Region non_fast_scrollable_region_; Region touch_event_handler_region_; SkColor background_color_; @@ -653,6 +656,11 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, // active side. int num_dependents_need_push_properties_; + // Layers that share a sorting context id will be sorted together in 3d + // space. 0 is a special value that means this layer will not be sorted and + // will be drawn in paint order. + int sorting_context_id_; + DrawMode current_draw_mode_; private: diff --git a/cc/layers/layer_impl_unittest.cc b/cc/layers/layer_impl_unittest.cc index 51939e459d..281a3f12ca 100644 --- a/cc/layers/layer_impl_unittest.cc +++ b/cc/layers/layer_impl_unittest.cc @@ -155,7 +155,7 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { root->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 10))); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetPosition(arbitrary_point_f)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetShouldFlattenTransform(false)); - EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetIs3dSorted(true)); + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->Set3dSortingContextId(1)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED( root->SetDoubleSided(false)); // constructor initializes it to "true". EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->ScrollBy(arbitrary_vector2d)); @@ -209,7 +209,7 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { root->SetPosition(arbitrary_point_f)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( root->SetShouldFlattenTransform(false)); - EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetIs3dSorted(true)); + EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( root->SetTransform(arbitrary_transform)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( @@ -303,7 +303,7 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { layer->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 5))); VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetPosition(arbitrary_point_f)); VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetShouldFlattenTransform(false)); - VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetIs3dSorted(true)); + VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1)); VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( layer->SetDoubleSided(false)); // constructor initializes it to "true". @@ -328,7 +328,7 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true)); VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true)); VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetPosition(arbitrary_point_f)); - VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetIs3dSorted(true)); + VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1)); VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( layer->SetDoubleSided(false)); // constructor initializes it to "true". VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( diff --git a/cc/layers/layer_position_constraint_unittest.cc b/cc/layers/layer_position_constraint_unittest.cc index 269bc9656c..d9e1f64bbc 100644 --- a/cc/layers/layer_position_constraint_unittest.cc +++ b/cc/layers/layer_position_constraint_unittest.cc @@ -22,14 +22,12 @@ void SetLayerPropertiesForTesting(LayerImpl* layer, const gfx::Point3F& transform_origin, const gfx::PointF& position, const gfx::Size& bounds, - bool flatten_transform, - bool is_3d_sorted) { + bool flatten_transform) { layer->SetTransform(transform); layer->SetTransformOrigin(transform_origin); layer->SetPosition(position); layer->SetBounds(bounds); layer->SetShouldFlattenTransform(flatten_transform); - layer->SetIs3dSorted(is_3d_sorted); layer->SetContentBounds(bounds); } @@ -96,29 +94,21 @@ class LayerPositionConstraintTest : public testing::Test { transform_origin, position, bounds, - true, - false); - SetLayerPropertiesForTesting(child.get(), - IdentityMatrix, - transform_origin, - position, - bounds, - true, - false); + true); + SetLayerPropertiesForTesting( + child.get(), IdentityMatrix, transform_origin, position, bounds, true); SetLayerPropertiesForTesting(grand_child.get(), IdentityMatrix, transform_origin, position, bounds, - true, - false); + true); SetLayerPropertiesForTesting(great_grand_child.get(), IdentityMatrix, transform_origin, position, bounds, - true, - false); + true); root->SetBounds(clip_bounds); scroll_layer->SetScrollClipLayer(root->id()); @@ -744,8 +734,7 @@ TEST_F(LayerPositionConstraintTest, gfx::Point3F(), gfx::PointF(), gfx::Size(100, 100), - true, - false); + true); great_grand_child->AddChild(fixed_position_child.Pass()); } LayerImpl* fixed_position_child = great_grand_child->children()[0]; diff --git a/cc/layers/nine_patch_layer_impl.cc b/cc/layers/nine_patch_layer_impl.cc index d0596ba7b8..46bd333c10 100644 --- a/cc/layers/nine_patch_layer_impl.cc +++ b/cc/layers/nine_patch_layer_impl.cc @@ -86,7 +86,8 @@ void NinePatchLayerImpl::AppendQuads(QuadSink* quad_sink, SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); PopulateSharedQuadState(shared_quad_state); - AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); + AppendDebugBorderQuad( + quad_sink, content_bounds(), shared_quad_state, append_quads_data); if (!ui_resource_id_) return; diff --git a/cc/layers/painted_scrollbar_layer_impl.cc b/cc/layers/painted_scrollbar_layer_impl.cc index ac6ce4a407..b83419f90d 100644 --- a/cc/layers/painted_scrollbar_layer_impl.cc +++ b/cc/layers/painted_scrollbar_layer_impl.cc @@ -81,7 +81,8 @@ void PaintedScrollbarLayerImpl::AppendQuads( SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); PopulateSharedQuadState(shared_quad_state); - AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); + AppendDebugBorderQuad( + quad_sink, content_bounds(), shared_quad_state, append_quads_data); gfx::Rect thumb_quad_rect = ComputeThumbQuadRect(); gfx::Rect visible_thumb_quad_rect = diff --git a/cc/layers/picture_image_layer_impl.cc b/cc/layers/picture_image_layer_impl.cc index d46ff8d975..247c46adbf 100644 --- a/cc/layers/picture_image_layer_impl.cc +++ b/cc/layers/picture_image_layer_impl.cc @@ -33,21 +33,17 @@ void PictureImageLayerImpl::GetDebugBorderProperties( *width = DebugColors::ImageLayerBorderWidth(layer_tree_impl()); } -bool PictureImageLayerImpl::ShouldAdjustRasterScale( - bool animating_transform_to_screen) const { +bool PictureImageLayerImpl::ShouldAdjustRasterScale() const { return false; } -void PictureImageLayerImpl::RecalculateRasterScales( - bool animating_transform_to_screen, - float maximum_animation_contents_scale) { - // Defaults from PictureLayerImpl. - PictureLayerImpl::RecalculateRasterScales(animating_transform_to_screen, - maximum_animation_contents_scale); - +void PictureImageLayerImpl::RecalculateRasterScales() { // Don't scale images during rastering to ensure image quality, save memory // and avoid frequent re-rastering on change of scale. - raster_contents_scale_ = std::max(1.f, MinimumContentsScale()); + raster_page_scale_ = 1.f; + raster_device_scale_ = 1.f; + raster_source_scale_ = std::max(1.f, MinimumContentsScale()); + raster_contents_scale_ = raster_source_scale_; // We don't need low res tiles. low_res_raster_contents_scale_ = raster_contents_scale_; } diff --git a/cc/layers/picture_image_layer_impl.h b/cc/layers/picture_image_layer_impl.h index 9b76d85efa..cb48cf5e50 100644 --- a/cc/layers/picture_image_layer_impl.h +++ b/cc/layers/picture_image_layer_impl.h @@ -25,11 +25,8 @@ class CC_EXPORT PictureImageLayerImpl : public PictureLayerImpl { protected: PictureImageLayerImpl(LayerTreeImpl* tree_impl, int id); - virtual bool ShouldAdjustRasterScale( - bool animating_transform_to_screen) const OVERRIDE; - virtual void RecalculateRasterScales(bool animating_transform_to_screen, - float maximum_animation_contents_scale) - OVERRIDE; + virtual bool ShouldAdjustRasterScale() const OVERRIDE; + virtual void RecalculateRasterScales() OVERRIDE; virtual void GetDebugBorderProperties( SkColor* color, float* width) const OVERRIDE; diff --git a/cc/layers/picture_image_layer_impl_unittest.cc b/cc/layers/picture_image_layer_impl_unittest.cc index 005a323ba9..e8eb8ff627 100644 --- a/cc/layers/picture_image_layer_impl_unittest.cc +++ b/cc/layers/picture_image_layer_impl_unittest.cc @@ -26,18 +26,8 @@ class TestablePictureImageLayerImpl : public PictureImageLayerImpl { } using PictureLayerImpl::UpdateIdealScales; using PictureLayerImpl::MaximumTilingContentsScale; - using PictureLayerImpl::ManageTilings; using PictureLayerImpl::DoPostCommitInitializationIfNeeded; - void ScaleAndManageTilings(bool animating_transform_to_screen, - float maximum_animation_contents_scale) { - DoPostCommitInitializationIfNeeded(); - UpdateIdealScales(); - if (CanHaveTilings()) { - ManageTilings(animating_transform_to_screen, - maximum_animation_contents_scale); - } - } PictureLayerTilingSet* tilings() { return tilings_.get(); } friend class PictureImageLayerImplTest; @@ -80,13 +70,12 @@ class PictureImageLayerImplTest : public testing::Test { return make_scoped_ptr(layer); } - void SetupDrawPropertiesAndManageTilings( - TestablePictureImageLayerImpl* layer, - float ideal_contents_scale, - float device_scale_factor, - float page_scale_factor, - float maximum_animation_contents_scale, - bool animating_transform_to_screen) { + void SetupDrawPropertiesAndUpdateTiles(TestablePictureImageLayerImpl* layer, + float ideal_contents_scale, + float device_scale_factor, + float page_scale_factor, + float maximum_animation_contents_scale, + bool animating_transform_to_screen) { layer->draw_properties().ideal_contents_scale = ideal_contents_scale; layer->draw_properties().device_scale_factor = device_scale_factor; layer->draw_properties().page_scale_factor = page_scale_factor; @@ -94,8 +83,7 @@ class PictureImageLayerImplTest : public testing::Test { maximum_animation_contents_scale; layer->draw_properties().screen_space_transform_is_animating = animating_transform_to_screen; - layer->ScaleAndManageTilings(animating_transform_to_screen, - maximum_animation_contents_scale); + layer->UpdateTiles(); } protected: @@ -109,7 +97,7 @@ TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); layer->SetDrawsContent(true); - SetupDrawPropertiesAndManageTilings(layer.get(), 2.f, 3.f, 4.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(layer.get(), 2.f, 3.f, 4.f, 1.f, false); EXPECT_FLOAT_EQ(1.f, layer->contents_scale_x()); EXPECT_FLOAT_EQ(1.f, layer->contents_scale_y()); @@ -128,24 +116,27 @@ TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { const float page_scale_factor = 4.f; const float maximum_animation_contents_scale = 1.f; const bool animating_transform_to_screen = false; - SetupDrawPropertiesAndManageTilings(pending_layer.get(), - suggested_ideal_contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform_to_screen); + SetupDrawPropertiesAndUpdateTiles(pending_layer.get(), + suggested_ideal_contents_scale, + device_scale_factor, + page_scale_factor, + maximum_animation_contents_scale, + animating_transform_to_screen); + EXPECT_EQ(1.f, pending_layer->tilings()->tiling_at(0)->contents_scale()); // Push to active layer. + host_impl_.pending_tree()->SetRootLayer(pending_layer.PassAs<LayerImpl>()); host_impl_.ActivatePendingTree(); - scoped_ptr<TestablePictureImageLayerImpl> active_layer( - CreateLayer(1, ACTIVE_TREE)); - pending_layer->PushPropertiesTo(active_layer.get()); - SetupDrawPropertiesAndManageTilings(active_layer.get(), - suggested_ideal_contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform_to_screen); + TestablePictureImageLayerImpl* active_layer = + static_cast<TestablePictureImageLayerImpl*>( + host_impl_.active_tree()->root_layer()); + SetupDrawPropertiesAndUpdateTiles(active_layer, + suggested_ideal_contents_scale, + device_scale_factor, + page_scale_factor, + maximum_animation_contents_scale, + animating_transform_to_screen); + EXPECT_EQ(1.f, active_layer->tilings()->tiling_at(0)->contents_scale()); // Create tile and resource. active_layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 0ebd0e4dc7..624b90aaf7 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -61,7 +61,7 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) raster_contents_scale_(0.f), low_res_raster_contents_scale_(0.f), raster_source_scale_is_fixed_(false), - was_animating_transform_to_screen_(false), + was_screen_space_transform_animating_(false), needs_post_commit_initialization_(true), should_update_tile_priorities_(false) { layer_tree_impl()->RegisterPictureLayerImpl(this); @@ -157,13 +157,15 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, draw_properties().clip_rect, draw_properties().is_clipped, draw_properties().opacity, - blend_mode()); + blend_mode(), + sorting_context_id_); gfx::Rect rect = scaled_visible_content_rect; if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { AppendDebugBorderQuad( quad_sink, + scaled_content_bounds, shared_quad_state, append_quads_data, DebugColors::DirectPictureBorderColor(), @@ -196,7 +198,8 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, return; } - AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); + AppendDebugBorderQuad( + quad_sink, scaled_content_bounds, shared_quad_state, append_quads_data); if (ShowDebugBorders()) { for (PictureLayerTilingSet::CoverageIterator iter( @@ -386,18 +389,10 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, CleanUpTilingsOnActiveLayer(seen_tilings); } -void PictureLayerImpl::UpdateTilePriorities() { - TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); +void PictureLayerImpl::UpdateTiles() { + TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles"); DoPostCommitInitializationIfNeeded(); - UpdateIdealScales(); - // TODO(sohanjg): Avoid needlessly update priorities when syncing to a - // non-updated tree which will then be updated immediately afterwards. - should_update_tile_priorities_ = true; - if (CanHaveTilings()) { - ManageTilings(draw_properties().screen_space_transform_is_animating, - draw_properties().maximum_animation_contents_scale); - } if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { visible_rect_for_tile_priority_ = visible_content_rect(); @@ -405,8 +400,45 @@ void PictureLayerImpl::UpdateTilePriorities() { screen_space_transform_for_tile_priority_ = screen_space_transform(); } - if (!tilings_->num_tilings()) + if (!CanHaveTilings()) { + ideal_page_scale_ = 0.f; + ideal_device_scale_ = 0.f; + ideal_contents_scale_ = 0.f; + ideal_source_scale_ = 0.f; + SanityCheckTilingState(); return; + } + + UpdateIdealScales(); + + DCHECK(tilings_->num_tilings() > 0 || raster_contents_scale_ == 0.f) + << "A layer with no tilings shouldn't have valid raster scales"; + if (!raster_contents_scale_ || ShouldAdjustRasterScale()) { + RecalculateRasterScales(); + AddTilingsForRasterScale(); + } + + DCHECK(raster_page_scale_); + DCHECK(raster_device_scale_); + DCHECK(raster_source_scale_); + DCHECK(raster_contents_scale_); + DCHECK(low_res_raster_contents_scale_); + + was_screen_space_transform_animating_ = + draw_properties().screen_space_transform_is_animating; + + // TODO(sohanjg): Avoid needlessly update priorities when syncing to a + // non-updated tree which will then be updated immediately afterwards. + should_update_tile_priorities_ = true; + + UpdateTilePriorities(); + + if (layer_tree_impl()->IsPendingTree()) + MarkVisibleResourcesAsRequired(); +} + +void PictureLayerImpl::UpdateTilePriorities() { + TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); double current_frame_time_in_seconds = (layer_tree_impl()->CurrentFrameTimeTicks() - @@ -441,15 +473,14 @@ void PictureLayerImpl::UpdateTilePriorities() { visible_rect_in_content_space, 1.f / contents_scale_x()); WhichTree tree = layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; - // TODO(sohanjg): Passing MaximumContentsScale as layer contents scale - // in UpdateTilePriorities is wrong and should be ideal contents scale. - tilings_->UpdateTilePriorities(tree, - visible_layer_rect, - MaximumTilingContentsScale(), - current_frame_time_in_seconds); - - if (layer_tree_impl()->IsPendingTree()) - MarkVisibleResourcesAsRequired(); + for (size_t i = 0; i < tilings_->num_tilings(); ++i) { + // TODO(sohanjg): Passing MaximumContentsScale as layer contents scale + // in UpdateTilePriorities is wrong and should be ideal contents scale. + tilings_->tiling_at(i)->UpdateTilePriorities(tree, + visible_layer_rect, + MaximumTilingContentsScale(), + current_frame_time_in_seconds); + } // Tile priorities were modified. layer_tree_impl()->DidModifyTilePriorities(); @@ -716,7 +747,6 @@ ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { DCHECK(layer_tree_impl()->IsPendingTree()); - DCHECK(!layer_tree_impl()->needs_update_draw_properties()); DCHECK(ideal_contents_scale_); DCHECK_GT(tilings_->num_tilings(), 0u); @@ -930,38 +960,7 @@ inline float PositiveRatio(float float1, float float2) { } // namespace -void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen, - float maximum_animation_contents_scale) { - DCHECK(ideal_contents_scale_); - DCHECK(ideal_page_scale_); - DCHECK(ideal_device_scale_); - DCHECK(ideal_source_scale_); - DCHECK(CanHaveTilings()); - DCHECK(!needs_post_commit_initialization_); - - bool change_target_tiling = - raster_page_scale_ == 0.f || - raster_device_scale_ == 0.f || - raster_source_scale_ == 0.f || - raster_contents_scale_ == 0.f || - low_res_raster_contents_scale_ == 0.f || - ShouldAdjustRasterScale(animating_transform_to_screen); - - if (tilings_->num_tilings() == 0) { - DCHECK(change_target_tiling) - << "A layer with no tilings shouldn't have valid raster scales"; - } - - if (change_target_tiling) { - RecalculateRasterScales(animating_transform_to_screen, - maximum_animation_contents_scale); - } - - was_animating_transform_to_screen_ = animating_transform_to_screen; - - if (!change_target_tiling) - return; - +void PictureLayerImpl::AddTilingsForRasterScale() { PictureLayerTiling* high_res = NULL; PictureLayerTiling* low_res = NULL; @@ -990,7 +989,8 @@ void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen, // tiling during a pinch or a CSS animation. bool is_pinching = layer_tree_impl()->PinchGestureActive(); if (layer_tree_impl()->create_low_res_tiling() && !is_pinching && - !animating_transform_to_screen && !low_res && low_res != high_res) + !draw_properties().screen_space_transform_is_animating && !low_res && + low_res != high_res) low_res = AddTiling(low_res_raster_contents_scale_); // Set low-res if we have one. @@ -1005,9 +1005,9 @@ void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen, SanityCheckTilingState(); } -bool PictureLayerImpl::ShouldAdjustRasterScale( - bool animating_transform_to_screen) const { - if (was_animating_transform_to_screen_ != animating_transform_to_screen) +bool PictureLayerImpl::ShouldAdjustRasterScale() const { + if (was_screen_space_transform_animating_ != + draw_properties().screen_space_transform_is_animating) return true; bool is_pinching = layer_tree_impl()->PinchGestureActive(); @@ -1033,7 +1033,8 @@ bool PictureLayerImpl::ShouldAdjustRasterScale( // When the source scale changes we want to match it, but not when animating // or when we've fixed the scale in place. - if (!animating_transform_to_screen && !raster_source_scale_is_fixed_ && + if (!draw_properties().screen_space_transform_is_animating && + !raster_source_scale_is_fixed_ && raster_source_scale_ != ideal_source_scale_) return true; @@ -1055,9 +1056,7 @@ float PictureLayerImpl::SnappedContentsScale(float scale) { return snapped_contents_scale; } -void PictureLayerImpl::RecalculateRasterScales( - bool animating_transform_to_screen, - float maximum_animation_contents_scale) { +void PictureLayerImpl::RecalculateRasterScales() { float old_raster_contents_scale = raster_contents_scale_; float old_raster_page_scale = raster_page_scale_; float old_raster_source_scale = raster_source_scale_; @@ -1070,8 +1069,9 @@ void PictureLayerImpl::RecalculateRasterScales( // If we're not animating, or leaving an animation, and the // ideal_source_scale_ changes, then things are unpredictable, and we fix // the raster_source_scale_ in place. - if (old_raster_source_scale && !animating_transform_to_screen && - !was_animating_transform_to_screen_ && + if (old_raster_source_scale && + !draw_properties().screen_space_transform_is_animating && + !was_screen_space_transform_animating_ && old_raster_source_scale != ideal_source_scale_) raster_source_scale_is_fixed_ = true; @@ -1107,10 +1107,11 @@ void PictureLayerImpl::RecalculateRasterScales( // Since we're not re-rasterizing during animation, rasterize at the maximum // scale that will occur during the animation, if the maximum scale is // known. - if (animating_transform_to_screen) { - if (maximum_animation_contents_scale > 0.f) { + if (draw_properties().screen_space_transform_is_animating) { + if (draw_properties().maximum_animation_contents_scale > 0.f) { raster_contents_scale_ = - std::max(raster_contents_scale_, maximum_animation_contents_scale); + std::max(raster_contents_scale_, + draw_properties().maximum_animation_contents_scale); } else { raster_contents_scale_ = std::max(raster_contents_scale_, @@ -1149,7 +1150,7 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer( float twin_low_res_scale = 0.f; PictureLayerImpl* twin = twin_layer_; - if (twin) { + if (twin && twin->CanHaveTilings()) { min_acceptable_high_res_scale = std::min( min_acceptable_high_res_scale, std::min(twin->raster_contents_scale_, twin->ideal_contents_scale_)); @@ -1272,14 +1273,7 @@ float PictureLayerImpl::MaximumTilingContentsScale() const { } void PictureLayerImpl::UpdateIdealScales() { - if (!CanHaveTilings()) { - ideal_page_scale_ = draw_properties().page_scale_factor; - ideal_device_scale_ = draw_properties().device_scale_factor; - ideal_contents_scale_ = draw_properties().ideal_contents_scale; - ideal_source_scale_ = - ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; - return; - } + DCHECK(CanHaveTilings()); float min_contents_scale = MinimumContentsScale(); DCHECK_GT(min_contents_scale, 0.f); diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h index de4ee2a630..6b1703e4a6 100644 --- a/cc/layers/picture_layer_impl.h +++ b/cc/layers/picture_layer_impl.h @@ -91,7 +91,7 @@ class CC_EXPORT PictureLayerImpl virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; virtual void AppendQuads(QuadSink* quad_sink, AppendQuadsData* append_quads_data) OVERRIDE; - virtual void UpdateTilePriorities() OVERRIDE; + virtual void UpdateTiles() OVERRIDE; virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE; virtual void DidBecomeActive() OVERRIDE; virtual void DidBeginTracing() OVERRIDE; @@ -138,12 +138,10 @@ class CC_EXPORT PictureLayerImpl void RemoveTiling(float contents_scale); void RemoveAllTilings(); void SyncFromActiveLayer(const PictureLayerImpl* other); - void ManageTilings(bool animating_transform_to_screen, - float maximum_animation_contents_scale); - virtual bool ShouldAdjustRasterScale( - bool animating_transform_to_screen) const; - virtual void RecalculateRasterScales(bool animating_transform_to_screen, - float maximum_animation_contents_scale); + void AddTilingsForRasterScale(); + void UpdateTilePriorities(); + virtual bool ShouldAdjustRasterScale() const; + virtual void RecalculateRasterScales(); void CleanUpTilingsOnActiveLayer( std::vector<PictureLayerTiling*> used_tilings); float MinimumContentsScale() const; @@ -194,7 +192,7 @@ class CC_EXPORT PictureLayerImpl float low_res_raster_contents_scale_; bool raster_source_scale_is_fixed_; - bool was_animating_transform_to_screen_; + bool was_screen_space_transform_animating_; bool needs_post_commit_initialization_; // A sanity state check to make sure UpdateTilePriorities only gets called // after a CalculateContentsScale/ManageTilings. diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index c26f74b2c5..bb61f4e4de 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -140,13 +140,12 @@ class PictureLayerImplTest : public testing::Test { pending_layer_->DoPostCommitInitializationIfNeeded(); } - void SetupDrawPropertiesAndManageTilings( - FakePictureLayerImpl* layer, - float ideal_contents_scale, - float device_scale_factor, - float page_scale_factor, - float maximum_animation_contents_scale, - bool animating_transform_to_screen) { + void SetupDrawPropertiesAndUpdateTiles(FakePictureLayerImpl* layer, + float ideal_contents_scale, + float device_scale_factor, + float page_scale_factor, + float maximum_animation_contents_scale, + bool animating_transform_to_screen) { layer->draw_properties().ideal_contents_scale = ideal_contents_scale; layer->draw_properties().device_scale_factor = device_scale_factor; layer->draw_properties().page_scale_factor = page_scale_factor; @@ -154,8 +153,7 @@ class PictureLayerImplTest : public testing::Test { maximum_animation_contents_scale; layer->draw_properties().screen_space_transform_is_animating = animating_transform_to_screen; - layer->ScaleAndManageTilings(animating_transform_to_screen, - maximum_animation_contents_scale); + layer->UpdateTiles(); } static void VerifyAllTilesExistAndHavePile( const PictureLayerTiling* tiling, @@ -174,19 +172,19 @@ class PictureLayerImplTest : public testing::Test { float page_scale_factor, float maximum_animation_contents_scale, bool animating_transform) { - SetupDrawPropertiesAndManageTilings(pending_layer_, - contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform); - - SetupDrawPropertiesAndManageTilings(active_layer_, - contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + contents_scale, + device_scale_factor, + page_scale_factor, + maximum_animation_contents_scale, + animating_transform); + + SetupDrawPropertiesAndUpdateTiles(active_layer_, + contents_scale, + device_scale_factor, + page_scale_factor, + maximum_animation_contents_scale, + animating_transform); } void ResetTilingsAndRasterScales() { @@ -223,8 +221,7 @@ class PictureLayerImplTest : public testing::Test { SetupTrees(pending_pile, active_pile); - SetupDrawPropertiesAndManageTilings( - active_layer_, 1.f, 1.f, 1.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); // Add 1x1 rects at the centers of each tile, then re-record pile contents active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); @@ -319,9 +316,9 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { Region invalidation; AddDefaultTilingsWithInvalidation(invalidation); - SetupDrawPropertiesAndManageTilings(active_layer_, 1.f, 1.f, 1.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); - // UpdateTilePriorities with valid viewport. Should update tile viewport. + // UpdateTiles with valid viewport. Should update tile viewport. bool valid_for_tile_management = true; gfx::Rect viewport = gfx::Rect(layer_bounds); gfx::Transform transform; @@ -329,7 +326,7 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { transform, viewport, viewport, valid_for_tile_management); active_layer_->draw_properties().visible_content_rect = viewport; active_layer_->draw_properties().screen_space_transform = transform; - active_layer_->UpdateTilePriorities(); + active_layer_->UpdateTiles(); gfx::Rect visible_rect_for_tile_priority = active_layer_->visible_rect_for_tile_priority(); @@ -351,7 +348,7 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { active_layer_->draw_properties().screen_space_transform = transform; host_impl_.SetExternalDrawConstraints( transform, viewport, viewport, valid_for_tile_management); - active_layer_->UpdateTilePriorities(); + active_layer_->UpdateTiles(); EXPECT_RECT_EQ(visible_rect_for_tile_priority, active_layer_->visible_rect_for_tile_priority()); @@ -367,7 +364,7 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { valid_for_tile_management = true; host_impl_.SetExternalDrawConstraints( transform, viewport, viewport, valid_for_tile_management); - active_layer_->UpdateTilePriorities(); + active_layer_->UpdateTiles(); EXPECT_FALSE(visible_rect_for_tile_priority == active_layer_->visible_rect_for_tile_priority()); @@ -404,7 +401,7 @@ TEST_F(PictureLayerImplTest, InvalidViewportAfterReleaseResources) { EXPECT_TRUE(active_layer_->HighResTiling()); size_t num_tilings = active_layer_->num_tilings(); - active_layer_->UpdateTilePriorities(); + active_layer_->UpdateTiles(); pending_layer_->AddTiling(0.5f); EXPECT_EQ(num_tilings + 1, active_layer_->num_tilings()); } @@ -578,8 +575,7 @@ TEST_F(PictureLayerImplTest, ManageTilingsWithNoRecording) { SetupTrees(pending_pile, active_pile); - SetupDrawPropertiesAndManageTilings( - pending_layer_, 1.f, 1.f, 1.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); } @@ -599,12 +595,12 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; EXPECT_LT(low_res_factor, 1.f); - SetupDrawPropertiesAndManageTilings(pending_layer_, - 6.f, // ideal contents scale - 3.f, // device scale - 2.f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 6.f, // ideal contents scale + 3.f, // device scale + 2.f, // page scale + 1.f, // maximum animation scale + false); ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.f, pending_layer_->tilings()->tiling_at(0)->contents_scale()); @@ -612,12 +608,12 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { pending_layer_->tilings()->tiling_at(1)->contents_scale()); // If we change the page scale factor, then we should get new tilings. - SetupDrawPropertiesAndManageTilings(pending_layer_, - 6.6f, // ideal contents scale - 3.f, // device scale - 2.2f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 6.6f, // ideal contents scale + 3.f, // device scale + 2.2f, // page scale + 1.f, // maximum animation scale + false); ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.6f, pending_layer_->tilings()->tiling_at(0)->contents_scale()); @@ -625,12 +621,12 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { pending_layer_->tilings()->tiling_at(2)->contents_scale()); // If we change the device scale factor, then we should get new tilings. - SetupDrawPropertiesAndManageTilings(pending_layer_, - 7.26f, // ideal contents scale - 3.3f, // device scale - 2.2f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 7.26f, // ideal contents scale + 3.3f, // device scale + 2.2f, // page scale + 1.f, // maximum animation scale + false); ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, pending_layer_->tilings()->tiling_at(0)->contents_scale()); @@ -639,12 +635,12 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { // If we change the device scale factor, but end up at the same total scale // factor somehow, then we don't get new tilings. - SetupDrawPropertiesAndManageTilings(pending_layer_, - 7.26f, // ideal contents scale - 2.2f, // device scale - 3.3f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 7.26f, // ideal contents scale + 2.2f, // device scale + 3.3f, // page scale + 1.f, // maximum animation scale + false); ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, pending_layer_->tilings()->tiling_at(0)->contents_scale()); @@ -674,12 +670,12 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { float maximum_animation_scale = 1.f; SetupPendingTree(valid_pile); - SetupDrawPropertiesAndManageTilings(pending_layer_, - high_res_scale, - device_scale, - page_scale, - maximum_animation_scale, - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + high_res_scale, + device_scale, + page_scale, + maximum_animation_scale, + false); ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(high_res_scale, pending_layer_->HighResTiling()->contents_scale()); @@ -688,31 +684,33 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { ActivateTree(); SetupPendingTree(empty_pile); - SetupDrawPropertiesAndManageTilings(pending_layer_, - high_res_scale, - device_scale, - page_scale, - maximum_animation_scale, - false); + EXPECT_FALSE(pending_layer_->CanHaveTilings()); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + high_res_scale, + device_scale, + page_scale, + maximum_animation_scale, + false); ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); ActivateTree(); - SetupDrawPropertiesAndManageTilings(active_layer_, - high_res_scale, - device_scale, - page_scale, - maximum_animation_scale, - false); + EXPECT_FALSE(active_layer_->CanHaveTilings()); + SetupDrawPropertiesAndUpdateTiles(active_layer_, + high_res_scale, + device_scale, + page_scale, + maximum_animation_scale, + false); ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); SetupPendingTree(valid_pile); - SetupDrawPropertiesAndManageTilings(pending_layer_, - high_res_scale, - device_scale, - page_scale, - maximum_animation_scale, - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + high_res_scale, + device_scale, + page_scale, + maximum_animation_scale, + false); ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(high_res_scale, @@ -919,7 +917,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. - SetupDrawPropertiesAndManageTilings( + SetupDrawPropertiesAndUpdateTiles( active_layer_, 1.1f, device_scale, page_scale, 1.f, false); // Because the pending layer's ideal scale is still 1.0, our tilings fall @@ -930,7 +928,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { // Move the ideal scale on the pending layer to 1.1 as well. Our target stays // 1.2 still. - SetupDrawPropertiesAndManageTilings( + SetupDrawPropertiesAndUpdateTiles( pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); // Our 1.0 tiling now falls outside the range between our ideal scale and our @@ -1088,12 +1086,12 @@ TEST_F(PictureLayerImplTest, ReleaseResources) { SetupTrees(pending_pile, active_pile); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); - SetupDrawPropertiesAndManageTilings(pending_layer_, - 1.3f, // ideal contents scale - 2.7f, // device scale - 3.2f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 1.3f, // ideal contents scale + 2.7f, // device scale + 3.2f, // page scale + 1.f, // maximum animation scale + false); EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); // All tilings should be removed when losing output surface. @@ -1103,12 +1101,12 @@ TEST_F(PictureLayerImplTest, ReleaseResources) { EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); // This should create new tilings. - SetupDrawPropertiesAndManageTilings(pending_layer_, - 1.3f, // ideal contents scale - 2.7f, // device scale - 3.2f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 1.3f, // ideal contents scale + 2.7f, // device scale + 3.2f, // page scale + 1.f, // maximum animation scale + false); EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); } @@ -1125,8 +1123,7 @@ TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { SetupTrees(pending_pile, active_pile); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); - SetupDrawPropertiesAndManageTilings( - pending_layer_, 1.f, 1.f, 1.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); @@ -1149,8 +1146,7 @@ TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( context.Pass()).PassAs<OutputSurface>()); - SetupDrawPropertiesAndManageTilings( - pending_layer_, 1.f, 1.f, 1.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); @@ -1174,8 +1170,7 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { SetupTrees(pending_pile, active_pile); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); - SetupDrawPropertiesAndManageTilings( - pending_layer_, 1.f, 1.f, 1.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); @@ -1198,8 +1193,7 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( context.Pass()).PassAs<OutputSurface>()); - SetupDrawPropertiesAndManageTilings( - pending_layer_, 1.f, 1.f, 1.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); @@ -1594,7 +1588,7 @@ TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { host_impl_.active_tree()->UpdateDrawProperties(); EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); - SetupDrawPropertiesAndManageTilings( + SetupDrawPropertiesAndUpdateTiles( active_layer_, 0.5f, 0.5f, 0.5f, 0.5f, false); active_layer_->tilings()->RemoveAllTilings(); PictureLayerTiling* tiling = active_layer_->tilings()->AddTiling(0.5f); @@ -1642,8 +1636,7 @@ TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { SetupDefaultTrees(layer_bounds); EXPECT_FALSE(host_impl_.use_gpu_rasterization()); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); - SetupDrawPropertiesAndManageTilings( - pending_layer_, 1.f, 1.f, 1.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); // Should have a low-res and a high-res tiling. ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); @@ -1651,8 +1644,7 @@ TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { host_impl_.SetUseGpuRasterization(true); EXPECT_TRUE(host_impl_.use_gpu_rasterization()); - SetupDrawPropertiesAndManageTilings( - pending_layer_, 1.f, 1.f, 1.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); // Should only have the high-res tiling. ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); @@ -1754,8 +1746,7 @@ class DeferredInitPictureLayerImplTest : public PictureLayerImplTest { // that trees need update draw properties after deferred initialization. // However, this is also a regression test for PictureLayerImpl in that // not having this update will cause a crash. -TEST_F(DeferredInitPictureLayerImplTest, - PreventUpdateTilePrioritiesDuringLostContext) { +TEST_F(DeferredInitPictureLayerImplTest, PreventUpdateTilesDuringLostContext) { host_impl_.pending_tree()->UpdateDrawProperties(); host_impl_.active_tree()->UpdateDrawProperties(); EXPECT_FALSE(host_impl_.pending_tree()->needs_update_draw_properties()); @@ -2285,46 +2276,46 @@ TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; EXPECT_LT(low_res_factor, 1.f); - SetupDrawPropertiesAndManageTilings(pending_layer_, - 6.f, // ideal contents scale - 3.f, // device scale - 2.f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 6.f, // ideal contents scale + 3.f, // device scale + 2.f, // page scale + 1.f, // maximum animation scale + false); ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.f, pending_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the page scale factor, then we should get new tilings. - SetupDrawPropertiesAndManageTilings(pending_layer_, - 6.6f, // ideal contents scale - 3.f, // device scale - 2.2f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 6.6f, // ideal contents scale + 3.f, // device scale + 2.2f, // page scale + 1.f, // maximum animation scale + false); ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.6f, pending_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the device scale factor, then we should get new tilings. - SetupDrawPropertiesAndManageTilings(pending_layer_, - 7.26f, // ideal contents scale - 3.3f, // device scale - 2.2f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 7.26f, // ideal contents scale + 3.3f, // device scale + 2.2f, // page scale + 1.f, // maximum animation scale + false); ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, pending_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the device scale factor, but end up at the same total scale // factor somehow, then we don't get new tilings. - SetupDrawPropertiesAndManageTilings(pending_layer_, - 7.26f, // ideal contents scale - 2.2f, // device scale - 3.3f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 7.26f, // ideal contents scale + 2.2f, // device scale + 3.3f, // page scale + 1.f, // maximum animation scale + false); ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, pending_layer_->tilings()->tiling_at(0)->contents_scale()); @@ -2419,9 +2410,9 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { Region invalidation; AddDefaultTilingsWithInvalidation(invalidation); - SetupDrawPropertiesAndManageTilings(active_layer_, 1.f, 1.f, 1.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); - // UpdateTilePriorities with valid viewport. Should update tile viewport. + // UpdateTiles with valid viewport. Should update tile viewport. bool valid_for_tile_management = true; gfx::Rect viewport = gfx::Rect(layer_bounds); gfx::Transform transform; @@ -2429,7 +2420,7 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { transform, viewport, viewport, valid_for_tile_management); active_layer_->draw_properties().visible_content_rect = viewport; active_layer_->draw_properties().screen_space_transform = transform; - active_layer_->UpdateTilePriorities(); + active_layer_->UpdateTiles(); gfx::Rect visible_rect_for_tile_priority = active_layer_->visible_rect_for_tile_priority(); @@ -2451,7 +2442,7 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { active_layer_->draw_properties().screen_space_transform = transform; host_impl_.SetExternalDrawConstraints( transform, viewport, viewport, valid_for_tile_management); - active_layer_->UpdateTilePriorities(); + active_layer_->UpdateTiles(); EXPECT_RECT_EQ(visible_rect_for_tile_priority, active_layer_->visible_rect_for_tile_priority()); @@ -2467,7 +2458,7 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { valid_for_tile_management = true; host_impl_.SetExternalDrawConstraints( transform, viewport, viewport, valid_for_tile_management); - active_layer_->UpdateTilePriorities(); + active_layer_->UpdateTiles(); EXPECT_FALSE(visible_rect_for_tile_priority == active_layer_->visible_rect_for_tile_priority()); @@ -2504,7 +2495,7 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportAfterReleaseResources) { EXPECT_TRUE(active_layer_->HighResTiling()); size_t num_tilings = active_layer_->num_tilings(); - active_layer_->UpdateTilePriorities(); + active_layer_->UpdateTiles(); pending_layer_->AddTiling(0.5f); EXPECT_EQ(num_tilings + 1, active_layer_->num_tilings()); } @@ -2586,7 +2577,7 @@ TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. - SetupDrawPropertiesAndManageTilings( + SetupDrawPropertiesAndUpdateTiles( active_layer_, 1.1f, device_scale, page_scale, 1.f, false); // Because the pending layer's ideal scale is still 1.0, our tilings fall @@ -2597,7 +2588,7 @@ TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { // Move the ideal scale on the pending layer to 1.1 as well. Our target stays // 1.2 still. - SetupDrawPropertiesAndManageTilings( + SetupDrawPropertiesAndUpdateTiles( pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); // Our 1.0 tiling now falls outside the range between our ideal scale and our @@ -2639,18 +2630,18 @@ TEST_F(PictureLayerImplTest, ScaleCollision) { float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; EXPECT_LT(low_res_factor, 1.f); - SetupDrawPropertiesAndManageTilings(pending_layer_, - pending_contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform); - SetupDrawPropertiesAndManageTilings(active_layer_, - active_contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + pending_contents_scale, + device_scale_factor, + page_scale_factor, + maximum_animation_contents_scale, + animating_transform); + SetupDrawPropertiesAndUpdateTiles(active_layer_, + active_contents_scale, + device_scale_factor, + page_scale_factor, + maximum_animation_contents_scale, + animating_transform); ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); @@ -2701,12 +2692,12 @@ TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { SetupTrees(pending_pile, active_pile); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); - SetupDrawPropertiesAndManageTilings(pending_layer_, - 1.3f, // ideal contents scale - 2.7f, // device scale - 3.2f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 1.3f, // ideal contents scale + 2.7f, // device scale + 3.2f, // page scale + 1.f, // maximum animation scale + false); EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); // All tilings should be removed when losing output surface. @@ -2716,12 +2707,12 @@ TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); // This should create new tilings. - SetupDrawPropertiesAndManageTilings(pending_layer_, - 1.3f, // ideal contents scale - 2.7f, // device scale - 3.2f, // page scale - 1.f, // maximum animation scale - false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, + 1.3f, // ideal contents scale + 2.7f, // device scale + 3.2f, // page scale + 1.f, // maximum animation scale + false); EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); } @@ -2740,8 +2731,7 @@ TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { SetupTrees(pending_pile, active_pile); - SetupDrawPropertiesAndManageTilings( - pending_layer_, 2.5f, 1.f, 1.f, 1.f, false); + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 2.5f, 1.f, 1.f, 1.f, false); host_impl_.pending_tree()->UpdateDrawProperties(); active_layer_->draw_properties().visible_content_rect = @@ -2774,5 +2764,50 @@ TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { quad_culler.shared_quad_state_list()[0]->visible_content_rect.ToString()); } +TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) { + gfx::Size tile_size(400, 400); + gfx::Size bounds(100000, 100); + + host_impl_.CreatePendingTree(); + + scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1); + + scoped_ptr<FakePictureLayerImpl> layer_with_mask = + FakePictureLayerImpl::Create(host_impl_.pending_tree(), 2); + + layer_with_mask->SetBounds(bounds); + layer_with_mask->SetContentBounds(bounds); + + scoped_refptr<FakePicturePileImpl> pending_pile = + FakePicturePileImpl::CreateFilledPile(tile_size, bounds); + scoped_ptr<FakePictureLayerImpl> mask = FakePictureLayerImpl::CreateWithPile( + host_impl_.pending_tree(), 3, pending_pile); + + mask->SetIsMask(true); + mask->SetBounds(bounds); + mask->SetContentBounds(bounds); + mask->SetDrawsContent(true); + + FakePictureLayerImpl* pending_mask_content = mask.get(); + layer_with_mask->SetMaskLayer(mask.PassAs<LayerImpl>()); + + scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask = + FakePictureLayerImpl::Create(host_impl_.pending_tree(), 4); + + child_of_layer_with_mask->SetBounds(bounds); + child_of_layer_with_mask->SetContentBounds(bounds); + child_of_layer_with_mask->SetDrawsContent(true); + + layer_with_mask->AddChild(child_of_layer_with_mask.PassAs<LayerImpl>()); + + root->AddChild(layer_with_mask.PassAs<LayerImpl>()); + + host_impl_.pending_tree()->SetRootLayer(root.Pass()); + + EXPECT_FALSE(pending_mask_content->tilings()); + host_impl_.pending_tree()->UpdateDrawProperties(); + EXPECT_NE(0u, pending_mask_content->num_tilings()); +} + } // namespace } // namespace cc diff --git a/cc/layers/render_surface_impl.cc b/cc/layers/render_surface_impl.cc index 3bce76fd81..af8c41a534 100644 --- a/cc/layers/render_surface_impl.cc +++ b/cc/layers/render_surface_impl.cc @@ -157,7 +157,8 @@ void RenderSurfaceImpl::AppendQuads(QuadSink* quad_sink, clip_rect_, is_clipped_, draw_opacity_, - owning_layer_->blend_mode()); + owning_layer_->blend_mode(), + owning_layer_->sorting_context_id()); if (owning_layer_->ShowDebugBorders()) { SkColor color = for_replica ? diff --git a/cc/layers/solid_color_layer_impl.cc b/cc/layers/solid_color_layer_impl.cc index e60edd1554..1f44b38320 100644 --- a/cc/layers/solid_color_layer_impl.cc +++ b/cc/layers/solid_color_layer_impl.cc @@ -27,7 +27,8 @@ void SolidColorLayerImpl::AppendQuads(QuadSink* quad_sink, SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); PopulateSharedQuadState(shared_quad_state); - AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); + AppendDebugBorderQuad( + quad_sink, content_bounds(), shared_quad_state, append_quads_data); // We create a series of smaller quads instead of just one large one so that // the culler can reduce the total pixels drawn. diff --git a/cc/layers/solid_color_scrollbar_layer_impl.cc b/cc/layers/solid_color_scrollbar_layer_impl.cc index be2358c3ad..1e255ab419 100644 --- a/cc/layers/solid_color_scrollbar_layer_impl.cc +++ b/cc/layers/solid_color_scrollbar_layer_impl.cc @@ -99,7 +99,8 @@ void SolidColorScrollbarLayerImpl::AppendQuads(QuadSink* quad_sink, SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); PopulateSharedQuadState(shared_quad_state); - AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); + AppendDebugBorderQuad( + quad_sink, content_bounds(), shared_quad_state, append_quads_data); gfx::Rect thumb_quad_rect(ComputeThumbQuadRect()); gfx::Rect visible_quad_rect = quad_sink->UnoccludedContentRect( diff --git a/cc/layers/surface_layer_impl.cc b/cc/layers/surface_layer_impl.cc index 6557e20b05..6891c14485 100644 --- a/cc/layers/surface_layer_impl.cc +++ b/cc/layers/surface_layer_impl.cc @@ -41,7 +41,8 @@ void SurfaceLayerImpl::AppendQuads(QuadSink* quad_sink, SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); PopulateSharedQuadState(shared_quad_state); - AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); + AppendDebugBorderQuad( + quad_sink, content_bounds(), shared_quad_state, append_quads_data); if (surface_id_.is_null()) return; diff --git a/cc/layers/texture_layer_impl.cc b/cc/layers/texture_layer_impl.cc index 5e65d72763..abbab25cbc 100644 --- a/cc/layers/texture_layer_impl.cc +++ b/cc/layers/texture_layer_impl.cc @@ -146,7 +146,8 @@ void TextureLayerImpl::AppendQuads(QuadSink* quad_sink, SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); PopulateSharedQuadState(shared_quad_state); - AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); + AppendDebugBorderQuad( + quad_sink, content_bounds(), shared_quad_state, append_quads_data); SkColor bg_color = blend_background_color_ ? background_color() : SK_ColorTRANSPARENT; diff --git a/cc/layers/tiled_layer_impl.cc b/cc/layers/tiled_layer_impl.cc index a510883d81..6aacd1e16b 100644 --- a/cc/layers/tiled_layer_impl.cc +++ b/cc/layers/tiled_layer_impl.cc @@ -161,7 +161,8 @@ void TiledLayerImpl::AppendQuads(QuadSink* quad_sink, SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); PopulateSharedQuadState(shared_quad_state); - AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); + AppendDebugBorderQuad( + quad_sink, content_bounds(), shared_quad_state, append_quads_data); int left, top, right, bottom; tiler_->ContentRectToTileIndices(content_rect, &left, &top, &right, &bottom); diff --git a/cc/layers/ui_resource_layer_impl.cc b/cc/layers/ui_resource_layer_impl.cc index a5b563f516..d2ec1e4f47 100644 --- a/cc/layers/ui_resource_layer_impl.cc +++ b/cc/layers/ui_resource_layer_impl.cc @@ -96,7 +96,8 @@ void UIResourceLayerImpl::AppendQuads(QuadSink* quad_sink, SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); PopulateSharedQuadState(shared_quad_state); - AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); + AppendDebugBorderQuad( + quad_sink, content_bounds(), shared_quad_state, append_quads_data); if (!ui_resource_id_) return; diff --git a/cc/layers/video_layer_impl.cc b/cc/layers/video_layer_impl.cc index dad31593c5..4abf85b963 100644 --- a/cc/layers/video_layer_impl.cc +++ b/cc/layers/video_layer_impl.cc @@ -131,7 +131,8 @@ void VideoLayerImpl::AppendQuads(QuadSink* quad_sink, SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); PopulateSharedQuadState(shared_quad_state); - AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); + AppendDebugBorderQuad( + quad_sink, content_bounds(), shared_quad_state, append_quads_data); gfx::Rect quad_rect(content_bounds()); gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc index 68c29e5bfe..75c3b6364a 100644 --- a/cc/output/delegating_renderer.cc +++ b/cc/output/delegating_renderer.cc @@ -146,22 +146,4 @@ void DelegatingRenderer::DidChangeVisibility() { context_provider->ContextSupport()->SetSurfaceVisible(visible()); } -void DelegatingRenderer::SendManagedMemoryStats(size_t bytes_visible, - size_t bytes_visible_and_nearby, - size_t bytes_allocated) { - ContextProvider* context_provider = output_surface_->context_provider(); - if (!context_provider) { - // In the software path each child process manages its memory separately, - // so memory stats don't have to be sent anywhere. - return; - } - gpu::ManagedMemoryStats stats; - stats.bytes_required = bytes_visible; - stats.bytes_nice_to_have = bytes_visible_and_nearby; - stats.bytes_allocated = bytes_allocated; - stats.backbuffer_requested = false; - - context_provider->ContextSupport()->SendManagedMemoryStats(stats); -} - } // namespace cc diff --git a/cc/output/delegating_renderer.h b/cc/output/delegating_renderer.h index 2649bcbf30..10d95ce61a 100644 --- a/cc/output/delegating_renderer.h +++ b/cc/output/delegating_renderer.h @@ -39,10 +39,6 @@ class CC_EXPORT DelegatingRenderer : public Renderer { virtual bool IsContextLost() OVERRIDE; - virtual void SendManagedMemoryStats(size_t bytes_visible, - size_t bytes_visible_and_nearby, - size_t bytes_allocated) OVERRIDE; - private: DelegatingRenderer(RendererClient* client, const LayerTreeSettings* settings, diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 80e866df07..68bc291408 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -387,17 +387,6 @@ void GLRenderer::DidChangeVisibility() { context_support_->SetSurfaceVisible(visible()); } -void GLRenderer::SendManagedMemoryStats(size_t bytes_visible, - size_t bytes_visible_and_nearby, - size_t bytes_allocated) { - gpu::ManagedMemoryStats stats; - stats.bytes_required = bytes_visible; - stats.bytes_nice_to_have = bytes_visible_and_nearby; - stats.bytes_allocated = bytes_allocated; - stats.backbuffer_requested = !is_backbuffer_discarded_; - context_support_->SendManagedMemoryStats(stats); -} - void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } void GLRenderer::DiscardPixels(bool has_external_stencil_test, diff --git a/cc/output/gl_renderer.h b/cc/output/gl_renderer.h index ee989d38a4..b798d55b27 100644 --- a/cc/output/gl_renderer.h +++ b/cc/output/gl_renderer.h @@ -67,10 +67,6 @@ class CC_EXPORT GLRenderer : public DirectRenderer { virtual bool IsContextLost() OVERRIDE; - virtual void SendManagedMemoryStats(size_t bytes_visible, - size_t bytes_visible_and_nearby, - size_t bytes_allocated) OVERRIDE; - static void DebugGLCall(gpu::gles2::GLES2Interface* gl, const char* command, const char* file, diff --git a/cc/output/renderer.h b/cc/output/renderer.h index c702209808..af77cbb230 100644 --- a/cc/output/renderer.h +++ b/cc/output/renderer.h @@ -77,10 +77,6 @@ class CC_EXPORT Renderer { bool visible() const { return visible_; } void SetVisible(bool visible); - virtual void SendManagedMemoryStats(size_t bytes_visible, - size_t bytes_visible_and_nearby, - size_t bytes_allocated) = 0; - protected: explicit Renderer(RendererClient* client, const LayerTreeSettings* settings) : client_(client), settings_(settings), visible_(true) {} diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc index 57f2a545f5..2377043d45 100644 --- a/cc/output/renderer_pixeltest.cc +++ b/cc/output/renderer_pixeltest.cc @@ -58,6 +58,7 @@ SharedQuadState* CreateTestSharedQuadState( const bool is_clipped = false; const float opacity = 1.0f; const SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; + int sorting_context_id = 0; SharedQuadState* shared_state = render_pass->CreateAndAppendSharedQuadState(); shared_state->SetAll(content_to_target_transform, content_bounds, @@ -65,7 +66,8 @@ SharedQuadState* CreateTestSharedQuadState( clip_rect, is_clipped, opacity, - blend_mode); + blend_mode, + sorting_context_id); return shared_state; } @@ -79,6 +81,7 @@ SharedQuadState* CreateTestSharedQuadStateClipped( const bool is_clipped = true; const float opacity = 1.0f; const SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; + int sorting_context_id = 0; SharedQuadState* shared_state = render_pass->CreateAndAppendSharedQuadState(); shared_state->SetAll(content_to_target_transform, content_bounds, @@ -86,7 +89,8 @@ SharedQuadState* CreateTestSharedQuadStateClipped( clip_rect, is_clipped, opacity, - blend_mode); + blend_mode, + sorting_context_id); return shared_state; } diff --git a/cc/output/software_renderer.h b/cc/output/software_renderer.h index 4eaa8e92b8..5c9fef0ba5 100644 --- a/cc/output/software_renderer.h +++ b/cc/output/software_renderer.h @@ -37,10 +37,6 @@ class CC_EXPORT SoftwareRenderer : public DirectRenderer { virtual const RendererCapabilitiesImpl& Capabilities() const OVERRIDE; virtual void Finish() OVERRIDE; virtual void SwapBuffers(const CompositorFrameMetadata& metadata) OVERRIDE; - virtual void SendManagedMemoryStats( - size_t bytes_visible, - size_t bytes_visible_and_nearby, - size_t bytes_allocated) OVERRIDE {} virtual void ReceiveSwapBuffersAck( const CompositorFrameAck& ack) OVERRIDE; virtual void DiscardBackbuffer() OVERRIDE; diff --git a/cc/output/software_renderer_unittest.cc b/cc/output/software_renderer_unittest.cc index ee5af29f99..52ff828d14 100644 --- a/cc/output/software_renderer_unittest.cc +++ b/cc/output/software_renderer_unittest.cc @@ -112,7 +112,8 @@ TEST_F(SoftwareRendererTest, SolidColorQuad) { outer_rect, false, 1.0, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<SolidColorDrawQuad> outer_quad = SolidColorDrawQuad::Create(); outer_quad->SetNew( shared_quad_state, outer_rect, outer_rect, SK_ColorYELLOW, false); @@ -198,7 +199,8 @@ TEST_F(SoftwareRendererTest, TileQuad) { outer_rect, false, 1.0, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<TileDrawQuad> outer_quad = TileDrawQuad::Create(); outer_quad->SetNew(shared_quad_state, outer_rect, @@ -281,7 +283,8 @@ TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { tile_rect, false, 1.0, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); quad->SetNew(shared_quad_state, tile_rect, diff --git a/cc/quads/draw_quad_unittest.cc b/cc/quads/draw_quad_unittest.cc index 7124db2a64..f0f77190ff 100644 --- a/cc/quads/draw_quad_unittest.cc +++ b/cc/quads/draw_quad_unittest.cc @@ -38,6 +38,7 @@ TEST(DrawQuadTest, CopySharedQuadState) { bool is_clipped = true; float opacity = 0.25f; SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; + int sorting_context_id = 65536; scoped_ptr<SharedQuadState> state(new SharedQuadState); state->SetAll(quad_transform, @@ -46,7 +47,8 @@ TEST(DrawQuadTest, CopySharedQuadState) { clip_rect, is_clipped, opacity, - blend_mode); + blend_mode, + sorting_context_id); scoped_ptr<SharedQuadState> copy(new SharedQuadState); copy->CopyFrom(state.get()); @@ -65,6 +67,7 @@ scoped_ptr<SharedQuadState> CreateSharedQuadState() { gfx::Rect clip_rect(19, 21, 23, 25); bool is_clipped = false; float opacity = 1.f; + int sorting_context_id = 65536; SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; scoped_ptr<SharedQuadState> state(new SharedQuadState); @@ -74,7 +77,8 @@ scoped_ptr<SharedQuadState> CreateSharedQuadState() { clip_rect, is_clipped, opacity, - blend_mode); + blend_mode, + sorting_context_id); return state.Pass(); } diff --git a/cc/quads/render_pass_unittest.cc b/cc/quads/render_pass_unittest.cc index 7f723a4060..59af62d2ed 100644 --- a/cc/quads/render_pass_unittest.cc +++ b/cc/quads/render_pass_unittest.cc @@ -86,7 +86,8 @@ TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { gfx::Rect(), false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<CheckerboardDrawQuad> checkerboard_quad = CheckerboardDrawQuad::Create(); @@ -136,7 +137,8 @@ TEST(RenderPassTest, CopyAllShouldBeIdentical) { gfx::Rect(), false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<CheckerboardDrawQuad> checkerboard_quad1 = CheckerboardDrawQuad::Create(); @@ -162,7 +164,8 @@ TEST(RenderPassTest, CopyAllShouldBeIdentical) { gfx::Rect(), false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<CheckerboardDrawQuad> checkerboard_quad3 = CheckerboardDrawQuad::Create(); @@ -203,7 +206,8 @@ TEST(RenderPassTest, CopyAllShouldBeIdentical) { gfx::Rect(), false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<CheckerboardDrawQuad> contrib_quad = CheckerboardDrawQuad::Create(); @@ -262,7 +266,8 @@ TEST(RenderPassTest, CopyAllWithCulledQuads) { gfx::Rect(), false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<CheckerboardDrawQuad> checkerboard_quad1 = CheckerboardDrawQuad::Create(); @@ -280,7 +285,8 @@ TEST(RenderPassTest, CopyAllWithCulledQuads) { gfx::Rect(), false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); // A second shared state with no quads. SharedQuadState* shared_state3 = pass->CreateAndAppendSharedQuadState(); @@ -290,7 +296,8 @@ TEST(RenderPassTest, CopyAllWithCulledQuads) { gfx::Rect(), false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); // A last shared state with a quad again. SharedQuadState* shared_state4 = pass->CreateAndAppendSharedQuadState(); @@ -300,7 +307,8 @@ TEST(RenderPassTest, CopyAllWithCulledQuads) { gfx::Rect(), false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<CheckerboardDrawQuad> checkerboard_quad2 = CheckerboardDrawQuad::Create(); diff --git a/cc/quads/shared_quad_state.cc b/cc/quads/shared_quad_state.cc index 444d3300be..57959e3cdd 100644 --- a/cc/quads/shared_quad_state.cc +++ b/cc/quads/shared_quad_state.cc @@ -11,7 +11,11 @@ namespace cc { SharedQuadState::SharedQuadState() - : is_clipped(false), opacity(0.f), blend_mode(SkXfermode::kSrcOver_Mode) {} + : is_clipped(false), + opacity(0.f), + blend_mode(SkXfermode::kSrcOver_Mode), + sorting_context_id(0) { +} SharedQuadState::~SharedQuadState() { TRACE_EVENT_OBJECT_DELETED_WITH_ID( @@ -29,7 +33,8 @@ void SharedQuadState::SetAll(const gfx::Transform& content_to_target_transform, const gfx::Rect& clip_rect, bool is_clipped, float opacity, - SkXfermode::Mode blend_mode) { + SkXfermode::Mode blend_mode, + int sorting_context_id) { this->content_to_target_transform = content_to_target_transform; this->content_bounds = content_bounds; this->visible_content_rect = visible_content_rect; @@ -37,6 +42,7 @@ void SharedQuadState::SetAll(const gfx::Transform& content_to_target_transform, this->is_clipped = is_clipped; this->opacity = opacity; this->blend_mode = blend_mode; + this->sorting_context_id = sorting_context_id; } scoped_ptr<base::Value> SharedQuadState::AsValue() const { diff --git a/cc/quads/shared_quad_state.h b/cc/quads/shared_quad_state.h index d0e2afb64e..30a1e25b3d 100644 --- a/cc/quads/shared_quad_state.h +++ b/cc/quads/shared_quad_state.h @@ -35,7 +35,8 @@ class CC_EXPORT SharedQuadState { const gfx::Rect& clip_rect, bool is_clipped, float opacity, - SkXfermode::Mode blend_mode); + SkXfermode::Mode blend_mode, + int sorting_context_id); scoped_ptr<base::Value> AsValue() const; // Transforms from quad's original content space to its target content space. @@ -49,6 +50,7 @@ class CC_EXPORT SharedQuadState { bool is_clipped; float opacity; SkXfermode::Mode blend_mode; + int sorting_context_id; }; } // namespace cc diff --git a/cc/resources/memory_history.cc b/cc/resources/memory_history.cc index a2f8b6ee11..4dc49c881a 100644 --- a/cc/resources/memory_history.cc +++ b/cc/resources/memory_history.cc @@ -24,7 +24,7 @@ void MemoryHistory::GetMinAndMax(size_t* min, size_t* max) const { *max = 0; for (RingBufferType::Iterator it = ring_buffer_.Begin(); it; ++it) { - size_t bytes_total = it->bytes_total(); + size_t bytes_total = it->total_bytes_used; if (bytes_total < *min) *min = bytes_total; diff --git a/cc/resources/memory_history.h b/cc/resources/memory_history.h index daca10f35a..570a3d0ca4 100644 --- a/cc/resources/memory_history.h +++ b/cc/resources/memory_history.h @@ -22,17 +22,12 @@ class MemoryHistory { struct Entry { Entry() : total_budget_in_bytes(0), - bytes_allocated(0), - bytes_unreleasable(0), - bytes_over(0) {} + total_bytes_used(0), + had_enough_memory(false) {} size_t total_budget_in_bytes; - size_t bytes_allocated; - size_t bytes_unreleasable; - size_t bytes_over; - size_t bytes_total() const { - return bytes_allocated + bytes_unreleasable + bytes_over; - } + size_t total_bytes_used; + bool had_enough_memory; }; void SaveEntry(const Entry& entry); diff --git a/cc/resources/picture_layer_tiling_set.cc b/cc/resources/picture_layer_tiling_set.cc index 4192c92aeb..fe55d76ef1 100644 --- a/cc/resources/picture_layer_tiling_set.cc +++ b/cc/resources/picture_layer_tiling_set.cc @@ -307,19 +307,6 @@ PictureLayerTilingSet::CoverageIterator::operator bool() const { region_iter_.has_rect(); } -void PictureLayerTilingSet::UpdateTilePriorities( - WhichTree tree, - const gfx::Rect& visible_layer_rect, - float layer_contents_scale, - double current_frame_time_in_seconds) { - for (size_t i = 0; i < tilings_.size(); ++i) { - tilings_[i]->UpdateTilePriorities(tree, - visible_layer_rect, - layer_contents_scale, - current_frame_time_in_seconds); - } -} - void PictureLayerTilingSet::DidBecomeActive() { for (size_t i = 0; i < tilings_.size(); ++i) tilings_[i]->DidBecomeActive(); diff --git a/cc/resources/picture_layer_tiling_set.h b/cc/resources/picture_layer_tiling_set.h index 5c8df6009a..67b267c280 100644 --- a/cc/resources/picture_layer_tiling_set.h +++ b/cc/resources/picture_layer_tiling_set.h @@ -54,11 +54,6 @@ class CC_EXPORT PictureLayerTilingSet { // Remove all tiles; keep all tilings. void RemoveAllTiles(); - void UpdateTilePriorities(WhichTree tree, - const gfx::Rect& visible_layer_rect, - float layer_contents_scale, - double current_frame_time_in_seconds); - void DidBecomeActive(); void DidBecomeRecycled(); diff --git a/cc/resources/picture_layer_tiling_unittest.cc b/cc/resources/picture_layer_tiling_unittest.cc index 3167c636bc..bfdd6fce8a 100644 --- a/cc/resources/picture_layer_tiling_unittest.cc +++ b/cc/resources/picture_layer_tiling_unittest.cc @@ -34,6 +34,19 @@ static gfx::Rect ViewportInLayerSpace( return ToEnclosingRect(viewport_in_layer_space); } +static void UpdateAllTilePriorities(PictureLayerTilingSet* set, + WhichTree tree, + const gfx::Rect& visible_layer_rect, + float layer_contents_scale, + double current_frame_time_in_seconds) { + for (size_t i = 0; i < set->num_tilings(); ++i) { + set->tiling_at(i)->UpdateTilePriorities(tree, + visible_layer_rect, + layer_contents_scale, + current_frame_time_in_seconds); + } +} + class TestablePictureLayerTiling : public PictureLayerTiling { public: using PictureLayerTiling::SetLiveTilesRect; @@ -1171,11 +1184,11 @@ TEST_F(PictureLayerTilingIteratorTest, AddTilingsToMatchScale) { gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); - active_set.UpdateTilePriorities( - PENDING_TREE, - gfx::Rect(layer_bounds), // visible content rect - 1.f, // current contents scale - 1.0); // current frame time + UpdateAllTilePriorities(&active_set, + PENDING_TREE, + gfx::Rect(layer_bounds), // visible content rect + 1.f, // current contents scale + 1.0); // current frame time // The active tiling has tiles now. VerifyTiles(active_set.tiling_at(0), @@ -1196,11 +1209,11 @@ TEST_F(PictureLayerTilingIteratorTest, AddTilingsToMatchScale) { // UpdateTilePriorities on the pending tiling at the same frame time. The // pending tiling should get tiles. - pending_set.UpdateTilePriorities( - PENDING_TREE, - gfx::Rect(layer_bounds), // visible content rect - 1.f, // current contents scale - 1.0); // current frame time + UpdateAllTilePriorities(&pending_set, + PENDING_TREE, + gfx::Rect(layer_bounds), // visible content rect + 1.f, // current contents scale + 1.0); // current frame time VerifyTiles(pending_set.tiling_at(0), 1.f, diff --git a/cc/resources/prioritized_tile_set.cc b/cc/resources/prioritized_tile_set.cc deleted file mode 100644 index b7b3b5a741..0000000000 --- a/cc/resources/prioritized_tile_set.cc +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "cc/resources/prioritized_tile_set.h" - -#include <algorithm> - -#include "cc/resources/managed_tile_state.h" -#include "cc/resources/tile.h" - -namespace cc { - -class BinComparator { - public: - bool operator()(const Tile* a, - const Tile* b) const { - const ManagedTileState& ams = a->managed_state(); - const ManagedTileState& bms = b->managed_state(); - - if (ams.priority_bin != bms.priority_bin) - return ams.priority_bin < bms.priority_bin; - - if (ams.required_for_activation != bms.required_for_activation) - return ams.required_for_activation; - - if (ams.resolution != bms.resolution) - return ams.resolution < bms.resolution; - - if (ams.distance_to_visible != bms.distance_to_visible) - return ams.distance_to_visible < bms.distance_to_visible; - - gfx::Rect a_rect = a->content_rect(); - gfx::Rect b_rect = b->content_rect(); - if (a_rect.y() != b_rect.y()) - return a_rect.y() < b_rect.y(); - return a_rect.x() < b_rect.x(); - } -}; - -namespace { - -typedef std::vector<Tile*> TileVector; - -void SortBinTiles(ManagedTileBin bin, TileVector* tiles) { - switch (bin) { - case NOW_AND_READY_TO_DRAW_BIN: - case NEVER_BIN: - break; - case NOW_BIN: - case SOON_BIN: - case EVENTUALLY_AND_ACTIVE_BIN: - case EVENTUALLY_BIN: - case AT_LAST_AND_ACTIVE_BIN: - case AT_LAST_BIN: - std::sort(tiles->begin(), tiles->end(), BinComparator()); - break; - default: - NOTREACHED(); - } -} - -} // namespace - -PrioritizedTileSet::PrioritizedTileSet() { - for (int bin = 0; bin < NUM_BINS; ++bin) - bin_sorted_[bin] = true; -} - -PrioritizedTileSet::~PrioritizedTileSet() {} - -void PrioritizedTileSet::InsertTile(Tile* tile, ManagedTileBin bin) { - tiles_[bin].push_back(tile); - bin_sorted_[bin] = false; -} - -void PrioritizedTileSet::Clear() { - for (int bin = 0; bin < NUM_BINS; ++bin) { - tiles_[bin].clear(); - bin_sorted_[bin] = true; - } -} - -void PrioritizedTileSet::SortBinIfNeeded(ManagedTileBin bin) { - if (!bin_sorted_[bin]) { - SortBinTiles(bin, &tiles_[bin]); - bin_sorted_[bin] = true; - } -} - -PrioritizedTileSet::Iterator::Iterator( - PrioritizedTileSet* tile_set, bool use_priority_ordering) - : tile_set_(tile_set), - current_bin_(NOW_AND_READY_TO_DRAW_BIN), - use_priority_ordering_(use_priority_ordering) { - if (use_priority_ordering_) - tile_set_->SortBinIfNeeded(current_bin_); - iterator_ = tile_set->tiles_[current_bin_].begin(); - if (iterator_ == tile_set_->tiles_[current_bin_].end()) - AdvanceList(); -} - -PrioritizedTileSet::Iterator::~Iterator() {} - -void PrioritizedTileSet::Iterator::DisablePriorityOrdering() { - use_priority_ordering_ = false; -} - -PrioritizedTileSet::Iterator& -PrioritizedTileSet::Iterator::operator++() { - // We can't increment past the end of the tiles. - DCHECK(iterator_ != tile_set_->tiles_[current_bin_].end()); - - ++iterator_; - if (iterator_ == tile_set_->tiles_[current_bin_].end()) - AdvanceList(); - return *this; -} - -Tile* PrioritizedTileSet::Iterator::operator*() { - DCHECK(iterator_ != tile_set_->tiles_[current_bin_].end()); - return *iterator_; -} - -void PrioritizedTileSet::Iterator::AdvanceList() { - DCHECK(iterator_ == tile_set_->tiles_[current_bin_].end()); - - while (current_bin_ != NEVER_BIN) { - current_bin_ = static_cast<ManagedTileBin>(current_bin_ + 1); - - if (use_priority_ordering_) - tile_set_->SortBinIfNeeded(current_bin_); - - iterator_ = tile_set_->tiles_[current_bin_].begin(); - if (iterator_ != tile_set_->tiles_[current_bin_].end()) - break; - } -} - -} // namespace cc diff --git a/cc/resources/prioritized_tile_set.h b/cc/resources/prioritized_tile_set.h deleted file mode 100644 index 15d0e4f8b4..0000000000 --- a/cc/resources/prioritized_tile_set.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CC_RESOURCES_PRIORITIZED_TILE_SET_H_ -#define CC_RESOURCES_PRIORITIZED_TILE_SET_H_ - -#include <vector> - -#include "cc/base/cc_export.h" -#include "cc/resources/managed_tile_state.h" - -namespace cc { -class Tile; - -class CC_EXPORT PrioritizedTileSet { - public: - PrioritizedTileSet(); - ~PrioritizedTileSet(); - - void InsertTile(Tile* tile, ManagedTileBin bin); - void Clear(); - - class CC_EXPORT Iterator { - public: - Iterator(PrioritizedTileSet* set, bool use_priority_ordering); - - ~Iterator(); - - void DisablePriorityOrdering(); - - Iterator& operator++(); - Tile* operator->() { return *(*this); } - Tile* operator*(); - operator bool() const { - return iterator_ != tile_set_->tiles_[current_bin_].end(); - } - - private: - void AdvanceList(); - - PrioritizedTileSet* tile_set_; - ManagedTileBin current_bin_; - std::vector<Tile*>::iterator iterator_; - bool use_priority_ordering_; - }; - - private: - friend class Iterator; - - void SortBinIfNeeded(ManagedTileBin bin); - - std::vector<Tile*> tiles_[NUM_BINS]; - bool bin_sorted_[NUM_BINS]; -}; - -} // namespace cc - -#endif // CC_RESOURCES_PRIORITIZED_TILE_SET_H_ diff --git a/cc/resources/prioritized_tile_set_unittest.cc b/cc/resources/prioritized_tile_set_unittest.cc deleted file mode 100644 index f0a01d2590..0000000000 --- a/cc/resources/prioritized_tile_set_unittest.cc +++ /dev/null @@ -1,732 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <algorithm> -#include <vector> - -#include "cc/resources/managed_tile_state.h" -#include "cc/resources/prioritized_tile_set.h" -#include "cc/resources/tile.h" -#include "cc/test/fake_output_surface.h" -#include "cc/test/fake_output_surface_client.h" -#include "cc/test/fake_picture_pile_impl.h" -#include "cc/test/fake_tile_manager.h" -#include "cc/test/fake_tile_manager_client.h" -#include "cc/test/test_shared_bitmap_manager.h" -#include "cc/test/test_tile_priorities.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace cc { - -class BinComparator { - public: - bool operator()(const scoped_refptr<Tile>& a, - const scoped_refptr<Tile>& b) const { - const ManagedTileState& ams = a->managed_state(); - const ManagedTileState& bms = b->managed_state(); - - if (ams.priority_bin != bms.priority_bin) - return ams.priority_bin < bms.priority_bin; - - if (ams.required_for_activation != bms.required_for_activation) - return ams.required_for_activation; - - if (ams.resolution != bms.resolution) - return ams.resolution < bms.resolution; - - if (ams.distance_to_visible != bms.distance_to_visible) - return ams.distance_to_visible < bms.distance_to_visible; - - gfx::Rect a_rect = a->content_rect(); - gfx::Rect b_rect = b->content_rect(); - if (a_rect.y() != b_rect.y()) - return a_rect.y() < b_rect.y(); - return a_rect.x() < b_rect.x(); - } -}; - -namespace { - -class PrioritizedTileSetTest : public testing::Test { - public: - PrioritizedTileSetTest() { - output_surface_ = FakeOutputSurface::Create3d().Pass(); - CHECK(output_surface_->BindToClient(&output_surface_client_)); - - shared_bitmap_manager_.reset(new TestSharedBitmapManager()); - resource_provider_ = - ResourceProvider::Create( - output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1, - false) - .Pass(); - resource_pool_ = ResourcePool::Create( - resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888); - tile_manager_.reset( - new FakeTileManager(&tile_manager_client_, resource_pool_.get())); - picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile(); - } - - scoped_refptr<Tile> CreateTile() { - return tile_manager_->CreateTile(picture_pile_.get(), - settings_.default_tile_size, - gfx::Rect(), - gfx::Rect(), - 1.0, - 0, - 0, - 0); - } - - private: - LayerTreeSettings settings_; - FakeOutputSurfaceClient output_surface_client_; - scoped_ptr<FakeOutputSurface> output_surface_; - scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; - scoped_ptr<ResourceProvider> resource_provider_; - scoped_ptr<ResourcePool> resource_pool_; - FakeTileManagerClient tile_manager_client_; - scoped_ptr<FakeTileManager> tile_manager_; - scoped_refptr<FakePicturePileImpl> picture_pile_; -}; - -TEST_F(PrioritizedTileSetTest, EmptyIterator) { - // Creating an iterator to an empty set should work (but create iterator that - // isn't valid). - - PrioritizedTileSet set; - - PrioritizedTileSet::Iterator it(&set, true); - EXPECT_FALSE(it); -} - -TEST_F(PrioritizedTileSetTest, NonEmptyIterator) { - PrioritizedTileSet set; - scoped_refptr<Tile> tile = CreateTile(); - set.InsertTile(tile, NOW_BIN); - - PrioritizedTileSet::Iterator it(&set, true); - EXPECT_TRUE(it); - EXPECT_TRUE(*it == tile.get()); - ++it; - EXPECT_FALSE(it); -} - -TEST_F(PrioritizedTileSetTest, NowAndReadyToDrawBin) { - // Ensure that tiles in NOW_AND_READY_TO_DRAW_BIN aren't sorted. - - PrioritizedTileSet set; - TilePriority priorities[4] = { - TilePriorityForEventualBin(), - TilePriorityForNowBin(), - TilePriority(), - TilePriorityForSoonBin()}; - - std::vector<scoped_refptr<Tile> > tiles; - for (int priority = 0; priority < 4; ++priority) { - for (int i = 0; i < 5; ++i) { - scoped_refptr<Tile> tile = CreateTile(); - tile->SetPriority(ACTIVE_TREE, priorities[priority]); - tile->SetPriority(PENDING_TREE, priorities[priority]); - tiles.push_back(tile); - set.InsertTile(tile, NOW_AND_READY_TO_DRAW_BIN); - } - } - - // Tiles should appear in the same order as inserted. - int i = 0; - for (PrioritizedTileSet::Iterator it(&set, true); - it; - ++it) { - EXPECT_TRUE(*it == tiles[i].get()); - ++i; - } - EXPECT_EQ(20, i); -} - -TEST_F(PrioritizedTileSetTest, NowBin) { - // Ensure that tiles in NOW_BIN are sorted according to BinComparator. - - PrioritizedTileSet set; - TilePriority priorities[4] = { - TilePriorityForEventualBin(), - TilePriorityForNowBin(), - TilePriority(), - TilePriorityForSoonBin()}; - - std::vector<scoped_refptr<Tile> > tiles; - for (int priority = 0; priority < 4; ++priority) { - for (int i = 0; i < 5; ++i) { - scoped_refptr<Tile> tile = CreateTile(); - tile->SetPriority(ACTIVE_TREE, priorities[priority]); - tile->SetPriority(PENDING_TREE, priorities[priority]); - tiles.push_back(tile); - set.InsertTile(tile, NOW_BIN); - } - } - - // Tiles should appear in BinComparator order. - std::sort(tiles.begin(), tiles.end(), BinComparator()); - - int i = 0; - for (PrioritizedTileSet::Iterator it(&set, true); - it; - ++it) { - EXPECT_TRUE(*it == tiles[i].get()); - ++i; - } - EXPECT_EQ(20, i); -} - -TEST_F(PrioritizedTileSetTest, SoonBin) { - // Ensure that tiles in SOON_BIN are sorted according to BinComparator. - - PrioritizedTileSet set; - TilePriority priorities[4] = { - TilePriorityForEventualBin(), - TilePriorityForNowBin(), - TilePriority(), - TilePriorityForSoonBin()}; - - std::vector<scoped_refptr<Tile> > tiles; - for (int priority = 0; priority < 4; ++priority) { - for (int i = 0; i < 5; ++i) { - scoped_refptr<Tile> tile = CreateTile(); - tile->SetPriority(ACTIVE_TREE, priorities[priority]); - tile->SetPriority(PENDING_TREE, priorities[priority]); - tiles.push_back(tile); - set.InsertTile(tile, SOON_BIN); - } - } - - // Tiles should appear in BinComparator order. - std::sort(tiles.begin(), tiles.end(), BinComparator()); - - int i = 0; - for (PrioritizedTileSet::Iterator it(&set, true); - it; - ++it) { - EXPECT_TRUE(*it == tiles[i].get()); - ++i; - } - EXPECT_EQ(20, i); -} - -TEST_F(PrioritizedTileSetTest, SoonBinNoPriority) { - // Ensure that when not using priority iterator, SOON_BIN tiles - // are not sorted. - - PrioritizedTileSet set; - TilePriority priorities[4] = { - TilePriorityForEventualBin(), - TilePriorityForNowBin(), - TilePriority(), - TilePriorityForSoonBin()}; - - std::vector<scoped_refptr<Tile> > tiles; - for (int priority = 0; priority < 4; ++priority) { - for (int i = 0; i < 5; ++i) { - scoped_refptr<Tile> tile = CreateTile(); - tile->SetPriority(ACTIVE_TREE, priorities[priority]); - tile->SetPriority(PENDING_TREE, priorities[priority]); - tiles.push_back(tile); - set.InsertTile(tile, SOON_BIN); - } - } - - int i = 0; - for (PrioritizedTileSet::Iterator it(&set, false); - it; - ++it) { - EXPECT_TRUE(*it == tiles[i].get()); - ++i; - } - EXPECT_EQ(20, i); -} - -TEST_F(PrioritizedTileSetTest, EventuallyAndActiveBin) { - // Ensure that EVENTUALLY_AND_ACTIVE_BIN tiles are sorted. - - PrioritizedTileSet set; - TilePriority priorities[4] = { - TilePriorityForEventualBin(), - TilePriorityForNowBin(), - TilePriority(), - TilePriorityForSoonBin()}; - - std::vector<scoped_refptr<Tile> > tiles; - for (int priority = 0; priority < 4; ++priority) { - for (int i = 0; i < 5; ++i) { - scoped_refptr<Tile> tile = CreateTile(); - tile->SetPriority(ACTIVE_TREE, priorities[priority]); - tile->SetPriority(PENDING_TREE, priorities[priority]); - tiles.push_back(tile); - set.InsertTile(tile, EVENTUALLY_AND_ACTIVE_BIN); - } - } - - // Tiles should appear in BinComparator order. - std::sort(tiles.begin(), tiles.end(), BinComparator()); - - int i = 0; - for (PrioritizedTileSet::Iterator it(&set, true); - it; - ++it) { - EXPECT_TRUE(*it == tiles[i].get()); - ++i; - } - EXPECT_EQ(20, i); -} - -TEST_F(PrioritizedTileSetTest, EventuallyBin) { - // Ensure that EVENTUALLY_BIN tiles are sorted. - - PrioritizedTileSet set; - TilePriority priorities[4] = { - TilePriorityForEventualBin(), - TilePriorityForNowBin(), - TilePriority(), - TilePriorityForSoonBin()}; - - std::vector<scoped_refptr<Tile> > tiles; - for (int priority = 0; priority < 4; ++priority) { - for (int i = 0; i < 5; ++i) { - scoped_refptr<Tile> tile = CreateTile(); - tile->SetPriority(ACTIVE_TREE, priorities[priority]); - tile->SetPriority(PENDING_TREE, priorities[priority]); - tiles.push_back(tile); - set.InsertTile(tile, EVENTUALLY_BIN); - } - } - - // Tiles should appear in BinComparator order. - std::sort(tiles.begin(), tiles.end(), BinComparator()); - - int i = 0; - for (PrioritizedTileSet::Iterator it(&set, true); - it; - ++it) { - EXPECT_TRUE(*it == tiles[i].get()); - ++i; - } - EXPECT_EQ(20, i); -} - -TEST_F(PrioritizedTileSetTest, AtLastAndActiveBin) { - // Ensure that AT_LAST_AND_ACTIVE_BIN tiles are sorted. - - PrioritizedTileSet set; - TilePriority priorities[4] = { - TilePriorityForEventualBin(), - TilePriorityForNowBin(), - TilePriority(), - TilePriorityForSoonBin()}; - - std::vector<scoped_refptr<Tile> > tiles; - for (int priority = 0; priority < 4; ++priority) { - for (int i = 0; i < 5; ++i) { - scoped_refptr<Tile> tile = CreateTile(); - tile->SetPriority(ACTIVE_TREE, priorities[priority]); - tile->SetPriority(PENDING_TREE, priorities[priority]); - tiles.push_back(tile); - set.InsertTile(tile, AT_LAST_AND_ACTIVE_BIN); - } - } - - // Tiles should appear in BinComparator order. - std::sort(tiles.begin(), tiles.end(), BinComparator()); - - int i = 0; - for (PrioritizedTileSet::Iterator it(&set, true); - it; - ++it) { - EXPECT_TRUE(*it == tiles[i].get()); - ++i; - } - EXPECT_EQ(20, i); -} - -TEST_F(PrioritizedTileSetTest, AtLastBin) { - // Ensure that AT_LAST_BIN tiles are sorted. - - PrioritizedTileSet set; - TilePriority priorities[4] = { - TilePriorityForEventualBin(), - TilePriorityForNowBin(), - TilePriority(), - TilePriorityForSoonBin()}; - - std::vector<scoped_refptr<Tile> > tiles; - for (int priority = 0; priority < 4; ++priority) { - for (int i = 0; i < 5; ++i) { - scoped_refptr<Tile> tile = CreateTile(); - tile->SetPriority(ACTIVE_TREE, priorities[priority]); - tile->SetPriority(PENDING_TREE, priorities[priority]); - tiles.push_back(tile); - set.InsertTile(tile, AT_LAST_BIN); - } - } - - // Tiles should appear in BinComparator order. - std::sort(tiles.begin(), tiles.end(), BinComparator()); - - int i = 0; - for (PrioritizedTileSet::Iterator it(&set, true); - it; - ++it) { - EXPECT_TRUE(*it == tiles[i].get()); - ++i; - } - EXPECT_EQ(20, i); -} - -TEST_F(PrioritizedTileSetTest, TilesForEachBin) { - // Aggregate test with one tile for each of the bins, which - // should appear in order of the bins. - - scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile(); - scoped_refptr<Tile> now_bin = CreateTile(); - scoped_refptr<Tile> soon_bin = CreateTile(); - scoped_refptr<Tile> eventually_and_active_bin = CreateTile(); - scoped_refptr<Tile> eventually_bin = CreateTile(); - scoped_refptr<Tile> at_last_bin = CreateTile(); - scoped_refptr<Tile> at_last_and_active_bin = CreateTile(); - - PrioritizedTileSet set; - set.InsertTile(soon_bin, SOON_BIN); - set.InsertTile(at_last_and_active_bin, AT_LAST_AND_ACTIVE_BIN); - set.InsertTile(eventually_bin, EVENTUALLY_BIN); - set.InsertTile(now_bin, NOW_BIN); - set.InsertTile(eventually_and_active_bin, EVENTUALLY_AND_ACTIVE_BIN); - set.InsertTile(at_last_bin, AT_LAST_BIN); - set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); - - // Tiles should appear in order. - PrioritizedTileSet::Iterator it(&set, true); - EXPECT_TRUE(*it == now_and_ready_to_draw_bin.get()); - ++it; - EXPECT_TRUE(*it == now_bin.get()); - ++it; - EXPECT_TRUE(*it == soon_bin.get()); - ++it; - EXPECT_TRUE(*it == eventually_and_active_bin.get()); - ++it; - EXPECT_TRUE(*it == eventually_bin.get()); - ++it; - EXPECT_TRUE(*it == at_last_and_active_bin.get()); - ++it; - EXPECT_TRUE(*it == at_last_bin.get()); - ++it; - EXPECT_FALSE(it); -} - -TEST_F(PrioritizedTileSetTest, ManyTilesForEachBin) { - // Aggregate test with many tiles in each of the bins of various - // priorities. Ensure that they are all returned in a sorted order. - - std::vector<scoped_refptr<Tile> > now_and_ready_to_draw_bins; - std::vector<scoped_refptr<Tile> > now_bins; - std::vector<scoped_refptr<Tile> > soon_bins; - std::vector<scoped_refptr<Tile> > eventually_and_active_bins; - std::vector<scoped_refptr<Tile> > eventually_bins; - std::vector<scoped_refptr<Tile> > at_last_bins; - std::vector<scoped_refptr<Tile> > at_last_and_active_bins; - - TilePriority priorities[4] = { - TilePriorityForEventualBin(), - TilePriorityForNowBin(), - TilePriority(), - TilePriorityForSoonBin()}; - - PrioritizedTileSet set; - for (int priority = 0; priority < 4; ++priority) { - for (int i = 0; i < 5; ++i) { - scoped_refptr<Tile> tile = CreateTile(); - tile->SetPriority(ACTIVE_TREE, priorities[priority]); - tile->SetPriority(PENDING_TREE, priorities[priority]); - - now_and_ready_to_draw_bins.push_back(tile); - now_bins.push_back(tile); - soon_bins.push_back(tile); - eventually_and_active_bins.push_back(tile); - eventually_bins.push_back(tile); - at_last_bins.push_back(tile); - at_last_and_active_bins.push_back(tile); - - set.InsertTile(tile, NOW_AND_READY_TO_DRAW_BIN); - set.InsertTile(tile, NOW_BIN); - set.InsertTile(tile, SOON_BIN); - set.InsertTile(tile, EVENTUALLY_AND_ACTIVE_BIN); - set.InsertTile(tile, EVENTUALLY_BIN); - set.InsertTile(tile, AT_LAST_BIN); - set.InsertTile(tile, AT_LAST_AND_ACTIVE_BIN); - } - } - - PrioritizedTileSet::Iterator it(&set, true); - std::vector<scoped_refptr<Tile> >::iterator vector_it; - - // Now and ready are not sorted. - for (vector_it = now_and_ready_to_draw_bins.begin(); - vector_it != now_and_ready_to_draw_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // Now bins are sorted. - std::sort(now_bins.begin(), now_bins.end(), BinComparator()); - for (vector_it = now_bins.begin(); vector_it != now_bins.end(); ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // Soon bins are sorted. - std::sort(soon_bins.begin(), soon_bins.end(), BinComparator()); - for (vector_it = soon_bins.begin(); vector_it != soon_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // Eventually and active bins are sorted. - std::sort(eventually_and_active_bins.begin(), - eventually_and_active_bins.end(), - BinComparator()); - for (vector_it = eventually_and_active_bins.begin(); - vector_it != eventually_and_active_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // Eventually bins are sorted. - std::sort(eventually_bins.begin(), eventually_bins.end(), BinComparator()); - for (vector_it = eventually_bins.begin(); vector_it != eventually_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // At last and active bins are sorted. - std::sort(at_last_and_active_bins.begin(), - at_last_and_active_bins.end(), - BinComparator()); - for (vector_it = at_last_and_active_bins.begin(); - vector_it != at_last_and_active_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // At last bins are sorted. - std::sort(at_last_bins.begin(), at_last_bins.end(), BinComparator()); - for (vector_it = at_last_bins.begin(); vector_it != at_last_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - EXPECT_FALSE(it); -} - -TEST_F(PrioritizedTileSetTest, ManyTilesForEachBinDisablePriority) { - // Aggregate test with many tiles for each of the bins. Tiles should - // appear in order, until DisablePriorityOrdering is called. After that - // tiles should appear in the order they were inserted. - - std::vector<scoped_refptr<Tile> > now_and_ready_to_draw_bins; - std::vector<scoped_refptr<Tile> > now_bins; - std::vector<scoped_refptr<Tile> > soon_bins; - std::vector<scoped_refptr<Tile> > eventually_and_active_bins; - std::vector<scoped_refptr<Tile> > eventually_bins; - std::vector<scoped_refptr<Tile> > at_last_bins; - std::vector<scoped_refptr<Tile> > at_last_and_active_bins; - - TilePriority priorities[4] = { - TilePriorityForEventualBin(), - TilePriorityForNowBin(), - TilePriority(), - TilePriorityForSoonBin()}; - - PrioritizedTileSet set; - for (int priority = 0; priority < 4; ++priority) { - for (int i = 0; i < 5; ++i) { - scoped_refptr<Tile> tile = CreateTile(); - tile->SetPriority(ACTIVE_TREE, priorities[priority]); - tile->SetPriority(PENDING_TREE, priorities[priority]); - - now_and_ready_to_draw_bins.push_back(tile); - now_bins.push_back(tile); - soon_bins.push_back(tile); - eventually_and_active_bins.push_back(tile); - eventually_bins.push_back(tile); - at_last_bins.push_back(tile); - at_last_and_active_bins.push_back(tile); - - set.InsertTile(tile, NOW_AND_READY_TO_DRAW_BIN); - set.InsertTile(tile, NOW_BIN); - set.InsertTile(tile, SOON_BIN); - set.InsertTile(tile, EVENTUALLY_AND_ACTIVE_BIN); - set.InsertTile(tile, EVENTUALLY_BIN); - set.InsertTile(tile, AT_LAST_BIN); - set.InsertTile(tile, AT_LAST_AND_ACTIVE_BIN); - } - } - - PrioritizedTileSet::Iterator it(&set, true); - std::vector<scoped_refptr<Tile> >::iterator vector_it; - - // Now and ready are not sorted. - for (vector_it = now_and_ready_to_draw_bins.begin(); - vector_it != now_and_ready_to_draw_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // Now bins are sorted. - std::sort(now_bins.begin(), now_bins.end(), BinComparator()); - for (vector_it = now_bins.begin(); vector_it != now_bins.end(); ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // Soon bins are sorted. - std::sort(soon_bins.begin(), soon_bins.end(), BinComparator()); - for (vector_it = soon_bins.begin(); vector_it != soon_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // After we disable priority ordering, we already have sorted the next vector. - it.DisablePriorityOrdering(); - - // Eventually and active bins are sorted. - std::sort(eventually_and_active_bins.begin(), - eventually_and_active_bins.end(), - BinComparator()); - for (vector_it = eventually_and_active_bins.begin(); - vector_it != eventually_and_active_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // Eventually bins are not sorted. - for (vector_it = eventually_bins.begin(); vector_it != eventually_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // At last and active bins are not sorted. - for (vector_it = at_last_and_active_bins.begin(); - vector_it != at_last_and_active_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - // At last bins are not sorted. - for (vector_it = at_last_bins.begin(); vector_it != at_last_bins.end(); - ++vector_it) { - EXPECT_TRUE(*vector_it == *it); - ++it; - } - - EXPECT_FALSE(it); -} - -TEST_F(PrioritizedTileSetTest, TilesForFirstAndLastBins) { - // Make sure that if we have empty lists between two non-empty lists, - // we just get two tiles from the iterator. - - scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile(); - scoped_refptr<Tile> at_last_bin = CreateTile(); - - PrioritizedTileSet set; - set.InsertTile(at_last_bin, AT_LAST_BIN); - set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); - - // Only two tiles should appear and they should appear in order. - PrioritizedTileSet::Iterator it(&set, true); - EXPECT_TRUE(*it == now_and_ready_to_draw_bin.get()); - ++it; - EXPECT_TRUE(*it == at_last_bin.get()); - ++it; - EXPECT_FALSE(it); -} - -TEST_F(PrioritizedTileSetTest, MultipleIterators) { - // Ensure that multiple iterators don't interfere with each other. - - scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile(); - scoped_refptr<Tile> now_bin = CreateTile(); - scoped_refptr<Tile> soon_bin = CreateTile(); - scoped_refptr<Tile> eventually_bin = CreateTile(); - scoped_refptr<Tile> at_last_bin = CreateTile(); - - PrioritizedTileSet set; - set.InsertTile(soon_bin, SOON_BIN); - set.InsertTile(eventually_bin, EVENTUALLY_BIN); - set.InsertTile(now_bin, NOW_BIN); - set.InsertTile(at_last_bin, AT_LAST_BIN); - set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); - - // Tiles should appear in order. - PrioritizedTileSet::Iterator it(&set, true); - EXPECT_TRUE(*it == now_and_ready_to_draw_bin.get()); - ++it; - EXPECT_TRUE(*it == now_bin.get()); - ++it; - EXPECT_TRUE(*it == soon_bin.get()); - ++it; - EXPECT_TRUE(*it == eventually_bin.get()); - ++it; - EXPECT_TRUE(*it == at_last_bin.get()); - ++it; - EXPECT_FALSE(it); - - // Creating multiple iterators shouldn't affect old iterators. - PrioritizedTileSet::Iterator second_it(&set, true); - EXPECT_TRUE(second_it); - EXPECT_FALSE(it); - - ++second_it; - EXPECT_TRUE(second_it); - ++second_it; - EXPECT_TRUE(second_it); - EXPECT_FALSE(it); - - PrioritizedTileSet::Iterator third_it(&set, true); - EXPECT_TRUE(third_it); - ++second_it; - ++second_it; - EXPECT_TRUE(second_it); - EXPECT_TRUE(third_it); - EXPECT_FALSE(it); - - ++third_it; - ++third_it; - EXPECT_TRUE(third_it); - EXPECT_TRUE(*third_it == soon_bin.get()); - EXPECT_TRUE(second_it); - EXPECT_TRUE(*second_it == at_last_bin.get()); - EXPECT_FALSE(it); - - ++second_it; - EXPECT_TRUE(third_it); - EXPECT_FALSE(second_it); - EXPECT_FALSE(it); - - set.Clear(); - - PrioritizedTileSet::Iterator empty_it(&set, true); - EXPECT_FALSE(empty_it); -} - -} // namespace -} // namespace cc - diff --git a/cc/resources/tile.cc b/cc/resources/tile.cc index d59dc029cc..16252ede5b 100644 --- a/cc/resources/tile.cc +++ b/cc/resources/tile.cc @@ -25,7 +25,6 @@ Tile::Tile(TileManager* tile_manager, int source_frame_number, int flags) : RefCountedManaged<Tile>(tile_manager), - tile_manager_(tile_manager), tile_size_(tile_size), content_rect_(content_rect), contents_scale_(contents_scale), @@ -44,19 +43,11 @@ Tile::~Tile() { } void Tile::SetPriority(WhichTree tree, const TilePriority& priority) { - if (priority == priority_[tree]) - return; - priority_[tree] = priority; - tile_manager_->DidChangeTilePriority(this); } void Tile::MarkRequiredForActivation() { - if (priority_[PENDING_TREE].required_for_activation) - return; - priority_[PENDING_TREE].required_for_activation = true; - tile_manager_->DidChangeTilePriority(this); } scoped_ptr<base::Value> Tile::AsValue() const { diff --git a/cc/resources/tile.h b/cc/resources/tile.h index 69ef56fde8..38469b6352 100644 --- a/cc/resources/tile.h +++ b/cc/resources/tile.h @@ -151,7 +151,6 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> { const ManagedTileState& managed_state() const { return managed_state_; } RasterMode DetermineRasterModeForResolution(TileResolution resolution) const; - TileManager* tile_manager_; scoped_refptr<PicturePileImpl> picture_pile_; gfx::Rect tile_size_; gfx::Rect content_rect_; diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc index b1cc1aec6b..b47491d852 100644 --- a/cc/resources/tile_manager.cc +++ b/cc/resources/tile_manager.cc @@ -227,110 +227,6 @@ class ImageDecodeTaskImpl : public ImageDecodeTask { const size_t kScheduledRasterTasksLimit = 32u; -// Memory limit policy works by mapping some bin states to the NEVER bin. -const ManagedTileBin kBinPolicyMap[NUM_TILE_MEMORY_LIMIT_POLICIES][NUM_BINS] = { - // [ALLOW_NOTHING] - {NEVER_BIN, // [NOW_AND_READY_TO_DRAW_BIN] - NEVER_BIN, // [NOW_BIN] - NEVER_BIN, // [SOON_BIN] - NEVER_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] - NEVER_BIN, // [EVENTUALLY_BIN] - NEVER_BIN, // [AT_LAST_AND_ACTIVE_BIN] - NEVER_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] - }, - // [ALLOW_ABSOLUTE_MINIMUM] - {NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] - NOW_BIN, // [NOW_BIN] - NEVER_BIN, // [SOON_BIN] - NEVER_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] - NEVER_BIN, // [EVENTUALLY_BIN] - NEVER_BIN, // [AT_LAST_AND_ACTIVE_BIN] - NEVER_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] - }, - // [ALLOW_PREPAINT_ONLY] - {NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] - NOW_BIN, // [NOW_BIN] - SOON_BIN, // [SOON_BIN] - NEVER_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] - NEVER_BIN, // [EVENTUALLY_BIN] - NEVER_BIN, // [AT_LAST_AND_ACTIVE_BIN] - NEVER_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] - }, - // [ALLOW_ANYTHING] - {NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] - NOW_BIN, // [NOW_BIN] - SOON_BIN, // [SOON_BIN] - EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] - EVENTUALLY_BIN, // [EVENTUALLY_BIN] - AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_AND_ACTIVE_BIN] - AT_LAST_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] - }}; - -// Ready to draw works by mapping NOW_BIN to NOW_AND_READY_TO_DRAW_BIN. -const ManagedTileBin kBinReadyToDrawMap[2][NUM_BINS] = { - // Not ready - {NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] - NOW_BIN, // [NOW_BIN] - SOON_BIN, // [SOON_BIN] - EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] - EVENTUALLY_BIN, // [EVENTUALLY_BIN] - AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_AND_ACTIVE_BIN] - AT_LAST_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] - }, - // Ready - {NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] - NOW_AND_READY_TO_DRAW_BIN, // [NOW_BIN] - SOON_BIN, // [SOON_BIN] - EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] - EVENTUALLY_BIN, // [EVENTUALLY_BIN] - AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_AND_ACTIVE_BIN] - AT_LAST_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] - }}; - -// Active works by mapping some bin stats to equivalent _ACTIVE_BIN state. -const ManagedTileBin kBinIsActiveMap[2][NUM_BINS] = { - // Inactive - {NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] - NOW_BIN, // [NOW_BIN] - SOON_BIN, // [SOON_BIN] - EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] - EVENTUALLY_BIN, // [EVENTUALLY_BIN] - AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_AND_ACTIVE_BIN] - AT_LAST_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] - }, - // Active - {NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] - NOW_BIN, // [NOW_BIN] - SOON_BIN, // [SOON_BIN] - EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] - EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_BIN] - AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_AND_ACTIVE_BIN] - AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] - }}; - -// Determine bin based on three categories of tiles: things we need now, -// things we need soon, and eventually. -inline ManagedTileBin BinFromTilePriority(const TilePriority& prio) { - if (prio.priority_bin == TilePriority::NOW) - return NOW_BIN; - - if (prio.priority_bin == TilePriority::SOON) - return SOON_BIN; - - if (prio.distance_to_visible == std::numeric_limits<float>::infinity()) - return NEVER_BIN; - - return EVENTUALLY_BIN; -} - } // namespace RasterTaskCompletionStats::RasterTaskCompletionStats() @@ -368,14 +264,7 @@ TileManager::TileManager( task_runner_(task_runner), resource_pool_(resource_pool), rasterizer_(rasterizer), - prioritized_tiles_dirty_(false), - all_tiles_that_need_to_be_rasterized_have_memory_(true), - all_tiles_required_for_activation_have_memory_(true), - memory_required_bytes_(0), - memory_nice_to_have_bytes_(0), - bytes_releasable_(0), - resources_releasable_(0), - ever_exceeded_memory_budget_(false), + all_tiles_that_need_to_be_rasterized_are_scheduled_(true), rendering_stats_instrumentation_(rendering_stats_instrumentation), did_initialize_visible_tile_(false), did_check_for_completed_tasks_since_last_schedule_tasks_(true), @@ -402,20 +291,12 @@ TileManager::~TileManager() { // resources. rasterizer_->Shutdown(); rasterizer_->CheckForCompletedTasks(); - - DCHECK_EQ(0u, bytes_releasable_); - DCHECK_EQ(0u, resources_releasable_); } void TileManager::Release(Tile* tile) { - prioritized_tiles_dirty_ = true; released_tiles_.push_back(tile); } -void TileManager::DidChangeTilePriority(Tile* tile) { - prioritized_tiles_dirty_ = true; -} - bool TileManager::ShouldForceTasksRequiredForActivationToComplete() const { return global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY; } @@ -449,17 +330,6 @@ void TileManager::CleanUpReleasedTiles() { released_tiles_.clear(); } -void TileManager::UpdatePrioritizedTileSetIfNeeded() { - if (!prioritized_tiles_dirty_) - return; - - CleanUpReleasedTiles(); - - prioritized_tiles_.Clear(); - GetTilesWithAssignedBins(&prioritized_tiles_); - prioritized_tiles_dirty_ = false; -} - void TileManager::DidFinishRunningTasks() { TRACE_EVENT0("cc", "TileManager::DidFinishRunningTasks"); @@ -468,7 +338,7 @@ void TileManager::DidFinishRunningTasks() { // When OOM, keep re-assigning memory until we reach a steady state // where top-priority tiles are initialized. - if (all_tiles_that_need_to_be_rasterized_have_memory_ && + if (all_tiles_that_need_to_be_rasterized_are_scheduled_ && !memory_usage_above_limit) return; @@ -476,8 +346,7 @@ void TileManager::DidFinishRunningTasks() { did_check_for_completed_tasks_since_last_schedule_tasks_ = true; TileVector tiles_that_need_to_be_rasterized; - AssignGpuMemoryToTiles(&prioritized_tiles_, - &tiles_that_need_to_be_rasterized); + AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized); // |tiles_that_need_to_be_rasterized| will be empty when we reach a // steady memory state. Keep scheduling tasks until we reach this state. @@ -518,150 +387,13 @@ void TileManager::DidFinishRunningTasks() { } void TileManager::DidFinishRunningTasksRequiredForActivation() { - // This is only a true indication that all tiles required for - // activation are initialized when no tiles are OOM. We need to - // wait for DidFinishRunningTasks() to be called, try to re-assign - // memory and in worst case use on-demand raster when tiles - // required for activation are OOM. - if (!all_tiles_required_for_activation_have_memory_) - return; - ready_to_activate_check_notifier_.Schedule(); } -void TileManager::GetTilesWithAssignedBins(PrioritizedTileSet* tiles) { - TRACE_EVENT0("cc", "TileManager::GetTilesWithAssignedBins"); - - // Compute new stats to be return by GetMemoryStats(). - memory_required_bytes_ = 0; - memory_nice_to_have_bytes_ = 0; - - const TileMemoryLimitPolicy memory_policy = global_state_.memory_limit_policy; - const TreePriority tree_priority = global_state_.tree_priority; - - // For each tree, bin into different categories of tiles. - for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { - Tile* tile = it->second; - ManagedTileState& mts = tile->managed_state(); - - const ManagedTileState::TileVersion& tile_version = - tile->GetTileVersionForDrawing(); - bool tile_is_ready_to_draw = tile_version.IsReadyToDraw(); - bool tile_is_active = tile_is_ready_to_draw || - mts.tile_versions[mts.raster_mode].raster_task_; - - // Get the active priority and bin. - TilePriority active_priority = tile->priority(ACTIVE_TREE); - ManagedTileBin active_bin = BinFromTilePriority(active_priority); - - // Get the pending priority and bin. - TilePriority pending_priority = tile->priority(PENDING_TREE); - ManagedTileBin pending_bin = BinFromTilePriority(pending_priority); - - bool pending_is_low_res = pending_priority.resolution == LOW_RESOLUTION; - bool pending_is_non_ideal = - pending_priority.resolution == NON_IDEAL_RESOLUTION; - bool active_is_non_ideal = - active_priority.resolution == NON_IDEAL_RESOLUTION; - - // Adjust bin state based on if ready to draw. - active_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][active_bin]; - pending_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][pending_bin]; - - // Adjust bin state based on if active. - active_bin = kBinIsActiveMap[tile_is_active][active_bin]; - pending_bin = kBinIsActiveMap[tile_is_active][pending_bin]; - - // We never want to paint new non-ideal tiles, as we always have - // a high-res tile covering that content (paint that instead). - if (!tile_is_ready_to_draw && active_is_non_ideal) - active_bin = NEVER_BIN; - if (!tile_is_ready_to_draw && pending_is_non_ideal) - pending_bin = NEVER_BIN; - - if (!tile_is_ready_to_draw || tile_version.requires_resource()) { - // The bin that the tile would have if the GPU memory manager had - // a maximally permissive policy, send to the GPU memory manager - // to determine policy. - ManagedTileBin gpu_memmgr_stats_bin = std::min(active_bin, pending_bin); - if ((gpu_memmgr_stats_bin == NOW_BIN) || - (gpu_memmgr_stats_bin == NOW_AND_READY_TO_DRAW_BIN)) - memory_required_bytes_ += BytesConsumedIfAllocated(tile); - if (gpu_memmgr_stats_bin != NEVER_BIN) - memory_nice_to_have_bytes_ += BytesConsumedIfAllocated(tile); - } - - ManagedTileBin tree_bin[NUM_TREES]; - tree_bin[ACTIVE_TREE] = kBinPolicyMap[memory_policy][active_bin]; - tree_bin[PENDING_TREE] = kBinPolicyMap[memory_policy][pending_bin]; - - // Adjust pending bin state for low res tiles. This prevents pending tree - // low-res tiles from being initialized before high-res tiles. - if (pending_is_low_res) - tree_bin[PENDING_TREE] = std::max(tree_bin[PENDING_TREE], EVENTUALLY_BIN); - - TilePriority tile_priority; - switch (tree_priority) { - case SAME_PRIORITY_FOR_BOTH_TREES: - mts.bin = std::min(tree_bin[ACTIVE_TREE], tree_bin[PENDING_TREE]); - tile_priority = tile->combined_priority(); - break; - case SMOOTHNESS_TAKES_PRIORITY: - mts.bin = tree_bin[ACTIVE_TREE]; - tile_priority = active_priority; - break; - case NEW_CONTENT_TAKES_PRIORITY: - mts.bin = tree_bin[PENDING_TREE]; - tile_priority = pending_priority; - break; - } - - // Bump up the priority if we determined it's NEVER_BIN on one tree, - // but is still required on the other tree. - bool is_in_never_bin_on_both_trees = tree_bin[ACTIVE_TREE] == NEVER_BIN && - tree_bin[PENDING_TREE] == NEVER_BIN; - - if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) - mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; - - mts.resolution = tile_priority.resolution; - mts.priority_bin = tile_priority.priority_bin; - mts.distance_to_visible = tile_priority.distance_to_visible; - mts.required_for_activation = tile_priority.required_for_activation; - - mts.visible_and_ready_to_draw = - tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; - - // Tiles that are required for activation shouldn't be in NEVER_BIN unless - // smoothness takes priority or memory policy allows nothing to be - // initialized. - DCHECK(!mts.required_for_activation || mts.bin != NEVER_BIN || - tree_priority == SMOOTHNESS_TAKES_PRIORITY || - memory_policy == ALLOW_NOTHING); - - // If the tile is in NEVER_BIN and it does not have an active task, then we - // can release the resources early. If it does have the task however, we - // should keep it in the prioritized tile set to ensure that AssignGpuMemory - // can visit it. - if (mts.bin == NEVER_BIN && - !mts.tile_versions[mts.raster_mode].raster_task_) { - FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(tile); - continue; - } - - // Insert the tile into a priority set. - tiles->InsertTile(tile, mts.bin); - } -} - void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) { TRACE_EVENT0("cc", "TileManager::ManageTiles"); - // Update internal state. - if (state != global_state_) { - global_state_ = state; - prioritized_tiles_dirty_ = true; - } + global_state_ = state; // We need to call CheckForCompletedTasks() once in-between each call // to ScheduleTasks() to prevent canceled tasks from being scheduled. @@ -670,11 +402,12 @@ void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) { did_check_for_completed_tasks_since_last_schedule_tasks_ = true; } - UpdatePrioritizedTileSetIfNeeded(); + // TODO(vmpstr): See if we still need to keep tiles alive when layers release + // them. + CleanUpReleasedTiles(); TileVector tiles_that_need_to_be_rasterized; - AssignGpuMemoryToTiles(&prioritized_tiles_, - &tiles_that_need_to_be_rasterized); + AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized); // Finally, schedule rasterizer tasks. ScheduleTasks(tiles_that_need_to_be_rasterized); @@ -712,21 +445,10 @@ bool TileManager::UpdateVisibleTiles() { return did_initialize_visible_tile; } -void TileManager::GetMemoryStats(size_t* memory_required_bytes, - size_t* memory_nice_to_have_bytes, - size_t* memory_allocated_bytes, - size_t* memory_used_bytes) const { - *memory_required_bytes = memory_required_bytes_; - *memory_nice_to_have_bytes = memory_nice_to_have_bytes_; - *memory_allocated_bytes = resource_pool_->total_memory_usage_bytes(); - *memory_used_bytes = resource_pool_->acquired_memory_usage_bytes(); -} - scoped_ptr<base::Value> TileManager::BasicStateAsValue() const { scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); state->SetInteger("tile_count", tiles_.size()); state->Set("global_state", global_state_.AsValue().release()); - state->Set("memory_requirements", GetMemoryRequirementsAsValue().release()); return state.PassAs<base::Value>(); } @@ -738,27 +460,63 @@ scoped_ptr<base::Value> TileManager::AllTilesAsValue() const { return state.PassAs<base::Value>(); } -scoped_ptr<base::Value> TileManager::GetMemoryRequirementsAsValue() const { - scoped_ptr<base::DictionaryValue> requirements(new base::DictionaryValue()); - - size_t memory_required_bytes; - size_t memory_nice_to_have_bytes; - size_t memory_allocated_bytes; - size_t memory_used_bytes; - GetMemoryStats(&memory_required_bytes, - &memory_nice_to_have_bytes, - &memory_allocated_bytes, - &memory_used_bytes); - requirements->SetInteger("memory_required_bytes", memory_required_bytes); - requirements->SetInteger("memory_nice_to_have_bytes", - memory_nice_to_have_bytes); - requirements->SetInteger("memory_allocated_bytes", memory_allocated_bytes); - requirements->SetInteger("memory_used_bytes", memory_used_bytes); - return requirements.PassAs<base::Value>(); +bool TileManager::FreeTileResourcesUntilUsageIsWithinLimit( + EvictionTileIterator* iterator, + const MemoryUsage& limit, + MemoryUsage* usage) { + while (usage->Exceeds(limit)) { + if (!*iterator) + return false; + + Tile* tile = **iterator; + + *usage -= MemoryUsage::FromTile(tile); + FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(tile); + ++(*iterator); + } + return true; +} + +bool TileManager::FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( + EvictionTileIterator* iterator, + const MemoryUsage& limit, + const TilePriority& other_priority, + MemoryUsage* usage) { + while (usage->Exceeds(limit)) { + if (!*iterator) + return false; + + Tile* tile = **iterator; + if (!other_priority.IsHigherPriorityThan( + tile->priority_for_tree_priority(global_state_.tree_priority))) { + return false; + } + + *usage -= MemoryUsage::FromTile(tile); + FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(tile); + ++(*iterator); + } + return true; +} + +bool TileManager::TilePriorityViolatesMemoryPolicy( + const TilePriority& priority) { + switch (global_state_.memory_limit_policy) { + case ALLOW_NOTHING: + return true; + case ALLOW_ABSOLUTE_MINIMUM: + return priority.priority_bin > TilePriority::NOW; + case ALLOW_PREPAINT_ONLY: + return priority.priority_bin > TilePriority::SOON; + case ALLOW_ANYTHING: + return priority.distance_to_visible == + std::numeric_limits<float>::infinity(); + } + NOTREACHED(); + return true; } void TileManager::AssignGpuMemoryToTiles( - PrioritizedTileSet* tiles, TileVector* tiles_that_need_to_be_rasterized) { TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); @@ -771,178 +529,99 @@ void TileManager::AssignGpuMemoryToTiles( // Now give memory out to the tiles until we're out, and build // the needs-to-be-rasterized queue. - all_tiles_that_need_to_be_rasterized_have_memory_ = true; - all_tiles_required_for_activation_have_memory_ = true; - - // Cast to prevent overflow. - int64 soft_bytes_available = - static_cast<int64>(bytes_releasable_) + - static_cast<int64>(global_state_.soft_memory_limit_in_bytes) - - static_cast<int64>(resource_pool_->acquired_memory_usage_bytes()); - int64 hard_bytes_available = - static_cast<int64>(bytes_releasable_) + - static_cast<int64>(global_state_.hard_memory_limit_in_bytes) - - static_cast<int64>(resource_pool_->acquired_memory_usage_bytes()); - int resources_available = resources_releasable_ + - global_state_.num_resources_limit - - resource_pool_->acquired_resource_count(); - size_t soft_bytes_allocatable = - std::max(static_cast<int64>(0), soft_bytes_available); - size_t hard_bytes_allocatable = - std::max(static_cast<int64>(0), hard_bytes_available); - size_t resources_allocatable = std::max(0, resources_available); - - size_t bytes_that_exceeded_memory_budget = 0; - size_t soft_bytes_left = soft_bytes_allocatable; - size_t hard_bytes_left = hard_bytes_allocatable; - - size_t resources_left = resources_allocatable; - bool oomed_soft = false; - bool oomed_hard = false; - bool have_hit_soft_memory = false; // Soft memory comes after hard. + all_tiles_that_need_to_be_rasterized_are_scheduled_ = true; - unsigned schedule_priority = 1u; - for (PrioritizedTileSet::Iterator it(tiles, true); it; ++it) { - Tile* tile = *it; - ManagedTileState& mts = tile->managed_state(); + MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes, + global_state_.num_resources_limit); + MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, + global_state_.num_resources_limit); + MemoryUsage memory_usage(resource_pool_->acquired_memory_usage_bytes(), + resource_pool_->acquired_resource_count()); - mts.scheduled_priority = schedule_priority++; + EvictionTileIterator eviction_it(this, global_state_.tree_priority); - mts.raster_mode = tile->DetermineOverallRasterMode(); + bool had_enough_memory_to_schedule_tiles_needed_now = true; - ManagedTileState::TileVersion& tile_version = - mts.tile_versions[mts.raster_mode]; + unsigned schedule_priority = 1u; + for (RasterTileIterator it(this, global_state_.tree_priority); it; ++it) { + Tile* tile = *it; + TilePriority priority = + tile->priority_for_tree_priority(global_state_.tree_priority); - // If this tile doesn't need a resource, then nothing to do. - if (!tile_version.requires_resource()) - continue; + if (TilePriorityViolatesMemoryPolicy(priority)) + break; - // If the tile is not needed, free it up. - if (mts.bin == NEVER_BIN) { - FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(tile); - continue; + // We won't be able to schedule this tile, so break out early. + if (tiles_that_need_to_be_rasterized->size() >= + kScheduledRasterTasksLimit) { + all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; + break; } - const bool tile_uses_hard_limit = mts.bin <= NOW_BIN; - const size_t bytes_if_allocated = BytesConsumedIfAllocated(tile); - const size_t tile_bytes_left = - (tile_uses_hard_limit) ? hard_bytes_left : soft_bytes_left; - - // Hard-limit is reserved for tiles that would cause a calamity - // if they were to go away, so by definition they are the highest - // priority memory, and must be at the front of the list. - DCHECK(!(have_hit_soft_memory && tile_uses_hard_limit)); - have_hit_soft_memory |= !tile_uses_hard_limit; - - size_t tile_bytes = 0; - size_t tile_resources = 0; - - // It costs to maintain a resource. - for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { - if (mts.tile_versions[mode].resource_) { - tile_bytes += bytes_if_allocated; - tile_resources++; - } - } + ManagedTileState& mts = tile->managed_state(); + mts.scheduled_priority = schedule_priority++; + mts.raster_mode = tile->DetermineOverallRasterMode(); + ManagedTileState::TileVersion& tile_version = + mts.tile_versions[mts.raster_mode]; - // Allow lower priority tiles with initialized resources to keep - // their memory by only assigning memory to new raster tasks if - // they can be scheduled. - bool reached_scheduled_raster_tasks_limit = - tiles_that_need_to_be_rasterized->size() >= kScheduledRasterTasksLimit; - if (!reached_scheduled_raster_tasks_limit) { - // If we don't have the required version, and it's not in flight - // then we'll have to pay to create a new task. - if (!tile_version.resource_ && !tile_version.raster_task_) { - tile_bytes += bytes_if_allocated; - tile_resources++; - } - } + DCHECK(!tile_version.IsReadyToDraw()); - // Tile is OOM. - if (tile_bytes > tile_bytes_left || tile_resources > resources_left) { - bool was_ready_to_draw = tile->IsReadyToDraw(); - - FreeResourcesForTile(tile); - - // This tile was already on screen and now its resources have been - // released. In order to prevent checkerboarding, set this tile as - // rasterize on demand immediately. - if (mts.visible_and_ready_to_draw) - tile_version.set_rasterize_on_demand(); - - if (was_ready_to_draw) - client_->NotifyTileStateChanged(tile); - - oomed_soft = true; - if (tile_uses_hard_limit) { - oomed_hard = true; - bytes_that_exceeded_memory_budget += tile_bytes; - } - } else { - resources_left -= tile_resources; - hard_bytes_left -= tile_bytes; - soft_bytes_left = - (soft_bytes_left > tile_bytes) ? soft_bytes_left - tile_bytes : 0; - if (tile_version.resource_) - continue; + // If the tile already has a raster_task, then the memory used by it is + // already accounted for in memory_usage. Otherwise, we'll have to acquire + // more memory to create a raster task. + MemoryUsage memory_required_by_tile_to_be_scheduled; + if (!tile_version.raster_task_) { + memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( + tile->size(), resource_pool_->resource_format()); } - DCHECK(!tile_version.resource_); - - // Tile shouldn't be rasterized if |tiles_that_need_to_be_rasterized| - // has reached it's limit or we've failed to assign gpu memory to this - // or any higher priority tile. Preventing tiles that fit into memory - // budget to be rasterized when higher priority tile is oom is - // important for two reasons: - // 1. Tile size should not impact raster priority. - // 2. Tiles with existing raster task could otherwise incorrectly - // be added as they are not affected by |bytes_allocatable|. - bool can_schedule_tile = - !oomed_soft && !reached_scheduled_raster_tasks_limit; - - if (!can_schedule_tile) { - all_tiles_that_need_to_be_rasterized_have_memory_ = false; - if (tile->required_for_activation()) - all_tiles_required_for_activation_have_memory_ = false; - it.DisablePriorityOrdering(); - continue; + bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; + + // This is the memory limit that will be used by this tile. Depending on + // the tile priority, it will be one of hard_memory_limit or + // soft_memory_limit. + MemoryUsage& tile_memory_limit = + tile_is_needed_now ? hard_memory_limit : soft_memory_limit; + + bool memory_usage_is_within_limit = + FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( + &eviction_it, + tile_memory_limit - memory_required_by_tile_to_be_scheduled, + priority, + &memory_usage); + + // If we couldn't fit the tile into our current memory limit, then we're + // done. + if (!memory_usage_is_within_limit) { + if (tile_is_needed_now) + had_enough_memory_to_schedule_tiles_needed_now = false; + all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; + break; } + memory_usage += memory_required_by_tile_to_be_scheduled; tiles_that_need_to_be_rasterized->push_back(tile); } - // OOM reporting uses hard-limit, soft-OOM is normal depending on limit. - ever_exceeded_memory_budget_ |= oomed_hard; - if (ever_exceeded_memory_budget_) { - TRACE_COUNTER_ID2("cc", - "over_memory_budget", - this, - "budget", - global_state_.hard_memory_limit_in_bytes, - "over", - bytes_that_exceeded_memory_budget); - } + // Note that we should try and further reduce memory in case the above loop + // didn't reduce memory. This ensures that we always release as many resources + // as possible to stay within the memory limit. + FreeTileResourcesUntilUsageIsWithinLimit( + &eviction_it, hard_memory_limit, &memory_usage); + + // Update memory_stats_from_last_assign_, which is used to display HUD + // information. memory_stats_from_last_assign_.total_budget_in_bytes = global_state_.hard_memory_limit_in_bytes; - memory_stats_from_last_assign_.bytes_allocated = - hard_bytes_allocatable - hard_bytes_left; - memory_stats_from_last_assign_.bytes_unreleasable = - resource_pool_->acquired_memory_usage_bytes() - bytes_releasable_; - memory_stats_from_last_assign_.bytes_over = bytes_that_exceeded_memory_budget; + memory_stats_from_last_assign_.total_bytes_used = memory_usage.memory_bytes(); + memory_stats_from_last_assign_.had_enough_memory = + had_enough_memory_to_schedule_tiles_needed_now; } void TileManager::FreeResourceForTile(Tile* tile, RasterMode mode) { ManagedTileState& mts = tile->managed_state(); - if (mts.tile_versions[mode].resource_) { + if (mts.tile_versions[mode].resource_) resource_pool_->ReleaseResource(mts.tile_versions[mode].resource_.Pass()); - - DCHECK_GE(bytes_releasable_, BytesConsumedIfAllocated(tile)); - DCHECK_GE(resources_releasable_, 1u); - - bytes_releasable_ -= BytesConsumedIfAllocated(tile); - --resources_releasable_; - } } void TileManager::FreeResourcesForTile(Tile* tile) { @@ -1144,9 +823,6 @@ void TileManager::OnRasterTaskCompleted( } else { tile_version.set_use_resource(); tile_version.resource_ = resource.Pass(); - - bytes_releasable_ += BytesConsumedIfAllocated(tile); - ++resources_releasable_; } FreeUnusedResourcesForTile(tile); @@ -1177,7 +853,6 @@ scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, tiles_[tile->id()] = tile; used_layer_counts_[tile->layer_id()]++; - prioritized_tiles_dirty_ = true; return tile; } @@ -1630,4 +1305,57 @@ void TileManager::CheckIfReadyToActivate() { client_->NotifyReadyToActivate(); } +TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) { +} + +TileManager::MemoryUsage::MemoryUsage(int64 memory_bytes, int resource_count) + : memory_bytes_(memory_bytes), resource_count_(resource_count) { +} + +// static +TileManager::MemoryUsage TileManager::MemoryUsage::FromConfig( + const gfx::Size& size, + ResourceFormat format) { + return MemoryUsage(Resource::MemorySizeBytes(size, format), 1); +} + +// static +TileManager::MemoryUsage TileManager::MemoryUsage::FromTile(const Tile* tile) { + const ManagedTileState& mts = tile->managed_state(); + MemoryUsage total_usage; + for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { + if (mts.tile_versions[mode].resource_) { + total_usage += MemoryUsage::FromConfig( + tile->size(), mts.tile_versions[mode].resource_->format()); + } + } + return total_usage; +} + +TileManager::MemoryUsage& TileManager::MemoryUsage::operator+=( + const MemoryUsage& other) { + memory_bytes_ += other.memory_bytes_; + resource_count_ += other.resource_count_; + return *this; +} + +TileManager::MemoryUsage& TileManager::MemoryUsage::operator-=( + const MemoryUsage& other) { + memory_bytes_ -= other.memory_bytes_; + resource_count_ -= other.resource_count_; + return *this; +} + +TileManager::MemoryUsage TileManager::MemoryUsage::operator-( + const MemoryUsage& other) { + MemoryUsage result = *this; + result -= other; + return result; +} + +bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { + return memory_bytes_ > limit.memory_bytes_ || + resource_count_ > limit.resource_count_; +} + } // namespace cc diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h index 30f4730423..fb53cabf7c 100644 --- a/cc/resources/tile_manager.h +++ b/cc/resources/tile_manager.h @@ -21,7 +21,6 @@ #include "cc/resources/managed_tile_state.h" #include "cc/resources/memory_history.h" #include "cc/resources/picture_pile_impl.h" -#include "cc/resources/prioritized_tile_set.h" #include "cc/resources/rasterizer.h" #include "cc/resources/resource_pool.h" #include "cc/resources/tile.h" @@ -187,11 +186,6 @@ class CC_EXPORT TileManager : public RasterizerClient, scoped_ptr<base::Value> BasicStateAsValue() const; scoped_ptr<base::Value> AllTilesAsValue() const; - void GetMemoryStats(size_t* memory_required_bytes, - size_t* memory_nice_to_have_bytes, - size_t* memory_allocated_bytes, - size_t* memory_used_bytes) const; - const MemoryHistory::Entry& memory_stats_from_last_assign() const { return memory_stats_from_last_assign_; } @@ -204,10 +198,8 @@ class CC_EXPORT TileManager : public RasterizerClient, ManagedTileState::TileVersion& tile_version = mts.tile_versions[HIGH_QUALITY_RASTER_MODE]; - tile_version.resource_ = resource_pool_->AcquireResource(gfx::Size(1, 1)); - - bytes_releasable_ += BytesConsumedIfAllocated(tiles[i]); - ++resources_releasable_; + tile_version.resource_ = + resource_pool_->AcquireResource(tiles[i]->size()); } } @@ -222,12 +214,7 @@ class CC_EXPORT TileManager : public RasterizerClient, void SetGlobalStateForTesting( const GlobalStateThatImpactsTilePriority& state) { - // Soft limit is used for resource pool such that - // memory returns to soft limit after going over. - if (state != global_state_) { - global_state_ = state; - prioritized_tiles_dirty_ = true; - } + global_state_ = state; } void SetRasterizerForTesting(Rasterizer* rasterizer); @@ -241,13 +228,10 @@ class CC_EXPORT TileManager : public RasterizerClient, Rasterizer* rasterizer, RenderingStatsInstrumentation* rendering_stats_instrumentation); - // Methods called by Tile - friend class Tile; - void DidChangeTilePriority(Tile* tile); - void CleanUpReleasedTiles(); // Overriden from RefCountedManager<Tile>: + friend class Tile; virtual void Release(Tile* tile) OVERRIDE; // Overriden from RasterizerClient: @@ -262,11 +246,30 @@ class CC_EXPORT TileManager : public RasterizerClient, virtual void ScheduleTasks( const TileVector& tiles_that_need_to_be_rasterized); - void AssignGpuMemoryToTiles(PrioritizedTileSet* tiles, - TileVector* tiles_that_need_to_be_rasterized); - void GetTilesWithAssignedBins(PrioritizedTileSet* tiles); + void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized); private: + class MemoryUsage { + public: + MemoryUsage(); + MemoryUsage(int64 memory_bytes, int resource_count); + + static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); + static MemoryUsage FromTile(const Tile* tile); + + MemoryUsage& operator+=(const MemoryUsage& other); + MemoryUsage& operator-=(const MemoryUsage& other); + MemoryUsage operator-(const MemoryUsage& other); + + bool Exceeds(const MemoryUsage& limit) const; + + int64 memory_bytes() const { return memory_bytes_; } + + private: + int64 memory_bytes_; + int resource_count_; + }; + void OnImageDecodeTaskCompleted(int layer_id, SkPixelRef* pixel_ref, bool was_canceled); @@ -276,11 +279,6 @@ class CC_EXPORT TileManager : public RasterizerClient, const PicturePileImpl::Analysis& analysis, bool was_canceled); - inline size_t BytesConsumedIfAllocated(const Tile* tile) const { - return Resource::MemorySizeBytes(tile->size(), - resource_pool_->resource_format()); - } - void FreeResourceForTile(Tile* tile, RasterMode mode); void FreeResourcesForTile(Tile* tile); void FreeUnusedResourcesForTile(Tile* tile); @@ -288,9 +286,16 @@ class CC_EXPORT TileManager : public RasterizerClient, scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, SkPixelRef* pixel_ref); scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); - scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; - void UpdatePrioritizedTileSetIfNeeded(); + bool FreeTileResourcesUntilUsageIsWithinLimit(EvictionTileIterator* iterator, + const MemoryUsage& limit, + MemoryUsage* usage); + bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( + EvictionTileIterator* iterator, + const MemoryUsage& limit, + const TilePriority& other_priority, + MemoryUsage* usage); + bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); bool IsReadyToActivate() const; void CheckIfReadyToActivate(); @@ -303,19 +308,8 @@ class CC_EXPORT TileManager : public RasterizerClient, typedef base::hash_map<Tile::Id, Tile*> TileMap; TileMap tiles_; - PrioritizedTileSet prioritized_tiles_; - bool prioritized_tiles_dirty_; - - bool all_tiles_that_need_to_be_rasterized_have_memory_; - bool all_tiles_required_for_activation_have_memory_; - - size_t memory_required_bytes_; - size_t memory_nice_to_have_bytes_; - - size_t bytes_releasable_; - size_t resources_releasable_; + bool all_tiles_that_need_to_be_rasterized_are_scheduled_; - bool ever_exceeded_memory_budget_; MemoryHistory::Entry memory_stats_from_last_assign_; RenderingStatsInstrumentation* rendering_stats_instrumentation_; diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc index 0ac79b16de..cc54fbb633 100644 --- a/cc/resources/tile_manager_perftest.cc +++ b/cc/resources/tile_manager_perftest.cc @@ -277,7 +277,7 @@ class TileManagerPerfTest : public testing::Test { do { host_impl_.UpdateCurrentFrameTime(); for (unsigned i = 0; i < layers.size(); ++i) - layers[i]->UpdateTilePriorities(); + layers[i]->UpdateTiles(); GlobalStateThatImpactsTilePriority global_state(GlobalStateForTest()); tile_manager()->ManageTiles(global_state); diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc index 4beae8f617..0d878cd3ee 100644 --- a/cc/resources/tile_manager_unittest.cc +++ b/cc/resources/tile_manager_unittest.cc @@ -20,455 +20,6 @@ namespace cc { namespace { -class TileManagerTest : public testing::TestWithParam<bool>, - public TileManagerClient { - public: - typedef std::vector<scoped_refptr<Tile> > TileVector; - - TileManagerTest() - : memory_limit_policy_(ALLOW_ANYTHING), - max_tiles_(0), - ready_to_activate_(false) {} - - void Initialize(int max_tiles, - TileMemoryLimitPolicy memory_limit_policy, - TreePriority tree_priority) { - output_surface_ = FakeOutputSurface::Create3d(); - CHECK(output_surface_->BindToClient(&output_surface_client_)); - - shared_bitmap_manager_.reset(new TestSharedBitmapManager()); - resource_provider_ = ResourceProvider::Create( - output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1, - false); - resource_pool_ = ResourcePool::Create( - resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888); - tile_manager_ = - make_scoped_ptr(new FakeTileManager(this, resource_pool_.get())); - - memory_limit_policy_ = memory_limit_policy; - max_tiles_ = max_tiles; - picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile(); - - SetTreePriority(tree_priority); - } - - void SetTreePriority(TreePriority tree_priority) { - GlobalStateThatImpactsTilePriority state; - gfx::Size tile_size = settings_.default_tile_size; - - if (UsingMemoryLimit()) { - state.soft_memory_limit_in_bytes = - max_tiles_ * 4 * tile_size.width() * tile_size.height(); - state.num_resources_limit = 100; - } else { - state.soft_memory_limit_in_bytes = 100 * 1000 * 1000; - state.num_resources_limit = max_tiles_; - } - state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2; - state.memory_limit_policy = memory_limit_policy_; - state.tree_priority = tree_priority; - - global_state_ = state; - resource_pool_->SetResourceUsageLimits(state.soft_memory_limit_in_bytes, - state.soft_memory_limit_in_bytes, - state.num_resources_limit); - tile_manager_->SetGlobalStateForTesting(state); - } - - virtual void TearDown() OVERRIDE { - tile_manager_.reset(NULL); - picture_pile_ = NULL; - - testing::Test::TearDown(); - } - - // TileManagerClient implementation. - virtual const std::vector<PictureLayerImpl*>& GetPictureLayers() OVERRIDE { - return picture_layers_; - } - virtual void NotifyReadyToActivate() OVERRIDE { ready_to_activate_ = true; } - virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE {} - - TileVector CreateTilesWithSize(int count, - TilePriority active_priority, - TilePriority pending_priority, - const gfx::Size& tile_size) { - TileVector tiles; - for (int i = 0; i < count; ++i) { - scoped_refptr<Tile> tile = tile_manager_->CreateTile(picture_pile_.get(), - tile_size, - gfx::Rect(), - gfx::Rect(), - 1.0, - 0, - 0, - 0); - tile->SetPriority(ACTIVE_TREE, active_priority); - tile->SetPriority(PENDING_TREE, pending_priority); - tiles.push_back(tile); - } - return tiles; - } - - TileVector CreateTiles(int count, - TilePriority active_priority, - TilePriority pending_priority) { - return CreateTilesWithSize( - count, active_priority, pending_priority, settings_.default_tile_size); - } - - FakeTileManager* tile_manager() { return tile_manager_.get(); } - - int AssignedMemoryCount(const TileVector& tiles) { - int has_memory_count = 0; - for (TileVector::const_iterator it = tiles.begin(); it != tiles.end(); - ++it) { - if (tile_manager_->HasBeenAssignedMemory(*it)) - ++has_memory_count; - } - return has_memory_count; - } - - bool ready_to_activate() const { return ready_to_activate_; } - - // The parametrization specifies whether the max tile limit should - // be applied to memory or resources. - bool UsingResourceLimit() { return !GetParam(); } - bool UsingMemoryLimit() { return GetParam(); } - - protected: - GlobalStateThatImpactsTilePriority global_state_; - - private: - LayerTreeSettings settings_; - scoped_ptr<FakeTileManager> tile_manager_; - scoped_refptr<FakePicturePileImpl> picture_pile_; - FakeOutputSurfaceClient output_surface_client_; - scoped_ptr<FakeOutputSurface> output_surface_; - scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; - scoped_ptr<ResourceProvider> resource_provider_; - scoped_ptr<ResourcePool> resource_pool_; - TileMemoryLimitPolicy memory_limit_policy_; - int max_tiles_; - bool ready_to_activate_; - std::vector<PictureLayerImpl*> picture_layers_; -}; - -TEST_P(TileManagerTest, EnoughMemoryAllowAnything) { - // A few tiles of each type of priority, with enough memory for all tiles. - - Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); - TileVector active_now = - CreateTiles(3, TilePriorityForNowBin(), TilePriority()); - TileVector pending_now = - CreateTiles(3, TilePriority(), TilePriorityForNowBin()); - TileVector active_pending_soon = - CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); - TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(3, AssignedMemoryCount(active_now)); - EXPECT_EQ(3, AssignedMemoryCount(pending_now)); - EXPECT_EQ(3, AssignedMemoryCount(active_pending_soon)); - EXPECT_EQ(0, AssignedMemoryCount(never_bin)); -} - -TEST_P(TileManagerTest, EnoughMemoryAllowPrepaintOnly) { - // A few tiles of each type of priority, with enough memory for all tiles, - // with the exception of never bin. - - Initialize(10, ALLOW_PREPAINT_ONLY, SMOOTHNESS_TAKES_PRIORITY); - TileVector active_now = - CreateTiles(3, TilePriorityForNowBin(), TilePriority()); - TileVector pending_now = - CreateTiles(3, TilePriority(), TilePriorityForNowBin()); - TileVector active_pending_soon = - CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); - TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(3, AssignedMemoryCount(active_now)); - EXPECT_EQ(3, AssignedMemoryCount(pending_now)); - EXPECT_EQ(3, AssignedMemoryCount(active_pending_soon)); - EXPECT_EQ(0, AssignedMemoryCount(never_bin)); -} - -TEST_P(TileManagerTest, EnoughMemoryPendingLowResAllowAbsoluteMinimum) { - // A few low-res tiles required for activation, with enough memory for all - // tiles. - - Initialize(5, ALLOW_ABSOLUTE_MINIMUM, SAME_PRIORITY_FOR_BOTH_TREES); - TileVector pending_low_res = - CreateTiles(5, TilePriority(), TilePriorityLowRes()); - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(5, AssignedMemoryCount(pending_low_res)); -} - -TEST_P(TileManagerTest, EnoughMemoryAllowAbsoluteMinimum) { - // A few tiles of each type of priority, with enough memory for all tiles, - // with the exception of never and soon bins. - - Initialize(10, ALLOW_ABSOLUTE_MINIMUM, SMOOTHNESS_TAKES_PRIORITY); - TileVector active_now = - CreateTiles(3, TilePriorityForNowBin(), TilePriority()); - TileVector pending_now = - CreateTiles(3, TilePriority(), TilePriorityForNowBin()); - TileVector active_pending_soon = - CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); - TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(3, AssignedMemoryCount(active_now)); - EXPECT_EQ(3, AssignedMemoryCount(pending_now)); - EXPECT_EQ(0, AssignedMemoryCount(active_pending_soon)); - EXPECT_EQ(0, AssignedMemoryCount(never_bin)); -} - -TEST_P(TileManagerTest, EnoughMemoryAllowNothing) { - // A few tiles of each type of priority, with enough memory for all tiles, - // but allow nothing should not assign any memory. - - Initialize(10, ALLOW_NOTHING, SMOOTHNESS_TAKES_PRIORITY); - TileVector active_now = - CreateTiles(3, TilePriorityForNowBin(), TilePriority()); - TileVector pending_now = - CreateTiles(3, TilePriority(), TilePriorityForNowBin()); - TileVector active_pending_soon = - CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); - TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(0, AssignedMemoryCount(active_now)); - EXPECT_EQ(0, AssignedMemoryCount(pending_now)); - EXPECT_EQ(0, AssignedMemoryCount(active_pending_soon)); - EXPECT_EQ(0, AssignedMemoryCount(never_bin)); -} - -TEST_P(TileManagerTest, PartialOOMMemoryToPending) { - // 5 tiles on active tree eventually bin, 5 tiles on pending tree that are - // required for activation, but only enough memory for 8 tiles. The result - // is all pending tree tiles get memory, and 3 of the active tree tiles - // get memory. None of these tiles is needed to avoid calimity (flickering or - // raster-on-demand) so the soft memory limit is used. - - Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); - TileVector active_tree_tiles = - CreateTiles(5, TilePriorityForEventualBin(), TilePriority()); - TileVector pending_tree_tiles = - CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles)); - - SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(3, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(5, AssignedMemoryCount(pending_tree_tiles)); -} - -TEST_P(TileManagerTest, PartialOOMMemoryToActive) { - // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, - // but only enough memory for 8 tiles. The result is all active tree tiles - // get memory, and 3 of the pending tree tiles get memory. - // The pending tiles are not needed to avoid calimity (flickering or - // raster-on-demand) and the active tiles fit, so the soft limit is used. - - Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); - TileVector active_tree_tiles = - CreateTiles(5, TilePriorityForNowBin(), TilePriority()); - TileVector pending_tree_tiles = - CreateTiles(5, TilePriority(), TilePriorityForNowBin()); - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles)); -} - -TEST_P(TileManagerTest, TotalOOMMemoryToPending) { - // 10 tiles on active tree eventually bin, 10 tiles on pending tree that are - // required for activation, but only enough tiles for 4 tiles. The result - // is 4 pending tree tiles get memory, and none of the active tree tiles - // get memory. - - Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); - TileVector active_tree_tiles = - CreateTiles(10, TilePriorityForEventualBin(), TilePriority()); - TileVector pending_tree_tiles = - CreateTiles(10, TilePriority(), TilePriorityRequiredForActivation()); - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); - - SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); - tile_manager()->AssignMemoryToTiles(global_state_); - - if (UsingResourceLimit()) { - EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles)); - } else { - // Pending tiles are now required to avoid calimity (flickering or - // raster-on-demand). Hard-limit is used and double the tiles fit. - EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(8, AssignedMemoryCount(pending_tree_tiles)); - } -} - -TEST_P(TileManagerTest, TotalOOMActiveSoonMemoryToPending) { - // 10 tiles on active tree soon bin, 10 tiles on pending tree that are - // required for activation, but only enough tiles for 4 tiles. The result - // is 4 pending tree tiles get memory, and none of the active tree tiles - // get memory. - - Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); - TileVector active_tree_tiles = - CreateTiles(10, TilePriorityForSoonBin(), TilePriority()); - TileVector pending_tree_tiles = - CreateTiles(10, TilePriority(), TilePriorityRequiredForActivation()); - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); - - SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); - tile_manager()->AssignMemoryToTiles(global_state_); - - if (UsingResourceLimit()) { - EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles)); - } else { - // Pending tiles are now required to avoid calimity (flickering or - // raster-on-demand). Hard-limit is used and double the tiles fit. - EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(8, AssignedMemoryCount(pending_tree_tiles)); - } -} - -TEST_P(TileManagerTest, TotalOOMMemoryToActive) { - // 10 tiles on active tree eventually bin, 10 tiles on pending tree now bin, - // but only enough memory for 4 tiles. The result is 4 active tree tiles - // get memory, and none of the pending tree tiles get memory. - - Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); - TileVector active_tree_tiles = - CreateTiles(10, TilePriorityForNowBin(), TilePriority()); - TileVector pending_tree_tiles = - CreateTiles(10, TilePriority(), TilePriorityForNowBin()); - - tile_manager()->AssignMemoryToTiles(global_state_); - - if (UsingResourceLimit()) { - EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); - } else { - // Active tiles are required to avoid calimity (flickering or - // raster-on-demand). Hard-limit is used and double the tiles fit. - EXPECT_EQ(8, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); - } -} - -TEST_P(TileManagerTest, TotalOOMMemoryToNewContent) { - // 10 tiles on active tree now bin, 10 tiles on pending tree now bin, - // but only enough memory for 8 tiles. Any tile missing would cause - // a calamity (flickering or raster-on-demand). Depending on mode, - // we should use varying amounts of the higher hard memory limit. - if (UsingResourceLimit()) - return; - - Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); - TileVector active_tree_tiles = - CreateTiles(10, TilePriorityForNowBin(), TilePriority()); - TileVector pending_tree_tiles = - CreateTiles(10, TilePriority(), TilePriorityForNowBin()); - - // Active tiles are required to avoid calimity. The hard-limit is used and all - // active-tiles fit. No pending tiles are needed to avoid calamity so only 10 - // tiles total are used. - tile_manager()->AssignMemoryToTiles(global_state_); - EXPECT_EQ(10, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); - - // Even the hard-limit won't save us now. All tiles are required to avoid - // a clamity but we only have 16. The tiles will be distribted randomly - // given they are identical, in practice depending on their screen location. - SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); - tile_manager()->AssignMemoryToTiles(global_state_); - EXPECT_EQ(16, - AssignedMemoryCount(active_tree_tiles) + - AssignedMemoryCount(pending_tree_tiles)); - - // The pending tree is now more important. Active tiles will take higher - // priority if they are ready-to-draw in practice. Importantly though, - // pending tiles also utilize the hard-limit. - SetTreePriority(NEW_CONTENT_TAKES_PRIORITY); - tile_manager()->AssignMemoryToTiles(global_state_); - EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); - EXPECT_EQ(10, AssignedMemoryCount(pending_tree_tiles)); -} - -TEST_P(TileManagerTest, RespectMemoryLimit) { - if (UsingResourceLimit()) - return; - - Initialize(5, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); - - // We use double the tiles since the hard-limit is double. - TileVector large_tiles = - CreateTiles(10, TilePriorityForNowBin(), TilePriority()); - - size_t memory_required_bytes; - size_t memory_nice_to_have_bytes; - size_t memory_allocated_bytes; - size_t memory_used_bytes; - - tile_manager()->AssignMemoryToTiles(global_state_); - tile_manager()->GetMemoryStats(&memory_required_bytes, - &memory_nice_to_have_bytes, - &memory_allocated_bytes, - &memory_used_bytes); - // Allocated bytes should never be more than the memory limit. - EXPECT_LE(memory_allocated_bytes, global_state_.hard_memory_limit_in_bytes); - - // Finish raster of large tiles. - tile_manager()->UpdateVisibleTiles(); - - // Remove all large tiles. This will leave the memory currently - // used by these tiles as unused when AssignMemoryToTiles() is called. - large_tiles.clear(); - - // Create a new set of tiles using a different size. These tiles - // can use the memory currently assigned to the large tiles but - // they can't use the same resources as the size doesn't match. - TileVector small_tiles = CreateTilesWithSize( - 10, TilePriorityForNowBin(), TilePriority(), gfx::Size(128, 128)); - - tile_manager()->AssignMemoryToTiles(global_state_); - tile_manager()->GetMemoryStats(&memory_required_bytes, - &memory_nice_to_have_bytes, - &memory_allocated_bytes, - &memory_used_bytes); - // Allocated bytes should never be more than the memory limit. - EXPECT_LE(memory_allocated_bytes, global_state_.hard_memory_limit_in_bytes); -} - -// If true, the max tile limit should be applied as bytes; if false, -// as num_resources_limit. -INSTANTIATE_TEST_CASE_P(TileManagerTests, - TileManagerTest, - ::testing::Values(true, false)); - class TileManagerTileIteratorTest : public testing::Test { public: TileManagerTileIteratorTest() diff --git a/cc/resources/tile_priority.h b/cc/resources/tile_priority.h index f8ac9c6c7b..1556b4e3a7 100644 --- a/cc/resources/tile_priority.h +++ b/cc/resources/tile_priority.h @@ -122,11 +122,6 @@ enum TileMemoryLimitPolicy { // You're the only thing in town. Go crazy. ALLOW_ANYTHING = 3, // Venti. - - NUM_TILE_MEMORY_LIMIT_POLICIES = 4, - - // NOTE: Be sure to update TreePriorityAsValue and kBinPolicyMap when adding - // or reordering fields. }; scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( TileMemoryLimitPolicy policy); @@ -135,8 +130,6 @@ enum TreePriority { SAME_PRIORITY_FOR_BOTH_TREES, SMOOTHNESS_TAKES_PRIORITY, NEW_CONTENT_TAKES_PRIORITY - - // Be sure to update TreePriorityAsValue when adding new fields. }; scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio); @@ -157,17 +150,6 @@ class GlobalStateThatImpactsTilePriority { TreePriority tree_priority; - bool operator==(const GlobalStateThatImpactsTilePriority& other) const { - return memory_limit_policy == other.memory_limit_policy && - soft_memory_limit_in_bytes == other.soft_memory_limit_in_bytes && - hard_memory_limit_in_bytes == other.hard_memory_limit_in_bytes && - num_resources_limit == other.num_resources_limit && - tree_priority == other.tree_priority; - } - bool operator!=(const GlobalStateThatImpactsTilePriority& other) const { - return !(*this == other); - } - scoped_ptr<base::Value> AsValue() const; }; diff --git a/cc/surfaces/surface_aggregator_test_helpers.cc b/cc/surfaces/surface_aggregator_test_helpers.cc index 747f84a3f1..a653eb1735 100644 --- a/cc/surfaces/surface_aggregator_test_helpers.cc +++ b/cc/surfaces/surface_aggregator_test_helpers.cc @@ -40,7 +40,8 @@ void AddTestSurfaceQuad(TestRenderPass* pass, clip_rect, is_clipped, opacity, - blend_mode); + blend_mode, + 0); scoped_ptr<SurfaceDrawQuad> surface_quad = SurfaceDrawQuad::Create(); gfx::Rect quad_rect = gfx::Rect(surface_size); @@ -60,7 +61,8 @@ void AddTestRenderPassQuad(TestRenderPass* pass, output_rect, false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); quad->SetNew(shared_state, output_rect, diff --git a/cc/surfaces/surface_aggregator_unittest.cc b/cc/surfaces/surface_aggregator_unittest.cc index aa5cea04c2..62ba079aad 100644 --- a/cc/surfaces/surface_aggregator_unittest.cc +++ b/cc/surfaces/surface_aggregator_unittest.cc @@ -430,7 +430,8 @@ void AddSolidColorQuadWithBlendMode(const gfx::Size& size, clip_rect, is_clipped, opacity, - blend_mode); + blend_mode, + 0); scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); color_quad->SetNew(pass->shared_quad_state_list.back(), diff --git a/cc/surfaces/surfaces_pixeltest.cc b/cc/surfaces/surfaces_pixeltest.cc index 3559d531a2..9afb4c639a 100644 --- a/cc/surfaces/surfaces_pixeltest.cc +++ b/cc/surfaces/surfaces_pixeltest.cc @@ -40,7 +40,8 @@ SharedQuadState* CreateAndAppendTestSharedQuadState( clip_rect, is_clipped, opacity, - blend_mode); + blend_mode, + 0); return shared_state; } diff --git a/cc/test/fake_layer_tree_host_impl_client.h b/cc/test/fake_layer_tree_host_impl_client.h index 2f33b7aea4..1499047b21 100644 --- a/cc/test/fake_layer_tree_host_impl_client.h +++ b/cc/test/fake_layer_tree_host_impl_client.h @@ -36,7 +36,6 @@ class FakeLayerTreeHostImplClient : public LayerTreeHostImplClient { virtual bool ReduceContentsTextureMemoryOnImplThread( size_t limit_bytes, int priority_cutoff) OVERRIDE; - virtual void SendManagedMemoryStats() OVERRIDE {} virtual bool IsInsideDraw() OVERRIDE; virtual void RenewTreePriority() OVERRIDE {} virtual void PostDelayedScrollbarFadeOnImplThread( diff --git a/cc/test/fake_picture_layer_impl.h b/cc/test/fake_picture_layer_impl.h index 38caff85cd..04661c461f 100644 --- a/cc/test/fake_picture_layer_impl.h +++ b/cc/test/fake_picture_layer_impl.h @@ -50,7 +50,6 @@ class FakePictureLayerImpl : public PictureLayerImpl { using PictureLayerImpl::UpdateIdealScales; using PictureLayerImpl::MaximumTilingContentsScale; - using PictureLayerImpl::ManageTilings; void SetNeedsPostCommitInitialization() { needs_post_commit_initialization_ = true; @@ -94,15 +93,6 @@ class FakePictureLayerImpl : public PictureLayerImpl { void SetAllTilesReadyInTiling(PictureLayerTiling* tiling); void ResetAllTilesPriorities(); - void ScaleAndManageTilings(bool animating_transform_to_screen, - float maximum_animation_contents_scale) { - UpdateIdealScales(); - if (CanHaveTilings()) { - ManageTilings(animating_transform_to_screen, - maximum_animation_contents_scale); - } - } - protected: FakePictureLayerImpl( LayerTreeImpl* tree_impl, diff --git a/cc/test/fake_tile_manager.cc b/cc/test/fake_tile_manager.cc index 1fc2e43e7f..60f75323e1 100644 --- a/cc/test/fake_tile_manager.cc +++ b/cc/test/fake_tile_manager.cc @@ -81,11 +81,9 @@ FakeTileManager::~FakeTileManager() {} void FakeTileManager::AssignMemoryToTiles( const GlobalStateThatImpactsTilePriority& state) { tiles_for_raster.clear(); - all_tiles.Clear(); SetGlobalStateForTesting(state); - GetTilesWithAssignedBins(&all_tiles); - AssignGpuMemoryToTiles(&all_tiles, &tiles_for_raster); + AssignGpuMemoryToTiles(&tiles_for_raster); } bool FakeTileManager::HasBeenAssignedMemory(Tile* tile) { diff --git a/cc/test/fake_tile_manager.h b/cc/test/fake_tile_manager.h index 05dbe6121f..cbb8d6bb5f 100644 --- a/cc/test/fake_tile_manager.h +++ b/cc/test/fake_tile_manager.h @@ -27,7 +27,6 @@ class FakeTileManager : public TileManager { virtual void Release(Tile* tile) OVERRIDE; std::vector<Tile*> tiles_for_raster; - PrioritizedTileSet all_tiles; }; } // namespace cc diff --git a/cc/test/layer_tree_host_common_test.h b/cc/test/layer_tree_host_common_test.h index 38dd85ac35..67eb6cc58b 100644 --- a/cc/test/layer_tree_host_common_test.h +++ b/cc/test/layer_tree_host_common_test.h @@ -43,7 +43,7 @@ class LayerTreeHostCommonTestBase { layer->SetPosition(position); layer->SetBounds(bounds); layer->SetShouldFlattenTransform(flatten_transform); - layer->SetIs3dSorted(is_3d_sorted); + layer->Set3dSortingContextId(is_3d_sorted ? 1 : 0); } void SetLayerPropertiesForTesting(Layer* layer, diff --git a/cc/test/layer_tree_json_parser.cc b/cc/test/layer_tree_json_parser.cc index e94bbea6f7..f177e118fc 100644 --- a/cc/test/layer_tree_json_parser.cc +++ b/cc/test/layer_tree_json_parser.cc @@ -130,8 +130,10 @@ scoped_refptr<Layer> ParseTreeFromValue(base::Value* val, new_layer->SetHaveScrollEventHandlers(scroll_handler); bool is_3d_sorted; - if (dict->GetBoolean("Is3DSorted", &is_3d_sorted)) - new_layer->SetIs3dSorted(is_3d_sorted); + if (dict->GetBoolean("Is3DSorted", &is_3d_sorted)) { + // A non-zero context ID will put the layer into a 3D sorting context + new_layer->Set3dSortingContextId(1); + } if (dict->HasKey("TouchRegion")) { success &= dict->GetList("TouchRegion", &list); diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index 10c415e8c1..8383126f9b 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -69,26 +69,31 @@ class ThreadProxyForTest : public ThreadProxy { private: TestHooks* test_hooks_; - virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE { - ThreadProxy::ScheduledActionBeginOutputSurfaceCreation(); - test_hooks_->ScheduledActionBeginOutputSurfaceCreation(); - } - virtual void ScheduledActionSendBeginMainFrame() OVERRIDE { test_hooks_->ScheduledActionWillSendBeginMainFrame(); ThreadProxy::ScheduledActionSendBeginMainFrame(); test_hooks_->ScheduledActionSendBeginMainFrame(); } + virtual DrawResult ScheduledActionDrawAndSwapIfPossible() OVERRIDE { + DrawResult result = ThreadProxy::ScheduledActionDrawAndSwapIfPossible(); + test_hooks_->ScheduledActionDrawAndSwapIfPossible(); + return result; + } + + virtual void ScheduledActionAnimate() OVERRIDE { + ThreadProxy::ScheduledActionAnimate(); + test_hooks_->ScheduledActionAnimate(); + } + virtual void ScheduledActionCommit() OVERRIDE { ThreadProxy::ScheduledActionCommit(); test_hooks_->ScheduledActionCommit(); } - virtual DrawResult ScheduledActionDrawAndSwapIfPossible() OVERRIDE { - DrawResult result = ThreadProxy::ScheduledActionDrawAndSwapIfPossible(); - test_hooks_->ScheduledActionDrawAndSwapIfPossible(); - return result; + virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE { + ThreadProxy::ScheduledActionBeginOutputSurfaceCreation(); + test_hooks_->ScheduledActionBeginOutputSurfaceCreation(); } ThreadProxyForTest( diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h index b111963919..8f38dda499 100644 --- a/cc/test/layer_tree_test.h +++ b/cc/test/layer_tree_test.h @@ -79,11 +79,12 @@ class TestHooks : public AnimationDelegate { virtual base::TimeDelta LowFrequencyAnimationInterval() const; // Hooks for SchedulerClient. - virtual void ScheduledActionBeginOutputSurfaceCreation() {} virtual void ScheduledActionWillSendBeginMainFrame() {} virtual void ScheduledActionSendBeginMainFrame() {} - virtual void ScheduledActionCommit() {} virtual void ScheduledActionDrawAndSwapIfPossible() {} + virtual void ScheduledActionAnimate() {} + virtual void ScheduledActionCommit() {} + virtual void ScheduledActionBeginOutputSurfaceCreation() {} // Implementation of AnimationDelegate: virtual void NotifyAnimationStarted(base::TimeTicks monotonic_time, diff --git a/cc/test/render_pass_test_common.cc b/cc/test/render_pass_test_common.cc index dd58b43b23..9cbb98762f 100644 --- a/cc/test/render_pass_test_common.cc +++ b/cc/test/render_pass_test_common.cc @@ -80,7 +80,8 @@ void TestRenderPass::AppendOneOfEveryQuadType( rect, false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<CheckerboardDrawQuad> checkerboard_quad = CheckerboardDrawQuad::Create(); @@ -197,7 +198,8 @@ void TestRenderPass::AppendOneOfEveryQuadType( rect, false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<TileDrawQuad> tile_quad = TileDrawQuad::Create(); tile_quad->SetNew(shared_state2, diff --git a/cc/test/render_pass_test_utils.cc b/cc/test/render_pass_test_utils.cc index 43cbf1f7c9..7ea3a7a0b1 100644 --- a/cc/test/render_pass_test_utils.cc +++ b/cc/test/render_pass_test_utils.cc @@ -37,7 +37,8 @@ SolidColorDrawQuad* AddQuad(TestRenderPass* pass, rect, false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); quad->SetNew(shared_state, rect, rect, color, false); SolidColorDrawQuad* quad_ptr = quad.get(); @@ -55,7 +56,8 @@ SolidColorDrawQuad* AddClippedQuad(TestRenderPass* pass, rect, true, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); quad->SetNew(shared_state, rect, rect, color, false); SolidColorDrawQuad* quad_ptr = quad.get(); @@ -68,8 +70,14 @@ SolidColorDrawQuad* AddTransformedQuad(TestRenderPass* pass, SkColor color, const gfx::Transform& transform) { SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); - shared_state->SetAll( - transform, rect.size(), rect, rect, false, 1, SkXfermode::kSrcOver_Mode); + shared_state->SetAll(transform, + rect.size(), + rect, + rect, + false, + 1, + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); quad->SetNew(shared_state, rect, rect, color, false); SolidColorDrawQuad* quad_ptr = quad.get(); @@ -87,7 +95,8 @@ void AddRenderPassQuad(TestRenderPass* to_pass, output_rect, false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); quad->SetNew(shared_state, output_rect, @@ -115,7 +124,8 @@ void AddRenderPassQuad(TestRenderPass* to_pass, output_rect, false, 1, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + 0); scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); quad->SetNew(shared_state, output_rect, diff --git a/cc/test/test_context_support.cc b/cc/test/test_context_support.cc index 9c34d68c7f..d5bfcd37df 100644 --- a/cc/test/test_context_support.cc +++ b/cc/test/test_context_support.cc @@ -40,9 +40,6 @@ void TestContextSupport::SetSurfaceVisible(bool visible) { } } -void TestContextSupport::SendManagedMemoryStats( - const gpu::ManagedMemoryStats& stats) {} - void TestContextSupport::CallAllSyncPointCallbacks() { for (size_t i = 0; i < sync_point_callbacks_.size(); ++i) { base::MessageLoop::current()->PostTask( diff --git a/cc/test/test_context_support.h b/cc/test/test_context_support.h index 7162b21749..adacf06b5f 100644 --- a/cc/test/test_context_support.h +++ b/cc/test/test_context_support.h @@ -23,8 +23,6 @@ class TestContextSupport : public gpu::ContextSupport { virtual void SignalQuery(uint32 query, const base::Closure& callback) OVERRIDE; virtual void SetSurfaceVisible(bool visible) OVERRIDE; - virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats) - OVERRIDE; virtual void Swap() OVERRIDE; virtual void PartialSwapBuffers(const gfx::Rect& sub_buffer) OVERRIDE; virtual void SetSwapBuffersCompleteCallback( diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index ebb51a88ce..3bbbf6340b 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -327,16 +327,16 @@ template <typename LayerType> static inline bool IsRootLayer(LayerType* layer) { template <typename LayerType> static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { - return layer->is_3d_sorted() && layer->parent() && - layer->parent()->is_3d_sorted(); + return layer->Is3dSorted() && layer->parent() && + layer->parent()->Is3dSorted(); } template <typename LayerType> static bool IsRootLayerOfNewRenderingContext(LayerType* layer) { if (layer->parent()) - return !layer->parent()->is_3d_sorted() && layer->is_3d_sorted(); + return !layer->parent()->Is3dSorted() && layer->Is3dSorted(); - return layer->is_3d_sorted(); + return layer->Is3dSorted(); } template <typename LayerType> @@ -2365,7 +2365,7 @@ static void CalculateDrawPropertiesInternal( // drawn from back to front. If the preserves-3d property is also set on the // parent then skip the sorting as the parent will sort all the descendants // anyway. - if (globals.layer_sorter && descendants.size() && layer->is_3d_sorted() && + if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() && !LayerIsInExisting3DRenderingContext(layer)) { SortLayers(descendants.begin() + sorting_start_index, descendants.end(), diff --git a/cc/trees/layer_tree_host_common_perftest.cc b/cc/trees/layer_tree_host_common_perftest.cc index eb80c63a3f..02b0770495 100644 --- a/cc/trees/layer_tree_host_common_perftest.cc +++ b/cc/trees/layer_tree_host_common_perftest.cc @@ -193,7 +193,7 @@ class LayerSorterMainTest : public CalcDrawPropsImplTest { } void BuildLayerImplList(LayerImpl* layer, LayerImplList* list) { - if (layer->is_3d_sorted()) { + if (layer->Is3dSorted()) { list->push_back(layer); } diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 2186c20bdd..8dcb6d7ad1 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -4000,8 +4000,8 @@ TEST_F(LayerTreeHostCommonTest, true, false); - front_facing_surface->SetIs3dSorted(true); - back_facing_surface->SetIs3dSorted(true); + front_facing_surface->Set3dSortingContextId(1); + back_facing_surface->Set3dSortingContextId(1); RenderSurfaceLayerList render_surface_layer_list; LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( @@ -6976,8 +6976,8 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { false); child3->SetDrawsContent(true); - child2->SetIs3dSorted(true); - child3->SetIs3dSorted(true); + child2->Set3dSortingContextId(1); + child3->Set3dSortingContextId(1); child2->AddChild(child3.Pass()); child1->AddChild(child2.Pass()); @@ -7037,7 +7037,7 @@ TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { false); root->SetShouldFlattenTransform(false); - root->SetIs3dSorted(true); + root->Set3dSortingContextId(1); render_surface->SetDoubleSided(false); render_surface->SetForceRenderSurface(true); @@ -7665,7 +7665,7 @@ TEST_F(LayerTreeHostCommonTest, DoNotClobberSorting) { true); scroll_child->SetShouldFlattenTransform(false); - scroll_child->SetIs3dSorted(true); + scroll_child->Set3dSortingContextId(1); scroll_child->AddChild(top_content.Pass()); scroll_child->AddChild(bottom_content.Pass()); diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 53c2f0d2ce..c3ea500050 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -240,9 +240,6 @@ LayerTreeHostImpl::LayerTreeHostImpl( proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() : proxy_->MainThreadTaskRunner())), max_memory_needed_bytes_(0), - last_sent_memory_visible_bytes_(0), - last_sent_memory_visible_and_nearby_bytes_(0), - last_sent_memory_use_bytes_(0), zero_budget_(false), device_scale_factor_(1.f), overhang_ui_resource_id_(0), @@ -350,8 +347,6 @@ void LayerTreeHostImpl::CommitComplete() { DCHECK(active_tree_->root_layer()); } - client_->SendManagedMemoryStats(); - micro_benchmark_controller_.DidCompleteCommit(); } @@ -425,18 +420,6 @@ void LayerTreeHostImpl::ManageTiles() { tile_priorities_dirty_ = false; tile_manager_->ManageTiles(global_tile_state_); - size_t memory_required_bytes; - size_t memory_nice_to_have_bytes; - size_t memory_allocated_bytes; - size_t memory_used_bytes; - tile_manager_->GetMemoryStats(&memory_required_bytes, - &memory_nice_to_have_bytes, - &memory_allocated_bytes, - &memory_used_bytes); - SendManagedMemoryStats(memory_required_bytes, - memory_nice_to_have_bytes, - memory_used_bytes); - client_->DidManageTiles(); } @@ -651,6 +634,7 @@ static void AppendQuadsToFillScreen( gfx::Rect root_target_rect = root_layer->render_surface()->content_rect(); float opacity = 1.f; + int sorting_context_id = 0; SharedQuadState* shared_quad_state = quad_culler.CreateSharedQuadState(); shared_quad_state->SetAll(gfx::Transform(), root_target_rect.size(), @@ -658,7 +642,8 @@ static void AppendQuadsToFillScreen( root_target_rect, false, opacity, - SkXfermode::kSrcOver_Mode); + SkXfermode::kSrcOver_Mode, + sorting_context_id); for (Region::Iterator fill_rects(screen_background_color_region); fill_rects.has_rect(); @@ -1174,7 +1159,6 @@ void LayerTreeHostImpl::EnforceManagedMemoryPolicy( client_->OnCanDrawStateChanged(CanDraw()); client_->RenewTreePriority(); } - client_->SendManagedMemoryStats(); UpdateTileManagerMemoryPolicy(policy); } @@ -2902,35 +2886,6 @@ int LayerTreeHostImpl::SourceAnimationFrameNumber() const { return fps_counter_->current_frame_number(); } -void LayerTreeHostImpl::SendManagedMemoryStats( - size_t memory_visible_bytes, - size_t memory_visible_and_nearby_bytes, - size_t memory_use_bytes) { - if (!renderer_) - return; - - // Round the numbers being sent up to the next 8MB, to throttle the rate - // at which we spam the GPU process. - static const size_t rounding_step = 8 * 1024 * 1024; - memory_visible_bytes = RoundUp(memory_visible_bytes, rounding_step); - memory_visible_and_nearby_bytes = RoundUp(memory_visible_and_nearby_bytes, - rounding_step); - memory_use_bytes = RoundUp(memory_use_bytes, rounding_step); - if (last_sent_memory_visible_bytes_ == memory_visible_bytes && - last_sent_memory_visible_and_nearby_bytes_ == - memory_visible_and_nearby_bytes && - last_sent_memory_use_bytes_ == memory_use_bytes) { - return; - } - last_sent_memory_visible_bytes_ = memory_visible_bytes; - last_sent_memory_visible_and_nearby_bytes_ = memory_visible_and_nearby_bytes; - last_sent_memory_use_bytes_ = memory_use_bytes; - - renderer_->SendManagedMemoryStats(last_sent_memory_visible_bytes_, - last_sent_memory_visible_and_nearby_bytes_, - last_sent_memory_use_bytes_); -} - void LayerTreeHostImpl::AnimateScrollbars(base::TimeTicks time) { AnimateScrollbarsRecursive(active_tree_->root_layer(), time); } diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index db9c325849..3d8a9a29e0 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -89,7 +89,6 @@ class LayerTreeHostImplClient { virtual bool ReduceContentsTextureMemoryOnImplThread( size_t limit_bytes, int priority_cutoff) = 0; - virtual void SendManagedMemoryStats() = 0; virtual bool IsInsideDraw() = 0; virtual void RenewTreePriority() = 0; virtual void PostDelayedScrollbarFadeOnImplThread( @@ -353,11 +352,6 @@ class CC_EXPORT LayerTreeHostImpl return !animation_registrar_->active_animation_controllers().empty(); } - void SendManagedMemoryStats( - size_t memory_visible_bytes, - size_t memory_visible_and_nearby_bytes, - size_t memory_use_bytes); - void set_max_memory_needed_bytes(size_t bytes) { max_memory_needed_bytes_ = bytes; } @@ -632,9 +626,6 @@ class CC_EXPORT LayerTreeHostImpl // manager, if there were no limit on memory usage. size_t max_memory_needed_bytes_; - size_t last_sent_memory_visible_bytes_; - size_t last_sent_memory_visible_and_nearby_bytes_; - size_t last_sent_memory_use_bytes_; bool zero_budget_; // Viewport size passed in from the main thread, in physical pixels. This diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 600ace79e4..f415c51afe 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -152,7 +152,6 @@ class LayerTreeHostImplTest : public testing::Test, current_priority_cutoff_value_ = priority_cutoff; return reduce_memory_result_; } - virtual void SendManagedMemoryStats() OVERRIDE {} virtual bool IsInsideDraw() OVERRIDE { return false; } virtual void RenewTreePriority() OVERRIDE {} virtual void PostDelayedScrollbarFadeOnImplThread( @@ -6574,61 +6573,5 @@ TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) { 150u * 1024u * 1024u); } -TEST_F(LayerTreeHostImplTest, UpdateTilesForMasksWithNoVisibleContent) { - gfx::Size bounds(100000, 100); - - host_impl_->CreatePendingTree(); - - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->pending_tree(), 1); - - scoped_ptr<FakePictureLayerImpl> layer_with_mask = - FakePictureLayerImpl::Create(host_impl_->pending_tree(), 2); - - layer_with_mask->SetBounds(bounds); - layer_with_mask->SetContentBounds(bounds); - - scoped_ptr<FakePictureLayerImpl> mask = - FakePictureLayerImpl::Create(host_impl_->pending_tree(), 3); - - mask->SetIsMask(true); - mask->SetBounds(bounds); - mask->SetContentBounds(bounds); - - FakePictureLayerImpl* pending_mask_content = mask.get(); - layer_with_mask->SetMaskLayer(mask.PassAs<LayerImpl>()); - - scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask = - FakePictureLayerImpl::Create(host_impl_->pending_tree(), 4); - - child_of_layer_with_mask->SetBounds(bounds); - child_of_layer_with_mask->SetContentBounds(bounds); - child_of_layer_with_mask->SetDrawsContent(true); - - layer_with_mask->AddChild(child_of_layer_with_mask.PassAs<LayerImpl>()); - - root->AddChild(layer_with_mask.PassAs<LayerImpl>()); - - host_impl_->pending_tree()->SetRootLayer(root.Pass()); - - gfx::Rect r1 = pending_mask_content->visible_rect_for_tile_priority(); - ASSERT_EQ(0, r1.x()); - ASSERT_EQ(0, r1.y()); - ASSERT_EQ(0, r1.width()); - ASSERT_EQ(0, r1.height()); - - host_impl_->ActivatePendingTree(); - - host_impl_->active_tree()->UpdateDrawProperties(); - - ASSERT_EQ(2u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); - - FakePictureLayerImpl* active_mask_content = - static_cast<FakePictureLayerImpl*>( - host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); - gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); - - ASSERT_TRUE(!r2.IsEmpty()); -} - } // namespace } // namespace cc diff --git a/cc/trees/layer_tree_host_pixeltest_filters.cc b/cc/trees/layer_tree_host_pixeltest_filters.cc index 2337611ab9..c8c8c7adf3 100644 --- a/cc/trees/layer_tree_host_pixeltest_filters.cc +++ b/cc/trees/layer_tree_host_pixeltest_filters.cc @@ -111,17 +111,17 @@ TEST_F(LayerTreeHostFiltersPixelTest, BackgroundFilterBlurOffAxis) { background->AddChild(blur); background->SetShouldFlattenTransform(false); - background->SetIs3dSorted(true); + background->Set3dSortingContextId(1); green->SetShouldFlattenTransform(false); - green->SetIs3dSorted(true); + green->Set3dSortingContextId(1); gfx::Transform background_transform; background_transform.ApplyPerspectiveDepth(200.0); background->SetTransform(background_transform); blur->SetShouldFlattenTransform(false); - blur->SetIs3dSorted(true); + blur->Set3dSortingContextId(1); for (size_t i = 0; i < blur->children().size(); ++i) - blur->children()[i]->SetIs3dSorted(true); + blur->children()[i]->Set3dSortingContextId(1); gfx::Transform blur_transform; blur_transform.Translate(55.0, 65.0); diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 2a38d89abd..d5ec804eaa 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -497,15 +497,15 @@ bool LayerTreeImpl::UpdateDrawProperties() { ++it) { LayerImpl* layer = *it; if (it.represents_itself()) - layer->UpdateTilePriorities(); + layer->UpdateTiles(); if (!it.represents_contributing_render_surface()) continue; if (layer->mask_layer()) - layer->mask_layer()->UpdateTilePriorities(); + layer->mask_layer()->UpdateTiles(); if (layer->replica_layer() && layer->replica_layer()->mask_layer()) - layer->replica_layer()->mask_layer()->UpdateTilePriorities(); + layer->replica_layer()->mask_layer()->UpdateTiles(); } } diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc index 91bad3ee7e..006fc35997 100644 --- a/cc/trees/layer_tree_impl_unittest.cc +++ b/cc/trees/layer_tree_impl_unittest.cc @@ -983,7 +983,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { false); root->SetDrawsContent(true); root->SetShouldFlattenTransform(false); - root->SetIs3dSorted(true); + root->Set3dSortingContextId(1); { // child 1 and child2 are initialized to overlap between x=50 and x=60. // grand_child is set to overlap both child1 and child2 between y=50 and @@ -1009,7 +1009,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { false); child1->SetDrawsContent(true); child1->SetShouldFlattenTransform(false); - child1->SetIs3dSorted(true); + child1->Set3dSortingContextId(1); position = gfx::PointF(50.f, 10.f); bounds = gfx::Size(50, 50); @@ -1024,7 +1024,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { false); child2->SetDrawsContent(true); child2->SetShouldFlattenTransform(false); - child2->SetIs3dSorted(true); + child2->Set3dSortingContextId(1); // Remember that grand_child is positioned with respect to its parent (i.e. // child1). In screen space, the intended position is (10, 50), with size diff --git a/cc/trees/occlusion_tracker.cc b/cc/trees/occlusion_tracker.cc index b549f89983..f4a414f6de 100644 --- a/cc/trees/occlusion_tracker.cc +++ b/cc/trees/occlusion_tracker.cc @@ -131,7 +131,7 @@ static inline bool SurfaceTransformsToScreenKnown(const RenderSurfaceImpl* rs) { } static inline bool LayerIsInUnsorted3dRenderingContext(const Layer* layer) { - return layer->is_3d_sorted(); + return layer->Is3dSorted(); } static inline bool LayerIsInUnsorted3dRenderingContext(const LayerImpl* layer) { return false; diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc index 89165b8d6f..1a6529bc55 100644 --- a/cc/trees/occlusion_tracker_unittest.cc +++ b/cc/trees/occlusion_tracker_unittest.cc @@ -1903,9 +1903,9 @@ class OcclusionTrackerTestUnsorted3dLayers gfx::Size(100, 100), true); parent->SetShouldFlattenTransform(false); - parent->SetIs3dSorted(true); - child1->SetIs3dSorted(true); - child2->SetIs3dSorted(true); + parent->Set3dSortingContextId(1); + child1->Set3dSortingContextId(1); + child2->Set3dSortingContextId(1); this->CalcDrawEtc(parent); @@ -1949,8 +1949,8 @@ class OcclusionTrackerTestPerspectiveTransform gfx::Size(200, 200), true); container->SetShouldFlattenTransform(false); - container->SetIs3dSorted(true); - layer->SetIs3dSorted(true); + container->Set3dSortingContextId(1); + layer->Set3dSortingContextId(1); layer->SetShouldFlattenTransform(false); this->CalcDrawEtc(parent); @@ -1994,9 +1994,9 @@ class OcclusionTrackerTestPerspectiveTransformBehindCamera typename Types::ContentLayerType* layer = this->CreateDrawingLayer( container, transform, gfx::PointF(), gfx::Size(500, 500), true); container->SetShouldFlattenTransform(false); - container->SetIs3dSorted(true); + container->Set3dSortingContextId(1); layer->SetShouldFlattenTransform(false); - layer->SetIs3dSorted(true); + layer->Set3dSortingContextId(1); this->CalcDrawEtc(parent); TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( @@ -2037,9 +2037,9 @@ class OcclusionTrackerTestLayerBehindCameraDoesNotOcclude typename Types::ContentLayerType* layer = this->CreateDrawingLayer( parent, transform, gfx::PointF(), gfx::Size(100, 100), true); parent->SetShouldFlattenTransform(false); - parent->SetIs3dSorted(true); + parent->Set3dSortingContextId(1); layer->SetShouldFlattenTransform(false); - layer->SetIs3dSorted(true); + layer->Set3dSortingContextId(1); this->CalcDrawEtc(parent); TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( @@ -2078,9 +2078,9 @@ class OcclusionTrackerTestLargePixelsOccludeInsideClipRect typename Types::ContentLayerType* layer = this->CreateDrawingLayer( parent, transform, gfx::PointF(), gfx::Size(100, 100), true); parent->SetShouldFlattenTransform(false); - parent->SetIs3dSorted(true); + parent->Set3dSortingContextId(1); layer->SetShouldFlattenTransform(false); - layer->SetIs3dSorted(true); + layer->Set3dSortingContextId(1); this->CalcDrawEtc(parent); TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index 157ecbeeb5..c254311a93 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -297,21 +297,6 @@ bool SingleThreadProxy::ReduceContentsTextureMemoryOnImplThread( limit_bytes, priority_cutoff, resource_provider); } -void SingleThreadProxy::SendManagedMemoryStats() { - DCHECK(Proxy::IsImplThread()); - if (!layer_tree_host_impl_) - return; - PrioritizedResourceManager* contents_texture_manager = - layer_tree_host_->contents_texture_manager(); - if (!contents_texture_manager) - return; - - layer_tree_host_impl_->SendManagedMemoryStats( - contents_texture_manager->MemoryVisibleBytes(), - contents_texture_manager->MemoryVisibleAndNearbyBytes(), - contents_texture_manager->MemoryUseBytes()); -} - bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() { diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index 5de42b5d44..7ad48b48be 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -74,7 +74,6 @@ class CC_EXPORT SingleThreadProxy : public Proxy, virtual bool ReduceContentsTextureMemoryOnImplThread( size_t limit_bytes, int priority_cutoff) OVERRIDE; - virtual void SendManagedMemoryStats() OVERRIDE; virtual bool IsInsideDraw() OVERRIDE; virtual void RenewTreePriority() OVERRIDE {} virtual void PostDelayedScrollbarFadeOnImplThread( diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index 1eed641f22..e16adb9a55 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -434,25 +434,6 @@ bool ThreadProxy::ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, return true; } -void ThreadProxy::SendManagedMemoryStats() { - DCHECK(IsImplThread()); - if (!impl().layer_tree_host_impl) - return; - if (!impl().contents_texture_manager) - return; - - // If we are using impl-side painting, then SendManagedMemoryStats is called - // directly after the tile manager's manage function, and doesn't need to - // interact with main thread's layer tree. - if (impl().layer_tree_host_impl->settings().impl_side_painting) - return; - - impl().layer_tree_host_impl->SendManagedMemoryStats( - impl().contents_texture_manager->MemoryVisibleBytes(), - impl().contents_texture_manager->MemoryVisibleAndNearbyBytes(), - impl().contents_texture_manager->MemoryUseBytes()); -} - bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; } void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index 4734778c8d..8d4348e490 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -198,7 +198,6 @@ class CC_EXPORT ThreadProxy : public Proxy, virtual bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, int priority_cutoff) OVERRIDE; - virtual void SendManagedMemoryStats() OVERRIDE; virtual bool IsInsideDraw() OVERRIDE; virtual void RenewTreePriority() OVERRIDE; virtual void PostDelayedScrollbarFadeOnImplThread( |