diff options
author | Torne (Richard Coles) <torne@google.com> | 2014-06-20 14:52:04 +0100 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2014-06-20 14:52:04 +0100 |
commit | f8ee788a64d60abd8f2d742a5fdedde054ecd910 (patch) | |
tree | 7dc14380200b953c64e0ccd16435cdbd1dbf1205 /cc | |
parent | fcbbbe23a38088a52492922075e71a419c4b01ec (diff) | |
download | chromium_org-f8ee788a64d60abd8f2d742a5fdedde054ecd910.tar.gz |
Merge from Chromium at DEPS revision 278205
This commit was generated by merge_to_master.py.
Change-Id: I23f1e7ea8c154ba72e7fb594436216f861f868ab
Diffstat (limited to 'cc')
150 files changed, 3419 insertions, 2334 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn index fef36f1eb1..1a1e7366fa 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn @@ -37,6 +37,8 @@ component("cc") { "animation/transform_operations.cc", "animation/transform_operations.h", "base/completion_event.h", + "base/delayed_unique_notifier.cc", + "base/delayed_unique_notifier.h", "base/invalidation_region.cc", "base/invalidation_region.h", "base/latency_info_swap_promise.cc", @@ -60,6 +62,8 @@ component("cc") { "base/switches.h", "base/tiling_data.cc", "base/tiling_data.h", + "base/unique_notifier.cc", + "base/unique_notifier.h", "base/util.h", "debug/benchmark_instrumentation.cc", "debug/benchmark_instrumentation.h", @@ -71,6 +75,8 @@ component("cc") { "debug/frame_rate_counter.cc", "debug/frame_rate_counter.h", "debug/frame_viewer_instrumentation.h", + "debug/invalidation_benchmark.cc", + "debug/invalidation_benchmark.h", "debug/lap_timer.cc", "debug/lap_timer.h", "debug/layer_tree_debug_state.cc", @@ -165,6 +171,7 @@ component("cc") { "layers/picture_layer_impl.cc", "layers/picture_layer_impl.h", "layers/quad_sink.h", + "layers/quad_sink.cc", "layers/render_pass_sink.h", "layers/render_surface.cc", "layers/render_surface.h", @@ -430,8 +437,6 @@ component("cc") { "trees/proxy.h", "trees/proxy_timing_history.cc", "trees/proxy_timing_history.h", - "trees/quad_culler.cc", - "trees/quad_culler.h", "trees/single_thread_proxy.cc", "trees/single_thread_proxy.h", "trees/thread_proxy.cc", @@ -562,8 +567,11 @@ source_set("test_support") { "test/layer_tree_pixel_test.h", "test/layer_tree_test.cc", "test/layer_tree_test.h", + "test/mock_occlusion_tracker.h", "test/mock_quad_culler.cc", "test/mock_quad_culler.h", + "test/ordered_simple_task_runner.cc", + "test/ordered_simple_task_runner.h", "test/ordered_texture_map.cc", "test/ordered_texture_map.h", "test/paths.cc", @@ -1,5 +1,4 @@ include_rules = [ - "-cc/surfaces", # cc shouldn't depend directly on the surface implementation "+gpu/GLES2", "+gpu/command_buffer/client/context_support.h", "+gpu/command_buffer/client/gles2_interface.h", diff --git a/cc/PRESUBMIT.py b/cc/PRESUBMIT.py index 6a7f921196..3397313bd9 100644 --- a/cc/PRESUBMIT.py +++ b/cc/PRESUBMIT.py @@ -149,6 +149,19 @@ def FindUnquotedQuote(contents, pos): match = re.search(r"(?<!\\)(?P<quote>\")", contents[pos:]) return -1 if not match else match.start("quote") + pos +def FindUselessIfdefs(input_api, output_api): + errors = [] + source_file_filter = lambda x: x + for f in input_api.AffectedSourceFiles(source_file_filter): + contents = input_api.ReadFile(f, 'rb') + if re.search(r'#if\s*0\s', contents): + errors.append(f.LocalPath()) + if errors: + return [output_api.PresubmitError( + 'Don\'t use #if '+'0; just delete the code.', + items=errors)] + return [] + def FindNamespaceInBlock(pos, namespace, contents, whitelist=[]): open_brace = -1 close_brace = -1 @@ -274,6 +287,7 @@ def CheckChangeOnUpload(input_api, output_api): results += CheckTodos(input_api, output_api) results += CheckNamespace(input_api, output_api) results += CheckForUseOfWrongClock(input_api, output_api) + results += FindUselessIfdefs(input_api, output_api) results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api) return results diff --git a/cc/base/tiling_data.cc b/cc/base/tiling_data.cc index a52c940767..185bbed401 100644 --- a/cc/base/tiling_data.cc +++ b/cc/base/tiling_data.cc @@ -139,20 +139,32 @@ int TilingData::LastBorderTileYIndexFromSrcCoord(int src_position) const { } gfx::Rect TilingData::ExpandRectToTileBoundsWithBorders( - const gfx::Rect rect) const { + const gfx::Rect& rect) const { if (!rect.Intersects(tiling_rect_) || has_empty_bounds()) return gfx::Rect(); int index_x = FirstBorderTileXIndexFromSrcCoord(rect.x()); int index_y = FirstBorderTileYIndexFromSrcCoord(rect.y()); - int index_right = LastBorderTileXIndexFromSrcCoord(rect.right()); - int index_bottom = LastBorderTileYIndexFromSrcCoord(rect.bottom()); + int index_right = LastBorderTileXIndexFromSrcCoord(rect.right() - 1); + int index_bottom = LastBorderTileYIndexFromSrcCoord(rect.bottom() - 1); gfx::Rect rect_top_left(TileBoundsWithBorder(index_x, index_y)); gfx::Rect rect_bottom_right(TileBoundsWithBorder(index_right, index_bottom)); - gfx::Rect expanded(rect_top_left); - expanded.Union(rect_bottom_right); - return expanded; + return gfx::UnionRects(rect_top_left, rect_bottom_right); +} + +gfx::Rect TilingData::ExpandRectToTileBounds(const gfx::Rect& rect) const { + if (!rect.Intersects(tiling_rect_) || has_empty_bounds()) + return gfx::Rect(); + int index_x = FirstBorderTileXIndexFromSrcCoord(rect.x()); + int index_y = FirstBorderTileYIndexFromSrcCoord(rect.y()); + int index_right = LastBorderTileXIndexFromSrcCoord(rect.right() - 1); + int index_bottom = LastBorderTileYIndexFromSrcCoord(rect.bottom() - 1); + + gfx::Rect rect_top_left(TileBounds(index_x, index_y)); + gfx::Rect rect_bottom_right(TileBounds(index_right, index_bottom)); + + return gfx::UnionRects(rect_top_left, rect_bottom_right); } gfx::Rect TilingData::TileBounds(int i, int j) const { diff --git a/cc/base/tiling_data.h b/cc/base/tiling_data.h index 3059c21b7a..8550e5f186 100644 --- a/cc/base/tiling_data.h +++ b/cc/base/tiling_data.h @@ -52,7 +52,8 @@ class CC_EXPORT TilingData { int LastBorderTileXIndexFromSrcCoord(int src_position) const; int LastBorderTileYIndexFromSrcCoord(int src_position) const; - gfx::Rect ExpandRectToTileBoundsWithBorders(const gfx::Rect rect) const; + gfx::Rect ExpandRectToTileBoundsWithBorders(const gfx::Rect& rect) const; + gfx::Rect ExpandRectToTileBounds(const gfx::Rect& rect) const; gfx::Rect TileBounds(int i, int j) const; gfx::Rect TileBoundsWithBorder(int i, int j) const; diff --git a/cc/base/tiling_data_unittest.cc b/cc/base/tiling_data_unittest.cc index fd0809d1f7..84d9e79dc7 100644 --- a/cc/base/tiling_data_unittest.cc +++ b/cc/base/tiling_data_unittest.cc @@ -2202,6 +2202,66 @@ TEST_P(TilingDataTest, ExpandRectToTileBoundsWithBorders) { EXPECT_FALSE(non_intersect.Intersects(data.tiling_rect())); EXPECT_RECT_EQ(gfx::Rect(), data.ExpandRectToTileBoundsWithBorders(non_intersect)); + + TilingData data2(gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(32, 64)), true); + + // Inside other tile border texels doesn't include other tiles. + gfx::Rect inner_rect_src(data2.TileBounds(1, 1)); + inner_rect_src.Inset(data2.border_texels(), data.border_texels()); + gfx::Rect inner_rect_result(data2.TileBoundsWithBorder(1, 1)); + gfx::Rect expanded = data2.ExpandRectToTileBoundsWithBorders(inner_rect_src); + EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString()); +} + +TEST_P(TilingDataTest, ExpandRectToTileBounds) { + gfx::Point origin = GetParam(); + TilingData data(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(16, 32)), true); + + // Small rect at origin rounds up to tile 0, 0. + gfx::Rect at_origin_src(origin, gfx::Size(1, 1)); + gfx::Rect at_origin_result(data.TileBounds(0, 0)); + EXPECT_NE(at_origin_src, at_origin_result); + EXPECT_RECT_EQ(at_origin_result, data.ExpandRectToTileBounds(at_origin_src)); + + // Arbitrary internal rect. + gfx::Rect rect_src(origin.x() + 6, origin.y() + 6, 1, 3); + // Tile 2, 2 => gfx::Rect(4, 4, 4, 4) + // Tile 3, 4 => gfx::Rect(6, 8, 4, 4) + gfx::Rect rect_result( + gfx::UnionRects(data.TileBounds(2, 2), data.TileBounds(3, 4))); + EXPECT_NE(rect_src, rect_result); + EXPECT_RECT_EQ(rect_result, data.ExpandRectToTileBounds(rect_src)); + + // On tile bounds rounds up to next tile (since border overlaps). + gfx::Rect border_rect_src( + gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4))); + gfx::Rect border_rect_result( + gfx::UnionRects(data.TileBounds(0, 1), data.TileBounds(4, 5))); + EXPECT_RECT_EQ(border_rect_result, + data.ExpandRectToTileBounds(border_rect_src)); + + // Equal to tiling rect. + EXPECT_RECT_EQ(data.tiling_rect(), + data.ExpandRectToTileBounds(data.tiling_rect())); + + // Containing, but larger than tiling rect. + EXPECT_RECT_EQ( + data.tiling_rect(), + data.ExpandRectToTileBounds(gfx::Rect(origin, gfx::Size(100, 100)))); + + // Non-intersecting with tiling rect. + gfx::Rect non_intersect(origin.x() + 200, origin.y() + 200, 100, 100); + EXPECT_FALSE(non_intersect.Intersects(data.tiling_rect())); + EXPECT_RECT_EQ(gfx::Rect(), data.ExpandRectToTileBounds(non_intersect)); + + TilingData data2(gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(32, 64)), true); + + // Inside other tile border texels doesn't include other tiles. + gfx::Rect inner_rect_src(data2.TileBounds(1, 1)); + inner_rect_src.Inset(data2.border_texels(), data.border_texels()); + gfx::Rect inner_rect_result(data2.TileBounds(1, 1)); + gfx::Rect expanded = data2.ExpandRectToTileBounds(inner_rect_src); + EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString()); } TEST_P(TilingDataTest, Assignment) { @@ -198,6 +198,7 @@ 'layers/picture_layer_impl.cc', 'layers/picture_layer_impl.h', 'layers/quad_sink.h', + 'layers/quad_sink.cc', 'layers/render_pass_sink.h', 'layers/render_surface.cc', 'layers/render_surface.h', @@ -439,7 +440,6 @@ 'scheduler/scheduler_settings.h', 'scheduler/scheduler_state_machine.cc', 'scheduler/scheduler_state_machine.h', - 'scheduler/time_source.h', 'trees/blocking_task_runner.cc', 'trees/blocking_task_runner.h', 'trees/damage_tracker.cc', @@ -463,8 +463,6 @@ 'trees/proxy.h', 'trees/proxy_timing_history.cc', 'trees/proxy_timing_history.h', - 'trees/quad_culler.cc', - 'trees/quad_culler.h', 'trees/single_thread_proxy.cc', 'trees/single_thread_proxy.h', 'trees/thread_proxy.cc', @@ -495,6 +493,7 @@ 'surfaces/display_client.h', 'surfaces/surface.cc', 'surfaces/surface.h', + 'surfaces/surface_id.h', 'surfaces/surface_aggregator.cc', 'surfaces/surface_aggregator.h', 'surfaces/surface_client.h', diff --git a/cc/cc.target.darwin-arm.mk b/cc/cc.target.darwin-arm.mk index ee9dccdcc5..cf8d707865 100644 --- a/cc/cc.target.darwin-arm.mk +++ b/cc/cc.target.darwin-arm.mk @@ -100,6 +100,7 @@ LOCAL_SRC_FILES := \ cc/layers/picture_image_layer_impl.cc \ cc/layers/picture_layer.cc \ cc/layers/picture_layer_impl.cc \ + cc/layers/quad_sink.cc \ cc/layers/render_surface.cc \ cc/layers/render_surface_impl.cc \ cc/layers/scrollbar_layer_impl_base.cc \ @@ -225,7 +226,6 @@ LOCAL_SRC_FILES := \ cc/trees/occlusion_tracker.cc \ cc/trees/proxy.cc \ cc/trees/proxy_timing_history.cc \ - cc/trees/quad_culler.cc \ cc/trees/single_thread_proxy.cc \ cc/trees/thread_proxy.cc \ cc/trees/tree_synchronizer.cc @@ -282,6 +282,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -304,11 +305,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -334,6 +335,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -420,6 +422,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -442,11 +445,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -473,6 +476,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc.target.darwin-arm64.mk b/cc/cc.target.darwin-arm64.mk index b1c2fb000a..cf3a19c04a 100644 --- a/cc/cc.target.darwin-arm64.mk +++ b/cc/cc.target.darwin-arm64.mk @@ -100,6 +100,7 @@ LOCAL_SRC_FILES := \ cc/layers/picture_image_layer_impl.cc \ cc/layers/picture_layer.cc \ cc/layers/picture_layer_impl.cc \ + cc/layers/quad_sink.cc \ cc/layers/render_surface.cc \ cc/layers/render_surface_impl.cc \ cc/layers/scrollbar_layer_impl_base.cc \ @@ -225,7 +226,6 @@ LOCAL_SRC_FILES := \ cc/trees/occlusion_tracker.cc \ cc/trees/proxy.cc \ cc/trees/proxy_timing_history.cc \ - cc/trees/quad_culler.cc \ cc/trees/single_thread_proxy.cc \ cc/trees/thread_proxy.cc \ cc/trees/tree_synchronizer.cc @@ -272,6 +272,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -294,11 +295,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -324,6 +325,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -399,6 +401,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -421,11 +424,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -452,6 +455,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc.target.darwin-mips.mk b/cc/cc.target.darwin-mips.mk index 15673102b1..f5cf3eff2c 100644 --- a/cc/cc.target.darwin-mips.mk +++ b/cc/cc.target.darwin-mips.mk @@ -100,6 +100,7 @@ LOCAL_SRC_FILES := \ cc/layers/picture_image_layer_impl.cc \ cc/layers/picture_layer.cc \ cc/layers/picture_layer_impl.cc \ + cc/layers/quad_sink.cc \ cc/layers/render_surface.cc \ cc/layers/render_surface_impl.cc \ cc/layers/scrollbar_layer_impl_base.cc \ @@ -225,7 +226,6 @@ LOCAL_SRC_FILES := \ cc/trees/occlusion_tracker.cc \ cc/trees/proxy.cc \ cc/trees/proxy_timing_history.cc \ - cc/trees/quad_culler.cc \ cc/trees/single_thread_proxy.cc \ cc/trees/thread_proxy.cc \ cc/trees/tree_synchronizer.cc @@ -276,6 +276,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -298,11 +299,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -328,6 +329,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -408,6 +410,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -430,11 +433,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -461,6 +464,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc.target.darwin-x86.mk b/cc/cc.target.darwin-x86.mk index 05eccdb38a..00925e6276 100644 --- a/cc/cc.target.darwin-x86.mk +++ b/cc/cc.target.darwin-x86.mk @@ -100,6 +100,7 @@ LOCAL_SRC_FILES := \ cc/layers/picture_image_layer_impl.cc \ cc/layers/picture_layer.cc \ cc/layers/picture_layer_impl.cc \ + cc/layers/quad_sink.cc \ cc/layers/render_surface.cc \ cc/layers/render_surface_impl.cc \ cc/layers/scrollbar_layer_impl_base.cc \ @@ -225,7 +226,6 @@ LOCAL_SRC_FILES := \ cc/trees/occlusion_tracker.cc \ cc/trees/proxy.cc \ cc/trees/proxy_timing_history.cc \ - cc/trees/quad_culler.cc \ cc/trees/single_thread_proxy.cc \ cc/trees/thread_proxy.cc \ cc/trees/tree_synchronizer.cc @@ -277,6 +277,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -299,11 +300,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -329,6 +330,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -409,6 +411,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -431,11 +434,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -462,6 +465,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc.target.darwin-x86_64.mk b/cc/cc.target.darwin-x86_64.mk index 1860a01f28..1d32942d47 100644 --- a/cc/cc.target.darwin-x86_64.mk +++ b/cc/cc.target.darwin-x86_64.mk @@ -100,6 +100,7 @@ LOCAL_SRC_FILES := \ cc/layers/picture_image_layer_impl.cc \ cc/layers/picture_layer.cc \ cc/layers/picture_layer_impl.cc \ + cc/layers/quad_sink.cc \ cc/layers/render_surface.cc \ cc/layers/render_surface_impl.cc \ cc/layers/scrollbar_layer_impl_base.cc \ @@ -225,7 +226,6 @@ LOCAL_SRC_FILES := \ cc/trees/occlusion_tracker.cc \ cc/trees/proxy.cc \ cc/trees/proxy_timing_history.cc \ - cc/trees/quad_culler.cc \ cc/trees/single_thread_proxy.cc \ cc/trees/thread_proxy.cc \ cc/trees/tree_synchronizer.cc @@ -276,6 +276,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -298,11 +299,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -328,6 +329,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -407,6 +409,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -429,11 +432,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -460,6 +463,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc.target.linux-arm.mk b/cc/cc.target.linux-arm.mk index ee9dccdcc5..cf8d707865 100644 --- a/cc/cc.target.linux-arm.mk +++ b/cc/cc.target.linux-arm.mk @@ -100,6 +100,7 @@ LOCAL_SRC_FILES := \ cc/layers/picture_image_layer_impl.cc \ cc/layers/picture_layer.cc \ cc/layers/picture_layer_impl.cc \ + cc/layers/quad_sink.cc \ cc/layers/render_surface.cc \ cc/layers/render_surface_impl.cc \ cc/layers/scrollbar_layer_impl_base.cc \ @@ -225,7 +226,6 @@ LOCAL_SRC_FILES := \ cc/trees/occlusion_tracker.cc \ cc/trees/proxy.cc \ cc/trees/proxy_timing_history.cc \ - cc/trees/quad_culler.cc \ cc/trees/single_thread_proxy.cc \ cc/trees/thread_proxy.cc \ cc/trees/tree_synchronizer.cc @@ -282,6 +282,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -304,11 +305,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -334,6 +335,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -420,6 +422,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -442,11 +445,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -473,6 +476,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc.target.linux-arm64.mk b/cc/cc.target.linux-arm64.mk index b1c2fb000a..cf3a19c04a 100644 --- a/cc/cc.target.linux-arm64.mk +++ b/cc/cc.target.linux-arm64.mk @@ -100,6 +100,7 @@ LOCAL_SRC_FILES := \ cc/layers/picture_image_layer_impl.cc \ cc/layers/picture_layer.cc \ cc/layers/picture_layer_impl.cc \ + cc/layers/quad_sink.cc \ cc/layers/render_surface.cc \ cc/layers/render_surface_impl.cc \ cc/layers/scrollbar_layer_impl_base.cc \ @@ -225,7 +226,6 @@ LOCAL_SRC_FILES := \ cc/trees/occlusion_tracker.cc \ cc/trees/proxy.cc \ cc/trees/proxy_timing_history.cc \ - cc/trees/quad_culler.cc \ cc/trees/single_thread_proxy.cc \ cc/trees/thread_proxy.cc \ cc/trees/tree_synchronizer.cc @@ -272,6 +272,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -294,11 +295,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -324,6 +325,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -399,6 +401,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -421,11 +424,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -452,6 +455,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc.target.linux-mips.mk b/cc/cc.target.linux-mips.mk index 15673102b1..f5cf3eff2c 100644 --- a/cc/cc.target.linux-mips.mk +++ b/cc/cc.target.linux-mips.mk @@ -100,6 +100,7 @@ LOCAL_SRC_FILES := \ cc/layers/picture_image_layer_impl.cc \ cc/layers/picture_layer.cc \ cc/layers/picture_layer_impl.cc \ + cc/layers/quad_sink.cc \ cc/layers/render_surface.cc \ cc/layers/render_surface_impl.cc \ cc/layers/scrollbar_layer_impl_base.cc \ @@ -225,7 +226,6 @@ LOCAL_SRC_FILES := \ cc/trees/occlusion_tracker.cc \ cc/trees/proxy.cc \ cc/trees/proxy_timing_history.cc \ - cc/trees/quad_culler.cc \ cc/trees/single_thread_proxy.cc \ cc/trees/thread_proxy.cc \ cc/trees/tree_synchronizer.cc @@ -276,6 +276,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -298,11 +299,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -328,6 +329,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -408,6 +410,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -430,11 +433,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -461,6 +464,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc.target.linux-x86.mk b/cc/cc.target.linux-x86.mk index 05eccdb38a..00925e6276 100644 --- a/cc/cc.target.linux-x86.mk +++ b/cc/cc.target.linux-x86.mk @@ -100,6 +100,7 @@ LOCAL_SRC_FILES := \ cc/layers/picture_image_layer_impl.cc \ cc/layers/picture_layer.cc \ cc/layers/picture_layer_impl.cc \ + cc/layers/quad_sink.cc \ cc/layers/render_surface.cc \ cc/layers/render_surface_impl.cc \ cc/layers/scrollbar_layer_impl_base.cc \ @@ -225,7 +226,6 @@ LOCAL_SRC_FILES := \ cc/trees/occlusion_tracker.cc \ cc/trees/proxy.cc \ cc/trees/proxy_timing_history.cc \ - cc/trees/quad_culler.cc \ cc/trees/single_thread_proxy.cc \ cc/trees/thread_proxy.cc \ cc/trees/tree_synchronizer.cc @@ -277,6 +277,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -299,11 +300,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -329,6 +330,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -409,6 +411,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -431,11 +434,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -462,6 +465,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc.target.linux-x86_64.mk b/cc/cc.target.linux-x86_64.mk index 1860a01f28..1d32942d47 100644 --- a/cc/cc.target.linux-x86_64.mk +++ b/cc/cc.target.linux-x86_64.mk @@ -100,6 +100,7 @@ LOCAL_SRC_FILES := \ cc/layers/picture_image_layer_impl.cc \ cc/layers/picture_layer.cc \ cc/layers/picture_layer_impl.cc \ + cc/layers/quad_sink.cc \ cc/layers/render_surface.cc \ cc/layers/render_surface_impl.cc \ cc/layers/scrollbar_layer_impl_base.cc \ @@ -225,7 +226,6 @@ LOCAL_SRC_FILES := \ cc/trees/occlusion_tracker.cc \ cc/trees/proxy.cc \ cc/trees/proxy_timing_history.cc \ - cc/trees/quad_culler.cc \ cc/trees/single_thread_proxy.cc \ cc/trees/thread_proxy.cc \ cc/trees/tree_synchronizer.cc @@ -276,6 +276,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -298,11 +299,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -328,6 +329,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -407,6 +409,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -429,11 +432,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -460,6 +463,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc_surfaces.target.darwin-arm.mk b/cc/cc_surfaces.target.darwin-arm.mk index 63173daf1a..8460098683 100644 --- a/cc/cc_surfaces.target.darwin-arm.mk +++ b/cc/cc_surfaces.target.darwin-arm.mk @@ -83,6 +83,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -104,11 +105,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -133,6 +134,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -217,6 +219,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -238,11 +241,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -268,6 +271,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc_surfaces.target.darwin-arm64.mk b/cc/cc_surfaces.target.darwin-arm64.mk index c5191ec80e..bf3845dcf9 100644 --- a/cc/cc_surfaces.target.darwin-arm64.mk +++ b/cc/cc_surfaces.target.darwin-arm64.mk @@ -73,6 +73,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -94,11 +95,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -123,6 +124,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -196,6 +198,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -217,11 +220,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -247,6 +250,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc_surfaces.target.darwin-mips.mk b/cc/cc_surfaces.target.darwin-mips.mk index 5326eb47cf..3b5aa354fd 100644 --- a/cc/cc_surfaces.target.darwin-mips.mk +++ b/cc/cc_surfaces.target.darwin-mips.mk @@ -77,6 +77,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -98,11 +99,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -127,6 +128,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -205,6 +207,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -226,11 +229,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -256,6 +259,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc_surfaces.target.darwin-x86.mk b/cc/cc_surfaces.target.darwin-x86.mk index b81722c6a2..6709d723a2 100644 --- a/cc/cc_surfaces.target.darwin-x86.mk +++ b/cc/cc_surfaces.target.darwin-x86.mk @@ -78,6 +78,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -99,11 +100,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -128,6 +129,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -206,6 +208,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -227,11 +230,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -257,6 +260,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc_surfaces.target.darwin-x86_64.mk b/cc/cc_surfaces.target.darwin-x86_64.mk index a5974cc332..634023f743 100644 --- a/cc/cc_surfaces.target.darwin-x86_64.mk +++ b/cc/cc_surfaces.target.darwin-x86_64.mk @@ -77,6 +77,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -98,11 +99,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -127,6 +128,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -204,6 +206,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -225,11 +228,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -255,6 +258,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc_surfaces.target.linux-arm.mk b/cc/cc_surfaces.target.linux-arm.mk index 63173daf1a..8460098683 100644 --- a/cc/cc_surfaces.target.linux-arm.mk +++ b/cc/cc_surfaces.target.linux-arm.mk @@ -83,6 +83,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -104,11 +105,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -133,6 +134,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -217,6 +219,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -238,11 +241,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -268,6 +271,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc_surfaces.target.linux-arm64.mk b/cc/cc_surfaces.target.linux-arm64.mk index c5191ec80e..bf3845dcf9 100644 --- a/cc/cc_surfaces.target.linux-arm64.mk +++ b/cc/cc_surfaces.target.linux-arm64.mk @@ -73,6 +73,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -94,11 +95,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -123,6 +124,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -196,6 +198,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -217,11 +220,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -247,6 +250,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc_surfaces.target.linux-mips.mk b/cc/cc_surfaces.target.linux-mips.mk index 5326eb47cf..3b5aa354fd 100644 --- a/cc/cc_surfaces.target.linux-mips.mk +++ b/cc/cc_surfaces.target.linux-mips.mk @@ -77,6 +77,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -98,11 +99,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -127,6 +128,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -205,6 +207,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -226,11 +229,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -256,6 +259,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc_surfaces.target.linux-x86.mk b/cc/cc_surfaces.target.linux-x86.mk index b81722c6a2..6709d723a2 100644 --- a/cc/cc_surfaces.target.linux-x86.mk +++ b/cc/cc_surfaces.target.linux-x86.mk @@ -78,6 +78,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -99,11 +100,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -128,6 +129,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -206,6 +208,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -227,11 +230,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -257,6 +260,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc_surfaces.target.linux-x86_64.mk b/cc/cc_surfaces.target.linux-x86_64.mk index a5974cc332..634023f743 100644 --- a/cc/cc_surfaces.target.linux-x86_64.mk +++ b/cc/cc_surfaces.target.linux-x86_64.mk @@ -77,6 +77,7 @@ MY_DEFS_Debug := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -98,11 +99,11 @@ MY_DEFS_Debug := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -127,6 +128,7 @@ LOCAL_C_INCLUDES_Debug := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ @@ -204,6 +206,7 @@ MY_DEFS_Release := \ '-DUSE_LIBJPEG_TURBO=1' \ '-DENABLE_WEBRTC=1' \ '-DUSE_PROPRIETARY_CODECS' \ + '-DENABLE_BROWSER_CDMS' \ '-DENABLE_CONFIGURATION_POLICY' \ '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ @@ -225,11 +228,11 @@ MY_DEFS_Release := \ '-DGR_GL_IGNORE_ES3_MSAA=0' \ '-DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT' \ '-DSK_SUPPORT_LEGACY_GETTOPDEVICE' \ - '-DSK_SUPPORT_LEGACY_SETCONFIG_INFO' \ + '-DSK_SUPPORT_LEGACY_BITMAP_CONFIG' \ + '-DSK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE' \ '-DSK_SUPPORT_LEGACY_N32_NAME' \ + '-DSK_SUPPORT_LEGACY_SETCONFIG' \ '-DSK_IGNORE_ETC1_SUPPORT' \ - '-DSK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS' \ - '-DSK_SUPPORT_LEGACY_DRAWPICTURE_API' \ '-DSK_SUPPORT_LEGACY_GETTOTALCLIP' \ '-DSK_BUILD_FOR_ANDROID' \ '-DSK_USE_POSIX_THREADS' \ @@ -255,6 +258,7 @@ LOCAL_C_INCLUDES_Release := \ $(gyp_shared_intermediate_dir)/shim_headers/icuuc/target \ $(gyp_shared_intermediate_dir)/shim_headers/icui18n/target \ $(gyp_shared_intermediate_dir)/shim_headers/ashmem/target \ + $(gyp_shared_intermediate_dir) \ $(LOCAL_PATH) \ $(LOCAL_PATH)/third_party/khronos \ $(LOCAL_PATH)/gpu \ diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index 4e92c65b33..af160850bc 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -194,6 +194,7 @@ 'test/layer_tree_pixel_test.h', 'test/layer_tree_test.cc', 'test/layer_tree_test.h', + 'test/mock_occlusion_tracker.h', 'test/mock_quad_culler.cc', 'test/mock_quad_culler.h', 'test/ordered_simple_task_runner.cc', diff --git a/cc/debug/devtools_instrumentation.h b/cc/debug/devtools_instrumentation.h index 8d19a4b545..85a9850f20 100644 --- a/cc/debug/devtools_instrumentation.h +++ b/cc/debug/devtools_instrumentation.h @@ -11,7 +11,9 @@ namespace cc { namespace devtools_instrumentation { namespace internal { -const char kCategory[] = "cc,devtools"; +const char kCategory[] = TRACE_DISABLED_BY_DEFAULT("devtools.timeline"); +const char kCategoryFrame[] = + TRACE_DISABLED_BY_DEFAULT("devtools.timeline.frame"); const char kFrameId[] = "frameId"; const char kLayerId[] = "layerId"; const char kLayerTreeId[] = "layerTreeId"; @@ -26,6 +28,7 @@ const char kDrawFrame[] = "DrawFrame"; const char kRasterTask[] = "RasterTask"; const char kPaintSetup[] = "PaintSetup"; +const char kUpdateLayer[] = "UpdateLayer"; class ScopedLayerTask { public: @@ -89,22 +92,25 @@ struct ScopedLayerObjectTracker }; inline void DidActivateLayerTree(int layer_tree_host_id, int frame_id) { - TRACE_EVENT_INSTANT2(internal::kCategory, + TRACE_EVENT_INSTANT2(internal::kCategoryFrame, internal::kActivateLayerTree, TRACE_EVENT_SCOPE_THREAD, - internal::kLayerTreeId, layer_tree_host_id, - internal::kFrameId, frame_id); + internal::kLayerTreeId, + layer_tree_host_id, + internal::kFrameId, + frame_id); } inline void DidBeginFrame(int layer_tree_host_id) { - TRACE_EVENT_INSTANT1(internal::kCategory, + TRACE_EVENT_INSTANT1(internal::kCategoryFrame, internal::kBeginFrame, TRACE_EVENT_SCOPE_THREAD, - internal::kLayerTreeId, layer_tree_host_id); + internal::kLayerTreeId, + layer_tree_host_id); } inline void DidDrawFrame(int layer_tree_host_id) { - TRACE_EVENT_INSTANT1(internal::kCategory, + TRACE_EVENT_INSTANT1(internal::kCategoryFrame, internal::kDrawFrame, TRACE_EVENT_SCOPE_THREAD, internal::kLayerTreeId, @@ -112,7 +118,7 @@ inline void DidDrawFrame(int layer_tree_host_id) { } inline void DidRequestMainThreadFrame(int layer_tree_host_id) { - TRACE_EVENT_INSTANT1(internal::kCategory, + TRACE_EVENT_INSTANT1(internal::kCategoryFrame, internal::kRequestMainThreadFrame, TRACE_EVENT_SCOPE_THREAD, internal::kLayerTreeId, diff --git a/cc/debug/rendering_stats_instrumentation.cc b/cc/debug/rendering_stats_instrumentation.cc index d58ae80eb9..9655241c63 100644 --- a/cc/debug/rendering_stats_instrumentation.cc +++ b/cc/debug/rendering_stats_instrumentation.cc @@ -21,35 +21,35 @@ RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {} MainThreadRenderingStats RenderingStatsInstrumentation::main_thread_rendering_stats() { base::AutoLock scoped_lock(lock_); - return main_stats_; + return main_thread_rendering_stats_; } ImplThreadRenderingStats RenderingStatsInstrumentation::impl_thread_rendering_stats() { base::AutoLock scoped_lock(lock_); - return impl_stats_; + return impl_thread_rendering_stats_; } RenderingStats RenderingStatsInstrumentation::GetRenderingStats() { base::AutoLock scoped_lock(lock_); RenderingStats rendering_stats; - rendering_stats.main_stats = main_stats_accu_; - rendering_stats.main_stats.Add(main_stats_); - rendering_stats.impl_stats = impl_stats_accu_; - rendering_stats.impl_stats.Add(impl_stats_); + rendering_stats.main_stats = main_thread_rendering_stats_accu_; + rendering_stats.main_stats.Add(main_thread_rendering_stats_); + rendering_stats.impl_stats = impl_thread_rendering_stats_accu_; + rendering_stats.impl_stats.Add(impl_thread_rendering_stats_); return rendering_stats; } void RenderingStatsInstrumentation::AccumulateAndClearMainThreadStats() { base::AutoLock scoped_lock(lock_); - main_stats_accu_.Add(main_stats_); - main_stats_ = MainThreadRenderingStats(); + main_thread_rendering_stats_accu_.Add(main_thread_rendering_stats_); + main_thread_rendering_stats_ = MainThreadRenderingStats(); } void RenderingStatsInstrumentation::AccumulateAndClearImplThreadStats() { base::AutoLock scoped_lock(lock_); - impl_stats_accu_.Add(impl_stats_); - impl_stats_ = ImplThreadRenderingStats(); + impl_thread_rendering_stats_accu_.Add(impl_thread_rendering_stats_); + impl_thread_rendering_stats_ = ImplThreadRenderingStats(); } base::TimeTicks RenderingStatsInstrumentation::StartRecording() const { @@ -78,9 +78,9 @@ void RenderingStatsInstrumentation::IncrementFrameCount(int64 count, base::AutoLock scoped_lock(lock_); if (main_thread) - main_stats_.frame_count += count; + main_thread_rendering_stats_.frame_count += count; else - impl_stats_.frame_count += count; + impl_thread_rendering_stats_.frame_count += count; } void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration, @@ -89,8 +89,8 @@ void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration, return; base::AutoLock scoped_lock(lock_); - main_stats_.paint_time += duration; - main_stats_.painted_pixel_count += pixels; + main_thread_rendering_stats_.paint_time += duration; + main_thread_rendering_stats_.painted_pixel_count += pixels; } void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration, @@ -99,8 +99,8 @@ void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration, return; base::AutoLock scoped_lock(lock_); - main_stats_.record_time += duration; - main_stats_.recorded_pixel_count += pixels; + main_thread_rendering_stats_.record_time += duration; + main_thread_rendering_stats_.recorded_pixel_count += pixels; } void RenderingStatsInstrumentation::AddRaster(base::TimeDelta duration, @@ -109,8 +109,8 @@ void RenderingStatsInstrumentation::AddRaster(base::TimeDelta duration, return; base::AutoLock scoped_lock(lock_); - impl_stats_.rasterize_time += duration; - impl_stats_.rasterized_pixel_count += pixels; + impl_thread_rendering_stats_.rasterize_time += duration; + impl_thread_rendering_stats_.rasterized_pixel_count += pixels; } void RenderingStatsInstrumentation::AddAnalysis(base::TimeDelta duration, @@ -119,7 +119,7 @@ void RenderingStatsInstrumentation::AddAnalysis(base::TimeDelta duration, return; base::AutoLock scoped_lock(lock_); - impl_stats_.analysis_time += duration; + impl_thread_rendering_stats_.analysis_time += duration; } void RenderingStatsInstrumentation::AddVisibleContentArea(int64 area) { @@ -127,7 +127,7 @@ void RenderingStatsInstrumentation::AddVisibleContentArea(int64 area) { return; base::AutoLock scoped_lock(lock_); - impl_stats_.visible_content_area += area; + impl_thread_rendering_stats_.visible_content_area += area; } void RenderingStatsInstrumentation::AddApproximatedVisibleContentArea( @@ -136,7 +136,7 @@ void RenderingStatsInstrumentation::AddApproximatedVisibleContentArea( return; base::AutoLock scoped_lock(lock_); - impl_stats_.approximated_visible_content_area += area; + impl_thread_rendering_stats_.approximated_visible_content_area += area; } } // namespace cc diff --git a/cc/debug/rendering_stats_instrumentation.h b/cc/debug/rendering_stats_instrumentation.h index e1061dc400..664013186c 100644 --- a/cc/debug/rendering_stats_instrumentation.h +++ b/cc/debug/rendering_stats_instrumentation.h @@ -59,11 +59,10 @@ class CC_EXPORT RenderingStatsInstrumentation { RenderingStatsInstrumentation(); private: - // TODO(ernstm): rename to *_thread_rendering_stats_* - MainThreadRenderingStats main_stats_; - MainThreadRenderingStats main_stats_accu_; - ImplThreadRenderingStats impl_stats_; - ImplThreadRenderingStats impl_stats_accu_; + MainThreadRenderingStats main_thread_rendering_stats_; + MainThreadRenderingStats main_thread_rendering_stats_accu_; + ImplThreadRenderingStats impl_thread_rendering_stats_; + ImplThreadRenderingStats impl_thread_rendering_stats_accu_; bool record_rendering_stats_; diff --git a/cc/layers/delegated_renderer_layer.cc b/cc/layers/delegated_renderer_layer.cc index 194455ac26..c47206172c 100644 --- a/cc/layers/delegated_renderer_layer.cc +++ b/cc/layers/delegated_renderer_layer.cc @@ -67,8 +67,6 @@ void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) { DelegatedRendererLayerImpl* delegated_impl = static_cast<DelegatedRendererLayerImpl*>(impl); - delegated_impl->SetDisplaySize(display_size_); - delegated_impl->CreateChildIdIfNeeded( frame_provider_->GetReturnResourcesCallbackForImplThread()); @@ -86,13 +84,6 @@ void DelegatedRendererLayer::ProviderHasNewFrame() { SetNextCommitWaitsForActivation(); } -void DelegatedRendererLayer::SetDisplaySize(const gfx::Size& size) { - if (display_size_ == size) - return; - display_size_ = size; - SetNeedsCommit(); -} - bool DelegatedRendererLayer::Update(ResourceUpdateQueue* queue, const OcclusionTracker<Layer>* occlusion) { bool updated = Layer::Update(queue, occlusion); diff --git a/cc/layers/delegated_renderer_layer.h b/cc/layers/delegated_renderer_layer.h index a22954328b..3bc0aa8758 100644 --- a/cc/layers/delegated_renderer_layer.h +++ b/cc/layers/delegated_renderer_layer.h @@ -29,12 +29,6 @@ class CC_EXPORT DelegatedRendererLayer : public Layer { const OcclusionTracker<Layer>* occlusion) OVERRIDE; virtual void PushPropertiesTo(LayerImpl* impl) OVERRIDE; - // Set the size at which the frame should be displayed, with the origin at the - // layer's origin. This must always contain at least the layer's bounds. A - // value of (0, 0) implies that the frame should be displayed to fit exactly - // in the layer's bounds. - void SetDisplaySize(const gfx::Size& size); - // Called by the DelegatedFrameProvider when a new frame is available to be // picked up. void ProviderHasNewFrame(); @@ -52,8 +46,6 @@ class CC_EXPORT DelegatedRendererLayer : public Layer { DelegatedFrameData* frame_data_; gfx::RectF frame_damage_; - gfx::Size display_size_; - scoped_refptr<BlockingTaskRunner> main_thread_runner_; base::WeakPtrFactory<DelegatedRendererLayer> weak_ptrs_; diff --git a/cc/layers/delegated_renderer_layer_impl.cc b/cc/layers/delegated_renderer_layer_impl.cc index d5fdec7a74..c1cdbbe419 100644 --- a/cc/layers/delegated_renderer_layer_impl.cc +++ b/cc/layers/delegated_renderer_layer_impl.cc @@ -76,7 +76,6 @@ void DelegatedRendererLayerImpl::PushPropertiesTo(LayerImpl* layer) { delegated_layer->own_child_id_ = true; own_child_id_ = false; - delegated_layer->SetDisplaySize(display_size_); if (have_render_passes_to_push_) { // This passes ownership of the render passes to the active tree. delegated_layer->SetRenderPasses(&render_passes_in_draw_order_); @@ -157,13 +156,6 @@ void DelegatedRendererLayerImpl::SetFrameData( have_render_passes_to_push_ = true; } -void DelegatedRendererLayerImpl::SetDisplaySize(const gfx::Size& size) { - if (display_size_ == size) - return; - display_size_ = size; - NoteLayerPropertyChanged(); -} - void DelegatedRendererLayerImpl::SetRenderPasses( ScopedPtrVector<RenderPass>* render_passes_in_draw_order) { ClearRenderPasses(); @@ -404,9 +396,6 @@ void DelegatedRendererLayerImpl::AppendRenderPassQuads( bool is_root_delegated_render_pass = delegated_render_pass == render_passes_in_draw_order_.back(); if (is_root_delegated_render_pass) { - // Don't allow areas inside the bounds that are empty. - DCHECK(display_size_.IsEmpty() || - gfx::Rect(display_size_).Contains(gfx::Rect(bounds()))); gfx::Transform delegated_frame_to_target_transform = draw_transform(); delegated_frame_to_target_transform.Scale(inverse_device_scale_factor_, inverse_device_scale_factor_); diff --git a/cc/layers/delegated_renderer_layer_impl.h b/cc/layers/delegated_renderer_layer_impl.h index e64fd46959..9f7aaf8b5b 100644 --- a/cc/layers/delegated_renderer_layer_impl.h +++ b/cc/layers/delegated_renderer_layer_impl.h @@ -48,8 +48,6 @@ class CC_EXPORT DelegatedRendererLayerImpl : public LayerImpl { void SetFrameData(const DelegatedFrameData* frame_data, const gfx::RectF& damage_in_frame); - void SetDisplaySize(const gfx::Size& size); - protected: DelegatedRendererLayerImpl(LayerTreeImpl* tree_impl, int id); @@ -92,7 +90,6 @@ class CC_EXPORT DelegatedRendererLayerImpl : public LayerImpl { base::hash_map<RenderPass::Id, int> render_passes_index_by_id_; ResourceProvider::ResourceIdArray resources_; - gfx::Size display_size_; int child_id_; bool own_child_id_; diff --git a/cc/layers/draw_properties.h b/cc/layers/draw_properties.h index 3f167b9b0b..a0bfc2a6f2 100644 --- a/cc/layers/draw_properties.h +++ b/cc/layers/draw_properties.h @@ -29,13 +29,18 @@ struct CC_EXPORT DrawProperties { num_descendants_that_draw_content(0), num_unclipped_descendants(0), layer_or_descendant_has_copy_request(false), + layer_or_descendant_has_input_handler(false), has_child_with_a_scroll_parent(false), sorted_for_recursion(false), index_of_first_descendants_addition(0), num_descendants_added(0), index_of_first_render_surface_layer_list_addition(0), num_render_surfaces_added(0), - last_drawn_render_surface_layer_list_id(0) {} + last_drawn_render_surface_layer_list_id(0), + ideal_contents_scale(0.f), + maximum_animation_contents_scale(0.f), + page_scale_factor(0.f), + device_scale_factor(0.f) {} // Transforms objects from content space to target surface space, where // this layer would be drawn. @@ -102,6 +107,9 @@ struct CC_EXPORT DrawProperties { // present on it. bool layer_or_descendant_has_copy_request; + // If true, the layer or one of its descendants has a wheel or touch handler. + bool layer_or_descendant_has_input_handler; + // This is true if the layer has any direct child that has a scroll parent. // This layer will not be the scroll parent in this case. This information // lets us avoid work in CalculateDrawPropertiesInternal -- if none of our @@ -128,6 +136,21 @@ struct CC_EXPORT DrawProperties { // or the layer doesn't contribute anything, then this ID will be either out // of date or 0. int last_drawn_render_surface_layer_list_id; + + // The scale at which content for the layer should be rastered in order to be + // perfectly crisp. + float ideal_contents_scale; + + // The maximum scale during the layers current animation at which content + // should be rastered at to be crisp. + float maximum_animation_contents_scale; + + // The page scale factor that is applied to the layer. Since some layers may + // have page scale applied and others not, this may differ between layers. + float page_scale_factor; + + // The device scale factor that is applied to the layer. + float device_scale_factor; }; } // namespace cc diff --git a/cc/layers/heads_up_display_layer_impl_unittest.cc b/cc/layers/heads_up_display_layer_impl_unittest.cc index 0db80f59aa..2c58e6a16f 100644 --- a/cc/layers/heads_up_display_layer_impl_unittest.cc +++ b/cc/layers/heads_up_display_layer_impl_unittest.cc @@ -17,7 +17,9 @@ namespace { void CheckDrawLayer(HeadsUpDisplayLayerImpl* layer, ResourceProvider* resource_provider, DrawMode draw_mode) { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); AppendQuadsData data; bool will_draw = layer->WillDraw(draw_mode, resource_provider); if (will_draw) diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index a444ee12c6..67664e088b 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -6,6 +6,7 @@ #include <algorithm> +#include "base/atomic_sequence_num.h" #include "base/debug/trace_event.h" #include "base/location.h" #include "base/metrics/histogram.h" @@ -28,7 +29,7 @@ namespace cc { -static int s_next_layer_id = 1; +base::StaticAtomicSequenceNumber g_next_layer_id; scoped_refptr<Layer> Layer::Create() { return make_scoped_refptr(new Layer()); @@ -38,7 +39,8 @@ Layer::Layer() : needs_push_properties_(false), num_dependents_need_push_properties_(false), stacking_order_changed_(false), - layer_id_(s_next_layer_id++), + // Layer IDs start from 1. + layer_id_(g_next_layer_id.GetNext() + 1), ignore_set_needs_commit_(false), parent_(NULL), layer_tree_host_(NULL), @@ -69,10 +71,6 @@ Layer::Layer() replica_layer_(NULL), raster_scale_(0.f), client_(NULL) { - if (layer_id_ == INT_MAX) { - s_next_layer_id = 1; - } - layer_animation_controller_ = LayerAnimationController::Create(layer_id_); layer_animation_controller_->AddValueObserver(this); layer_animation_controller_->set_value_provider(this); diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 79e64aa079..52a15eef2c 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -479,10 +479,6 @@ skia::RefPtr<SkPicture> LayerImpl::GetPicture() { return skia::RefPtr<SkPicture>(); } -bool LayerImpl::AreVisibleResourcesReady() const { - return true; -} - scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) { return LayerImpl::Create(tree_impl, layer_id_); } @@ -1045,21 +1041,6 @@ void LayerImpl::SetContentsScale(float contents_scale_x, NoteLayerPropertyChanged(); } -void LayerImpl::CalculateContentsScale(float ideal_contents_scale, - float device_scale_factor, - float page_scale_factor, - float maximum_animation_contents_scale, - bool animating_transform_to_screen, - float* contents_scale_x, - float* contents_scale_y, - gfx::Size* content_bounds) { - // Base LayerImpl has all of its content scales and content bounds pushed - // from its Layer during commit and just reuses those values as-is. - *contents_scale_x = this->contents_scale_x(); - *contents_scale_y = this->contents_scale_y(); - *content_bounds = this->content_bounds(); -} - void LayerImpl::SetScrollOffsetDelegate( ScrollOffsetDelegate* scroll_offset_delegate) { // Having both a scroll parent and a scroll offset delegate is unsupported. @@ -1165,7 +1146,6 @@ gfx::Vector2d LayerImpl::MaxScrollOffset() const { LayerImpl const* page_scale_layer = layer_tree_impl()->page_scale_layer(); DCHECK(this != page_scale_layer); - DCHECK(scroll_clip_layer_); DCHECK(this != layer_tree_impl()->InnerViewportScrollLayer() || IsContainerForFixedPositionLayers()); diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index 2ce6eac06d..b93a504259 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -359,15 +359,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, float contents_scale_y() const { return draw_properties_.contents_scale_y; } void SetContentsScale(float contents_scale_x, float contents_scale_y); - virtual void CalculateContentsScale(float ideal_contents_scale, - float device_scale_factor, - float page_scale_factor, - float maximum_animation_contents_scale, - bool animating_transform_to_screen, - float* contents_scale_x, - float* contents_scale_y, - gfx::Size* content_bounds); - void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate); bool IsExternalFlingActive() const; @@ -515,8 +506,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, virtual skia::RefPtr<SkPicture> GetPicture(); - virtual bool AreVisibleResourcesReady() const; - virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); virtual void PushPropertiesTo(LayerImpl* layer); diff --git a/cc/layers/nine_patch_layer_impl_unittest.cc b/cc/layers/nine_patch_layer_impl_unittest.cc index f2a0dfc84a..b129676948 100644 --- a/cc/layers/nine_patch_layer_impl_unittest.cc +++ b/cc/layers/nine_patch_layer_impl_unittest.cc @@ -36,7 +36,9 @@ void NinePatchLayerLayoutTest(const gfx::Size& bitmap_size, const gfx::Rect& border, bool fill_center, size_t expected_quad_size) { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); gfx::Rect visible_content_rect(layer_size); gfx::Rect expected_remaining(border.x(), border.y(), diff --git a/cc/layers/picture_image_layer_impl.cc b/cc/layers/picture_image_layer_impl.cc index 62bab45108..d46ff8d975 100644 --- a/cc/layers/picture_image_layer_impl.cc +++ b/cc/layers/picture_image_layer_impl.cc @@ -27,28 +27,6 @@ scoped_ptr<LayerImpl> PictureImageLayerImpl::CreateLayerImpl( return PictureImageLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); } -void PictureImageLayerImpl::CalculateContentsScale( - float ideal_contents_scale, - float device_scale_factor, - float page_scale_factor, - float maximum_animation_contents_scale, - bool animating_transform_to_screen, - float* contents_scale_x, - float* contents_scale_y, - gfx::Size* content_bounds) { - // CalculateRasterContentsScale always returns 1.f, so make that the ideal - // scale. - ideal_contents_scale = 1.f; - PictureLayerImpl::CalculateContentsScale(ideal_contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform_to_screen, - contents_scale_x, - contents_scale_y, - content_bounds); -} - void PictureImageLayerImpl::GetDebugBorderProperties( SkColor* color, float* width) const { *color = DebugColors::ImageLayerBorderColor(); @@ -74,4 +52,11 @@ void PictureImageLayerImpl::RecalculateRasterScales( low_res_raster_contents_scale_ = raster_contents_scale_; } +void PictureImageLayerImpl::UpdateIdealScales() { + ideal_contents_scale_ = 1.f; + ideal_page_scale_ = 1.f; + ideal_device_scale_ = 1.f; + ideal_source_scale_ = 1.f; +} + } // namespace cc diff --git a/cc/layers/picture_image_layer_impl.h b/cc/layers/picture_image_layer_impl.h index 483d5f244b..9b76d85efa 100644 --- a/cc/layers/picture_image_layer_impl.h +++ b/cc/layers/picture_image_layer_impl.h @@ -21,14 +21,6 @@ class CC_EXPORT PictureImageLayerImpl : public PictureLayerImpl { virtual const char* LayerTypeAsString() const OVERRIDE; virtual scoped_ptr<LayerImpl> CreateLayerImpl( LayerTreeImpl* tree_impl) OVERRIDE; - virtual void CalculateContentsScale(float ideal_contents_scale, - float device_scale_factor, - float page_scale_factor, - float maximum_animation_contents_scale, - bool animating_transform_to_screen, - float* contents_scale_x, - float* contents_scale_y, - gfx::Size* content_bounds) OVERRIDE; protected: PictureImageLayerImpl(LayerTreeImpl* tree_impl, int id); @@ -41,6 +33,8 @@ class CC_EXPORT PictureImageLayerImpl : public PictureLayerImpl { virtual void GetDebugBorderProperties( SkColor* color, float* width) const OVERRIDE; + virtual void UpdateIdealScales() OVERRIDE; + private: DISALLOW_COPY_AND_ASSIGN(PictureImageLayerImpl); }; diff --git a/cc/layers/picture_image_layer_impl_unittest.cc b/cc/layers/picture_image_layer_impl_unittest.cc index 97d522aae3..005a323ba9 100644 --- a/cc/layers/picture_image_layer_impl_unittest.cc +++ b/cc/layers/picture_image_layer_impl_unittest.cc @@ -24,7 +24,20 @@ class TestablePictureImageLayerImpl : public PictureImageLayerImpl { TestablePictureImageLayerImpl(LayerTreeImpl* tree_impl, int id) : PictureImageLayerImpl(tree_impl, id) { } - + 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; @@ -60,14 +73,29 @@ class PictureImageLayerImplTest : public testing::Test { TestablePictureImageLayerImpl* layer = new TestablePictureImageLayerImpl(tree, id); layer->SetBounds(gfx::Size(100, 200)); + layer->SetContentBounds(gfx::Size(100, 200)); layer->tilings_.reset(new PictureLayerTilingSet(&tiling_client_, layer->bounds())); layer->pile_ = tiling_client_.pile(); return make_scoped_ptr(layer); } - void UpdateDrawProperties() { - host_impl_.pending_tree()->UpdateDrawProperties(); + 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) { + 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; + layer->draw_properties().maximum_animation_contents_scale = + 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); } protected: @@ -81,43 +109,11 @@ TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); layer->SetDrawsContent(true); - float contents_scale_x; - float contents_scale_y; - gfx::Size content_bounds; - layer->CalculateContentsScale(2.f, - 3.f, - 4.f, - 1.f, - false, - &contents_scale_x, - &contents_scale_y, - &content_bounds); - EXPECT_FLOAT_EQ(1.f, contents_scale_x); - EXPECT_FLOAT_EQ(1.f, contents_scale_y); - EXPECT_EQ(layer->bounds(), content_bounds); -} - -TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) { - scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); - layer->SetBounds(gfx::Size(100, 200)); - layer->SetDrawsContent(true); + SetupDrawPropertiesAndManageTilings(layer.get(), 2.f, 3.f, 4.f, 1.f, false); - UpdateDrawProperties(); - - float contents_scale_x; - float contents_scale_y; - gfx::Size content_bounds; - layer->CalculateContentsScale(2.f, - 3.f, - 4.f, - 1.f, - false, - &contents_scale_x, - &contents_scale_y, - &content_bounds); - layer->UpdateTilePriorities(); - - EXPECT_TRUE(layer->AreVisibleResourcesReady()); + EXPECT_FLOAT_EQ(1.f, layer->contents_scale_x()); + EXPECT_FLOAT_EQ(1.f, layer->contents_scale_y()); + EXPECT_FLOAT_EQ(1.f, layer->MaximumTilingContentsScale()); } TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { @@ -132,31 +128,24 @@ 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; - float contents_scale_x; - float contents_scale_y; - gfx::Size content_bounds; - pending_layer->CalculateContentsScale(suggested_ideal_contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform_to_screen, - &contents_scale_x, - &contents_scale_y, - &content_bounds); + SetupDrawPropertiesAndManageTilings(pending_layer.get(), + suggested_ideal_contents_scale, + device_scale_factor, + page_scale_factor, + maximum_animation_contents_scale, + animating_transform_to_screen); // Push to active layer. host_impl_.ActivatePendingTree(); scoped_ptr<TestablePictureImageLayerImpl> active_layer( CreateLayer(1, ACTIVE_TREE)); pending_layer->PushPropertiesTo(active_layer.get()); - active_layer->CalculateContentsScale(suggested_ideal_contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform_to_screen, - &contents_scale_x, - &contents_scale_y, - &content_bounds); + SetupDrawPropertiesAndManageTilings(active_layer.get(), + suggested_ideal_contents_scale, + device_scale_factor, + page_scale_factor, + maximum_animation_contents_scale, + animating_transform_to_screen); // Create tile and resource. active_layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); @@ -166,7 +155,9 @@ TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { // Draw. active_layer->draw_properties().visible_content_rect = gfx::Rect(active_layer->bounds()); - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); AppendQuadsData data; active_layer->WillDraw(DRAW_MODE_SOFTWARE, NULL); active_layer->AppendQuads(&quad_culler, &data); diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index ae823a6cec..61dce74194 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -21,7 +21,9 @@ PictureLayer::PictureLayer(ContentLayerClient* client) pile_(make_scoped_refptr(new PicturePile())), instrumentation_object_tracker_(id()), is_mask_(false), - update_source_frame_number_(-1) {} + update_source_frame_number_(-1), + can_use_lcd_text_last_frame_(can_use_lcd_text()) { +} PictureLayer::~PictureLayer() { } @@ -88,6 +90,8 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue, update_source_frame_number_ = layer_tree_host()->source_frame_number(); bool updated = Layer::Update(queue, occlusion); + UpdateCanUseLCDText(); + gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( visible_content_rect(), 1.f / contents_scale_x()); @@ -102,6 +106,8 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue, TRACE_EVENT1("cc", "PictureLayer::Update", "source_frame_number", layer_tree_host()->source_frame_number()); + devtools_instrumentation::ScopedLayerTreeTask update_layer( + devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->id()); pile_->SetTilingRect(layer_rect); @@ -115,16 +121,22 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue, // the full page content must always be provided in the picture layer. visible_layer_rect = gfx::Rect(bounds()); } + + // UpdateAndExpandInvalidation will give us an invalidation that covers + // anything not explicitly recorded in this frame. We give this region + // to the impl side so that it drops tiles that may not have a recording + // for them. DCHECK(client_); - updated |= pile_->Update(client_, - SafeOpaqueBackgroundColor(), - contents_opaque(), - client_->FillsBoundsCompletely(), - pile_invalidation_, - visible_layer_rect, - update_source_frame_number_, - RecordingMode(), - rendering_stats_instrumentation()); + updated |= + pile_->UpdateAndExpandInvalidation(client_, + &pile_invalidation_, + SafeOpaqueBackgroundColor(), + contents_opaque(), + client_->FillsBoundsCompletely(), + visible_layer_rect, + update_source_frame_number_, + RecordingMode(), + rendering_stats_instrumentation()); last_updated_visible_content_rect_ = visible_content_rect(); if (updated) { @@ -157,6 +169,15 @@ bool PictureLayer::SupportsLCDText() const { return true; } +void PictureLayer::UpdateCanUseLCDText() { + if (can_use_lcd_text_last_frame_ == can_use_lcd_text()) + return; + + can_use_lcd_text_last_frame_ = can_use_lcd_text(); + if (client_) + client_->DidChangeLayerCanUseLCDText(); +} + skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { // We could either flatten the PicturePile into a single SkPicture, // or paint a fresh one depending on what we intend to do with the diff --git a/cc/layers/picture_layer.h b/cc/layers/picture_layer.h index 740bd85829..406ffad2f1 100644 --- a/cc/layers/picture_layer.h +++ b/cc/layers/picture_layer.h @@ -49,6 +49,8 @@ class CC_EXPORT PictureLayer : public Layer { explicit PictureLayer(ContentLayerClient* client); virtual ~PictureLayer(); + void UpdateCanUseLCDText(); + private: ContentLayerClient* client_; scoped_refptr<PicturePile> pile_; @@ -62,6 +64,7 @@ class CC_EXPORT PictureLayer : public Layer { bool is_mask_; int update_source_frame_number_; + bool can_use_lcd_text_last_frame_; DISALLOW_COPY_AND_ASSIGN(PictureLayer); }; diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 6d37b7f4db..0ebd0e4dc7 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -62,15 +62,13 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) low_res_raster_contents_scale_(0.f), raster_source_scale_is_fixed_(false), was_animating_transform_to_screen_(false), - is_using_lcd_text_(tree_impl->settings().can_use_lcd_text), needs_post_commit_initialization_(true), - should_update_tile_priorities_(false), - layer_needs_to_register_itself_(true) { + should_update_tile_priorities_(false) { + layer_tree_impl()->RegisterPictureLayerImpl(this); } PictureLayerImpl::~PictureLayerImpl() { - if (!layer_needs_to_register_itself_) - layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this); + layer_tree_impl()->UnregisterPictureLayerImpl(this); } const char* PictureLayerImpl::LayerTypeAsString() const { @@ -123,8 +121,6 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { layer_impl->raster_source_scale_ = raster_source_scale_; layer_impl->raster_contents_scale_ = raster_contents_scale_; layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; - - layer_impl->UpdateLCDTextStatus(is_using_lcd_text_); layer_impl->needs_post_commit_initialization_ = false; // The invalidation on this soon-to-be-recycled layer must be cleared to @@ -142,10 +138,28 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, AppendQuadsData* append_quads_data) { DCHECK(!needs_post_commit_initialization_); - gfx::Rect rect(visible_content_rect()); + + float max_contents_scale = MaximumTilingContentsScale(); + gfx::Transform scaled_draw_transform = draw_transform(); + scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, + SK_MScalar1 / max_contents_scale); + gfx::Size scaled_content_bounds = + gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale)); + + gfx::Rect scaled_visible_content_rect = + gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); + scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); - PopulateSharedQuadState(shared_quad_state); + shared_quad_state->SetAll(scaled_draw_transform, + scaled_content_bounds, + scaled_visible_content_rect, + draw_properties().clip_rect, + draw_properties().is_clipped, + draw_properties().opacity, + blend_mode()); + + gfx::Rect rect = scaled_visible_content_rect; if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { AppendDebugBorderQuad( @@ -165,7 +179,6 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, gfx::Size texture_size = rect.size(); gfx::RectF texture_rect = gfx::RectF(texture_size); gfx::Rect quad_content_rect = rect; - float contents_scale = contents_scale_x(); scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); quad->SetNew(shared_quad_state, @@ -176,7 +189,7 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, texture_size, RGBA_8888, quad_content_rect, - contents_scale, + max_contents_scale, pile_); quad_sink->Append(quad.PassAs<DrawQuad>()); append_quads_data->num_missing_tiles++; @@ -187,7 +200,7 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, if (ShowDebugBorders()) { for (PictureLayerTilingSet::CoverageIterator iter( - tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); + tilings_.get(), max_contents_scale, rect, ideal_contents_scale_); iter; ++iter) { SkColor color; @@ -207,7 +220,7 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { color = DebugColors::LowResTileBorderColor(); width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); - } else if (iter->contents_scale() > contents_scale_x()) { + } else if (iter->contents_scale() > max_contents_scale) { color = DebugColors::ExtraHighResTileBorderColor(); width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); } else { @@ -239,7 +252,7 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, size_t missing_tile_count = 0u; size_t on_demand_missing_tile_count = 0u; for (PictureLayerTilingSet::CoverageIterator iter( - tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); + tilings_.get(), max_contents_scale, rect, ideal_contents_scale_); iter; ++iter) { gfx::Rect geometry_rect = iter.geometry_rect(); @@ -373,21 +386,17 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, CleanUpTilingsOnActiveLayer(seen_tilings); } -void PictureLayerImpl::DidUnregisterLayer() { - TRACE_EVENT0("cc", "PictureLayerImpl::DidUnregisterLayer"); - - layer_needs_to_register_itself_ = true; -} - void PictureLayerImpl::UpdateTilePriorities() { TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); - DCHECK(!needs_post_commit_initialization_); - CHECK(should_update_tile_priorities_); - - if (layer_needs_to_register_itself_) { - layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); - layer_needs_to_register_itself_ = false; + 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()) { @@ -414,8 +423,6 @@ void PictureLayerImpl::UpdateTilePriorities() { if (!tiling_needs_update) return; - UpdateLCDTextStatus(can_use_lcd_text()); - // Use visible_content_rect, unless it's empty. If it's empty, then // try to inverse project the viewport into layer space and use that. gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_; @@ -430,12 +437,15 @@ void PictureLayerImpl::UpdateTilePriorities() { } } + gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( + 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_rect_in_content_space, - contents_scale_x(), + visible_layer_rect, + MaximumTilingContentsScale(), current_frame_time_in_seconds); if (layer_tree_impl()->IsPendingTree()) @@ -475,74 +485,6 @@ void PictureLayerImpl::ReleaseResources() { layer_tree_impl()->set_needs_update_draw_properties(); } -void PictureLayerImpl::CalculateContentsScale( - float ideal_contents_scale, - float device_scale_factor, - float page_scale_factor, - float maximum_animation_contents_scale, - bool animating_transform_to_screen, - float* contents_scale_x, - float* contents_scale_y, - gfx::Size* content_bounds) { - DoPostCommitInitializationIfNeeded(); - - // This function sets valid raster scales and manages tilings, so tile - // priorities can now be updated. - should_update_tile_priorities_ = true; - - if (!CanHaveTilings()) { - ideal_page_scale_ = page_scale_factor; - ideal_device_scale_ = device_scale_factor; - ideal_contents_scale_ = ideal_contents_scale; - ideal_source_scale_ = - ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; - *contents_scale_x = ideal_contents_scale_; - *contents_scale_y = ideal_contents_scale_; - *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), - ideal_contents_scale_, - ideal_contents_scale_)); - return; - } - - float min_contents_scale = MinimumContentsScale(); - DCHECK_GT(min_contents_scale, 0.f); - float min_page_scale = layer_tree_impl()->min_page_scale_factor(); - DCHECK_GT(min_page_scale, 0.f); - float min_device_scale = 1.f; - float min_source_scale = - min_contents_scale / min_page_scale / min_device_scale; - - float ideal_page_scale = page_scale_factor; - float ideal_device_scale = device_scale_factor; - float ideal_source_scale = - ideal_contents_scale / ideal_page_scale / ideal_device_scale; - - ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); - ideal_page_scale_ = ideal_page_scale; - ideal_device_scale_ = ideal_device_scale; - ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); - - ManageTilings(animating_transform_to_screen, - maximum_animation_contents_scale); - - // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. - // There are (usually) several tilings at different scales. However, the - // content bounds is the (integer!) space in which quads are generated. - // In order to guarantee that we can fill this integer space with any set of - // tilings (and then map back to floating point texture coordinates), the - // contents scale must be at least as large as the largest of the tilings. - float max_contents_scale = min_contents_scale; - for (size_t i = 0; i < tilings_->num_tilings(); ++i) { - const PictureLayerTiling* tiling = tilings_->tiling_at(i); - max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); - } - - *contents_scale_x = max_contents_scale; - *contents_scale_y = max_contents_scale; - *content_bounds = gfx::ToCeiledSize( - gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); -} - skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { return pile_->GetFlattenedPicture(); } @@ -553,9 +495,6 @@ scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, return scoped_refptr<Tile>(); int flags = 0; - if (is_using_lcd_text_) - flags |= Tile::USE_LCD_TEXT; - // We analyze picture before rasterization to detect solid-color tiles. // If the tile is detected as such there is no need to raster or upload. // It is drawn directly as a solid-color quad saving memory, raster and upload @@ -687,11 +626,10 @@ gfx::Size PictureLayerImpl::CalculateTileSize( } void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { + TRACE_EVENT0("cc", "SyncFromActiveLayer"); DCHECK(!other->needs_post_commit_initialization_); DCHECK(other->tilings_); - UpdateLCDTextStatus(other->is_using_lcd_text_); - if (!DrawsContent()) { RemoveAllTilings(); return; @@ -703,23 +641,6 @@ void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { raster_contents_scale_ = other->raster_contents_scale_; low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; - // Add synthetic invalidations for any recordings that were dropped. As - // tiles are updated to point to this new pile, this will force the dropping - // of tiles that can no longer be rastered. This is not ideal, but is a - // trade-off for memory (use the same pile as much as possible, by switching - // during DidBecomeActive) and for time (don't bother checking every tile - // during activation to see if the new pile can still raster it). - for (int x = 0; x < pile_->num_tiles_x(); ++x) { - for (int y = 0; y < pile_->num_tiles_y(); ++y) { - bool previously_had = other->pile_->HasRecordingAt(x, y); - bool now_has = pile_->HasRecordingAt(x, y); - if (now_has || !previously_had) - continue; - gfx::Rect layer_rect = pile_->tile_bounds(x, y); - invalidation_.Union(layer_rect); - } - } - // Union in the other newly exposed regions as invalid. Region difference_region = Region(gfx::Rect(bounds())); difference_region.Subtract(gfx::Rect(other->bounds())); @@ -772,7 +693,7 @@ void PictureLayerImpl::SetIsMask(bool is_mask) { ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { gfx::Rect content_rect(content_bounds()); - float scale = contents_scale_x(); + float scale = MaximumTilingContentsScale(); PictureLayerTilingSet::CoverageIterator iter( tilings_.get(), scale, content_rect, ideal_contents_scale_); @@ -803,6 +724,10 @@ void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { // be ready to draw in order to activate without flashing content from a // higher res on the active tree to a lower res on the pending tree. + // First, early out for layers with no visible content. + if (visible_content_rect().IsEmpty()) + return; + gfx::Rect rect(visible_content_rect()); float min_acceptable_scale = @@ -1221,6 +1146,7 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer( raster_contents_scale_, ideal_contents_scale_); float max_acceptable_high_res_scale = std::max( raster_contents_scale_, ideal_contents_scale_); + float twin_low_res_scale = 0.f; PictureLayerImpl* twin = twin_layer_; if (twin) { @@ -1230,6 +1156,12 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer( max_acceptable_high_res_scale = std::max( max_acceptable_high_res_scale, std::max(twin->raster_contents_scale_, twin->ideal_contents_scale_)); + + for (size_t i = 0; i < twin->tilings_->num_tilings(); ++i) { + PictureLayerTiling* tiling = twin->tilings_->tiling_at(i); + if (tiling->resolution() == LOW_RESOLUTION) + twin_low_res_scale = tiling->contents_scale(); + } } std::vector<PictureLayerTiling*> to_remove; @@ -1243,9 +1175,11 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer( continue; // Keep low resolution tilings, if the layer should have them. - if (tiling->resolution() == LOW_RESOLUTION && - layer_tree_impl()->create_low_res_tiling()) - continue; + if (layer_tree_impl()->create_low_res_tiling()) { + if (tiling->resolution() == LOW_RESOLUTION || + tiling->contents_scale() == twin_low_res_scale) + continue; + } // Don't remove tilings that are being used (and thus would cause a flash.) if (std::find(used_tilings.begin(), used_tilings.end(), tiling) != @@ -1284,18 +1218,6 @@ float PictureLayerImpl::MinimumContentsScale() const { return std::max(1.f / min_dimension, setting_min); } -void PictureLayerImpl::UpdateLCDTextStatus(bool new_status) { - // Once this layer is not using lcd text, don't switch back. - if (!is_using_lcd_text_) - return; - - if (is_using_lcd_text_ == new_status) - return; - - is_using_lcd_text_ = new_status; - tilings_->SetCanUseLCDText(is_using_lcd_text_); -} - void PictureLayerImpl::ResetRasterScale() { raster_page_scale_ = 0.f; raster_device_scale_ = 0.f; @@ -1340,6 +1262,44 @@ void PictureLayerImpl::SanityCheckTilingState() const { #endif } +float PictureLayerImpl::MaximumTilingContentsScale() const { + float max_contents_scale = MinimumContentsScale(); + for (size_t i = 0; i < tilings_->num_tilings(); ++i) { + const PictureLayerTiling* tiling = tilings_->tiling_at(i); + max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); + } + return max_contents_scale; +} + +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; + } + + float min_contents_scale = MinimumContentsScale(); + DCHECK_GT(min_contents_scale, 0.f); + float min_page_scale = layer_tree_impl()->min_page_scale_factor(); + DCHECK_GT(min_page_scale, 0.f); + float min_device_scale = 1.f; + float min_source_scale = + min_contents_scale / min_page_scale / min_device_scale; + + float ideal_page_scale = draw_properties().page_scale_factor; + float ideal_device_scale = draw_properties().device_scale_factor; + float ideal_source_scale = draw_properties().ideal_contents_scale / + ideal_page_scale / ideal_device_scale; + ideal_contents_scale_ = + std::max(draw_properties().ideal_contents_scale, min_contents_scale); + ideal_page_scale_ = draw_properties().page_scale_factor; + ideal_device_scale_ = draw_properties().device_scale_factor; + ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); +} + void PictureLayerImpl::GetDebugBorderProperties( SkColor* color, float* width) const { @@ -1351,7 +1311,7 @@ void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); LayerImpl::AsValueInto(state); state->SetDouble("ideal_contents_scale", ideal_contents_scale_); - state->SetDouble("geometry_contents_scale", contents_scale_x()); + state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); state->Set("tilings", tilings_->AsValue().release()); state->Set("pictures", pile_->AsValue().release()); state->Set("invalidation", invalidation_.AsValue().release()); @@ -1372,7 +1332,6 @@ void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { coverage_tiles->Append(tile_data.release()); } state->Set("coverage_tiles", coverage_tiles.release()); - state->SetBoolean("is_using_lcd_text", is_using_lcd_text_); } size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { @@ -1392,13 +1351,23 @@ bool PictureLayerImpl::IsOnActiveOrPendingTree() const { return !layer_tree_impl()->IsRecycleTree(); } +bool PictureLayerImpl::HasValidTilePriorities() const { + return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); +} + bool PictureLayerImpl::AllTilesRequiredForActivationAreReadyToDraw() const { if (!layer_tree_impl()->IsPendingTree()) return true; + if (!HasValidTilePriorities()) + return true; + if (!tilings_) return true; + if (visible_content_rect().IsEmpty()) + return true; + for (size_t i = 0; i < tilings_->num_tilings(); ++i) { PictureLayerTiling* tiling = tilings_->tiling_at(i); if (tiling->resolution() != HIGH_RESOLUTION && @@ -1431,11 +1400,20 @@ PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator( bool prioritize_low_res) : layer_(layer), current_stage_(0) { DCHECK(layer_); + + // Early out if the layer has no tilings. if (!layer_->tilings_ || !layer_->tilings_->num_tilings()) { current_stage_ = arraysize(stages_); return; } + // Tiles without valid priority are treated as having lowest priority and + // never considered for raster. + if (!layer_->HasValidTilePriorities()) { + current_stage_ = arraysize(stages_); + return; + } + WhichTree tree = layer_->layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; @@ -1535,6 +1513,10 @@ PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator( iteration_stage_(TilePriority::EVENTUALLY), required_for_activation_(false), layer_(layer) { + // Early out if the layer has no tilings. + // TODO(vmpstr): Once tile priorities are determined by the iterators, ensure + // that layers that don't have valid tile priorities have lowest priorities so + // they evict their tiles first (crbug.com/381704) if (!layer_->tilings_ || !layer_->tilings_->num_tilings()) return; diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h index 9609ccf3e4..de4ee2a630 100644 --- a/cc/layers/picture_layer_impl.h +++ b/cc/layers/picture_layer_impl.h @@ -96,14 +96,6 @@ class CC_EXPORT PictureLayerImpl virtual void DidBecomeActive() OVERRIDE; virtual void DidBeginTracing() OVERRIDE; virtual void ReleaseResources() OVERRIDE; - virtual void CalculateContentsScale(float ideal_contents_scale, - float device_scale_factor, - float page_scale_factor, - float maximum_animation_contents_scale, - bool animating_transform_to_screen, - float* contents_scale_x, - float* contents_scale_y, - gfx::Size* content_bounds) OVERRIDE; virtual skia::RefPtr<SkPicture> GetPicture() OVERRIDE; // PictureLayerTilingClient overrides. @@ -132,10 +124,10 @@ class CC_EXPORT PictureLayerImpl virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark) OVERRIDE; // Functions used by tile manager. - void DidUnregisterLayer(); PictureLayerImpl* GetTwinLayer() { return twin_layer_; } WhichTree GetTree() const; bool IsOnActiveOrPendingTree() const; + bool HasValidTilePriorities() const; bool AllTilesRequiredForActivationAreReadyToDraw() const; protected: @@ -156,7 +148,6 @@ class CC_EXPORT PictureLayerImpl std::vector<PictureLayerTiling*> used_tilings); float MinimumContentsScale() const; float SnappedContentsScale(float new_contents_scale); - void UpdateLCDTextStatus(bool new_status); void ResetRasterScale(); void MarkVisibleResourcesAsRequired() const; bool MarkVisibleTilesAsRequired( @@ -180,6 +171,9 @@ class CC_EXPORT PictureLayerImpl SkColor* color, float* width) const OVERRIDE; virtual void AsValueInto(base::DictionaryValue* dict) const OVERRIDE; + virtual void UpdateIdealScales(); + float MaximumTilingContentsScale() const; + PictureLayerImpl* twin_layer_; scoped_ptr<PictureLayerTilingSet> tilings_; @@ -201,14 +195,11 @@ class CC_EXPORT PictureLayerImpl bool raster_source_scale_is_fixed_; bool was_animating_transform_to_screen_; - bool is_using_lcd_text_; bool needs_post_commit_initialization_; // A sanity state check to make sure UpdateTilePriorities only gets called // after a CalculateContentsScale/ManageTilings. bool should_update_tile_priorities_; - bool layer_needs_to_register_itself_; - // Save a copy of the visible rect and viewport size of the last frame that // has a valid viewport for prioritizing tiles. gfx::Rect visible_rect_for_tile_priority_; diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index d380cfecd2..c26f74b2c5 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -26,6 +26,7 @@ #include "cc/trees/layer_tree_impl.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/rect_conversions.h" +#include "ui/gfx/size_conversions.h" namespace cc { namespace { @@ -139,6 +140,23 @@ 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) { + 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; + layer->draw_properties().maximum_animation_contents_scale = + 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); + } static void VerifyAllTilesExistAndHavePile( const PictureLayerTiling* tiling, PicturePileImpl* pile) { @@ -156,24 +174,19 @@ class PictureLayerImplTest : public testing::Test { float page_scale_factor, float maximum_animation_contents_scale, bool animating_transform) { - float result_scale_x, result_scale_y; - gfx::Size result_bounds; - pending_layer_->CalculateContentsScale(contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform, - &result_scale_x, - &result_scale_y, - &result_bounds); - active_layer_->CalculateContentsScale(contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform, - &result_scale_x, - &result_scale_y, - &result_bounds); + 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); } void ResetTilingsAndRasterScales() { @@ -210,16 +223,8 @@ class PictureLayerImplTest : public testing::Test { SetupTrees(pending_pile, active_pile); - float result_scale_x, result_scale_y; - gfx::Size result_bounds; - active_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + 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(); @@ -298,86 +303,6 @@ TEST_F(PictureLayerImplTest, CloneNoInvalidation) { VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), active_pile.get()); } -TEST_F(PictureLayerImplTest, TileManagerRegisterUnregister) { - gfx::Size tile_size(100, 100); - gfx::Size layer_bounds(400, 400); - - scoped_refptr<FakePicturePileImpl> pending_pile = - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - scoped_refptr<FakePicturePileImpl> active_pile = - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - - SetupTrees(pending_pile, active_pile); - - std::vector<TileManager::PairedPictureLayer> paired_layers; - host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); - EXPECT_EQ(0u, paired_layers.size()); - - // Update tile priorities will force the layer to register itself. - float dummy_contents_scale_x; - float dummy_contents_scale_y; - gfx::Size dummy_content_bounds; - active_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &dummy_contents_scale_x, - &dummy_contents_scale_y, - &dummy_content_bounds); - active_layer_->UpdateTilePriorities(); - host_impl_.pending_tree()->UpdateDrawProperties(); - pending_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &dummy_contents_scale_x, - &dummy_contents_scale_y, - &dummy_content_bounds); - pending_layer_->UpdateTilePriorities(); - - host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); - EXPECT_EQ(1u, paired_layers.size()); - EXPECT_EQ(active_layer_, paired_layers[0].active_layer); - EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); - - // Destroy and recreate tile manager. - host_impl_.DidLoseOutputSurface(); - scoped_ptr<TestWebGraphicsContext3D> context = - TestWebGraphicsContext3D::Create(); - host_impl_.InitializeRenderer( - FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>()); - - host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); - EXPECT_EQ(0u, paired_layers.size()); - - active_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &dummy_contents_scale_x, - &dummy_contents_scale_y, - &dummy_content_bounds); - active_layer_->UpdateTilePriorities(); - host_impl_.pending_tree()->UpdateDrawProperties(); - pending_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &dummy_contents_scale_x, - &dummy_contents_scale_y, - &dummy_content_bounds); - pending_layer_->UpdateTilePriorities(); - - host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); - EXPECT_EQ(1u, paired_layers.size()); - EXPECT_EQ(active_layer_, paired_layers[0].active_layer); - EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); -} - TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { base::TimeTicks time_ticks; host_impl_.SetCurrentFrameTimeTicks(time_ticks); @@ -394,17 +319,7 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { Region invalidation; AddDefaultTilingsWithInvalidation(invalidation); - float dummy_contents_scale_x; - float dummy_contents_scale_y; - gfx::Size dummy_content_bounds; - active_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &dummy_contents_scale_x, - &dummy_contents_scale_y, - &dummy_content_bounds); + SetupDrawPropertiesAndManageTilings(active_layer_, 1.f, 1.f, 1.f, 1.f, false); // UpdateTilePriorities with valid viewport. Should update tile viewport. bool valid_for_tile_management = true; @@ -661,19 +576,10 @@ TEST_F(PictureLayerImplTest, ManageTilingsWithNoRecording) { scoped_refptr<FakePicturePileImpl> active_pile = FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); - float result_scale_x, result_scale_y; - gfx::Size result_bounds; - SetupTrees(pending_pile, active_pile); - pending_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + pending_layer_, 1.f, 1.f, 1.f, 1.f, false); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); } @@ -687,23 +593,18 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { scoped_refptr<FakePicturePileImpl> active_pile = FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - float result_scale_x, result_scale_y; - gfx::Size result_bounds; - SetupTrees(pending_pile, active_pile); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; EXPECT_LT(low_res_factor, 1.f); - pending_layer_->CalculateContentsScale(6.f, // ideal contents scale - 3.f, // device scale - 2.f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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()); @@ -711,14 +612,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. - pending_layer_->CalculateContentsScale(6.6f, // ideal contents scale - 3.f, // device scale - 2.2f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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()); @@ -726,14 +625,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. - pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale - 3.3f, // device scale - 2.2f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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()); @@ -742,14 +639,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. - pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale - 2.2f, // device scale - 3.3f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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()); @@ -777,18 +672,14 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { float device_scale = 1.7f; float page_scale = 3.2f; float maximum_animation_scale = 1.f; - float result_scale_x, result_scale_y; - gfx::Size result_bounds; SetupPendingTree(valid_pile); - pending_layer_->CalculateContentsScale(high_res_scale, - device_scale, - page_scale, - maximum_animation_scale, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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()); @@ -797,37 +688,31 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { ActivateTree(); SetupPendingTree(empty_pile); - pending_layer_->CalculateContentsScale(high_res_scale, - device_scale, - page_scale, - maximum_animation_scale, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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(); - active_layer_->CalculateContentsScale(high_res_scale, - device_scale, - page_scale, - maximum_animation_scale, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(active_layer_, + high_res_scale, + device_scale, + page_scale, + maximum_animation_scale, + false); ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); SetupPendingTree(valid_pile); - pending_layer_->CalculateContentsScale(high_res_scale, - device_scale, - page_scale, - maximum_animation_scale, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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, @@ -961,8 +846,6 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { scoped_refptr<FakePicturePileImpl> active_pile = FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - float result_scale_x, result_scale_y; - gfx::Size result_bounds; std::vector<PictureLayerTiling*> used_tilings; SetupTrees(pending_pile, active_pile); @@ -1036,14 +919,8 @@ 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. - active_layer_->CalculateContentsScale(1.1f, - device_scale, - page_scale, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + 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 // in the range [1.0,1.2] and are kept. @@ -1053,14 +930,8 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { // Move the ideal scale on the pending layer to 1.1 as well. Our target stays // 1.2 still. - pending_layer_->CalculateContentsScale(1.1f, - device_scale, - page_scale, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + 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 // target raster scale. But it is in our used tilings set, so nothing is @@ -1214,20 +1085,15 @@ TEST_F(PictureLayerImplTest, ReleaseResources) { scoped_refptr<FakePicturePileImpl> active_pile = FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - float result_scale_x, result_scale_y; - gfx::Size result_bounds; - SetupTrees(pending_pile, active_pile); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); - pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale - 2.7f, // device scale - 3.2f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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. @@ -1237,14 +1103,12 @@ TEST_F(PictureLayerImplTest, ReleaseResources) { EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); // This should create new tilings. - pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale - 2.7f, // device scale - 3.2f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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()); } @@ -1258,20 +1122,11 @@ TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { scoped_refptr<FakePicturePileImpl> active_pile = FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - float result_scale_x, result_scale_y; - gfx::Size result_bounds; - SetupTrees(pending_pile, active_pile); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); - pending_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + 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(); @@ -1294,14 +1149,8 @@ TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( context.Pass()).PassAs<OutputSurface>()); - pending_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + 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(); @@ -1322,20 +1171,11 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { scoped_refptr<FakePicturePileImpl> active_pile = FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - float result_scale_x, result_scale_y; - gfx::Size result_bounds; - SetupTrees(pending_pile, active_pile); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); - pending_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + 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(); @@ -1358,14 +1198,8 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( context.Pass()).PassAs<OutputSurface>()); - pending_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + 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(); @@ -1382,7 +1216,9 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { } TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); gfx::Size tile_size(400, 400); gfx::Size layer_bounds(1300, 1900); @@ -1394,7 +1230,6 @@ TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { SetupTrees(pending_pile, active_pile); - active_layer_->SetContentBounds(layer_bounds); active_layer_->draw_properties().visible_content_rect = gfx::Rect(layer_bounds); @@ -1648,8 +1483,8 @@ TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { // by a sync from the active layer. This could happen because if the // pending layer has not been post-commit initialized it will attempt // to sync from the active layer. - bool default_lcd_text_setting = pending_layer_->is_using_lcd_text(); - pending_layer_->force_set_lcd_text(!default_lcd_text_setting); + float raster_page_scale = 10.f * pending_layer_->raster_page_scale(); + pending_layer_->set_raster_page_scale(raster_page_scale); EXPECT_TRUE(pending_layer_->needs_post_commit_initialization()); host_impl_.ActivatePendingTree(); @@ -1658,7 +1493,7 @@ TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { host_impl_.active_tree()->LayerById(id_)); EXPECT_EQ(0u, active_layer_->num_tilings()); - EXPECT_EQ(!default_lcd_text_setting, active_layer_->is_using_lcd_text()); + EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale()); EXPECT_FALSE(active_layer_->needs_post_commit_initialization()); } @@ -1759,17 +1594,8 @@ TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { host_impl_.active_tree()->UpdateDrawProperties(); EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); - float result_scale_x; - float result_scale_y; - gfx::Size result_bounds; - active_layer_->CalculateContentsScale(0.5f, - 0.5f, - 0.5f, - 0.5f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + active_layer_, 0.5f, 0.5f, 0.5f, 0.5f, false); active_layer_->tilings()->RemoveAllTilings(); PictureLayerTiling* tiling = active_layer_->tilings()->AddTiling(0.5f); active_layer_->tilings()->AddTiling(1.5f); @@ -1812,20 +1638,12 @@ TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { gfx::Size default_tile_size(host_impl_.settings().default_tile_size); gfx::Size layer_bounds(default_tile_size.width() * 4, default_tile_size.height() * 4); - float result_scale_x, result_scale_y; - gfx::Size result_bounds; SetupDefaultTrees(layer_bounds); EXPECT_FALSE(host_impl_.use_gpu_rasterization()); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); - pending_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + 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()); @@ -1833,14 +1651,9 @@ TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { host_impl_.SetUseGpuRasterization(true); EXPECT_TRUE(host_impl_.use_gpu_rasterization()); - pending_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + 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()); } @@ -2466,63 +2279,52 @@ TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { scoped_refptr<FakePicturePileImpl> active_pile = FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - float result_scale_x, result_scale_y; - gfx::Size result_bounds; - SetupTrees(pending_pile, active_pile); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; EXPECT_LT(low_res_factor, 1.f); - pending_layer_->CalculateContentsScale(6.f, // ideal contents scale - 3.f, // device scale - 2.f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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. - pending_layer_->CalculateContentsScale(6.6f, // ideal contents scale - 3.f, // device scale - 2.2f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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. - pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale - 3.3f, // device scale - 2.2f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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. - pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale - 2.2f, // device scale - 3.3f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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()); @@ -2601,86 +2403,6 @@ TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { AssertNoTilesRequired(pending_layer_->LowResTiling()); } -TEST_F(NoLowResPictureLayerImplTest, TileManagerRegisterUnregister) { - gfx::Size tile_size(100, 100); - gfx::Size layer_bounds(400, 400); - - scoped_refptr<FakePicturePileImpl> pending_pile = - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - scoped_refptr<FakePicturePileImpl> active_pile = - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - - SetupTrees(pending_pile, active_pile); - - std::vector<TileManager::PairedPictureLayer> paired_layers; - host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); - EXPECT_EQ(0u, paired_layers.size()); - - // Update tile priorities will force the layer to register itself. - float dummy_contents_scale_x; - float dummy_contents_scale_y; - gfx::Size dummy_content_bounds; - active_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &dummy_contents_scale_x, - &dummy_contents_scale_y, - &dummy_content_bounds); - active_layer_->UpdateTilePriorities(); - host_impl_.pending_tree()->UpdateDrawProperties(); - pending_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &dummy_contents_scale_x, - &dummy_contents_scale_y, - &dummy_content_bounds); - pending_layer_->UpdateTilePriorities(); - - host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); - EXPECT_EQ(1u, paired_layers.size()); - EXPECT_EQ(active_layer_, paired_layers[0].active_layer); - EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); - - // Destroy and recreate tile manager. - host_impl_.DidLoseOutputSurface(); - scoped_ptr<TestWebGraphicsContext3D> context = - TestWebGraphicsContext3D::Create(); - host_impl_.InitializeRenderer( - FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>()); - - host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); - EXPECT_EQ(0u, paired_layers.size()); - - active_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &dummy_contents_scale_x, - &dummy_contents_scale_y, - &dummy_content_bounds); - active_layer_->UpdateTilePriorities(); - host_impl_.pending_tree()->UpdateDrawProperties(); - pending_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &dummy_contents_scale_x, - &dummy_contents_scale_y, - &dummy_content_bounds); - pending_layer_->UpdateTilePriorities(); - - host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); - EXPECT_EQ(1u, paired_layers.size()); - EXPECT_EQ(active_layer_, paired_layers[0].active_layer); - EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); -} - TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { base::TimeTicks time_ticks; host_impl_.SetCurrentFrameTimeTicks(time_ticks); @@ -2697,17 +2419,7 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { Region invalidation; AddDefaultTilingsWithInvalidation(invalidation); - float dummy_contents_scale_x; - float dummy_contents_scale_y; - gfx::Size dummy_content_bounds; - active_layer_->CalculateContentsScale(1.f, - 1.f, - 1.f, - 1.f, - false, - &dummy_contents_scale_x, - &dummy_contents_scale_y, - &dummy_content_bounds); + SetupDrawPropertiesAndManageTilings(active_layer_, 1.f, 1.f, 1.f, 1.f, false); // UpdateTilePriorities with valid viewport. Should update tile viewport. bool valid_for_tile_management = true; @@ -2806,8 +2518,6 @@ TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { scoped_refptr<FakePicturePileImpl> active_pile = FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - float result_scale_x, result_scale_y; - gfx::Size result_bounds; std::vector<PictureLayerTiling*> used_tilings; SetupTrees(pending_pile, active_pile); @@ -2876,14 +2586,8 @@ 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. - active_layer_->CalculateContentsScale(1.1f, - device_scale, - page_scale, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + 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 // in the range [1.0,1.2] and are kept. @@ -2893,14 +2597,8 @@ TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { // Move the ideal scale on the pending layer to 1.1 as well. Our target stays // 1.2 still. - pending_layer_->CalculateContentsScale(1.1f, - device_scale, - page_scale, - 1.f, - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings( + 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 // target raster scale. But it is in our used tilings set, so nothing is @@ -2917,7 +2615,7 @@ TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); } -TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { +TEST_F(PictureLayerImplTest, ScaleCollision) { gfx::Size tile_size(400, 400); gfx::Size layer_bounds(1300, 1900); @@ -2926,20 +2624,89 @@ TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { scoped_refptr<FakePicturePileImpl> active_pile = FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - float result_scale_x, result_scale_y; - gfx::Size result_bounds; + std::vector<PictureLayerTiling*> used_tilings; + + SetupTrees(pending_pile, active_pile); + + float pending_contents_scale = 1.f; + float active_contents_scale = 2.f; + float device_scale_factor = 1.f; + float page_scale_factor = 1.f; + float maximum_animation_contents_scale = 1.f; + bool animating_transform = false; + + EXPECT_TRUE(host_impl_.settings().create_low_res_tiling); + 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); + + ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); + ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); + + EXPECT_EQ(active_contents_scale, + pending_layer_->tilings()->tiling_at(0)->contents_scale()); + EXPECT_EQ(pending_contents_scale, + pending_layer_->tilings()->tiling_at(1)->contents_scale()); + EXPECT_EQ(active_contents_scale * low_res_factor, + pending_layer_->tilings()->tiling_at(2)->contents_scale()); + EXPECT_EQ(pending_contents_scale * low_res_factor, + pending_layer_->tilings()->tiling_at(3)->contents_scale()); + + EXPECT_EQ(active_contents_scale, + active_layer_->tilings()->tiling_at(0)->contents_scale()); + EXPECT_EQ(pending_contents_scale, + active_layer_->tilings()->tiling_at(1)->contents_scale()); + EXPECT_EQ(active_contents_scale * low_res_factor, + active_layer_->tilings()->tiling_at(2)->contents_scale()); + EXPECT_EQ(pending_contents_scale * low_res_factor, + active_layer_->tilings()->tiling_at(3)->contents_scale()); + + // The unused low res tiling from the pending tree must be kept or we may add + // it again on the active tree and collide with the pending tree. + used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); + + EXPECT_EQ(active_contents_scale, + active_layer_->tilings()->tiling_at(0)->contents_scale()); + EXPECT_EQ(pending_contents_scale, + active_layer_->tilings()->tiling_at(1)->contents_scale()); + EXPECT_EQ(active_contents_scale * low_res_factor, + active_layer_->tilings()->tiling_at(2)->contents_scale()); + EXPECT_EQ(pending_contents_scale * low_res_factor, + active_layer_->tilings()->tiling_at(3)->contents_scale()); +} + +TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { + gfx::Size tile_size(400, 400); + gfx::Size layer_bounds(1300, 1900); + + scoped_refptr<FakePicturePileImpl> pending_pile = + FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); + scoped_refptr<FakePicturePileImpl> active_pile = + FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); SetupTrees(pending_pile, active_pile); EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); - pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale - 2.7f, // device scale - 3.2f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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. @@ -2949,16 +2716,63 @@ TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); // This should create new tilings. - pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale - 2.7f, // device scale - 3.2f, // page scale - 1.f, // maximum animation scale - false, - &result_scale_x, - &result_scale_y, - &result_bounds); + SetupDrawPropertiesAndManageTilings(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()); } +TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + + gfx::Size tile_size(400, 400); + gfx::Size layer_bounds(1000, 2000); + + scoped_refptr<FakePicturePileImpl> pending_pile = + FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); + scoped_refptr<FakePicturePileImpl> active_pile = + FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); + + SetupTrees(pending_pile, active_pile); + + SetupDrawPropertiesAndManageTilings( + pending_layer_, 2.5f, 1.f, 1.f, 1.f, false); + host_impl_.pending_tree()->UpdateDrawProperties(); + + active_layer_->draw_properties().visible_content_rect = + gfx::Rect(layer_bounds); + host_impl_.active_tree()->UpdateDrawProperties(); + + float max_contents_scale = active_layer_->MaximumTilingContentsScale(); + gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); + scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, + SK_MScalar1 / max_contents_scale); + + AppendQuadsData data; + active_layer_->AppendQuads(&quad_culler, &data); + + // SharedQuadState should have be of size 1, as we are doing AppenQuad once. + EXPECT_EQ(1u, quad_culler.shared_quad_state_list().size()); + // The content_to_target_transform should be scaled by the + // MaximumTilingContentsScale on the layer. + EXPECT_EQ(scaled_draw_transform.ToString(), + quad_culler.shared_quad_state_list()[0] + ->content_to_target_transform.ToString()); + // The content_bounds should be scaled by the + // MaximumTilingContentsScale on the layer. + EXPECT_EQ(gfx::Size(2500u, 5000u).ToString(), + quad_culler.shared_quad_state_list()[0]->content_bounds.ToString()); + // The visible_content_rect should be scaled by the + // MaximumTilingContentsScale on the layer. + EXPECT_EQ( + gfx::Rect(0u, 0u, 2500u, 5000u).ToString(), + quad_culler.shared_quad_state_list()[0]->visible_content_rect.ToString()); +} + } // namespace } // namespace cc diff --git a/cc/trees/quad_culler.cc b/cc/layers/quad_sink.cc index 419a3dd26f..23758afc66 100644 --- a/cc/trees/quad_culler.cc +++ b/cc/layers/quad_sink.cc @@ -1,8 +1,8 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 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/trees/quad_culler.h" +#include "cc/layers/quad_sink.h" #include "cc/debug/debug_colors.h" #include "cc/layers/append_quads_data.h" @@ -16,35 +16,33 @@ namespace cc { -QuadCuller::QuadCuller(RenderPass* render_pass, - const LayerImpl* layer, - const OcclusionTracker<LayerImpl>& occlusion_tracker) +QuadSink::QuadSink(RenderPass* render_pass, + const OcclusionTracker<LayerImpl>* occlusion_tracker) : render_pass_(render_pass), - layer_(layer), - occlusion_tracker_(occlusion_tracker), - current_shared_quad_state_(NULL) { + current_shared_quad_state_(NULL), + occlusion_tracker_(occlusion_tracker) { } -SharedQuadState* QuadCuller::CreateSharedQuadState() { +SharedQuadState* QuadSink::CreateSharedQuadState() { current_shared_quad_state_ = render_pass_->CreateAndAppendSharedQuadState(); return current_shared_quad_state_; } -gfx::Rect QuadCuller::UnoccludedContentRect( +gfx::Rect QuadSink::UnoccludedContentRect( const gfx::Rect& content_rect, const gfx::Transform& draw_transform) { - return occlusion_tracker_.UnoccludedContentRect( - layer_->render_target(), content_rect, draw_transform); + return occlusion_tracker_->UnoccludedContentRect(content_rect, + draw_transform); } -gfx::Rect QuadCuller::UnoccludedContributingSurfaceContentRect( +gfx::Rect QuadSink::UnoccludedContributingSurfaceContentRect( const gfx::Rect& content_rect, const gfx::Transform& draw_transform) { - return occlusion_tracker_.UnoccludedContributingSurfaceContentRect( - layer_, content_rect, draw_transform); + return occlusion_tracker_->UnoccludedContributingSurfaceContentRect( + content_rect, draw_transform); } -void QuadCuller::Append(scoped_ptr<DrawQuad> draw_quad) { +void QuadSink::Append(scoped_ptr<DrawQuad> draw_quad) { DCHECK(draw_quad->shared_quad_state == current_shared_quad_state_); DCHECK(!render_pass_->shared_quad_state_list.empty()); DCHECK(render_pass_->shared_quad_state_list.back() == diff --git a/cc/layers/quad_sink.h b/cc/layers/quad_sink.h index 0b503e4952..c033bfb489 100644 --- a/cc/layers/quad_sink.h +++ b/cc/layers/quad_sink.h @@ -17,26 +17,41 @@ namespace cc { class DrawQuad; class LayerImpl; +class RenderPass; +class RenderSurfaceImpl; class SharedQuadState; +template <typename LayerType> +class OcclusionTracker; class CC_EXPORT QuadSink { public: - virtual ~QuadSink() {} + QuadSink(RenderPass* render_pass, + const OcclusionTracker<LayerImpl>* occlusion_tracker); + ~QuadSink() {} // Call this to add a SharedQuadState before appending quads that refer to it. // Returns a pointer to the given SharedQuadState, that can be set on the // quads to append. - virtual SharedQuadState* CreateSharedQuadState() = 0; + virtual SharedQuadState* CreateSharedQuadState(); - virtual gfx::Rect UnoccludedContentRect( - const gfx::Rect& content_rect, - const gfx::Transform& draw_transform) = 0; + virtual gfx::Rect UnoccludedContentRect(const gfx::Rect& content_rect, + const gfx::Transform& draw_transform); virtual gfx::Rect UnoccludedContributingSurfaceContentRect( const gfx::Rect& content_rect, - const gfx::Transform& draw_transform) = 0; + const gfx::Transform& draw_transform); + + virtual void Append(scoped_ptr<DrawQuad> draw_quad); + + protected: + RenderPass* render_pass_; + + SharedQuadState* current_shared_quad_state_; + + private: + const OcclusionTracker<LayerImpl>* occlusion_tracker_; - virtual void Append(scoped_ptr<DrawQuad> draw_quad) = 0; + DISALLOW_COPY_AND_ASSIGN(QuadSink); }; } // namespace cc diff --git a/cc/layers/render_surface_unittest.cc b/cc/layers/render_surface_unittest.cc index 47ce2765b8..62c88bcc71 100644 --- a/cc/layers/render_surface_unittest.cc +++ b/cc/layers/render_surface_unittest.cc @@ -107,8 +107,9 @@ TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectSharedQuadState) { render_surface->SetClipRect(clip_rect); render_surface->SetDrawOpacity(1.f); + MockOcclusionTracker<LayerImpl> occlusion_tracker; scoped_ptr<RenderPass> render_pass = RenderPass::Create(); - MockQuadCuller mock_quad_culler(render_pass.get()); + MockQuadCuller mock_quad_culler(render_pass.get(), &occlusion_tracker); AppendQuadsData append_quads_data; bool for_replica = false; diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc index 2f9ede6730..2d00e01bb3 100644 --- a/cc/layers/scrollbar_layer_unittest.cc +++ b/cc/layers/scrollbar_layer_unittest.cc @@ -294,7 +294,9 @@ TEST(ScrollbarLayerTest, SolidColorDrawQuads) { // Thickness should be overridden to 3. { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); AppendQuadsData data; scrollbar_layer_impl->AppendQuads(&quad_culler, &data); @@ -308,7 +310,9 @@ TEST(ScrollbarLayerTest, SolidColorDrawQuads) { scrollbar_layer_impl->draw_properties().contents_scale_x = 2.f; scrollbar_layer_impl->draw_properties().contents_scale_y = 2.f; { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); AppendQuadsData data; scrollbar_layer_impl->AppendQuads(&quad_culler, &data); @@ -324,7 +328,9 @@ TEST(ScrollbarLayerTest, SolidColorDrawQuads) { // current viewport state. scrollbar_layer_impl->SetVisibleToTotalLengthRatio(0.2f); { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); AppendQuadsData data; scrollbar_layer_impl->AppendQuads(&quad_culler, &data); @@ -381,7 +387,10 @@ TEST(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { scrollbar_layer_impl->SetMaximum(8); { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + AppendQuadsData data; scrollbar_layer_impl->AppendQuads(&quad_culler, &data); diff --git a/cc/layers/solid_color_layer_impl_unittest.cc b/cc/layers/solid_color_layer_impl_unittest.cc index 6caa70ca06..b01c343423 100644 --- a/cc/layers/solid_color_layer_impl_unittest.cc +++ b/cc/layers/solid_color_layer_impl_unittest.cc @@ -22,7 +22,10 @@ namespace cc { namespace { TEST(SolidColorLayerImplTest, VerifyTilingCompleteAndNoOverlap) { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + gfx::Size layer_size = gfx::Size(800, 600); gfx::Rect visible_content_rect = gfx::Rect(layer_size); @@ -47,7 +50,10 @@ TEST(SolidColorLayerImplTest, VerifyTilingCompleteAndNoOverlap) { TEST(SolidColorLayerImplTest, VerifyCorrectBackgroundColorInQuad) { SkColor test_color = 0xFFA55AFF; - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + gfx::Size layer_size = gfx::Size(100, 100); gfx::Rect visible_content_rect = gfx::Rect(layer_size); @@ -74,7 +80,10 @@ TEST(SolidColorLayerImplTest, VerifyCorrectBackgroundColorInQuad) { TEST(SolidColorLayerImplTest, VerifyCorrectOpacityInQuad) { const float opacity = 0.5f; - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + gfx::Size layer_size = gfx::Size(100, 100); gfx::Rect visible_content_rect = gfx::Rect(layer_size); @@ -134,7 +143,10 @@ TEST(SolidColorLayerImplTest, VerifyOpaqueRect) { // should be the full tile. layer_impl->draw_properties().opacity = 1; - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + AppendQuadsData data; layer_impl->AppendQuads(&quad_culler, &data); @@ -159,7 +171,10 @@ TEST(SolidColorLayerImplTest, VerifyOpaqueRect) { // should be empty. layer_impl->draw_properties().opacity = 1; - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + AppendQuadsData data; layer_impl->AppendQuads(&quad_culler, &data); diff --git a/cc/layers/surface_layer.cc b/cc/layers/surface_layer.cc index 385f158608..f345b7423d 100644 --- a/cc/layers/surface_layer.cc +++ b/cc/layers/surface_layer.cc @@ -12,11 +12,12 @@ scoped_refptr<SurfaceLayer> SurfaceLayer::Create() { return make_scoped_refptr(new SurfaceLayer); } -SurfaceLayer::SurfaceLayer() : Layer(), surface_id_(0) {} +SurfaceLayer::SurfaceLayer() : Layer() { +} SurfaceLayer::~SurfaceLayer() {} -void SurfaceLayer::SetSurfaceId(int surface_id) { +void SurfaceLayer::SetSurfaceId(SurfaceId surface_id) { surface_id_ = surface_id; SetNeedsPushProperties(); } @@ -26,7 +27,7 @@ scoped_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { } bool SurfaceLayer::DrawsContent() const { - return surface_id_ && Layer::DrawsContent(); + return !surface_id_.is_null() && Layer::DrawsContent(); } void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) { diff --git a/cc/layers/surface_layer.h b/cc/layers/surface_layer.h index 8ff3151cdb..cf150ab480 100644 --- a/cc/layers/surface_layer.h +++ b/cc/layers/surface_layer.h @@ -7,6 +7,7 @@ #include "cc/base/cc_export.h" #include "cc/layers/layer.h" +#include "cc/surfaces/surface_id.h" namespace cc { @@ -16,7 +17,7 @@ class CC_EXPORT SurfaceLayer : public Layer { public: static scoped_refptr<SurfaceLayer> Create(); - void SetSurfaceId(int surface_id); + void SetSurfaceId(SurfaceId surface_id); // Layer overrides. virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) @@ -30,7 +31,7 @@ class CC_EXPORT SurfaceLayer : public Layer { private: virtual ~SurfaceLayer(); - int surface_id_; + SurfaceId surface_id_; DISALLOW_COPY_AND_ASSIGN(SurfaceLayer); }; diff --git a/cc/layers/surface_layer_impl.cc b/cc/layers/surface_layer_impl.cc index 3bfae2d375..6557e20b05 100644 --- a/cc/layers/surface_layer_impl.cc +++ b/cc/layers/surface_layer_impl.cc @@ -11,7 +11,8 @@ namespace cc { SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) - : LayerImpl(tree_impl, id), surface_id_(0) {} + : LayerImpl(tree_impl, id) { +} SurfaceLayerImpl::~SurfaceLayerImpl() {} @@ -20,7 +21,7 @@ scoped_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl( return SurfaceLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); } -void SurfaceLayerImpl::SetSurfaceId(int surface_id) { +void SurfaceLayerImpl::SetSurfaceId(SurfaceId surface_id) { if (surface_id_ == surface_id) return; @@ -42,7 +43,7 @@ void SurfaceLayerImpl::AppendQuads(QuadSink* quad_sink, AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); - if (!surface_id_) + if (surface_id_.is_null()) return; scoped_ptr<SurfaceDrawQuad> quad = SurfaceDrawQuad::Create(); @@ -63,7 +64,7 @@ void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, void SurfaceLayerImpl::AsValueInto(base::DictionaryValue* dict) const { LayerImpl::AsValueInto(dict); - dict->SetInteger("surface_id", surface_id_); + dict->SetInteger("surface_id", surface_id_.id); } const char* SurfaceLayerImpl::LayerTypeAsString() const { diff --git a/cc/layers/surface_layer_impl.h b/cc/layers/surface_layer_impl.h index b8447d0e44..82ac2279e2 100644 --- a/cc/layers/surface_layer_impl.h +++ b/cc/layers/surface_layer_impl.h @@ -8,6 +8,7 @@ #include "base/memory/scoped_ptr.h" #include "cc/base/cc_export.h" #include "cc/layers/layer_impl.h" +#include "cc/surfaces/surface_id.h" namespace cc { @@ -18,7 +19,7 @@ class CC_EXPORT SurfaceLayerImpl : public LayerImpl { } virtual ~SurfaceLayerImpl(); - void SetSurfaceId(int surface_id); + void SetSurfaceId(SurfaceId surface_id); // LayerImpl overrides. virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) @@ -36,7 +37,7 @@ class CC_EXPORT SurfaceLayerImpl : public LayerImpl { virtual void AsValueInto(base::DictionaryValue* dict) const OVERRIDE; virtual const char* LayerTypeAsString() const OVERRIDE; - int surface_id_; + SurfaceId surface_id_; DISALLOW_COPY_AND_ASSIGN(SurfaceLayerImpl); }; diff --git a/cc/layers/surface_layer_impl_unittest.cc b/cc/layers/surface_layer_impl_unittest.cc index aeee4b618a..fb0ed2fe45 100644 --- a/cc/layers/surface_layer_impl_unittest.cc +++ b/cc/layers/surface_layer_impl_unittest.cc @@ -21,7 +21,8 @@ TEST(SurfaceLayerImplTest, Occlusion) { surface_layer_impl->SetBounds(layer_size); surface_layer_impl->SetContentBounds(layer_size); surface_layer_impl->SetDrawsContent(true); - surface_layer_impl->SetSurfaceId(9); + SurfaceId surface_id(9); + surface_layer_impl->SetSurfaceId(surface_id); impl.CalcDrawProps(viewport_size); diff --git a/cc/layers/tiled_layer_impl_unittest.cc b/cc/layers/tiled_layer_impl_unittest.cc index e470effcb5..7fa7d0f7b5 100644 --- a/cc/layers/tiled_layer_impl_unittest.cc +++ b/cc/layers/tiled_layer_impl_unittest.cc @@ -75,7 +75,8 @@ class TiledLayerImplTest : public testing::Test { layer->draw_properties().visible_content_rect = visible_content_rect; layer->SetBounds(layer_size); - MockQuadCuller quad_culler(render_pass); + MockOcclusionTracker<LayerImpl> occlusion_tracker; + MockQuadCuller quad_culler(render_pass, &occlusion_tracker); AppendQuadsData data; layer->AppendQuads(&quad_culler, &data); } @@ -97,7 +98,10 @@ TEST_F(TiledLayerImplTest, EmptyQuadList) { { scoped_ptr<TiledLayerImpl> layer = CreateLayer(tile_size, layer_size, LayerTilingData::NO_BORDER_TEXELS); - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + AppendQuadsData data; EXPECT_TRUE(layer->WillDraw(DRAW_MODE_HARDWARE, NULL)); layer->AppendQuads(&quad_culler, &data); @@ -112,7 +116,10 @@ TEST_F(TiledLayerImplTest, EmptyQuadList) { CreateLayer(tile_size, layer_size, LayerTilingData::NO_BORDER_TEXELS); layer->draw_properties().visible_content_rect = gfx::Rect(); - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + EXPECT_FALSE(layer->WillDraw(DRAW_MODE_HARDWARE, NULL)); } @@ -124,7 +131,10 @@ TEST_F(TiledLayerImplTest, EmptyQuadList) { gfx::Rect outside_bounds(-100, -100, 50, 50); layer->draw_properties().visible_content_rect = outside_bounds; - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + AppendQuadsData data; EXPECT_TRUE(layer->WillDraw(DRAW_MODE_HARDWARE, NULL)); layer->AppendQuads(&quad_culler, &data); @@ -138,7 +148,10 @@ TEST_F(TiledLayerImplTest, EmptyQuadList) { CreateLayer(tile_size, layer_size, LayerTilingData::NO_BORDER_TEXELS); layer->set_skips_draw(true); - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + AppendQuadsData data; layer->AppendQuads(&quad_culler, &data); EXPECT_EQ(quad_culler.quad_list().size(), 0u); @@ -157,7 +170,10 @@ TEST_F(TiledLayerImplTest, Checkerboarding) { // No checkerboarding { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + AppendQuadsData data; layer->AppendQuads(&quad_culler, &data); EXPECT_EQ(quad_culler.quad_list().size(), 4u); @@ -173,7 +189,10 @@ TEST_F(TiledLayerImplTest, Checkerboarding) { // All checkerboarding { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + AppendQuadsData data; layer->AppendQuads(&quad_culler, &data); EXPECT_LT(0u, data.num_missing_tiles); diff --git a/cc/layers/ui_resource_layer_impl_unittest.cc b/cc/layers/ui_resource_layer_impl_unittest.cc index a46f1e4d4d..cd0d7bf02f 100644 --- a/cc/layers/ui_resource_layer_impl_unittest.cc +++ b/cc/layers/ui_resource_layer_impl_unittest.cc @@ -45,7 +45,10 @@ scoped_ptr<UIResourceLayerImpl> GenerateUIResourceLayer( void QuadSizeTest(scoped_ptr<UIResourceLayerImpl> layer, size_t expected_quad_size) { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + AppendQuadsData data; layer->AppendQuads(&quad_culler, &data); @@ -84,7 +87,10 @@ TEST(UIResourceLayerImplTest, VerifyDrawQuads) { void OpaqueBoundsTest(scoped_ptr<UIResourceLayerImpl> layer, const gfx::Rect& expected_opaque_bounds) { - MockQuadCuller quad_culler; + MockOcclusionTracker<LayerImpl> occlusion_tracker; + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); + AppendQuadsData data; layer->AppendQuads(&quad_culler, &data); diff --git a/cc/output/begin_frame_args.cc b/cc/output/begin_frame_args.cc index a592ecc5c0..065cadd372 100644 --- a/cc/output/begin_frame_args.cc +++ b/cc/output/begin_frame_args.cc @@ -52,8 +52,8 @@ BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor( // produce output, the Renderer Impl thread the middle 1/3 of a frame to produce // ouput, and the Renderer Main thread the first 1/3 of a frame to produce // output. -base::TimeDelta BeginFrameArgs::DefaultDeadlineAdjustment() { - return base::TimeDelta::FromMicroseconds(-16666 / 3); +base::TimeDelta BeginFrameArgs::DefaultEstimatedParentDrawTime() { + return base::TimeDelta::FromMicroseconds(16666 / 3); } base::TimeDelta BeginFrameArgs::DefaultInterval() { diff --git a/cc/output/begin_frame_args.h b/cc/output/begin_frame_args.h index 6312e215bc..91ad182ce0 100644 --- a/cc/output/begin_frame_args.h +++ b/cc/output/begin_frame_args.h @@ -25,7 +25,7 @@ struct CC_EXPORT BeginFrameArgs { // This is the default delta that will be used to adjust the deadline when // proper draw-time estimations are not yet available. - static base::TimeDelta DefaultDeadlineAdjustment(); + static base::TimeDelta DefaultEstimatedParentDrawTime(); // This is the default interval to use to avoid sprinkling the code with // magic numbers. diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h index f992e9788c..98a48304b8 100644 --- a/cc/output/output_surface.h +++ b/cc/output/output_surface.h @@ -125,6 +125,7 @@ class CC_EXPORT OutputSurface { // passed in (though it will not take ownership of the CompositorFrame // itself). virtual void SwapBuffers(CompositorFrame* frame); + virtual void OnSwapBuffersComplete(); // Notifies frame-rate smoothness preference. If true, all non-critical // processing should be stopped, or lowered in priority. @@ -182,8 +183,6 @@ class CC_EXPORT OutputSurface { void SetMemoryPolicy(const ManagedMemoryPolicy& policy); void UpdateAndMeasureGpuLatency(); - void OnSwapBuffersComplete(); - bool external_stencil_test_enabled_; base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; diff --git a/cc/quads/draw_quad_unittest.cc b/cc/quads/draw_quad_unittest.cc index c038214d47..7124db2a64 100644 --- a/cc/quads/draw_quad_unittest.cc +++ b/cc/quads/draw_quad_unittest.cc @@ -490,7 +490,7 @@ TEST(DrawQuadTest, CopyStreamVideoDrawQuad) { TEST(DrawQuadTest, CopySurfaceDrawQuad) { gfx::Rect visible_rect(40, 50, 30, 20); - int surface_id = 1234; + SurfaceId surface_id(1234); CREATE_SHARED_STATE(); CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id); @@ -798,7 +798,7 @@ TEST_F(DrawQuadIteratorTest, StreamVideoDrawQuad) { TEST_F(DrawQuadIteratorTest, SurfaceDrawQuad) { gfx::Rect visible_rect(40, 50, 30, 20); - int surface_id = 4321; + SurfaceId surface_id(4321); CREATE_SHARED_STATE(); CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id); diff --git a/cc/quads/surface_draw_quad.cc b/cc/quads/surface_draw_quad.cc index e7d09d5efc..8591261c2d 100644 --- a/cc/quads/surface_draw_quad.cc +++ b/cc/quads/surface_draw_quad.cc @@ -9,7 +9,8 @@ namespace cc { -SurfaceDrawQuad::SurfaceDrawQuad() : surface_id(0) {} +SurfaceDrawQuad::SurfaceDrawQuad() { +} scoped_ptr<SurfaceDrawQuad> SurfaceDrawQuad::Create() { return make_scoped_ptr(new SurfaceDrawQuad); @@ -18,7 +19,7 @@ scoped_ptr<SurfaceDrawQuad> SurfaceDrawQuad::Create() { void SurfaceDrawQuad::SetNew(const SharedQuadState* shared_quad_state, const gfx::Rect& rect, const gfx::Rect& visible_rect, - int surface_id) { + SurfaceId surface_id) { gfx::Rect opaque_rect; bool needs_blending = false; DrawQuad::SetAll(shared_quad_state, DrawQuad::SURFACE_CONTENT, rect, @@ -31,7 +32,7 @@ void SurfaceDrawQuad::SetAll(const SharedQuadState* shared_quad_state, const gfx::Rect& opaque_rect, const gfx::Rect& visible_rect, bool needs_blending, - int surface_id) { + SurfaceId surface_id) { DrawQuad::SetAll(shared_quad_state, DrawQuad::SURFACE_CONTENT, rect, opaque_rect, visible_rect, needs_blending); this->surface_id = surface_id; @@ -46,7 +47,7 @@ const SurfaceDrawQuad* SurfaceDrawQuad::MaterialCast(const DrawQuad* quad) { } void SurfaceDrawQuad::ExtendValue(base::DictionaryValue* value) const { - value->SetInteger("surface_id", surface_id); + value->SetInteger("surface_id", surface_id.id); } diff --git a/cc/quads/surface_draw_quad.h b/cc/quads/surface_draw_quad.h index f3092114af..e182ea3c28 100644 --- a/cc/quads/surface_draw_quad.h +++ b/cc/quads/surface_draw_quad.h @@ -8,6 +8,7 @@ #include "base/memory/scoped_ptr.h" #include "cc/base/cc_export.h" #include "cc/quads/draw_quad.h" +#include "cc/surfaces/surface_id.h" namespace cc { @@ -18,16 +19,16 @@ class CC_EXPORT SurfaceDrawQuad : public DrawQuad { void SetNew(const SharedQuadState* shared_quad_state, const gfx::Rect& rect, const gfx::Rect& visible_rect, - int surface_id); + SurfaceId surface_id); void SetAll(const SharedQuadState* shared_quad_state, const gfx::Rect& rect, const gfx::Rect& opaque_rect, const gfx::Rect& visible_rect, bool needs_blending, - int surface_id); + SurfaceId surface_id); - int surface_id; + SurfaceId surface_id; virtual void IterateResources(const ResourceIteratorCallback& callback) OVERRIDE; diff --git a/cc/resources/managed_tile_state.cc b/cc/resources/managed_tile_state.cc index d1bf9acbc5..037432764b 100644 --- a/cc/resources/managed_tile_state.cc +++ b/cc/resources/managed_tile_state.cc @@ -54,8 +54,8 @@ ManagedTileState::ManagedTileState() visible_and_ready_to_draw(false), scheduled_priority(0) {} -ManagedTileState::TileVersion::TileVersion() - : mode_(RESOURCE_MODE), has_text_(false) {} +ManagedTileState::TileVersion::TileVersion() : mode_(RESOURCE_MODE) { +} ManagedTileState::TileVersion::~TileVersion() { DCHECK(!resource_); } diff --git a/cc/resources/managed_tile_state.h b/cc/resources/managed_tile_state.h index b3d80bb3aa..7224dd64b4 100644 --- a/cc/resources/managed_tile_state.h +++ b/cc/resources/managed_tile_state.h @@ -76,7 +76,6 @@ class CC_EXPORT ManagedTileState { size_t GPUMemoryUsageInBytes() const; void SetSolidColorForTesting(SkColor color) { set_solid_color(color); } - void SetHasTextForTesting(bool has_text) { has_text_ = has_text; } void SetResourceForTesting(scoped_ptr<ScopedResource> resource) { resource_ = resource.Pass(); } @@ -94,13 +93,10 @@ class CC_EXPORT ManagedTileState { solid_color_ = color; } - void set_has_text(bool has_text) { has_text_ = has_text; } - void set_rasterize_on_demand() { mode_ = PICTURE_PILE_MODE; } Mode mode_; SkColor solid_color_; - bool has_text_; scoped_ptr<ScopedResource> resource_; scoped_refptr<RasterTask> raster_task_; }; diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc index 7147a156b0..a19fd33f3a 100644 --- a/cc/resources/picture.cc +++ b/cc/resources/picture.cc @@ -267,11 +267,8 @@ void Picture::Record(ContentLayerClient* painter, scoped_ptr<EXPERIMENTAL::SkRecording> recording; skia::RefPtr<SkCanvas> canvas; - canvas = skia::SharePtr( - recorder.beginRecording(layer_rect_.width(), - layer_rect_.height(), - &factory, - SkPicture::kUsePathBoundsForClip_RecordingFlag)); + canvas = skia::SharePtr(recorder.beginRecording( + layer_rect_.width(), layer_rect_.height(), &factory)); ContentLayerClient::GraphicsContextStatus graphics_context_status = ContentLayerClient::GRAPHICS_CONTEXT_ENABLED; @@ -448,8 +445,7 @@ scoped_ptr<base::Value> Picture::AsValue() const { skia::RefPtr<SkCanvas> canvas(skia::SharePtr(recorder.beginRecording( layer_rect_.width(), layer_rect_.height(), - NULL, // Default (no) bounding-box hierarchy is fastest. - SkPicture::kUsePathBoundsForClip_RecordingFlag))); + NULL))); // Default (no) bounding-box hierarchy is fastest. playback_->draw(canvas.get()); skia::RefPtr<SkPicture> picture(skia::AdoptRef(recorder.endRecording())); picture->serialize(&stream, &EncodeBitmap); @@ -474,13 +470,18 @@ scoped_ptr<base::Value> Picture::AsValue() const { } void Picture::EmitTraceSnapshot() const { - TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), - "cc::Picture", this, TracedPicture::AsTraceablePicture(this)); + TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( + TRACE_DISABLED_BY_DEFAULT("cc.debug") "," TRACE_DISABLED_BY_DEFAULT( + "devtools.timeline.picture"), + "cc::Picture", + this, + TracedPicture::AsTraceablePicture(this)); } void Picture::EmitTraceSnapshotAlias(Picture* original) const { TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( - TRACE_DISABLED_BY_DEFAULT("cc.debug"), + TRACE_DISABLED_BY_DEFAULT("cc.debug") "," TRACE_DISABLED_BY_DEFAULT( + "devtools.timeline.picture"), "cc::Picture", this, TracedPicture::AsTraceablePictureAlias(original)); diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc index 9ab2cf5f06..5a419516e6 100644 --- a/cc/resources/picture_layer_tiling.cc +++ b/cc/resources/picture_layer_tiling.cc @@ -122,11 +122,6 @@ Tile* PictureLayerTiling::CreateTile(int i, return tile.get(); } -void PictureLayerTiling::SetCanUseLCDText(bool can_use_lcd_text) { - for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) - it->second->set_can_use_lcd_text(can_use_lcd_text); -} - void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); bool include_borders = true; diff --git a/cc/resources/picture_layer_tiling.h b/cc/resources/picture_layer_tiling.h index 131e338d33..fc7505c99a 100644 --- a/cc/resources/picture_layer_tiling.h +++ b/cc/resources/picture_layer_tiling.h @@ -129,8 +129,6 @@ class CC_EXPORT PictureLayerTiling { void RemoveTilesInRegion(const Region& layer_region); void CreateMissingTilesInLiveTilesRect(); - void SetCanUseLCDText(bool can_use_lcd_text); - void SetClient(PictureLayerTilingClient* client); void set_resolution(TileResolution resolution) { resolution_ = resolution; } TileResolution resolution() const { return resolution_; } diff --git a/cc/resources/picture_layer_tiling_set.cc b/cc/resources/picture_layer_tiling_set.cc index d292d83fab..4192c92aeb 100644 --- a/cc/resources/picture_layer_tiling_set.cc +++ b/cc/resources/picture_layer_tiling_set.cc @@ -103,18 +103,9 @@ void PictureLayerTilingSet::RemoveTilesInRegion(const Region& region) { tilings_[i]->RemoveTilesInRegion(region); } -void PictureLayerTilingSet::SetCanUseLCDText(bool can_use_lcd_text) { - for (size_t i = 0; i < tilings_.size(); ++i) - tilings_[i]->SetCanUseLCDText(can_use_lcd_text); -} - PictureLayerTiling* PictureLayerTilingSet::AddTiling(float contents_scale) { - for (size_t i = 0; i < tilings_.size(); ++i) { - // TODO(enne): temporary sanity CHECK for http://crbug.com/358350. - // If a duplicate tiling gets added, then many assumptions in - // PictureLayerImpl fail. - CHECK_NE(tilings_[i]->contents_scale(), contents_scale); - } + for (size_t i = 0; i < tilings_.size(); ++i) + DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); tilings_.push_back(PictureLayerTiling::Create(contents_scale, layer_bounds_, @@ -318,12 +309,9 @@ PictureLayerTilingSet::CoverageIterator::operator bool() const { void PictureLayerTilingSet::UpdateTilePriorities( WhichTree tree, - const gfx::Rect& visible_content_rect, + const gfx::Rect& visible_layer_rect, float layer_contents_scale, double current_frame_time_in_seconds) { - gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( - visible_content_rect, 1.f / layer_contents_scale); - for (size_t i = 0; i < tilings_.size(); ++i) { tilings_[i]->UpdateTilePriorities(tree, visible_layer_rect, diff --git a/cc/resources/picture_layer_tiling_set.h b/cc/resources/picture_layer_tiling_set.h index db1e4ef439..5c8df6009a 100644 --- a/cc/resources/picture_layer_tiling_set.h +++ b/cc/resources/picture_layer_tiling_set.h @@ -35,8 +35,6 @@ class CC_EXPORT PictureLayerTilingSet { gfx::Size layer_bounds() const { return layer_bounds_; } - void SetCanUseLCDText(bool can_use_lcd_text); - PictureLayerTiling* AddTiling(float contents_scale); size_t num_tilings() const { return tilings_.size(); } int NumHighResTilings() const; @@ -57,7 +55,7 @@ class CC_EXPORT PictureLayerTilingSet { void RemoveAllTiles(); void UpdateTilePriorities(WhichTree tree, - const gfx::Rect& visible_content_rect, + const gfx::Rect& visible_layer_rect, float layer_contents_scale, double current_frame_time_in_seconds); diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc index 27c58a1ff4..6341e88b36 100644 --- a/cc/resources/picture_pile.cc +++ b/cc/resources/picture_pile.cc @@ -146,15 +146,16 @@ PicturePile::PicturePile() : is_suitable_for_gpu_rasterization_(true) {} PicturePile::~PicturePile() { } -bool PicturePile::Update(ContentLayerClient* painter, - SkColor background_color, - bool contents_opaque, - bool contents_fill_bounds_completely, - const Region& invalidation, - const gfx::Rect& visible_layer_rect, - int frame_number, - Picture::RecordingMode recording_mode, - RenderingStatsInstrumentation* stats_instrumentation) { +bool PicturePile::UpdateAndExpandInvalidation( + ContentLayerClient* painter, + Region* invalidation, + SkColor background_color, + bool contents_opaque, + bool contents_fill_bounds_completely, + const gfx::Rect& visible_layer_rect, + int frame_number, + Picture::RecordingMode recording_mode, + RenderingStatsInstrumentation* stats_instrumentation) { background_color_ = background_color; contents_opaque_ = contents_opaque; contents_fill_bounds_completely_ = contents_fill_bounds_completely; @@ -168,13 +169,18 @@ bool PicturePile::Update(ContentLayerClient* painter, recorded_viewport_ = interest_rect; recorded_viewport_.Intersect(tiling_rect()); + gfx::Rect interest_rect_over_tiles = + tiling_.ExpandRectToTileBounds(interest_rect); + + Region invalidation_expanded_to_full_tiles; + bool invalidated = false; - for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { - gfx::Rect invalidation = i.rect(); + for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) { + gfx::Rect invalid_rect = i.rect(); // Split this inflated invalidation across tile boundaries and apply it // to all tiles that it touches. bool include_borders = true; - for (TilingData::Iterator iter(&tiling_, invalidation, include_borders); + for (TilingData::Iterator iter(&tiling_, invalid_rect, include_borders); iter; ++iter) { const PictureMapKey& key = iter.index(); @@ -186,8 +192,22 @@ bool PicturePile::Update(ContentLayerClient* painter, // Inform the grid cell that it has been invalidated in this frame. invalidated = picture_it->second.Invalidate(frame_number) || invalidated; } + + // Expand invalidation that is outside tiles that intersect the interest + // rect. These tiles are no longer valid and should be considerered fully + // invalid, so we can know to not keep around raster tiles that intersect + // with these recording tiles. + gfx::Rect invalid_rect_outside_interest_rect_tiles = invalid_rect; + // TODO(danakj): We should have a Rect-subtract-Rect-to-2-rects operator + // instead of using Rect::Subtract which gives you the bounding box of the + // subtraction. + invalid_rect_outside_interest_rect_tiles.Subtract(interest_rect_over_tiles); + invalidation_expanded_to_full_tiles.Union(tiling_.ExpandRectToTileBounds( + invalid_rect_outside_interest_rect_tiles)); } + invalidation->Union(invalidation_expanded_to_full_tiles); + // Make a list of all invalid tiles; we will attempt to // cluster these into multiple invalidation regions. std::vector<gfx::Rect> invalid_tiles; @@ -204,12 +224,19 @@ bool PicturePile::Update(ContentLayerClient* painter, if (info.NeedsRecording(frame_number, distance_to_visible)) { gfx::Rect tile = tiling_.TileBounds(key.first, key.second); invalid_tiles.push_back(tile); - } else if (!info.GetPicture() && recorded_viewport_.Intersects(rect)) { - // Recorded viewport is just an optimization for a fully recorded - // interest rect. In this case, a tile in that rect has declined - // to be recorded (probably due to frequent invalidations). - // TODO(enne): Shrink the recorded_viewport_ rather than clearing. - recorded_viewport_ = gfx::Rect(); + } else if (!info.GetPicture()) { + if (recorded_viewport_.Intersects(rect)) { + // Recorded viewport is just an optimization for a fully recorded + // interest rect. In this case, a tile in that rect has declined + // to be recorded (probably due to frequent invalidations). + // TODO(enne): Shrink the recorded_viewport_ rather than clearing. + recorded_viewport_ = gfx::Rect(); + } + + // If a tile in the interest rect is not recorded, the entire tile needs + // to be considered invalid, so that we know not to keep around raster + // tiles that intersect this recording tile. + invalidation->Union(tiling_.TileBounds(it.index_x(), it.index_y())); } } diff --git a/cc/resources/picture_pile.h b/cc/resources/picture_pile.h index 415bbdfeec..86ef32f218 100644 --- a/cc/resources/picture_pile.h +++ b/cc/resources/picture_pile.h @@ -18,17 +18,20 @@ class CC_EXPORT PicturePile : public PicturePileBase { PicturePile(); // Re-record parts of the picture that are invalid. - // Invalidations are in layer space. + // Invalidations are in layer space, and will be expanded to cover everything + // that was either recorded/changed or that has no recording, leaving out only + // pieces that we had a recording for and it was not changed. // Return true iff the pile was modified. - bool Update(ContentLayerClient* painter, - SkColor background_color, - bool contents_opaque, - bool contents_fill_bounds_completely, - const Region& invalidation, - const gfx::Rect& visible_layer_rect, - int frame_number, - Picture::RecordingMode recording_mode, - RenderingStatsInstrumentation* stats_instrumentation); + bool UpdateAndExpandInvalidation( + ContentLayerClient* painter, + Region* invalidation, + SkColor background_color, + bool contents_opaque, + bool contents_fill_bounds_completely, + const gfx::Rect& visible_layer_rect, + int frame_number, + Picture::RecordingMode recording_mode, + RenderingStatsInstrumentation* stats_instrumentation); void set_slow_down_raster_scale_factor(int factor) { slow_down_raster_scale_factor_for_debug_ = factor; diff --git a/cc/resources/picture_pile_base.h b/cc/resources/picture_pile_base.h index dd5f883ae4..9f8acffd29 100644 --- a/cc/resources/picture_pile_base.h +++ b/cc/resources/picture_pile_base.h @@ -33,6 +33,11 @@ class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> { gfx::Rect tiling_rect() const { return tiling_.tiling_rect(); } void SetMinContentsScale(float min_contents_scale); + // If non-empty, all pictures tiles inside this rect are recorded. There may + // be recordings outside this rect, but everything inside the rect is + // recorded. + gfx::Rect recorded_viewport() const { return recorded_viewport_; } + int num_tiles_x() const { return tiling_.num_tiles_x(); } int num_tiles_y() const { return tiling_.num_tiles_y(); } gfx::Rect tile_bounds(int x, int y) const { return tiling_.TileBounds(x, y); } @@ -98,7 +103,6 @@ class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> { // indices to picture infos. PictureMap picture_map_; TilingData tiling_; - // If non-empty, all pictures tiles inside this rect are recorded. gfx::Rect recorded_viewport_; float min_contents_scale_; SkTileGridFactory::TileGridInfo tile_grid_info_; diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc index bb467474f8..90713b4fc7 100644 --- a/cc/resources/picture_pile_impl.cc +++ b/cc/resources/picture_pile_impl.cc @@ -348,10 +348,7 @@ skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { gfx::Rect tiling_rect(tiling_.tiling_rect()); SkPictureRecorder recorder; SkCanvas* canvas = - recorder.beginRecording(tiling_rect.width(), - tiling_rect.height(), - NULL, - SkPicture::kUsePathBoundsForClip_RecordingFlag); + recorder.beginRecording(tiling_rect.width(), tiling_rect.height()); if (!tiling_rect.IsEmpty()) RasterToBitmap(canvas, tiling_rect, 1.0, NULL); skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); @@ -384,14 +381,14 @@ void PicturePileImpl::AnalyzeInRect( RasterForAnalysis(&canvas, layer_rect, 1.0f, stats_instrumentation); analysis->is_solid_color = canvas.GetColorIfSolid(&analysis->solid_color); - analysis->has_text = canvas.HasText(); } // Since there are situations when we can skip analysis, the variables have to // be set to their safest values. That is, we have to assume that the tile is // not solid color. As well, we have to assume that the tile has text so we // don't early out incorrectly. -PicturePileImpl::Analysis::Analysis() : is_solid_color(false), has_text(true) {} +PicturePileImpl::Analysis::Analysis() : is_solid_color(false) { +} PicturePileImpl::Analysis::~Analysis() { } diff --git a/cc/resources/picture_pile_impl.h b/cc/resources/picture_pile_impl.h index e4e82f9c53..ba19381107 100644 --- a/cc/resources/picture_pile_impl.h +++ b/cc/resources/picture_pile_impl.h @@ -68,7 +68,6 @@ class CC_EXPORT PicturePileImpl : public PicturePileBase { ~Analysis(); bool is_solid_color; - bool has_text; SkColor solid_color; }; diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc index 03878630f6..681166ea87 100644 --- a/cc/resources/picture_pile_unittest.cc +++ b/cc/resources/picture_pile_unittest.cc @@ -51,20 +51,26 @@ class PicturePileTest : public testing::Test { gfx::Rect tiling_rect() const { return pile_->tiling_rect(); } - bool Update(const Region& invalidation, const gfx::Rect& visible_layer_rect) { + bool UpdateAndExpandInvalidation(Region* invalidation, + const gfx::Rect& visible_layer_rect) { frame_number_++; - return pile_->Update(&client_, - background_color_, - contents_opaque_, - false, - invalidation, - visible_layer_rect, - frame_number_, - Picture::RECORD_NORMALLY, - &stats_instrumentation_); + return pile_->UpdateAndExpandInvalidation(&client_, + invalidation, + background_color_, + contents_opaque_, + false, + visible_layer_rect, + frame_number_, + Picture::RECORD_NORMALLY, + &stats_instrumentation_); } - bool UpdateWholePile() { return Update(tiling_rect(), tiling_rect()); } + bool UpdateWholePile() { + Region invalidation = tiling_rect(); + bool result = UpdateAndExpandInvalidation(&invalidation, tiling_rect()); + EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); + return result; + } FakeContentLayerClient client_; FakeRenderingStatsInstrumentation stats_instrumentation_; @@ -79,8 +85,9 @@ TEST_F(PicturePileTest, SmallInvalidateInflated) { UpdateWholePile(); // Invalidate something inside a tile. - gfx::Rect invalidate_rect(50, 50, 1, 1); - Update(invalidate_rect, tiling_rect()); + Region invalidate_rect(gfx::Rect(50, 50, 1, 1)); + UpdateAndExpandInvalidation(&invalidate_rect, tiling_rect()); + EXPECT_EQ(gfx::Rect(50, 50, 1, 1).ToString(), invalidate_rect.ToString()); EXPECT_EQ(1, pile_->tiling().num_tiles_x()); EXPECT_EQ(1, pile_->tiling().num_tiles_y()); @@ -102,8 +109,9 @@ TEST_F(PicturePileTest, LargeInvalidateInflated) { UpdateWholePile(); // Invalidate something inside a tile. - gfx::Rect invalidate_rect(50, 50, 100, 100); - Update(invalidate_rect, tiling_rect()); + Region invalidate_rect(gfx::Rect(50, 50, 100, 100)); + UpdateAndExpandInvalidation(&invalidate_rect, tiling_rect()); + EXPECT_EQ(gfx::Rect(50, 50, 100, 100).ToString(), invalidate_rect.ToString()); EXPECT_EQ(1, pile_->tiling().num_tiles_x()); EXPECT_EQ(1, pile_->tiling().num_tiles_y()); @@ -143,12 +151,14 @@ TEST_F(PicturePileTest, InvalidateOnTileBoundaryInflated) { // Invalidate something just over a tile boundary by a single pixel. // This will invalidate the tile (1, 1), as well as 1 row of pixels in (1, 0). - gfx::Rect invalidate_rect( - pile_->tiling().TileBoundsWithBorder(0, 0).right(), - pile_->tiling().TileBoundsWithBorder(0, 0).bottom() - 1, - 50, - 50); - Update(invalidate_rect, tiling_rect()); + Region invalidate_rect( + gfx::Rect(pile_->tiling().TileBoundsWithBorder(0, 0).right(), + pile_->tiling().TileBoundsWithBorder(0, 0).bottom() - 1, + 50, + 50)); + Region expected_invalidation = invalidate_rect; + UpdateAndExpandInvalidation(&invalidate_rect, tiling_rect()); + EXPECT_EQ(expected_invalidation.ToString(), invalidate_rect.ToString()); for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { @@ -197,9 +207,10 @@ TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) { } } - // Update once more with a small viewport tiilng_rect.x(), tiilng_rect.y(), - // tiling_rect.width() by 1 - Update(tiling_rect(), viewport); + // Update once more with a small viewport. + Region invalidation = tiling_rect(); + UpdateAndExpandInvalidation(&invalidation, viewport); + EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { @@ -218,8 +229,22 @@ TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) { } } + // Update a partial tile that doesn't get recorded. We should expand the + // invalidation to the entire tiles that overlap it. + Region small_invalidation = + gfx::Rect(pile_->tiling().TileBounds(3, 4).x(), + pile_->tiling().TileBounds(3, 4).y() + 10, + 1, + 1); + UpdateAndExpandInvalidation(&small_invalidation, viewport); + EXPECT_TRUE(small_invalidation.Contains(gfx::UnionRects( + pile_->tiling().TileBounds(2, 4), pile_->tiling().TileBounds(3, 4)))) + << small_invalidation.ToString(); + // Now update with no invalidation and full viewport - Update(gfx::Rect(), tiling_rect()); + Region empty_invalidation; + UpdateAndExpandInvalidation(&empty_invalidation, tiling_rect()); + EXPECT_EQ(Region().ToString(), empty_invalidation.ToString()); for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { @@ -229,12 +254,7 @@ TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) { ->second; // Expect the invalidation frequency to be less than 1, since we just // updated with no invalidations. - float expected_frequency = - 1.0f - - 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED; - - EXPECT_FLOAT_EQ(expected_frequency, - picture_info.GetInvalidationFrequencyForTesting()); + EXPECT_LT(picture_info.GetInvalidationFrequencyForTesting(), 1.f); // We expect that there are pictures everywhere now. EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; @@ -291,7 +311,9 @@ TEST_F(PicturePileTest, FrequentInvalidationCanRaster) { // Update once more with a small viewport. gfx::Rect viewport(0, 0, tiling_rect().width(), 1); - Update(tiling_rect(), viewport); + Region invalidation(tiling_rect()); + UpdateAndExpandInvalidation(&invalidation, viewport); + EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); // Sanity check some pictures exist and others don't. EXPECT_TRUE(pile_->picture_map() @@ -315,16 +337,48 @@ TEST_F(PicturePileTest, NoInvalidationValidViewport) { EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty()); // No invalidation, same viewport. - Update(gfx::Rect(), tiling_rect()); + Region invalidation; + UpdateAndExpandInvalidation(&invalidation, tiling_rect()); EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty()); + EXPECT_EQ(Region().ToString(), invalidation.ToString()); // Partial invalidation, same viewport. - Update(gfx::Rect(gfx::Rect(0, 0, 1, 1)), tiling_rect()); + invalidation = gfx::Rect(0, 0, 1, 1); + UpdateAndExpandInvalidation(&invalidation, tiling_rect()); EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty()); + EXPECT_EQ(gfx::Rect(0, 0, 1, 1).ToString(), invalidation.ToString()); // No invalidation, changing viewport. - Update(gfx::Rect(), gfx::Rect(5, 5, 5, 5)); + invalidation = Region(); + UpdateAndExpandInvalidation(&invalidation, gfx::Rect(5, 5, 5, 5)); EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty()); + EXPECT_EQ(Region().ToString(), invalidation.ToString()); +} + +TEST_F(PicturePileTest, InvalidationOutsideRecordingRect) { + gfx::Rect huge_layer_rect(10000000, 20000000); + gfx::Rect viewport(300000, 400000, 5000, 6000); + + pile_->SetTilingRect(huge_layer_rect); + + // Invalidation inside the recording rect does not need to be expanded. + Region invalidation = viewport; + UpdateAndExpandInvalidation(&invalidation, viewport); + EXPECT_EQ(viewport.ToString(), invalidation.ToString()); + + // Invalidation outside the recording rect should expand to the tiles it + // covers. + gfx::Rect recorded_over_tiles = + pile_->tiling().ExpandRectToTileBounds(pile_->recorded_viewport()); + gfx::Rect invalidation_outside( + recorded_over_tiles.right(), recorded_over_tiles.y(), 30, 30); + invalidation = invalidation_outside; + UpdateAndExpandInvalidation(&invalidation, viewport); + gfx::Rect expanded_recorded_viewport = + pile_->tiling().ExpandRectToTileBounds(pile_->recorded_viewport()); + Region expected_invalidation = + pile_->tiling().ExpandRectToTileBounds(invalidation_outside); + EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); } } // namespace diff --git a/cc/resources/prioritized_tile_set_unittest.cc b/cc/resources/prioritized_tile_set_unittest.cc index 69fef52627..f0a01d2590 100644 --- a/cc/resources/prioritized_tile_set_unittest.cc +++ b/cc/resources/prioritized_tile_set_unittest.cc @@ -75,7 +75,7 @@ class PrioritizedTileSetTest : public testing::Test { 1.0, 0, 0, - Tile::USE_LCD_TEXT); + 0); } private: diff --git a/cc/resources/raster_mode.cc b/cc/resources/raster_mode.cc index 61375c2666..5da8ee76e9 100644 --- a/cc/resources/raster_mode.cc +++ b/cc/resources/raster_mode.cc @@ -12,9 +12,6 @@ namespace cc { scoped_ptr<base::Value> RasterModeAsValue(RasterMode raster_mode) { switch (raster_mode) { - case HIGH_QUALITY_NO_LCD_RASTER_MODE: - return scoped_ptr<base::Value>( - new base::StringValue("HIGH_QUALITY_NO_LCD_RASTER_MODE")); case HIGH_QUALITY_RASTER_MODE: return scoped_ptr<base::Value>( new base::StringValue("HIGH_QUALITY_RASTER_MODE")); diff --git a/cc/resources/raster_mode.h b/cc/resources/raster_mode.h index 9868059e0b..0a2b4c9b07 100644 --- a/cc/resources/raster_mode.h +++ b/cc/resources/raster_mode.h @@ -13,15 +13,12 @@ class Value; namespace cc { -// Low quality implies no lcd test; -// high quality implies lcd text. // Note that the order of these matters, from "better" to "worse" in terms of // quality. enum RasterMode { - HIGH_QUALITY_NO_LCD_RASTER_MODE = 0, - HIGH_QUALITY_RASTER_MODE = 1, - LOW_QUALITY_RASTER_MODE = 2, - NUM_RASTER_MODES = 3 + HIGH_QUALITY_RASTER_MODE = 0, + LOW_QUALITY_RASTER_MODE = 1, + NUM_RASTER_MODES = 2 }; scoped_ptr<base::Value> RasterModeAsValue(RasterMode mode); diff --git a/cc/resources/tile.cc b/cc/resources/tile.cc index 485e230704..d59dc029cc 100644 --- a/cc/resources/tile.cc +++ b/cc/resources/tile.cc @@ -71,7 +71,6 @@ scoped_ptr<base::Value> Tile::AsValue() const { res->Set("active_priority", priority_[ACTIVE_TREE].AsValue().release()); res->Set("pending_priority", priority_[PENDING_TREE].AsValue().release()); res->Set("managed_state", managed_state_.AsValue().release()); - res->SetBoolean("can_use_lcd_text", can_use_lcd_text()); res->SetBoolean("use_picture_analysis", use_picture_analysis()); return res.PassAs<base::Value>(); } @@ -94,15 +93,9 @@ RasterMode Tile::DetermineOverallRasterMode() const { RasterMode Tile::DetermineRasterModeForResolution( TileResolution resolution) const { RasterMode current_mode = managed_state_.raster_mode; - RasterMode raster_mode = HIGH_QUALITY_RASTER_MODE; - if (resolution == LOW_RESOLUTION) - raster_mode = LOW_QUALITY_RASTER_MODE; - else if (can_use_lcd_text()) - raster_mode = HIGH_QUALITY_RASTER_MODE; - else if (managed_state_.tile_versions[current_mode].has_text_ || - !managed_state_.tile_versions[current_mode].IsReadyToDraw()) - raster_mode = HIGH_QUALITY_NO_LCD_RASTER_MODE; - + RasterMode raster_mode = resolution == LOW_RESOLUTION + ? LOW_QUALITY_RASTER_MODE + : HIGH_QUALITY_RASTER_MODE; return std::min(raster_mode, current_mode); } diff --git a/cc/resources/tile.h b/cc/resources/tile.h index d7cb16b4d0..69ef56fde8 100644 --- a/cc/resources/tile.h +++ b/cc/resources/tile.h @@ -20,7 +20,7 @@ namespace cc { class CC_EXPORT Tile : public RefCountedManaged<Tile> { public: - enum TileRasterFlags { USE_LCD_TEXT = 1 << 0, USE_PICTURE_ANALYSIS = 1 << 1 }; + enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 }; typedef uint64 Id; @@ -66,17 +66,6 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> { return priority_[PENDING_TREE].required_for_activation; } - void set_can_use_lcd_text(bool can_use_lcd_text) { - if (can_use_lcd_text) - flags_ |= USE_LCD_TEXT; - else - flags_ &= ~USE_LCD_TEXT; - } - - bool can_use_lcd_text() const { - return !!(flags_ & USE_LCD_TEXT); - } - bool use_picture_analysis() const { return !!(flags_ & USE_PICTURE_ANALYSIS); } @@ -112,10 +101,6 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> { } gfx::Rect opaque_rect() const { return opaque_rect_; } - bool has_text(RasterMode mode) const { - return managed_state_.tile_versions[mode].has_text_; - } - float contents_scale() const { return contents_scale_; } gfx::Rect content_rect() const { return content_rect_; } diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc index 4a4cfeaf27..b1cc1aec6b 100644 --- a/cc/resources/tile_manager.cc +++ b/cc/resources/tile_manager.cc @@ -30,18 +30,6 @@ namespace { // a tile is of solid color. const bool kUseColorEstimator = true; -class DisableLCDTextFilter : public SkDrawFilter { - public: - // SkDrawFilter interface. - virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { - if (type != SkDrawFilter::kText_Type) - return true; - - paint->setLCDRenderText(false); - return true; - } -}; - class RasterTaskImpl : public RasterTask { public: RasterTaskImpl( @@ -146,9 +134,6 @@ class RasterTaskImpl : public RasterTask { case LOW_QUALITY_RASTER_MODE: draw_filter = skia::AdoptRef(new skia::PaintSimplifier); break; - case HIGH_QUALITY_NO_LCD_RASTER_MODE: - draw_filter = skia::AdoptRef(new DisableLCDTextFilter); - break; case HIGH_QUALITY_RASTER_MODE: break; case NUM_RASTER_MODES: @@ -420,13 +405,6 @@ TileManager::~TileManager() { DCHECK_EQ(0u, bytes_releasable_); DCHECK_EQ(0u, resources_releasable_); - - for (std::vector<PictureLayerImpl*>::iterator it = layers_.begin(); - it != layers_.end(); - ++it) { - (*it)->DidUnregisterLayer(); - } - layers_.clear(); } void TileManager::Release(Tile* tile) { @@ -676,19 +654,6 @@ void TileManager::GetTilesWithAssignedBins(PrioritizedTileSet* tiles) { } } -void TileManager::CleanUpLayers() { - for (size_t i = 0; i < layers_.size(); ++i) { - if (layers_[i]->IsDrawnRenderSurfaceLayerListMember()) - continue; - - layers_[i]->DidUnregisterLayer(); - std::swap(layers_[i], layers_.back()); - layers_.pop_back(); - --i; - prioritized_tiles_dirty_ = true; - } -} - void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) { TRACE_EVENT0("cc", "TileManager::ManageTiles"); @@ -698,8 +663,6 @@ void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) { prioritized_tiles_dirty_ = true; } - CleanUpLayers(); - // We need to call CheckForCompletedTasks() once in-between each call // to ScheduleTasks() to prevent canceled tasks from being scheduled. if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { @@ -991,7 +954,7 @@ void TileManager::FreeResourcesForTile(Tile* tile) { void TileManager::FreeUnusedResourcesForTile(Tile* tile) { DCHECK(tile->IsReadyToDraw()); ManagedTileState& mts = tile->managed_state(); - RasterMode used_mode = HIGH_QUALITY_NO_LCD_RASTER_MODE; + RasterMode used_mode = LOW_QUALITY_RASTER_MODE; for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { if (mts.tile_versions[mode].IsReadyToDraw()) { used_mode = static_cast<RasterMode>(mode); @@ -1175,7 +1138,6 @@ void TileManager::OnRasterTaskCompleted( ++update_visible_tiles_stats_.completed_count; - tile_version.set_has_text(analysis.has_text); if (analysis.is_solid_color) { tile_version.set_solid_color(analysis.solid_color); resource_pool_->ReleaseResource(resource.Pass()); @@ -1219,38 +1181,28 @@ scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, return tile; } -void TileManager::RegisterPictureLayerImpl(PictureLayerImpl* layer) { - DCHECK(std::find(layers_.begin(), layers_.end(), layer) == layers_.end()); - layers_.push_back(layer); -} - -void TileManager::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { - std::vector<PictureLayerImpl*>::iterator it = - std::find(layers_.begin(), layers_.end(), layer); - DCHECK(it != layers_.end()); - layers_.erase(it); -} - void TileManager::GetPairedPictureLayers( std::vector<PairedPictureLayer>* paired_layers) const { + const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); + paired_layers->clear(); // Reserve a maximum possible paired layers. - paired_layers->reserve(layers_.size()); + paired_layers->reserve(layers.size()); - for (std::vector<PictureLayerImpl*>::const_iterator it = layers_.begin(); - it != layers_.end(); + for (std::vector<PictureLayerImpl*>::const_iterator it = layers.begin(); + it != layers.end(); ++it) { PictureLayerImpl* layer = *it; - // This is a recycle tree layer, we can safely skip since the tiles on this - // layer have to be accessible via the active tree. - if (!layer->IsOnActiveOrPendingTree()) + // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 + if (!layer->HasValidTilePriorities()) continue; PictureLayerImpl* twin_layer = layer->GetTwinLayer(); - // If the twin layer is recycled, it is not a valid twin. - if (twin_layer && !twin_layer->IsOnActiveOrPendingTree()) + // Ignore the twin layer when tile priorities are invalid. + // TODO(vmpstr): Iterators should handle this instead. crbug.com/381704 + if (twin_layer && !twin_layer->HasValidTilePriorities()) twin_layer = NULL; PairedPictureLayer paired_layer; @@ -1450,6 +1402,8 @@ bool TileManager::RasterTileIterator::RasterOrderComparator::operator()( // If the bin is the same but the resolution is not, then the order will be // determined by whether we prioritize low res or not. + // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile + // class but instead produced by the iterators. if (b_priority.priority_bin == a_priority.priority_bin && b_priority.resolution != a_priority.resolution) { // Non ideal resolution should be sorted lower than other resolutions. @@ -1623,12 +1577,27 @@ bool TileManager::EvictionTileIterator::EvictionOrderComparator::operator()( a_tile->priority_for_tree_priority(tree_priority_); const TilePriority& b_priority = b_tile->priority_for_tree_priority(tree_priority_); - bool prioritize_low_res = tree_priority_ != SMOOTHNESS_TAKES_PRIORITY; + bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; + + // Now we have to return true iff b is lower priority than a. + + // If the bin is the same but the resolution is not, then the order will be + // determined by whether we prioritize low res or not. + // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile + // class but instead produced by the iterators. + if (b_priority.priority_bin == a_priority.priority_bin && + b_priority.resolution != a_priority.resolution) { + // Non ideal resolution should be sorted higher than other resolutions. + if (a_priority.resolution == NON_IDEAL_RESOLUTION) + return false; - if (b_priority.resolution != a_priority.resolution) { - return (prioritize_low_res && b_priority.resolution == LOW_RESOLUTION) || - (!prioritize_low_res && b_priority.resolution == HIGH_RESOLUTION) || - (a_priority.resolution == NON_IDEAL_RESOLUTION); + if (b_priority.resolution == NON_IDEAL_RESOLUTION) + return true; + + if (prioritize_low_res) + return a_priority.resolution == LOW_RESOLUTION; + + return a_priority.resolution == HIGH_RESOLUTION; } return a_priority.IsHigherPriorityThan(b_priority); } @@ -1639,8 +1608,10 @@ void TileManager::SetRasterizerForTesting(Rasterizer* rasterizer) { } bool TileManager::IsReadyToActivate() const { - for (std::vector<PictureLayerImpl*>::const_iterator it = layers_.begin(); - it != layers_.end(); + const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); + + for (std::vector<PictureLayerImpl*>::const_iterator it = layers.begin(); + it != layers.end(); ++it) { if (!(*it)->AllTilesRequiredForActivationAreReadyToDraw()) return false; diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h index 4c7360c22f..30f4730423 100644 --- a/cc/resources/tile_manager.h +++ b/cc/resources/tile_manager.h @@ -31,6 +31,9 @@ class ResourceProvider; class CC_EXPORT TileManagerClient { public: + // Returns the set of layers that the tile manager should consider for raster. + virtual const std::vector<PictureLayerImpl*>& GetPictureLayers() = 0; + // Called when all tiles marked as required for activation are ready to draw. virtual void NotifyReadyToActivate() = 0; @@ -182,9 +185,6 @@ class CC_EXPORT TileManager : public RasterizerClient, int source_frame_number, int flags); - void RegisterPictureLayerImpl(PictureLayerImpl* layer); - void UnregisterPictureLayerImpl(PictureLayerImpl* layer); - scoped_ptr<base::Value> BasicStateAsValue() const; scoped_ptr<base::Value> AllTilesAsValue() const; void GetMemoryStats(size_t* memory_required_bytes, @@ -202,7 +202,7 @@ class CC_EXPORT TileManager : public RasterizerClient, for (size_t i = 0; i < tiles.size(); ++i) { ManagedTileState& mts = tiles[i]->managed_state(); ManagedTileState::TileVersion& tile_version = - mts.tile_versions[HIGH_QUALITY_NO_LCD_RASTER_MODE]; + mts.tile_versions[HIGH_QUALITY_RASTER_MODE]; tile_version.resource_ = resource_pool_->AcquireResource(gfx::Size(1, 1)); @@ -290,7 +290,6 @@ class CC_EXPORT TileManager : public RasterizerClient, scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; void UpdatePrioritizedTileSetIfNeeded(); - void CleanUpLayers(); bool IsReadyToActivate() const; void CheckIfReadyToActivate(); @@ -343,8 +342,6 @@ class CC_EXPORT TileManager : public RasterizerClient, std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_; - std::vector<PictureLayerImpl*> layers_; - UniqueNotifier ready_to_activate_check_notifier_; DISALLOW_COPY_AND_ASSIGN(TileManager); diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc index c7fa68f04e..0ac79b16de 100644 --- a/cc/resources/tile_manager_perftest.cc +++ b/cc/resources/tile_manager_perftest.cc @@ -76,12 +76,11 @@ class FakeRasterizerImpl : public Rasterizer, public RasterizerTaskClient { base::LazyInstance<FakeRasterizerImpl> g_fake_rasterizer = LAZY_INSTANCE_INITIALIZER; -class TileManagerPerfTest : public testing::Test, public TileManagerClient { +class TileManagerPerfTest : public testing::Test { public: TileManagerPerfTest() : memory_limit_policy_(ALLOW_ANYTHING), max_tiles_(10000), - ready_to_activate_(false), id_(7), proxy_(base::MessageLoopProxy::current()), host_impl_(ImplSidePaintingSettings(10000), @@ -291,10 +290,6 @@ class TileManagerPerfTest : public testing::Test, public TileManagerClient { "manage_tiles", "", test_name, timer_.LapsPerSecond(), "runs/s", true); } - // TileManagerClient implementation. - virtual void NotifyReadyToActivate() OVERRIDE { ready_to_activate_ = true; } - virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE {} - TileManager* tile_manager() { return host_impl_.tile_manager(); } protected: @@ -303,7 +298,6 @@ class TileManagerPerfTest : public testing::Test, public TileManagerClient { TestSharedBitmapManager shared_bitmap_manager_; TileMemoryLimitPolicy memory_limit_policy_; int max_tiles_; - bool ready_to_activate_; int id_; FakeImplProxy proxy_; FakeLayerTreeHostImpl host_impl_; diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc index ce54d3822b..4beae8f617 100644 --- a/cc/resources/tile_manager_unittest.cc +++ b/cc/resources/tile_manager_unittest.cc @@ -83,6 +83,9 @@ class TileManagerTest : public testing::TestWithParam<bool>, } // 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 {} @@ -99,7 +102,7 @@ class TileManagerTest : public testing::TestWithParam<bool>, 1.0, 0, 0, - Tile::USE_LCD_TEXT); + 0); tile->SetPriority(ACTIVE_TREE, active_priority); tile->SetPriority(PENDING_TREE, pending_priority); tiles.push_back(tile); @@ -126,16 +129,6 @@ class TileManagerTest : public testing::TestWithParam<bool>, return has_memory_count; } - int TilesWithLCDCount(const TileVector& tiles) { - int has_lcd_count = 0; - for (TileVector::const_iterator it = tiles.begin(); it != tiles.end(); - ++it) { - if ((*it)->GetRasterModeForTesting() == HIGH_QUALITY_RASTER_MODE) - ++has_lcd_count; - } - return has_lcd_count; - } - bool ready_to_activate() const { return ready_to_activate_; } // The parametrization specifies whether the max tile limit should @@ -158,6 +151,7 @@ class TileManagerTest : public testing::TestWithParam<bool>, TileMemoryLimitPolicy memory_limit_policy_; int max_tiles_; bool ready_to_activate_; + std::vector<PictureLayerImpl*> picture_layers_; }; TEST_P(TileManagerTest, EnoughMemoryAllowAnything) { @@ -424,150 +418,6 @@ TEST_P(TileManagerTest, TotalOOMMemoryToNewContent) { EXPECT_EQ(10, AssignedMemoryCount(pending_tree_tiles)); } -TEST_P(TileManagerTest, RasterAsLCD) { - Initialize(20, 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, TilesWithLCDCount(active_tree_tiles)); - EXPECT_EQ(5, TilesWithLCDCount(pending_tree_tiles)); -} - -TEST_P(TileManagerTest, RasterAsNoLCD) { - Initialize(20, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); - TileVector active_tree_tiles = - CreateTiles(5, TilePriorityForNowBin(), TilePriority()); - TileVector pending_tree_tiles = - CreateTiles(5, TilePriority(), TilePriorityForNowBin()); - - for (TileVector::iterator it = active_tree_tiles.begin(); - it != active_tree_tiles.end(); - ++it) { - (*it)->set_can_use_lcd_text(false); - } - for (TileVector::iterator it = pending_tree_tiles.begin(); - it != pending_tree_tiles.end(); - ++it) { - (*it)->set_can_use_lcd_text(false); - } - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(0, TilesWithLCDCount(active_tree_tiles)); - EXPECT_EQ(0, TilesWithLCDCount(pending_tree_tiles)); -} - -TEST_P(TileManagerTest, ReRasterAsNoLCD) { - Initialize(20, 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, TilesWithLCDCount(active_tree_tiles)); - EXPECT_EQ(5, TilesWithLCDCount(pending_tree_tiles)); - - for (TileVector::iterator it = active_tree_tiles.begin(); - it != active_tree_tiles.end(); - ++it) { - (*it)->set_can_use_lcd_text(false); - } - for (TileVector::iterator it = pending_tree_tiles.begin(); - it != pending_tree_tiles.end(); - ++it) { - (*it)->set_can_use_lcd_text(false); - } - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(0, TilesWithLCDCount(active_tree_tiles)); - EXPECT_EQ(0, TilesWithLCDCount(pending_tree_tiles)); -} - -TEST_P(TileManagerTest, NoTextDontReRasterAsNoLCD) { - Initialize(20, 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, TilesWithLCDCount(active_tree_tiles)); - EXPECT_EQ(5, TilesWithLCDCount(pending_tree_tiles)); - - for (TileVector::iterator it = active_tree_tiles.begin(); - it != active_tree_tiles.end(); - ++it) { - ManagedTileState::TileVersion& tile_version = - (*it)->GetTileVersionForTesting(HIGH_QUALITY_RASTER_MODE); - tile_version.SetSolidColorForTesting(SkColorSetARGB(0, 0, 0, 0)); - (*it)->set_can_use_lcd_text(false); - EXPECT_TRUE((*it)->IsReadyToDraw()); - } - for (TileVector::iterator it = pending_tree_tiles.begin(); - it != pending_tree_tiles.end(); - ++it) { - ManagedTileState::TileVersion& tile_version = - (*it)->GetTileVersionForTesting(HIGH_QUALITY_RASTER_MODE); - tile_version.SetSolidColorForTesting(SkColorSetARGB(0, 0, 0, 0)); - (*it)->set_can_use_lcd_text(false); - EXPECT_TRUE((*it)->IsReadyToDraw()); - } - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(5, TilesWithLCDCount(active_tree_tiles)); - EXPECT_EQ(5, TilesWithLCDCount(pending_tree_tiles)); -} - -TEST_P(TileManagerTest, TextReRasterAsNoLCD) { - Initialize(20, 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, TilesWithLCDCount(active_tree_tiles)); - EXPECT_EQ(5, TilesWithLCDCount(pending_tree_tiles)); - - for (TileVector::iterator it = active_tree_tiles.begin(); - it != active_tree_tiles.end(); - ++it) { - ManagedTileState::TileVersion& tile_version = - (*it)->GetTileVersionForTesting(HIGH_QUALITY_RASTER_MODE); - tile_version.SetSolidColorForTesting(SkColorSetARGB(0, 0, 0, 0)); - tile_version.SetHasTextForTesting(true); - (*it)->set_can_use_lcd_text(false); - - EXPECT_TRUE((*it)->IsReadyToDraw()); - } - for (TileVector::iterator it = pending_tree_tiles.begin(); - it != pending_tree_tiles.end(); - ++it) { - ManagedTileState::TileVersion& tile_version = - (*it)->GetTileVersionForTesting(HIGH_QUALITY_RASTER_MODE); - tile_version.SetSolidColorForTesting(SkColorSetARGB(0, 0, 0, 0)); - tile_version.SetHasTextForTesting(true); - (*it)->set_can_use_lcd_text(false); - - EXPECT_TRUE((*it)->IsReadyToDraw()); - } - - tile_manager()->AssignMemoryToTiles(global_state_); - - EXPECT_EQ(0, TilesWithLCDCount(active_tree_tiles)); - EXPECT_EQ(0, TilesWithLCDCount(pending_tree_tiles)); -} - TEST_P(TileManagerTest, RespectMemoryLimit) { if (UsingResourceLimit()) return; @@ -619,8 +469,7 @@ INSTANTIATE_TEST_CASE_P(TileManagerTests, TileManagerTest, ::testing::Values(true, false)); -class TileManagerTileIteratorTest : public testing::Test, - public TileManagerClient { +class TileManagerTileIteratorTest : public testing::Test { public: TileManagerTileIteratorTest() : memory_limit_policy_(ALLOW_ANYTHING), @@ -717,10 +566,6 @@ class TileManagerTileIteratorTest : public testing::Test, pending_layer_->SetAllTilesVisible(); } - // TileManagerClient implementation. - virtual void NotifyReadyToActivate() OVERRIDE { ready_to_activate_ = true; } - virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE {} - TileManager* tile_manager() { return host_impl_.tile_manager(); } protected: @@ -738,15 +583,12 @@ class TileManagerTileIteratorTest : public testing::Test, }; TEST_F(TileManagerTileIteratorTest, PairedPictureLayers) { - FakeImplProxy proxy; - TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); - host_impl.CreatePendingTree(); - host_impl.ActivatePendingTree(); - host_impl.CreatePendingTree(); - - LayerTreeImpl* active_tree = host_impl.active_tree(); - LayerTreeImpl* pending_tree = host_impl.pending_tree(); + host_impl_.CreatePendingTree(); + host_impl_.ActivatePendingTree(); + host_impl_.CreatePendingTree(); + + LayerTreeImpl* active_tree = host_impl_.active_tree(); + LayerTreeImpl* pending_tree = host_impl_.pending_tree(); EXPECT_NE(active_tree, pending_tree); scoped_ptr<FakePictureLayerImpl> active_layer = @@ -757,9 +599,6 @@ TEST_F(TileManagerTileIteratorTest, PairedPictureLayers) { TileManager* tile_manager = TileManagerTileIteratorTest::tile_manager(); EXPECT_TRUE(tile_manager); - tile_manager->RegisterPictureLayerImpl(active_layer.get()); - tile_manager->RegisterPictureLayerImpl(pending_layer.get()); - std::vector<TileManager::PairedPictureLayer> paired_layers; tile_manager->GetPairedPictureLayers(&paired_layers); @@ -788,9 +627,6 @@ TEST_F(TileManagerTileIteratorTest, PairedPictureLayers) { EXPECT_EQ(active_layer.get(), paired_layers[0].active_layer); EXPECT_EQ(pending_layer.get(), paired_layers[0].pending_layer); - - tile_manager->UnregisterPictureLayerImpl(active_layer.get()); - tile_manager->UnregisterPictureLayerImpl(pending_layer.get()); } TEST_F(TileManagerTileIteratorTest, RasterTileIterator) { diff --git a/cc/scheduler/delay_based_time_source.cc b/cc/scheduler/delay_based_time_source.cc index c40e4e6cb6..2be3d3d472 100644 --- a/cc/scheduler/delay_based_time_source.cc +++ b/cc/scheduler/delay_based_time_source.cc @@ -6,6 +6,7 @@ #include <algorithm> #include <cmath> +#include <string> #include "base/bind.h" #include "base/debug/trace_event.h" @@ -105,9 +106,11 @@ base::TimeTicks DelayBasedTimeSource::SetActive(bool active) { bool DelayBasedTimeSource::Active() const { return active_; } -base::TimeTicks DelayBasedTimeSource::LastTickTime() { return last_tick_time_; } +base::TimeTicks DelayBasedTimeSource::LastTickTime() const { + return last_tick_time_; +} -base::TimeTicks DelayBasedTimeSource::NextTickTime() { +base::TimeTicks DelayBasedTimeSource::NextTickTime() const { return Active() ? current_parameters_.tick_target : base::TimeTicks(); } @@ -278,4 +281,39 @@ void DelayBasedTimeSource::PostNextTickTask(base::TimeTicks now) { current_parameters_ = next_parameters_; } +std::string DelayBasedTimeSource::TypeString() const { + return "DelayBasedTimeSource"; +} + +std::string DelayBasedTimeSourceHighRes::TypeString() const { + return "DelayBasedTimeSourceHighRes"; +} + +scoped_ptr<base::Value> DelayBasedTimeSource::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); + state->SetString("type", TypeString()); + state->SetDouble("last_tick_time_us", LastTickTime().ToInternalValue()); + state->SetDouble("next_tick_time_us", NextTickTime().ToInternalValue()); + + scoped_ptr<base::DictionaryValue> state_current_parameters( + new base::DictionaryValue); + state_current_parameters->SetDouble( + "interval_us", current_parameters_.interval.InMicroseconds()); + state_current_parameters->SetDouble( + "tick_target_us", current_parameters_.tick_target.ToInternalValue()); + state->Set("current_parameters", state_current_parameters.release()); + + scoped_ptr<base::DictionaryValue> state_next_parameters( + new base::DictionaryValue); + state_next_parameters->SetDouble("interval_us", + next_parameters_.interval.InMicroseconds()); + state_next_parameters->SetDouble( + "tick_target_us", next_parameters_.tick_target.ToInternalValue()); + state->Set("next_parameters", state_next_parameters.release()); + + state->SetBoolean("active", active_); + + return state.PassAs<base::Value>(); +} + } // namespace cc diff --git a/cc/scheduler/delay_based_time_source.h b/cc/scheduler/delay_based_time_source.h index 9faaeac465..18c8002f29 100644 --- a/cc/scheduler/delay_based_time_source.h +++ b/cc/scheduler/delay_based_time_source.h @@ -5,44 +5,59 @@ #ifndef CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ #define CC_SCHEDULER_DELAY_BASED_TIME_SOURCE_H_ +#include <string> + #include "base/memory/weak_ptr.h" +#include "base/values.h" #include "cc/base/cc_export.h" -#include "cc/scheduler/time_source.h" namespace base { class SingleThreadTaskRunner; } namespace cc { +class CC_EXPORT TimeSourceClient { + public: + virtual void OnTimerTick() = 0; + + protected: + virtual ~TimeSourceClient() {} +}; + // This timer implements a time source that achieves the specified interval // in face of millisecond-precision delayed callbacks and random queueing // delays. DelayBasedTimeSource uses base::TimeTicks::Now as its timebase. -class CC_EXPORT DelayBasedTimeSource : public TimeSource { +class CC_EXPORT DelayBasedTimeSource + : public base::RefCounted<DelayBasedTimeSource> { public: static scoped_refptr<DelayBasedTimeSource> Create( base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner); - virtual void SetClient(TimeSourceClient* client) OVERRIDE; + virtual void SetClient(TimeSourceClient* client); // TimeSource implementation virtual void SetTimebaseAndInterval(base::TimeTicks timebase, - base::TimeDelta interval) OVERRIDE; + base::TimeDelta interval); - virtual base::TimeTicks SetActive(bool active) OVERRIDE; - virtual bool Active() const OVERRIDE; + virtual base::TimeTicks SetActive(bool active); + virtual bool Active() const; // Get the last and next tick times. NextTickTime() returns null when // inactive. - virtual base::TimeTicks LastTickTime() OVERRIDE; - virtual base::TimeTicks NextTickTime() OVERRIDE; + virtual base::TimeTicks LastTickTime() const; + virtual base::TimeTicks NextTickTime() const; // Virtual for testing. virtual base::TimeTicks Now() const; + virtual scoped_ptr<base::Value> AsValue() const; + protected: DelayBasedTimeSource(base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner); virtual ~DelayBasedTimeSource(); + virtual std::string TypeString() const; + base::TimeTicks NextTickTarget(base::TimeTicks now); void PostNextTickTask(base::TimeTicks now); void OnTimerFired(); @@ -70,6 +85,7 @@ class CC_EXPORT DelayBasedTimeSource : public TimeSource { base::WeakPtrFactory<DelayBasedTimeSource> weak_factory_; private: + friend class base::RefCounted<DelayBasedTimeSource>; DISALLOW_COPY_AND_ASSIGN(DelayBasedTimeSource); }; @@ -86,6 +102,8 @@ class DelayBasedTimeSourceHighRes : public DelayBasedTimeSource { base::SingleThreadTaskRunner* task_runner); virtual ~DelayBasedTimeSourceHighRes(); + virtual std::string TypeString() const OVERRIDE; + private: DISALLOW_COPY_AND_ASSIGN(DelayBasedTimeSourceHighRes); }; diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc index cc6ae1a39d..4a682cdb44 100644 --- a/cc/scheduler/scheduler.cc +++ b/cc/scheduler/scheduler.cc @@ -61,11 +61,14 @@ void Scheduler::SyntheticBeginFrameSource::OnTimerTick() { scheduler_->BeginFrame(begin_frame_args); } +scoped_ptr<base::Value> Scheduler::SyntheticBeginFrameSource::AsValue() const { + return time_source_->AsValue(); +} + BeginFrameArgs Scheduler::SyntheticBeginFrameSource::CreateSyntheticBeginFrameArgs( base::TimeTicks frame_time) { - base::TimeTicks deadline = - time_source_->NextTickTime() - scheduler_->EstimatedParentDrawTime(); + base::TimeTicks deadline = time_source_->NextTickTime(); return BeginFrameArgs::Create( frame_time, deadline, scheduler_->VSyncInterval()); } @@ -137,6 +140,7 @@ void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, } void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { + DCHECK_GE(draw_time.ToInternalValue(), 0); estimated_parent_draw_time_ = draw_time; } @@ -398,6 +402,9 @@ void Scheduler::BeginFrame(const BeginFrameArgs& args) { TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", ToTrace(args)); DCHECK(settings_.throttle_frame_production); + BeginFrameArgs adjusted_args(args); + adjusted_args.deadline -= EstimatedParentDrawTime(); + bool should_defer_begin_frame; if (settings_.using_synchronous_renderer_compositor) { should_defer_begin_frame = false; @@ -410,13 +417,13 @@ void Scheduler::BeginFrame(const BeginFrameArgs& args) { } if (should_defer_begin_frame) { - begin_retro_frame_args_.push_back(args); + begin_retro_frame_args_.push_back(adjusted_args); TRACE_EVENT_INSTANT0( "cc", "Scheduler::BeginFrame deferred", TRACE_EVENT_SCOPE_THREAD); return; } - BeginImplFrame(args); + BeginImplFrame(adjusted_args); } // BeginRetroFrame is called for BeginFrames that we've deferred because @@ -676,6 +683,9 @@ bool Scheduler::WillDrawIfNeeded() const { scoped_ptr<base::Value> Scheduler::AsValue() const { scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); state->Set("state_machine", state_machine_.AsValue().release()); + if (synthetic_begin_frame_source_) + state->Set("synthetic_begin_frame_source_", + synthetic_begin_frame_source_->AsValue().release()); scoped_ptr<base::DictionaryValue> scheduler_state(new base::DictionaryValue); scheduler_state->SetDouble( diff --git a/cc/scheduler/scheduler.h b/cc/scheduler/scheduler.h index 510c66a7a8..3de06acbdc 100644 --- a/cc/scheduler/scheduler.h +++ b/cc/scheduler/scheduler.h @@ -14,10 +14,10 @@ #include "base/time/time.h" #include "cc/base/cc_export.h" #include "cc/output/begin_frame_args.h" +#include "cc/scheduler/delay_based_time_source.h" #include "cc/scheduler/draw_result.h" #include "cc/scheduler/scheduler_settings.h" #include "cc/scheduler/scheduler_state_machine.h" -#include "cc/scheduler/time_source.h" namespace base { class SingleThreadTaskRunner; @@ -94,9 +94,6 @@ class CC_EXPORT Scheduler { void DidManageTiles(); void DidLoseOutputSurface(); void DidCreateAndInitializeOutputSurface(); - bool HasInitializedOutputSurface() const { - return state_machine_.HasInitializedOutputSurface(); - } bool CommitPending() const { return state_machine_.CommitPending(); } bool RedrawPending() const { return state_machine_.RedrawPending(); } @@ -164,11 +161,13 @@ class CC_EXPORT Scheduler { // TimeSourceClient implementation of OnTimerTick triggers a BeginFrame. virtual void OnTimerTick() OVERRIDE; + scoped_ptr<base::Value> AsValue() const; + private: BeginFrameArgs CreateSyntheticBeginFrameArgs(base::TimeTicks frame_time); Scheduler* scheduler_; - scoped_refptr<TimeSource> time_source_; + scoped_refptr<DelayBasedTimeSource> time_source_; }; Scheduler( diff --git a/cc/scheduler/scheduler_settings.cc b/cc/scheduler/scheduler_settings.cc index ccc3e92156..f1bf60e786 100644 --- a/cc/scheduler/scheduler_settings.cc +++ b/cc/scheduler/scheduler_settings.cc @@ -4,6 +4,8 @@ #include "cc/scheduler/scheduler_settings.h" +#include "cc/trees/layer_tree_settings.h" + namespace cc { SchedulerSettings::SchedulerSettings() @@ -17,6 +19,21 @@ SchedulerSettings::SchedulerSettings() throttle_frame_production(true) { } +SchedulerSettings::SchedulerSettings(const LayerTreeSettings& settings) + : begin_frame_scheduling_enabled(settings.begin_frame_scheduling_enabled), + main_frame_before_draw_enabled(settings.main_frame_before_draw_enabled), + main_frame_before_activation_enabled( + settings.main_frame_before_activation_enabled), + impl_side_painting(settings.impl_side_painting), + timeout_and_draw_when_animation_checkerboards( + settings.timeout_and_draw_when_animation_checkerboards), + maximum_number_of_failed_draws_before_draw_is_forced_( + settings.maximum_number_of_failed_draws_before_draw_is_forced_), + using_synchronous_renderer_compositor( + settings.using_synchronous_renderer_compositor), + throttle_frame_production(settings.throttle_frame_production) { +} + SchedulerSettings::~SchedulerSettings() {} scoped_ptr<base::Value> SchedulerSettings::AsValue() const { diff --git a/cc/scheduler/scheduler_settings.h b/cc/scheduler/scheduler_settings.h index 519d22a043..c282cf6a12 100644 --- a/cc/scheduler/scheduler_settings.h +++ b/cc/scheduler/scheduler_settings.h @@ -10,10 +10,12 @@ #include "cc/base/cc_export.h" namespace cc { +class LayerTreeSettings; class CC_EXPORT SchedulerSettings { public: SchedulerSettings(); + explicit SchedulerSettings(const LayerTreeSettings& settings); ~SchedulerSettings(); bool begin_frame_scheduling_enabled; diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc index f7919a6a36..dea25b4087 100644 --- a/cc/scheduler/scheduler_state_machine.cc +++ b/cc/scheduler/scheduler_state_machine.cc @@ -464,9 +464,12 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { if (!HasInitializedOutputSurface()) return false; - // SwapAck throttle the BeginMainFrames + // SwapAck throttle the BeginMainFrames unless we just swapped. // TODO(brianderson): Remove this restriction to improve throughput. - if (pending_swaps_ >= max_pending_swaps_) + bool just_swapped_in_deadline = + begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && + HasSwappedThisFrame(); + if (pending_swaps_ >= max_pending_swaps_ && !just_swapped_in_deadline) return false; if (skip_begin_main_frame_to_reduce_latency_) diff --git a/cc/scheduler/scheduler_state_machine_unittest.cc b/cc/scheduler/scheduler_state_machine_unittest.cc index f862bafa00..b5834241d8 100644 --- a/cc/scheduler/scheduler_state_machine_unittest.cc +++ b/cc/scheduler/scheduler_state_machine_unittest.cc @@ -1723,7 +1723,32 @@ TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyAfterAbortedCommit) { EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); } -TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyForSmoothness) { +void FinishPreviousCommitAndDrawWithoutExitingDeadline( + StateMachine* state_ptr) { + // Gross, but allows us to use macros below. + StateMachine& state = *state_ptr; + + state.NotifyBeginMainFrameStarted(); + state.NotifyReadyToCommit(); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); + state.NotifyReadyToActivate(); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); + + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); + + EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); + state.OnBeginImplFrameDeadline(); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); + state.DidSwapBuffers(); +} + +TEST(SchedulerStateMachineTest, TestSmoothnessTakesPriority) { SchedulerSettings settings; settings.impl_side_painting = true; StateMachine state(settings); @@ -1735,18 +1760,50 @@ TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyForSmoothness) { // This test ensures that impl-draws are prioritized over main thread updates // in prefer smoothness mode. - state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); state.SetNeedsRedraw(true); state.SetNeedsCommit(); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - // The deadline is not triggered early until we enter prefer smoothness mode. + // Verify the deadline is not triggered early until we enter + // prefer smoothness mode. EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); state.SetSmoothnessTakesPriority(true); EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); + + // Trigger the deadline. + state.OnBeginImplFrameDeadline(); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); + state.DidSwapBuffers(); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); + state.DidSwapBuffersComplete(); + + // Request a new commit and finish the previous one. + state.SetNeedsCommit(); + FinishPreviousCommitAndDrawWithoutExitingDeadline(&state); + EXPECT_ACTION_UPDATE_STATE( + SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); + state.DidSwapBuffersComplete(); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); + + // Finish the previous commit and draw it. + FinishPreviousCommitAndDrawWithoutExitingDeadline(&state); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); + + // Verify we do not send another BeginMainFrame if was are swap throttled + // and did not just swap. + state.SetNeedsCommit(); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); + EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); + state.OnBeginImplFrameDeadline(); + EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); } TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyOnLostOutputSurface) { diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc index 70fa1ae000..7d5a163dac 100644 --- a/cc/scheduler/scheduler_unittest.cc +++ b/cc/scheduler/scheduler_unittest.cc @@ -18,15 +18,19 @@ #include "testing/gtest/include/gtest/gtest.h" #define EXPECT_ACTION(action, client, action_index, expected_num_actions) \ - EXPECT_EQ(expected_num_actions, client.num_actions_()); \ - ASSERT_LT(action_index, client.num_actions_()); \ do { \ - EXPECT_STREQ(action, client.Action(action_index)); \ + EXPECT_EQ(expected_num_actions, client.num_actions_()); \ + if (action_index >= 0) { \ + ASSERT_LT(action_index, client.num_actions_()) << scheduler; \ + EXPECT_STREQ(action, client.Action(action_index)); \ + } \ for (int i = expected_num_actions; i < client.num_actions_(); ++i) \ - ADD_FAILURE() << "Unexpected action: " << client.Action(i) << \ - " with state:\n" << client.StateForAction(action_index); \ + ADD_FAILURE() << "Unexpected action: " << client.Action(i) \ + << " with state:\n" << client.StateForAction(i); \ } while (false) +#define EXPECT_NO_ACTION(client) EXPECT_ACTION("", client, -1, 0) + #define EXPECT_SINGLE_ACTION(action, client) \ EXPECT_ACTION(action, client, 0, 1) @@ -286,7 +290,7 @@ TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); client.Reset(); scheduler->DidCreateAndInitializeOutputSurface(); - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); } TEST(SchedulerTest, RequestCommit) { @@ -316,7 +320,7 @@ TEST(SchedulerTest, RequestCommit) { // If we don't swap on the deadline, we wait for the next BeginFrame. client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(client.needs_begin_frame()); client.Reset(); @@ -1220,7 +1224,7 @@ TEST(SchedulerTest, BeginRetroFrame) { // If we don't swap on the deadline, we wait for the next BeginImplFrame. client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(client.needs_begin_frame()); client.Reset(); @@ -1295,7 +1299,7 @@ TEST(SchedulerTest, BeginRetroFrame_SwapThrottled) { EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); args.frame_time += base::TimeDelta::FromSeconds(1); scheduler->BeginFrame(args); - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); client.Reset(); @@ -1326,7 +1330,7 @@ TEST(SchedulerTest, BeginRetroFrame_SwapThrottled) { // Queue BeginFrame while we are still handling the previous BeginFrame. args.frame_time += base::TimeDelta::FromSeconds(1); scheduler->BeginFrame(args); - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(client.needs_begin_frame()); client.Reset(); @@ -1366,7 +1370,7 @@ void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled, client.Reset(); scheduler->SetNeedsCommit(); EXPECT_FALSE(client.needs_begin_frame()); - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); client.Reset(); // When the client-driven BeginFrame are disabled, the scheduler posts it's @@ -1380,7 +1384,7 @@ void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled, // If we don't swap on the deadline, we wait for the next BeginFrame. client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_FALSE(client.needs_begin_frame()); client.Reset(); @@ -1417,7 +1421,7 @@ void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled, // Make sure SetNeedsBeginFrame isn't called on the client // when the BeginFrame is no longer needed. client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); EXPECT_FALSE(client.needs_begin_frame()); client.Reset(); } @@ -1464,7 +1468,7 @@ void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled, client.Reset(); scheduler->SetNeedsCommit(); EXPECT_FALSE(client.needs_begin_frame()); - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); client.Reset(); // Trigger the first BeginImplFrame and BeginMainFrame @@ -1549,7 +1553,7 @@ TEST(SchedulerTest, DidLoseOutputSurfaceAfterOutputSurfaceIsInitialized) { EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); client.Reset(); scheduler->DidCreateAndInitializeOutputSurface(); - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); scheduler->DidLoseOutputSurface(); EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); @@ -1579,7 +1583,7 @@ TEST(SchedulerTest, DidLoseOutputSurfaceAfterBeginFrameStarted) { client.Reset(); scheduler->DidLoseOutputSurface(); // Do nothing when impl frame is in deadine pending state. - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); client.Reset(); scheduler->NotifyBeginMainFrameStarted(); @@ -1618,17 +1622,17 @@ void DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency( client.Reset(); scheduler->DidLoseOutputSurface(); // Do nothing when impl frame is in deadine pending state. - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); client.Reset(); client.task_runner().RunPendingTasks(); // Run posted deadline. // OnBeginImplFrameDeadline didn't schedule any actions because main frame is // not yet completed. - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); // BeginImplFrame is not started. scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); client.Reset(); @@ -1690,7 +1694,7 @@ void DidLoseOutputSurfaceAfterReadyToCommit(bool impl_side_painting) { EXPECT_SINGLE_ACTION("ScheduledActionActivatePendingTree", client); } else { // Do nothing when impl frame is in deadine pending state. - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); } client.Reset(); @@ -1729,7 +1733,7 @@ TEST(SchedulerTest, DidLoseOutputSurfaceAfterSetNeedsManageTiles) { client.Reset(); scheduler->DidLoseOutputSurface(); - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); client.Reset(); client.task_runner().RunPendingTasks(); // Run posted deadline. @@ -1772,7 +1776,7 @@ TEST(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) { // If we don't swap on the deadline, we wait for the next BeginImplFrame. client.Reset(); client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(client.needs_begin_frame()); @@ -1793,7 +1797,7 @@ TEST(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) { // Posted BeginRetroFrame is aborted. client.Reset(); client.task_runner().RunPendingTasks(); - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); } TEST(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { @@ -1831,7 +1835,7 @@ TEST(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { // If we don't swap on the deadline, we wait for the next BeginImplFrame. client.Reset(); client.task_runner().RunPendingTasks(); // Run posted deadline. - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); EXPECT_TRUE(client.needs_begin_frame()); @@ -1853,7 +1857,7 @@ TEST(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { client.Reset(); EXPECT_FALSE(scheduler->IsBeginRetroFrameArgsEmpty()); scheduler->DidLoseOutputSurface(); - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); EXPECT_TRUE(scheduler->IsBeginRetroFrameArgsEmpty()); // BeginImplFrame deadline should abort drawing. @@ -1866,7 +1870,7 @@ TEST(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { // No more BeginRetroFrame because BeginRetroFrame queue is cleared. client.Reset(); client.task_runner().RunPendingTasks(); - EXPECT_EQ(0, client.num_actions_()); + EXPECT_NO_ACTION(client); } TEST(SchedulerTest, diff --git a/cc/scheduler/time_source.h b/cc/scheduler/time_source.h deleted file mode 100644 index 3b8d048886..0000000000 --- a/cc/scheduler/time_source.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2011 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_SCHEDULER_TIME_SOURCE_H_ -#define CC_SCHEDULER_TIME_SOURCE_H_ - -#include "base/memory/ref_counted.h" -#include "base/time/time.h" -#include "cc/base/cc_export.h" - -namespace cc { - -class CC_EXPORT TimeSourceClient { - public: - virtual void OnTimerTick() = 0; - - protected: - virtual ~TimeSourceClient() {} -}; - -// An generic interface for getting a reliably-ticking timesource of -// a specified rate. -// -// Be sure to call SetActive(false) before releasing your reference to the -// timer, or it will keep on ticking! -class CC_EXPORT TimeSource : public base::RefCounted<TimeSource> { - public: - virtual void SetClient(TimeSourceClient* client) = 0; - - // If transitioning from not active to active, SetActive will return the - // timestamp of the most recenly missed tick that did not have OnTimerTick - // called. - virtual base::TimeTicks SetActive(bool active) = 0; - - virtual bool Active() const = 0; - virtual void SetTimebaseAndInterval(base::TimeTicks timebase, - base::TimeDelta interval) = 0; - virtual base::TimeTicks LastTickTime() = 0; - virtual base::TimeTicks NextTickTime() = 0; - - protected: - virtual ~TimeSource() {} - - private: - friend class base::RefCounted<TimeSource>; -}; - -} // namespace cc - -#endif // CC_SCHEDULER_TIME_SOURCE_H_ diff --git a/cc/surfaces/display.cc b/cc/surfaces/display.cc index ba4ed03153..a39695f573 100644 --- a/cc/surfaces/display.cc +++ b/cc/surfaces/display.cc @@ -2,30 +2,43 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CC_SURFACES_DISPLAY_H_ -#define CC_SURFACES_DISPLAY_H_ - #include "cc/surfaces/display.h" #include "base/message_loop/message_loop.h" #include "cc/output/compositor_frame.h" #include "cc/output/direct_renderer.h" #include "cc/output/gl_renderer.h" +#include "cc/output/software_renderer.h" #include "cc/surfaces/display_client.h" #include "cc/surfaces/surface.h" -#include "ui/gfx/frame_time.h" namespace cc { +static ResourceProvider::ResourceId ResourceRemapHelper( + bool* invalid_frame, + const ResourceProvider::ResourceIdMap& child_to_parent_map, + ResourceProvider::ResourceIdArray* resources_in_frame, + ResourceProvider::ResourceId id) { + ResourceProvider::ResourceIdMap::const_iterator it = + child_to_parent_map.find(id); + if (it == child_to_parent_map.end()) { + *invalid_frame = true; + return 0; + } + + DCHECK_EQ(it->first, id); + ResourceProvider::ResourceId remapped_id = it->second; + resources_in_frame->push_back(id); + return remapped_id; +} + Display::Display(DisplayClient* client, SurfaceManager* manager, SharedBitmapManager* bitmap_manager) - : scheduled_draw_(false), - client_(client), + : client_(client), manager_(manager), aggregator_(manager), - bitmap_manager_(bitmap_manager), - schedule_draw_factory_(this) { + bitmap_manager_(bitmap_manager) { } Display::~Display() { @@ -35,10 +48,61 @@ void Display::Resize(const gfx::Size& size) { current_surface_.reset(new Surface(manager_, this, size)); } +void Display::InitializeOutputSurface() { + if (output_surface_) + return; + scoped_ptr<OutputSurface> output_surface = client_->CreateOutputSurface(); + if (!output_surface->BindToClient(this)) + return; + + int highp_threshold_min = 0; + bool use_rgba_4444_texture_format = false; + size_t id_allocation_chunk_size = 1; + bool use_distance_field_text = false; + scoped_ptr<ResourceProvider> resource_provider = + ResourceProvider::Create(output_surface.get(), + bitmap_manager_, + highp_threshold_min, + use_rgba_4444_texture_format, + id_allocation_chunk_size, + use_distance_field_text); + if (!resource_provider) + return; + + if (output_surface->context_provider()) { + TextureMailboxDeleter* texture_mailbox_deleter = NULL; + scoped_ptr<GLRenderer> renderer = + GLRenderer::Create(this, + &settings_, + output_surface.get(), + resource_provider.get(), + texture_mailbox_deleter, + highp_threshold_min); + if (!renderer) + return; + renderer_ = renderer.Pass(); + } else { + scoped_ptr<SoftwareRenderer> renderer = SoftwareRenderer::Create( + this, &settings_, output_surface.get(), resource_provider.get()); + if (!renderer) + return; + renderer_ = renderer.Pass(); + } + + output_surface_ = output_surface.Pass(); + resource_provider_ = resource_provider.Pass(); + child_id_ = resource_provider_->CreateChild( + base::Bind(&Display::ReturnResources, base::Unretained(this))); +} + bool Display::Draw() { if (!current_surface_) return false; + InitializeOutputSurface(); + if (!output_surface_) + return false; + // TODO(jamesr): Use the surface aggregator instead. scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); CompositorFrame* current_frame = current_surface_->GetEligibleFrame(); @@ -47,70 +111,53 @@ bool Display::Draw() { RenderPass::CopyAll(current_frame->delegated_frame_data->render_pass_list, &frame_data->render_pass_list); - if (!layer_tree_host_) { - // TODO(jbauman): Switch to use ResourceProvider and GLRenderer directly, - // as using LayerTreeHost from here is a layering violation. - LayerTreeSettings settings; - layer_tree_host_ = LayerTreeHost::CreateSingleThreaded( - this, this, bitmap_manager_, settings); - resource_collection_ = new DelegatedFrameResourceCollection; - resource_collection_->SetClient(this); - layer_tree_host_->SetLayerTreeHostClientReady(); - } - if (!delegated_frame_provider_ || - delegated_frame_provider_->frame_size() != - frame_data->render_pass_list.back()->output_rect.size()) { - delegated_frame_provider_ = - new DelegatedFrameProvider(resource_collection_, frame_data.Pass()); - delegated_layer_ = - DelegatedRendererLayer::Create(delegated_frame_provider_); - - layer_tree_host_->SetRootLayer(delegated_layer_); - delegated_layer_->SetDisplaySize(current_surface_->size()); - delegated_layer_->SetBounds(current_surface_->size()); - delegated_layer_->SetContentsOpaque(true); - delegated_layer_->SetIsDrawable(true); - } else { - delegated_frame_provider_->SetFrameData(frame_data.Pass()); + if (frame_data->render_pass_list.empty()) + return false; + + const ResourceProvider::ResourceIdMap& resource_map = + resource_provider_->GetChildToParentMap(child_id_); + resource_provider_->ReceiveFromChild(child_id_, frame_data->resource_list); + + bool invalid_frame = false; + ResourceProvider::ResourceIdArray resources_in_frame; + DrawQuad::ResourceIteratorCallback remap_resources_to_parent_callback = + base::Bind(&ResourceRemapHelper, + &invalid_frame, + resource_map, + &resources_in_frame); + for (size_t i = 0; i < frame_data->render_pass_list.size(); ++i) { + RenderPass* pass = frame_data->render_pass_list[i]; + for (size_t j = 0; j < pass->quad_list.size(); ++j) { + DrawQuad* quad = pass->quad_list[j]; + quad->IterateResources(remap_resources_to_parent_callback); + } } - layer_tree_host_->SetViewportSize(current_surface_->size()); + if (invalid_frame) + return false; + resource_provider_->DeclareUsedResourcesFromChild(child_id_, + resources_in_frame); + + float device_scale_factor = 1.0f; + gfx::Rect device_viewport_rect = gfx::Rect(current_surface_->size()); + gfx::Rect device_clip_rect = device_viewport_rect; + bool disable_picture_quad_image_filtering = false; + + renderer_->DrawFrame(&frame_data->render_pass_list, + device_scale_factor, + device_viewport_rect, + device_clip_rect, + disable_picture_quad_image_filtering); + CompositorFrameMetadata metadata; + renderer_->SwapBuffers(metadata); return true; } -scoped_ptr<OutputSurface> Display::CreateOutputSurface(bool fallback) { - return client_->CreateOutputSurface(); -} - -void Display::ScheduleComposite() { - if (scheduled_draw_) - return; - - scheduled_draw_ = true; - - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&Display::DoComposite, schedule_draw_factory_.GetWeakPtr())); -} - -void Display::ScheduleAnimation() { - ScheduleComposite(); -} - -void Display::DoComposite() { - scheduled_draw_ = false; - layer_tree_host_->Composite(gfx::FrameTime::Now()); -} - -int Display::CurrentSurfaceID() { - return current_surface_ ? current_surface_->surface_id() : 0; +SurfaceId Display::CurrentSurfaceId() { + return current_surface_ ? current_surface_->surface_id() : SurfaceId(); } void Display::ReturnResources(const ReturnedResourceArray& resources) { - // We never generate any resources, so we should never have any returned. - DCHECK(resources.empty()); } } // namespace cc - -#endif // CC_SURFACES_DISPLAY_H_ diff --git a/cc/surfaces/display.h b/cc/surfaces/display.h index ff2632b8cd..85b172ae8c 100644 --- a/cc/surfaces/display.h +++ b/cc/surfaces/display.h @@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#ifndef CC_SURFACES_DISPLAY_H_ +#define CC_SURFACES_DISPLAY_H_ + #include "base/memory/scoped_ptr.h" -#include "cc/layers/delegated_frame_resource_collection.h" -#include "cc/layers/delegated_renderer_layer.h" #include "cc/output/output_surface_client.h" +#include "cc/output/renderer.h" #include "cc/surfaces/surface_aggregator.h" #include "cc/surfaces/surface_client.h" +#include "cc/surfaces/surface_id.h" #include "cc/surfaces/surfaces_export.h" -#include "cc/trees/layer_tree_host_client.h" -#include "cc/trees/layer_tree_host_single_thread_client.h" namespace gfx { class Size; @@ -21,18 +22,15 @@ namespace cc { class DirectRenderer; class DisplayClient; -class LayerTreeHost; class OutputSurface; class ResourceProvider; class SharedBitmapManager; class Surface; class SurfaceManager; -class CC_SURFACES_EXPORT Display - : public SurfaceClient, - public DelegatedFrameResourceCollectionClient, - NON_EXPORTED_BASE(public LayerTreeHostClient), - NON_EXPORTED_BASE(public LayerTreeHostSingleThreadClient) { +class CC_SURFACES_EXPORT Display : public SurfaceClient, + public OutputSurfaceClient, + public RendererClient { public: Display(DisplayClient* client, SurfaceManager* manager, @@ -42,51 +40,51 @@ class CC_SURFACES_EXPORT Display void Resize(const gfx::Size& new_size); bool Draw(); - int CurrentSurfaceID(); - - // LayerTreeHostClient implementation. - virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} - virtual void DidBeginMainFrame() OVERRIDE {} - virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} - virtual void Layout() OVERRIDE {} - virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, - float page_scale) OVERRIDE {} - virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) OVERRIDE; - virtual void DidInitializeOutputSurface() OVERRIDE {} - virtual void WillCommit() OVERRIDE {} - virtual void DidCommit() OVERRIDE {} - virtual void DidCommitAndDrawFrame() OVERRIDE {} - virtual void DidCompleteSwapBuffers() OVERRIDE {} - - // LayerTreeHostSingleThreadClient implementation. - virtual void ScheduleComposite() OVERRIDE; - virtual void ScheduleAnimation() OVERRIDE; - virtual void DidPostSwapBuffers() OVERRIDE {} - virtual void DidAbortSwapBuffers() OVERRIDE {} - - // DelegatedFrameResourceCollectionClient implementation. - virtual void UnusedResourcesAreAvailable() OVERRIDE {} + SurfaceId CurrentSurfaceId(); + + // OutputSurfaceClient implementation. + virtual void DeferredInitialize() OVERRIDE {} + virtual void ReleaseGL() OVERRIDE {} + virtual void CommitVSyncParameters(base::TimeTicks timebase, + base::TimeDelta interval) OVERRIDE {} + virtual void SetNeedsRedrawRect(const gfx::Rect& damage_rect) OVERRIDE {} + virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {} + virtual void DidSwapBuffers() OVERRIDE {} + virtual void DidSwapBuffersComplete() OVERRIDE {} + virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE {} + virtual void DidLoseOutputSurface() OVERRIDE {} + virtual void SetExternalDrawConstraints( + const gfx::Transform& transform, + const gfx::Rect& viewport, + const gfx::Rect& clip, + bool valid_for_tile_management) OVERRIDE {} + virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE {} + virtual void SetTreeActivationCallback( + const base::Closure& callback) OVERRIDE {} + + // RendererClient implementation. + virtual void SetFullRootLayerDamage() OVERRIDE {} // SurfaceClient implementation. virtual void ReturnResources(const ReturnedResourceArray& resources) OVERRIDE; private: - void DoComposite(); - - bool scheduled_draw_; + void InitializeOutputSurface(); DisplayClient* client_; SurfaceManager* manager_; SurfaceAggregator aggregator_; SharedBitmapManager* bitmap_manager_; + LayerTreeSettings settings_; scoped_ptr<Surface> current_surface_; - scoped_ptr<LayerTreeHost> layer_tree_host_; - scoped_refptr<DelegatedFrameResourceCollection> resource_collection_; - scoped_refptr<DelegatedFrameProvider> delegated_frame_provider_; - scoped_refptr<DelegatedRendererLayer> delegated_layer_; - base::WeakPtrFactory<Display> schedule_draw_factory_; + scoped_ptr<OutputSurface> output_surface_; + scoped_ptr<ResourceProvider> resource_provider_; + scoped_ptr<DirectRenderer> renderer_; + int child_id_; DISALLOW_COPY_AND_ASSIGN(Display); }; } // namespace cc + +#endif // CC_SURFACES_DISPLAY_H_ diff --git a/cc/surfaces/surface.cc b/cc/surfaces/surface.cc index 82a13222f2..ed5a0f6dd8 100644 --- a/cc/surfaces/surface.cc +++ b/cc/surfaces/surface.cc @@ -15,7 +15,7 @@ Surface::Surface(SurfaceManager* manager, : manager_(manager), client_(client), size_(size) { - surface_id_ = manager_->RegisterAndAllocateIDForSurface(this); + surface_id_ = manager_->RegisterAndAllocateIdForSurface(this); } Surface::~Surface() { @@ -23,9 +23,70 @@ Surface::~Surface() { } void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame) { + scoped_ptr<CompositorFrame> previous_frame = current_frame_.Pass(); current_frame_ = frame.Pass(); + ReceiveResourcesFromClient( + current_frame_->delegated_frame_data->resource_list); + if (previous_frame) { + ReturnedResourceArray previous_resources; + TransferableResource::ReturnResources( + previous_frame->delegated_frame_data->resource_list, + &previous_resources); + UnrefResources(previous_resources); + } } CompositorFrame* Surface::GetEligibleFrame() { return current_frame_.get(); } +void Surface::ReturnUnusedResourcesToClient() { + client_->ReturnResources(resources_available_to_return_); + resources_available_to_return_.clear(); +} + +void Surface::RefCurrentFrameResources() { + if (!current_frame_) + return; + const TransferableResourceArray& current_frame_resources = + current_frame_->delegated_frame_data->resource_list; + for (size_t i = 0; i < current_frame_resources.size(); ++i) { + const TransferableResource& resource = current_frame_resources[i]; + ResourceIdCountMap::iterator it = + resource_id_use_count_map_.find(resource.id); + DCHECK(it != resource_id_use_count_map_.end()); + it->second.refs_holding_resource_alive++; + } +} + +Surface::ResourceRefs::ResourceRefs() + : refs_received_from_child(0), refs_holding_resource_alive(0) { +} + +void Surface::ReceiveResourcesFromClient( + const TransferableResourceArray& resources) { + for (TransferableResourceArray::const_iterator it = resources.begin(); + it != resources.end(); + ++it) { + ResourceRefs& ref = resource_id_use_count_map_[it->id]; + ref.refs_holding_resource_alive++; + ref.refs_received_from_child++; + } +} + +void Surface::UnrefResources(const ReturnedResourceArray& resources) { + for (ReturnedResourceArray::const_iterator it = resources.begin(); + it != resources.end(); + ++it) { + ResourceProvider::ResourceId id = it->id; + ResourceIdCountMap::iterator count_it = resource_id_use_count_map_.find(id); + DCHECK(count_it != resource_id_use_count_map_.end()); + count_it->second.refs_holding_resource_alive -= it->count; + if (count_it->second.refs_holding_resource_alive == 0) { + resources_available_to_return_.push_back(*it); + resources_available_to_return_.back().count = + count_it->second.refs_received_from_child; + resource_id_use_count_map_.erase(count_it); + } + } +} + } // namespace cc diff --git a/cc/surfaces/surface.h b/cc/surfaces/surface.h index 8ed4399a6a..007f33d10a 100644 --- a/cc/surfaces/surface.h +++ b/cc/surfaces/surface.h @@ -5,15 +5,19 @@ #ifndef CC_SURFACES_SURFACE_H_ #define CC_SURFACES_SURFACE_H_ +#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" +#include "cc/resources/resource_provider.h" +#include "cc/resources/return_callback.h" +#include "cc/surfaces/surface_client.h" +#include "cc/surfaces/surface_id.h" #include "cc/surfaces/surfaces_export.h" #include "ui/gfx/size.h" namespace cc { class CompositorFrame; class SurfaceManager; -class SurfaceClient; class CC_SURFACES_EXPORT Surface { public: @@ -23,20 +27,46 @@ class CC_SURFACES_EXPORT Surface { ~Surface(); const gfx::Size& size() const { return size_; } - int surface_id() const { return surface_id_; } + SurfaceId surface_id() const { return surface_id_; } void QueueFrame(scoped_ptr<CompositorFrame> frame); // Returns the most recent frame that is eligible to be rendered. CompositorFrame* GetEligibleFrame(); + // Takes a reference to all of the current frame's resources for an external + // consumer (e.g. a ResourceProvider). The caller to this should call + // UnrefResources() when they are done with the resources. + void RefCurrentFrameResources(); + void UnrefResources(const ReturnedResourceArray& resources); + + // Returns all resources that are currently not in use to the client. + void ReturnUnusedResourcesToClient(); + private: + void ReceiveResourcesFromClient(const TransferableResourceArray& resources); + SurfaceManager* manager_; SurfaceClient* client_; gfx::Size size_; - int surface_id_; + SurfaceId surface_id_; // TODO(jamesr): Support multiple frames in flight. scoped_ptr<CompositorFrame> current_frame_; + struct ResourceRefs { + ResourceRefs(); + + int refs_received_from_child; + int refs_holding_resource_alive; + }; + // Keeps track of the number of users currently in flight for each resource + // ID we've received from the client. When this counter hits zero for a + // particular resource, that ID is available to return to the client. + typedef base::hash_map<ResourceProvider::ResourceId, ResourceRefs> + ResourceIdCountMap; + ResourceIdCountMap resource_id_use_count_map_; + + ReturnedResourceArray resources_available_to_return_; + DISALLOW_COPY_AND_ASSIGN(Surface); }; diff --git a/cc/surfaces/surface_aggregator.cc b/cc/surfaces/surface_aggregator.cc index 6b2178d410..72300c0a5d 100644 --- a/cc/surfaces/surface_aggregator.cc +++ b/cc/surfaces/surface_aggregator.cc @@ -24,9 +24,9 @@ SurfaceAggregator::SurfaceAggregator(SurfaceManager* manager) SurfaceAggregator::~SurfaceAggregator() {} -DelegatedFrameData* SurfaceAggregator::GetReferencedDataForSurfaceID( - int surface_id) { - Surface* referenced_surface = manager_->GetSurfaceForID(surface_id); +DelegatedFrameData* SurfaceAggregator::GetReferencedDataForSurfaceId( + SurfaceId surface_id) { + Surface* referenced_surface = manager_->GetSurfaceForId(surface_id); if (!referenced_surface) return NULL; // Invalid surface id, skip this quad. CompositorFrame* referenced_frame = referenced_surface->GetEligibleFrame(); @@ -74,16 +74,16 @@ RenderPass::Id SurfaceAggregator::RemapPassId( void SurfaceAggregator::HandleSurfaceQuad(const SurfaceDrawQuad* surface_quad, RenderPass* dest_pass) { - int surface_id = surface_quad->surface_id; + SurfaceId surface_id = surface_quad->surface_id; // If this surface's id is already in our referenced set then it creates // a cycle in the graph and should be dropped. - if (referenced_surfaces_.count(surface_id)) + if (referenced_surfaces_.count(surface_id.id)) return; DelegatedFrameData* referenced_data = - GetReferencedDataForSurfaceID(surface_id); + GetReferencedDataForSurfaceId(surface_id); if (!referenced_data) return; - std::set<int>::iterator it = referenced_surfaces_.insert(surface_id).first; + std::set<int>::iterator it = referenced_surfaces_.insert(surface_id.id).first; const RenderPassList& referenced_passes = referenced_data->render_pass_list; for (size_t j = 0; j + 1 < referenced_passes.size(); ++j) { @@ -91,7 +91,7 @@ void SurfaceAggregator::HandleSurfaceQuad(const SurfaceDrawQuad* surface_quad, scoped_ptr<RenderPass> copy_pass(RenderPass::Create()); - RenderPass::Id remapped_pass_id = RemapPassId(source.id, surface_id); + RenderPass::Id remapped_pass_id = RemapPassId(source.id, surface_id.id); copy_pass->SetAll(remapped_pass_id, source.output_rect, @@ -111,7 +111,7 @@ void SurfaceAggregator::HandleSurfaceQuad(const SurfaceDrawQuad* surface_quad, source.shared_quad_state_list, gfx::Transform(), copy_pass.get(), - surface_id); + surface_id.id); dest_pass_list_->push_back(copy_pass.Pass()); } @@ -125,7 +125,7 @@ void SurfaceAggregator::HandleSurfaceQuad(const SurfaceDrawQuad* surface_quad, last_pass.shared_quad_state_list, surface_quad->quadTransform(), dest_pass, - surface_id); + surface_id.id); referenced_surfaces_.erase(it); } @@ -215,8 +215,8 @@ void SurfaceAggregator::CopyPasses(const RenderPassList& source_pass_list, } } -scoped_ptr<CompositorFrame> SurfaceAggregator::Aggregate(int surface_id) { - Surface* surface = manager_->GetSurfaceForID(surface_id); +scoped_ptr<CompositorFrame> SurfaceAggregator::Aggregate(SurfaceId surface_id) { + Surface* surface = manager_->GetSurfaceForId(surface_id); if (!surface) return scoped_ptr<CompositorFrame>(); CompositorFrame* root_surface_frame = surface->GetEligibleFrame(); @@ -231,10 +231,10 @@ scoped_ptr<CompositorFrame> SurfaceAggregator::Aggregate(int surface_id) { const RenderPassList& source_pass_list = root_surface_frame->delegated_frame_data->render_pass_list; - std::set<int>::iterator it = referenced_surfaces_.insert(surface_id).first; + std::set<int>::iterator it = referenced_surfaces_.insert(surface_id.id).first; dest_pass_list_ = &frame->delegated_frame_data->render_pass_list; - CopyPasses(source_pass_list, surface_id); + CopyPasses(source_pass_list, surface_id.id); referenced_surfaces_.erase(it); DCHECK(referenced_surfaces_.empty()); diff --git a/cc/surfaces/surface_aggregator.h b/cc/surfaces/surface_aggregator.h index 4115bc39a1..fe52050503 100644 --- a/cc/surfaces/surface_aggregator.h +++ b/cc/surfaces/surface_aggregator.h @@ -10,6 +10,7 @@ #include "base/containers/scoped_ptr_hash_map.h" #include "base/memory/scoped_ptr.h" #include "cc/quads/render_pass.h" +#include "cc/surfaces/surface_id.h" #include "cc/surfaces/surfaces_export.h" namespace cc { @@ -24,10 +25,10 @@ class CC_SURFACES_EXPORT SurfaceAggregator { explicit SurfaceAggregator(SurfaceManager* manager); ~SurfaceAggregator(); - scoped_ptr<CompositorFrame> Aggregate(int surface_id); + scoped_ptr<CompositorFrame> Aggregate(SurfaceId surface_id); private: - DelegatedFrameData* GetReferencedDataForSurfaceID(int surface_id); + DelegatedFrameData* GetReferencedDataForSurfaceId(SurfaceId surface_id); RenderPass::Id RemapPassId(RenderPass::Id surface_local_pass_id, int surface_id); diff --git a/cc/surfaces/surface_aggregator_test_helpers.cc b/cc/surfaces/surface_aggregator_test_helpers.cc index 51d1cb66bc..747f84a3f1 100644 --- a/cc/surfaces/surface_aggregator_test_helpers.cc +++ b/cc/surfaces/surface_aggregator_test_helpers.cc @@ -24,7 +24,7 @@ namespace test { void AddTestSurfaceQuad(TestRenderPass* pass, const gfx::Size& surface_size, - int surface_id) { + SurfaceId surface_id) { gfx::Transform content_to_target_transform; gfx::Size content_bounds = surface_size; gfx::Rect visible_content_rect = gfx::Rect(surface_size); diff --git a/cc/surfaces/surface_aggregator_test_helpers.h b/cc/surfaces/surface_aggregator_test_helpers.h index fd2c8d3a5b..10c56590d7 100644 --- a/cc/surfaces/surface_aggregator_test_helpers.h +++ b/cc/surfaces/surface_aggregator_test_helpers.h @@ -7,6 +7,7 @@ #include "cc/quads/draw_quad.h" #include "cc/quads/render_pass.h" +#include "cc/surfaces/surface_id.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/size.h" @@ -25,7 +26,7 @@ struct Quad { return quad; } - static Quad SurfaceQuad(int surface_id) { + static Quad SurfaceQuad(SurfaceId surface_id) { Quad quad; quad.material = DrawQuad::SURFACE_CONTENT; quad.surface_id = surface_id; @@ -41,7 +42,7 @@ struct Quad { DrawQuad::Material material; // Set when material==DrawQuad::SURFACE_CONTENT. - int surface_id; + SurfaceId surface_id; // Set when material==DrawQuad::SOLID_COLOR. SkColor color; // Set when material==DrawQuad::RENDER_PASS. @@ -50,7 +51,6 @@ struct Quad { private: Quad() : material(DrawQuad::INVALID), - surface_id(-1), color(SK_ColorWHITE), render_pass_id(-1, -1) {} }; diff --git a/cc/surfaces/surface_aggregator_unittest.cc b/cc/surfaces/surface_aggregator_unittest.cc index 1809409bef..aa5cea04c2 100644 --- a/cc/surfaces/surface_aggregator_unittest.cc +++ b/cc/surfaces/surface_aggregator_unittest.cc @@ -19,7 +19,12 @@ namespace cc { namespace { -const int kInvalidSurfaceId = -1; + +SurfaceId InvalidSurfaceId() { + static SurfaceId invalid; + invalid.id = -1; + return invalid; +} class SurfaceAggregatorTest : public testing::Test { public: @@ -31,7 +36,7 @@ class SurfaceAggregatorTest : public testing::Test { }; TEST_F(SurfaceAggregatorTest, InvalidSurfaceId) { - scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(kInvalidSurfaceId); + scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(InvalidSurfaceId()); EXPECT_FALSE(frame); } @@ -258,7 +263,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { // be dropped. TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), - test::Quad::SurfaceQuad(kInvalidSurfaceId), + test::Quad::SurfaceQuad(InvalidSurfaceId()), test::Quad::SolidColorQuad(SK_ColorBLUE)}; test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; diff --git a/cc/surfaces/surface_client.h b/cc/surfaces/surface_client.h index 538bedaf65..88758729b8 100644 --- a/cc/surfaces/surface_client.h +++ b/cc/surfaces/surface_client.h @@ -16,6 +16,7 @@ class CC_SURFACES_EXPORT SurfaceClient { virtual void ReturnResources(const ReturnedResourceArray& resources) = 0; }; -} + +} // namespace cc #endif // CC_SURFACES_SURFACE_CLIENT_H_ diff --git a/cc/surfaces/surface_id.h b/cc/surfaces/surface_id.h new file mode 100644 index 0000000000..aa9474d61f --- /dev/null +++ b/cc/surfaces/surface_id.h @@ -0,0 +1,29 @@ +// Copyright 2014 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_SURFACES_SURFACE_ID_H_ +#define CC_SURFACES_SURFACE_ID_H_ + +namespace cc { + +struct SurfaceId { + SurfaceId() : id(0) {} + explicit SurfaceId(int id) : id(id) {} + + bool is_null() const { return id == 0; } + + int id; +}; + +inline bool operator==(const SurfaceId& a, const SurfaceId& b) { + return a.id == b.id; +} + +inline bool operator!=(const SurfaceId& a, const SurfaceId& b) { + return !(a == b); +} + +} // namespace cc + +#endif // CC_SURFACES_SURFACE_ID_H_ diff --git a/cc/surfaces/surface_manager.cc b/cc/surfaces/surface_manager.cc index 366fa81c70..b41aefc424 100644 --- a/cc/surfaces/surface_manager.cc +++ b/cc/surfaces/surface_manager.cc @@ -14,21 +14,21 @@ SurfaceManager::SurfaceManager() SurfaceManager::~SurfaceManager() {} -int SurfaceManager::RegisterAndAllocateIDForSurface(Surface* surface) { +SurfaceId SurfaceManager::RegisterAndAllocateIdForSurface(Surface* surface) { DCHECK(surface); int surface_id = next_surface_id_++; surface_map_[surface_id] = surface; - return surface_id; + return SurfaceId(surface_id); } -void SurfaceManager::DeregisterSurface(int surface_id) { - SurfaceMap::iterator it = surface_map_.find(surface_id); +void SurfaceManager::DeregisterSurface(SurfaceId surface_id) { + SurfaceMap::iterator it = surface_map_.find(surface_id.id); DCHECK(it != surface_map_.end()); surface_map_.erase(it); } -Surface* SurfaceManager::GetSurfaceForID(int surface_id) { - SurfaceMap::iterator it = surface_map_.find(surface_id); +Surface* SurfaceManager::GetSurfaceForId(SurfaceId surface_id) { + SurfaceMap::iterator it = surface_map_.find(surface_id.id); if (it == surface_map_.end()) return NULL; return it->second; diff --git a/cc/surfaces/surface_manager.h b/cc/surfaces/surface_manager.h index fe12dbfc5d..b14259d63d 100644 --- a/cc/surfaces/surface_manager.h +++ b/cc/surfaces/surface_manager.h @@ -7,23 +7,23 @@ #include "base/containers/hash_tables.h" #include "base/macros.h" +#include "cc/surfaces/surface_id.h" #include "cc/surfaces/surfaces_export.h" -namespace gfx { class Size; } - namespace cc { class CompositorFrame; class Surface; +class SurfaceClient; class CC_SURFACES_EXPORT SurfaceManager { public: SurfaceManager(); ~SurfaceManager(); - int RegisterAndAllocateIDForSurface(Surface* surface); - void DeregisterSurface(int surface_id); + SurfaceId RegisterAndAllocateIdForSurface(Surface* surface); + void DeregisterSurface(SurfaceId surface_id); - Surface* GetSurfaceForID(int surface_id); + Surface* GetSurfaceForId(SurfaceId surface_id); private: typedef base::hash_map<int, Surface*> SurfaceMap; diff --git a/cc/surfaces/surface_unittest.cc b/cc/surfaces/surface_unittest.cc index 7b185125ab..66890c4213 100644 --- a/cc/surfaces/surface_unittest.cc +++ b/cc/surfaces/surface_unittest.cc @@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "cc/output/compositor_frame.h" +#include "cc/output/delegated_frame_data.h" #include "cc/surfaces/surface.h" +#include "cc/surfaces/surface_client.h" #include "cc/surfaces/surface_manager.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/size.h" @@ -13,15 +16,395 @@ namespace { TEST(SurfaceTest, SurfaceLifetime) { SurfaceManager manager; - int surface_id = 0; + SurfaceId surface_id; { Surface surface(&manager, NULL, gfx::Size(5, 5)); surface_id = surface.surface_id(); - EXPECT_GT(surface_id, 0); - EXPECT_EQ(&surface, manager.GetSurfaceForID(surface_id)); + EXPECT_TRUE(!surface_id.is_null()); + EXPECT_EQ(&surface, manager.GetSurfaceForId(surface_id)); } - EXPECT_EQ(NULL, manager.GetSurfaceForID(surface_id)); + EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id)); +} + +class TestSurfaceClient : public SurfaceClient { + public: + TestSurfaceClient() {} + virtual ~TestSurfaceClient() {} + + virtual void ReturnResources( + const ReturnedResourceArray& resources) OVERRIDE { + returned_resources_ = resources; + } + + const ReturnedResourceArray& returned_resources() const { + return returned_resources_; + } + + void clear_returned_resources() { returned_resources_.clear(); } + + private: + ReturnedResourceArray returned_resources_; + + DISALLOW_COPY_AND_ASSIGN(TestSurfaceClient); +}; + +void SubmitFrameWithResources(ResourceProvider::ResourceId* resource_ids, + size_t num_resource_ids, + Surface* surface) { + scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); + for (size_t i = 0u; i < num_resource_ids; ++i) { + TransferableResource resource; + resource.id = resource_ids[i]; + resource.mailbox_holder.texture_target = GL_TEXTURE_2D; + frame_data->resource_list.push_back(resource); + } + scoped_ptr<CompositorFrame> frame(new CompositorFrame); + frame->delegated_frame_data = frame_data.Pass(); + surface->QueueFrame(frame.Pass()); +} + +void CheckReturnedResourcesMatchExpected( + ResourceProvider::ResourceId* expected_returned_ids, + int* expected_returned_counts, + size_t expected_resources, + const ReturnedResourceArray& actual_resources) { + ASSERT_EQ(expected_resources, actual_resources.size()); + for (size_t i = 0; i < expected_resources; ++i) { + ReturnedResource resource = actual_resources[i]; + EXPECT_EQ(expected_returned_ids[i], resource.id); + EXPECT_EQ(expected_returned_counts[i], resource.count); + } +} + +void UnrefResources(ResourceProvider::ResourceId* ids_to_unref, + int* counts_to_unref, + size_t num_ids_to_unref, + Surface* surface) { + ReturnedResourceArray unref_array; + for (size_t i = 0; i < num_ids_to_unref; ++i) { + ReturnedResource resource; + resource.id = ids_to_unref[i]; + resource.count = counts_to_unref[i]; + unref_array.push_back(resource); + } + surface->UnrefResources(unref_array); +} + +// Tests submitting a frame with resources followed by one with no resources +// with no resource provider action in between. +TEST(SurfaceTest, ResourceLifetimeSimple) { + SurfaceManager manager; + TestSurfaceClient client; + Surface surface(&manager, &client, gfx::Size(5, 5)); + + ResourceProvider::ResourceId first_frame_ids[] = {1, 2, 3}; + SubmitFrameWithResources( + first_frame_ids, arraysize(first_frame_ids), &surface); + + // All of the resources submitted in the first frame are still in use at this + // time by virtue of being in the pending frame, so none can be returned to + // the client yet. + surface.ReturnUnusedResourcesToClient(); + EXPECT_EQ(0u, client.returned_resources().size()); + client.clear_returned_resources(); + + // The second frame references no resources and thus should make all resources + // available to be returned. + SubmitFrameWithResources(NULL, 0, &surface); + + surface.ReturnUnusedResourcesToClient(); + ResourceProvider::ResourceId expected_returned_ids[] = {1, 2, 3}; + int expected_returned_counts[] = {1, 1, 1}; + CheckReturnedResourcesMatchExpected(expected_returned_ids, + expected_returned_counts, + arraysize(expected_returned_counts), + client.returned_resources()); +} + +// Tests submitting a frame with resources followed by one with no resources +// with the resource provider holding everything alive. +TEST(SurfaceTest, ResourceLifetimeSimpleWithProviderHoldingAlive) { + SurfaceManager manager; + TestSurfaceClient client; + Surface surface(&manager, &client, gfx::Size(5, 5)); + + ResourceProvider::ResourceId first_frame_ids[] = {1, 2, 3}; + SubmitFrameWithResources( + first_frame_ids, arraysize(first_frame_ids), &surface); + + // All of the resources submitted in the first frame are still in use at this + // time by virtue of being in the pending frame, so none can be returned to + // the client yet. + surface.ReturnUnusedResourcesToClient(); + EXPECT_EQ(0u, client.returned_resources().size()); + client.clear_returned_resources(); + + // Hold on to everything. + surface.RefCurrentFrameResources(); + + // The second frame references no resources and thus should make all resources + // available to be returned as soon as the resource provider releases them. + SubmitFrameWithResources(NULL, 0, &surface); + + surface.ReturnUnusedResourcesToClient(); + EXPECT_EQ(0u, client.returned_resources().size()); + client.clear_returned_resources(); + + int release_counts[] = {1, 1, 1}; + UnrefResources( + first_frame_ids, release_counts, arraysize(first_frame_ids), &surface); + + surface.ReturnUnusedResourcesToClient(); + ResourceProvider::ResourceId expected_returned_ids[] = {1, 2, 3}; + int expected_returned_counts[] = {1, 1, 1}; + CheckReturnedResourcesMatchExpected(expected_returned_ids, + expected_returned_counts, + arraysize(expected_returned_counts), + client.returned_resources()); +} + +// Tests referencing a resource, unref'ing it to zero, then using it again +// before returning it to the client. +TEST(SurfaceTest, ResourceReusedBeforeReturn) { + SurfaceManager manager; + TestSurfaceClient client; + Surface surface(&manager, &client, gfx::Size(5, 5)); + + ResourceProvider::ResourceId first_frame_ids[] = {7}; + SubmitFrameWithResources( + first_frame_ids, arraysize(first_frame_ids), &surface); + + // This removes all references to resource id 7. + SubmitFrameWithResources(NULL, 0, &surface); + + // This references id 7 again. + SubmitFrameWithResources( + first_frame_ids, arraysize(first_frame_ids), &surface); + + // This removes it again. + SubmitFrameWithResources(NULL, 0, &surface); + + // Now it should be returned. + surface.ReturnUnusedResourcesToClient(); + + // We don't care how many entries are in the returned array for 7, so long as + // the total returned count matches the submitted count. + const ReturnedResourceArray& returned = client.returned_resources(); + size_t return_count = 0; + for (size_t i = 0; i < returned.size(); ++i) { + EXPECT_EQ(7u, returned[i].id); + return_count += returned[i].count; + } + EXPECT_EQ(2u, return_count); +} + +// Tests having resources referenced multiple times, as if referenced by +// multiple providers. +TEST(SurfaceTest, ResourceRefMultipleTimes) { + SurfaceManager manager; + TestSurfaceClient client; + Surface surface(&manager, &client, gfx::Size(5, 5)); + + ResourceProvider::ResourceId first_frame_ids[] = {3, 4}; + SubmitFrameWithResources( + first_frame_ids, arraysize(first_frame_ids), &surface); + + // Ref resources from the first frame twice. + surface.RefCurrentFrameResources(); + surface.RefCurrentFrameResources(); + + ResourceProvider::ResourceId second_frame_ids[] = {4, 5}; + SubmitFrameWithResources( + second_frame_ids, arraysize(second_frame_ids), &surface); + + // Ref resources from the second frame 3 times. + surface.RefCurrentFrameResources(); + surface.RefCurrentFrameResources(); + surface.RefCurrentFrameResources(); + + // Submit a frame with no resources to remove all current frame refs from + // submitted resources. + SubmitFrameWithResources(NULL, 0, &surface); + + surface.ReturnUnusedResourcesToClient(); + EXPECT_EQ(0u, client.returned_resources().size()); + client.clear_returned_resources(); + + // Expected current refs: + // 3 -> 2 + // 4 -> 2 + 3 = 5 + // 5 -> 3 + { + SCOPED_TRACE("unref all 3"); + ResourceProvider::ResourceId ids_to_unref[] = {3, 4, 5}; + int counts[] = {1, 1, 1}; + UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref), &surface); + + surface.ReturnUnusedResourcesToClient(); + EXPECT_EQ(0u, client.returned_resources().size()); + client.clear_returned_resources(); + + UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref), &surface); + + surface.ReturnUnusedResourcesToClient(); + ResourceProvider::ResourceId expected_returned_ids[] = {3}; + int expected_returned_counts[] = {1}; + CheckReturnedResourcesMatchExpected(expected_returned_ids, + expected_returned_counts, + arraysize(expected_returned_counts), + client.returned_resources()); + } + + // Expected refs remaining: + // 4 -> 3 + // 5 -> 1 + { + SCOPED_TRACE("unref 4 and 5"); + ResourceProvider::ResourceId ids_to_unref[] = {4, 5}; + int counts[] = {1, 1}; + UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref), &surface); + + surface.ReturnUnusedResourcesToClient(); + ResourceProvider::ResourceId expected_returned_ids[] = {5}; + int expected_returned_counts[] = {1}; + CheckReturnedResourcesMatchExpected(expected_returned_ids, + expected_returned_counts, + arraysize(expected_returned_counts), + client.returned_resources()); + } + + // Now, just 2 refs remaining on resource 4. Unref both at once and make sure + // the returned count is correct. + { + SCOPED_TRACE("unref only 4"); + ResourceProvider::ResourceId ids_to_unref[] = {4}; + int counts[] = {2}; + UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref), &surface); + + surface.ReturnUnusedResourcesToClient(); + ResourceProvider::ResourceId expected_returned_ids[] = {4}; + int expected_returned_counts[] = {2}; + CheckReturnedResourcesMatchExpected(expected_returned_ids, + expected_returned_counts, + arraysize(expected_returned_counts), + client.returned_resources()); + } +} + +TEST(SurfaceTest, ResourceLifetime) { + SurfaceManager manager; + TestSurfaceClient client; + Surface surface(&manager, &client, gfx::Size(5, 5)); + + ResourceProvider::ResourceId first_frame_ids[] = {1, 2, 3}; + SubmitFrameWithResources( + first_frame_ids, arraysize(first_frame_ids), &surface); + + // All of the resources submitted in the first frame are still in use at this + // time by virtue of being in the pending frame, so none can be returned to + // the client yet. + surface.ReturnUnusedResourcesToClient(); + EXPECT_EQ(0u, client.returned_resources().size()); + client.clear_returned_resources(); + + // The second frame references some of the same resources, but some different + // ones. We expect to receive back resource 1 with a count of 1 since it was + // only referenced by the first frame. + ResourceProvider::ResourceId second_frame_ids[] = {2, 3, 4}; + SubmitFrameWithResources( + second_frame_ids, arraysize(second_frame_ids), &surface); + + surface.ReturnUnusedResourcesToClient(); + { + SCOPED_TRACE("second frame"); + ResourceProvider::ResourceId expected_returned_ids[] = {1}; + int expected_returned_counts[] = {1}; + CheckReturnedResourcesMatchExpected(expected_returned_ids, + expected_returned_counts, + arraysize(expected_returned_counts), + client.returned_resources()); + } + + // The third frame references a disjoint set of resources, so we expect to + // receive back all resources from the first and second frames. Resource IDs 2 + // and 3 will have counts of 2, since they were used in both frames, and + // resource ID 4 will have a count of 1. + ResourceProvider::ResourceId third_frame_ids[] = {10, 11, 12, 13}; + SubmitFrameWithResources( + third_frame_ids, arraysize(third_frame_ids), &surface); + + surface.ReturnUnusedResourcesToClient(); + { + SCOPED_TRACE("third frame"); + ResourceProvider::ResourceId expected_returned_ids[] = {2, 3, 4}; + int expected_returned_counts[] = {2, 2, 1}; + CheckReturnedResourcesMatchExpected(expected_returned_ids, + expected_returned_counts, + arraysize(expected_returned_counts), + client.returned_resources()); + } + + // Simulate a ResourceProvider taking a ref on all of the resources. + surface.RefCurrentFrameResources(); + + ResourceProvider::ResourceId fourth_frame_ids[] = {12, 13}; + SubmitFrameWithResources( + fourth_frame_ids, arraysize(fourth_frame_ids), &surface); + + surface.ReturnUnusedResourcesToClient(); + EXPECT_EQ(0u, client.returned_resources().size()); + + surface.RefCurrentFrameResources(); + + // All resources are still being used by the external reference, so none can + // be returned to the client. + surface.ReturnUnusedResourcesToClient(); + EXPECT_EQ(0u, client.returned_resources().size()); + + // Release resources associated with the first RefCurrentFrameResources() call + // first. + { + ResourceProvider::ResourceId ids_to_unref[] = {10, 11, 12, 13}; + int counts[] = {1, 1, 1, 1}; + UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref), &surface); + } + + surface.ReturnUnusedResourcesToClient(); + { + SCOPED_TRACE("fourth frame, first unref"); + ResourceProvider::ResourceId expected_returned_ids[] = {10, 11}; + int expected_returned_counts[] = {1, 1}; + CheckReturnedResourcesMatchExpected(expected_returned_ids, + expected_returned_counts, + arraysize(expected_returned_counts), + client.returned_resources()); + } + + { + ResourceProvider::ResourceId ids_to_unref[] = {12, 13}; + int counts[] = {1, 1}; + UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref), &surface); + } + + // Resources 12 and 13 are still in use by the current frame, so they + // shouldn't be available to be returned. + surface.ReturnUnusedResourcesToClient(); + EXPECT_EQ(0u, client.returned_resources().size()); + + // If we submit an empty frame, however, they should become available. + SubmitFrameWithResources(NULL, 0u, &surface); + + surface.ReturnUnusedResourcesToClient(); + { + SCOPED_TRACE("fourth frame, second unref"); + ResourceProvider::ResourceId expected_returned_ids[] = {12, 13}; + int expected_returned_counts[] = {2, 2}; + CheckReturnedResourcesMatchExpected(expected_returned_ids, + expected_returned_counts, + arraysize(expected_returned_counts), + client.returned_resources()); + } } } // namespace diff --git a/cc/test/fake_picture_layer_impl.cc b/cc/test/fake_picture_layer_impl.cc index 3f5b82a7bc..8514bc32e7 100644 --- a/cc/test/fake_picture_layer_impl.cc +++ b/cc/test/fake_picture_layer_impl.cc @@ -19,6 +19,7 @@ FakePictureLayerImpl::FakePictureLayerImpl( pile_ = pile; CHECK(pile->tiling_rect().origin() == gfx::Point()); SetBounds(pile_->tiling_rect().size()); + SetContentBounds(pile_->tiling_rect().size()); } FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, @@ -28,6 +29,7 @@ FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, : PictureLayerImpl(tree_impl, id), append_quads_count_(0) { pile_ = pile; SetBounds(layer_bounds); + SetContentBounds(layer_bounds); } FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id) diff --git a/cc/test/fake_picture_layer_impl.h b/cc/test/fake_picture_layer_impl.h index 9ce0283e9b..38caff85cd 100644 --- a/cc/test/fake_picture_layer_impl.h +++ b/cc/test/fake_picture_layer_impl.h @@ -48,6 +48,10 @@ class FakePictureLayerImpl : public PictureLayerImpl { using PictureLayerImpl::MinimumContentsScale; using PictureLayerImpl::SanityCheckTilingState; + using PictureLayerImpl::UpdateIdealScales; + using PictureLayerImpl::MaximumTilingContentsScale; + using PictureLayerImpl::ManageTilings; + void SetNeedsPostCommitInitialization() { needs_post_commit_initialization_ = true; } @@ -56,8 +60,8 @@ class FakePictureLayerImpl : public PictureLayerImpl { return needs_post_commit_initialization_; } - bool is_using_lcd_text() const { return is_using_lcd_text_; } - void force_set_lcd_text(bool enabled) { is_using_lcd_text_ = enabled; } + float raster_page_scale() const { return raster_page_scale_; } + void set_raster_page_scale(float scale) { raster_page_scale_ = scale; } PictureLayerTiling* HighResTiling() const; PictureLayerTiling* LowResTiling() const; @@ -90,6 +94,15 @@ 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_picture_layer_tiling_client.cc b/cc/test/fake_picture_layer_tiling_client.cc index 0c0fce69a0..dd64ac248c 100644 --- a/cc/test/fake_picture_layer_tiling_client.cc +++ b/cc/test/fake_picture_layer_tiling_client.cc @@ -41,7 +41,7 @@ scoped_refptr<Tile> FakePictureLayerTilingClient::CreateTile( if (!allow_create_tile_) return scoped_refptr<Tile>(); return tile_manager_->CreateTile( - pile_.get(), tile_size_, rect, gfx::Rect(), 1, 0, 0, Tile::USE_LCD_TEXT); + pile_.get(), tile_size_, rect, gfx::Rect(), 1, 0, 0, 0); } void FakePictureLayerTilingClient::SetTileSize(const gfx::Size& tile_size) { diff --git a/cc/test/fake_tile_manager_client.cc b/cc/test/fake_tile_manager_client.cc index c82aeb00cb..adbae1c5da 100644 --- a/cc/test/fake_tile_manager_client.cc +++ b/cc/test/fake_tile_manager_client.cc @@ -4,6 +4,19 @@ #include "cc/test/fake_tile_manager_client.h" +#include <vector> + namespace cc { +FakeTileManagerClient::FakeTileManagerClient() { +} + +FakeTileManagerClient::~FakeTileManagerClient() { +} + +const std::vector<PictureLayerImpl*>& +FakeTileManagerClient::GetPictureLayers() { + return picture_layers_; +} + } // namespace cc diff --git a/cc/test/fake_tile_manager_client.h b/cc/test/fake_tile_manager_client.h index 7faa30ed38..5c3812876d 100644 --- a/cc/test/fake_tile_manager_client.h +++ b/cc/test/fake_tile_manager_client.h @@ -5,17 +5,24 @@ #ifndef CC_TEST_FAKE_TILE_MANAGER_CLIENT_H_ #define CC_TEST_FAKE_TILE_MANAGER_CLIENT_H_ +#include <vector> + #include "cc/resources/tile_manager.h" namespace cc { class FakeTileManagerClient : public TileManagerClient { public: - virtual ~FakeTileManagerClient() {} + FakeTileManagerClient(); + virtual ~FakeTileManagerClient(); // TileManagerClient implementation. + virtual const std::vector<PictureLayerImpl*>& GetPictureLayers() OVERRIDE; virtual void NotifyReadyToActivate() OVERRIDE {} virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE {} + + private: + std::vector<PictureLayerImpl*> picture_layers_; }; } // namespace cc diff --git a/cc/test/layer_test_common.cc b/cc/test/layer_test_common.cc index 6661644934..4daca5d2f9 100644 --- a/cc/test/layer_test_common.cc +++ b/cc/test/layer_test_common.cc @@ -101,8 +101,10 @@ void LayerTestCommon::VerifyQuadsCoverRectWithOcclusion( LayerTestCommon::LayerImplTest::LayerImplTest() : host_(FakeLayerTreeHost::Create()), - root_layer_impl_( - LayerImpl::Create(host_->host_impl()->active_tree(), 1)) { + root_layer_impl_(LayerImpl::Create(host_->host_impl()->active_tree(), 1)), + render_pass_(RenderPass::Create()), + quad_culler_(make_scoped_ptr( + new MockQuadCuller(render_pass_.get(), &occlusion_tracker_))) { scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); host_->host_impl()->InitializeRenderer( output_surface.PassAs<OutputSurface>()); @@ -123,10 +125,10 @@ void LayerTestCommon::LayerImplTest::AppendQuadsWithOcclusion( const gfx::Rect& occluded) { AppendQuadsData data; - quad_culler_.clear_lists(); - quad_culler_.set_occluded_target_rect(occluded); + quad_culler_->clear_lists(); + quad_culler_->set_occluded_target_rect(occluded); layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); - layer_impl->AppendQuads(&quad_culler_, &data); + layer_impl->AppendQuads(quad_culler_.get(), &data); layer_impl->DidDraw(resource_provider()); } @@ -136,10 +138,10 @@ void LayerTestCommon::LayerImplTest::AppendQuadsForPassWithOcclusion( const gfx::Rect& occluded) { AppendQuadsData data(id); - quad_culler_.clear_lists(); - quad_culler_.set_occluded_target_rect(occluded); + quad_culler_->clear_lists(); + quad_culler_->set_occluded_target_rect(occluded); layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); - layer_impl->AppendQuads(&quad_culler_, &data); + layer_impl->AppendQuads(quad_culler_.get(), &data); layer_impl->DidDraw(resource_provider()); } @@ -148,11 +150,11 @@ void LayerTestCommon::LayerImplTest::AppendSurfaceQuadsWithOcclusion( const gfx::Rect& occluded) { AppendQuadsData data; - quad_culler_.clear_lists(); - quad_culler_.set_occluded_target_rect_for_contributing_surface(occluded); + quad_culler_->clear_lists(); + quad_culler_->set_occluded_target_rect_for_contributing_surface(occluded); bool for_replica = false; RenderPass::Id id(1, 1); - surface_impl->AppendQuads(&quad_culler_, &data, for_replica, id); + surface_impl->AppendQuads(quad_culler_.get(), &data, for_replica, id); } } // namespace cc diff --git a/cc/test/layer_test_common.h b/cc/test/layer_test_common.h index ee7d1328b2..d3f2ab3770 100644 --- a/cc/test/layer_test_common.h +++ b/cc/test/layer_test_common.h @@ -113,12 +113,14 @@ class LayerTestCommon { LayerImpl* root_layer() const { return root_layer_impl_.get(); } FakeLayerTreeHostImpl* host_impl() const { return host_->host_impl(); } Proxy* proxy() const { return host_->host_impl()->proxy(); } - const QuadList& quad_list() const { return quad_culler_.quad_list(); } + const QuadList& quad_list() const { return quad_culler_->quad_list(); } private: scoped_ptr<FakeLayerTreeHost> host_; scoped_ptr<LayerImpl> root_layer_impl_; - MockQuadCuller quad_culler_; + scoped_ptr<RenderPass> render_pass_; + MockOcclusionTracker<LayerImpl> occlusion_tracker_; + scoped_ptr<MockQuadCuller> quad_culler_; }; }; diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index d21d43ebc2..10c415e8c1 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -75,6 +75,7 @@ class ThreadProxyForTest : public ThreadProxy { } virtual void ScheduledActionSendBeginMainFrame() OVERRIDE { + test_hooks_->ScheduledActionWillSendBeginMainFrame(); ThreadProxy::ScheduledActionSendBeginMainFrame(); test_hooks_->ScheduledActionSendBeginMainFrame(); } diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h index 2c078a1ceb..b111963919 100644 --- a/cc/test/layer_tree_test.h +++ b/cc/test/layer_tree_test.h @@ -80,6 +80,7 @@ class TestHooks : public AnimationDelegate { // Hooks for SchedulerClient. virtual void ScheduledActionBeginOutputSurfaceCreation() {} + virtual void ScheduledActionWillSendBeginMainFrame() {} virtual void ScheduledActionSendBeginMainFrame() {} virtual void ScheduledActionCommit() {} virtual void ScheduledActionDrawAndSwapIfPossible() {} diff --git a/cc/test/mock_occlusion_tracker.h b/cc/test/mock_occlusion_tracker.h new file mode 100644 index 0000000000..6a88bce22f --- /dev/null +++ b/cc/test/mock_occlusion_tracker.h @@ -0,0 +1,48 @@ +// Copyright 2014 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_TEST_MOCK_OCCLUSION_TRACKER_H_ +#define CC_TEST_MOCK_OCCLUSION_TRACKER_H_ + +#include "cc/trees/occlusion_tracker.h" + +namespace cc { + +template <typename LayerType> +class MockOcclusionTracker : public OcclusionTracker<LayerType> { + // This class is used for testing only. It fakes just enough information to + // calculate unoccluded content rect and unoccluded contributing surface + // content rect. It calls the helper function of occlusion tracker to avoid + // DCHECKs since testing environment won't be set up properly to pass those. + public: + MockOcclusionTracker() + : OcclusionTracker<LayerType>(gfx::Rect(0, 0, 1000, 1000)) { + typename OcclusionTracker<LayerType>::StackObject stack_obj; + OcclusionTracker<LayerType>::stack_.push_back(stack_obj); + OcclusionTracker<LayerType>::stack_.push_back(stack_obj); + } + + explicit MockOcclusionTracker(const gfx::Rect& screen_scissor_rect) + : OcclusionTracker<LayerType>(screen_scissor_rect) { + typename OcclusionTracker<LayerType>::StackObject stack_obj; + OcclusionTracker<LayerType>::stack_.push_back(stack_obj); + OcclusionTracker<LayerType>::stack_.push_back(stack_obj); + } + + void set_occluded_target_rect(const gfx::Rect& occluded) { + OcclusionTracker<LayerType>::stack_.back().occlusion_from_inside_target = + occluded; + } + + void set_occluded_target_rect_for_contributing_surface( + const gfx::Rect& occluded) { + OcclusionTracker< + LayerType>::stack_[OcclusionTracker<LayerType>::stack_.size() - 2] + .occlusion_from_inside_target = occluded; + } +}; + +} // namespace cc + +#endif // CC_TEST_MOCK_OCCLUSION_TRACKER_H_ diff --git a/cc/test/mock_quad_culler.cc b/cc/test/mock_quad_culler.cc index ddb5913c41..e1b140bbd3 100644 --- a/cc/test/mock_quad_culler.cc +++ b/cc/test/mock_quad_culler.cc @@ -4,62 +4,30 @@ #include "cc/test/mock_quad_culler.h" -#include "cc/base/math_util.h" -#include "cc/quads/draw_quad.h" - namespace cc { -MockQuadCuller::MockQuadCuller() { - render_pass_storage_ = RenderPass::Create(); - active_render_pass_ = render_pass_storage_.get(); -} - -MockQuadCuller::MockQuadCuller(RenderPass* external_render_pass) - : active_render_pass_(external_render_pass) { +MockQuadCuller::MockQuadCuller( + RenderPass* render_pass, + MockOcclusionTracker<LayerImpl>* occlusion_tracker) + : QuadSink(render_pass, occlusion_tracker), + occlusion_tracker_(occlusion_tracker) { } MockQuadCuller::~MockQuadCuller() {} -SharedQuadState* MockQuadCuller::CreateSharedQuadState() { - return active_render_pass_->CreateAndAppendSharedQuadState(); -} - gfx::Rect MockQuadCuller::UnoccludedContentRect( const gfx::Rect& content_rect, const gfx::Transform& draw_transform) { - DCHECK(draw_transform.IsIdentityOrIntegerTranslation() || - occluded_target_rect_.IsEmpty()); - gfx::Rect target_rect = - MathUtil::MapEnclosingClippedRect(draw_transform, content_rect); - target_rect.Subtract(occluded_target_rect_); - gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); - if (!draw_transform.GetInverse(&inverse_draw_transform)) - NOTREACHED(); - gfx::Rect result = MathUtil::ProjectEnclosingClippedRect( - inverse_draw_transform, target_rect); - return result; + return occlusion_tracker_->UnoccludedContentRect(content_rect, + draw_transform); } gfx::Rect MockQuadCuller::UnoccludedContributingSurfaceContentRect( const gfx::Rect& content_rect, const gfx::Transform& draw_transform) { - DCHECK(draw_transform.IsIdentityOrIntegerTranslation() || - occluded_target_rect_for_contributing_surface_.IsEmpty()); - gfx::Rect target_rect = - MathUtil::MapEnclosingClippedRect(draw_transform, content_rect); - target_rect.Subtract(occluded_target_rect_for_contributing_surface_); - gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); - if (!draw_transform.GetInverse(&inverse_draw_transform)) - NOTREACHED(); - gfx::Rect result = MathUtil::ProjectEnclosingClippedRect( - inverse_draw_transform, target_rect); - return result; -} - -void MockQuadCuller::Append(scoped_ptr<DrawQuad> draw_quad) { - DCHECK(!draw_quad->rect.IsEmpty()); - DCHECK(!draw_quad->visible_rect.IsEmpty()); - active_render_pass_->quad_list.push_back(draw_quad.Pass()); + return occlusion_tracker_->UnoccludedContributingSurfaceContentRect( + content_rect, draw_transform); } } // namespace cc + diff --git a/cc/test/mock_quad_culler.h b/cc/test/mock_quad_culler.h index 195eb5bf06..ca2f0aa3e5 100644 --- a/cc/test/mock_quad_culler.h +++ b/cc/test/mock_quad_culler.h @@ -9,50 +9,48 @@ #include "cc/layers/quad_sink.h" #include "cc/quads/draw_quad.h" #include "cc/quads/render_pass.h" +#include "cc/test/mock_occlusion_tracker.h" namespace cc { +class LayerImpl; class MockQuadCuller : public QuadSink { public: - MockQuadCuller(); virtual ~MockQuadCuller(); - explicit MockQuadCuller(RenderPass* external_render_pass); + MockQuadCuller(RenderPass* render_pass, + MockOcclusionTracker<LayerImpl>* occlusion_tracker); + + virtual gfx::Rect UnoccludedContentRect( + const gfx::Rect& content_rect, + const gfx::Transform& draw_transform) OVERRIDE; - // QuadSink interface. - virtual SharedQuadState* CreateSharedQuadState() OVERRIDE; - virtual gfx::Rect UnoccludedContentRect(const gfx::Rect& content_rect, - const gfx::Transform& draw_transform) - OVERRIDE; virtual gfx::Rect UnoccludedContributingSurfaceContentRect( const gfx::Rect& content_rect, const gfx::Transform& draw_transform) OVERRIDE; - virtual void Append(scoped_ptr<DrawQuad> draw_quad) OVERRIDE; - const QuadList& quad_list() const { return active_render_pass_->quad_list; } + const QuadList& quad_list() const { return render_pass_->quad_list; } const SharedQuadStateList& shared_quad_state_list() const { - return active_render_pass_->shared_quad_state_list; + return render_pass_->shared_quad_state_list; } void set_occluded_target_rect(const gfx::Rect& occluded) { - occluded_target_rect_ = occluded; + occlusion_tracker_->set_occluded_target_rect(occluded); } void set_occluded_target_rect_for_contributing_surface( const gfx::Rect& occluded) { - occluded_target_rect_for_contributing_surface_ = occluded; + occlusion_tracker_->set_occluded_target_rect_for_contributing_surface( + occluded); } void clear_lists() { - active_render_pass_->quad_list.clear(); - active_render_pass_->shared_quad_state_list.clear(); + render_pass_->quad_list.clear(); + render_pass_->shared_quad_state_list.clear(); } private: - scoped_ptr<RenderPass> render_pass_storage_; - RenderPass* active_render_pass_; - gfx::Rect occluded_target_rect_; - gfx::Rect occluded_target_rect_for_contributing_surface_; + MockOcclusionTracker<LayerImpl>* occlusion_tracker_; }; } // namespace cc diff --git a/cc/test/test_gles2_interface.cc b/cc/test/test_gles2_interface.cc index 26055ba679..cf28225ed8 100644 --- a/cc/test/test_gles2_interface.cc +++ b/cc/test/test_gles2_interface.cc @@ -226,7 +226,7 @@ void TestGLES2Interface::TexParameteri(GLenum target, void TestGLES2Interface::AsyncTexImage2DCHROMIUM(GLenum target, GLint level, - GLint internalformat, + GLenum internalformat, GLsizei width, GLsizei height, GLint border, diff --git a/cc/test/test_gles2_interface.h b/cc/test/test_gles2_interface.h index 417bf4a125..be18e73dcb 100644 --- a/cc/test/test_gles2_interface.h +++ b/cc/test/test_gles2_interface.h @@ -99,7 +99,7 @@ class TestGLES2Interface : public gpu::gles2::GLES2InterfaceStub { virtual void AsyncTexImage2DCHROMIUM(GLenum target, GLint level, - GLint internalformat, + GLenum internalformat, GLsizei width, GLsizei height, GLint border, diff --git a/cc/test/test_web_graphics_context_3d.cc b/cc/test/test_web_graphics_context_3d.cc index 613c5d0075..25517d138d 100644 --- a/cc/test/test_web_graphics_context_3d.cc +++ b/cc/test/test_web_graphics_context_3d.cc @@ -55,6 +55,8 @@ TestWebGraphicsContext3D::TestWebGraphicsContext3D() context_lost_(false), times_map_image_chromium_succeeds_(-1), times_map_buffer_chromium_succeeds_(-1), + current_used_transfer_buffer_usage_bytes_(0), + max_used_transfer_buffer_usage_bytes_(0), next_program_id_(1000), next_shader_id_(2000), max_texture_size_(2048), @@ -498,10 +500,17 @@ void TestWebGraphicsContext3D::bufferData(GLenum target, return; } + size_t old_size = buffer->size; + buffer->pixels.reset(new uint8[size]); buffer->size = size; if (data != NULL) memcpy(buffer->pixels.get(), data, size); + if (buffer->target == GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM) + current_used_transfer_buffer_usage_bytes_ += buffer->size - old_size; + max_used_transfer_buffer_usage_bytes_ = + std::max(max_used_transfer_buffer_usage_bytes_, + current_used_transfer_buffer_usage_bytes_); } void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target, @@ -647,18 +656,6 @@ void TestWebGraphicsContext3D::RetireImageId(GLuint id) { DCHECK_EQ(context_id, context_id_); } -size_t TestWebGraphicsContext3D::GetTransferBufferMemoryUsedBytes() const { - size_t total_bytes = 0; - base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; - base::ScopedPtrHashMap<unsigned, Buffer>::iterator it = buffers.begin(); - for (; it != buffers.end(); ++it) { - Buffer* buffer = it->second; - if (buffer->target == GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM) - total_bytes += buffer->size; - } - return total_bytes; -} - void TestWebGraphicsContext3D::SetMaxTransferBufferUsageBytes( size_t max_transfer_buffer_usage_bytes) { test_capabilities_.max_transfer_buffer_usage_bytes = diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h index 3ce3ddd391..3cbe9ca580 100644 --- a/cc/test/test_web_graphics_context_3d.h +++ b/cc/test/test_web_graphics_context_3d.h @@ -323,8 +323,10 @@ class TestWebGraphicsContext3D { virtual GLuint NextImageId(); virtual void RetireImageId(GLuint id); - size_t GetTransferBufferMemoryUsedBytes() const; void SetMaxTransferBufferUsageBytes(size_t max_transfer_buffer_usage_bytes); + size_t max_used_transfer_buffer_usage_bytes() const { + return max_used_transfer_buffer_usage_bytes_; + } void set_test_support(TestContextSupport* test_support) { test_support_ = test_support; @@ -415,6 +417,8 @@ class TestWebGraphicsContext3D { bool context_lost_; int times_map_image_chromium_succeeds_; int times_map_buffer_chromium_succeeds_; + int current_used_transfer_buffer_usage_bytes_; + int max_used_transfer_buffer_usage_bytes_; base::Closure context_lost_callback_; base::hash_set<unsigned> used_textures_; unsigned next_program_id_; diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index fe77820fed..51b9b4f2e3 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -271,28 +271,15 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { contents_texture_manager_->UpdateBackingsState( host_impl->resource_provider()); - } - - // In impl-side painting, synchronize to the pending tree so that it has - // time to raster before being displayed. If no pending tree is needed, - // synchronization can happen directly to the active tree and - // unlinked contents resources can be reclaimed immediately. - LayerTreeImpl* sync_tree; - if (settings_.impl_side_painting) { - // Commits should not occur while there is already a pending tree. - DCHECK(!host_impl->pending_tree()); - host_impl->CreatePendingTree(); - sync_tree = host_impl->pending_tree(); - if (next_commit_forces_redraw_) - sync_tree->ForceRedrawNextActivation(); - } else { - if (next_commit_forces_redraw_) - host_impl->SetFullRootLayerDamage(); contents_texture_manager_->ReduceMemory(host_impl->resource_provider()); - sync_tree = host_impl->active_tree(); } - next_commit_forces_redraw_ = false; + LayerTreeImpl* sync_tree = host_impl->sync_tree(); + + if (next_commit_forces_redraw_) { + sync_tree->ForceRedrawNextActivation(); + next_commit_forces_redraw_ = false; + } sync_tree->set_source_frame_number(source_frame_number()); @@ -328,24 +315,13 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { sync_tree->ClearViewportLayers(); } - float page_scale_delta, sent_page_scale_delta; - if (settings_.impl_side_painting) { - // Update the delta from the active tree, which may have - // adjusted its delta prior to the pending tree being created. - // This code is equivalent to that in LayerTreeImpl::SetPageScaleDelta. - DCHECK_EQ(1.f, sync_tree->sent_page_scale_delta()); - page_scale_delta = host_impl->active_tree()->page_scale_delta(); - sent_page_scale_delta = host_impl->active_tree()->sent_page_scale_delta(); - } else { - page_scale_delta = sync_tree->page_scale_delta(); - sent_page_scale_delta = sync_tree->sent_page_scale_delta(); - sync_tree->set_sent_page_scale_delta(1.f); - } - - sync_tree->SetPageScaleFactorAndLimits(page_scale_factor_, - min_page_scale_factor_, - max_page_scale_factor_); - sync_tree->SetPageScaleDelta(page_scale_delta / sent_page_scale_delta); + float page_scale_delta = + sync_tree->page_scale_delta() / sync_tree->sent_page_scale_delta(); + sync_tree->SetPageScaleValues(page_scale_factor_, + min_page_scale_factor_, + max_page_scale_factor_, + page_scale_delta); + sync_tree->set_sent_page_scale_delta(1.f); sync_tree->PassSwapPromises(&swap_promise_list_); @@ -368,10 +344,6 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { if (!ui_resource_request_queue_.empty()) { sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); ui_resource_request_queue_.clear(); - // Process any ui resource requests in the queue. For impl-side-painting, - // the queue is processed in LayerTreeHostImpl::ActivatePendingTree. - if (!settings_.impl_side_painting) - sync_tree->ProcessUIResourceRequestQueue(); } if (overhang_ui_resource_) { host_impl->SetOverhangUIResource( @@ -386,14 +358,6 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { sync_tree->ResetContentsTexturesPurged(); } - if (!settings_.impl_side_painting) { - // If we're not in impl-side painting, the tree is immediately - // considered active. - sync_tree->DidBecomeActive(); - host_impl->ActivateAnimations(); - devtools_instrumentation::DidActivateLayerTree(id_, source_frame_number_); - } - micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); } diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index 2335f4e031..ebb51a88ce 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -81,7 +81,7 @@ inline gfx::Rect CalculateVisibleRectWithCachedLayerRect( minimal_surface_rect.Intersect(layer_rect_in_target_space); if (minimal_surface_rect.IsEmpty()) - return gfx::Rect(); + return gfx::Rect(); // Project the corners of the target surface rect into the layer space. // This bounding rectangle may be larger than it needs to be (being @@ -487,6 +487,11 @@ static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, if (layer->draw_properties().layer_or_descendant_has_copy_request) return false; + // We cannot skip the the subtree if a descendant has a wheel or touch handler + // or the hit testing code will break (it requires fresh transforms, etc). + if (layer->draw_properties().layer_or_descendant_has_input_handler) + return false; + // If the layer is not drawn, then skip it and its subtree. if (!layer_is_drawn) return true; @@ -513,6 +518,11 @@ static inline bool SubtreeShouldBeSkipped(Layer* layer, bool layer_is_drawn) { if (layer->draw_properties().layer_or_descendant_has_copy_request) return false; + // We cannot skip the the subtree if a descendant has a wheel or touch handler + // or the hit testing code will break (it requires fresh transforms, etc). + if (layer->draw_properties().layer_or_descendant_has_input_handler) + return false; + // If the layer is not drawn, then skip it and its subtree. if (!layer_is_drawn) return true; @@ -909,8 +919,32 @@ gfx::Transform ComputeScrollCompensationMatrixForChildren( } template <typename LayerType> -static inline void CalculateContentsScale( +static inline void UpdateLayerScaleDrawProperties( LayerType* layer, + float ideal_contents_scale, + float maximum_animation_contents_scale, + float page_scale_factor, + float device_scale_factor) { + layer->draw_properties().ideal_contents_scale = ideal_contents_scale; + layer->draw_properties().maximum_animation_contents_scale = + maximum_animation_contents_scale; + layer->draw_properties().page_scale_factor = page_scale_factor; + layer->draw_properties().device_scale_factor = device_scale_factor; +} + +static inline void CalculateContentsScale( + LayerImpl* layer, + float contents_scale, + float device_scale_factor, + float page_scale_factor, + float maximum_animation_contents_scale, + bool animating_transform_to_screen) { + // LayerImpl has all of its content scales and bounds pushed from the Main + // thread during commit and just uses those values as-is. +} + +static inline void CalculateContentsScale( + Layer* layer, float contents_scale, float device_scale_factor, float page_scale_factor, @@ -925,7 +959,7 @@ static inline void CalculateContentsScale( &layer->draw_properties().contents_scale_y, &layer->draw_properties().content_bounds); - LayerType* mask_layer = layer->mask_layer(); + Layer* mask_layer = layer->mask_layer(); if (mask_layer) { mask_layer->CalculateContentsScale( contents_scale, @@ -938,7 +972,7 @@ static inline void CalculateContentsScale( &mask_layer->draw_properties().content_bounds); } - LayerType* replica_mask_layer = + Layer* replica_mask_layer = layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL; if (replica_mask_layer) { replica_mask_layer->CalculateContentsScale( @@ -1184,15 +1218,19 @@ static inline void RemoveSurfaceForEarlyExit( struct PreCalculateMetaInformationRecursiveData { bool layer_or_descendant_has_copy_request; + bool layer_or_descendant_has_input_handler; int num_unclipped_descendants; PreCalculateMetaInformationRecursiveData() : layer_or_descendant_has_copy_request(false), + layer_or_descendant_has_input_handler(false), num_unclipped_descendants(0) {} void Merge(const PreCalculateMetaInformationRecursiveData& data) { layer_or_descendant_has_copy_request |= data.layer_or_descendant_has_copy_request; + layer_or_descendant_has_input_handler |= + data.layer_or_descendant_has_input_handler; num_unclipped_descendants += data.num_unclipped_descendants; } @@ -1252,12 +1290,18 @@ static void PreCalculateMetaInformation( if (layer->HasCopyRequest()) recursive_data->layer_or_descendant_has_copy_request = true; + if (!layer->touch_event_handler_region().IsEmpty() || + layer->have_wheel_event_handlers()) + recursive_data->layer_or_descendant_has_input_handler = true; + layer->draw_properties().num_descendants_that_draw_content = num_descendants_that_draw_content; layer->draw_properties().num_unclipped_descendants = recursive_data->num_unclipped_descendants; layer->draw_properties().layer_or_descendant_has_copy_request = recursive_data->layer_or_descendant_has_copy_request; + layer->draw_properties().layer_or_descendant_has_input_handler = + recursive_data->layer_or_descendant_has_input_handler; } static void RoundTranslationComponents(gfx::Transform* transform) { @@ -1740,6 +1784,40 @@ static void CalculateDrawPropertiesInternal( combined_maximum_animation_contents_scale, animating_transform_to_screen); + UpdateLayerScaleDrawProperties( + layer, + ideal_contents_scale, + combined_maximum_animation_contents_scale, + data_from_ancestor.in_subtree_of_page_scale_application_layer + ? globals.page_scale_factor + : 1.f, + globals.device_scale_factor); + + LayerType* mask_layer = layer->mask_layer(); + if (mask_layer) { + UpdateLayerScaleDrawProperties( + mask_layer, + ideal_contents_scale, + combined_maximum_animation_contents_scale, + data_from_ancestor.in_subtree_of_page_scale_application_layer + ? globals.page_scale_factor + : 1.f, + globals.device_scale_factor); + } + + LayerType* replica_mask_layer = + layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL; + if (replica_mask_layer) { + UpdateLayerScaleDrawProperties( + replica_mask_layer, + ideal_contents_scale, + combined_maximum_animation_contents_scale, + data_from_ancestor.in_subtree_of_page_scale_application_layer + ? globals.page_scale_factor + : 1.f, + globals.device_scale_factor); + } + // The draw_transform that gets computed below is effectively the layer's // draw_transform, unless the layer itself creates a render_surface. In that // case, the render_surface re-parents the transforms. @@ -1770,7 +1848,7 @@ static void CalculateDrawPropertiesInternal( layer_draw_properties.target_space_transform. IsIdentityOrIntegerTranslation(); - gfx::RectF content_rect(layer->content_bounds()); + gfx::Rect content_rect(layer->content_bounds()); // full_hierarchy_matrix is the matrix that transforms objects between screen // space (except projection matrix) and the most recent RenderSurfaceImpl's @@ -2003,8 +2081,8 @@ static void CalculateDrawPropertiesInternal( if (adjust_text_aa) layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; - gfx::Rect rect_in_target_space = ToEnclosingRect( - MathUtil::MapClippedRect(layer->draw_transform(), content_rect)); + gfx::Rect rect_in_target_space = + MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect); if (LayerClipsSubtree(layer)) { layer_or_ancestor_clips_descendants = true; diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 1c850810bb..2186c20bdd 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -156,6 +156,52 @@ TEST_F(LayerTreeHostCommonTest, TransformsForNoOpLayer) { grand_child->screen_space_transform()); } +TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) { + scoped_refptr<Layer> parent = Layer::Create(); + scoped_refptr<Layer> child = Layer::Create(); + scoped_refptr<Layer> grand_child = Layer::Create(); + parent->AddChild(child); + child->AddChild(grand_child); + + scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); + host->SetRootLayer(parent); + + gfx::Transform identity_matrix; + SetLayerPropertiesForTesting(parent.get(), + identity_matrix, + gfx::Point3F(), + gfx::PointF(), + gfx::Size(100, 100), + true, + false); + SetLayerPropertiesForTesting(child.get(), + identity_matrix, + gfx::Point3F(), + gfx::PointF(10, 10), + gfx::Size(100, 100), + true, + false); + // This would have previously caused us to skip our subtree, but this would be + // wrong; we need up-to-date draw properties to do hit testing on the layers + // with handlers. + child->SetOpacity(0.f); + SetLayerPropertiesForTesting(grand_child.get(), + identity_matrix, + gfx::Point3F(), + gfx::PointF(10, 10), + gfx::Size(100, 100), + true, + false); + grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); + + ExecuteCalculateDrawProperties(parent.get()); + + // Check that we've computed draw properties for the subtree rooted at + // |child|. + EXPECT_FALSE(child->draw_transform().IsIdentity()); + EXPECT_FALSE(grand_child->draw_transform().IsIdentity()); +} + TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) { gfx::Transform identity_matrix; scoped_refptr<Layer> layer = Layer::Create(); @@ -7820,37 +7866,12 @@ class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { virtual ~AnimationScaleFactorTrackingLayerImpl() {} - virtual void CalculateContentsScale(float ideal_contents_scale, - float device_scale_factor, - float page_scale_factor, - float maximum_animation_contents_scale, - bool animating_transform_to_screen, - float* contents_scale_x, - float* contents_scale_y, - gfx::Size* content_bounds) OVERRIDE { - last_maximum_animation_contents_scale_ = maximum_animation_contents_scale; - LayerImpl::CalculateContentsScale(ideal_contents_scale, - device_scale_factor, - page_scale_factor, - maximum_animation_contents_scale, - animating_transform_to_screen, - contents_scale_x, - contents_scale_y, - content_bounds); - } - - float last_maximum_animation_contents_scale() { - return last_maximum_animation_contents_scale_; - } - private: explicit AnimationScaleFactorTrackingLayerImpl(LayerTreeImpl* tree_impl, int id) - : LayerImpl(tree_impl, id), last_maximum_animation_contents_scale_(0.f) { + : LayerImpl(tree_impl, id) { SetDrawsContent(true); } - - float last_maximum_animation_contents_scale_; }; TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { @@ -7907,10 +7928,13 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { ExecuteCalculateDrawProperties(grand_parent.get()); // No layers have animations. - EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, parent_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); + EXPECT_EQ(0.f, + grand_parent->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, + parent_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ( + 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); TransformOperations translation; translation.AppendTranslate(1.f, 2.f, 3.f); @@ -7919,10 +7943,13 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { parent_raw, 1.0, TransformOperations(), translation); // No layers have scale-affecting animations. - EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, parent_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); + EXPECT_EQ(0.f, + grand_parent->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, + parent_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ( + 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); TransformOperations scale; scale.AppendScale(5.f, 4.f, 3.f); @@ -7931,31 +7958,40 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { ExecuteCalculateDrawProperties(grand_parent.get()); // Only |child| has a scale-affecting animation. - EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, parent_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(5.f, child_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(5.f, grand_child_raw->last_maximum_animation_contents_scale()); + EXPECT_EQ(0.f, + grand_parent->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, + parent_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ( + 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); AddAnimatedTransformToLayer( grand_parent.get(), 1.0, TransformOperations(), scale); ExecuteCalculateDrawProperties(grand_parent.get()); // |grand_parent| and |child| have scale-affecting animations. - EXPECT_EQ(5.f, grand_parent->last_maximum_animation_contents_scale()); - EXPECT_EQ(5.f, parent_raw->last_maximum_animation_contents_scale()); + EXPECT_EQ(5.f, + grand_parent->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(5.f, + parent_raw->draw_properties().maximum_animation_contents_scale); // We don't support combining animated scales from two nodes; 0.f means // that the maximum scale could not be computed. - EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); + EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ( + 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); AddAnimatedTransformToLayer(parent_raw, 1.0, TransformOperations(), scale); ExecuteCalculateDrawProperties(grand_parent.get()); // |grand_parent|, |parent|, and |child| have scale-affecting animations. - EXPECT_EQ(5.f, grand_parent->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, parent_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); + EXPECT_EQ(5.f, + grand_parent->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, + parent_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ( + 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); grand_parent->layer_animation_controller()->AbortAnimations( Animation::Transform); @@ -7973,10 +8009,13 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { // |child| has a scale-affecting animation but computing the maximum of this // animation is not supported. - EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, parent_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); + EXPECT_EQ(0.f, + grand_parent->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, + parent_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ( + 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); child_raw->layer_animation_controller()->AbortAnimations( Animation::Transform); @@ -7990,10 +8029,15 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale // animation with maximum scale 5.f. - EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); - EXPECT_EQ(10.f, parent_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(10.f, child_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(10.f, grand_child_raw->last_maximum_animation_contents_scale()); + EXPECT_EQ(0.f, + grand_parent->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(10.f, + parent_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(10.f, + child_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ( + 10.f, + grand_child_raw->draw_properties().maximum_animation_contents_scale); gfx::Transform perspective_matrix; perspective_matrix.ApplyPerspectiveDepth(2.f); @@ -8001,20 +8045,26 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { ExecuteCalculateDrawProperties(grand_parent.get()); // |child| has a transform that's neither a translation nor a scale. - EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); - EXPECT_EQ(10.f, parent_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); + EXPECT_EQ(0.f, + grand_parent->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(10.f, + parent_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ( + 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); parent_raw->SetTransform(perspective_matrix); ExecuteCalculateDrawProperties(grand_parent.get()); // |parent| and |child| have transforms that are neither translations nor // scales. - EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, parent_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); + EXPECT_EQ(0.f, + grand_parent->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, + parent_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ( + 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); parent_raw->SetTransform(identity_matrix); child_raw->SetTransform(identity_matrix); @@ -8023,10 +8073,13 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { ExecuteCalculateDrawProperties(grand_parent.get()); // |grand_parent| has a transform that's neither a translation nor a scale. - EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, parent_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); - EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); + EXPECT_EQ(0.f, + grand_parent->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, + parent_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); + EXPECT_EQ( + 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); } static int membership_id(LayerImpl* layer) { @@ -8312,5 +8365,238 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { GatherDrawnLayers(render_surface_layer_list_impl(), &actual); EXPECT_EQ(expected, actual); } + +TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) { + FakeImplProxy proxy; + TestSharedBitmapManager shared_bitmap_manager; + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + + scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); + LayerImpl* root_layer = root.get(); + scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); + LayerImpl* child1_layer = child1.get(); + scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); + LayerImpl* child2_layer = child2.get(); + + root->AddChild(child1.Pass()); + root->AddChild(child2.Pass()); + + gfx::Transform identity_matrix, scale_transform_child1, + scale_transform_child2; + scale_transform_child1.Scale(2, 3); + scale_transform_child2.Scale(4, 5); + + SetLayerPropertiesForTesting(root_layer, + identity_matrix, + gfx::Point3F(), + gfx::PointF(), + gfx::Size(1, 1), + true, + false); + SetLayerPropertiesForTesting(child1_layer, + scale_transform_child1, + gfx::Point3F(), + gfx::PointF(), + gfx::Size(), + true, + false); + + child1_layer->SetMaskLayer( + LayerImpl::Create(host_impl.active_tree(), 4).Pass()); + + scoped_ptr<LayerImpl> replica_layer = + LayerImpl::Create(host_impl.active_tree(), 5); + replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); + child1_layer->SetReplicaLayer(replica_layer.Pass()); + + ExecuteCalculateDrawProperties(root_layer); + + TransformOperations scale; + scale.AppendScale(5.f, 8.f, 3.f); + + AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); + SetLayerPropertiesForTesting(child2_layer, + scale_transform_child2, + gfx::Point3F(), + gfx::PointF(), + gfx::Size(), + true, + false); + + ExecuteCalculateDrawProperties(root_layer); + + EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); + EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale); + EXPECT_FLOAT_EQ( + 3.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale); + EXPECT_FLOAT_EQ(3.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .ideal_contents_scale); + EXPECT_FLOAT_EQ(5.f, child2_layer->draw_properties().ideal_contents_scale); + + EXPECT_FLOAT_EQ( + 0.f, root_layer->draw_properties().maximum_animation_contents_scale); + EXPECT_FLOAT_EQ( + 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); + EXPECT_FLOAT_EQ(0.f, + child1_layer->mask_layer() + ->draw_properties() + .maximum_animation_contents_scale); + EXPECT_FLOAT_EQ(0.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .maximum_animation_contents_scale); + EXPECT_FLOAT_EQ( + 8.f, child2_layer->draw_properties().maximum_animation_contents_scale); + + EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); + EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().page_scale_factor); + EXPECT_FLOAT_EQ( + 1.f, child1_layer->mask_layer()->draw_properties().page_scale_factor); + EXPECT_FLOAT_EQ(1.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .page_scale_factor); + EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().page_scale_factor); + + EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor); + EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor); + EXPECT_FLOAT_EQ( + 1.f, child1_layer->mask_layer()->draw_properties().device_scale_factor); + EXPECT_FLOAT_EQ(1.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .device_scale_factor); + EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor); + + // Changing page-scale would affect ideal_contents_scale and + // maximum_animation_contents_scale. + + float page_scale_factor = 3.f; + float device_scale_factor = 1.0f; + std::vector<LayerImpl*> render_surface_layer_list; + gfx::Size device_viewport_size = + gfx::Size(root_layer->bounds().width() * device_scale_factor, + root_layer->bounds().height() * device_scale_factor); + LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( + root_layer, device_viewport_size, &render_surface_layer_list); + + inputs.page_scale_factor = page_scale_factor; + inputs.can_adjust_raster_scales = true; + inputs.page_scale_application_layer = root_layer; + LayerTreeHostCommon::CalculateDrawProperties(&inputs); + + EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); + EXPECT_FLOAT_EQ(9.f, child1_layer->draw_properties().ideal_contents_scale); + EXPECT_FLOAT_EQ( + 9.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale); + EXPECT_FLOAT_EQ(9.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .ideal_contents_scale); + EXPECT_FLOAT_EQ(15.f, child2_layer->draw_properties().ideal_contents_scale); + + EXPECT_FLOAT_EQ( + 0.f, root_layer->draw_properties().maximum_animation_contents_scale); + EXPECT_FLOAT_EQ( + 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); + EXPECT_FLOAT_EQ(0.f, + child1_layer->mask_layer() + ->draw_properties() + .maximum_animation_contents_scale); + EXPECT_FLOAT_EQ(0.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .maximum_animation_contents_scale); + EXPECT_FLOAT_EQ( + 24.f, child2_layer->draw_properties().maximum_animation_contents_scale); + + EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); + EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor); + EXPECT_FLOAT_EQ( + 3.f, child1_layer->mask_layer()->draw_properties().page_scale_factor); + EXPECT_FLOAT_EQ(3.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .page_scale_factor); + EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor); + + EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor); + EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor); + EXPECT_FLOAT_EQ( + 1.f, child1_layer->mask_layer()->draw_properties().device_scale_factor); + EXPECT_FLOAT_EQ(1.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .device_scale_factor); + EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor); + + // Changing device-scale would affect ideal_contents_scale and + // maximum_animation_contents_scale. + + device_scale_factor = 4.0f; + inputs.device_scale_factor = device_scale_factor; + inputs.can_adjust_raster_scales = true; + LayerTreeHostCommon::CalculateDrawProperties(&inputs); + + EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().ideal_contents_scale); + EXPECT_FLOAT_EQ(36.f, child1_layer->draw_properties().ideal_contents_scale); + EXPECT_FLOAT_EQ( + 36.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale); + EXPECT_FLOAT_EQ(36.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .ideal_contents_scale); + EXPECT_FLOAT_EQ(60.f, child2_layer->draw_properties().ideal_contents_scale); + + EXPECT_FLOAT_EQ( + 0.f, root_layer->draw_properties().maximum_animation_contents_scale); + EXPECT_FLOAT_EQ( + 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); + EXPECT_FLOAT_EQ(0.f, + child1_layer->mask_layer() + ->draw_properties() + .maximum_animation_contents_scale); + EXPECT_FLOAT_EQ(0.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .maximum_animation_contents_scale); + EXPECT_FLOAT_EQ( + 96.f, child2_layer->draw_properties().maximum_animation_contents_scale); + + EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); + EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor); + EXPECT_FLOAT_EQ( + 3.f, child1_layer->mask_layer()->draw_properties().page_scale_factor); + EXPECT_FLOAT_EQ(3.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .page_scale_factor); + EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor); + + EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().device_scale_factor); + EXPECT_FLOAT_EQ(4.f, child1_layer->draw_properties().device_scale_factor); + EXPECT_FLOAT_EQ( + 4.f, child1_layer->mask_layer()->draw_properties().device_scale_factor); + EXPECT_FLOAT_EQ(4.f, + child1_layer->replica_layer() + ->mask_layer() + ->draw_properties() + .device_scale_factor); + EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor); +} + } // namespace } // namespace cc diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 7f6ae44ff7..53c2f0d2ce 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -32,6 +32,7 @@ #include "cc/layers/layer_impl.h" #include "cc/layers/layer_iterator.h" #include "cc/layers/painted_scrollbar_layer_impl.h" +#include "cc/layers/quad_sink.h" #include "cc/layers/render_surface_impl.h" #include "cc/layers/scrollbar_layer_impl_base.h" #include "cc/output/compositor_frame_metadata.h" @@ -60,7 +61,6 @@ #include "cc/trees/layer_tree_host_common.h" #include "cc/trees/layer_tree_impl.h" #include "cc/trees/occlusion_tracker.h" -#include "cc/trees/quad_culler.h" #include "cc/trees/single_thread_proxy.h" #include "cc/trees/tree_synchronizer.h" #include "gpu/GLES2/gl2extchromium.h" @@ -154,17 +154,17 @@ class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); } - // TODO(enne): This should probably happen post-animate. - if (layer_tree_host_impl_->pending_tree()) { - layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); - layer_tree_host_impl_->ManageTiles(); - } - layer_tree_host_impl_->Animate( layer_tree_host_impl_->CurrentFrameTimeTicks()); layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); bool start_ready_animations = true; layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); + + if (layer_tree_host_impl_->pending_tree()) { + layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); + layer_tree_host_impl_->ManageTiles(); + } + layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); } @@ -315,7 +315,12 @@ void LayerTreeHostImpl::BeginMainFrameAborted(bool did_handle) { } } -void LayerTreeHostImpl::BeginCommit() {} +void LayerTreeHostImpl::BeginCommit() { + TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit"); + + if (settings_.impl_side_painting) + CreatePendingTree(); +} void LayerTreeHostImpl::CommitComplete() { TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); @@ -333,6 +338,13 @@ void LayerTreeHostImpl::CommitComplete() { else ManageTiles(); } else { + // If we're not in impl-side painting, the tree is immediately considered + // active. + active_tree_->ProcessUIResourceRequestQueue(); + active_tree_->DidBecomeActive(); + + ActivateAnimations(); + active_tree_->set_needs_update_draw_properties(); if (time_source_client_adapter_ && time_source_client_adapter_->Active()) DCHECK(active_tree_->root_layer()); @@ -474,9 +486,6 @@ bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( if (!CurrentlyScrollingLayer()) return false; - if (!EnsureRenderSurfaceLayerList()) - return false; - gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, device_scale_factor_); @@ -493,8 +502,6 @@ bool LayerTreeHostImpl::HaveTouchEventHandlersAt( const gfx::Point& viewport_point) { if (!settings_.touch_hit_testing) return true; - if (!EnsureRenderSurfaceLayerList()) - return false; gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, device_scale_factor_); @@ -582,7 +589,7 @@ static void AppendQuadsForLayer( LayerImpl* layer, const OcclusionTracker<LayerImpl>& occlusion_tracker, AppendQuadsData* append_quads_data) { - QuadCuller quad_culler(target_render_pass, layer, occlusion_tracker); + QuadSink quad_culler(target_render_pass, &occlusion_tracker); layer->AppendQuads(&quad_culler, append_quads_data); } @@ -592,7 +599,7 @@ static void AppendQuadsForRenderSurfaceLayer( const RenderPass* contributing_render_pass, const OcclusionTracker<LayerImpl>& occlusion_tracker, AppendQuadsData* append_quads_data) { - QuadCuller quad_culler(target_render_pass, layer, occlusion_tracker); + QuadSink quad_culler(target_render_pass, &occlusion_tracker); bool is_replica = false; layer->render_surface()->AppendQuads(&quad_culler, @@ -635,7 +642,7 @@ static void AppendQuadsToFillScreen( screen_background_color_region.Intersect(root_scroll_layer_rect); } - QuadCuller quad_culler(target_render_pass, root_layer, occlusion_tracker); + QuadSink quad_culler(target_render_pass, &occlusion_tracker); // Manually create the quad state for the gutter quads, as the root layer // doesn't have any bounds and so can't generate this itself. @@ -1094,7 +1101,8 @@ DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { } need_to_update_visible_tiles_before_draw_ = true; - active_tree_->UpdateDrawProperties(); + bool ok = active_tree_->UpdateDrawProperties(); + DCHECK(ok) << "UpdateDrawProperties failed during draw"; frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); frame->render_passes.clear(); @@ -1236,6 +1244,10 @@ void LayerTreeHostImpl::DidInitializeVisibleTile() { client_->DidInitializeVisibleTileOnImplThread(); } +const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() { + return picture_layers_; +} + void LayerTreeHostImpl::NotifyReadyToActivate() { client_->NotifyReadyToActivate(); } @@ -1448,8 +1460,9 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, } TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( - TRACE_DISABLED_BY_DEFAULT("cc.debug") "," TRACE_DISABLED_BY_DEFAULT( - "cc.debug.quads"), + TRACE_DISABLED_BY_DEFAULT("cc.debug") "," + TRACE_DISABLED_BY_DEFAULT("cc.debug.quads") "," + TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers"), "cc::LayerTreeHostImpl", id_, TracedValue::FromValue(AsValueWithFrame(frame).release())); @@ -1686,6 +1699,13 @@ void LayerTreeHostImpl::CreatePendingTree() { recycle_tree_.swap(pending_tree_); else pending_tree_ = LayerTreeImpl::create(this); + + // Update the delta from the active tree, which may have + // adjusted its delta prior to the pending tree being created. + DCHECK_EQ(1.f, pending_tree_->sent_page_scale_delta()); + pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / + active_tree_->sent_page_scale_delta()); + client_->OnCanDrawStateChanged(CanDraw()); TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); } @@ -1750,8 +1770,6 @@ void LayerTreeHostImpl::ActivatePendingTree() { if (time_source_client_adapter_ && time_source_client_adapter_->Active()) DCHECK(active_tree_->root_layer()); - devtools_instrumentation::DidActivateLayerTree( - id_, active_tree_->source_frame_number()); } void LayerTreeHostImpl::SetVisible(bool visible) { @@ -2005,8 +2023,9 @@ bool LayerTreeHostImpl::InitializeRenderer( // TODO(brianderson): Don't use a hard-coded parent draw time. base::TimeDelta parent_draw_time = - output_surface_->capabilities().adjust_deadline_for_parent - ? BeginFrameArgs::DefaultDeadlineAdjustment() + (!settings_.begin_frame_scheduling_enabled && + output_surface_->capabilities().adjust_deadline_for_parent) + ? BeginFrameArgs::DefaultEstimatedParentDrawTime() : base::TimeDelta(); client_->SetEstimatedParentDrawTime(parent_draw_time); @@ -2031,12 +2050,14 @@ void LayerTreeHostImpl::DeferredInitialize() { ReleaseTreeResources(); renderer_.reset(); + DestroyTileManager(); resource_provider_->InitializeGL(); CreateAndSetRenderer(); - EnforceZeroBudget(false); + CreateAndSetTileManager(); + client_->SetNeedsCommitOnImplThread(); } @@ -2048,11 +2069,11 @@ void LayerTreeHostImpl::ReleaseGL() { ReleaseTreeResources(); renderer_.reset(); DestroyTileManager(); - resource_provider_->InitializeSoftware(); + resource_provider_->InitializeSoftware(); output_surface_->ReleaseContextProvider(); - CreateAndSetRenderer(); + CreateAndSetRenderer(); EnforceZeroBudget(true); CreateAndSetTileManager(); @@ -2128,11 +2149,6 @@ void LayerTreeHostImpl::DidChangeTopControlsPosition() { SetFullRootLayerDamage(); } -bool LayerTreeHostImpl::EnsureRenderSurfaceLayerList() { - active_tree_->UpdateDrawProperties(); - return !active_tree_->RenderSurfaceLayerList().empty(); -} - void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { DCHECK(input_handler_client_ == NULL); input_handler_client_ = client; @@ -2153,7 +2169,7 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( DCHECK(scroll_on_main_thread); // Walk up the hierarchy and look for a scrollable layer. - LayerImpl* potentially_scrolling_layer_impl = 0; + LayerImpl* potentially_scrolling_layer_impl = NULL; for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { // The content layer can also block attempts to scroll outside the main // thread. @@ -2215,9 +2231,6 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( DCHECK(!CurrentlyScrollingLayer()); ClearCurrentlyScrollingLayer(); - if (!EnsureRenderSurfaceLayerList()) - return ScrollIgnored; - gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, device_scale_factor_); LayerImpl* layer_impl = @@ -2527,6 +2540,7 @@ void LayerTreeHostImpl::SetRootLayerScrollOffsetDelegate( void LayerTreeHostImpl::OnRootLayerDelegatedScrollOffsetChanged() { DCHECK(root_layer_scroll_offset_delegate_ != NULL); client_->SetNeedsCommitOnImplThread(); + active_tree_->set_needs_update_draw_properties(); } void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { @@ -2581,9 +2595,6 @@ float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( } void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { - if (!EnsureRenderSurfaceLayerList()) - return; - gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, device_scale_factor_); LayerImpl* layer_impl = @@ -3135,4 +3146,17 @@ void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { (*it)->OnSetNeedsRedrawOnImpl(); } +void LayerTreeHostImpl::RegisterPictureLayerImpl(PictureLayerImpl* layer) { + DCHECK(std::find(picture_layers_.begin(), picture_layers_.end(), layer) == + picture_layers_.end()); + picture_layers_.push_back(layer); +} + +void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { + std::vector<PictureLayerImpl*>::iterator it = + std::find(picture_layers_.begin(), picture_layers_.end(), layer); + DCHECK(it != picture_layers_.end()); + picture_layers_.erase(it); +} + } // namespace cc diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 45fefe578b..db9c325849 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -48,6 +48,7 @@ class LayerTreeImpl; class MemoryHistory; class PageScaleAnimation; class PaintTimeCounter; +class PictureLayerImpl; class RasterWorkerPool; class RenderPassDrawQuad; class RenderingStatsInstrumentation; @@ -231,6 +232,7 @@ class CC_EXPORT LayerTreeHostImpl virtual void SetFullRootLayerDamage() OVERRIDE; // TileManagerClient implementation. + virtual const std::vector<PictureLayerImpl*>& GetPictureLayers() OVERRIDE; virtual void NotifyReadyToActivate() OVERRIDE; virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE; @@ -263,6 +265,7 @@ class CC_EXPORT LayerTreeHostImpl void OnCanDrawStateChangedForTree(); // Implementation. + int id() const { return id_; } bool CanDraw() const; OutputSurface* output_surface() const { return output_surface_.get(); } @@ -293,6 +296,13 @@ class CC_EXPORT LayerTreeHostImpl LayerTreeImpl* pending_tree() { return pending_tree_.get(); } const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); } const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); } + // Returns the tree LTH synchronizes with. + LayerTreeImpl* sync_tree() { + // In impl-side painting, synchronize to the pending tree so that it has + // time to raster before being displayed. + return settings_.impl_side_painting ? pending_tree_.get() + : active_tree_.get(); + } virtual void CreatePendingTree(); virtual void UpdateVisibleTiles(); virtual void ActivatePendingTree(); @@ -457,6 +467,9 @@ class CC_EXPORT LayerTreeHostImpl void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor); void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor); + void RegisterPictureLayerImpl(PictureLayerImpl* layer); + void UnregisterPictureLayerImpl(PictureLayerImpl* layer); + protected: LayerTreeHostImpl( const LayerTreeSettings& settings, @@ -517,7 +530,6 @@ class CC_EXPORT LayerTreeHostImpl // the frame should be drawn. DrawResult CalculateRenderPasses(FrameData* frame); - bool EnsureRenderSurfaceLayerList(); void ClearCurrentlyScrollingLayer(); bool HandleMouseOverScrollbar(LayerImpl* layer_impl, @@ -682,6 +694,8 @@ class CC_EXPORT LayerTreeHostImpl size_t transfer_buffer_memory_limit_; + std::vector<PictureLayerImpl*> picture_layers_; + DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); }; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 45d533b5fb..600ace79e4 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -538,7 +538,7 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { // We should not crash when trying to scroll after the renderer initialization // fails. - EXPECT_EQ(InputHandler::ScrollIgnored, + EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); } @@ -1641,8 +1641,7 @@ TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) { } } -// TODO(enne): Convert this to PictureLayerImpl -class DidDrawCheckLayer : public TiledLayerImpl { +class DidDrawCheckLayer : public LayerImpl { public: static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { return scoped_ptr<LayerImpl>(new DidDrawCheckLayer(tree_impl, id)); @@ -1653,18 +1652,18 @@ class DidDrawCheckLayer : public TiledLayerImpl { will_draw_called_ = true; if (will_draw_returns_false_) return false; - return TiledLayerImpl::WillDraw(draw_mode, provider); + return LayerImpl::WillDraw(draw_mode, provider); } virtual void AppendQuads(QuadSink* quad_sink, AppendQuadsData* append_quads_data) OVERRIDE { append_quads_called_ = true; - TiledLayerImpl::AppendQuads(quad_sink, append_quads_data); + LayerImpl::AppendQuads(quad_sink, append_quads_data); } virtual void DidDraw(ResourceProvider* provider) OVERRIDE { did_draw_called_ = true; - TiledLayerImpl::DidDraw(provider); + LayerImpl::DidDraw(provider); } bool will_draw_called() const { return will_draw_called_; } @@ -1681,7 +1680,7 @@ class DidDrawCheckLayer : public TiledLayerImpl { protected: DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) - : TiledLayerImpl(tree_impl, id), + : LayerImpl(tree_impl, id), will_draw_returns_false_(false), will_draw_called_(false), append_quads_called_(false), @@ -1689,14 +1688,7 @@ class DidDrawCheckLayer : public TiledLayerImpl { SetBounds(gfx::Size(10, 10)); SetContentBounds(gfx::Size(10, 10)); SetDrawsContent(true); - set_skips_draw(false); draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); - - scoped_ptr<LayerTilingData> tiler = - LayerTilingData::Create(gfx::Size(100, 100), - LayerTilingData::HAS_BORDER_TEXELS); - tiler->SetTilingRect(gfx::Rect(content_bounds())); - SetTilingData(*tiler.get()); } private: @@ -1872,69 +1864,59 @@ class MissingTextureAnimatingLayer : public DidDrawCheckLayer { static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id, bool tile_missing, - bool skips_draw, + bool had_incomplete_tile, bool animating, ResourceProvider* resource_provider) { - return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer( - tree_impl, - id, - tile_missing, - skips_draw, - animating, - resource_provider)); + return scoped_ptr<LayerImpl>( + new MissingTextureAnimatingLayer(tree_impl, + id, + tile_missing, + had_incomplete_tile, + animating, + resource_provider)); } virtual void AppendQuads(QuadSink* quad_sink, AppendQuadsData* append_quads_data) OVERRIDE { - TiledLayerImpl::AppendQuads(quad_sink, append_quads_data); - if (tile_missing_) + LayerImpl::AppendQuads(quad_sink, append_quads_data); + if (had_incomplete_tile_) append_quads_data->had_incomplete_tile = true; + if (tile_missing_) + append_quads_data->num_missing_tiles++; } private: MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, int id, bool tile_missing, - bool skips_draw, + bool had_incomplete_tile, bool animating, ResourceProvider* resource_provider) - : DidDrawCheckLayer(tree_impl, id), tile_missing_(tile_missing) { - scoped_ptr<LayerTilingData> tiling_data = - LayerTilingData::Create(gfx::Size(10, 10), - LayerTilingData::NO_BORDER_TEXELS); - tiling_data->SetTilingRect(gfx::Rect(bounds())); - SetTilingData(*tiling_data.get()); - set_skips_draw(skips_draw); - if (!tile_missing) { - ResourceProvider::ResourceId resource = - resource_provider->CreateResource(gfx::Size(1, 1), - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - RGBA_8888); - resource_provider->AllocateForTesting(resource); - PushTileProperties(0, 0, resource, gfx::Rect(), false); - } + : DidDrawCheckLayer(tree_impl, id), + tile_missing_(tile_missing), + had_incomplete_tile_(had_incomplete_tile) { if (animating) AddAnimatedTransformToLayer(this, 10.0, 3, 0); } bool tile_missing_; + bool had_incomplete_tile_; }; -TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenNoTexturesMissing) { +TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { host_impl_->active_tree()->SetRootLayer( DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); bool tile_missing = false; - bool skips_draw = false; + bool had_incomplete_tile = false; bool is_animating = false; root->AddChild( MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2, tile_missing, - skips_draw, + had_incomplete_tile, is_animating, host_impl_->resource_provider())); @@ -1951,13 +1933,13 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); bool tile_missing = false; - bool skips_draw = false; + bool had_incomplete_tile = false; bool is_animating = true; root->AddChild( MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2, tile_missing, - skips_draw, + had_incomplete_tile, is_animating, host_impl_->resource_provider())); @@ -1968,23 +1950,20 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { host_impl_->DidDrawAllLayers(frame); } -TEST_F(LayerTreeHostImplTest, - PrepareToDrawSucceedsWithNonAnimatedMissingTexture) { - // When a texture is missing and we're not animating, we draw as usual with - // checkerboarding. +TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { host_impl_->active_tree()->SetRootLayer( DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); bool tile_missing = true; - bool skips_draw = false; + bool had_incomplete_tile = false; bool is_animating = false; root->AddChild( MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 4, tile_missing, - skips_draw, + had_incomplete_tile, is_animating, host_impl_->resource_provider())); LayerTreeHostImpl::FrameData frame; @@ -1993,21 +1972,42 @@ TEST_F(LayerTreeHostImplTest, host_impl_->DidDrawAllLayers(frame); } -TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { - // When a texture is missing and we're animating, we don't want to draw - // anything. +TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { + host_impl_->active_tree()->SetRootLayer( + DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); + DidDrawCheckLayer* root = + static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); + + bool tile_missing = false; + bool had_incomplete_tile = true; + bool is_animating = false; + root->AddChild( + MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), + 4, + tile_missing, + had_incomplete_tile, + is_animating, + host_impl_->resource_provider())); + LayerTreeHostImpl::FrameData frame; + EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); + host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); + host_impl_->DidDrawAllLayers(frame); +} + +TEST_F(LayerTreeHostImplTest, + PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { host_impl_->active_tree()->SetRootLayer( DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); bool tile_missing = true; - bool skips_draw = false; + bool had_incomplete_tile = false; bool is_animating = true; root->AddChild( MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 6, tile_missing, - skips_draw, + had_incomplete_tile, is_animating, host_impl_->resource_provider())); LayerTreeHostImpl::FrameData frame; @@ -2018,20 +2018,19 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { } TEST_F(LayerTreeHostImplTest, - PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) { - // When the layer skips draw and we're animating, we still draw the frame. + PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { host_impl_->active_tree()->SetRootLayer( - DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); + DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); bool tile_missing = false; - bool skips_draw = true; + bool had_incomplete_tile = true; bool is_animating = true; root->AddChild( MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), - 8, + 6, tile_missing, - skips_draw, + had_incomplete_tile, is_animating, host_impl_->resource_provider())); LayerTreeHostImpl::FrameData frame; @@ -2040,21 +2039,19 @@ TEST_F(LayerTreeHostImplTest, host_impl_->DidDrawAllLayers(frame); } -TEST_F(LayerTreeHostImplTest, - PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) { - // When the layer skips draw and we're animating, we still draw the frame. +TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { host_impl_->active_tree()->SetRootLayer( DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); bool tile_missing = false; - bool skips_draw = false; + bool had_incomplete_tile = false; bool is_animating = false; root->AddChild( MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 8, tile_missing, - skips_draw, + had_incomplete_tile, is_animating, host_impl_->resource_provider())); host_impl_->active_tree()->SetRequiresHighResToDraw(); @@ -2065,20 +2062,19 @@ TEST_F(LayerTreeHostImplTest, } TEST_F(LayerTreeHostImplTest, - PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) { - // When the layer skips draw and we're animating, we still draw the frame. + PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { host_impl_->active_tree()->SetRootLayer( DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); - bool tile_missing = true; - bool skips_draw = false; + bool tile_missing = false; + bool had_incomplete_tile = true; bool is_animating = false; root->AddChild( MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 8, tile_missing, - skips_draw, + had_incomplete_tile, is_animating, host_impl_->resource_provider())); host_impl_->active_tree()->SetRequiresHighResToDraw(); @@ -2089,6 +2085,29 @@ TEST_F(LayerTreeHostImplTest, host_impl_->DidDrawAllLayers(frame); } +TEST_F(LayerTreeHostImplTest, + PrepareToDrawSucceedsWhenHighResRequiredAndMissingTile) { + host_impl_->active_tree()->SetRootLayer( + DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); + DidDrawCheckLayer* root = + static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); + bool tile_missing = true; + bool had_incomplete_tile = false; + bool is_animating = false; + root->AddChild( + MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), + 8, + tile_missing, + had_incomplete_tile, + is_animating, + host_impl_->resource_provider())); + host_impl_->active_tree()->SetRequiresHighResToDraw(); + LayerTreeHostImpl::FrameData frame; + EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); + host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); + host_impl_->DidDrawAllLayers(frame); +} + TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); root->SetScrollClipLayer(Layer::INVALID_ID); @@ -3156,6 +3175,42 @@ TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { scroll_layer->TotalScrollOffset().ToString()); } +void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { + const gfx::Transform target_space_transform = + layer->draw_properties().target_space_transform; + EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); + gfx::Point translated_point; + target_space_transform.TransformPoint(&translated_point); + gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); + EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); +} + +TEST_F(LayerTreeHostImplTest, + ExternalRootLayerScrollOffsetDelegationReflectedInNextDraw) { + TestScrollOffsetDelegate scroll_delegate; + host_impl_->SetViewportSize(gfx::Size(10, 20)); + LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); + LayerImpl* clip_layer = scroll_layer->parent()->parent(); + clip_layer->SetBounds(gfx::Size(10, 20)); + host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate); + + // Draw first frame to clear any pending draws and check scroll. + DrawFrame(); + CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f)); + EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); + + // Set external scroll delta on delegate and notify LayerTreeHost. + gfx::Vector2dF scroll_delta(10.f, 10.f); + scroll_delegate.set_getter_return_value(scroll_delta); + host_impl_->OnRootLayerDelegatedScrollOffsetChanged(); + + // Check scroll delta reflected in layer. + DrawFrame(); + CheckLayerScrollDelta(scroll_layer, scroll_delta); + + host_impl_->SetRootLayerScrollOffsetDelegate(NULL); +} + TEST_F(LayerTreeHostImplTest, OverscrollRoot) { SetupScrollAndContentsLayers(gfx::Size(100, 100)); host_impl_->SetViewportSize(gfx::Size(50, 50)); @@ -6530,12 +6585,14 @@ TEST_F(LayerTreeHostImplTest, UpdateTilesForMasksWithNoVisibleContent) { 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>()); @@ -6544,6 +6601,7 @@ TEST_F(LayerTreeHostImplTest, UpdateTilesForMasksWithNoVisibleContent) { 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>()); diff --git a/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc b/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc index 5bc2f318a9..0d31709f28 100644 --- a/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc +++ b/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc @@ -41,8 +41,9 @@ class LayerTreeHostOnDemandRasterPixelTest : public LayerTreePixelTest { PictureLayerImpl* picture_layer = static_cast<PictureLayerImpl*>( host_impl->active_tree()->root_layer()->child_at(0)); + MockOcclusionTracker<LayerImpl> occlusion_tracker; scoped_ptr<RenderPass> render_pass = RenderPass::Create(); - MockQuadCuller quad_culler(render_pass.get()); + MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); AppendQuadsData data; picture_layer->AppendQuads(&quad_culler, &data); diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 870f2df5f8..6b781cb60e 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -574,15 +574,13 @@ class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { // and each damage should be the bounding box of it and its child. If this // was working improperly, the damage might not include its childs bounding // box. - // TODO(enne): This compositor thread function is asking for the - // frame number from the layer tree host on the main thread. :( - switch (layer_tree_host()->source_frame_number()) { - case 1: + switch (host_impl->active_tree()->source_frame_number()) { + case 0: EXPECT_RECT_EQ(gfx::Rect(root_layer_->bounds()), root_damage_rect); break; + case 1: case 2: case 3: - case 4: EXPECT_RECT_EQ(gfx::Rect(child_layer_->bounds()), root_damage_rect); break; default: @@ -623,8 +621,7 @@ class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { scoped_refptr<FakeContentLayer> child_layer_; }; -// TODO(enne): http://crbug.com/380895 -// SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater); +SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater); // Tests that if a layer is not drawn because of some reason in the parent, // causing its content bounds to not be computed, then when it is later drawn, @@ -2213,7 +2210,11 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest { }; virtual void SetupTree() OVERRIDE { - scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_); + scoped_refptr<Layer> root_layer; + if (layer_tree_host()->settings().impl_side_painting) + root_layer = PictureLayer::Create(&client_); + else + root_layer = ContentLayer::Create(&client_); root_layer->SetIsDrawable(true); root_layer->SetBounds(gfx::Size(1, 1)); @@ -2234,7 +2235,7 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest { virtual void DidCommit() OVERRIDE { switch (layer_tree_host()->source_frame_number()) { case 1: - // The first update consists one LCD notification and one paint. + // The first update consists of one LCD notification and one paint. EXPECT_EQ(1, client_.lcd_notification_count()); EXPECT_EQ(1, client_.paint_count()); // LCD text must have been enabled on the layer. @@ -2253,7 +2254,7 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest { // No need to request a commit - setting opacity will do it. break; default: - // Verify that there is not extra commit due to layer invalidation. + // Verify that there is no extra commit due to layer invalidation. EXPECT_EQ(3, layer_tree_host()->source_frame_number()); // LCD notification count should have incremented due to // change in layer opacity. @@ -2271,7 +2272,7 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest { NotificationClient client_; }; -SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); +SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification); // Verify that the BeginFrame notification is used to initiate rendering. class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { @@ -4202,7 +4203,7 @@ class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { // Expect that the transfer buffer memory used is equal to the // MaxTransferBufferUsageBytes value set in CreateOutputSurface. - EXPECT_EQ(1024 * 1024u, context->GetTransferBufferMemoryUsedBytes()); + EXPECT_EQ(1024 * 1024u, context->max_used_transfer_buffer_usage_bytes()); EndTest(); } @@ -4213,10 +4214,7 @@ class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { }; // Impl-side painting is a multi-threaded compositor feature. -// Disabled for flakiness: http://crbug.com/380662 -#if 0 MULTI_THREAD_TEST_F(LayerTreeHostTestMaxTransferBufferUsageBytes); -#endif // Test ensuring that memory limits are sent to the prioritized resource // manager. @@ -4633,7 +4631,8 @@ class LayerTreeHostTestHighResRequiredAfterEvictingUIResources scoped_ptr<FakeScopedUIResource> ui_resource_; }; -MULTI_THREAD_TEST_F(LayerTreeHostTestHighResRequiredAfterEvictingUIResources); +// This test is flaky, see http://crbug.com/386199 +//MULTI_THREAD_TEST_F(LayerTreeHostTestHighResRequiredAfterEvictingUIResources); class LayerTreeHostTestGpuRasterizationDefault : public LayerTreeHostTest { protected: diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc index 6aaf7cac40..1542a1417b 100644 --- a/cc/trees/layer_tree_host_unittest_animation.cc +++ b/cc/trees/layer_tree_host_unittest_animation.cc @@ -1305,13 +1305,14 @@ class LayerTreeHostAnimationTestAddAnimationAfterAnimating virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) OVERRIDE { - // The third frame is when both animations have started. Check that both - // have a valid start time. - if (++num_swap_buffers_ == 3) { + // After both animations have started, verify that they have valid + // start times. + num_swap_buffers_++; + AnimationRegistrar::AnimationControllerMap copy = + host_impl->animation_registrar()->active_animation_controllers(); + if (copy.size() == 2u) { EndTest(); - AnimationRegistrar::AnimationControllerMap copy = - host_impl->animation_registrar()->active_animation_controllers(); - EXPECT_EQ(2u, copy.size()); + EXPECT_GE(num_swap_buffers_, 3); for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); iter != copy.end(); diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc index 47edbb144a..879e5347e3 100644 --- a/cc/trees/layer_tree_host_unittest_context.cc +++ b/cc/trees/layer_tree_host_unittest_context.cc @@ -1473,5 +1473,64 @@ class LayerTreeHostContextTestSurfaceCreateCallback SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); +class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame + : public LayerTreeHostContextTest { + protected: + virtual void BeginTest() OVERRIDE { + deferred_ = false; + PostSetNeedsCommitToMainThread(); + } + + virtual void ScheduledActionWillSendBeginMainFrame() OVERRIDE { + if (deferred_) + return; + deferred_ = true; + + // Defer commits before the BeginFrame arrives, causing it to be delayed. + MainThreadTaskRunner()->PostTask( + FROM_HERE, + base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: + DeferCommitsOnMainThread, + base::Unretained(this), + true)); + // Meanwhile, lose the context while we are in defer commits. + ImplThreadTaskRunner()->PostTask( + FROM_HERE, + base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: + LoseContextOnImplThread, + base::Unretained(this))); + } + + void LoseContextOnImplThread() { + LoseContext(); + + // After losing the context, stop deferring commits. + MainThreadTaskRunner()->PostTask( + FROM_HERE, + base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: + DeferCommitsOnMainThread, + base::Unretained(this), + false)); + } + + void DeferCommitsOnMainThread(bool defer_commits) { + layer_tree_host()->SetDeferCommits(defer_commits); + } + + virtual void WillBeginMainFrame() OVERRIDE { + // Don't begin a frame with a lost surface. + EXPECT_FALSE(layer_tree_host()->output_surface_lost()); + } + + virtual void DidCommitAndDrawFrame() OVERRIDE { EndTest(); } + + virtual void AfterTest() OVERRIDE {} + + bool deferred_; +}; + +// TODO(danakj): We don't use scheduler with SingleThreadProxy yet. +MULTI_THREAD_TEST_F(LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); + } // namespace } // namespace cc diff --git a/cc/trees/layer_tree_host_unittest_delegated.cc b/cc/trees/layer_tree_host_unittest_delegated.cc index dfef15effb..37c928b9bd 100644 --- a/cc/trees/layer_tree_host_unittest_delegated.cc +++ b/cc/trees/layer_tree_host_unittest_delegated.cc @@ -516,39 +516,35 @@ class LayerTreeHostDelegatedTestLayerUsesFrameDamage layer_tree_host()->SetNeedsCommit(); break; case 9: - // Should damage the full layer. - delegated_->SetDisplaySize(gfx::Size(10, 10)); - break; - case 10: // Should create zero damage. layer_tree_host()->SetNeedsCommit(); break; - case 11: + case 10: // Changing the frame size damages the full layer. SetFrameData( CreateFrameData(gfx::Rect(0, 0, 5, 5), gfx::Rect(4, 4, 1, 1))); break; - case 12: + case 11: // An invalid frame isn't used, so it should not cause damage. SetFrameData(CreateInvalidFrameData(gfx::Rect(0, 0, 5, 5), gfx::Rect(4, 4, 1, 1))); break; - case 13: + case 12: // Should create gfx::Rect(1, 1, 2, 2) of damage. SetFrameData( CreateFrameData(gfx::Rect(0, 0, 5, 5), gfx::Rect(1, 1, 2, 2))); break; - case 14: + case 13: // Should create zero damage. layer_tree_host()->SetNeedsCommit(); break; - case 15: + case 14: // Moving the layer out of the tree and back in will damage the whole // impl layer. delegated_->RemoveFromParent(); layer_tree_host()->root_layer()->AddChild(delegated_); break; - case 16: + case 15: // Make a larger frame with lots of damage. Then a frame smaller than // the first frame's damage. The entire layer should be damaged, but // nothing more. @@ -557,7 +553,7 @@ class LayerTreeHostDelegatedTestLayerUsesFrameDamage SetFrameData( CreateFrameData(gfx::Rect(0, 0, 5, 5), gfx::Rect(1, 1, 2, 2))); break; - case 17: + case 16: // Make a frame with lots of damage. Then replace it with a frame with // no damage. The entire layer should be damaged, but nothing more. SetFrameData( @@ -565,7 +561,7 @@ class LayerTreeHostDelegatedTestLayerUsesFrameDamage SetFrameData( CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(0, 0, 0, 0))); break; - case 18: + case 17: // Make another layer that uses the same frame provider. The new layer // should be damaged. delegated_copy_ = CreateDelegatedLayer(frame_provider_); @@ -575,7 +571,7 @@ class LayerTreeHostDelegatedTestLayerUsesFrameDamage SetFrameData( CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(4, 0, 1, 1))); break; - case 19: + case 18: // Set another new frame, both layers should be damaged in the same // ways. SetFrameData( @@ -632,22 +628,22 @@ class LayerTreeHostDelegatedTestLayerUsesFrameDamage EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); break; case 9: - EXPECT_EQ(gfx::Rect(6, 6).ToString(), damage_rect.ToString()); + EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); break; case 10: - EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); break; case 11: - EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); + EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); break; case 12: - EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(1, 1, 2, 2).ToString(), damage_rect.ToString()); break; case 13: - EXPECT_EQ(gfx::Rect(1, 1, 2, 2).ToString(), damage_rect.ToString()); + EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); break; case 14: - EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); break; case 15: EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); @@ -656,14 +652,11 @@ class LayerTreeHostDelegatedTestLayerUsesFrameDamage EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); break; case 17: - EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); - break; - case 18: EXPECT_EQ(gfx::UnionRects(gfx::Rect(5, 0, 10, 10), gfx::Rect(4, 0, 1, 1)).ToString(), damage_rect.ToString()); break; - case 19: + case 18: EXPECT_EQ(gfx::Rect(3, 3, 6, 1).ToString(), damage_rect.ToString()); EndTest(); break; diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 9932a33be0..2a38d89abd 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -14,6 +14,7 @@ #include "cc/animation/scrollbar_animation_controller_thinning.h" #include "cc/base/math_util.h" #include "cc/base/util.h" +#include "cc/debug/devtools_instrumentation.h" #include "cc/debug/traced_value.h" #include "cc/layers/heads_up_display_layer_impl.h" #include "cc/layers/layer.h" @@ -188,15 +189,14 @@ void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { DCHECK_EQ(ui_resource_request_queue_.size(), 0u); if (next_activation_forces_redraw_) { - layer_tree_host_impl_->SetFullRootLayerDamage(); + target_tree->ForceRedrawNextActivation(); next_activation_forces_redraw_ = false; } target_tree->PassSwapPromises(&swap_promise_list_); - target_tree->SetPageScaleFactorAndLimits( - page_scale_factor(), min_page_scale_factor(), max_page_scale_factor()); - target_tree->SetPageScaleDelta( + target_tree->SetPageScaleValues( + page_scale_factor(), min_page_scale_factor(), max_page_scale_factor(), target_tree->page_scale_delta() / target_tree->sent_page_scale_delta()); target_tree->set_sent_page_scale_delta(1); @@ -290,54 +290,50 @@ void ForceScrollbarParameterUpdateAfterScaleChange(LayerImpl* current_layer) { void LayerTreeImpl::SetPageScaleFactorAndLimits(float page_scale_factor, float min_page_scale_factor, float max_page_scale_factor) { - if (!page_scale_factor) - return; + SetPageScaleValues(page_scale_factor, min_page_scale_factor, + max_page_scale_factor, page_scale_delta_); +} - if (min_page_scale_factor == min_page_scale_factor_ && - max_page_scale_factor == max_page_scale_factor_ && - page_scale_factor == page_scale_factor_) - return; +void LayerTreeImpl::SetPageScaleDelta(float delta) { + SetPageScaleValues(page_scale_factor_, min_page_scale_factor_, + max_page_scale_factor_, delta); +} + +void LayerTreeImpl::SetPageScaleValues(float page_scale_factor, + float min_page_scale_factor, float max_page_scale_factor, + float page_scale_delta) { + bool page_scale_changed = + min_page_scale_factor != min_page_scale_factor_ || + max_page_scale_factor != max_page_scale_factor_ || + page_scale_factor != page_scale_factor_; min_page_scale_factor_ = min_page_scale_factor; max_page_scale_factor_ = max_page_scale_factor; page_scale_factor_ = page_scale_factor; - if (root_layer_scroll_offset_delegate_) { - root_layer_scroll_offset_delegate_->UpdateRootLayerState( - TotalScrollOffset(), - TotalMaxScrollOffset(), - ScrollableSize(), - total_page_scale_factor(), - this->min_page_scale_factor(), - this->max_page_scale_factor()); - } - - ForceScrollbarParameterUpdateAfterScaleChange(page_scale_layer()); -} - -void LayerTreeImpl::SetPageScaleDelta(float delta) { - // Clamp to the current min/max limits. - float total = page_scale_factor_ * delta; + float total = page_scale_factor_ * page_scale_delta; if (min_page_scale_factor_ && total < min_page_scale_factor_) - delta = min_page_scale_factor_ / page_scale_factor_; + page_scale_delta = min_page_scale_factor_ / page_scale_factor_; else if (max_page_scale_factor_ && total > max_page_scale_factor_) - delta = max_page_scale_factor_ / page_scale_factor_; + page_scale_delta = max_page_scale_factor_ / page_scale_factor_; - if (delta == page_scale_delta_) + if (page_scale_delta_ == page_scale_delta && !page_scale_changed) return; - page_scale_delta_ = delta; + if (page_scale_delta_ != page_scale_delta) { + page_scale_delta_ = page_scale_delta; - if (IsActiveTree()) { - LayerTreeImpl* pending_tree = layer_tree_host_impl_->pending_tree(); - if (pending_tree) { - DCHECK_EQ(1, pending_tree->sent_page_scale_delta()); - pending_tree->SetPageScaleDelta( - page_scale_delta_ / sent_page_scale_delta_); + if (IsActiveTree()) { + LayerTreeImpl* pending_tree = layer_tree_host_impl_->pending_tree(); + if (pending_tree) { + DCHECK_EQ(1, pending_tree->sent_page_scale_delta()); + pending_tree->SetPageScaleDelta( + page_scale_delta_ / sent_page_scale_delta_); + } } - } - set_needs_update_draw_properties(); + set_needs_update_draw_properties(); + } if (root_layer_scroll_offset_delegate_) { root_layer_scroll_offset_delegate_->UpdateRootLayerState( @@ -345,9 +341,11 @@ void LayerTreeImpl::SetPageScaleDelta(float delta) { TotalMaxScrollOffset(), ScrollableSize(), total_page_scale_factor(), - min_page_scale_factor(), - max_page_scale_factor()); + min_page_scale_factor_, + max_page_scale_factor_); } + + ForceScrollbarParameterUpdateAfterScaleChange(page_scale_layer()); } gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const { @@ -438,16 +436,19 @@ void LayerTreeImpl::ClearViewportLayers() { outer_viewport_scroll_layer_ = NULL; } -void LayerTreeImpl::UpdateDrawProperties() { - needs_update_draw_properties_ = false; - render_surface_layer_list_.clear(); +bool LayerTreeImpl::UpdateDrawProperties() { + if (!needs_update_draw_properties_) + return true; // For max_texture_size. if (!layer_tree_host_impl_->renderer()) - return; + return false; if (!root_layer()) - return; + return false; + + needs_update_draw_properties_ = false; + render_surface_layer_list_.clear(); { TRACE_EVENT2("cc", @@ -510,6 +511,7 @@ void LayerTreeImpl::UpdateDrawProperties() { DCHECK(!needs_update_draw_properties_) << "CalcDrawProperties should not set_needs_update_draw_properties()"; + return true; } const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const { @@ -558,12 +560,19 @@ void LayerTreeImpl::DidBecomeActive() { if (!root_layer()) return; + if (next_activation_forces_redraw_) { + layer_tree_host_impl_->SetFullRootLayerDamage(); + next_activation_forces_redraw_ = false; + } + if (scrolling_layer_id_from_previous_tree_) { currently_scrolling_layer_ = LayerTreeHostCommon::FindLayerInSubtree( root_layer_.get(), scrolling_layer_id_from_previous_tree_); } DidBecomeActiveRecursive(root_layer()); + devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), + source_frame_number_); } bool LayerTreeImpl::ContentsTexturesPurged() const { @@ -1095,35 +1104,33 @@ static bool PointHitsRegion(const gfx::PointF& screen_space_point, gfx::ToRoundedPoint(hit_test_point_in_layer_space)); } +static LayerImpl* GetNextClippingLayer(LayerImpl* layer) { + if (layer->scroll_parent()) + return layer->scroll_parent(); + if (layer->clip_parent()) + return layer->clip_parent(); + return layer->parent(); +} + static bool PointIsClippedBySurfaceOrClipRect( const gfx::PointF& screen_space_point, LayerImpl* layer) { - LayerImpl* current_layer = layer; - // Walk up the layer tree and hit-test any render_surfaces and any layer // clip rects that are active. - while (current_layer) { - if (current_layer->render_surface() && - !PointHitsRect( - screen_space_point, - current_layer->render_surface()->screen_space_transform(), - current_layer->render_surface()->content_rect(), - NULL)) + for (; layer; layer = GetNextClippingLayer(layer)) { + if (layer->render_surface() && + !PointHitsRect(screen_space_point, + layer->render_surface()->screen_space_transform(), + layer->render_surface()->content_rect(), + NULL)) return true; - // Note that drawable content rects are actually in target surface space, so - // the transform we have to provide is the target surface's - // screen_space_transform. - LayerImpl* render_target = current_layer->render_target(); - if (LayerClipsSubtree(current_layer) && - !PointHitsRect( - screen_space_point, - render_target->render_surface()->screen_space_transform(), - current_layer->drawable_content_rect(), - NULL)) + if (LayerClipsSubtree(layer) && + !PointHitsRect(screen_space_point, + layer->screen_space_transform(), + gfx::Rect(layer->content_bounds()), + NULL)) return true; - - current_layer = current_layer->parent(); } // If we have finished walking all ancestors without having already exited, @@ -1229,6 +1236,10 @@ struct HitTestVisibleScrollableOrTouchableFunctor { LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( const gfx::PointF& screen_space_point) { + if (!root_layer()) + return NULL; + if (!UpdateDrawProperties()) + return NULL; FindClosestMatchingLayerDataForRecursion data_for_recursion; FindClosestMatchingLayer(screen_space_point, root_layer(), @@ -1268,6 +1279,10 @@ struct FindTouchEventLayerFunctor { LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( const gfx::PointF& screen_space_point) { + if (!root_layer()) + return NULL; + if (!UpdateDrawProperties()) + return NULL; FindTouchEventLayerFunctor func = {screen_space_point}; FindClosestMatchingLayerDataForRecursion data_for_recursion; FindClosestMatchingLayer( @@ -1275,4 +1290,12 @@ LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( return data_for_recursion.closest_match; } +void LayerTreeImpl::RegisterPictureLayerImpl(PictureLayerImpl* layer) { + layer_tree_host_impl_->RegisterPictureLayerImpl(layer); +} + +void LayerTreeImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { + layer_tree_host_impl_->UnregisterPictureLayerImpl(layer); +} + } // namespace cc diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index 95f702fb54..3b3c6cf562 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -42,6 +42,7 @@ class LayerTreeSettings; class MemoryHistory; class OutputSurface; class PaintTimeCounter; +class PictureLayerImpl; class Proxy; class ResourceProvider; class TileManager; @@ -154,6 +155,9 @@ class CC_EXPORT LayerTreeImpl { void SetPageScaleFactorAndLimits(float page_scale_factor, float min_page_scale_factor, float max_page_scale_factor); void SetPageScaleDelta(float delta); + void SetPageScaleValues(float page_scale_factor, + float min_page_scale_factor, float max_page_scale_factor, + float page_scale_delta); float total_page_scale_factor() const { return page_scale_factor_ * page_scale_delta_; } @@ -167,8 +171,8 @@ class CC_EXPORT LayerTreeImpl { float sent_page_scale_delta() const { return sent_page_scale_delta_; } // Updates draw properties and render surface layer list, as well as tile - // priorities. - void UpdateDrawProperties(); + // priorities. Returns false if it was unable to update. + bool UpdateDrawProperties(); void set_needs_update_draw_properties() { needs_update_draw_properties_ = true; @@ -259,6 +263,9 @@ class CC_EXPORT LayerTreeImpl { LayerImpl* FindLayerThatIsHitByPointInTouchHandlerRegion( const gfx::PointF& screen_space_point); + void RegisterPictureLayerImpl(PictureLayerImpl* layer); + void UnregisterPictureLayerImpl(PictureLayerImpl* layer); + protected: explicit LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl); void ReleaseResourcesRecursive(LayerImpl* current); diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc index 8db2b9567c..91bad3ee7e 100644 --- a/cc/trees/layer_tree_impl_unittest.cc +++ b/cc/trees/layer_tree_impl_unittest.cc @@ -1117,6 +1117,144 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { EXPECT_EQ(4, result_layer->id()); } +TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { + scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + gfx::Transform identity_matrix; + gfx::Point3F transform_origin; + gfx::PointF position; + gfx::Size bounds(100, 100); + SetLayerPropertiesForTesting(root.get(), + identity_matrix, + transform_origin, + position, + bounds, + true, + false); + root->SetDrawsContent(true); + { + scoped_ptr<LayerImpl> child = + LayerImpl::Create(host_impl().active_tree(), 2); + scoped_ptr<LayerImpl> grand_child = + LayerImpl::Create(host_impl().active_tree(), 4); + + position = gfx::PointF(10.f, 10.f); + bounds = gfx::Size(1, 1); + SetLayerPropertiesForTesting(child.get(), + identity_matrix, + transform_origin, + position, + bounds, + true, + false); + child->SetDrawsContent(true); + child->SetMasksToBounds(true); + + position = gfx::PointF(0.f, 40.f); + bounds = gfx::Size(100, 50); + SetLayerPropertiesForTesting(grand_child.get(), + identity_matrix, + transform_origin, + position, + bounds, + true, + false); + grand_child->SetDrawsContent(true); + grand_child->SetForceRenderSurface(true); + + // This should let |grand_child| "escape" |child|'s clip. + grand_child->SetClipParent(root.get()); + + child->AddChild(grand_child.Pass()); + root->AddChild(child.Pass()); + } + + host_impl().SetViewportSize(root->bounds()); + host_impl().active_tree()->SetRootLayer(root.Pass()); + host_impl().active_tree()->UpdateDrawProperties(); + + gfx::Point test_point = gfx::Point(12, 52); + LayerImpl* result_layer = + host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); + ASSERT_TRUE(result_layer); + EXPECT_EQ(4, result_layer->id()); +} + +TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { + scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + gfx::Transform identity_matrix; + gfx::Point3F transform_origin; + gfx::PointF position; + gfx::Size bounds(100, 100); + SetLayerPropertiesForTesting(root.get(), + identity_matrix, + transform_origin, + position, + bounds, + true, + false); + root->SetDrawsContent(true); + { + scoped_ptr<LayerImpl> child = + LayerImpl::Create(host_impl().active_tree(), 2); + scoped_ptr<LayerImpl> scroll_child = + LayerImpl::Create(host_impl().active_tree(), 3); + scoped_ptr<LayerImpl> grand_child = + LayerImpl::Create(host_impl().active_tree(), 4); + + position = gfx::PointF(10.f, 10.f); + bounds = gfx::Size(1, 1); + SetLayerPropertiesForTesting(child.get(), + identity_matrix, + transform_origin, + position, + bounds, + true, + false); + child->SetDrawsContent(true); + child->SetMasksToBounds(true); + + position = gfx::PointF(); + bounds = gfx::Size(200, 200); + SetLayerPropertiesForTesting(scroll_child.get(), + identity_matrix, + transform_origin, + position, + bounds, + true, + false); + scroll_child->SetDrawsContent(true); + + // This should cause scroll child and its descendants to be affected by + // |child|'s clip. + scroll_child->SetScrollParent(child.get()); + + SetLayerPropertiesForTesting(grand_child.get(), + identity_matrix, + transform_origin, + position, + bounds, + true, + false); + grand_child->SetDrawsContent(true); + grand_child->SetForceRenderSurface(true); + + scroll_child->AddChild(grand_child.Pass()); + root->AddChild(scroll_child.Pass()); + root->AddChild(child.Pass()); + } + + host_impl().SetViewportSize(root->bounds()); + host_impl().active_tree()->SetRootLayer(root.Pass()); + host_impl().active_tree()->UpdateDrawProperties(); + + gfx::Point test_point = gfx::Point(12, 52); + LayerImpl* result_layer = + host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); + // The |test_point| should have been clipped away by |child|, the scroll + // parent, so the only thing that should be hit is |root|. + ASSERT_TRUE(result_layer); + ASSERT_EQ(1, result_layer->id()); +} TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { // // The geometry is set up similarly to the previous case, but diff --git a/cc/trees/occlusion_tracker.cc b/cc/trees/occlusion_tracker.cc index ceb2d1434c..b549f89983 100644 --- a/cc/trees/occlusion_tracker.cc +++ b/cc/trees/occlusion_tracker.cc @@ -335,10 +335,9 @@ void OcclusionTracker<LayerType>::LeaveToRenderTarget( gfx::Rect unoccluded_replica_rect; if (old_target->background_filters().HasFilterThatMovesPixels()) { unoccluded_surface_rect = UnoccludedContributingSurfaceContentRect( - old_target, old_surface->content_rect(), old_surface->draw_transform()); + old_surface->content_rect(), old_surface->draw_transform()); if (old_target->has_replica()) { unoccluded_replica_rect = UnoccludedContributingSurfaceContentRect( - old_target, old_surface->content_rect(), old_surface->replica_draw_transform()); } @@ -543,23 +542,13 @@ bool OcclusionTracker<LayerType>::Occluded( template <typename LayerType> gfx::Rect OcclusionTracker<LayerType>::UnoccludedContentRect( - const LayerType* render_target, const gfx::Rect& content_rect, const gfx::Transform& draw_transform) const { - DCHECK(!stack_.empty()); if (stack_.empty()) return content_rect; if (content_rect.IsEmpty()) return content_rect; - // For tests with no render target. - if (!render_target) - return content_rect; - - DCHECK_EQ(render_target->render_target(), render_target); - DCHECK(render_target->render_surface()); - DCHECK_EQ(render_target, stack_.back().target); - if (stack_.back().occlusion_from_inside_target.IsEmpty() && stack_.back().occlusion_from_outside_target.IsEmpty()) { return content_rect; @@ -589,20 +578,8 @@ gfx::Rect OcclusionTracker<LayerType>::UnoccludedContentRect( template <typename LayerType> gfx::Rect OcclusionTracker<LayerType>::UnoccludedContributingSurfaceContentRect( - const LayerType* layer, const gfx::Rect& content_rect, const gfx::Transform& draw_transform) const { - DCHECK(!stack_.empty()); - // The layer is a contributing render_target so it should have a surface. - DCHECK(layer->render_surface()); - // The layer is a contributing render_target so its target should be itself. - DCHECK_EQ(layer->render_target(), layer); - // The layer should not be the root, else what is is contributing to? - DCHECK(layer->parent()); - // This should be called while the layer is still considered the current - // target in the occlusion tracker. - DCHECK_EQ(layer, stack_.back().target); - if (content_rect.IsEmpty()) return content_rect; diff --git a/cc/trees/occlusion_tracker.h b/cc/trees/occlusion_tracker.h index e4567afb64..78b992cd1c 100644 --- a/cc/trees/occlusion_tracker.h +++ b/cc/trees/occlusion_tracker.h @@ -53,15 +53,13 @@ class CC_EXPORT OcclusionTracker { // layer. Used when considering occlusion for a layer that paints/draws // something. |render_target| is the contributing layer's render target, and // |draw_transform| and |impl_draw_transform_is_unknown| are relative to that. - gfx::Rect UnoccludedContentRect(const LayerType* render_target, - const gfx::Rect& content_rect, + gfx::Rect UnoccludedContentRect(const gfx::Rect& content_rect, const gfx::Transform& draw_transform) const; // Gives an unoccluded sub-rect of |content_rect| in the content space of the // render_target owned by the layer. Used when considering occlusion for a // contributing surface that is rendering into another target. gfx::Rect UnoccludedContributingSurfaceContentRect( - const LayerType* layer, const gfx::Rect& content_rect, const gfx::Transform& draw_transform) const; diff --git a/cc/trees/occlusion_tracker_perftest.cc b/cc/trees/occlusion_tracker_perftest.cc index 1506b2ff02..d9130746de 100644 --- a/cc/trees/occlusion_tracker_perftest.cc +++ b/cc/trees/occlusion_tracker_perftest.cc @@ -109,10 +109,8 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) { for (int x = 0; x < viewport_rect.width(); x += 256) { for (int y = 0; y < viewport_rect.height(); y += 256) { gfx::Rect query_content_rect(x, y, 256, 256); - gfx::Rect unoccluded = - tracker.UnoccludedContentRect(pos.target_render_surface_layer, - query_content_rect, - transform_to_target); + gfx::Rect unoccluded = tracker.UnoccludedContentRect( + query_content_rect, transform_to_target); // Sanity test that we're not hitting early outs. bool expect_empty = query_content_rect.right() <= viewport_rect.width() && @@ -186,10 +184,8 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_10OpaqueLayers) { for (int x = 0; x < viewport_rect.width(); x += 256) { for (int y = 0; y < viewport_rect.height(); y += 256) { gfx::Rect query_content_rect(x, y, 256, 256); - gfx::Rect unoccluded = - tracker.UnoccludedContentRect(pos.target_render_surface_layer, - query_content_rect, - transform_to_target); + gfx::Rect unoccluded = tracker.UnoccludedContentRect( + query_content_rect, transform_to_target); } } diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc index 6ce278159c..89165b8d6f 100644 --- a/cc/trees/occlusion_tracker_unittest.cc +++ b/cc/trees/occlusion_tracker_unittest.cc @@ -90,8 +90,7 @@ class TestOcclusionTrackerWithClip : public TestOcclusionTracker<LayerType> { gfx::Rect UnoccludedLayerContentRect(const LayerType* layer, const gfx::Rect& content_rect) const { DCHECK(layer->visible_content_rect().Contains(content_rect)); - return this->UnoccludedContentRect( - layer->render_target(), content_rect, layer->draw_transform()); + return this->UnoccludedContentRect(content_rect, layer->draw_transform()); } gfx::Rect UnoccludedSurfaceContentRect(const LayerType* layer, @@ -101,8 +100,8 @@ class TestOcclusionTrackerWithClip : public TestOcclusionTracker<LayerType> { gfx::Transform draw_transform = for_replica ? surface->replica_draw_transform() : surface->draw_transform(); - return this->UnoccludedContributingSurfaceContentRect( - layer, content_rect, draw_transform); + return this->UnoccludedContributingSurfaceContentRect(content_rect, + draw_transform); } }; @@ -611,15 +610,14 @@ class OcclusionTrackerTestQuadsMismatchLayer gfx::Transform quad_transform; quad_transform.Translate(30.0, 30.0); - EXPECT_TRUE(occlusion.UnoccludedContentRect(parent, - gfx::Rect(0, 0, 10, 10), + EXPECT_TRUE(occlusion.UnoccludedContentRect(gfx::Rect(0, 0, 10, 10), quad_transform).IsEmpty()); EXPECT_RECT_EQ(gfx::Rect(40, 40, 10, 10), - occlusion.UnoccludedContentRect( - parent, gfx::Rect(40, 40, 10, 10), quad_transform)); + occlusion.UnoccludedContentRect(gfx::Rect(40, 40, 10, 10), + quad_transform)); EXPECT_RECT_EQ(gfx::Rect(40, 30, 5, 10), - occlusion.UnoccludedContentRect( - parent, gfx::Rect(35, 30, 10, 10), quad_transform)); + occlusion.UnoccludedContentRect(gfx::Rect(35, 30, 10, 10), + quad_transform)); } }; diff --git a/cc/trees/quad_culler.h b/cc/trees/quad_culler.h deleted file mode 100644 index 1a69cd40bb..0000000000 --- a/cc/trees/quad_culler.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2012 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_TREES_QUAD_CULLER_H_ -#define CC_TREES_QUAD_CULLER_H_ - -#include "cc/base/cc_export.h" -#include "cc/layers/quad_sink.h" - -namespace cc { -class LayerImpl; -class RenderPass; -class RenderSurfaceImpl; -template <typename LayerType> -class OcclusionTracker; - -class CC_EXPORT QuadCuller : public QuadSink { - public: - QuadCuller(RenderPass* render_pass, - const LayerImpl* layer, - const OcclusionTracker<LayerImpl>& occlusion_tracker); - virtual ~QuadCuller() {} - - // QuadSink implementation. - virtual SharedQuadState* CreateSharedQuadState() OVERRIDE; - virtual gfx::Rect UnoccludedContentRect(const gfx::Rect& content_rect, - const gfx::Transform& draw_transform) - OVERRIDE; - virtual gfx::Rect UnoccludedContributingSurfaceContentRect( - const gfx::Rect& content_rect, - const gfx::Transform& draw_transform) OVERRIDE; - virtual void Append(scoped_ptr<DrawQuad> draw_quad) OVERRIDE; - - private: - RenderPass* render_pass_; - const LayerImpl* layer_; - const OcclusionTracker<LayerImpl>& occlusion_tracker_; - - SharedQuadState* current_shared_quad_state_; - - DISALLOW_COPY_AND_ASSIGN(QuadCuller); -}; - -} // namespace cc - -#endif // CC_TREES_QUAD_CULLER_H_ diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index f14e38b92f..1eed641f22 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -198,40 +198,59 @@ void ThreadProxy::UpdateBackgroundAnimateTicking() { impl().animations_frozen_until_next_draw = false; } -void ThreadProxy::DoCreateAndInitializeOutputSurface() { +void ThreadProxy::DidLoseOutputSurface() { + TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); + DCHECK(IsMainThread()); + layer_tree_host()->DidLoseOutputSurface(); + + { + DebugScopedSetMainThreadBlocked main_thread_blocked(this); + + // Return lost resources to their owners immediately. + BlockingTaskRunner::CapturePostTasks blocked; + + CompletionEvent completion; + Proxy::ImplThreadTaskRunner()->PostTask( + FROM_HERE, + base::Bind(&ThreadProxy::DeleteContentsTexturesOnImplThread, + impl_thread_weak_ptr_, + &completion)); + completion.Wait(); + } +} + +void ThreadProxy::CreateAndInitializeOutputSurface() { TRACE_EVENT0("cc", "ThreadProxy::DoCreateAndInitializeOutputSurface"); DCHECK(IsMainThread()); scoped_ptr<OutputSurface> output_surface = layer_tree_host()->CreateOutputSurface(); - RendererCapabilities capabilities; - bool success = !!output_surface; - if (success) { - // Make a blocking call to InitializeOutputSurfaceOnImplThread. The results - // of that call are pushed into the success and capabilities local - // variables. - CompletionEvent completion; - DebugScopedSetMainThreadBlocked main_thread_blocked(this); - + if (output_surface) { Proxy::ImplThreadTaskRunner()->PostTask( FROM_HERE, base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread, impl_thread_weak_ptr_, - &completion, - base::Passed(&output_surface), - &success, - &capabilities)); - completion.Wait(); + base::Passed(&output_surface))); + return; } + + DidInitializeOutputSurface(false, RendererCapabilities()); +} + +void ThreadProxy::DidInitializeOutputSurface( + bool success, + const RendererCapabilities& capabilities) { + TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); + DCHECK(IsMainThread()); main().renderer_capabilities_main_thread_copy = capabilities; layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(success); - if (success) { - main().output_surface_creation_callback.Cancel(); - } else if (!main().output_surface_creation_callback.IsCancelled()) { + if (!success) { Proxy::MainThreadTaskRunner()->PostTask( - FROM_HERE, main().output_surface_creation_callback.callback()); + FROM_HERE, + base::Bind(&ThreadProxy::CreateAndInitializeOutputSurface, + main_thread_weak_ptr_)); } } @@ -312,6 +331,9 @@ void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { DCHECK(IsImplThread()); if (!impl().layer_tree_host_impl->IsContextLost()) return; + Proxy::MainThreadTaskRunner()->PostTask( + FROM_HERE, + base::Bind(&ThreadProxy::DidLoseOutputSurface, main_thread_weak_ptr_)); impl().scheduler->DidLoseOutputSurface(); } @@ -727,23 +749,11 @@ void ThreadProxy::BeginMainFrame( // swap promises. SwapPromiseChecker swap_promise_checker(layer_tree_host()); - // Do not notify the impl thread of commit requests that occur during - // the apply/animate/layout part of the BeginMainFrameAndCommit process since - // those commit requests will get painted immediately. Once we have done - // the paint, main().commit_requested will be set to false to allow new commit - // requests to be scheduled. - main().commit_requested = true; - main().commit_request_sent_to_impl_thread = true; - - // On the other hand, the AnimationRequested flag needs to be cleared - // here so that any animation requests generated by the apply or animate - // callbacks will trigger another frame. + main().commit_requested = false; + main().commit_request_sent_to_impl_thread = false; main().animate_requested = false; if (!layer_tree_host()->visible()) { - main().commit_requested = false; - main().commit_request_sent_to_impl_thread = false; - TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); bool did_handle = false; Proxy::ImplThreadTaskRunner()->PostTask( @@ -754,6 +764,29 @@ void ThreadProxy::BeginMainFrame( return; } + if (layer_tree_host()->output_surface_lost()) { + TRACE_EVENT_INSTANT0( + "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); + bool did_handle = false; + Proxy::ImplThreadTaskRunner()->PostTask( + FROM_HERE, + base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, + impl_thread_weak_ptr_, + did_handle)); + return; + } + + // Do not notify the impl thread of commit requests that occur during + // the apply/animate/layout part of the BeginMainFrameAndCommit process since + // those commit requests will get painted immediately. Once we have done + // the paint, main().commit_requested will be set to false to allow new commit + // requests to be scheduled. + // On the other hand, the animate_requested flag should remain cleared + // here so that any animation requests generated by the apply or animate + // callbacks will trigger another frame. + main().commit_requested = true; + main().commit_request_sent_to_impl_thread = true; + layer_tree_host()->ApplyScrollAndScale(*begin_main_frame_state->scroll_info); layer_tree_host()->WillBeginMainFrame(); @@ -1195,64 +1228,12 @@ void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) { layer_tree_host()->SetAnimationEvents(events.Pass()); } -void ThreadProxy::CreateAndInitializeOutputSurface() { - TRACE_EVENT0("cc", "ThreadProxy::CreateAndInitializeOutputSurface"); - DCHECK(IsMainThread()); - - // Check that output surface has not been recreated by CompositeAndReadback - // after this task is posted but before it is run. - bool has_initialized_output_surface = true; - { - CompletionEvent completion; - Proxy::ImplThreadTaskRunner()->PostTask( - FROM_HERE, - base::Bind(&ThreadProxy::HasInitializedOutputSurfaceOnImplThread, - impl_thread_weak_ptr_, - &completion, - &has_initialized_output_surface)); - completion.Wait(); - } - if (has_initialized_output_surface) - return; - - layer_tree_host()->DidLoseOutputSurface(); - main().output_surface_creation_callback.Reset( - base::Bind(&ThreadProxy::DoCreateAndInitializeOutputSurface, - base::Unretained(this))); - main().output_surface_creation_callback.callback().Run(); -} - -void ThreadProxy::HasInitializedOutputSurfaceOnImplThread( - CompletionEvent* completion, - bool* has_initialized_output_surface) { - DCHECK(IsImplThread()); - *has_initialized_output_surface = - impl().scheduler->HasInitializedOutputSurface(); - completion->Signal(); -} - void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); DCHECK(IsImplThread()); impl().layer_tree_host_impl = layer_tree_host()->CreateLayerTreeHostImpl(this); - const LayerTreeSettings& settings = layer_tree_host()->settings(); - SchedulerSettings scheduler_settings; - scheduler_settings.begin_frame_scheduling_enabled = - settings.begin_frame_scheduling_enabled; - scheduler_settings.main_frame_before_draw_enabled = - settings.main_frame_before_draw_enabled; - scheduler_settings.main_frame_before_activation_enabled = - settings.main_frame_before_activation_enabled; - scheduler_settings.impl_side_painting = settings.impl_side_painting; - scheduler_settings.timeout_and_draw_when_animation_checkerboards = - settings.timeout_and_draw_when_animation_checkerboards; - scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ = - settings.maximum_number_of_failed_draws_before_draw_is_forced_; - scheduler_settings.using_synchronous_renderer_compositor = - settings.using_synchronous_renderer_compositor; - scheduler_settings.throttle_frame_production = - settings.throttle_frame_production; + SchedulerSettings scheduler_settings(layer_tree_host()->settings()); impl().scheduler = Scheduler::Create(this, scheduler_settings, impl().layer_tree_host_id, @@ -1263,31 +1244,38 @@ void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { completion->Signal(); } -void ThreadProxy::InitializeOutputSurfaceOnImplThread( - CompletionEvent* completion, - scoped_ptr<OutputSurface> output_surface, - bool* success, - RendererCapabilities* capabilities) { - TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); +void ThreadProxy::DeleteContentsTexturesOnImplThread( + CompletionEvent* completion) { + TRACE_EVENT0("cc", "ThreadProxy::DeleteContentsTexturesOnImplThread"); DCHECK(IsImplThread()); DCHECK(IsMainThreadBlocked()); - DCHECK(success); - DCHECK(capabilities); - layer_tree_host()->DeleteContentsTexturesOnImplThread( impl().layer_tree_host_impl->resource_provider()); + completion->Signal(); +} - *success = - impl().layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); +void ThreadProxy::InitializeOutputSurfaceOnImplThread( + scoped_ptr<OutputSurface> output_surface) { + TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); + DCHECK(IsImplThread()); - if (*success) { - *capabilities = impl() - .layer_tree_host_impl->GetRendererCapabilities() - .MainThreadCapabilities(); - impl().scheduler->DidCreateAndInitializeOutputSurface(); + LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); + bool success = host_impl->InitializeRenderer(output_surface.Pass()); + RendererCapabilities capabilities; + if (success) { + capabilities = + host_impl->GetRendererCapabilities().MainThreadCapabilities(); } - completion->Signal(); + Proxy::MainThreadTaskRunner()->PostTask( + FROM_HERE, + base::Bind(&ThreadProxy::DidInitializeOutputSurface, + main_thread_weak_ptr_, + success, + capabilities)); + + if (success) + impl().scheduler->DidCreateAndInitializeOutputSurface(); } void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { @@ -1301,6 +1289,7 @@ void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); DCHECK(IsImplThread()); + DCHECK(IsMainThreadBlocked()); layer_tree_host()->DeleteContentsTexturesOnImplThread( impl().layer_tree_host_impl->resource_provider()); impl().current_resource_update_controller.reset(); diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index a86d828059..4734778c8d 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -72,7 +72,6 @@ class CC_EXPORT ThreadProxy : public Proxy, bool can_cancel_commit; bool defer_commits; - base::CancelableClosure output_surface_creation_callback; RendererCapabilities renderer_capabilities_main_thread_copy; scoped_ptr<BeginMainFrameAndCommitState> pending_deferred_commit; @@ -242,8 +241,10 @@ class CC_EXPORT ThreadProxy : public Proxy, void DidCommitAndDrawFrame(); void DidCompleteSwapBuffers(); void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); + void DidLoseOutputSurface(); void CreateAndInitializeOutputSurface(); - void DoCreateAndInitializeOutputSurface(); + void DidInitializeOutputSurface(bool success, + const RendererCapabilities& capabilities); void SendCommitRequestToImplThreadIfNeeded(); // Called on impl thread. @@ -261,11 +262,9 @@ class CC_EXPORT ThreadProxy : public Proxy, void HasInitializedOutputSurfaceOnImplThread( CompletionEvent* completion, bool* has_initialized_output_surface); - virtual void InitializeOutputSurfaceOnImplThread( - CompletionEvent* completion, - scoped_ptr<OutputSurface> output_surface, - bool* success, - RendererCapabilities* capabilities); + void DeleteContentsTexturesOnImplThread(CompletionEvent* completion); + void InitializeOutputSurfaceOnImplThread( + scoped_ptr<OutputSurface> output_surface); void FinishGLOnImplThread(CompletionEvent* completion); void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); DrawResult DrawSwapInternal(bool forced_draw); |