blob: 51ebf69b19c00769068fefa025de011924413d0c [file] [log] [blame]
[email protected]c0dd24c2012-08-30 23:25:271// 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
[email protected]cc3cfaa2013-03-18 09:05:525#include "cc/layers/texture_layer.h"
[email protected]c0dd24c2012-08-30 23:25:276
avi02a4d172015-12-21 06:14:367#include <stddef.h>
8#include <stdint.h>
9
[email protected]b04264f92013-09-13 23:37:2910#include <algorithm>
[email protected]de44a152013-01-08 15:28:4611#include <string>
12
[email protected]b04264f92013-09-13 23:37:2913#include "base/bind.h"
[email protected]de44a152013-01-08 15:28:4614#include "base/callback.h"
skyostil0fd1dad2015-04-13 20:11:4815#include "base/location.h"
avi02a4d172015-12-21 06:14:3616#include "base/macros.h"
danakj60bc3bc2016-04-09 00:24:4817#include "base/memory/ptr_util.h"
skyostil0fd1dad2015-04-13 20:11:4818#include "base/single_thread_task_runner.h"
danakj3c3973b2015-08-25 21:50:1819#include "base/synchronization/lock.h"
[email protected]9794fb32013-08-29 09:49:5920#include "base/synchronization/waitable_event.h"
[email protected]74b43cc2013-08-30 06:29:2721#include "base/threading/thread.h"
gab39cb4ed72016-05-11 17:45:1922#include "base/threading/thread_task_runner_handle.h"
[email protected]74b43cc2013-08-30 06:29:2723#include "base/time/time.h"
loysoab32ee72016-06-08 03:33:1824#include "cc/animation/animation_host.h"
[email protected]b04264f92013-09-13 23:37:2925#include "cc/layers/solid_color_layer.h"
[email protected]97d519fb2013-03-29 02:27:5426#include "cc/layers/texture_layer_client.h"
[email protected]cc3cfaa2013-03-18 09:05:5227#include "cc/layers/texture_layer_impl.h"
[email protected]b04264f92013-09-13 23:37:2928#include "cc/output/compositor_frame_ack.h"
29#include "cc/output/context_provider.h"
[email protected]e00bab022013-08-19 00:42:4530#include "cc/resources/returned_resource.h"
khushalsagarb64b360d2015-10-21 19:25:1631#include "cc/test/fake_impl_task_runner_provider.h"
[email protected]101441ce2012-10-16 01:45:0332#include "cc/test/fake_layer_tree_host_client.h"
[email protected]586d51ed2012-12-07 20:31:4533#include "cc/test/fake_layer_tree_host_impl.h"
[email protected]199b715e2013-08-13 05:18:3434#include "cc/test/fake_output_surface.h"
[email protected]06d68d02013-04-19 18:46:2135#include "cc/test/layer_test_common.h"
[email protected]e216fef02013-03-20 22:56:1036#include "cc/test/layer_tree_test.h"
reveman34b7a1522015-03-23 20:27:4737#include "cc/test/test_task_graph_runner.h"
[email protected]c2610b9f2013-10-31 06:54:5938#include "cc/test/test_web_graphics_context_3d.h"
[email protected]9794fb32013-08-29 09:49:5939#include "cc/trees/blocking_task_runner.h"
[email protected]556fd292013-03-18 08:03:0440#include "cc/trees/layer_tree_host.h"
41#include "cc/trees/layer_tree_impl.h"
42#include "cc/trees/single_thread_proxy.h"
[email protected]0bf5a202013-07-10 14:50:5443#include "gpu/GLES2/gl2extchromium.h"
[email protected]7f0c53db2012-10-02 00:23:1844#include "testing/gmock/include/gmock/gmock.h"
45#include "testing/gtest/include/gtest/gtest.h"
[email protected]c0dd24c2012-08-30 23:25:2746
[email protected]c0dd24c2012-08-30 23:25:2747using ::testing::Mock;
48using ::testing::_;
49using ::testing::AtLeast;
50using ::testing::AnyNumber;
[email protected]d72d9e02014-04-03 18:40:0951using ::testing::InvokeWithoutArgs;
[email protected]c0dd24c2012-08-30 23:25:2752
[email protected]ba565742012-11-10 09:29:4853namespace cc {
[email protected]c0dd24c2012-08-30 23:25:2754namespace {
55
[email protected]e0a4d732014-02-15 00:23:2656gpu::Mailbox MailboxFromChar(char value) {
[email protected]df41e252014-02-03 23:39:5057 gpu::Mailbox mailbox;
[email protected]e0a4d732014-02-15 00:23:2658 memset(mailbox.name, value, sizeof(mailbox.name));
[email protected]df41e252014-02-03 23:39:5059 return mailbox;
60}
61
dyen398dd0142016-01-21 22:05:5662gpu::SyncToken SyncTokenFromUInt(uint32_t value) {
lukasza2573ce7d2016-02-16 19:17:2263 return gpu::SyncToken(gpu::CommandBufferNamespace::GPU_IO, 0,
64 gpu::CommandBufferId::FromUnsafeValue(0x123), value);
dyen398dd0142016-01-21 22:05:5665}
66
[email protected]408b5e22013-03-19 09:48:0967class MockLayerTreeHost : public LayerTreeHost {
[email protected]28571b042013-03-14 07:59:1568 public:
danakj60bc3bc2016-04-09 00:24:4869 static std::unique_ptr<MockLayerTreeHost> Create(
danakjcf610582015-06-16 22:48:5670 FakeLayerTreeHostClient* client,
71 TaskGraphRunner* task_graph_runner) {
sadrul6780f3da2015-05-11 17:01:5272 LayerTreeHost::InitParams params;
73 params.client = client;
danakjcf610582015-06-16 22:48:5674 params.task_graph_runner = task_graph_runner;
loysoab32ee72016-06-08 03:33:1875 params.animation_host =
76 AnimationHost::CreateForTesting(ThreadInstance::MAIN);
sadrul6780f3da2015-05-11 17:01:5277 LayerTreeSettings settings;
78 params.settings = &settings;
danakj60bc3bc2016-04-09 00:24:4879 return base::WrapUnique(new MockLayerTreeHost(client, &params));
[email protected]28571b042013-03-14 07:59:1580 }
[email protected]c0dd24c2012-08-30 23:25:2781
[email protected]28571b042013-03-14 07:59:1582 MOCK_METHOD0(SetNeedsCommit, void());
[email protected]3519b872013-07-30 07:17:5083 MOCK_METHOD0(SetNeedsUpdateLayers, void());
[email protected]aeeb3372013-11-05 14:05:5484 MOCK_METHOD0(StartRateLimiter, void());
85 MOCK_METHOD0(StopRateLimiter, void());
sadrul6780f3da2015-05-11 17:01:5286
87 private:
88 MockLayerTreeHost(FakeLayerTreeHostClient* client,
89 LayerTreeHost::InitParams* params)
khushalsagare0a38d42016-01-29 01:15:0690 : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) {
sadrul6780f3da2015-05-11 17:01:5291 InitializeSingleThreaded(client, base::ThreadTaskRunnerHandle::Get(),
92 nullptr);
93 }
[email protected]c0dd24c2012-08-30 23:25:2794};
95
[email protected]d72d9e02014-04-03 18:40:0996class FakeTextureLayerClient : public TextureLayerClient {
97 public:
[email protected]17e08432014-04-10 00:41:1198 FakeTextureLayerClient() : mailbox_changed_(true) {}
[email protected]d72d9e02014-04-03 18:40:0999
dcheng716bedf2014-10-21 09:51:08100 bool PrepareTextureMailbox(
[email protected]d72d9e02014-04-03 18:40:09101 TextureMailbox* mailbox,
danakj60bc3bc2016-04-09 00:24:48102 std::unique_ptr<SingleReleaseCallback>* release_callback,
mostynbf68776d82014-10-06 18:07:37103 bool use_shared_memory) override {
[email protected]d72d9e02014-04-03 18:40:09104 if (!mailbox_changed_)
105 return false;
106
107 *mailbox = mailbox_;
danakja04855a2015-11-18 20:39:10108 *release_callback = std::move(release_callback_);
[email protected]d72d9e02014-04-03 18:40:09109 mailbox_changed_ = false;
110 return true;
111 }
112
[email protected]d72d9e02014-04-03 18:40:09113 void set_mailbox(const TextureMailbox& mailbox,
danakj60bc3bc2016-04-09 00:24:48114 std::unique_ptr<SingleReleaseCallback> release_callback) {
[email protected]d72d9e02014-04-03 18:40:09115 mailbox_ = mailbox;
danakja04855a2015-11-18 20:39:10116 release_callback_ = std::move(release_callback);
[email protected]d72d9e02014-04-03 18:40:09117 mailbox_changed_ = true;
118 }
119
120 private:
[email protected]d72d9e02014-04-03 18:40:09121 TextureMailbox mailbox_;
danakj60bc3bc2016-04-09 00:24:48122 std::unique_ptr<SingleReleaseCallback> release_callback_;
[email protected]d72d9e02014-04-03 18:40:09123 bool mailbox_changed_;
124 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient);
125};
126
127class MockMailboxCallback {
128 public:
129 MOCK_METHOD3(Release,
130 void(const gpu::Mailbox& mailbox,
dyencc16ed4d2015-11-03 20:03:04131 const gpu::SyncToken& sync_token,
[email protected]d72d9e02014-04-03 18:40:09132 bool lost_resource));
133 MOCK_METHOD3(Release2,
jbauman9015c8b2014-12-11 00:49:37134 void(SharedBitmap* shared_bitmap,
dyencc16ed4d2015-11-03 20:03:04135 const gpu::SyncToken& sync_token,
[email protected]d72d9e02014-04-03 18:40:09136 bool lost_resource));
skyostil3976a3f2014-09-04 22:07:23137 MOCK_METHOD4(ReleaseImpl,
138 void(const gpu::Mailbox& mailbox,
dyencc16ed4d2015-11-03 20:03:04139 const gpu::SyncToken& sync_token,
skyostil3976a3f2014-09-04 22:07:23140 bool lost_resource,
141 BlockingTaskRunner* main_thread_task_runner));
142 MOCK_METHOD4(ReleaseImpl2,
jbauman9015c8b2014-12-11 00:49:37143 void(SharedBitmap* shared_bitmap,
dyencc16ed4d2015-11-03 20:03:04144 const gpu::SyncToken& sync_token,
skyostil3976a3f2014-09-04 22:07:23145 bool lost_resource,
146 BlockingTaskRunner* main_thread_task_runner));
[email protected]d72d9e02014-04-03 18:40:09147};
148
149struct CommonMailboxObjects {
jbauman9015c8b2014-12-11 00:49:37150 explicit CommonMailboxObjects(SharedBitmapManager* manager)
[email protected]d72d9e02014-04-03 18:40:09151 : mailbox_name1_(MailboxFromChar('1')),
152 mailbox_name2_(MailboxFromChar('2')),
lukasza2573ce7d2016-02-16 19:17:22153 sync_token1_(gpu::CommandBufferNamespace::GPU_IO,
154 123,
155 gpu::CommandBufferId::FromUnsafeValue(0x234),
156 1),
157 sync_token2_(gpu::CommandBufferNamespace::GPU_IO,
158 123,
159 gpu::CommandBufferId::FromUnsafeValue(0x234),
160 2) {
[email protected]d72d9e02014-04-03 18:40:09161 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release,
162 base::Unretained(&mock_callback_),
163 mailbox_name1_);
164 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release,
165 base::Unretained(&mock_callback_),
166 mailbox_name2_);
skyostil3976a3f2014-09-04 22:07:23167 release_mailbox1_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl,
168 base::Unretained(&mock_callback_),
169 mailbox_name1_);
170 release_mailbox2_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl,
171 base::Unretained(&mock_callback_),
172 mailbox_name2_);
avi02a4d172015-12-21 06:14:36173 const uint32_t arbitrary_target1 = GL_TEXTURE_2D;
174 const uint32_t arbitrary_target2 = GL_TEXTURE_EXTERNAL_OES;
dyencc16ed4d2015-11-03 20:03:04175 mailbox1_ = TextureMailbox(mailbox_name1_, sync_token1_, arbitrary_target1);
176 mailbox2_ = TextureMailbox(mailbox_name2_, sync_token2_, arbitrary_target2);
[email protected]d72d9e02014-04-03 18:40:09177 gfx::Size size(128, 128);
jbauman9015c8b2014-12-11 00:49:37178 shared_bitmap_ = manager->AllocateSharedBitmap(size);
179 DCHECK(shared_bitmap_);
180 release_mailbox3_ =
181 base::Bind(&MockMailboxCallback::Release2,
182 base::Unretained(&mock_callback_), shared_bitmap_.get());
183 release_mailbox3_impl_ =
184 base::Bind(&MockMailboxCallback::ReleaseImpl2,
185 base::Unretained(&mock_callback_), shared_bitmap_.get());
186 mailbox3_ = TextureMailbox(shared_bitmap_.get(), size);
[email protected]d72d9e02014-04-03 18:40:09187 }
188
189 gpu::Mailbox mailbox_name1_;
190 gpu::Mailbox mailbox_name2_;
191 MockMailboxCallback mock_callback_;
192 ReleaseCallback release_mailbox1_;
193 ReleaseCallback release_mailbox2_;
194 ReleaseCallback release_mailbox3_;
skyostil3976a3f2014-09-04 22:07:23195 ReleaseCallbackImpl release_mailbox1_impl_;
196 ReleaseCallbackImpl release_mailbox2_impl_;
197 ReleaseCallbackImpl release_mailbox3_impl_;
[email protected]d72d9e02014-04-03 18:40:09198 TextureMailbox mailbox1_;
199 TextureMailbox mailbox2_;
200 TextureMailbox mailbox3_;
dyencc16ed4d2015-11-03 20:03:04201 gpu::SyncToken sync_token1_;
202 gpu::SyncToken sync_token2_;
danakj60bc3bc2016-04-09 00:24:48203 std::unique_ptr<SharedBitmap> shared_bitmap_;
[email protected]d72d9e02014-04-03 18:40:09204};
205
[email protected]31d4df82013-07-18 10:17:22206class TextureLayerTest : public testing::Test {
207 public:
208 TextureLayerTest()
209 : fake_client_(
[email protected]4e2eb352014-03-20 17:25:45210 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)),
revemand180dfc32015-09-24 00:19:43211 output_surface_(FakeOutputSurface::Create3d()),
khushalsagarb64b360d2015-10-21 19:25:16212 host_impl_(&task_runner_provider_,
213 &shared_bitmap_manager_,
214 &task_graph_runner_),
jbauman9015c8b2014-12-11 00:49:37215 test_data_(&shared_bitmap_manager_) {}
[email protected]31d4df82013-07-18 10:17:22216
217 protected:
dcheng93a52eb2014-12-23 02:14:23218 void SetUp() override {
danakjcf610582015-06-16 22:48:56219 layer_tree_host_ =
220 MockLayerTreeHost::Create(&fake_client_, &task_graph_runner_);
[email protected]d72d9e02014-04-03 18:40:09221 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
222 layer_tree_host_->SetViewportSize(gfx::Size(10, 10));
223 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
[email protected]31d4df82013-07-18 10:17:22224 }
225
dcheng93a52eb2014-12-23 02:14:23226 void TearDown() override {
[email protected]31d4df82013-07-18 10:17:22227 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
[email protected]31d4df82013-07-18 10:17:22228 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
229
kulkarni.a4015690f12014-10-10 13:50:06230 layer_tree_host_->SetRootLayer(nullptr);
danakjf446a072014-09-27 21:55:48231 layer_tree_host_ = nullptr;
[email protected]31d4df82013-07-18 10:17:22232 }
233
danakj60bc3bc2016-04-09 00:24:48234 std::unique_ptr<MockLayerTreeHost> layer_tree_host_;
khushalsagarb64b360d2015-10-21 19:25:16235 FakeImplTaskRunnerProvider task_runner_provider_;
[email protected]31d4df82013-07-18 10:17:22236 FakeLayerTreeHostClient fake_client_;
[email protected]4e2eb352014-03-20 17:25:45237 TestSharedBitmapManager shared_bitmap_manager_;
reveman34b7a1522015-03-23 20:27:47238 TestTaskGraphRunner task_graph_runner_;
danakj60bc3bc2016-04-09 00:24:48239 std::unique_ptr<OutputSurface> output_surface_;
[email protected]31d4df82013-07-18 10:17:22240 FakeLayerTreeHostImpl host_impl_;
jbauman9015c8b2014-12-11 00:49:37241 CommonMailboxObjects test_data_;
[email protected]31d4df82013-07-18 10:17:22242};
243
[email protected]31d4df82013-07-18 10:17:22244TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) {
kulkarni.a4015690f12014-10-10 13:50:06245 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31246 TextureLayer::CreateForMailbox(nullptr);
[email protected]80d42bd2013-08-30 19:13:45247 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer));
[email protected]31d4df82013-07-18 10:17:22248
249 // Test properties that should call SetNeedsCommit. All properties need to
250 // be set to new values in order for SetNeedsCommit to be called.
251 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false));
jackhou10c9af42014-12-04 05:24:44252 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true));
[email protected]31d4df82013-07-18 10:17:22253 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV(
254 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f)));
255 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity(
256 0.5f, 0.5f, 0.5f, 0.5f));
257 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false));
258 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true));
[email protected]31d4df82013-07-18 10:17:22259}
260
[email protected]df41e252014-02-03 23:39:50261class TestMailboxHolder : public TextureLayer::TextureMailboxHolder {
[email protected]9794fb32013-08-29 09:49:59262 public:
[email protected]df41e252014-02-03 23:39:50263 using TextureLayer::TextureMailboxHolder::Create;
[email protected]9794fb32013-08-29 09:49:59264
265 protected:
dcheng716bedf2014-10-21 09:51:08266 ~TestMailboxHolder() override {}
[email protected]9794fb32013-08-29 09:49:59267};
268
[email protected]de44a152013-01-08 15:28:46269class TextureLayerWithMailboxTest : public TextureLayerTest {
[email protected]28571b042013-03-14 07:59:15270 protected:
dcheng93a52eb2014-12-23 02:14:23271 void TearDown() override {
[email protected]28571b042013-03-14 07:59:15272 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
dyencc16ed4d2015-11-03 20:03:04273 EXPECT_CALL(
274 test_data_.mock_callback_,
275 Release(test_data_.mailbox_name1_, test_data_.sync_token1_, false))
276 .Times(1);
[email protected]28571b042013-03-14 07:59:15277 TextureLayerTest::TearDown();
278 }
[email protected]de44a152013-01-08 15:28:46279};
280
[email protected]28571b042013-03-14 07:59:15281TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) {
kulkarni.a4015690f12014-10-10 13:50:06282 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31283 TextureLayer::CreateForMailbox(nullptr);
[email protected]22898ed2013-06-01 04:52:30284 ASSERT_TRUE(test_layer.get());
[email protected]de44a152013-01-08 15:28:46285
[email protected]28571b042013-03-14 07:59:15286 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
287 layer_tree_host_->SetRootLayer(test_layer);
288 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
[email protected]de44a152013-01-08 15:28:46289
[email protected]28571b042013-03-14 07:59:15290 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
[email protected]9260757f2013-09-17 01:24:16291 test_layer->SetTextureMailbox(
292 test_data_.mailbox1_,
293 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
[email protected]28571b042013-03-14 07:59:15294 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
[email protected]de44a152013-01-08 15:28:46295
[email protected]28571b042013-03-14 07:59:15296 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
dyencc16ed4d2015-11-03 20:03:04297 EXPECT_CALL(
298 test_data_.mock_callback_,
299 Release(test_data_.mailbox_name1_, test_data_.sync_token1_, false))
[email protected]28571b042013-03-14 07:59:15300 .Times(1);
[email protected]9260757f2013-09-17 01:24:16301 test_layer->SetTextureMailbox(
302 test_data_.mailbox2_,
303 SingleReleaseCallback::Create(test_data_.release_mailbox2_));
[email protected]28571b042013-03-14 07:59:15304 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
305 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]de44a152013-01-08 15:28:46306
[email protected]28571b042013-03-14 07:59:15307 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
dyencc16ed4d2015-11-03 20:03:04308 EXPECT_CALL(
309 test_data_.mock_callback_,
310 Release(test_data_.mailbox_name2_, test_data_.sync_token2_, false))
[email protected]28571b042013-03-14 07:59:15311 .Times(1);
danakj968153f32014-10-15 22:52:16312 test_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]28571b042013-03-14 07:59:15313 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
314 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]de44a152013-01-08 15:28:46315
[email protected]80d42bd2013-08-30 19:13:45316 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
[email protected]9260757f2013-09-17 01:24:16317 test_layer->SetTextureMailbox(
318 test_data_.mailbox3_,
319 SingleReleaseCallback::Create(test_data_.release_mailbox3_));
[email protected]42f40a52013-06-08 04:38:51320 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
321 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
322
[email protected]42f40a52013-06-08 04:38:51323 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
324 EXPECT_CALL(test_data_.mock_callback_,
dyencc16ed4d2015-11-03 20:03:04325 Release2(test_data_.shared_bitmap_.get(), _, false))
326 .Times(1);
danakj968153f32014-10-15 22:52:16327 test_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]42f40a52013-06-08 04:38:51328 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
329 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
330
[email protected]28571b042013-03-14 07:59:15331 // Test destructor.
332 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
[email protected]9260757f2013-09-17 01:24:16333 test_layer->SetTextureMailbox(
334 test_data_.mailbox1_,
335 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
[email protected]de44a152013-01-08 15:28:46336}
337
[email protected]9794fb32013-08-29 09:49:59338class TextureLayerMailboxHolderTest : public TextureLayerTest {
339 public:
340 TextureLayerMailboxHolderTest()
341 : main_thread_("MAIN") {
342 main_thread_.Start();
fdoray70df5a92016-06-22 21:13:59343 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48344 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::InitializeOnMain,
345 base::Unretained(this)));
skyostil3976a3f2014-09-04 22:07:23346 Wait(main_thread_);
[email protected]9794fb32013-08-29 09:49:59347 }
348
349 void Wait(const base::Thread& thread) {
gabcca53112016-06-08 20:13:28350 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
351 base::WaitableEvent::InitialState::NOT_SIGNALED);
fdoray70df5a92016-06-22 21:13:59352 thread.task_runner()->PostTask(
[email protected]9794fb32013-08-29 09:49:59353 FROM_HERE,
354 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event)));
355 event.Wait();
356 }
357
358 void CreateMainRef() {
359 main_ref_ = TestMailboxHolder::Create(
[email protected]9260757f2013-09-17 01:24:16360 test_data_.mailbox1_,
danakja5a05ba02015-11-20 20:14:21361 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
[email protected]9794fb32013-08-29 09:49:59362 }
363
danakjf446a072014-09-27 21:55:48364 void ReleaseMainRef() { main_ref_ = nullptr; }
[email protected]9794fb32013-08-29 09:49:59365
danakj60bc3bc2016-04-09 00:24:48366 void CreateImplRef(std::unique_ptr<SingleReleaseCallbackImpl>* impl_ref) {
[email protected]9794fb32013-08-29 09:49:59367 *impl_ref = main_ref_->holder()->GetCallbackForImplThread();
368 }
369
370 void CapturePostTasksAndWait(base::WaitableEvent* begin_capture,
371 base::WaitableEvent* wait_for_capture,
372 base::WaitableEvent* stop_capture) {
373 begin_capture->Wait();
skyostil3976a3f2014-09-04 22:07:23374 BlockingTaskRunner::CapturePostTasks capture(
375 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59376 wait_for_capture->Signal();
377 stop_capture->Wait();
378 }
379
380 protected:
skyostil3976a3f2014-09-04 22:07:23381 void InitializeOnMain() {
382 main_thread_task_runner_ =
skyostil0fd1dad2015-04-13 20:11:48383 BlockingTaskRunner::Create(main_thread_.task_runner());
skyostil3976a3f2014-09-04 22:07:23384 }
385
danakj60bc3bc2016-04-09 00:24:48386 std::unique_ptr<TestMailboxHolder::MainThreadReference> main_ref_;
[email protected]9794fb32013-08-29 09:49:59387 base::Thread main_thread_;
danakj60bc3bc2016-04-09 00:24:48388 std::unique_ptr<BlockingTaskRunner> main_thread_task_runner_;
[email protected]9794fb32013-08-29 09:49:59389};
390
391TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) {
kulkarni.a4015690f12014-10-10 13:50:06392 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31393 TextureLayer::CreateForMailbox(nullptr);
[email protected]9794fb32013-08-29 09:49:59394 ASSERT_TRUE(test_layer.get());
395
fdoray70df5a92016-06-22 21:13:59396 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48397 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
398 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59399
400 Wait(main_thread_);
401
402 // The texture layer is attached to compositor1, and passes a reference to its
403 // impl tree.
danakj60bc3bc2016-04-09 00:24:48404 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
fdoray70df5a92016-06-22 21:13:59405 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48406 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
407 base::Unretained(this), &compositor1));
[email protected]9794fb32013-08-29 09:49:59408
409 // Then the texture layer is removed and attached to compositor2, and passes a
410 // reference to its impl tree.
danakj60bc3bc2016-04-09 00:24:48411 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
fdoray70df5a92016-06-22 21:13:59412 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48413 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
414 base::Unretained(this), &compositor2));
[email protected]9794fb32013-08-29 09:49:59415
416 Wait(main_thread_);
417 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
418
419 // The compositors both destroy their impl trees before the main thread layer
420 // is destroyed.
dyen398dd0142016-01-21 22:05:56421 compositor1->Run(SyncTokenFromUInt(100), false,
422 main_thread_task_runner_.get());
423 compositor2->Run(SyncTokenFromUInt(200), false,
424 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59425
426 Wait(main_thread_);
427
428 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
429 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
430
431 // The main thread ref is the last one, so the mailbox is released back to the
432 // embedder, with the last sync point provided by the impl trees.
433 EXPECT_CALL(test_data_.mock_callback_,
dyen398dd0142016-01-21 22:05:56434 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(200), false))
dyencc16ed4d2015-11-03 20:03:04435 .Times(1);
[email protected]9794fb32013-08-29 09:49:59436
fdoray70df5a92016-06-22 21:13:59437 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48438 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
439 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59440 Wait(main_thread_);
441 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
442}
443
444TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) {
kulkarni.a4015690f12014-10-10 13:50:06445 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31446 TextureLayer::CreateForMailbox(nullptr);
[email protected]9794fb32013-08-29 09:49:59447 ASSERT_TRUE(test_layer.get());
448
fdoray70df5a92016-06-22 21:13:59449 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48450 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
451 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59452
453 Wait(main_thread_);
454
455 // The texture layer is attached to compositor1, and passes a reference to its
456 // impl tree.
danakj60bc3bc2016-04-09 00:24:48457 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
fdoray70df5a92016-06-22 21:13:59458 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48459 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
460 base::Unretained(this), &compositor1));
[email protected]9794fb32013-08-29 09:49:59461
462 // Then the texture layer is removed and attached to compositor2, and passes a
463 // reference to its impl tree.
danakj60bc3bc2016-04-09 00:24:48464 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
fdoray70df5a92016-06-22 21:13:59465 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48466 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
467 base::Unretained(this), &compositor2));
[email protected]9794fb32013-08-29 09:49:59468
469 Wait(main_thread_);
470 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
471
472 // One compositor destroys their impl tree.
dyen398dd0142016-01-21 22:05:56473 compositor1->Run(SyncTokenFromUInt(100), false,
474 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59475
476 // Then the main thread reference is destroyed.
fdoray70df5a92016-06-22 21:13:59477 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48478 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
479 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59480
481 Wait(main_thread_);
482
483 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
484 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
485
486 // The second impl reference is destroyed last, causing the mailbox to be
487 // released back to the embedder with the last sync point from the impl tree.
488 EXPECT_CALL(test_data_.mock_callback_,
dyen398dd0142016-01-21 22:05:56489 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(200), true))
dyencc16ed4d2015-11-03 20:03:04490 .Times(1);
[email protected]9794fb32013-08-29 09:49:59491
dyen398dd0142016-01-21 22:05:56492 compositor2->Run(SyncTokenFromUInt(200), true,
493 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59494 Wait(main_thread_);
495 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
496}
497
498TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) {
kulkarni.a4015690f12014-10-10 13:50:06499 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31500 TextureLayer::CreateForMailbox(nullptr);
[email protected]9794fb32013-08-29 09:49:59501 ASSERT_TRUE(test_layer.get());
502
fdoray70df5a92016-06-22 21:13:59503 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48504 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
505 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59506
507 Wait(main_thread_);
508
509 // The texture layer is attached to compositor1, and passes a reference to its
510 // impl tree.
danakj60bc3bc2016-04-09 00:24:48511 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
fdoray70df5a92016-06-22 21:13:59512 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48513 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
514 base::Unretained(this), &compositor1));
[email protected]9794fb32013-08-29 09:49:59515
516 // Then the texture layer is removed and attached to compositor2, and passes a
517 // reference to its impl tree.
danakj60bc3bc2016-04-09 00:24:48518 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
fdoray70df5a92016-06-22 21:13:59519 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48520 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
521 base::Unretained(this), &compositor2));
[email protected]9794fb32013-08-29 09:49:59522
523 Wait(main_thread_);
524 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
525
526 // The main thread reference is destroyed first.
fdoray70df5a92016-06-22 21:13:59527 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48528 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
529 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59530
531 // One compositor destroys their impl tree.
dyen398dd0142016-01-21 22:05:56532 compositor2->Run(SyncTokenFromUInt(200), false,
533 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59534
535 Wait(main_thread_);
536
537 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
538 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
539
540 // The second impl reference is destroyed last, causing the mailbox to be
541 // released back to the embedder with the last sync point from the impl tree.
542 EXPECT_CALL(test_data_.mock_callback_,
dyen398dd0142016-01-21 22:05:56543 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(100), true))
dyencc16ed4d2015-11-03 20:03:04544 .Times(1);
[email protected]9794fb32013-08-29 09:49:59545
dyen398dd0142016-01-21 22:05:56546 compositor1->Run(SyncTokenFromUInt(100), true,
547 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59548 Wait(main_thread_);
549 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
550}
551
552TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) {
kulkarni.a4015690f12014-10-10 13:50:06553 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31554 TextureLayer::CreateForMailbox(nullptr);
[email protected]9794fb32013-08-29 09:49:59555 ASSERT_TRUE(test_layer.get());
556
fdoray70df5a92016-06-22 21:13:59557 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48558 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
559 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59560
561 Wait(main_thread_);
562
563 // The texture layer is attached to compositor1, and passes a reference to its
564 // impl tree.
danakj60bc3bc2016-04-09 00:24:48565 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
fdoray70df5a92016-06-22 21:13:59566 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48567 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
568 base::Unretained(this), &compositor1));
[email protected]9794fb32013-08-29 09:49:59569
570 // Then the texture layer is removed and attached to compositor2, and passes a
571 // reference to its impl tree.
danakj60bc3bc2016-04-09 00:24:48572 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
fdoray70df5a92016-06-22 21:13:59573 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48574 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
575 base::Unretained(this), &compositor2));
[email protected]9794fb32013-08-29 09:49:59576
577 Wait(main_thread_);
578 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
579
580 // The main thread reference is destroyed first.
fdoray70df5a92016-06-22 21:13:59581 main_thread_.task_runner()->PostTask(
skyostil0fd1dad2015-04-13 20:11:48582 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
583 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59584
585 EXPECT_CALL(test_data_.mock_callback_,
dyen398dd0142016-01-21 22:05:56586 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(200), true))
dyencc16ed4d2015-11-03 20:03:04587 .Times(1);
[email protected]9794fb32013-08-29 09:49:59588
gabcca53112016-06-08 20:13:28589 base::WaitableEvent begin_capture(
590 base::WaitableEvent::ResetPolicy::AUTOMATIC,
591 base::WaitableEvent::InitialState::NOT_SIGNALED);
592 base::WaitableEvent wait_for_capture(
593 base::WaitableEvent::ResetPolicy::AUTOMATIC,
594 base::WaitableEvent::InitialState::NOT_SIGNALED);
595 base::WaitableEvent stop_capture(
596 base::WaitableEvent::ResetPolicy::AUTOMATIC,
597 base::WaitableEvent::InitialState::NOT_SIGNALED);
[email protected]9794fb32013-08-29 09:49:59598
599 // Post a task to start capturing tasks on the main thread. This will block
600 // the main thread until we signal the |stop_capture| event.
fdoray70df5a92016-06-22 21:13:59601 main_thread_.task_runner()->PostTask(
[email protected]9794fb32013-08-29 09:49:59602 FROM_HERE,
603 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait,
skyostil0fd1dad2015-04-13 20:11:48604 base::Unretained(this), &begin_capture, &wait_for_capture,
[email protected]9794fb32013-08-29 09:49:59605 &stop_capture));
606
607 // Before the main thread capturing starts, one compositor destroys their
608 // impl reference. Since capturing did not start, this gets post-tasked to
609 // the main thread.
dyen398dd0142016-01-21 22:05:56610 compositor1->Run(SyncTokenFromUInt(100), false,
611 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59612
613 // Start capturing on the main thread.
614 begin_capture.Signal();
615 wait_for_capture.Wait();
616
617 // Meanwhile, the second compositor released its impl reference, but this task
618 // gets shortcutted directly to the main thread. This means the reference is
619 // released before compositor1, whose reference will be released later when
620 // the post-task is serviced. But since it was destroyed _on the impl thread_
621 // last, its sync point values should be used.
dyen398dd0142016-01-21 22:05:56622 compositor2->Run(SyncTokenFromUInt(200), true,
623 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59624
625 stop_capture.Signal();
626 Wait(main_thread_);
627
628 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
629}
630
[email protected]e216fef02013-03-20 22:56:10631class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
[email protected]28571b042013-03-14 07:59:15632 public:
633 TextureLayerImplWithMailboxThreadedCallback()
634 : callback_count_(0),
635 commit_count_(0) {}
636
637 // Make sure callback is received on main and doesn't block the impl thread.
dyencc16ed4d2015-11-03 20:03:04638 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
[email protected]9794fb32013-08-29 09:49:59639 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
[email protected]7ba3ca72013-04-11 06:37:25640 EXPECT_FALSE(lost_resource);
[email protected]28571b042013-03-14 07:59:15641 ++callback_count_;
642 }
643
644 void SetMailbox(char mailbox_char) {
[email protected]9794fb32013-08-29 09:49:59645 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
danakj60bc3bc2016-04-09 00:24:48646 std::unique_ptr<SingleReleaseCallback> callback =
647 SingleReleaseCallback::Create(base::Bind(
[email protected]28571b042013-03-14 07:59:15648 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback,
649 base::Unretained(this)));
dyene5db881b2016-03-01 19:47:03650 layer_->SetTextureMailbox(
651 TextureMailbox(MailboxFromChar(mailbox_char),
652 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)),
653 GL_TEXTURE_2D),
654 std::move(callback));
[email protected]28571b042013-03-14 07:59:15655 }
656
dcheng716bedf2014-10-21 09:51:08657 void BeginTest() override {
[email protected]9794fb32013-08-29 09:49:59658 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
659
[email protected]28571b042013-03-14 07:59:15660 gfx::Size bounds(100, 100);
loyso0940d412016-03-14 01:30:31661 root_ = Layer::Create();
[email protected]28571b042013-03-14 07:59:15662 root_->SetBounds(bounds);
663
loyso0940d412016-03-14 01:30:31664 layer_ = TextureLayer::CreateForMailbox(nullptr);
[email protected]28571b042013-03-14 07:59:15665 layer_->SetIsDrawable(true);
[email protected]28571b042013-03-14 07:59:15666 layer_->SetBounds(bounds);
667
668 root_->AddChild(layer_);
[email protected]e216fef02013-03-20 22:56:10669 layer_tree_host()->SetRootLayer(root_);
[email protected]18ce59702013-04-09 04:58:40670 layer_tree_host()->SetViewportSize(bounds);
[email protected]28571b042013-03-14 07:59:15671 SetMailbox('1');
672 EXPECT_EQ(0, callback_count_);
673
674 // Case #1: change mailbox before the commit. The old mailbox should be
675 // released immediately.
676 SetMailbox('2');
677 EXPECT_EQ(1, callback_count_);
[email protected]e216fef02013-03-20 22:56:10678 PostSetNeedsCommitToMainThread();
[email protected]28571b042013-03-14 07:59:15679 }
680
dcheng716bedf2014-10-21 09:51:08681 void DidCommit() override {
[email protected]28571b042013-03-14 07:59:15682 ++commit_count_;
683 switch (commit_count_) {
684 case 1:
685 // Case #2: change mailbox after the commit (and draw), where the
686 // layer draws. The old mailbox should be released during the next
687 // commit.
688 SetMailbox('3');
689 EXPECT_EQ(1, callback_count_);
690 break;
691 case 2:
[email protected]28571b042013-03-14 07:59:15692 EXPECT_EQ(2, callback_count_);
693 // Case #3: change mailbox when the layer doesn't draw. The old
694 // mailbox should be released during the next commit.
695 layer_->SetBounds(gfx::Size());
696 SetMailbox('4');
697 break;
[email protected]9794fb32013-08-29 09:49:59698 case 3:
[email protected]28571b042013-03-14 07:59:15699 EXPECT_EQ(3, callback_count_);
700 // Case #4: release mailbox that was committed but never drawn. The
701 // old mailbox should be released during the next commit.
danakj968153f32014-10-15 22:52:16702 layer_->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]28571b042013-03-14 07:59:15703 break;
[email protected]9794fb32013-08-29 09:49:59704 case 4:
danakj431a1202015-06-17 19:09:33705 // With impl painting, the texture mailbox will still be on the impl
706 // thread when the commit finishes, because the layer is not drawble
707 // when it has no texture mailbox, and thus does not block the commit
708 // on activation. So, we wait for activation.
709 // TODO(danakj): fix this. crbug.com/277953
710 layer_tree_host()->SetNeedsCommit();
711 break;
[email protected]9794fb32013-08-29 09:49:59712 case 5:
[email protected]28571b042013-03-14 07:59:15713 EXPECT_EQ(4, callback_count_);
[email protected]7096acc2013-06-18 21:12:43714 // Restore a mailbox for the next step.
715 SetMailbox('5');
716 break;
[email protected]9794fb32013-08-29 09:49:59717 case 6:
[email protected]7096acc2013-06-18 21:12:43718 // Case #5: remove layer from tree. Callback should *not* be called, the
719 // mailbox is returned to the main thread.
720 EXPECT_EQ(4, callback_count_);
721 layer_->RemoveFromParent();
722 break;
[email protected]9794fb32013-08-29 09:49:59723 case 7:
danakj431a1202015-06-17 19:09:33724 // With impl painting, the texture mailbox will still be on the impl
725 // thread when the commit finishes, because the layer is not around to
726 // block the commit on activation anymore. So, we wait for activation.
727 // TODO(danakj): fix this. crbug.com/277953
728 layer_tree_host()->SetNeedsCommit();
729 break;
[email protected]9794fb32013-08-29 09:49:59730 case 8:
[email protected]7096acc2013-06-18 21:12:43731 EXPECT_EQ(4, callback_count_);
732 // Resetting the mailbox will call the callback now.
danakj968153f32014-10-15 22:52:16733 layer_->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]7096acc2013-06-18 21:12:43734 EXPECT_EQ(5, callback_count_);
[email protected]e216fef02013-03-20 22:56:10735 EndTest();
[email protected]28571b042013-03-14 07:59:15736 break;
737 default:
738 NOTREACHED();
739 break;
[email protected]de44a152013-01-08 15:28:46740 }
[email protected]28571b042013-03-14 07:59:15741 }
[email protected]de44a152013-01-08 15:28:46742
dcheng716bedf2014-10-21 09:51:08743 void AfterTest() override {}
[email protected]de44a152013-01-08 15:28:46744
[email protected]28571b042013-03-14 07:59:15745 private:
[email protected]9794fb32013-08-29 09:49:59746 base::ThreadChecker main_thread_;
[email protected]28571b042013-03-14 07:59:15747 int callback_count_;
748 int commit_count_;
749 scoped_refptr<Layer> root_;
750 scoped_refptr<TextureLayer> layer_;
[email protected]de44a152013-01-08 15:28:46751};
752
[email protected]4145d172013-05-10 16:54:36753SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
754 TextureLayerImplWithMailboxThreadedCallback);
[email protected]de44a152013-01-08 15:28:46755
[email protected]74b43cc2013-08-30 06:29:27756
[email protected]74b43cc2013-08-30 06:29:27757class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest {
758 protected:
[email protected]98ea818e2014-01-24 10:22:08759 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {}
[email protected]74b43cc2013-08-30 06:29:27760
dyene5db881b2016-03-01 19:47:03761 static void ReleaseCallback(const gpu::SyncToken& original_sync_token,
762 const gpu::SyncToken& release_sync_token,
dyencc16ed4d2015-11-03 20:03:04763 bool lost_resource) {}
[email protected]74b43cc2013-08-30 06:29:27764
765 void SetMailbox(char mailbox_char) {
dyene5db881b2016-03-01 19:47:03766 const gpu::SyncToken sync_token =
767 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char));
danakj60bc3bc2016-04-09 00:24:48768 std::unique_ptr<SingleReleaseCallback> callback =
769 SingleReleaseCallback::Create(base::Bind(
770 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback,
771 sync_token));
dyencc16ed4d2015-11-03 20:03:04772 layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char),
dyene5db881b2016-03-01 19:47:03773 sync_token, GL_TEXTURE_2D),
danakja04855a2015-11-18 20:39:10774 std::move(callback));
[email protected]74b43cc2013-08-30 06:29:27775 }
776
dcheng716bedf2014-10-21 09:51:08777 void BeginTest() override {
[email protected]74b43cc2013-08-30 06:29:27778 gfx::Size bounds(100, 100);
loyso0940d412016-03-14 01:30:31779 root_ = Layer::Create();
[email protected]74b43cc2013-08-30 06:29:27780 root_->SetBounds(bounds);
781
loyso0940d412016-03-14 01:30:31782 layer_ = TextureLayer::CreateForMailbox(nullptr);
[email protected]74b43cc2013-08-30 06:29:27783 layer_->SetIsDrawable(true);
[email protected]74b43cc2013-08-30 06:29:27784 layer_->SetBounds(bounds);
785
786 root_->AddChild(layer_);
787 layer_tree_host()->SetRootLayer(root_);
788 layer_tree_host()->SetViewportSize(bounds);
789 SetMailbox('1');
790
791 PostSetNeedsCommitToMainThread();
792 }
793
dcheng716bedf2014-10-21 09:51:08794 void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override {
danakj3c3973b2015-08-25 21:50:18795 base::AutoLock lock(activate_count_lock_);
[email protected]74b43cc2013-08-30 06:29:27796 ++activate_count_;
797 }
798
dcheng716bedf2014-10-21 09:51:08799 void DidCommit() override {
danakj3c3973b2015-08-25 21:50:18800 // The first frame doesn't cause anything to be returned so it does not
801 // need to wait for activation.
802 if (layer_tree_host()->source_frame_number() > 1) {
803 base::AutoLock lock(activate_count_lock_);
804 // The activate happened before commit is done on the main side.
805 EXPECT_EQ(activate_count_, layer_tree_host()->source_frame_number());
806 }
807
[email protected]98ea818e2014-01-24 10:22:08808 switch (layer_tree_host()->source_frame_number()) {
[email protected]74b43cc2013-08-30 06:29:27809 case 1:
810 // The first mailbox has been activated. Set a new mailbox, and
811 // expect the next commit to finish *after* it is activated.
812 SetMailbox('2');
[email protected]74b43cc2013-08-30 06:29:27813 break;
814 case 2:
815 // The second mailbox has been activated. Remove the layer from
816 // the tree to cause another commit/activation. The commit should
817 // finish *after* the layer is removed from the active tree.
818 layer_->RemoveFromParent();
[email protected]74b43cc2013-08-30 06:29:27819 break;
820 case 3:
821 EndTest();
822 break;
823 }
824 }
825
dcheng716bedf2014-10-21 09:51:08826 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
danakj3c3973b2015-08-25 21:50:18827 // The activate didn't happen before commit is done on the impl side (but it
828 // should happen before the main thread is done).
829 EXPECT_EQ(activate_count_, host_impl->sync_tree()->source_frame_number());
[email protected]74b43cc2013-08-30 06:29:27830 }
831
dcheng716bedf2014-10-21 09:51:08832 void AfterTest() override {}
[email protected]74b43cc2013-08-30 06:29:27833
danakj3c3973b2015-08-25 21:50:18834 base::Lock activate_count_lock_;
[email protected]74b43cc2013-08-30 06:29:27835 int activate_count_;
836 scoped_refptr<Layer> root_;
837 scoped_refptr<TextureLayer> layer_;
838};
839
840SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
841 TextureLayerMailboxIsActivatedDuringCommit);
842
[email protected]de44a152013-01-08 15:28:46843class TextureLayerImplWithMailboxTest : public TextureLayerTest {
[email protected]28571b042013-03-14 07:59:15844 protected:
[email protected]408b5e22013-03-19 09:48:09845 TextureLayerImplWithMailboxTest()
846 : fake_client_(
847 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)) {}
848
dcheng93a52eb2014-12-23 02:14:23849 void SetUp() override {
[email protected]28571b042013-03-14 07:59:15850 TextureLayerTest::SetUp();
danakjcf610582015-06-16 22:48:56851 layer_tree_host_ =
852 MockLayerTreeHost::Create(&fake_client_, &task_graph_runner_);
sievers71c62dd52015-10-07 01:44:39853 host_impl_.SetVisible(true);
revemand180dfc32015-09-24 00:19:43854 EXPECT_TRUE(host_impl_.InitializeRenderer(output_surface_.get()));
[email protected]28571b042013-03-14 07:59:15855 }
[email protected]de44a152013-01-08 15:28:46856
[email protected]0ec335c42013-07-04 06:17:08857 bool WillDraw(TextureLayerImpl* layer, DrawMode mode) {
858 bool will_draw = layer->WillDraw(
859 mode, host_impl_.active_tree()->resource_provider());
860 if (will_draw)
861 layer->DidDraw(host_impl_.active_tree()->resource_provider());
862 return will_draw;
863 }
864
[email protected]408b5e22013-03-19 09:48:09865 FakeLayerTreeHostClient fake_client_;
[email protected]de44a152013-01-08 15:28:46866};
867
[email protected]ffbb2212013-06-02 23:47:59868// Test conditions for results of TextureLayerImpl::WillDraw under
869// different configurations of different mailbox, texture_id, and draw_mode.
870TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) {
skyostil3976a3f2014-09-04 22:07:23871 EXPECT_CALL(
872 test_data_.mock_callback_,
dyencc16ed4d2015-11-03 20:03:04873 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _))
[email protected]0ec335c42013-07-04 06:17:08874 .Times(AnyNumber());
dyencc16ed4d2015-11-03 20:03:04875 EXPECT_CALL(
876 test_data_.mock_callback_,
877 ReleaseImpl2(test_data_.shared_bitmap_.get(), gpu::SyncToken(), false, _))
[email protected]0ec335c42013-07-04 06:17:08878 .Times(AnyNumber());
[email protected]ffbb2212013-06-02 23:47:59879 // Hardware mode.
880 {
danakj60bc3bc2016-04-09 00:24:48881 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11882 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]9260757f2013-09-17 01:24:16883 impl_layer->SetTextureMailbox(
884 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:23885 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]0ec335c42013-07-04 06:17:08886 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
[email protected]ffbb2212013-06-02 23:47:59887 }
888
889 {
danakj60bc3bc2016-04-09 00:24:48890 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11891 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
danakj968153f32014-10-15 22:52:16892 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]0ec335c42013-07-04 06:17:08893 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
894 }
895
896 {
897 // Software resource.
danakj60bc3bc2016-04-09 00:24:48898 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11899 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]9260757f2013-09-17 01:24:16900 impl_layer->SetTextureMailbox(
901 test_data_.mailbox3_,
skyostil3976a3f2014-09-04 22:07:23902 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_));
[email protected]3e44d7a2013-07-30 00:03:10903 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
[email protected]ffbb2212013-06-02 23:47:59904 }
905
[email protected]0ec335c42013-07-04 06:17:08906 // Software mode.
907 {
danakj60bc3bc2016-04-09 00:24:48908 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11909 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]9260757f2013-09-17 01:24:16910 impl_layer->SetTextureMailbox(
911 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:23912 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]0ec335c42013-07-04 06:17:08913 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
914 }
915
916 {
danakj60bc3bc2016-04-09 00:24:48917 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11918 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
danakj968153f32014-10-15 22:52:16919 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]0ec335c42013-07-04 06:17:08920 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
921 }
922
923 {
924 // Software resource.
danakj60bc3bc2016-04-09 00:24:48925 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11926 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]9260757f2013-09-17 01:24:16927 impl_layer->SetTextureMailbox(
928 test_data_.mailbox3_,
skyostil3976a3f2014-09-04 22:07:23929 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_));
[email protected]0ec335c42013-07-04 06:17:08930 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
931 }
932
[email protected]ffbb2212013-06-02 23:47:59933 // Resourceless software mode.
934 {
danakj60bc3bc2016-04-09 00:24:48935 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11936 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]9260757f2013-09-17 01:24:16937 impl_layer->SetTextureMailbox(
938 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:23939 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]0ec335c42013-07-04 06:17:08940 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE));
[email protected]ffbb2212013-06-02 23:47:59941 }
[email protected]ffbb2212013-06-02 23:47:59942}
943
[email protected]28571b042013-03-14 07:59:15944TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) {
945 host_impl_.CreatePendingTree();
danakj60bc3bc2016-04-09 00:24:48946 std::unique_ptr<TextureLayerImpl> pending_layer;
[email protected]17e08432014-04-10 00:41:11947 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1);
[email protected]28571b042013-03-14 07:59:15948 ASSERT_TRUE(pending_layer);
[email protected]de44a152013-01-08 15:28:46949
danakj60bc3bc2016-04-09 00:24:48950 std::unique_ptr<LayerImpl> active_layer(
[email protected]28571b042013-03-14 07:59:15951 pending_layer->CreateLayerImpl(host_impl_.active_tree()));
[email protected]ed511b8d2013-03-25 03:29:29952 ASSERT_TRUE(active_layer);
[email protected]de44a152013-01-08 15:28:46953
[email protected]9260757f2013-09-17 01:24:16954 pending_layer->SetTextureMailbox(
955 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:23956 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]421e84f2013-02-22 03:27:15957
[email protected]28571b042013-03-14 07:59:15958 // Test multiple commits without an activation.
skyostil3976a3f2014-09-04 22:07:23959 EXPECT_CALL(
960 test_data_.mock_callback_,
dyencc16ed4d2015-11-03 20:03:04961 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _))
[email protected]28571b042013-03-14 07:59:15962 .Times(1);
[email protected]9260757f2013-09-17 01:24:16963 pending_layer->SetTextureMailbox(
964 test_data_.mailbox2_,
skyostil3976a3f2014-09-04 22:07:23965 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox2_impl_));
[email protected]28571b042013-03-14 07:59:15966 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]421e84f2013-02-22 03:27:15967
[email protected]28571b042013-03-14 07:59:15968 // Test callback after activation.
[email protected]ed511b8d2013-03-25 03:29:29969 pending_layer->PushPropertiesTo(active_layer.get());
970 active_layer->DidBecomeActive();
[email protected]421e84f2013-02-22 03:27:15971
skyostil3976a3f2014-09-04 22:07:23972 EXPECT_CALL(test_data_.mock_callback_, ReleaseImpl(_, _, _, _)).Times(0);
[email protected]9260757f2013-09-17 01:24:16973 pending_layer->SetTextureMailbox(
974 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:23975 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]28571b042013-03-14 07:59:15976 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]421e84f2013-02-22 03:27:15977
[email protected]7ba3ca72013-04-11 06:37:25978 EXPECT_CALL(test_data_.mock_callback_,
skyostil3976a3f2014-09-04 22:07:23979 ReleaseImpl(test_data_.mailbox_name2_, _, false, _)).Times(1);
[email protected]ed511b8d2013-03-25 03:29:29980 pending_layer->PushPropertiesTo(active_layer.get());
981 active_layer->DidBecomeActive();
[email protected]28571b042013-03-14 07:59:15982 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]de44a152013-01-08 15:28:46983
[email protected]28571b042013-03-14 07:59:15984 // Test resetting the mailbox.
[email protected]7ba3ca72013-04-11 06:37:25985 EXPECT_CALL(test_data_.mock_callback_,
skyostil3976a3f2014-09-04 22:07:23986 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1);
danakj968153f32014-10-15 22:52:16987 pending_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]ed511b8d2013-03-25 03:29:29988 pending_layer->PushPropertiesTo(active_layer.get());
989 active_layer->DidBecomeActive();
[email protected]28571b042013-03-14 07:59:15990 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]de44a152013-01-08 15:28:46991
[email protected]28571b042013-03-14 07:59:15992 // Test destructor.
skyostil3976a3f2014-09-04 22:07:23993 EXPECT_CALL(
994 test_data_.mock_callback_,
dyencc16ed4d2015-11-03 20:03:04995 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _))
[email protected]28571b042013-03-14 07:59:15996 .Times(1);
[email protected]9260757f2013-09-17 01:24:16997 pending_layer->SetTextureMailbox(
998 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:23999 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]de44a152013-01-08 15:28:461000}
1001
[email protected]28571b042013-03-14 07:59:151002TEST_F(TextureLayerImplWithMailboxTest,
1003 TestDestructorCallbackOnCreatedResource) {
danakj60bc3bc2016-04-09 00:24:481004 std::unique_ptr<TextureLayerImpl> impl_layer;
[email protected]17e08432014-04-10 00:41:111005 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]28571b042013-03-14 07:59:151006 ASSERT_TRUE(impl_layer);
[email protected]de44a152013-01-08 15:28:461007
[email protected]7ba3ca72013-04-11 06:37:251008 EXPECT_CALL(test_data_.mock_callback_,
skyostil3976a3f2014-09-04 22:07:231009 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1);
[email protected]9260757f2013-09-17 01:24:161010 impl_layer->SetTextureMailbox(
1011 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:231012 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]ffbb2212013-06-02 23:47:591013 impl_layer->DidBecomeActive();
1014 EXPECT_TRUE(impl_layer->WillDraw(
1015 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider()));
[email protected]28571b042013-03-14 07:59:151016 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider());
danakj968153f32014-10-15 22:52:161017 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]de44a152013-01-08 15:28:461018}
1019
[email protected]28571b042013-03-14 07:59:151020TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) {
1021 ResourceProvider* provider = host_impl_.active_tree()->resource_provider();
jbaumanbbd425e2015-05-19 00:33:351022 ResourceId id = provider->CreateResourceFromTextureMailbox(
skyostil3976a3f2014-09-04 22:07:231023 test_data_.mailbox1_,
1024 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]28571b042013-03-14 07:59:151025 provider->AllocateForTesting(id);
[email protected]de44a152013-01-08 15:28:461026
[email protected]28571b042013-03-14 07:59:151027 // Transfer some resources to the parent.
1028 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1029 resource_ids_to_transfer.push_back(id);
1030 TransferableResourceArray list;
1031 provider->PrepareSendToParent(resource_ids_to_transfer, &list);
1032 EXPECT_TRUE(provider->InUseByConsumer(id));
skyostil3976a3f2014-09-04 22:07:231033 EXPECT_CALL(test_data_.mock_callback_, ReleaseImpl(_, _, _, _)).Times(0);
[email protected]28571b042013-03-14 07:59:151034 provider->DeleteResource(id);
1035 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]7ba3ca72013-04-11 06:37:251036 EXPECT_CALL(test_data_.mock_callback_,
skyostil3976a3f2014-09-04 22:07:231037 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1);
[email protected]e00bab022013-08-19 00:42:451038 ReturnedResourceArray returned;
1039 TransferableResource::ReturnResources(list, &returned);
1040 provider->ReceiveReturnsFromParent(returned);
[email protected]de44a152013-01-08 15:28:461041}
1042
[email protected]4bad8b62013-10-24 01:27:291043// Checks that TextureLayer::Update does not cause an extra commit when setting
1044// the texture mailbox.
1045class TextureLayerNoExtraCommitForMailboxTest
1046 : public LayerTreeTest,
1047 public TextureLayerClient {
1048 public:
[email protected]4bad8b62013-10-24 01:27:291049 // TextureLayerClient implementation.
dcheng716bedf2014-10-21 09:51:081050 bool PrepareTextureMailbox(
[email protected]df41e252014-02-03 23:39:501051 TextureMailbox* texture_mailbox,
danakj60bc3bc2016-04-09 00:24:481052 std::unique_ptr<SingleReleaseCallback>* release_callback,
mostynbf68776d82014-10-06 18:07:371053 bool use_shared_memory) override {
[email protected]cce34bd2013-12-02 23:24:451054 if (layer_tree_host()->source_frame_number() == 1) {
[email protected]9f35bd22014-06-03 15:25:461055 // Once this has been committed, the mailbox will be released.
[email protected]df41e252014-02-03 23:39:501056 *texture_mailbox = TextureMailbox();
[email protected]cce34bd2013-12-02 23:24:451057 return true;
1058 }
[email protected]4bad8b62013-10-24 01:27:291059
dyene5db881b2016-03-01 19:47:031060 *texture_mailbox = TextureMailbox(MailboxFromChar('1'),
1061 SyncTokenFromUInt(0x123), GL_TEXTURE_2D);
[email protected]4bad8b62013-10-24 01:27:291062 *release_callback = SingleReleaseCallback::Create(
1063 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased,
1064 base::Unretained(this)));
[email protected]4bad8b62013-10-24 01:27:291065 return true;
1066 }
1067
dyencc16ed4d2015-11-03 20:03:041068 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
[email protected]9f35bd22014-06-03 15:25:461069 // Source frame number during callback is the same as the source frame
1070 // on which it was released.
1071 EXPECT_EQ(1, layer_tree_host()->source_frame_number());
dyene5db881b2016-03-01 19:47:031072 EXPECT_TRUE(sync_token.HasData());
[email protected]cce34bd2013-12-02 23:24:451073 EndTest();
[email protected]4bad8b62013-10-24 01:27:291074 }
1075
dcheng716bedf2014-10-21 09:51:081076 void SetupTree() override {
loyso0940d412016-03-14 01:30:311077 scoped_refptr<Layer> root = Layer::Create();
[email protected]4bad8b62013-10-24 01:27:291078 root->SetBounds(gfx::Size(10, 10));
[email protected]4bad8b62013-10-24 01:27:291079 root->SetIsDrawable(true);
1080
loyso0940d412016-03-14 01:30:311081 texture_layer_ = TextureLayer::CreateForMailbox(this);
[email protected]4bad8b62013-10-24 01:27:291082 texture_layer_->SetBounds(gfx::Size(10, 10));
[email protected]4bad8b62013-10-24 01:27:291083 texture_layer_->SetIsDrawable(true);
[email protected]0d7fb302014-01-23 21:30:471084 root->AddChild(texture_layer_);
[email protected]4bad8b62013-10-24 01:27:291085
1086 layer_tree_host()->SetRootLayer(root);
1087 LayerTreeTest::SetupTree();
1088 }
1089
dcheng716bedf2014-10-21 09:51:081090 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
[email protected]4bad8b62013-10-24 01:27:291091
dcheng716bedf2014-10-21 09:51:081092 void DidCommitAndDrawFrame() override {
[email protected]4bad8b62013-10-24 01:27:291093 switch (layer_tree_host()->source_frame_number()) {
1094 case 1:
[email protected]4ea293f72014-08-13 03:03:171095 EXPECT_FALSE(proxy()->MainFrameWillHappenForTesting());
[email protected]cce34bd2013-12-02 23:24:451096 // Invalidate the texture layer to clear the mailbox before
1097 // ending the test.
1098 texture_layer_->SetNeedsDisplay();
1099 break;
1100 case 2:
[email protected]4bad8b62013-10-24 01:27:291101 break;
1102 default:
1103 NOTREACHED();
1104 break;
1105 }
1106 }
1107
dcheng716bedf2014-10-21 09:51:081108 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
[email protected]cce34bd2013-12-02 23:24:451109 ASSERT_TRUE(result);
1110 DelegatedFrameData* delegated_frame_data =
1111 output_surface()->last_sent_frame().delegated_frame_data.get();
1112 if (!delegated_frame_data)
1113 return;
1114
1115 // Return all resources immediately.
1116 TransferableResourceArray resources_to_return =
1117 output_surface()->resources_held_by_parent();
1118
1119 CompositorFrameAck ack;
1120 for (size_t i = 0; i < resources_to_return.size(); ++i)
1121 output_surface()->ReturnResource(resources_to_return[i].id, &ack);
1122 host_impl->ReclaimResources(&ack);
[email protected]cce34bd2013-12-02 23:24:451123 }
1124
dcheng716bedf2014-10-21 09:51:081125 void AfterTest() override {}
[email protected]4bad8b62013-10-24 01:27:291126
1127 private:
[email protected]4bad8b62013-10-24 01:27:291128 scoped_refptr<TextureLayer> texture_layer_;
[email protected]4bad8b62013-10-24 01:27:291129};
1130
[email protected]cce34bd2013-12-02 23:24:451131SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerNoExtraCommitForMailboxTest);
[email protected]4bad8b62013-10-24 01:27:291132
[email protected]b04264f92013-09-13 23:37:291133// Checks that changing a mailbox in the client for a TextureLayer that's
1134// invisible correctly works and uses the new mailbox as soon as the layer
1135// becomes visible (and returns the old one).
1136class TextureLayerChangeInvisibleMailboxTest
1137 : public LayerTreeTest,
1138 public TextureLayerClient {
1139 public:
1140 TextureLayerChangeInvisibleMailboxTest()
1141 : mailbox_changed_(true),
1142 mailbox_returned_(0),
1143 prepare_called_(0),
1144 commit_count_(0) {
1145 mailbox_ = MakeMailbox('1');
1146 }
1147
1148 // TextureLayerClient implementation.
dcheng716bedf2014-10-21 09:51:081149 bool PrepareTextureMailbox(
[email protected]e51444a2013-12-10 23:05:011150 TextureMailbox* mailbox,
danakj60bc3bc2016-04-09 00:24:481151 std::unique_ptr<SingleReleaseCallback>* release_callback,
mostynbf68776d82014-10-06 18:07:371152 bool use_shared_memory) override {
[email protected]b04264f92013-09-13 23:37:291153 ++prepare_called_;
1154 if (!mailbox_changed_)
1155 return false;
1156 *mailbox = mailbox_;
[email protected]9260757f2013-09-17 01:24:161157 *release_callback = SingleReleaseCallback::Create(
1158 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased,
1159 base::Unretained(this)));
[email protected]b04264f92013-09-13 23:37:291160 return true;
1161 }
1162
1163 TextureMailbox MakeMailbox(char name) {
dyene5db881b2016-03-01 19:47:031164 return TextureMailbox(MailboxFromChar(name),
1165 SyncTokenFromUInt(static_cast<uint32_t>(name)),
dyencc16ed4d2015-11-03 20:03:041166 GL_TEXTURE_2D);
[email protected]b04264f92013-09-13 23:37:291167 }
1168
dyencc16ed4d2015-11-03 20:03:041169 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
dyene5db881b2016-03-01 19:47:031170 EXPECT_TRUE(sync_token.HasData());
[email protected]b04264f92013-09-13 23:37:291171 ++mailbox_returned_;
1172 }
1173
dcheng716bedf2014-10-21 09:51:081174 void SetupTree() override {
loyso0940d412016-03-14 01:30:311175 scoped_refptr<Layer> root = Layer::Create();
[email protected]b04264f92013-09-13 23:37:291176 root->SetBounds(gfx::Size(10, 10));
[email protected]b04264f92013-09-13 23:37:291177 root->SetIsDrawable(true);
1178
loyso0940d412016-03-14 01:30:311179 solid_layer_ = SolidColorLayer::Create();
[email protected]b04264f92013-09-13 23:37:291180 solid_layer_->SetBounds(gfx::Size(10, 10));
1181 solid_layer_->SetIsDrawable(true);
1182 solid_layer_->SetBackgroundColor(SK_ColorWHITE);
1183 root->AddChild(solid_layer_);
1184
loyso0940d412016-03-14 01:30:311185 parent_layer_ = Layer::Create();
[email protected]b04264f92013-09-13 23:37:291186 parent_layer_->SetBounds(gfx::Size(10, 10));
1187 parent_layer_->SetIsDrawable(true);
1188 root->AddChild(parent_layer_);
1189
loyso0940d412016-03-14 01:30:311190 texture_layer_ = TextureLayer::CreateForMailbox(this);
[email protected]b04264f92013-09-13 23:37:291191 texture_layer_->SetBounds(gfx::Size(10, 10));
[email protected]b04264f92013-09-13 23:37:291192 texture_layer_->SetIsDrawable(true);
1193 parent_layer_->AddChild(texture_layer_);
1194
1195 layer_tree_host()->SetRootLayer(root);
1196 LayerTreeTest::SetupTree();
1197 }
1198
dcheng716bedf2014-10-21 09:51:081199 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
[email protected]b04264f92013-09-13 23:37:291200
dcheng716bedf2014-10-21 09:51:081201 void DidCommitAndDrawFrame() override {
[email protected]b04264f92013-09-13 23:37:291202 ++commit_count_;
1203 switch (commit_count_) {
1204 case 1:
1205 // We should have updated the layer, committing the texture.
1206 EXPECT_EQ(1, prepare_called_);
1207 // Make layer invisible.
1208 parent_layer_->SetOpacity(0.f);
1209 break;
1210 case 2:
1211 // Layer shouldn't have been updated.
1212 EXPECT_EQ(1, prepare_called_);
1213 // Change the texture.
1214 mailbox_ = MakeMailbox('2');
1215 mailbox_changed_ = true;
1216 texture_layer_->SetNeedsDisplay();
1217 // Force a change to make sure we draw a frame.
1218 solid_layer_->SetBackgroundColor(SK_ColorGRAY);
1219 break;
1220 case 3:
1221 // Layer shouldn't have been updated.
1222 EXPECT_EQ(1, prepare_called_);
1223 // So the old mailbox isn't returned yet.
1224 EXPECT_EQ(0, mailbox_returned_);
1225 // Make layer visible again.
jaydasikacf223762016-05-16 23:02:091226 parent_layer_->SetOpacity(0.9f);
[email protected]b04264f92013-09-13 23:37:291227 break;
1228 case 4:
1229 // Layer should have been updated.
1230 EXPECT_EQ(2, prepare_called_);
1231 // So the old mailbox should have been returned already.
1232 EXPECT_EQ(1, mailbox_returned_);
1233 texture_layer_->ClearClient();
1234 break;
1235 case 5:
1236 EXPECT_EQ(2, mailbox_returned_);
1237 EndTest();
1238 break;
1239 default:
1240 NOTREACHED();
1241 break;
1242 }
1243 }
1244
dcheng716bedf2014-10-21 09:51:081245 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
[email protected]b04264f92013-09-13 23:37:291246 ASSERT_TRUE(result);
1247 DelegatedFrameData* delegated_frame_data =
1248 output_surface()->last_sent_frame().delegated_frame_data.get();
1249 if (!delegated_frame_data)
1250 return;
1251
1252 // Return all resources immediately.
1253 TransferableResourceArray resources_to_return =
1254 output_surface()->resources_held_by_parent();
1255
1256 CompositorFrameAck ack;
1257 for (size_t i = 0; i < resources_to_return.size(); ++i)
1258 output_surface()->ReturnResource(resources_to_return[i].id, &ack);
[email protected]a7335e0b2013-09-18 09:34:511259 host_impl->ReclaimResources(&ack);
[email protected]b04264f92013-09-13 23:37:291260 }
1261
dcheng716bedf2014-10-21 09:51:081262 void AfterTest() override {}
[email protected]b04264f92013-09-13 23:37:291263
1264 private:
1265 scoped_refptr<SolidColorLayer> solid_layer_;
1266 scoped_refptr<Layer> parent_layer_;
1267 scoped_refptr<TextureLayer> texture_layer_;
1268
1269 // Used on the main thread.
1270 bool mailbox_changed_;
1271 TextureMailbox mailbox_;
1272 int mailbox_returned_;
1273 int prepare_called_;
1274 int commit_count_;
1275};
1276
1277SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerChangeInvisibleMailboxTest);
1278
[email protected]0d7fb302014-01-23 21:30:471279// Test that TextureLayerImpl::ReleaseResources can be called which releases
1280// the mailbox back to TextureLayerClient.
1281class TextureLayerReleaseResourcesBase
1282 : public LayerTreeTest,
1283 public TextureLayerClient {
1284 public:
1285 // TextureLayerClient implementation.
dcheng716bedf2014-10-21 09:51:081286 bool PrepareTextureMailbox(
[email protected]0d7fb302014-01-23 21:30:471287 TextureMailbox* mailbox,
danakj60bc3bc2016-04-09 00:24:481288 std::unique_ptr<SingleReleaseCallback>* release_callback,
mostynbf68776d82014-10-06 18:07:371289 bool use_shared_memory) override {
dyene5db881b2016-03-01 19:47:031290 *mailbox = TextureMailbox(MailboxFromChar('1'), SyncTokenFromUInt(1),
1291 GL_TEXTURE_2D);
[email protected]0d7fb302014-01-23 21:30:471292 *release_callback = SingleReleaseCallback::Create(
1293 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased,
1294 base::Unretained(this)));
1295 return true;
1296 }
1297
dyencc16ed4d2015-11-03 20:03:041298 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
[email protected]0d7fb302014-01-23 21:30:471299 mailbox_released_ = true;
1300 }
1301
dcheng716bedf2014-10-21 09:51:081302 void SetupTree() override {
[email protected]0d7fb302014-01-23 21:30:471303 LayerTreeTest::SetupTree();
1304
1305 scoped_refptr<TextureLayer> texture_layer =
loyso0940d412016-03-14 01:30:311306 TextureLayer::CreateForMailbox(this);
[email protected]0d7fb302014-01-23 21:30:471307 texture_layer->SetBounds(gfx::Size(10, 10));
[email protected]0d7fb302014-01-23 21:30:471308 texture_layer->SetIsDrawable(true);
1309
1310 layer_tree_host()->root_layer()->AddChild(texture_layer);
jaydasikabd6f15a2016-04-21 19:45:371311 texture_layer_id_ = texture_layer->id();
[email protected]0d7fb302014-01-23 21:30:471312 }
1313
dcheng716bedf2014-10-21 09:51:081314 void BeginTest() override {
[email protected]0d7fb302014-01-23 21:30:471315 mailbox_released_ = false;
1316 PostSetNeedsCommitToMainThread();
1317 }
1318
dcheng716bedf2014-10-21 09:51:081319 void DidCommitAndDrawFrame() override { EndTest(); }
[email protected]0d7fb302014-01-23 21:30:471320
dcheng716bedf2014-10-21 09:51:081321 void AfterTest() override { EXPECT_TRUE(mailbox_released_); }
[email protected]0d7fb302014-01-23 21:30:471322
jaydasikabd6f15a2016-04-21 19:45:371323 protected:
1324 int texture_layer_id_;
1325
[email protected]0d7fb302014-01-23 21:30:471326 private:
1327 bool mailbox_released_;
1328};
1329
1330class TextureLayerReleaseResourcesAfterCommit
1331 : public TextureLayerReleaseResourcesBase {
1332 public:
dcheng716bedf2014-10-21 09:51:081333 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
kulkarni.a4015690f12014-10-10 13:50:061334 LayerTreeImpl* tree = nullptr;
danakj009cdfdf2015-02-17 22:35:141335 tree = host_impl->sync_tree();
jaydasikabd6f15a2016-04-21 19:45:371336 tree->LayerById(texture_layer_id_)->ReleaseResources();
[email protected]0d7fb302014-01-23 21:30:471337 }
1338};
1339
1340SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterCommit);
1341
1342class TextureLayerReleaseResourcesAfterActivate
1343 : public TextureLayerReleaseResourcesBase {
1344 public:
dcheng716bedf2014-10-21 09:51:081345 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
jaydasikabd6f15a2016-04-21 19:45:371346 host_impl->active_tree()->LayerById(texture_layer_id_)->ReleaseResources();
[email protected]0d7fb302014-01-23 21:30:471347 }
1348};
1349
1350SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterActivate);
1351
[email protected]9c2bd822013-07-26 12:30:171352class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest {
1353 public:
dyencc16ed4d2015-11-03 20:03:041354 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
[email protected]9794fb32013-08-29 09:49:591355 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
[email protected]9c2bd822013-07-26 12:30:171356 EXPECT_FALSE(lost_resource);
1357 ++callback_count_;
1358 EndTest();
1359 }
1360
1361 void SetMailbox(char mailbox_char) {
[email protected]9794fb32013-08-29 09:49:591362 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
danakj60bc3bc2016-04-09 00:24:481363 std::unique_ptr<SingleReleaseCallback> callback =
1364 SingleReleaseCallback::Create(base::Bind(
[email protected]9c2bd822013-07-26 12:30:171365 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback,
1366 base::Unretained(this)));
dyene5db881b2016-03-01 19:47:031367 layer_->SetTextureMailbox(
1368 TextureMailbox(MailboxFromChar(mailbox_char),
1369 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)),
1370 GL_TEXTURE_2D),
1371 std::move(callback));
[email protected]9c2bd822013-07-26 12:30:171372 }
1373
dcheng716bedf2014-10-21 09:51:081374 void SetupTree() override {
[email protected]9c2bd822013-07-26 12:30:171375 gfx::Size bounds(100, 100);
loyso0940d412016-03-14 01:30:311376 root_ = Layer::Create();
[email protected]9c2bd822013-07-26 12:30:171377 root_->SetBounds(bounds);
1378
loyso0940d412016-03-14 01:30:311379 layer_ = TextureLayer::CreateForMailbox(nullptr);
[email protected]9c2bd822013-07-26 12:30:171380 layer_->SetIsDrawable(true);
[email protected]9c2bd822013-07-26 12:30:171381 layer_->SetBounds(bounds);
1382
1383 root_->AddChild(layer_);
1384 layer_tree_host()->SetRootLayer(root_);
1385 layer_tree_host()->SetViewportSize(bounds);
1386 }
1387
dcheng716bedf2014-10-21 09:51:081388 void BeginTest() override {
[email protected]9794fb32013-08-29 09:49:591389 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1390
[email protected]9c2bd822013-07-26 12:30:171391 callback_count_ = 0;
1392
1393 // Set the mailbox on the main thread.
1394 SetMailbox('1');
1395 EXPECT_EQ(0, callback_count_);
1396
1397 PostSetNeedsCommitToMainThread();
1398 }
1399
dcheng716bedf2014-10-21 09:51:081400 void DidCommitAndDrawFrame() override {
[email protected]9c2bd822013-07-26 12:30:171401 switch (layer_tree_host()->source_frame_number()) {
1402 case 1:
1403 // Delete the TextureLayer on the main thread while the mailbox is in
1404 // the impl tree.
1405 layer_->RemoveFromParent();
kulkarni.a4015690f12014-10-10 13:50:061406 layer_ = nullptr;
[email protected]9c2bd822013-07-26 12:30:171407 break;
1408 }
1409 }
1410
dcheng716bedf2014-10-21 09:51:081411 void AfterTest() override { EXPECT_EQ(1, callback_count_); }
[email protected]9c2bd822013-07-26 12:30:171412
1413 private:
[email protected]9794fb32013-08-29 09:49:591414 base::ThreadChecker main_thread_;
[email protected]9c2bd822013-07-26 12:30:171415 int callback_count_;
1416 scoped_refptr<Layer> root_;
1417 scoped_refptr<TextureLayer> layer_;
1418};
1419
1420SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1421 TextureLayerWithMailboxMainThreadDeleted);
1422
1423class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest {
1424 public:
dyencc16ed4d2015-11-03 20:03:041425 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
[email protected]9794fb32013-08-29 09:49:591426 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
[email protected]9c2bd822013-07-26 12:30:171427 EXPECT_FALSE(lost_resource);
1428 ++callback_count_;
1429 EndTest();
1430 }
1431
1432 void SetMailbox(char mailbox_char) {
[email protected]9794fb32013-08-29 09:49:591433 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
danakj60bc3bc2016-04-09 00:24:481434 std::unique_ptr<SingleReleaseCallback> callback =
1435 SingleReleaseCallback::Create(base::Bind(
[email protected]9c2bd822013-07-26 12:30:171436 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback,
1437 base::Unretained(this)));
dyene5db881b2016-03-01 19:47:031438 layer_->SetTextureMailbox(
1439 TextureMailbox(MailboxFromChar(mailbox_char),
1440 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)),
1441 GL_TEXTURE_2D),
1442 std::move(callback));
[email protected]9c2bd822013-07-26 12:30:171443 }
1444
dcheng716bedf2014-10-21 09:51:081445 void SetupTree() override {
[email protected]9c2bd822013-07-26 12:30:171446 gfx::Size bounds(100, 100);
loyso0940d412016-03-14 01:30:311447 root_ = Layer::Create();
[email protected]9c2bd822013-07-26 12:30:171448 root_->SetBounds(bounds);
1449
loyso0940d412016-03-14 01:30:311450 layer_ = TextureLayer::CreateForMailbox(nullptr);
[email protected]9c2bd822013-07-26 12:30:171451 layer_->SetIsDrawable(true);
[email protected]9c2bd822013-07-26 12:30:171452 layer_->SetBounds(bounds);
1453
1454 root_->AddChild(layer_);
1455 layer_tree_host()->SetRootLayer(root_);
1456 layer_tree_host()->SetViewportSize(bounds);
1457 }
1458
dcheng716bedf2014-10-21 09:51:081459 void BeginTest() override {
[email protected]9794fb32013-08-29 09:49:591460 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1461
[email protected]9c2bd822013-07-26 12:30:171462 callback_count_ = 0;
1463
1464 // Set the mailbox on the main thread.
1465 SetMailbox('1');
1466 EXPECT_EQ(0, callback_count_);
1467
1468 PostSetNeedsCommitToMainThread();
1469 }
1470
dcheng716bedf2014-10-21 09:51:081471 void DidCommitAndDrawFrame() override {
[email protected]9c2bd822013-07-26 12:30:171472 switch (layer_tree_host()->source_frame_number()) {
1473 case 1:
1474 // Remove the TextureLayer on the main thread while the mailbox is in
1475 // the impl tree, but don't delete the TextureLayer until after the impl
1476 // tree side is deleted.
1477 layer_->RemoveFromParent();
1478 break;
1479 case 2:
kulkarni.a4015690f12014-10-10 13:50:061480 layer_ = nullptr;
[email protected]9c2bd822013-07-26 12:30:171481 break;
1482 }
1483 }
1484
dcheng716bedf2014-10-21 09:51:081485 void AfterTest() override { EXPECT_EQ(1, callback_count_); }
[email protected]9c2bd822013-07-26 12:30:171486
1487 private:
[email protected]9794fb32013-08-29 09:49:591488 base::ThreadChecker main_thread_;
[email protected]9c2bd822013-07-26 12:30:171489 int callback_count_;
1490 scoped_refptr<Layer> root_;
1491 scoped_refptr<TextureLayer> layer_;
1492};
1493
1494SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1495 TextureLayerWithMailboxImplThreadDeleted);
1496
[email protected]ba565742012-11-10 09:29:481497} // namespace
1498} // namespace cc