[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
avi | 02a4d17 | 2015-12-21 06:14:36 | [diff] [blame] | 5 | #include <stddef.h> |
| 6 | #include <stdint.h> |
| 7 | |
Sebastien Marchand | 6d0558fd | 2019-01-25 16:49:37 | [diff] [blame] | 8 | #include "base/bind.h" |
Avi Drissman | 0dd4e0e6 | 2018-12-25 23:20:46 | [diff] [blame] | 9 | #include "base/stl_util.h" |
Stephen McGruer | 25ddb137 | 2018-01-18 19:10:15 | [diff] [blame] | 10 | #include "build/build_config.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 11 | #include "cc/layers/heads_up_display_layer.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 12 | #include "cc/layers/layer_impl.h" |
[email protected] | 3a83478b | 2013-08-22 20:55:17 | [diff] [blame] | 13 | #include "cc/layers/painted_scrollbar_layer.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 14 | #include "cc/layers/picture_layer.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 15 | #include "cc/layers/texture_layer.h" |
[email protected] | 4145d17 | 2013-05-10 16:54:36 | [diff] [blame] | 16 | #include "cc/layers/texture_layer_impl.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 17 | #include "cc/layers/video_layer.h" |
| 18 | #include "cc/layers/video_layer_impl.h" |
Khushal | 7865b5be | 2017-11-22 03:12:06 | [diff] [blame] | 19 | #include "cc/paint/filter_operations.h" |
enne | 34f6084c | 2017-02-02 22:39:08 | [diff] [blame] | 20 | #include "cc/paint/paint_flags.h" |
khushalsagar | 8ec0740 | 2016-09-10 03:13:19 | [diff] [blame] | 21 | #include "cc/resources/ui_resource_manager.h" |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 22 | #include "cc/test/fake_content_layer_client.h" |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 23 | #include "cc/test/fake_layer_tree_host_client.h" |
[email protected] | 3a83478b | 2013-08-22 20:55:17 | [diff] [blame] | 24 | #include "cc/test/fake_painted_scrollbar_layer.h" |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 25 | #include "cc/test/fake_picture_layer.h" |
| 26 | #include "cc/test/fake_picture_layer_impl.h" |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 27 | #include "cc/test/fake_scoped_ui_resource.h" |
[email protected] | c28df4c1 | 2013-05-22 17:36:49 | [diff] [blame] | 28 | #include "cc/test/fake_scrollbar.h" |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 29 | #include "cc/test/fake_video_frame_provider.h" |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 30 | #include "cc/test/layer_tree_test.h" |
danakj | 7e605b66 | 2015-08-18 20:23:12 | [diff] [blame] | 31 | #include "cc/test/render_pass_test_utils.h" |
Antoine Labour | 7f5179a | 2019-06-04 01:46:29 | [diff] [blame] | 32 | #include "cc/test/test_layer_tree_frame_sink.h" |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 33 | #include "cc/trees/layer_tree_host.h" |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 34 | #include "cc/trees/layer_tree_host_impl.h" |
| 35 | #include "cc/trees/layer_tree_impl.h" |
| 36 | #include "cc/trees/single_thread_proxy.h" |
danakj | 4b15f74 | 2018-05-30 22:52:22 | [diff] [blame] | 37 | #include "components/viz/client/client_resource_provider.h" |
danakj | f20f450 | 2017-09-26 17:13:31 | [diff] [blame] | 38 | #include "components/viz/common/resources/single_release_callback.h" |
danakj | b90335d | 2018-06-07 23:42:29 | [diff] [blame] | 39 | #include "components/viz/test/fake_output_surface.h" |
kylechar | dfe762f | 2018-02-26 17:00:01 | [diff] [blame] | 40 | #include "components/viz/test/test_context_provider.h" |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 41 | #include "components/viz/test/test_gles2_interface.h" |
kylechar | efc4845 | 2018-02-23 17:11:00 | [diff] [blame] | 42 | #include "components/viz/test/test_shared_bitmap_manager.h" |
[email protected] | 7a6acd0 | 2013-01-19 04:16:13 | [diff] [blame] | 43 | #include "gpu/GLES2/gl2extchromium.h" |
Victor Miura | 3a4ad4f8 | 2017-12-13 06:03:45 | [diff] [blame] | 44 | #include "gpu/command_buffer/client/raster_interface.h" |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 45 | #include "media/base/media.h" |
| 46 | |
| 47 | using media::VideoFrame; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 48 | |
| 49 | namespace cc { |
| 50 | namespace { |
| 51 | |
Yuri Wiitala | d061176 | 2017-07-22 02:33:21 | [diff] [blame] | 52 | // Returns a fake TimeTicks based on the given microsecond offset. |
| 53 | base::TimeTicks TicksFromMicroseconds(int64_t micros) { |
| 54 | return base::TimeTicks() + base::TimeDelta::FromMicroseconds(micros); |
| 55 | } |
| 56 | |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 57 | // These tests deal with losing the 3d graphics context. |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 58 | class LayerTreeHostContextTest : public LayerTreeTest { |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 59 | public: |
| 60 | LayerTreeHostContextTest() |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 61 | : LayerTreeTest(), |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 62 | times_to_fail_create_(0), |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 63 | times_to_lose_during_commit_(0), |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 64 | times_to_lose_during_draw_(0), |
| 65 | times_to_fail_recreate_(0), |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 66 | times_to_expect_create_failed_(0), |
| 67 | times_create_failed_(0), |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 68 | committed_at_least_once_(false), |
[email protected] | ebc0e1df | 2013-08-01 02:46:22 | [diff] [blame] | 69 | context_should_support_io_surface_(false), |
enne | 2097cab | 2014-09-25 20:16:31 | [diff] [blame] | 70 | fallback_context_works_(false), |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 71 | async_layer_tree_frame_sink_creation_(false) { |
chcunningham | fd11b3c | 2015-06-09 02:09:42 | [diff] [blame] | 72 | media::InitializeMediaLibrary(); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | void LoseContext() { |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 76 | // CreateDisplayLayerTreeFrameSink happens on a different thread, so lock |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 77 | // gl_ to make sure we don't set it to null after recreating it |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 78 | // there. |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 79 | base::AutoLock lock(gl_lock_); |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 80 | // For sanity-checking tests, they should only call this when the |
| 81 | // context is not lost. |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 82 | CHECK(gl_); |
| 83 | gl_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 84 | GL_INNOCENT_CONTEXT_RESET_ARB); |
| 85 | gl_ = nullptr; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 86 | } |
| 87 | |
Antoine Labour | 7f5179a | 2019-06-04 01:46:29 | [diff] [blame] | 88 | std::unique_ptr<TestLayerTreeFrameSink> CreateLayerTreeFrameSink( |
Alex Zhang | bcce8b13 | 2017-07-20 20:17:24 | [diff] [blame] | 89 | const viz::RendererSettings& renderer_settings, |
Alex Zhang | 903cb6a | 2017-06-12 20:31:37 | [diff] [blame] | 90 | double refresh_rate, |
Xu Xing | 3254916 | 2017-07-17 22:25:43 | [diff] [blame] | 91 | scoped_refptr<viz::ContextProvider> compositor_context_provider, |
Victor Miura | 29b7ea3d | 2017-12-19 20:23:59 | [diff] [blame] | 92 | scoped_refptr<viz::RasterContextProvider> worker_context_provider) |
| 93 | override { |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 94 | base::AutoLock lock(gl_lock_); |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 95 | |
Xu Xing | 0d4b2bf9 | 2018-05-17 00:20:12 | [diff] [blame] | 96 | auto gl_owned = std::make_unique<viz::TestGLES2Interface>(); |
| 97 | if (context_should_support_io_surface_) { |
| 98 | gl_owned->set_have_extension_io_surface(true); |
| 99 | gl_owned->set_have_extension_egl_image(true); |
| 100 | } |
| 101 | |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 102 | gl_ = gl_owned.get(); |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 103 | |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 104 | auto provider = viz::TestContextProvider::Create(std::move(gl_owned)); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 105 | if (times_to_fail_create_) { |
| 106 | --times_to_fail_create_; |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 107 | ExpectCreateToFail(); |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 108 | gl_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 109 | GL_INNOCENT_CONTEXT_RESET_ARB); |
danakj | 014316e | 2016-08-04 18:40:26 | [diff] [blame] | 110 | } |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 111 | |
Eric Karl | 8d678f89 | 2018-12-11 06:51:00 | [diff] [blame] | 112 | sii_ = provider->SharedImageInterface(); |
| 113 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 114 | return LayerTreeTest::CreateLayerTreeFrameSink( |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 115 | renderer_settings, refresh_rate, std::move(provider), |
danakj | 014316e | 2016-08-04 18:40:26 | [diff] [blame] | 116 | std::move(worker_context_provider)); |
| 117 | } |
| 118 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 119 | DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 120 | LayerTreeHostImpl::FrameData* frame, |
| 121 | DrawResult draw_result) override { |
enne | 98f3a6c | 2014-10-09 20:09:44 | [diff] [blame] | 122 | if (draw_result == DRAW_ABORTED_MISSING_HIGH_RES_CONTENT) { |
danakj | 431a120 | 2015-06-17 19:09:33 | [diff] [blame] | 123 | // Only valid for single-threaded compositing, which activates |
enne | 98f3a6c | 2014-10-09 20:09:44 | [diff] [blame] | 124 | // immediately and will try to draw again when content has finished. |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 125 | DCHECK(!host_impl->task_runner_provider()->HasImplThread()); |
enne | 98f3a6c | 2014-10-09 20:09:44 | [diff] [blame] | 126 | return draw_result; |
| 127 | } |
[email protected] | 30d8214 | 2014-05-12 04:26:02 | [diff] [blame] | 128 | EXPECT_EQ(DRAW_SUCCESS, draw_result); |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 129 | if (!times_to_lose_during_draw_) |
[email protected] | 7ddfe7e8 | 2014-01-30 07:22:11 | [diff] [blame] | 130 | return draw_result; |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 131 | |
| 132 | --times_to_lose_during_draw_; |
[email protected] | c9addd1 | 2013-12-08 22:43:26 | [diff] [blame] | 133 | LoseContext(); |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 134 | |
| 135 | times_to_fail_create_ = times_to_fail_recreate_; |
| 136 | times_to_fail_recreate_ = 0; |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 137 | |
[email protected] | 7ddfe7e8 | 2014-01-30 07:22:11 | [diff] [blame] | 138 | return draw_result; |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 139 | } |
| 140 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 141 | void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 142 | committed_at_least_once_ = true; |
| 143 | |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 144 | if (!times_to_lose_during_commit_) |
| 145 | return; |
| 146 | --times_to_lose_during_commit_; |
| 147 | LoseContext(); |
| 148 | |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 149 | times_to_fail_create_ = times_to_fail_recreate_; |
| 150 | times_to_fail_recreate_ = 0; |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 151 | } |
| 152 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 153 | void DidFailToInitializeLayerTreeFrameSink() override { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 154 | ++times_create_failed_; |
| 155 | } |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 156 | |
danakj | aeb9506 | 2014-11-14 01:35:36 | [diff] [blame] | 157 | void TearDown() override { |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 158 | LayerTreeTest::TearDown(); |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 159 | EXPECT_EQ(times_to_expect_create_failed_, times_create_failed_); |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 160 | } |
| 161 | |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 162 | void ExpectCreateToFail() { ++times_to_expect_create_failed_; } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 163 | |
| 164 | protected: |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 165 | // Protects use of gl_ so LoseContext and |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 166 | // CreateDisplayLayerTreeFrameSink can both use it on different threads. |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 167 | base::Lock gl_lock_; |
| 168 | viz::TestGLES2Interface* gl_ = nullptr; |
Eric Karl | 8d678f89 | 2018-12-11 06:51:00 | [diff] [blame] | 169 | viz::TestSharedImageInterface* sii_ = nullptr; |
danakj | 5d89711 | 2015-06-24 20:07:20 | [diff] [blame] | 170 | |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 171 | int times_to_fail_create_; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 172 | int times_to_lose_during_commit_; |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 173 | int times_to_lose_during_draw_; |
[email protected] | 155399d | 2013-03-29 19:07:36 | [diff] [blame] | 174 | int times_to_fail_recreate_; |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 175 | int times_to_expect_create_failed_; |
| 176 | int times_create_failed_; |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 177 | bool committed_at_least_once_; |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 178 | bool context_should_support_io_surface_; |
[email protected] | ebc0e1df | 2013-08-01 02:46:22 | [diff] [blame] | 179 | bool fallback_context_works_; |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 180 | bool async_layer_tree_frame_sink_creation_; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 181 | }; |
| 182 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 183 | class LayerTreeHostContextTestLostContextSucceeds |
| 184 | : public LayerTreeHostContextTest { |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 185 | public: |
| 186 | LayerTreeHostContextTestLostContextSucceeds() |
| 187 | : LayerTreeHostContextTest(), |
| 188 | test_case_(0), |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 189 | num_losses_(0), |
[email protected] | c9addd1 | 2013-12-08 22:43:26 | [diff] [blame] | 190 | num_losses_last_test_case_(-1), |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 191 | recovered_context_(true), |
| 192 | first_initialized_(false) {} |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 193 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 194 | void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 195 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 196 | void RequestNewLayerTreeFrameSink() override { |
| 197 | if (async_layer_tree_frame_sink_creation_) { |
enne | 2097cab | 2014-09-25 20:16:31 | [diff] [blame] | 198 | MainThreadTaskRunner()->PostTask( |
tzik | 4604bb5 | 2017-04-13 21:50:22 | [diff] [blame] | 199 | FROM_HERE, |
| 200 | base::BindOnce(&LayerTreeHostContextTestLostContextSucceeds:: |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 201 | AsyncRequestNewLayerTreeFrameSink, |
tzik | 4604bb5 | 2017-04-13 21:50:22 | [diff] [blame] | 202 | base::Unretained(this))); |
enne | 2097cab | 2014-09-25 20:16:31 | [diff] [blame] | 203 | } else { |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 204 | AsyncRequestNewLayerTreeFrameSink(); |
enne | 2097cab | 2014-09-25 20:16:31 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 208 | void AsyncRequestNewLayerTreeFrameSink() { |
| 209 | LayerTreeHostContextTest::RequestNewLayerTreeFrameSink(); |
enne | 2097cab | 2014-09-25 20:16:31 | [diff] [blame] | 210 | } |
| 211 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 212 | void DidInitializeLayerTreeFrameSink() override { |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 213 | if (first_initialized_) |
| 214 | ++num_losses_; |
| 215 | else |
| 216 | first_initialized_ = true; |
| 217 | |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 218 | recovered_context_ = true; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 219 | } |
| 220 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 221 | void AfterTest() override { EXPECT_EQ(11u, test_case_); } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 222 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 223 | void DidCommitAndDrawFrame() override { |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 224 | // If the last frame had a context loss, then we'll commit again to |
| 225 | // recover. |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 226 | if (!recovered_context_) |
| 227 | return; |
| 228 | if (times_to_lose_during_commit_) |
| 229 | return; |
| 230 | if (times_to_lose_during_draw_) |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 231 | return; |
| 232 | |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 233 | recovered_context_ = false; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 234 | if (NextTestCase()) |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 235 | InvalidateAndSetNeedsCommit(); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 236 | else |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 237 | EndTest(); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 238 | } |
| 239 | |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 240 | virtual void InvalidateAndSetNeedsCommit() { |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 241 | // Cause damage so we try to draw. |
khushalsagar | b69ba945 | 2017-01-27 22:20:07 | [diff] [blame] | 242 | layer_tree_host()->root_layer()->SetNeedsDisplay(); |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 243 | layer_tree_host()->SetNeedsCommit(); |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 244 | } |
| 245 | |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 246 | bool NextTestCase() { |
| 247 | static const TestCase kTests[] = { |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 248 | // Losing the context and failing to recreate it (or losing it again |
| 249 | // immediately) a small number of times should succeed. |
[email protected] | 174c6d4 | 2014-08-12 01:43:06 | [diff] [blame] | 250 | { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 251 | 1, // times_to_lose_during_commit |
| 252 | 0, // times_to_lose_during_draw |
| 253 | 0, // times_to_fail_recreate |
| 254 | false, // fallback_context_works |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 255 | false, // async_layer_tree_frame_sink_creation |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 256 | }, |
[email protected] | 174c6d4 | 2014-08-12 01:43:06 | [diff] [blame] | 257 | { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 258 | 0, // times_to_lose_during_commit |
| 259 | 1, // times_to_lose_during_draw |
| 260 | 0, // times_to_fail_recreate |
| 261 | false, // fallback_context_works |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 262 | false, // async_layer_tree_frame_sink_creation |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 263 | }, |
[email protected] | 174c6d4 | 2014-08-12 01:43:06 | [diff] [blame] | 264 | { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 265 | 1, // times_to_lose_during_commit |
| 266 | 0, // times_to_lose_during_draw |
| 267 | 3, // times_to_fail_recreate |
| 268 | false, // fallback_context_works |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 269 | false, // async_layer_tree_frame_sink_creation |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 270 | }, |
[email protected] | 174c6d4 | 2014-08-12 01:43:06 | [diff] [blame] | 271 | { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 272 | 0, // times_to_lose_during_commit |
| 273 | 1, // times_to_lose_during_draw |
| 274 | 3, // times_to_fail_recreate |
| 275 | false, // fallback_context_works |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 276 | false, // async_layer_tree_frame_sink_creation |
enne | 2097cab | 2014-09-25 20:16:31 | [diff] [blame] | 277 | }, |
| 278 | { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 279 | 0, // times_to_lose_during_commit |
| 280 | 1, // times_to_lose_during_draw |
| 281 | 3, // times_to_fail_recreate |
| 282 | false, // fallback_context_works |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 283 | true, // async_layer_tree_frame_sink_creation |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 284 | }, |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 285 | // Losing the context and recreating it any number of times should |
| 286 | // succeed. |
[email protected] | 174c6d4 | 2014-08-12 01:43:06 | [diff] [blame] | 287 | { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 288 | 10, // times_to_lose_during_commit |
| 289 | 0, // times_to_lose_during_draw |
| 290 | 0, // times_to_fail_recreate |
| 291 | false, // fallback_context_works |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 292 | false, // async_layer_tree_frame_sink_creation |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 293 | }, |
[email protected] | 174c6d4 | 2014-08-12 01:43:06 | [diff] [blame] | 294 | { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 295 | 0, // times_to_lose_during_commit |
| 296 | 10, // times_to_lose_during_draw |
| 297 | 0, // times_to_fail_recreate |
| 298 | false, // fallback_context_works |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 299 | false, // async_layer_tree_frame_sink_creation |
enne | 2097cab | 2014-09-25 20:16:31 | [diff] [blame] | 300 | }, |
| 301 | { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 302 | 10, // times_to_lose_during_commit |
| 303 | 0, // times_to_lose_during_draw |
| 304 | 0, // times_to_fail_recreate |
| 305 | false, // fallback_context_works |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 306 | true, // async_layer_tree_frame_sink_creation |
enne | 2097cab | 2014-09-25 20:16:31 | [diff] [blame] | 307 | }, |
| 308 | { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 309 | 0, // times_to_lose_during_commit |
| 310 | 10, // times_to_lose_during_draw |
| 311 | 0, // times_to_fail_recreate |
| 312 | false, // fallback_context_works |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 313 | true, // async_layer_tree_frame_sink_creation |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 314 | }, |
| 315 | // Losing the context, failing to reinitialize it, and making a fallback |
| 316 | // context should work. |
[email protected] | 174c6d4 | 2014-08-12 01:43:06 | [diff] [blame] | 317 | { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 318 | 0, // times_to_lose_during_commit |
| 319 | 1, // times_to_lose_during_draw |
| 320 | 0, // times_to_fail_recreate |
| 321 | true, // fallback_context_works |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 322 | false, // async_layer_tree_frame_sink_creation |
enne | 2097cab | 2014-09-25 20:16:31 | [diff] [blame] | 323 | }, |
| 324 | { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 325 | 0, // times_to_lose_during_commit |
| 326 | 1, // times_to_lose_during_draw |
| 327 | 0, // times_to_fail_recreate |
| 328 | true, // fallback_context_works |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 329 | true, // async_layer_tree_frame_sink_creation |
[email protected] | 174c6d4 | 2014-08-12 01:43:06 | [diff] [blame] | 330 | }, |
| 331 | }; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 332 | |
Avi Drissman | 0dd4e0e6 | 2018-12-25 23:20:46 | [diff] [blame] | 333 | if (test_case_ >= base::size(kTests)) |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 334 | return false; |
[email protected] | c9addd1 | 2013-12-08 22:43:26 | [diff] [blame] | 335 | // Make sure that we lost our context at least once in the last test run so |
| 336 | // the test did something. |
| 337 | EXPECT_GT(num_losses_, num_losses_last_test_case_); |
| 338 | num_losses_last_test_case_ = num_losses_; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 339 | |
| 340 | times_to_lose_during_commit_ = |
| 341 | kTests[test_case_].times_to_lose_during_commit; |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 342 | times_to_lose_during_draw_ = kTests[test_case_].times_to_lose_during_draw; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 343 | times_to_fail_recreate_ = kTests[test_case_].times_to_fail_recreate; |
[email protected] | ebc0e1df | 2013-08-01 02:46:22 | [diff] [blame] | 344 | fallback_context_works_ = kTests[test_case_].fallback_context_works; |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 345 | async_layer_tree_frame_sink_creation_ = |
| 346 | kTests[test_case_].async_layer_tree_frame_sink_creation; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 347 | ++test_case_; |
| 348 | return true; |
| 349 | } |
| 350 | |
| 351 | struct TestCase { |
| 352 | int times_to_lose_during_commit; |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 353 | int times_to_lose_during_draw; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 354 | int times_to_fail_recreate; |
[email protected] | ebc0e1df | 2013-08-01 02:46:22 | [diff] [blame] | 355 | bool fallback_context_works; |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 356 | bool async_layer_tree_frame_sink_creation; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 357 | }; |
| 358 | |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 359 | protected: |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 360 | size_t test_case_; |
| 361 | int num_losses_; |
[email protected] | c9addd1 | 2013-12-08 22:43:26 | [diff] [blame] | 362 | int num_losses_last_test_case_; |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 363 | bool recovered_context_; |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 364 | bool first_initialized_; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 365 | }; |
| 366 | |
Xida Chen | 4731a33 | 2017-06-23 17:41:09 | [diff] [blame] | 367 | // Disabled because of crbug.com/736392 |
| 368 | // SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLostContextSucceeds); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 369 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 370 | class LayerTreeHostClientNotVisibleDoesNotCreateLayerTreeFrameSink |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 371 | : public LayerTreeHostContextTest { |
| 372 | public: |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 373 | LayerTreeHostClientNotVisibleDoesNotCreateLayerTreeFrameSink() |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 374 | : LayerTreeHostContextTest() {} |
| 375 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 376 | void WillBeginTest() override { |
sievers | 71c62dd5 | 2015-10-07 01:44:39 | [diff] [blame] | 377 | // Override to not become visible. |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 378 | DCHECK(!layer_tree_host()->IsVisible()); |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 379 | } |
| 380 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 381 | void BeginTest() override { |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 382 | PostSetNeedsCommitToMainThread(); |
| 383 | EndTest(); |
| 384 | } |
| 385 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 386 | void RequestNewLayerTreeFrameSink() override { |
| 387 | ADD_FAILURE() << "RequestNewLayerTreeFrameSink() should not be called"; |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 388 | } |
| 389 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 390 | void DidInitializeLayerTreeFrameSink() override { EXPECT_TRUE(false); } |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 391 | }; |
| 392 | |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 393 | SINGLE_AND_MULTI_THREAD_TEST_F( |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 394 | LayerTreeHostClientNotVisibleDoesNotCreateLayerTreeFrameSink); |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 395 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 396 | // This tests the LayerTreeFrameSink release logic in the following sequence. |
| 397 | // SetUp LTH and create and init LayerTreeFrameSink. |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 398 | // LTH::SetVisible(false); |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 399 | // LTH::ReleaseLayerTreeFrameSink(); |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 400 | // ... |
| 401 | // LTH::SetVisible(true); |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 402 | // Create and init new LayerTreeFrameSink |
| 403 | class LayerTreeHostClientTakeAwayLayerTreeFrameSink |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 404 | : public LayerTreeHostContextTest { |
| 405 | public: |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 406 | LayerTreeHostClientTakeAwayLayerTreeFrameSink() |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 407 | : LayerTreeHostContextTest(), setos_counter_(0) {} |
| 408 | |
| 409 | void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 410 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 411 | void RequestNewLayerTreeFrameSink() override { |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 412 | if (layer_tree_host()->IsVisible()) { |
danakj | 014316e | 2016-08-04 18:40:26 | [diff] [blame] | 413 | setos_counter_++; |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 414 | LayerTreeHostContextTest::RequestNewLayerTreeFrameSink(); |
danakj | 014316e | 2016-08-04 18:40:26 | [diff] [blame] | 415 | } |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 416 | } |
| 417 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 418 | void HideAndReleaseLayerTreeFrameSink() { |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 419 | EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread()); |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 420 | layer_tree_host()->SetVisible(false); |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 421 | std::unique_ptr<LayerTreeFrameSink> surface = |
| 422 | layer_tree_host()->ReleaseLayerTreeFrameSink(); |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 423 | CHECK(surface); |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 424 | MainThreadTaskRunner()->PostTask( |
| 425 | FROM_HERE, |
tzik | 4604bb5 | 2017-04-13 21:50:22 | [diff] [blame] | 426 | base::BindOnce( |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 427 | &LayerTreeHostClientTakeAwayLayerTreeFrameSink::MakeVisible, |
tzik | 4604bb5 | 2017-04-13 21:50:22 | [diff] [blame] | 428 | base::Unretained(this))); |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 429 | } |
| 430 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 431 | void DidInitializeLayerTreeFrameSink() override { |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 432 | EXPECT_TRUE(layer_tree_host()->IsVisible()); |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 433 | if (setos_counter_ == 1) { |
| 434 | MainThreadTaskRunner()->PostTask( |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 435 | FROM_HERE, |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 436 | base::BindOnce(&LayerTreeHostClientTakeAwayLayerTreeFrameSink:: |
| 437 | HideAndReleaseLayerTreeFrameSink, |
tzik | 4604bb5 | 2017-04-13 21:50:22 | [diff] [blame] | 438 | base::Unretained(this))); |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 439 | } else { |
| 440 | EndTest(); |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | void MakeVisible() { |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 445 | EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread()); |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 446 | layer_tree_host()->SetVisible(true); |
| 447 | } |
| 448 | |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 449 | int setos_counter_; |
| 450 | }; |
| 451 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 452 | SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostClientTakeAwayLayerTreeFrameSink); |
sohan.jyoti | 3a33d87 | 2015-09-18 22:32:55 | [diff] [blame] | 453 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 454 | class MultipleCompositeDoesNotCreateLayerTreeFrameSink |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 455 | : public LayerTreeHostContextTest { |
| 456 | public: |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 457 | MultipleCompositeDoesNotCreateLayerTreeFrameSink() |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 458 | : LayerTreeHostContextTest(), request_count_(0) {} |
| 459 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 460 | void InitializeSettings(LayerTreeSettings* settings) override { |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 461 | settings->single_thread_proxy_scheduler = false; |
danakj | 16e072d | 2015-05-21 00:31:16 | [diff] [blame] | 462 | settings->use_zero_copy = true; |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 463 | } |
| 464 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 465 | void RequestNewLayerTreeFrameSink() override { |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 466 | EXPECT_GE(1, ++request_count_); |
| 467 | EndTest(); |
| 468 | } |
| 469 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 470 | void BeginTest() override { |
Khushal | 4b6c4188 | 2018-02-16 09:02:10 | [diff] [blame] | 471 | layer_tree_host()->Composite(TicksFromMicroseconds(1), false); |
| 472 | layer_tree_host()->Composite(TicksFromMicroseconds(2), false); |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 473 | } |
| 474 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 475 | void DidInitializeLayerTreeFrameSink() override { EXPECT_TRUE(false); } |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 476 | |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 477 | int request_count_; |
| 478 | }; |
| 479 | |
Dana Jansens | ab27776 | 2015-06-12 23:52:55 | [diff] [blame] | 480 | // This test uses Composite() which only exists for single thread. |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 481 | SINGLE_THREAD_TEST_F(MultipleCompositeDoesNotCreateLayerTreeFrameSink); |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 482 | |
enne | 5232fbb | 2015-01-27 21:22:41 | [diff] [blame] | 483 | // This test makes sure that once a SingleThreadProxy issues a |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 484 | // DidFailToInitializeLayerTreeFrameSink, that future Composite calls will not |
enne | 5232fbb | 2015-01-27 21:22:41 | [diff] [blame] | 485 | // trigger additional requests for output surfaces. |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 486 | class FailedCreateDoesNotCreateExtraLayerTreeFrameSink |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 487 | : public LayerTreeHostContextTest { |
| 488 | public: |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 489 | FailedCreateDoesNotCreateExtraLayerTreeFrameSink() |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 490 | : LayerTreeHostContextTest(), num_requests_(0), has_failed_(false) { |
| 491 | times_to_fail_create_ = 1; |
| 492 | } |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 493 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 494 | void InitializeSettings(LayerTreeSettings* settings) override { |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 495 | settings->single_thread_proxy_scheduler = false; |
danakj | 16e072d | 2015-05-21 00:31:16 | [diff] [blame] | 496 | settings->use_zero_copy = true; |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 497 | } |
| 498 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 499 | void RequestNewLayerTreeFrameSink() override { |
enne | 5232fbb | 2015-01-27 21:22:41 | [diff] [blame] | 500 | num_requests_++; |
| 501 | // There should be one initial request and then one request from |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 502 | // the LayerTreeTest test hooks DidFailToInitializeLayerTreeFrameSink |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 503 | // (which is hard to skip). This second request is just ignored and is test |
| 504 | // cruft. |
enne | 5232fbb | 2015-01-27 21:22:41 | [diff] [blame] | 505 | EXPECT_LE(num_requests_, 2); |
| 506 | if (num_requests_ > 1) |
| 507 | return; |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 508 | LayerTreeHostContextTest::RequestNewLayerTreeFrameSink(); |
danakj | 014316e | 2016-08-04 18:40:26 | [diff] [blame] | 509 | } |
| 510 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 511 | void BeginTest() override { |
enne | 5232fbb | 2015-01-27 21:22:41 | [diff] [blame] | 512 | // First composite tries to create a surface. |
Khushal | 4b6c4188 | 2018-02-16 09:02:10 | [diff] [blame] | 513 | layer_tree_host()->Composite(TicksFromMicroseconds(1), false); |
enne | 5232fbb | 2015-01-27 21:22:41 | [diff] [blame] | 514 | EXPECT_EQ(num_requests_, 2); |
| 515 | EXPECT_TRUE(has_failed_); |
| 516 | |
| 517 | // Second composite should not request or fail. |
Khushal | 4b6c4188 | 2018-02-16 09:02:10 | [diff] [blame] | 518 | layer_tree_host()->Composite(TicksFromMicroseconds(2), false); |
enne | 5232fbb | 2015-01-27 21:22:41 | [diff] [blame] | 519 | EXPECT_EQ(num_requests_, 2); |
| 520 | EndTest(); |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 521 | } |
| 522 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 523 | void DidInitializeLayerTreeFrameSink() override { EXPECT_TRUE(false); } |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 524 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 525 | void DidFailToInitializeLayerTreeFrameSink() override { |
| 526 | LayerTreeHostContextTest::DidFailToInitializeLayerTreeFrameSink(); |
enne | 5232fbb | 2015-01-27 21:22:41 | [diff] [blame] | 527 | EXPECT_FALSE(has_failed_); |
| 528 | has_failed_ = true; |
enne | 7f8fdde | 2014-12-10 21:32:09 | [diff] [blame] | 529 | } |
| 530 | |
enne | 5232fbb | 2015-01-27 21:22:41 | [diff] [blame] | 531 | int num_requests_; |
| 532 | bool has_failed_; |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 533 | }; |
| 534 | |
Dana Jansens | ab27776 | 2015-06-12 23:52:55 | [diff] [blame] | 535 | // This test uses Composite() which only exists for single thread. |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 536 | SINGLE_THREAD_TEST_F(FailedCreateDoesNotCreateExtraLayerTreeFrameSink); |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 537 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 538 | class LayerTreeHostContextTestCommitAfterDelayedLayerTreeFrameSink |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 539 | : public LayerTreeHostContextTest { |
| 540 | public: |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 541 | LayerTreeHostContextTestCommitAfterDelayedLayerTreeFrameSink() |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 542 | : LayerTreeHostContextTest(), creating_output_(false) {} |
| 543 | |
| 544 | void InitializeSettings(LayerTreeSettings* settings) override { |
| 545 | settings->single_thread_proxy_scheduler = false; |
danakj | 16e072d | 2015-05-21 00:31:16 | [diff] [blame] | 546 | settings->use_zero_copy = true; |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 547 | } |
| 548 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 549 | void RequestNewLayerTreeFrameSink() override { |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 550 | MainThreadTaskRunner()->PostTask( |
| 551 | FROM_HERE, |
tzik | 4604bb5 | 2017-04-13 21:50:22 | [diff] [blame] | 552 | base::BindOnce( |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 553 | &LayerTreeHostContextTestCommitAfterDelayedLayerTreeFrameSink:: |
| 554 | CreateAndSetLayerTreeFrameSink, |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 555 | base::Unretained(this))); |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 556 | } |
| 557 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 558 | void CreateAndSetLayerTreeFrameSink() { |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 559 | creating_output_ = true; |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 560 | LayerTreeHostContextTest::RequestNewLayerTreeFrameSink(); |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 561 | } |
| 562 | |
mithro | 0bdb49d | 2015-05-27 13:08:01 | [diff] [blame] | 563 | void BeginTest() override { |
Khushal | 4b6c4188 | 2018-02-16 09:02:10 | [diff] [blame] | 564 | layer_tree_host()->Composite(TicksFromMicroseconds(1), false); |
mithro | 0bdb49d | 2015-05-27 13:08:01 | [diff] [blame] | 565 | } |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 566 | |
| 567 | void ScheduleComposite() override { |
| 568 | if (creating_output_) |
| 569 | EndTest(); |
| 570 | } |
| 571 | |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 572 | bool creating_output_; |
| 573 | }; |
| 574 | |
Dana Jansens | ab27776 | 2015-06-12 23:52:55 | [diff] [blame] | 575 | // This test uses Composite() which only exists for single thread. |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 576 | SINGLE_THREAD_TEST_F( |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 577 | LayerTreeHostContextTestCommitAfterDelayedLayerTreeFrameSink); |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 578 | |
| 579 | class LayerTreeHostContextTestAvoidUnnecessaryComposite |
| 580 | : public LayerTreeHostContextTest { |
| 581 | public: |
| 582 | LayerTreeHostContextTestAvoidUnnecessaryComposite() |
| 583 | : LayerTreeHostContextTest(), in_composite_(false) {} |
| 584 | |
| 585 | void InitializeSettings(LayerTreeSettings* settings) override { |
| 586 | settings->single_thread_proxy_scheduler = false; |
danakj | 16e072d | 2015-05-21 00:31:16 | [diff] [blame] | 587 | settings->use_zero_copy = true; |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 588 | } |
| 589 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 590 | void RequestNewLayerTreeFrameSink() override { |
| 591 | LayerTreeHostContextTest::RequestNewLayerTreeFrameSink(); |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 592 | EndTest(); |
| 593 | } |
| 594 | |
| 595 | void BeginTest() override { |
| 596 | in_composite_ = true; |
Khushal | 4b6c4188 | 2018-02-16 09:02:10 | [diff] [blame] | 597 | layer_tree_host()->Composite(TicksFromMicroseconds(1), false); |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 598 | in_composite_ = false; |
| 599 | } |
| 600 | |
| 601 | void ScheduleComposite() override { EXPECT_FALSE(in_composite_); } |
| 602 | |
jbauman | 399aec1a | 2014-10-25 02:33:32 | [diff] [blame] | 603 | bool in_composite_; |
| 604 | }; |
| 605 | |
Dana Jansens | ab27776 | 2015-06-12 23:52:55 | [diff] [blame] | 606 | // This test uses Composite() which only exists for single thread. |
| 607 | SINGLE_THREAD_TEST_F(LayerTreeHostContextTestAvoidUnnecessaryComposite); |
jbauman | 8ab0f9e | 2014-10-15 02:30:34 | [diff] [blame] | 608 | |
Dana Jansens | ab27776 | 2015-06-12 23:52:55 | [diff] [blame] | 609 | // This test uses PictureLayer to check for a working context. |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 610 | class LayerTreeHostContextTestLostContextSucceedsWithContent |
| 611 | : public LayerTreeHostContextTestLostContextSucceeds { |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 612 | public: |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 613 | void SetupTree() override { |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 614 | root_ = Layer::Create(); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 615 | root_->SetBounds(gfx::Size(10, 10)); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 616 | root_->SetIsDrawable(true); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 617 | |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 618 | // Paint non-solid color. |
enne | bb7c4bcf | 2017-02-07 17:59:49 | [diff] [blame] | 619 | PaintFlags flags; |
| 620 | flags.setColor(SkColorSetARGB(100, 80, 200, 200)); |
| 621 | client_.add_draw_rect(gfx::Rect(5, 5), flags); |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 622 | |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 623 | layer_ = FakePictureLayer::Create(&client_); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 624 | layer_->SetBounds(gfx::Size(10, 10)); |
| 625 | layer_->SetIsDrawable(true); |
| 626 | |
| 627 | root_->AddChild(layer_); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 628 | |
khushalsagar | b69ba945 | 2017-01-27 22:20:07 | [diff] [blame] | 629 | layer_tree_host()->SetRootLayer(root_); |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 630 | LayerTreeHostContextTest::SetupTree(); |
chrishtr | 01539b80 | 2015-11-24 08:11:32 | [diff] [blame] | 631 | client_.set_bounds(root_->bounds()); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 632 | } |
| 633 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 634 | void InvalidateAndSetNeedsCommit() override { |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 635 | // Invalidate the render surface so we don't try to use a cached copy of the |
| 636 | // surface. We want to make sure to test the drawing paths for drawing to |
| 637 | // a child surface. |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 638 | layer_->SetNeedsDisplay(); |
[email protected] | e01dddb1 | 2013-01-23 03:57:08 | [diff] [blame] | 639 | LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); |
| 640 | } |
| 641 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 642 | void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
danakj | eed856b6 | 2015-06-10 21:31:03 | [diff] [blame] | 643 | FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>( |
sunxd | 1ae6803f | 2016-04-21 20:15:12 | [diff] [blame] | 644 | host_impl->active_tree()->LayerById(layer_->id())); |
danakj | eed856b6 | 2015-06-10 21:31:03 | [diff] [blame] | 645 | EXPECT_TRUE(picture_impl->HighResTiling() |
| 646 | ->TileAt(0, 0) |
| 647 | ->draw_info() |
| 648 | .IsReadyToDraw()); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | protected: |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 652 | FakeContentLayerClient client_; |
| 653 | scoped_refptr<Layer> root_; |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 654 | scoped_refptr<Layer> layer_; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 655 | }; |
| 656 | |
Dana Jansens | ab27776 | 2015-06-12 23:52:55 | [diff] [blame] | 657 | SINGLE_AND_MULTI_THREAD_TEST_F( |
[email protected] | c2cc8bb | 2014-04-24 01:17:52 | [diff] [blame] | 658 | LayerTreeHostContextTestLostContextSucceedsWithContent); |
[email protected] | 2a61ad5 | 2013-05-13 14:01:29 | [diff] [blame] | 659 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 660 | class LayerTreeHostContextTestCreateLayerTreeFrameSinkFailsOnce |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 661 | : public LayerTreeHostContextTest { |
| 662 | public: |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 663 | LayerTreeHostContextTestCreateLayerTreeFrameSinkFailsOnce() |
enne | 7f8fdde | 2014-12-10 21:32:09 | [diff] [blame] | 664 | : times_to_fail_(1), times_initialized_(0) { |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 665 | times_to_fail_create_ = times_to_fail_; |
| 666 | } |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 667 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 668 | void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 669 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 670 | void DidInitializeLayerTreeFrameSink() override { times_initialized_++; } |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 671 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 672 | void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { EndTest(); } |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 673 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 674 | void AfterTest() override { |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 675 | EXPECT_EQ(times_to_fail_, times_create_failed_); |
[email protected] | da8e3b72b | 2014-04-25 02:33:45 | [diff] [blame] | 676 | EXPECT_NE(0, times_initialized_); |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | private: |
| 680 | int times_to_fail_; |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 681 | int times_initialized_; |
| 682 | }; |
| 683 | |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 684 | SINGLE_AND_MULTI_THREAD_TEST_F( |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 685 | LayerTreeHostContextTestCreateLayerTreeFrameSinkFailsOnce); |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 686 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 687 | class LayerTreeHostContextTestLostContextAndEvictTextures |
| 688 | : public LayerTreeHostContextTest { |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 689 | public: |
| 690 | LayerTreeHostContextTestLostContextAndEvictTextures() |
| 691 | : LayerTreeHostContextTest(), |
Ivan Kotenkov | 05d5754 | 2017-10-25 06:47:00 | [diff] [blame] | 692 | impl_host_(nullptr), |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 693 | num_commits_(0), |
| 694 | lost_context_(false) {} |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 695 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 696 | void SetupTree() override { |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 697 | // Paint non-solid color. |
enne | bb7c4bcf | 2017-02-07 17:59:49 | [diff] [blame] | 698 | PaintFlags flags; |
| 699 | flags.setColor(SkColorSetARGB(100, 80, 200, 200)); |
| 700 | client_.add_draw_rect(gfx::Rect(5, 5), flags); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 701 | |
danakj | eed856b6 | 2015-06-10 21:31:03 | [diff] [blame] | 702 | scoped_refptr<FakePictureLayer> picture_layer = |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 703 | FakePictureLayer::Create(&client_); |
danakj | eed856b6 | 2015-06-10 21:31:03 | [diff] [blame] | 704 | picture_layer->SetBounds(gfx::Size(10, 20)); |
chrishtr | 01539b80 | 2015-11-24 08:11:32 | [diff] [blame] | 705 | client_.set_bounds(picture_layer->bounds()); |
khushalsagar | b69ba945 | 2017-01-27 22:20:07 | [diff] [blame] | 706 | layer_tree_host()->SetRootLayer(picture_layer); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 707 | |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 708 | LayerTreeHostContextTest::SetupTree(); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 709 | } |
| 710 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 711 | void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 712 | |
| 713 | void PostEvictTextures() { |
[email protected] | 810d40b7 | 2013-06-20 18:26:15 | [diff] [blame] | 714 | if (HasImplThread()) { |
| 715 | ImplThreadTaskRunner()->PostTask( |
| 716 | FROM_HERE, |
tzik | 4604bb5 | 2017-04-13 21:50:22 | [diff] [blame] | 717 | base::BindOnce(&LayerTreeHostContextTestLostContextAndEvictTextures:: |
| 718 | EvictTexturesOnImplThread, |
| 719 | base::Unretained(this))); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 720 | } else { |
khushalsagar | b7db1fe | 2015-11-12 00:51:27 | [diff] [blame] | 721 | DebugScopedSetImplThread impl(task_runner_provider()); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 722 | EvictTexturesOnImplThread(); |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | void EvictTexturesOnImplThread() { |
[email protected] | 0309ba5e0 | 2013-06-26 04:11:08 | [diff] [blame] | 727 | impl_host_->EvictTexturesForTesting(); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 728 | |
| 729 | if (lose_after_evict_) { |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 730 | LoseContext(); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 731 | lost_context_ = true; |
| 732 | } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 733 | } |
| 734 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 735 | void DidCommitAndDrawFrame() override { |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 736 | if (num_commits_ > 1) |
| 737 | return; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 738 | PostEvictTextures(); |
| 739 | } |
| 740 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 741 | void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
Dirk Pranke | 035a794 | 2014-09-17 18:56:14 | [diff] [blame] | 742 | LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 743 | if (num_commits_ > 1) |
| 744 | return; |
| 745 | ++num_commits_; |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 746 | if (!lose_after_evict_) { |
Dirk Pranke | 035a794 | 2014-09-17 18:56:14 | [diff] [blame] | 747 | LoseContext(); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 748 | lost_context_ = true; |
| 749 | } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 750 | } |
| 751 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 752 | void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
Xianzhu Wang | 66e13e0 | 2019-09-18 20:39:12 | [diff] [blame] | 753 | FakePictureLayerImpl* picture_impl = |
| 754 | static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer()); |
danakj | eed856b6 | 2015-06-10 21:31:03 | [diff] [blame] | 755 | EXPECT_TRUE(picture_impl->HighResTiling() |
| 756 | ->TileAt(0, 0) |
| 757 | ->draw_info() |
| 758 | .IsReadyToDraw()); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 759 | |
| 760 | impl_host_ = impl; |
| 761 | if (lost_context_) |
| 762 | EndTest(); |
| 763 | } |
| 764 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 765 | void DidInitializeLayerTreeFrameSink() override {} |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 766 | |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 767 | protected: |
| 768 | bool lose_after_evict_; |
| 769 | FakeContentLayerClient client_; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 770 | LayerTreeHostImpl* impl_host_; |
| 771 | int num_commits_; |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 772 | bool lost_context_; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 773 | }; |
| 774 | |
Olga Sharonova | e899468 | 2017-11-22 12:05:22 | [diff] [blame] | 775 | TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 776 | LoseAfterEvict_SingleThread) { |
| 777 | lose_after_evict_ = true; |
| 778 | RunTest(CompositorMode::SINGLE_THREADED); |
| 779 | } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 780 | |
Olga Sharonova | e899468 | 2017-11-22 12:05:22 | [diff] [blame] | 781 | TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 782 | LoseAfterEvict_MultiThread) { |
| 783 | lose_after_evict_ = true; |
| 784 | RunTest(CompositorMode::THREADED); |
| 785 | } |
[email protected] | 4145d17 | 2013-05-10 16:54:36 | [diff] [blame] | 786 | |
Olga Sharonova | e899468 | 2017-11-22 12:05:22 | [diff] [blame] | 787 | TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 788 | LoseBeforeEvict_SingleThread) { |
| 789 | lose_after_evict_ = false; |
| 790 | RunTest(CompositorMode::SINGLE_THREADED); |
| 791 | } |
[email protected] | 4145d17 | 2013-05-10 16:54:36 | [diff] [blame] | 792 | |
Olga Sharonova | e899468 | 2017-11-22 12:05:22 | [diff] [blame] | 793 | TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 794 | LoseBeforeEvict_MultiThread) { |
| 795 | lose_after_evict_ = false; |
| 796 | RunTest(CompositorMode::THREADED); |
| 797 | } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 798 | |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 799 | class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 800 | public: |
| 801 | LayerTreeHostContextTestLayersNotified() |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 802 | : LayerTreeHostContextTest(), num_commits_(0) {} |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 803 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 804 | void SetupTree() override { |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 805 | root_ = FakePictureLayer::Create(&client_); |
| 806 | child_ = FakePictureLayer::Create(&client_); |
| 807 | grandchild_ = FakePictureLayer::Create(&client_); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 808 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 809 | root_->AddChild(child_); |
| 810 | child_->AddChild(grandchild_); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 811 | |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 812 | LayerTreeHostContextTest::SetupTree(); |
chrishtr | 01539b80 | 2015-11-24 08:11:32 | [diff] [blame] | 813 | client_.set_bounds(root_->bounds()); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 814 | } |
| 815 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 816 | void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 817 | |
Adrienne Walker | 91d934793 | 2018-11-07 02:11:17 | [diff] [blame] | 818 | void AttachTree() { layer_tree_host()->SetRootLayer(root_); } |
| 819 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 820 | void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
[email protected] | 94bf75c | 2013-06-12 13:20:04 | [diff] [blame] | 821 | LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 822 | |
Sunny Sachanandani | 0c193dc | 2018-11-10 01:14:02 | [diff] [blame] | 823 | ++num_commits_; |
| 824 | |
Ivan Kotenkov | 05d5754 | 2017-10-25 06:47:00 | [diff] [blame] | 825 | FakePictureLayerImpl* root_picture = nullptr; |
| 826 | FakePictureLayerImpl* child_picture = nullptr; |
| 827 | FakePictureLayerImpl* grandchild_picture = nullptr; |
Sunny Sachanandani | 0c193dc | 2018-11-10 01:14:02 | [diff] [blame] | 828 | // Root layer isn't attached on first activation so the static_cast will |
| 829 | // fail before second activation. |
| 830 | if (num_commits_ >= 2) { |
| 831 | root_picture = static_cast<FakePictureLayerImpl*>( |
Xianzhu Wang | 66e13e0 | 2019-09-18 20:39:12 | [diff] [blame] | 832 | host_impl->active_tree()->root_layer()); |
Sunny Sachanandani | 0c193dc | 2018-11-10 01:14:02 | [diff] [blame] | 833 | child_picture = static_cast<FakePictureLayerImpl*>( |
| 834 | host_impl->active_tree()->LayerById(child_->id())); |
| 835 | grandchild_picture = static_cast<FakePictureLayerImpl*>( |
| 836 | host_impl->active_tree()->LayerById(grandchild_->id())); |
| 837 | } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 838 | switch (num_commits_) { |
| 839 | case 1: |
Adrienne Walker | 91d934793 | 2018-11-07 02:11:17 | [diff] [blame] | 840 | // Because setting the colorspace on the first activation releases |
| 841 | // resources, don't attach the layers until the first activation. |
| 842 | // Because of single thread vs multi thread differences (i.e. |
| 843 | // commit to active tree), if this delay is not done, then the |
| 844 | // active tree layers will have a different number of resource |
| 845 | // releasing. |
| 846 | MainThreadTaskRunner()->PostTask( |
| 847 | FROM_HERE, |
| 848 | base::BindOnce(&LayerTreeHostContextTestLayersNotified::AttachTree, |
| 849 | base::Unretained(this))); |
| 850 | break; |
| 851 | case 2: |
danakj | eed856b6 | 2015-06-10 21:31:03 | [diff] [blame] | 852 | EXPECT_EQ(0u, root_picture->release_resources_count()); |
| 853 | EXPECT_EQ(0u, child_picture->release_resources_count()); |
| 854 | EXPECT_EQ(0u, grandchild_picture->release_resources_count()); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 855 | |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 856 | // Lose the context and struggle to recreate it. |
| 857 | LoseContext(); |
| 858 | times_to_fail_create_ = 1; |
| 859 | break; |
Adrienne Walker | 91d934793 | 2018-11-07 02:11:17 | [diff] [blame] | 860 | case 3: |
danakj | eed856b6 | 2015-06-10 21:31:03 | [diff] [blame] | 861 | EXPECT_TRUE(root_picture->release_resources_count()); |
| 862 | EXPECT_TRUE(child_picture->release_resources_count()); |
| 863 | EXPECT_TRUE(grandchild_picture->release_resources_count()); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 864 | |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 865 | EndTest(); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 866 | break; |
| 867 | default: |
| 868 | NOTREACHED(); |
| 869 | } |
| 870 | } |
| 871 | |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 872 | private: |
| 873 | int num_commits_; |
| 874 | |
| 875 | FakeContentLayerClient client_; |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 876 | scoped_refptr<Layer> root_; |
| 877 | scoped_refptr<Layer> child_; |
| 878 | scoped_refptr<Layer> grandchild_; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 879 | }; |
| 880 | |
[email protected] | 75ea789f | 2013-03-27 18:06:10 | [diff] [blame] | 881 | SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 882 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 883 | class LayerTreeHostContextTestDontUseLostResources |
| 884 | : public LayerTreeHostContextTest { |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 885 | public: |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 886 | LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) { |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 887 | context_should_support_io_surface_ = true; |
[email protected] | 50008cd | 2013-10-20 08:20:27 | [diff] [blame] | 888 | |
kylechar | dfe762f | 2018-02-26 17:00:01 | [diff] [blame] | 889 | child_context_provider_ = viz::TestContextProvider::Create(); |
danakj | 45cfd23 | 2017-10-18 19:31:31 | [diff] [blame] | 890 | auto result = child_context_provider_->BindToCurrentThread(); |
| 891 | CHECK_EQ(result, gpu::ContextResult::kSuccess); |
kylechar | efc4845 | 2018-02-23 17:11:00 | [diff] [blame] | 892 | shared_bitmap_manager_ = std::make_unique<viz::TestSharedBitmapManager>(); |
Xu Xing | b57edf3 | 2017-08-22 04:18:47 | [diff] [blame] | 893 | child_resource_provider_ = |
danakj | 4b15f74 | 2018-05-30 22:52:22 | [diff] [blame] | 894 | std::make_unique<viz::ClientResourceProvider>(true); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 895 | } |
| 896 | |
dyen | cc16ed4d | 2015-11-03 20:03:04 | [diff] [blame] | 897 | static void EmptyReleaseCallback(const gpu::SyncToken& sync_token, |
| 898 | bool lost) {} |
[email protected] | 50008cd | 2013-10-20 08:20:27 | [diff] [blame] | 899 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 900 | void SetupTree() override { |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 901 | gpu::gles2::GLES2Interface* gl = child_context_provider_->ContextGL(); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 902 | |
Antoine Labour | 3a776dc1 | 2018-06-13 00:07:48 | [diff] [blame] | 903 | gpu::Mailbox mailbox = gpu::Mailbox::Generate(); |
dyen | 0f07227 | 2016-01-08 01:16:15 | [diff] [blame] | 904 | |
dyen | 0f07227 | 2016-01-08 01:16:15 | [diff] [blame] | 905 | gpu::SyncToken sync_token; |
Sunny Sachanandani | c94b8de | 2017-12-16 03:30:30 | [diff] [blame] | 906 | gl->GenSyncTokenCHROMIUM(sync_token.GetData()); |
[email protected] | 50008cd | 2013-10-20 08:20:27 | [diff] [blame] | 907 | |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 908 | scoped_refptr<Layer> root = Layer::Create(); |
[email protected] | 50008cd | 2013-10-20 08:20:27 | [diff] [blame] | 909 | root->SetBounds(gfx::Size(10, 10)); |
[email protected] | 50008cd | 2013-10-20 08:20:27 | [diff] [blame] | 910 | root->SetIsDrawable(true); |
| 911 | |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 912 | scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client_); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 913 | layer->SetBounds(gfx::Size(10, 10)); |
| 914 | layer->SetIsDrawable(true); |
| 915 | root->AddChild(layer); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 916 | |
Ivan Kotenkov | 05d5754 | 2017-10-25 06:47:00 | [diff] [blame] | 917 | scoped_refptr<TextureLayer> texture = |
| 918 | TextureLayer::CreateForMailbox(nullptr); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 919 | texture->SetBounds(gfx::Size(10, 10)); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 920 | texture->SetIsDrawable(true); |
Saman Sami | 51c0a3e | 2019-05-02 13:43:38 | [diff] [blame] | 921 | constexpr gfx::Size size(64, 64); |
danakj | 5df8257f | 2017-11-20 22:16:58 | [diff] [blame] | 922 | auto resource = viz::TransferableResource::MakeGL( |
Saman Sami | 51c0a3e | 2019-05-02 13:43:38 | [diff] [blame] | 923 | mailbox, GL_LINEAR, GL_TEXTURE_2D, sync_token, size, |
| 924 | false /* is_overlay_candidate */); |
danakj | 5df8257f | 2017-11-20 22:16:58 | [diff] [blame] | 925 | texture->SetTransferableResource( |
kylechar | 3ef69ec | 2019-01-16 21:07:15 | [diff] [blame] | 926 | resource, viz::SingleReleaseCallback::Create(base::BindOnce( |
| 927 | &LayerTreeHostContextTestDontUseLostResources:: |
| 928 | EmptyReleaseCallback))); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 929 | root->AddChild(texture); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 930 | |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 931 | scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client_); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 932 | mask->SetBounds(gfx::Size(10, 10)); |
chrishtr | 01539b80 | 2015-11-24 08:11:32 | [diff] [blame] | 933 | client_.set_bounds(mask->bounds()); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 934 | |
danakj | eed856b6 | 2015-06-10 21:31:03 | [diff] [blame] | 935 | scoped_refptr<PictureLayer> layer_with_mask = |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 936 | PictureLayer::Create(&client_); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 937 | layer_with_mask->SetBounds(gfx::Size(10, 10)); |
| 938 | layer_with_mask->SetIsDrawable(true); |
Xianzhu Wang | 15557bb2f | 2019-08-30 22:33:01 | [diff] [blame] | 939 | layer_with_mask->SetMaskLayer(mask); |
sohan.jyoti | 9d1e420 | 2014-09-23 21:02:33 | [diff] [blame] | 940 | root->AddChild(layer_with_mask); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 941 | |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 942 | scoped_refptr<VideoLayer> video_color = |
| 943 | VideoLayer::Create(&color_frame_provider_, media::VIDEO_ROTATION_0); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 944 | video_color->SetBounds(gfx::Size(10, 10)); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 945 | video_color->SetIsDrawable(true); |
| 946 | root->AddChild(video_color); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 947 | |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 948 | scoped_refptr<VideoLayer> video_hw = |
| 949 | VideoLayer::Create(&hw_frame_provider_, media::VIDEO_ROTATION_0); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 950 | video_hw->SetBounds(gfx::Size(10, 10)); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 951 | video_hw->SetIsDrawable(true); |
| 952 | root->AddChild(video_hw); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 953 | |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 954 | scoped_refptr<VideoLayer> video_scaled_hw = |
| 955 | VideoLayer::Create(&scaled_hw_frame_provider_, media::VIDEO_ROTATION_0); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 956 | video_scaled_hw->SetBounds(gfx::Size(10, 10)); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 957 | video_scaled_hw->SetIsDrawable(true); |
| 958 | root->AddChild(video_scaled_hw); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 959 | |
[email protected] | 50008cd | 2013-10-20 08:20:27 | [diff] [blame] | 960 | color_video_frame_ = VideoFrame::CreateColorFrame( |
| 961 | gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
emircan | 8428d41 | 2016-01-15 08:59:27 | [diff] [blame] | 962 | ASSERT_TRUE(color_video_frame_); |
jbauman | b97bf4cf | 2016-05-12 00:20:18 | [diff] [blame] | 963 | gpu::MailboxHolder holders[media::VideoFrame::kMaxPlanes] = { |
| 964 | gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D)}; |
| 965 | hw_video_frame_ = VideoFrame::WrapNativeTextures( |
| 966 | media::PIXEL_FORMAT_ARGB, holders, |
achaulk | 91d8e7f | 2015-01-29 22:16:05 | [diff] [blame] | 967 | media::VideoFrame::ReleaseMailboxCB(), gfx::Size(4, 4), |
mcasas | 4337a74 | 2015-06-11 00:11:39 | [diff] [blame] | 968 | gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeDelta()); |
emircan | 8428d41 | 2016-01-15 08:59:27 | [diff] [blame] | 969 | ASSERT_TRUE(hw_video_frame_); |
jbauman | b97bf4cf | 2016-05-12 00:20:18 | [diff] [blame] | 970 | scaled_hw_video_frame_ = VideoFrame::WrapNativeTextures( |
| 971 | media::PIXEL_FORMAT_ARGB, holders, |
achaulk | 91d8e7f | 2015-01-29 22:16:05 | [diff] [blame] | 972 | media::VideoFrame::ReleaseMailboxCB(), gfx::Size(4, 4), |
mcasas | 4337a74 | 2015-06-11 00:11:39 | [diff] [blame] | 973 | gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeDelta()); |
emircan | 8428d41 | 2016-01-15 08:59:27 | [diff] [blame] | 974 | ASSERT_TRUE(scaled_hw_video_frame_); |
[email protected] | 50008cd | 2013-10-20 08:20:27 | [diff] [blame] | 975 | |
| 976 | color_frame_provider_.set_frame(color_video_frame_); |
| 977 | hw_frame_provider_.set_frame(hw_video_frame_); |
| 978 | scaled_hw_frame_provider_.set_frame(scaled_hw_video_frame_); |
| 979 | |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 980 | // Enable the hud. |
| 981 | LayerTreeDebugState debug_state; |
[email protected] | 846f455b | 2013-03-18 19:07:41 | [diff] [blame] | 982 | debug_state.show_property_changed_rects = true; |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 983 | layer_tree_host()->SetDebugState(debug_state); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 984 | |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 985 | scoped_refptr<PaintedScrollbarLayer> scrollbar = |
Xianzhu Wang | 5e6254e | 2019-10-30 17:58:49 | [diff] [blame] | 986 | PaintedScrollbarLayer::Create(base::MakeRefCounted<FakeScrollbar>()); |
Xianzhu Wang | 42e5f477 | 2019-10-04 00:10:22 | [diff] [blame] | 987 | scrollbar->SetScrollElementId(layer->element_id()); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 988 | scrollbar->SetBounds(gfx::Size(10, 10)); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 989 | scrollbar->SetIsDrawable(true); |
| 990 | root->AddChild(scrollbar); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 991 | |
khushalsagar | b69ba945 | 2017-01-27 22:20:07 | [diff] [blame] | 992 | layer_tree_host()->SetRootLayer(root); |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 993 | LayerTreeHostContextTest::SetupTree(); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 994 | } |
| 995 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 996 | void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 997 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 998 | void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 999 | LayerTreeHostContextTest::CommitCompleteOnThread(host_impl); |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 1000 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 1001 | if (host_impl->active_tree()->source_frame_number() == 3) { |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 1002 | // On the third commit we're recovering from context loss. Hardware |
| 1003 | // video frames should not be reused by the VideoFrameProvider, but |
| 1004 | // software frames can be. |
Ivan Kotenkov | 05d5754 | 2017-10-25 06:47:00 | [diff] [blame] | 1005 | hw_frame_provider_.set_frame(nullptr); |
| 1006 | scaled_hw_frame_provider_.set_frame(nullptr); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 1007 | } |
| 1008 | } |
| 1009 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1010 | DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 1011 | LayerTreeHostImpl::FrameData* frame, |
| 1012 | DrawResult draw_result) override { |
sohan | 5f34803 | 2017-07-22 01:33:28 | [diff] [blame] | 1013 | if (host_impl->active_tree()->source_frame_number() == 2) { |
| 1014 | // Lose the context after draw on the second commit. This will cause |
| 1015 | // a third commit to recover. |
Xu Xing | 1252efe | 2018-05-05 00:20:25 | [diff] [blame] | 1016 | gl_->set_times_bind_texture_succeeds(0); |
sohan | 5f34803 | 2017-07-22 01:33:28 | [diff] [blame] | 1017 | } |
[email protected] | 7ddfe7e8 | 2014-01-30 07:22:11 | [diff] [blame] | 1018 | return draw_result; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 1019 | } |
| 1020 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 1021 | void RequestNewLayerTreeFrameSink() override { |
[email protected] | e96e343 | 2013-12-19 18:56:07 | [diff] [blame] | 1022 | // This will get called twice: |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 1023 | // First when we create the initial LayerTreeFrameSink... |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 1024 | if (layer_tree_host()->SourceFrameNumber() > 0) { |
[email protected] | 0c7a561 | 2014-03-12 21:58:22 | [diff] [blame] | 1025 | // ... and then again after we forced the context to be lost. |
[email protected] | 5b9e9bc | 2013-10-05 05:08:32 | [diff] [blame] | 1026 | lost_context_ = true; |
[email protected] | 5b9e9bc | 2013-10-05 05:08:32 | [diff] [blame] | 1027 | } |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 1028 | LayerTreeHostContextTest::RequestNewLayerTreeFrameSink(); |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 1029 | } |
| 1030 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1031 | void DidCommitAndDrawFrame() override { |
khushalsagar | b69ba945 | 2017-01-27 22:20:07 | [diff] [blame] | 1032 | ASSERT_TRUE(layer_tree_host()->hud_layer()); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 1033 | // End the test once we know the 3nd frame drew. |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 1034 | if (layer_tree_host()->SourceFrameNumber() < 5) { |
khushalsagar | b69ba945 | 2017-01-27 22:20:07 | [diff] [blame] | 1035 | layer_tree_host()->root_layer()->SetNeedsDisplay(); |
[email protected] | 5b9e9bc | 2013-10-05 05:08:32 | [diff] [blame] | 1036 | layer_tree_host()->SetNeedsCommit(); |
| 1037 | } else { |
[email protected] | 796e18f | 2013-09-26 18:38:34 | [diff] [blame] | 1038 | EndTest(); |
[email protected] | 5b9e9bc | 2013-10-05 05:08:32 | [diff] [blame] | 1039 | } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 1040 | } |
| 1041 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1042 | void AfterTest() override { EXPECT_TRUE(lost_context_); } |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 1043 | |
| 1044 | private: |
| 1045 | FakeContentLayerClient client_; |
[email protected] | 5b9e9bc | 2013-10-05 05:08:32 | [diff] [blame] | 1046 | bool lost_context_; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 1047 | |
kylechar | dfe762f | 2018-02-26 17:00:01 | [diff] [blame] | 1048 | scoped_refptr<viz::TestContextProvider> child_context_provider_; |
Fady Samuel | 4b5f986 | 2017-07-11 05:27:20 | [diff] [blame] | 1049 | std::unique_ptr<viz::SharedBitmapManager> shared_bitmap_manager_; |
danakj | 57baa77 | 2018-05-29 15:59:14 | [diff] [blame] | 1050 | std::unique_ptr<viz::ClientResourceProvider> child_resource_provider_; |
[email protected] | 50008cd | 2013-10-20 08:20:27 | [diff] [blame] | 1051 | |
[email protected] | 568285b | 2013-01-07 23:19:19 | [diff] [blame] | 1052 | scoped_refptr<VideoFrame> color_video_frame_; |
| 1053 | scoped_refptr<VideoFrame> hw_video_frame_; |
| 1054 | scoped_refptr<VideoFrame> scaled_hw_video_frame_; |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 1055 | |
| 1056 | FakeVideoFrameProvider color_frame_provider_; |
| 1057 | FakeVideoFrameProvider hw_frame_provider_; |
| 1058 | FakeVideoFrameProvider scaled_hw_frame_provider_; |
| 1059 | }; |
| 1060 | |
[email protected] | 75ea789f | 2013-03-27 18:06:10 | [diff] [blame] | 1061 | SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources); |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 1062 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1063 | class LayerTreeHostContextTestImplSidePainting |
danakj | eed856b6 | 2015-06-10 21:31:03 | [diff] [blame] | 1064 | : public LayerTreeHostContextTest { |
[email protected] | 45c4b1e | 2013-01-16 02:19:40 | [diff] [blame] | 1065 | public: |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1066 | void SetupTree() override { |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 1067 | scoped_refptr<Layer> root = Layer::Create(); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 1068 | root->SetBounds(gfx::Size(10, 10)); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 1069 | root->SetIsDrawable(true); |
[email protected] | 45c4b1e | 2013-01-16 02:19:40 | [diff] [blame] | 1070 | |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 1071 | scoped_refptr<PictureLayer> picture = PictureLayer::Create(&client_); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 1072 | picture->SetBounds(gfx::Size(10, 10)); |
chrishtr | 01539b80 | 2015-11-24 08:11:32 | [diff] [blame] | 1073 | client_.set_bounds(picture->bounds()); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 1074 | picture->SetIsDrawable(true); |
| 1075 | root->AddChild(picture); |
[email protected] | 45c4b1e | 2013-01-16 02:19:40 | [diff] [blame] | 1076 | |
khushalsagar | b69ba945 | 2017-01-27 22:20:07 | [diff] [blame] | 1077 | layer_tree_host()->SetRootLayer(root); |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 1078 | LayerTreeHostContextTest::SetupTree(); |
[email protected] | 45c4b1e | 2013-01-16 02:19:40 | [diff] [blame] | 1079 | } |
| 1080 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1081 | void BeginTest() override { |
[email protected] | 45c4b1e | 2013-01-16 02:19:40 | [diff] [blame] | 1082 | times_to_lose_during_commit_ = 1; |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 1083 | PostSetNeedsCommitToMainThread(); |
[email protected] | 45c4b1e | 2013-01-16 02:19:40 | [diff] [blame] | 1084 | } |
| 1085 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 1086 | void DidInitializeLayerTreeFrameSink() override { EndTest(); } |
[email protected] | 45c4b1e | 2013-01-16 02:19:40 | [diff] [blame] | 1087 | |
| 1088 | private: |
| 1089 | FakeContentLayerClient client_; |
| 1090 | }; |
| 1091 | |
Dana Jansens | ab27776 | 2015-06-12 23:52:55 | [diff] [blame] | 1092 | SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestImplSidePainting); |
[email protected] | 45c4b1e | 2013-01-16 02:19:40 | [diff] [blame] | 1093 | |
[email protected] | 7a6acd0 | 2013-01-19 04:16:13 | [diff] [blame] | 1094 | class ScrollbarLayerLostContext : public LayerTreeHostContextTest { |
| 1095 | public: |
| 1096 | ScrollbarLayerLostContext() : commits_(0) {} |
| 1097 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1098 | void BeginTest() override { |
loyso | 0940d41 | 2016-03-14 01:30:31 | [diff] [blame] | 1099 | scoped_refptr<Layer> scroll_layer = Layer::Create(); |
pdr | faf2ee22 | 2017-04-19 03:11:04 | [diff] [blame] | 1100 | scrollbar_layer_ = FakePaintedScrollbarLayer::Create( |
pdr | 75a6cc5 | 2017-04-20 19:21:14 | [diff] [blame] | 1101 | false, true, scroll_layer->element_id()); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 1102 | scrollbar_layer_->SetBounds(gfx::Size(10, 100)); |
khushalsagar | b69ba945 | 2017-01-27 22:20:07 | [diff] [blame] | 1103 | layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); |
| 1104 | layer_tree_host()->root_layer()->AddChild(scroll_layer); |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 1105 | PostSetNeedsCommitToMainThread(); |
[email protected] | 7a6acd0 | 2013-01-19 04:16:13 | [diff] [blame] | 1106 | } |
| 1107 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1108 | void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 1109 | LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 1110 | |
[email protected] | 7a6acd0 | 2013-01-19 04:16:13 | [diff] [blame] | 1111 | ++commits_; |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1112 | switch (commits_) { |
[email protected] | 7a6acd0 | 2013-01-19 04:16:13 | [diff] [blame] | 1113 | case 1: |
| 1114 | // First (regular) update, we should upload 2 resources (thumb, and |
| 1115 | // backtrack). |
| 1116 | EXPECT_EQ(1, scrollbar_layer_->update_count()); |
[email protected] | 7a6acd0 | 2013-01-19 04:16:13 | [diff] [blame] | 1117 | LoseContext(); |
| 1118 | break; |
| 1119 | case 2: |
| 1120 | // Second update, after the lost context, we should still upload 2 |
| 1121 | // resources even if the contents haven't changed. |
| 1122 | EXPECT_EQ(2, scrollbar_layer_->update_count()); |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 1123 | EndTest(); |
[email protected] | 7a6acd0 | 2013-01-19 04:16:13 | [diff] [blame] | 1124 | break; |
| 1125 | default: |
| 1126 | NOTREACHED(); |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | private: |
| 1131 | int commits_; |
[email protected] | 3a83478b | 2013-08-22 20:55:17 | [diff] [blame] | 1132 | scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer_; |
[email protected] | 7a6acd0 | 2013-01-19 04:16:13 | [diff] [blame] | 1133 | }; |
| 1134 | |
[email protected] | 75ea789f | 2013-03-27 18:06:10 | [diff] [blame] | 1135 | SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext); |
[email protected] | 7a6acd0 | 2013-01-19 04:16:13 | [diff] [blame] | 1136 | |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1137 | class UIResourceLostTest : public LayerTreeHostContextTest { |
| 1138 | public: |
| 1139 | UIResourceLostTest() : time_step_(0) {} |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1140 | void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1141 | |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1142 | // This is called on the main thread after each commit and |
| 1143 | // DidActivateTreeOnThread, with the value of time_step_ at the time |
| 1144 | // of the call to DidActivateTreeOnThread. Similar tests will do |
| 1145 | // work on the main thread in DidCommit but that is unsuitable because |
| 1146 | // the main thread work for these tests must happen after |
| 1147 | // DidActivateTreeOnThread, which happens after DidCommit with impl-side |
| 1148 | // painting. |
| 1149 | virtual void StepCompleteOnMainThread(int time_step) = 0; |
| 1150 | |
| 1151 | // Called after DidActivateTreeOnThread. If this is done during the commit, |
| 1152 | // the call to StepCompleteOnMainThread will not occur until after |
| 1153 | // the commit completes, because the main thread is blocked. |
| 1154 | void PostStepCompleteToMainThread() { |
khushalsagar | b7db1fe | 2015-11-12 00:51:27 | [diff] [blame] | 1155 | task_runner_provider()->MainThreadTaskRunner()->PostTask( |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1156 | FROM_HERE, |
tzik | 4604bb5 | 2017-04-13 21:50:22 | [diff] [blame] | 1157 | base::BindOnce(&UIResourceLostTest::StepCompleteOnMainThreadInternal, |
| 1158 | base::Unretained(this), time_step_)); |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1159 | } |
| 1160 | |
| 1161 | void PostLoseContextToImplThread() { |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 1162 | EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread()); |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 1163 | ImplThreadTaskRunner()->PostTask( |
tzik | 4604bb5 | 2017-04-13 21:50:22 | [diff] [blame] | 1164 | FROM_HERE, base::BindOnce(&LayerTreeHostContextTest::LoseContext, |
| 1165 | base::Unretained(this))); |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1166 | } |
| 1167 | |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1168 | protected: |
| 1169 | int time_step_; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 1170 | std::unique_ptr<FakeScopedUIResource> ui_resource_; |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1171 | |
| 1172 | private: |
| 1173 | void StepCompleteOnMainThreadInternal(int step) { |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 1174 | EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread()); |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1175 | StepCompleteOnMainThread(step); |
| 1176 | } |
| 1177 | }; |
| 1178 | |
| 1179 | class UIResourceLostTestSimple : public UIResourceLostTest { |
| 1180 | public: |
danakj | 431a120 | 2015-06-17 19:09:33 | [diff] [blame] | 1181 | // This is called when the new layer tree has been activated. |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1182 | virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) = 0; |
| 1183 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1184 | void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
danakj | 431a120 | 2015-06-17 19:09:33 | [diff] [blame] | 1185 | StepCompleteOnImplThread(impl); |
| 1186 | PostStepCompleteToMainThread(); |
| 1187 | ++time_step_; |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1188 | } |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1189 | }; |
| 1190 | |
| 1191 | // Losing context after an UI resource has been created. |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1192 | class UIResourceLostAfterCommit : public UIResourceLostTestSimple { |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1193 | public: |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1194 | void StepCompleteOnMainThread(int step) override { |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 1195 | EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread()); |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1196 | switch (step) { |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1197 | case 0: |
khushalsagar | 8ec0740 | 2016-09-10 03:13:19 | [diff] [blame] | 1198 | ui_resource_ = FakeScopedUIResource::Create( |
| 1199 | layer_tree_host()->GetUIResourceManager()); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1200 | // Expects a valid UIResourceId. |
| 1201 | EXPECT_NE(0, ui_resource_->id()); |
| 1202 | PostSetNeedsCommitToMainThread(); |
| 1203 | break; |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1204 | case 4: |
| 1205 | // Release resource before ending the test. |
danakj | f446a07 | 2014-09-27 21:55:48 | [diff] [blame] | 1206 | ui_resource_ = nullptr; |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1207 | EndTest(); |
| 1208 | break; |
| 1209 | case 5: |
[email protected] | 2decdd78 | 2014-08-13 22:36:06 | [diff] [blame] | 1210 | NOTREACHED(); |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 1211 | break; |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1212 | } |
| 1213 | } |
| 1214 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1215 | void StepCompleteOnImplThread(LayerTreeHostImpl* impl) override { |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1216 | LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1217 | switch (time_step_) { |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1218 | case 1: |
| 1219 | // The resource should have been created on LTHI after the commit. |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1220 | EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1221 | PostSetNeedsCommitToMainThread(); |
| 1222 | break; |
| 1223 | case 2: |
| 1224 | LoseContext(); |
| 1225 | break; |
| 1226 | case 3: |
| 1227 | // The resources should have been recreated. The bitmap callback should |
| 1228 | // have been called once with the resource_lost flag set to true. |
| 1229 | EXPECT_EQ(1, ui_resource_->lost_resource_count); |
| 1230 | // Resource Id on the impl-side have been recreated as well. Note |
| 1231 | // that the same UIResourceId persists after the context lost. |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1232 | EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1233 | PostSetNeedsCommitToMainThread(); |
| 1234 | break; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1235 | } |
| 1236 | } |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1237 | }; |
| 1238 | |
| 1239 | SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostAfterCommit); |
| 1240 | |
| 1241 | // Losing context before UI resource requests can be commited. Three sequences |
| 1242 | // of creation/deletion are considered: |
| 1243 | // 1. Create one resource -> Context Lost => Expect the resource to have been |
| 1244 | // created. |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1245 | // 2. Delete an existing resource (test_id0_) -> create a second resource |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1246 | // (test_id1_) -> Context Lost => Expect the test_id0_ to be removed and |
| 1247 | // test_id1_ to have been created. |
| 1248 | // 3. Create one resource -> Delete that same resource -> Context Lost => Expect |
| 1249 | // the resource to not exist in the manager. |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1250 | class UIResourceLostBeforeCommit : public UIResourceLostTestSimple { |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1251 | public: |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 1252 | UIResourceLostBeforeCommit() : test_id0_(0), test_id1_(0) {} |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1253 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1254 | void StepCompleteOnMainThread(int step) override { |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1255 | switch (step) { |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1256 | case 0: |
khushalsagar | 8ec0740 | 2016-09-10 03:13:19 | [diff] [blame] | 1257 | ui_resource_ = FakeScopedUIResource::Create( |
| 1258 | layer_tree_host()->GetUIResourceManager()); |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1259 | // Lose the context on the impl thread before the commit. |
| 1260 | PostLoseContextToImplThread(); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1261 | break; |
| 1262 | case 2: |
| 1263 | // Sequence 2: |
| 1264 | // Currently one resource has been created. |
| 1265 | test_id0_ = ui_resource_->id(); |
| 1266 | // Delete this resource. |
danakj | f446a07 | 2014-09-27 21:55:48 | [diff] [blame] | 1267 | ui_resource_ = nullptr; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1268 | // Create another resource. |
khushalsagar | 8ec0740 | 2016-09-10 03:13:19 | [diff] [blame] | 1269 | ui_resource_ = FakeScopedUIResource::Create( |
| 1270 | layer_tree_host()->GetUIResourceManager()); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1271 | test_id1_ = ui_resource_->id(); |
| 1272 | // Sanity check that two resource creations return different ids. |
| 1273 | EXPECT_NE(test_id0_, test_id1_); |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1274 | // Lose the context on the impl thread before the commit. |
| 1275 | PostLoseContextToImplThread(); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1276 | break; |
| 1277 | case 3: |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1278 | // Clear the manager of resources. |
danakj | f446a07 | 2014-09-27 21:55:48 | [diff] [blame] | 1279 | ui_resource_ = nullptr; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1280 | PostSetNeedsCommitToMainThread(); |
| 1281 | break; |
| 1282 | case 4: |
| 1283 | // Sequence 3: |
khushalsagar | 8ec0740 | 2016-09-10 03:13:19 | [diff] [blame] | 1284 | ui_resource_ = FakeScopedUIResource::Create( |
| 1285 | layer_tree_host()->GetUIResourceManager()); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1286 | test_id0_ = ui_resource_->id(); |
| 1287 | // Sanity check the UIResourceId should not be 0. |
| 1288 | EXPECT_NE(0, test_id0_); |
| 1289 | // Usually ScopedUIResource are deleted from the manager in their |
danakj | f446a07 | 2014-09-27 21:55:48 | [diff] [blame] | 1290 | // destructor (so usually ui_resource_ = nullptr). But here we need |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1291 | // ui_resource_ for the next step, so call DeleteUIResource directly. |
khushalsagar | 8ec0740 | 2016-09-10 03:13:19 | [diff] [blame] | 1292 | layer_tree_host()->GetUIResourceManager()->DeleteUIResource(test_id0_); |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1293 | // Delete the resouce and then lose the context. |
| 1294 | PostLoseContextToImplThread(); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1295 | break; |
| 1296 | case 5: |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1297 | // Release resource before ending the test. |
danakj | f446a07 | 2014-09-27 21:55:48 | [diff] [blame] | 1298 | ui_resource_ = nullptr; |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1299 | EndTest(); |
| 1300 | break; |
| 1301 | case 6: |
[email protected] | 2decdd78 | 2014-08-13 22:36:06 | [diff] [blame] | 1302 | NOTREACHED(); |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 1303 | break; |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1304 | } |
| 1305 | } |
| 1306 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1307 | void StepCompleteOnImplThread(LayerTreeHostImpl* impl) override { |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1308 | LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1309 | switch (time_step_) { |
| 1310 | case 1: |
| 1311 | // Sequence 1 (continued): |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1312 | // The first context lost happens before the resources were created, |
| 1313 | // and because it resulted in no resources being destroyed, it does not |
| 1314 | // trigger resource re-creation. |
| 1315 | EXPECT_EQ(1, ui_resource_->resource_create_count); |
| 1316 | EXPECT_EQ(0, ui_resource_->lost_resource_count); |
| 1317 | // Resource Id on the impl-side has been created. |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1318 | PostSetNeedsCommitToMainThread(); |
| 1319 | break; |
| 1320 | case 3: |
| 1321 | // Sequence 2 (continued): |
| 1322 | // The previous resource should have been deleted. |
| 1323 | EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id0_)); |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 1324 | // The second resource should have been created. |
| 1325 | EXPECT_NE(0u, impl->ResourceIdForUIResource(test_id1_)); |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1326 | // The second resource was not actually uploaded before the context |
| 1327 | // was lost, so it only got created once. |
| 1328 | EXPECT_EQ(1, ui_resource_->resource_create_count); |
| 1329 | EXPECT_EQ(0, ui_resource_->lost_resource_count); |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1330 | break; |
| 1331 | case 5: |
| 1332 | // Sequence 3 (continued): |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1333 | // Expect the resource callback to have been called once. |
| 1334 | EXPECT_EQ(1, ui_resource_->resource_create_count); |
| 1335 | // No "resource lost" callbacks. |
| 1336 | EXPECT_EQ(0, ui_resource_->lost_resource_count); |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1337 | // The UI resource id should not be valid |
| 1338 | EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id0_)); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1339 | break; |
| 1340 | } |
| 1341 | } |
| 1342 | |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1343 | private: |
| 1344 | UIResourceId test_id0_; |
| 1345 | UIResourceId test_id1_; |
| 1346 | }; |
| 1347 | |
Sahel Sharify | d985764 | 2018-04-30 15:06:40 | [diff] [blame] | 1348 | // http://crbug.com/803532 : Flaky on Win 7 (dbg) and linux tsan |
| 1349 | #if (defined(NDEBUG) || !defined(OS_WIN)) && \ |
| 1350 | (!defined(THREAD_SANITIZER) || !defined(OS_LINUX)) |
Stephen McGruer | 25ddb137 | 2018-01-18 19:10:15 | [diff] [blame] | 1351 | SINGLE_THREAD_TEST_F(UIResourceLostBeforeCommit); |
| 1352 | #endif |
| 1353 | MULTI_THREAD_TEST_F(UIResourceLostBeforeCommit); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1354 | |
| 1355 | // Losing UI resource before the pending trees is activated but after the |
| 1356 | // commit. Impl-side-painting only. |
| 1357 | class UIResourceLostBeforeActivateTree : public UIResourceLostTest { |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1358 | void StepCompleteOnMainThread(int step) override { |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 1359 | EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread()); |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1360 | switch (step) { |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1361 | case 0: |
khushalsagar | 8ec0740 | 2016-09-10 03:13:19 | [diff] [blame] | 1362 | ui_resource_ = FakeScopedUIResource::Create( |
| 1363 | layer_tree_host()->GetUIResourceManager()); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1364 | PostSetNeedsCommitToMainThread(); |
| 1365 | break; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1366 | case 3: |
| 1367 | test_id_ = ui_resource_->id(); |
danakj | f446a07 | 2014-09-27 21:55:48 | [diff] [blame] | 1368 | ui_resource_ = nullptr; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1369 | PostSetNeedsCommitToMainThread(); |
| 1370 | break; |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1371 | case 5: |
| 1372 | // Release resource before ending the test. |
danakj | f446a07 | 2014-09-27 21:55:48 | [diff] [blame] | 1373 | ui_resource_ = nullptr; |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1374 | EndTest(); |
| 1375 | break; |
| 1376 | case 6: |
| 1377 | // Make sure no extra commits happened. |
| 1378 | NOTREACHED(); |
| 1379 | } |
| 1380 | } |
| 1381 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1382 | void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1383 | LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1384 | switch (time_step_) { |
| 1385 | case 2: |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1386 | PostSetNeedsCommitToMainThread(); |
| 1387 | break; |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1388 | case 4: |
| 1389 | PostSetNeedsCommitToMainThread(); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1390 | break; |
| 1391 | } |
| 1392 | } |
| 1393 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1394 | void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1395 | switch (time_step_) { |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1396 | case 1: |
| 1397 | // The resource creation callback has been called. |
| 1398 | EXPECT_EQ(1, ui_resource_->resource_create_count); |
| 1399 | // The resource is not yet lost (sanity check). |
| 1400 | EXPECT_EQ(0, ui_resource_->lost_resource_count); |
| 1401 | // The resource should not have been created yet on the impl-side. |
| 1402 | EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1403 | LoseContext(); |
| 1404 | break; |
| 1405 | case 3: |
| 1406 | LoseContext(); |
| 1407 | break; |
| 1408 | } |
| 1409 | } |
| 1410 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1411 | void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1412 | LayerTreeHostContextTest::DidActivateTreeOnThread(impl); |
| 1413 | switch (time_step_) { |
| 1414 | case 1: |
sievers | 68dc75d | 2016-09-23 22:31:31 | [diff] [blame] | 1415 | // The pending requests on the impl-side should not have been processed |
| 1416 | // since the context was lost. But we should have marked the resource as |
| 1417 | // evicted instead. |
| 1418 | EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1419 | EXPECT_TRUE(impl->EvictedUIResourcesExist()); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1420 | break; |
| 1421 | case 2: |
sievers | 68dc75d | 2016-09-23 22:31:31 | [diff] [blame] | 1422 | // The "lost resource" callback should have been called once and it |
| 1423 | // should have gotten recreated now and shouldn't be marked as evicted |
| 1424 | // anymore. |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1425 | EXPECT_EQ(1, ui_resource_->lost_resource_count); |
sievers | 68dc75d | 2016-09-23 22:31:31 | [diff] [blame] | 1426 | EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1427 | EXPECT_FALSE(impl->EvictedUIResourcesExist()); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1428 | break; |
| 1429 | case 4: |
| 1430 | // The resource is deleted and should not be in the manager. Use |
| 1431 | // test_id_ since ui_resource_ has been deleted. |
| 1432 | EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id_)); |
| 1433 | break; |
| 1434 | } |
[email protected] | e11fceee | 2013-09-09 23:49:49 | [diff] [blame] | 1435 | |
| 1436 | PostStepCompleteToMainThread(); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1437 | ++time_step_; |
| 1438 | } |
| 1439 | |
| 1440 | private: |
| 1441 | UIResourceId test_id_; |
| 1442 | }; |
| 1443 | |
Dana Jansens | ab27776 | 2015-06-12 23:52:55 | [diff] [blame] | 1444 | SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostBeforeActivateTree); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1445 | |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1446 | // Resources evicted explicitly and by visibility changes. |
| 1447 | class UIResourceLostEviction : public UIResourceLostTestSimple { |
| 1448 | public: |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1449 | void StepCompleteOnMainThread(int step) override { |
khushalsagar | cebe494 | 2016-09-07 23:27:01 | [diff] [blame] | 1450 | EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread()); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1451 | switch (step) { |
| 1452 | case 0: |
khushalsagar | 8ec0740 | 2016-09-10 03:13:19 | [diff] [blame] | 1453 | ui_resource_ = FakeScopedUIResource::Create( |
| 1454 | layer_tree_host()->GetUIResourceManager()); |
| 1455 | ui_resource2_ = FakeScopedUIResource::Create( |
| 1456 | layer_tree_host()->GetUIResourceManager()); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1457 | EXPECT_NE(0, ui_resource_->id()); |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1458 | EXPECT_NE(0, ui_resource2_->id()); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1459 | PostSetNeedsCommitToMainThread(); |
| 1460 | break; |
| 1461 | case 2: |
| 1462 | // Make the tree not visible. |
| 1463 | PostSetVisibleToMainThread(false); |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1464 | ui_resource2_->DeleteResource(); |
khushalsagar | 8ec0740 | 2016-09-10 03:13:19 | [diff] [blame] | 1465 | ui_resource3_ = FakeScopedUIResource::Create( |
| 1466 | layer_tree_host()->GetUIResourceManager()); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1467 | break; |
| 1468 | case 3: |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1469 | // Release resources before ending the test. |
danakj | f446a07 | 2014-09-27 21:55:48 | [diff] [blame] | 1470 | ui_resource_ = nullptr; |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1471 | ui_resource2_ = nullptr; |
| 1472 | ui_resource3_ = nullptr; |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1473 | EndTest(); |
| 1474 | break; |
| 1475 | case 4: |
| 1476 | NOTREACHED(); |
| 1477 | } |
| 1478 | } |
| 1479 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1480 | void DidSetVisibleOnImplTree(LayerTreeHostImpl* impl, bool visible) override { |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1481 | if (!visible) { |
| 1482 | // All resources should have been evicted. |
Eric Karl | 8d678f89 | 2018-12-11 06:51:00 | [diff] [blame] | 1483 | ASSERT_EQ(0u, sii_->shared_image_count()); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1484 | EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1485 | EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource2_->id())); |
| 1486 | EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource3_->id())); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1487 | EXPECT_EQ(2, ui_resource_->resource_create_count); |
| 1488 | EXPECT_EQ(1, ui_resource_->lost_resource_count); |
| 1489 | // Drawing is disabled both because of the evicted resources and |
| 1490 | // because the renderer is not visible. |
| 1491 | EXPECT_FALSE(impl->CanDraw()); |
| 1492 | // Make the renderer visible again. |
| 1493 | PostSetVisibleToMainThread(true); |
| 1494 | } |
| 1495 | } |
| 1496 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1497 | void StepCompleteOnImplThread(LayerTreeHostImpl* impl) override { |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1498 | LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1499 | switch (time_step_) { |
| 1500 | case 1: |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1501 | // The first two resources should have been created on LTHI after the |
| 1502 | // commit. |
Eric Karl | 8d678f89 | 2018-12-11 06:51:00 | [diff] [blame] | 1503 | ASSERT_EQ(2u, sii_->shared_image_count()); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1504 | EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1505 | EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource2_->id())); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1506 | EXPECT_EQ(1, ui_resource_->resource_create_count); |
| 1507 | EXPECT_EQ(0, ui_resource_->lost_resource_count); |
| 1508 | EXPECT_TRUE(impl->CanDraw()); |
| 1509 | // Evict all UI resources. This will trigger a commit. |
| 1510 | impl->EvictAllUIResources(); |
Eric Karl | 8d678f89 | 2018-12-11 06:51:00 | [diff] [blame] | 1511 | ASSERT_EQ(0u, sii_->shared_image_count()); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1512 | EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1513 | EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource2_->id())); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1514 | EXPECT_EQ(1, ui_resource_->resource_create_count); |
| 1515 | EXPECT_EQ(0, ui_resource_->lost_resource_count); |
| 1516 | EXPECT_FALSE(impl->CanDraw()); |
| 1517 | break; |
| 1518 | case 2: |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1519 | // The first two resources should have been recreated. |
Eric Karl | 8d678f89 | 2018-12-11 06:51:00 | [diff] [blame] | 1520 | ASSERT_EQ(2u, sii_->shared_image_count()); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1521 | EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1522 | EXPECT_EQ(2, ui_resource_->resource_create_count); |
| 1523 | EXPECT_EQ(1, ui_resource_->lost_resource_count); |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1524 | EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource2_->id())); |
| 1525 | EXPECT_EQ(2, ui_resource2_->resource_create_count); |
| 1526 | EXPECT_EQ(1, ui_resource2_->lost_resource_count); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1527 | EXPECT_TRUE(impl->CanDraw()); |
| 1528 | break; |
| 1529 | case 3: |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1530 | // The first resource should have been recreated after visibility was |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1531 | // restored. |
Eric Karl | 8d678f89 | 2018-12-11 06:51:00 | [diff] [blame] | 1532 | ASSERT_EQ(2u, sii_->shared_image_count()); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1533 | EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1534 | EXPECT_EQ(3, ui_resource_->resource_create_count); |
| 1535 | EXPECT_EQ(2, ui_resource_->lost_resource_count); |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1536 | |
| 1537 | // This resource was deleted. |
| 1538 | EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource2_->id())); |
| 1539 | EXPECT_EQ(2, ui_resource2_->resource_create_count); |
| 1540 | EXPECT_EQ(1, ui_resource2_->lost_resource_count); |
| 1541 | |
| 1542 | // This resource should have been created now. |
| 1543 | EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource3_->id())); |
| 1544 | EXPECT_EQ(1, ui_resource3_->resource_create_count); |
| 1545 | EXPECT_EQ(0, ui_resource3_->lost_resource_count); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1546 | EXPECT_TRUE(impl->CanDraw()); |
| 1547 | break; |
| 1548 | } |
| 1549 | } |
sievers | 8afa2d4 | 2016-08-26 19:45:15 | [diff] [blame] | 1550 | |
| 1551 | private: |
| 1552 | std::unique_ptr<FakeScopedUIResource> ui_resource2_; |
| 1553 | std::unique_ptr<FakeScopedUIResource> ui_resource3_; |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1554 | }; |
| 1555 | |
| 1556 | SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); |
| 1557 | |
danakj | b90335d | 2018-06-07 23:42:29 | [diff] [blame] | 1558 | class UIResourceFreedIfLostWhileExported : public LayerTreeHostContextTest { |
| 1559 | protected: |
| 1560 | void BeginTest() override { |
| 1561 | // Make 1 UIResource, post it to the compositor thread, where it will be |
| 1562 | // uploaded. |
| 1563 | ui_resource_ = |
| 1564 | FakeScopedUIResource::Create(layer_tree_host()->GetUIResourceManager()); |
| 1565 | EXPECT_NE(0, ui_resource_->id()); |
| 1566 | PostSetNeedsCommitToMainThread(); |
| 1567 | } |
| 1568 | |
| 1569 | void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 1570 | switch (impl->active_tree()->source_frame_number()) { |
| 1571 | case 0: |
| 1572 | // The UIResource has been created and a gpu resource made for it. |
| 1573 | EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
Eric Karl | 8d678f89 | 2018-12-11 06:51:00 | [diff] [blame] | 1574 | EXPECT_EQ(1u, sii_->shared_image_count()); |
danakj | b90335d | 2018-06-07 23:42:29 | [diff] [blame] | 1575 | // Lose the LayerTreeFrameSink connection. The UI resource should |
| 1576 | // be replaced and the old texture should be destroyed. |
| 1577 | impl->DidLoseLayerTreeFrameSink(); |
| 1578 | break; |
| 1579 | case 1: |
| 1580 | // The UIResource has been recreated, the old texture is not kept |
| 1581 | // around. |
| 1582 | EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
Eric Karl | 8d678f89 | 2018-12-11 06:51:00 | [diff] [blame] | 1583 | EXPECT_EQ(1u, sii_->shared_image_count()); |
danakj | b90335d | 2018-06-07 23:42:29 | [diff] [blame] | 1584 | MainThreadTaskRunner()->PostTask( |
| 1585 | FROM_HERE, |
| 1586 | base::BindOnce( |
| 1587 | &UIResourceFreedIfLostWhileExported::DeleteAndEndTest, |
| 1588 | base::Unretained(this))); |
| 1589 | } |
| 1590 | } |
| 1591 | |
| 1592 | void DeleteAndEndTest() { |
| 1593 | ui_resource_->DeleteResource(); |
| 1594 | EndTest(); |
| 1595 | } |
| 1596 | |
danakj | b90335d | 2018-06-07 23:42:29 | [diff] [blame] | 1597 | std::unique_ptr<FakeScopedUIResource> ui_resource_; |
| 1598 | }; |
| 1599 | |
| 1600 | SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceFreedIfLostWhileExported); |
| 1601 | |
| 1602 | class TileResourceFreedIfLostWhileExported : public LayerTreeHostContextTest { |
| 1603 | protected: |
| 1604 | void SetupTree() override { |
| 1605 | PaintFlags flags; |
| 1606 | client_.set_fill_with_nonsolid_color(true); |
| 1607 | |
| 1608 | scoped_refptr<FakePictureLayer> picture_layer = |
| 1609 | FakePictureLayer::Create(&client_); |
| 1610 | picture_layer->SetBounds(gfx::Size(10, 20)); |
| 1611 | client_.set_bounds(picture_layer->bounds()); |
| 1612 | layer_tree_host()->SetRootLayer(std::move(picture_layer)); |
| 1613 | |
| 1614 | LayerTreeTest::SetupTree(); |
| 1615 | } |
| 1616 | |
| 1617 | void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1618 | |
| 1619 | void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
Antoine Labour | 7a950ebc | 2018-11-08 21:59:49 | [diff] [blame] | 1620 | auto* context_provider = static_cast<viz::TestContextProvider*>( |
| 1621 | impl->layer_tree_frame_sink()->worker_context_provider()); |
| 1622 | viz::TestSharedImageInterface* sii = |
| 1623 | context_provider->SharedImageInterface(); |
danakj | b90335d | 2018-06-07 23:42:29 | [diff] [blame] | 1624 | switch (impl->active_tree()->source_frame_number()) { |
| 1625 | case 0: |
| 1626 | // The PicturLayer has a texture for a tile, that has been exported to |
| 1627 | // the display compositor now. |
| 1628 | EXPECT_EQ(1u, impl->resource_provider()->num_resources_for_testing()); |
| 1629 | EXPECT_EQ(1u, impl->resource_pool()->resource_count()); |
Antoine Labour | 7a950ebc | 2018-11-08 21:59:49 | [diff] [blame] | 1630 | // Shows that the tile texture is allocated with the current worker |
| 1631 | // context. |
| 1632 | num_textures_ = sii->shared_image_count(); |
danakj | b90335d | 2018-06-07 23:42:29 | [diff] [blame] | 1633 | EXPECT_GT(num_textures_, 0u); |
| 1634 | |
| 1635 | // Lose the LayerTreeFrameSink connection. The tile resource should |
| 1636 | // be replaced and the old texture should be destroyed. |
| 1637 | LoseContext(); |
| 1638 | break; |
| 1639 | case 1: |
| 1640 | // The tile has been recreated, the old texture is not kept around in |
| 1641 | // the pool indefinitely. It can be dropped as soon as the context is |
| 1642 | // known to be lost. |
| 1643 | EXPECT_EQ(1u, impl->resource_provider()->num_resources_for_testing()); |
| 1644 | EXPECT_EQ(1u, impl->resource_pool()->resource_count()); |
| 1645 | // Shows that the replacement tile texture is re-allocated with the |
Antoine Labour | 7a950ebc | 2018-11-08 21:59:49 | [diff] [blame] | 1646 | // current worker context, not just the previous one. |
| 1647 | EXPECT_EQ(num_textures_, sii->shared_image_count()); |
danakj | b90335d | 2018-06-07 23:42:29 | [diff] [blame] | 1648 | EndTest(); |
| 1649 | } |
| 1650 | } |
| 1651 | |
danakj | b90335d | 2018-06-07 23:42:29 | [diff] [blame] | 1652 | FakeContentLayerClient client_; |
| 1653 | size_t num_textures_ = 0; |
| 1654 | }; |
| 1655 | |
| 1656 | SINGLE_AND_MULTI_THREAD_TEST_F(TileResourceFreedIfLostWhileExported); |
| 1657 | |
| 1658 | class SoftwareTileResourceFreedIfLostWhileExported : public LayerTreeTest { |
| 1659 | protected: |
Antoine Labour | 7f5179a | 2019-06-04 01:46:29 | [diff] [blame] | 1660 | std::unique_ptr<TestLayerTreeFrameSink> CreateLayerTreeFrameSink( |
danakj | b90335d | 2018-06-07 23:42:29 | [diff] [blame] | 1661 | const viz::RendererSettings& renderer_settings, |
| 1662 | double refresh_rate, |
| 1663 | scoped_refptr<viz::ContextProvider> compositor_context_provider, |
| 1664 | scoped_refptr<viz::RasterContextProvider> worker_context_provider) |
| 1665 | override { |
| 1666 | // Induce software compositing in cc. |
| 1667 | return LayerTreeTest::CreateLayerTreeFrameSink( |
| 1668 | renderer_settings, refresh_rate, nullptr, nullptr); |
| 1669 | } |
| 1670 | |
| 1671 | std::unique_ptr<viz::OutputSurface> CreateDisplayOutputSurfaceOnThread( |
| 1672 | scoped_refptr<viz::ContextProvider> compositor_context_provider) |
| 1673 | override { |
| 1674 | // Induce software compositing in the display compositor. |
| 1675 | return viz::FakeOutputSurface::CreateSoftware( |
| 1676 | std::make_unique<viz::SoftwareOutputDevice>()); |
| 1677 | } |
| 1678 | |
| 1679 | void SetupTree() override { |
| 1680 | PaintFlags flags; |
| 1681 | client_.set_fill_with_nonsolid_color(true); |
| 1682 | |
| 1683 | scoped_refptr<FakePictureLayer> picture_layer = |
| 1684 | FakePictureLayer::Create(&client_); |
| 1685 | picture_layer->SetBounds(gfx::Size(10, 20)); |
| 1686 | client_.set_bounds(picture_layer->bounds()); |
| 1687 | layer_tree_host()->SetRootLayer(std::move(picture_layer)); |
| 1688 | |
| 1689 | LayerTreeTest::SetupTree(); |
| 1690 | } |
| 1691 | |
| 1692 | void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1693 | |
| 1694 | void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 1695 | switch (impl->active_tree()->source_frame_number()) { |
| 1696 | case 0: { |
| 1697 | // The PicturLayer has a bitmap for a tile, that has been exported to |
| 1698 | // the display compositor now. |
| 1699 | EXPECT_EQ(1u, impl->resource_provider()->num_resources_for_testing()); |
| 1700 | EXPECT_EQ(1u, impl->resource_pool()->resource_count()); |
| 1701 | |
| 1702 | impl->DidLoseLayerTreeFrameSink(); |
| 1703 | break; |
| 1704 | } |
| 1705 | case 1: { |
| 1706 | // The tile did not need to be recreated, the same bitmap/resource |
| 1707 | // should be used for it. |
| 1708 | EXPECT_EQ(1u, impl->resource_provider()->num_resources_for_testing()); |
| 1709 | EXPECT_EQ(1u, impl->resource_pool()->resource_count()); |
| 1710 | |
| 1711 | // TODO(danakj): It'd be possible to not destroy and recreate the |
| 1712 | // software bitmap, however for simplicity we do the same for software |
| 1713 | // and for gpu paths. If we didn't destroy it we could see the same |
| 1714 | // bitmap on PictureLayerImpl's tile. |
| 1715 | |
| 1716 | EndTest(); |
| 1717 | } |
| 1718 | } |
| 1719 | } |
| 1720 | |
danakj | b90335d | 2018-06-07 23:42:29 | [diff] [blame] | 1721 | FakeContentLayerClient client_; |
| 1722 | viz::ResourceId exported_resource_id_ = 0; |
| 1723 | }; |
| 1724 | |
| 1725 | SINGLE_AND_MULTI_THREAD_TEST_F(SoftwareTileResourceFreedIfLostWhileExported); |
| 1726 | |
[email protected] | 92218694 | 2014-06-11 16:30:35 | [diff] [blame] | 1727 | class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame |
| 1728 | : public LayerTreeHostContextTest { |
| 1729 | protected: |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 1730 | void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
[email protected] | 92218694 | 2014-06-11 16:30:35 | [diff] [blame] | 1731 | |
danakj | 94b7e4f | 2016-07-20 01:49:38 | [diff] [blame] | 1732 | void WillBeginMainFrame() override { |
| 1733 | // Don't begin a frame with a lost surface. |
danakj | be9c59ee | 2016-08-26 18:24:56 | [diff] [blame] | 1734 | EXPECT_FALSE(lost_); |
danakj | 94b7e4f | 2016-07-20 01:49:38 | [diff] [blame] | 1735 | |
[email protected] | 92218694 | 2014-06-11 16:30:35 | [diff] [blame] | 1736 | if (deferred_) |
| 1737 | return; |
| 1738 | deferred_ = true; |
| 1739 | |
Stephen Chenney | 6d3f5ce | 2018-11-14 02:08:05 | [diff] [blame] | 1740 | // TODO(schenney): This should switch back to defer_commits_ because there |
| 1741 | // is no way in the real code to start deferring main frame updates when |
| 1742 | // inside WillBeginMainFrame. Defer commits before the BeginFrame completes, |
| 1743 | // causing it to be delayed. |
| 1744 | scoped_defer_main_frame_update_ = layer_tree_host()->DeferMainFrameUpdate(); |
| 1745 | // Meanwhile, lose the context while we are in defer BeginMainFrame. |
[email protected] | 92218694 | 2014-06-11 16:30:35 | [diff] [blame] | 1746 | ImplThreadTaskRunner()->PostTask( |
| 1747 | FROM_HERE, |
tzik | 4604bb5 | 2017-04-13 21:50:22 | [diff] [blame] | 1748 | base::BindOnce(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: |
| 1749 | LoseContextOnImplThread, |
| 1750 | base::Unretained(this))); |
danakj | be9c59ee | 2016-08-26 18:24:56 | [diff] [blame] | 1751 | |
| 1752 | // After the first frame, we will lose the context and then not start |
Stephen Chenney | 6d3f5ce | 2018-11-14 02:08:05 | [diff] [blame] | 1753 | // lifecycle updates and commits until that happens. The 2nd frame should |
| 1754 | // not happen before DidInitializeLayerTreeFrameSink occurs. |
danakj | be9c59ee | 2016-08-26 18:24:56 | [diff] [blame] | 1755 | lost_ = true; |
| 1756 | } |
| 1757 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 1758 | void DidInitializeLayerTreeFrameSink() override { |
danakj | be9c59ee | 2016-08-26 18:24:56 | [diff] [blame] | 1759 | EXPECT_TRUE(lost_); |
| 1760 | lost_ = false; |
[email protected] | 92218694 | 2014-06-11 16:30:35 | [diff] [blame] | 1761 | } |
| 1762 | |
| 1763 | void LoseContextOnImplThread() { |
| 1764 | LoseContext(); |
| 1765 | |
Stephen Chenney | 6d3f5ce | 2018-11-14 02:08:05 | [diff] [blame] | 1766 | // TODO(schenney): This should switch back to defer_commits_ to match the |
| 1767 | // change above. |
[email protected] | 92218694 | 2014-06-11 16:30:35 | [diff] [blame] | 1768 | // After losing the context, stop deferring commits. |
Stephen Chenney | 6d3f5ce | 2018-11-14 02:08:05 | [diff] [blame] | 1769 | PostReturnDeferMainFrameUpdateToMainThread( |
| 1770 | std::move(scoped_defer_main_frame_update_)); |
[email protected] | 92218694 | 2014-06-11 16:30:35 | [diff] [blame] | 1771 | } |
| 1772 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 1773 | void DidCommitAndDrawFrame() override { EndTest(); } |
[email protected] | 92218694 | 2014-06-11 16:30:35 | [diff] [blame] | 1774 | |
Stephen Chenney | 6d3f5ce | 2018-11-14 02:08:05 | [diff] [blame] | 1775 | std::unique_ptr<ScopedDeferMainFrameUpdate> scoped_defer_main_frame_update_; |
danakj | be9c59ee | 2016-08-26 18:24:56 | [diff] [blame] | 1776 | bool deferred_ = false; |
| 1777 | bool lost_ = true; |
[email protected] | 92218694 | 2014-06-11 16:30:35 | [diff] [blame] | 1778 | }; |
| 1779 | |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 1780 | SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1781 | LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
[email protected] | 92218694 | 2014-06-11 16:30:35 | [diff] [blame] | 1782 | |
Sunny Sachanandani | 158d26d | 2017-12-12 19:44:10 | [diff] [blame] | 1783 | class LayerTreeHostContextTestWorkerContextLostRecovery : public LayerTreeTest { |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 1784 | protected: |
| 1785 | void SetupTree() override { |
enne | bb7c4bcf | 2017-02-07 17:59:49 | [diff] [blame] | 1786 | PaintFlags flags; |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 1787 | client_.set_fill_with_nonsolid_color(true); |
enne | bb7c4bcf | 2017-02-07 17:59:49 | [diff] [blame] | 1788 | client_.add_draw_rect(gfx::Rect(5, 5), flags); |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 1789 | |
| 1790 | scoped_refptr<FakePictureLayer> picture_layer = |
| 1791 | FakePictureLayer::Create(&client_); |
| 1792 | picture_layer->SetBounds(gfx::Size(10, 20)); |
| 1793 | client_.set_bounds(picture_layer->bounds()); |
khushalsagar | b69ba945 | 2017-01-27 22:20:07 | [diff] [blame] | 1794 | layer_tree_host()->SetRootLayer(picture_layer); |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 1795 | |
| 1796 | LayerTreeTest::SetupTree(); |
| 1797 | } |
| 1798 | |
| 1799 | void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1800 | |
| 1801 | void WillPrepareTilesOnThread(LayerTreeHostImpl* host_impl) override { |
Sunny Sachanandani | 158d26d | 2017-12-12 19:44:10 | [diff] [blame] | 1802 | if (did_lose_context) |
| 1803 | return; |
| 1804 | did_lose_context = true; |
Victor Miura | 29b7ea3d | 2017-12-19 20:23:59 | [diff] [blame] | 1805 | viz::RasterContextProvider::ScopedRasterContextLock scoped_context( |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 1806 | host_impl->layer_tree_frame_sink()->worker_context_provider()); |
Victor Miura | 29b7ea3d | 2017-12-19 20:23:59 | [diff] [blame] | 1807 | gpu::raster::RasterInterface* ri = scoped_context.RasterInterface(); |
Victor Miura | 3a4ad4f8 | 2017-12-13 06:03:45 | [diff] [blame] | 1808 | ri->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 1809 | GL_INNOCENT_CONTEXT_RESET_ARB); |
| 1810 | } |
| 1811 | |
Sunny Sachanandani | 158d26d | 2017-12-12 19:44:10 | [diff] [blame] | 1812 | void DidInitializeLayerTreeFrameSink() override { num_frame_sinks_++; } |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 1813 | |
| 1814 | void DidCommitAndDrawFrame() override { EndTest(); } |
| 1815 | |
Sunny Sachanandani | 158d26d | 2017-12-12 19:44:10 | [diff] [blame] | 1816 | void AfterTest() override { |
| 1817 | EXPECT_TRUE(did_lose_context); |
| 1818 | EXPECT_EQ(num_frame_sinks_, 2); |
| 1819 | } |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 1820 | |
| 1821 | FakeContentLayerClient client_; |
Sunny Sachanandani | 158d26d | 2017-12-12 19:44:10 | [diff] [blame] | 1822 | bool did_lose_context = false; |
| 1823 | int num_frame_sinks_ = 0; |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 1824 | }; |
| 1825 | |
Sunny Sachanandani | 158d26d | 2017-12-12 19:44:10 | [diff] [blame] | 1826 | MULTI_THREAD_TEST_F(LayerTreeHostContextTestWorkerContextLostRecovery); |
sunnyps | e9fd952 | 2016-10-06 23:03:27 | [diff] [blame] | 1827 | |
[email protected] | d993b60 | 2013-01-04 02:08:12 | [diff] [blame] | 1828 | } // namespace |
| 1829 | } // namespace cc |