blob: 3f354274ba353565c832a99c19bb1732928385dd [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"
skyostil0fd1dad2015-04-13 20:11:4821#include "base/thread_task_runner_handle.h"
[email protected]74b43cc2013-08-30 06:29:2722#include "base/threading/thread.h"
23#include "base/time/time.h"
[email protected]b04264f92013-09-13 23:37:2924#include "cc/layers/solid_color_layer.h"
[email protected]97d519fb2013-03-29 02:27:5425#include "cc/layers/texture_layer_client.h"
[email protected]cc3cfaa2013-03-18 09:05:5226#include "cc/layers/texture_layer_impl.h"
[email protected]b04264f92013-09-13 23:37:2927#include "cc/output/compositor_frame_ack.h"
28#include "cc/output/context_provider.h"
[email protected]e00bab022013-08-19 00:42:4529#include "cc/resources/returned_resource.h"
khushalsagarb64b360d2015-10-21 19:25:1630#include "cc/test/fake_impl_task_runner_provider.h"
[email protected]101441ce2012-10-16 01:45:0331#include "cc/test/fake_layer_tree_host_client.h"
[email protected]586d51ed2012-12-07 20:31:4532#include "cc/test/fake_layer_tree_host_impl.h"
[email protected]199b715e2013-08-13 05:18:3433#include "cc/test/fake_output_surface.h"
[email protected]06d68d02013-04-19 18:46:2134#include "cc/test/layer_test_common.h"
[email protected]e216fef02013-03-20 22:56:1035#include "cc/test/layer_tree_test.h"
reveman34b7a1522015-03-23 20:27:4736#include "cc/test/test_task_graph_runner.h"
[email protected]c2610b9f2013-10-31 06:54:5937#include "cc/test/test_web_graphics_context_3d.h"
[email protected]9794fb32013-08-29 09:49:5938#include "cc/trees/blocking_task_runner.h"
[email protected]556fd292013-03-18 08:03:0439#include "cc/trees/layer_tree_host.h"
40#include "cc/trees/layer_tree_impl.h"
41#include "cc/trees/single_thread_proxy.h"
[email protected]0bf5a202013-07-10 14:50:5442#include "gpu/GLES2/gl2extchromium.h"
[email protected]7f0c53db2012-10-02 00:23:1843#include "testing/gmock/include/gmock/gmock.h"
44#include "testing/gtest/include/gtest/gtest.h"
[email protected]c0dd24c2012-08-30 23:25:2745
[email protected]c0dd24c2012-08-30 23:25:2746using ::testing::Mock;
47using ::testing::_;
48using ::testing::AtLeast;
49using ::testing::AnyNumber;
[email protected]d72d9e02014-04-03 18:40:0950using ::testing::InvokeWithoutArgs;
[email protected]c0dd24c2012-08-30 23:25:2751
[email protected]ba565742012-11-10 09:29:4852namespace cc {
[email protected]c0dd24c2012-08-30 23:25:2753namespace {
54
[email protected]e0a4d732014-02-15 00:23:2655gpu::Mailbox MailboxFromChar(char value) {
[email protected]df41e252014-02-03 23:39:5056 gpu::Mailbox mailbox;
[email protected]e0a4d732014-02-15 00:23:2657 memset(mailbox.name, value, sizeof(mailbox.name));
[email protected]df41e252014-02-03 23:39:5058 return mailbox;
59}
60
dyen398dd0142016-01-21 22:05:5661gpu::SyncToken SyncTokenFromUInt(uint32_t value) {
lukasza2573ce7d2016-02-16 19:17:2262 return gpu::SyncToken(gpu::CommandBufferNamespace::GPU_IO, 0,
63 gpu::CommandBufferId::FromUnsafeValue(0x123), value);
dyen398dd0142016-01-21 22:05:5664}
65
[email protected]408b5e22013-03-19 09:48:0966class MockLayerTreeHost : public LayerTreeHost {
[email protected]28571b042013-03-14 07:59:1567 public:
danakj60bc3bc2016-04-09 00:24:4868 static std::unique_ptr<MockLayerTreeHost> Create(
danakjcf610582015-06-16 22:48:5669 FakeLayerTreeHostClient* client,
70 TaskGraphRunner* task_graph_runner) {
sadrul6780f3da2015-05-11 17:01:5271 LayerTreeHost::InitParams params;
72 params.client = client;
danakjcf610582015-06-16 22:48:5673 params.task_graph_runner = task_graph_runner;
sadrul6780f3da2015-05-11 17:01:5274 LayerTreeSettings settings;
75 params.settings = &settings;
danakj60bc3bc2016-04-09 00:24:4876 return base::WrapUnique(new MockLayerTreeHost(client, &params));
[email protected]28571b042013-03-14 07:59:1577 }
[email protected]c0dd24c2012-08-30 23:25:2778
[email protected]28571b042013-03-14 07:59:1579 MOCK_METHOD0(SetNeedsCommit, void());
[email protected]3519b872013-07-30 07:17:5080 MOCK_METHOD0(SetNeedsUpdateLayers, void());
[email protected]aeeb3372013-11-05 14:05:5481 MOCK_METHOD0(StartRateLimiter, void());
82 MOCK_METHOD0(StopRateLimiter, void());
sadrul6780f3da2015-05-11 17:01:5283
84 private:
85 MockLayerTreeHost(FakeLayerTreeHostClient* client,
86 LayerTreeHost::InitParams* params)
khushalsagare0a38d42016-01-29 01:15:0687 : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) {
sadrul6780f3da2015-05-11 17:01:5288 InitializeSingleThreaded(client, base::ThreadTaskRunnerHandle::Get(),
89 nullptr);
90 }
[email protected]c0dd24c2012-08-30 23:25:2791};
92
[email protected]d72d9e02014-04-03 18:40:0993class FakeTextureLayerClient : public TextureLayerClient {
94 public:
[email protected]17e08432014-04-10 00:41:1195 FakeTextureLayerClient() : mailbox_changed_(true) {}
[email protected]d72d9e02014-04-03 18:40:0996
dcheng716bedf2014-10-21 09:51:0897 bool PrepareTextureMailbox(
[email protected]d72d9e02014-04-03 18:40:0998 TextureMailbox* mailbox,
danakj60bc3bc2016-04-09 00:24:4899 std::unique_ptr<SingleReleaseCallback>* release_callback,
mostynbf68776d82014-10-06 18:07:37100 bool use_shared_memory) override {
[email protected]d72d9e02014-04-03 18:40:09101 if (!mailbox_changed_)
102 return false;
103
104 *mailbox = mailbox_;
danakja04855a2015-11-18 20:39:10105 *release_callback = std::move(release_callback_);
[email protected]d72d9e02014-04-03 18:40:09106 mailbox_changed_ = false;
107 return true;
108 }
109
[email protected]d72d9e02014-04-03 18:40:09110 void set_mailbox(const TextureMailbox& mailbox,
danakj60bc3bc2016-04-09 00:24:48111 std::unique_ptr<SingleReleaseCallback> release_callback) {
[email protected]d72d9e02014-04-03 18:40:09112 mailbox_ = mailbox;
danakja04855a2015-11-18 20:39:10113 release_callback_ = std::move(release_callback);
[email protected]d72d9e02014-04-03 18:40:09114 mailbox_changed_ = true;
115 }
116
117 private:
[email protected]d72d9e02014-04-03 18:40:09118 TextureMailbox mailbox_;
danakj60bc3bc2016-04-09 00:24:48119 std::unique_ptr<SingleReleaseCallback> release_callback_;
[email protected]d72d9e02014-04-03 18:40:09120 bool mailbox_changed_;
121 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient);
122};
123
124class MockMailboxCallback {
125 public:
126 MOCK_METHOD3(Release,
127 void(const gpu::Mailbox& mailbox,
dyencc16ed4d2015-11-03 20:03:04128 const gpu::SyncToken& sync_token,
[email protected]d72d9e02014-04-03 18:40:09129 bool lost_resource));
130 MOCK_METHOD3(Release2,
jbauman9015c8b2014-12-11 00:49:37131 void(SharedBitmap* shared_bitmap,
dyencc16ed4d2015-11-03 20:03:04132 const gpu::SyncToken& sync_token,
[email protected]d72d9e02014-04-03 18:40:09133 bool lost_resource));
skyostil3976a3f2014-09-04 22:07:23134 MOCK_METHOD4(ReleaseImpl,
135 void(const gpu::Mailbox& mailbox,
dyencc16ed4d2015-11-03 20:03:04136 const gpu::SyncToken& sync_token,
skyostil3976a3f2014-09-04 22:07:23137 bool lost_resource,
138 BlockingTaskRunner* main_thread_task_runner));
139 MOCK_METHOD4(ReleaseImpl2,
jbauman9015c8b2014-12-11 00:49:37140 void(SharedBitmap* shared_bitmap,
dyencc16ed4d2015-11-03 20:03:04141 const gpu::SyncToken& sync_token,
skyostil3976a3f2014-09-04 22:07:23142 bool lost_resource,
143 BlockingTaskRunner* main_thread_task_runner));
[email protected]d72d9e02014-04-03 18:40:09144};
145
146struct CommonMailboxObjects {
jbauman9015c8b2014-12-11 00:49:37147 explicit CommonMailboxObjects(SharedBitmapManager* manager)
[email protected]d72d9e02014-04-03 18:40:09148 : mailbox_name1_(MailboxFromChar('1')),
149 mailbox_name2_(MailboxFromChar('2')),
lukasza2573ce7d2016-02-16 19:17:22150 sync_token1_(gpu::CommandBufferNamespace::GPU_IO,
151 123,
152 gpu::CommandBufferId::FromUnsafeValue(0x234),
153 1),
154 sync_token2_(gpu::CommandBufferNamespace::GPU_IO,
155 123,
156 gpu::CommandBufferId::FromUnsafeValue(0x234),
157 2) {
[email protected]d72d9e02014-04-03 18:40:09158 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release,
159 base::Unretained(&mock_callback_),
160 mailbox_name1_);
161 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release,
162 base::Unretained(&mock_callback_),
163 mailbox_name2_);
skyostil3976a3f2014-09-04 22:07:23164 release_mailbox1_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl,
165 base::Unretained(&mock_callback_),
166 mailbox_name1_);
167 release_mailbox2_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl,
168 base::Unretained(&mock_callback_),
169 mailbox_name2_);
avi02a4d172015-12-21 06:14:36170 const uint32_t arbitrary_target1 = GL_TEXTURE_2D;
171 const uint32_t arbitrary_target2 = GL_TEXTURE_EXTERNAL_OES;
dyencc16ed4d2015-11-03 20:03:04172 mailbox1_ = TextureMailbox(mailbox_name1_, sync_token1_, arbitrary_target1);
173 mailbox2_ = TextureMailbox(mailbox_name2_, sync_token2_, arbitrary_target2);
[email protected]d72d9e02014-04-03 18:40:09174 gfx::Size size(128, 128);
jbauman9015c8b2014-12-11 00:49:37175 shared_bitmap_ = manager->AllocateSharedBitmap(size);
176 DCHECK(shared_bitmap_);
177 release_mailbox3_ =
178 base::Bind(&MockMailboxCallback::Release2,
179 base::Unretained(&mock_callback_), shared_bitmap_.get());
180 release_mailbox3_impl_ =
181 base::Bind(&MockMailboxCallback::ReleaseImpl2,
182 base::Unretained(&mock_callback_), shared_bitmap_.get());
183 mailbox3_ = TextureMailbox(shared_bitmap_.get(), size);
[email protected]d72d9e02014-04-03 18:40:09184 }
185
186 gpu::Mailbox mailbox_name1_;
187 gpu::Mailbox mailbox_name2_;
188 MockMailboxCallback mock_callback_;
189 ReleaseCallback release_mailbox1_;
190 ReleaseCallback release_mailbox2_;
191 ReleaseCallback release_mailbox3_;
skyostil3976a3f2014-09-04 22:07:23192 ReleaseCallbackImpl release_mailbox1_impl_;
193 ReleaseCallbackImpl release_mailbox2_impl_;
194 ReleaseCallbackImpl release_mailbox3_impl_;
[email protected]d72d9e02014-04-03 18:40:09195 TextureMailbox mailbox1_;
196 TextureMailbox mailbox2_;
197 TextureMailbox mailbox3_;
dyencc16ed4d2015-11-03 20:03:04198 gpu::SyncToken sync_token1_;
199 gpu::SyncToken sync_token2_;
danakj60bc3bc2016-04-09 00:24:48200 std::unique_ptr<SharedBitmap> shared_bitmap_;
[email protected]d72d9e02014-04-03 18:40:09201};
202
[email protected]31d4df82013-07-18 10:17:22203class TextureLayerTest : public testing::Test {
204 public:
205 TextureLayerTest()
206 : fake_client_(
[email protected]4e2eb352014-03-20 17:25:45207 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)),
revemand180dfc32015-09-24 00:19:43208 output_surface_(FakeOutputSurface::Create3d()),
khushalsagarb64b360d2015-10-21 19:25:16209 host_impl_(&task_runner_provider_,
210 &shared_bitmap_manager_,
211 &task_graph_runner_),
jbauman9015c8b2014-12-11 00:49:37212 test_data_(&shared_bitmap_manager_) {}
[email protected]31d4df82013-07-18 10:17:22213
214 protected:
dcheng93a52eb2014-12-23 02:14:23215 void SetUp() override {
danakjcf610582015-06-16 22:48:56216 layer_tree_host_ =
217 MockLayerTreeHost::Create(&fake_client_, &task_graph_runner_);
[email protected]d72d9e02014-04-03 18:40:09218 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
219 layer_tree_host_->SetViewportSize(gfx::Size(10, 10));
220 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
[email protected]31d4df82013-07-18 10:17:22221 }
222
dcheng93a52eb2014-12-23 02:14:23223 void TearDown() override {
[email protected]31d4df82013-07-18 10:17:22224 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
[email protected]31d4df82013-07-18 10:17:22225 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
226
kulkarni.a4015690f12014-10-10 13:50:06227 layer_tree_host_->SetRootLayer(nullptr);
danakjf446a072014-09-27 21:55:48228 layer_tree_host_ = nullptr;
[email protected]31d4df82013-07-18 10:17:22229 }
230
danakj60bc3bc2016-04-09 00:24:48231 std::unique_ptr<MockLayerTreeHost> layer_tree_host_;
khushalsagarb64b360d2015-10-21 19:25:16232 FakeImplTaskRunnerProvider task_runner_provider_;
[email protected]31d4df82013-07-18 10:17:22233 FakeLayerTreeHostClient fake_client_;
[email protected]4e2eb352014-03-20 17:25:45234 TestSharedBitmapManager shared_bitmap_manager_;
reveman34b7a1522015-03-23 20:27:47235 TestTaskGraphRunner task_graph_runner_;
danakj60bc3bc2016-04-09 00:24:48236 std::unique_ptr<OutputSurface> output_surface_;
[email protected]31d4df82013-07-18 10:17:22237 FakeLayerTreeHostImpl host_impl_;
jbauman9015c8b2014-12-11 00:49:37238 CommonMailboxObjects test_data_;
[email protected]31d4df82013-07-18 10:17:22239};
240
[email protected]31d4df82013-07-18 10:17:22241TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) {
kulkarni.a4015690f12014-10-10 13:50:06242 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31243 TextureLayer::CreateForMailbox(nullptr);
[email protected]80d42bd2013-08-30 19:13:45244 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer));
[email protected]31d4df82013-07-18 10:17:22245
246 // Test properties that should call SetNeedsCommit. All properties need to
247 // be set to new values in order for SetNeedsCommit to be called.
248 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false));
jackhou10c9af42014-12-04 05:24:44249 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true));
[email protected]31d4df82013-07-18 10:17:22250 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV(
251 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f)));
252 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity(
253 0.5f, 0.5f, 0.5f, 0.5f));
254 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false));
255 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true));
[email protected]31d4df82013-07-18 10:17:22256}
257
[email protected]df41e252014-02-03 23:39:50258class TestMailboxHolder : public TextureLayer::TextureMailboxHolder {
[email protected]9794fb32013-08-29 09:49:59259 public:
[email protected]df41e252014-02-03 23:39:50260 using TextureLayer::TextureMailboxHolder::Create;
[email protected]9794fb32013-08-29 09:49:59261
262 protected:
dcheng716bedf2014-10-21 09:51:08263 ~TestMailboxHolder() override {}
[email protected]9794fb32013-08-29 09:49:59264};
265
[email protected]de44a152013-01-08 15:28:46266class TextureLayerWithMailboxTest : public TextureLayerTest {
[email protected]28571b042013-03-14 07:59:15267 protected:
dcheng93a52eb2014-12-23 02:14:23268 void TearDown() override {
[email protected]28571b042013-03-14 07:59:15269 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
dyencc16ed4d2015-11-03 20:03:04270 EXPECT_CALL(
271 test_data_.mock_callback_,
272 Release(test_data_.mailbox_name1_, test_data_.sync_token1_, false))
273 .Times(1);
[email protected]28571b042013-03-14 07:59:15274 TextureLayerTest::TearDown();
275 }
[email protected]de44a152013-01-08 15:28:46276};
277
[email protected]28571b042013-03-14 07:59:15278TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) {
kulkarni.a4015690f12014-10-10 13:50:06279 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31280 TextureLayer::CreateForMailbox(nullptr);
[email protected]22898ed2013-06-01 04:52:30281 ASSERT_TRUE(test_layer.get());
[email protected]de44a152013-01-08 15:28:46282
[email protected]28571b042013-03-14 07:59:15283 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
284 layer_tree_host_->SetRootLayer(test_layer);
285 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
[email protected]de44a152013-01-08 15:28:46286
[email protected]28571b042013-03-14 07:59:15287 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
[email protected]9260757f2013-09-17 01:24:16288 test_layer->SetTextureMailbox(
289 test_data_.mailbox1_,
290 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
[email protected]28571b042013-03-14 07:59:15291 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
[email protected]de44a152013-01-08 15:28:46292
[email protected]28571b042013-03-14 07:59:15293 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
dyencc16ed4d2015-11-03 20:03:04294 EXPECT_CALL(
295 test_data_.mock_callback_,
296 Release(test_data_.mailbox_name1_, test_data_.sync_token1_, false))
[email protected]28571b042013-03-14 07:59:15297 .Times(1);
[email protected]9260757f2013-09-17 01:24:16298 test_layer->SetTextureMailbox(
299 test_data_.mailbox2_,
300 SingleReleaseCallback::Create(test_data_.release_mailbox2_));
[email protected]28571b042013-03-14 07:59:15301 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
302 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]de44a152013-01-08 15:28:46303
[email protected]28571b042013-03-14 07:59:15304 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
dyencc16ed4d2015-11-03 20:03:04305 EXPECT_CALL(
306 test_data_.mock_callback_,
307 Release(test_data_.mailbox_name2_, test_data_.sync_token2_, false))
[email protected]28571b042013-03-14 07:59:15308 .Times(1);
danakj968153f32014-10-15 22:52:16309 test_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]28571b042013-03-14 07:59:15310 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
311 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]de44a152013-01-08 15:28:46312
[email protected]80d42bd2013-08-30 19:13:45313 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
[email protected]9260757f2013-09-17 01:24:16314 test_layer->SetTextureMailbox(
315 test_data_.mailbox3_,
316 SingleReleaseCallback::Create(test_data_.release_mailbox3_));
[email protected]42f40a52013-06-08 04:38:51317 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
318 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
319
[email protected]42f40a52013-06-08 04:38:51320 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
321 EXPECT_CALL(test_data_.mock_callback_,
dyencc16ed4d2015-11-03 20:03:04322 Release2(test_data_.shared_bitmap_.get(), _, false))
323 .Times(1);
danakj968153f32014-10-15 22:52:16324 test_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]42f40a52013-06-08 04:38:51325 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
326 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
327
[email protected]28571b042013-03-14 07:59:15328 // Test destructor.
329 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
[email protected]9260757f2013-09-17 01:24:16330 test_layer->SetTextureMailbox(
331 test_data_.mailbox1_,
332 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
[email protected]de44a152013-01-08 15:28:46333}
334
ihf8c461432016-05-10 05:14:05335TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) {
336 scoped_refptr<TextureLayer> test_layer =
337 TextureLayer::CreateForMailbox(nullptr);
338 ASSERT_TRUE(test_layer.get());
339
340 // These use the same gpu::Mailbox, but different sync points.
341 TextureMailbox mailbox1(MailboxFromChar('a'), SyncTokenFromUInt(1),
342 GL_TEXTURE_2D);
343 TextureMailbox mailbox2(MailboxFromChar('a'), SyncTokenFromUInt(2),
344 GL_TEXTURE_2D);
345
346 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
347 layer_tree_host_->SetRootLayer(test_layer);
348 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
349
350 // Set the mailbox the first time. It should cause a commit.
351 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
352 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox1);
353 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
354
355 // Set the mailbox again with a new sync point, as the backing texture has
356 // been updated. It should cause a new commit.
357 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
358 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox2);
359 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
360}
361
[email protected]9794fb32013-08-29 09:49:59362class TextureLayerMailboxHolderTest : public TextureLayerTest {
363 public:
364 TextureLayerMailboxHolderTest()
365 : main_thread_("MAIN") {
366 main_thread_.Start();
skyostil0fd1dad2015-04-13 20:11:48367 main_thread_.message_loop()->task_runner()->PostTask(
368 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::InitializeOnMain,
369 base::Unretained(this)));
skyostil3976a3f2014-09-04 22:07:23370 Wait(main_thread_);
[email protected]9794fb32013-08-29 09:49:59371 }
372
373 void Wait(const base::Thread& thread) {
374 bool manual_reset = false;
375 bool initially_signaled = false;
376 base::WaitableEvent event(manual_reset, initially_signaled);
skyostil0fd1dad2015-04-13 20:11:48377 thread.message_loop()->task_runner()->PostTask(
[email protected]9794fb32013-08-29 09:49:59378 FROM_HERE,
379 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event)));
380 event.Wait();
381 }
382
383 void CreateMainRef() {
384 main_ref_ = TestMailboxHolder::Create(
[email protected]9260757f2013-09-17 01:24:16385 test_data_.mailbox1_,
danakja5a05ba02015-11-20 20:14:21386 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
[email protected]9794fb32013-08-29 09:49:59387 }
388
danakjf446a072014-09-27 21:55:48389 void ReleaseMainRef() { main_ref_ = nullptr; }
[email protected]9794fb32013-08-29 09:49:59390
danakj60bc3bc2016-04-09 00:24:48391 void CreateImplRef(std::unique_ptr<SingleReleaseCallbackImpl>* impl_ref) {
[email protected]9794fb32013-08-29 09:49:59392 *impl_ref = main_ref_->holder()->GetCallbackForImplThread();
393 }
394
395 void CapturePostTasksAndWait(base::WaitableEvent* begin_capture,
396 base::WaitableEvent* wait_for_capture,
397 base::WaitableEvent* stop_capture) {
398 begin_capture->Wait();
skyostil3976a3f2014-09-04 22:07:23399 BlockingTaskRunner::CapturePostTasks capture(
400 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59401 wait_for_capture->Signal();
402 stop_capture->Wait();
403 }
404
405 protected:
skyostil3976a3f2014-09-04 22:07:23406 void InitializeOnMain() {
407 main_thread_task_runner_ =
skyostil0fd1dad2015-04-13 20:11:48408 BlockingTaskRunner::Create(main_thread_.task_runner());
skyostil3976a3f2014-09-04 22:07:23409 }
410
danakj60bc3bc2016-04-09 00:24:48411 std::unique_ptr<TestMailboxHolder::MainThreadReference> main_ref_;
[email protected]9794fb32013-08-29 09:49:59412 base::Thread main_thread_;
danakj60bc3bc2016-04-09 00:24:48413 std::unique_ptr<BlockingTaskRunner> main_thread_task_runner_;
[email protected]9794fb32013-08-29 09:49:59414};
415
416TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) {
kulkarni.a4015690f12014-10-10 13:50:06417 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31418 TextureLayer::CreateForMailbox(nullptr);
[email protected]9794fb32013-08-29 09:49:59419 ASSERT_TRUE(test_layer.get());
420
skyostil0fd1dad2015-04-13 20:11:48421 main_thread_.message_loop()->task_runner()->PostTask(
422 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
423 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59424
425 Wait(main_thread_);
426
427 // The texture layer is attached to compositor1, and passes a reference to its
428 // impl tree.
danakj60bc3bc2016-04-09 00:24:48429 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
skyostil0fd1dad2015-04-13 20:11:48430 main_thread_.message_loop()->task_runner()->PostTask(
431 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
432 base::Unretained(this), &compositor1));
[email protected]9794fb32013-08-29 09:49:59433
434 // Then the texture layer is removed and attached to compositor2, and passes a
435 // reference to its impl tree.
danakj60bc3bc2016-04-09 00:24:48436 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
skyostil0fd1dad2015-04-13 20:11:48437 main_thread_.message_loop()->task_runner()->PostTask(
438 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
439 base::Unretained(this), &compositor2));
[email protected]9794fb32013-08-29 09:49:59440
441 Wait(main_thread_);
442 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
443
444 // The compositors both destroy their impl trees before the main thread layer
445 // is destroyed.
dyen398dd0142016-01-21 22:05:56446 compositor1->Run(SyncTokenFromUInt(100), false,
447 main_thread_task_runner_.get());
448 compositor2->Run(SyncTokenFromUInt(200), false,
449 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59450
451 Wait(main_thread_);
452
453 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
454 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
455
456 // The main thread ref is the last one, so the mailbox is released back to the
457 // embedder, with the last sync point provided by the impl trees.
458 EXPECT_CALL(test_data_.mock_callback_,
dyen398dd0142016-01-21 22:05:56459 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(200), false))
dyencc16ed4d2015-11-03 20:03:04460 .Times(1);
[email protected]9794fb32013-08-29 09:49:59461
skyostil0fd1dad2015-04-13 20:11:48462 main_thread_.message_loop()->task_runner()->PostTask(
463 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
464 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59465 Wait(main_thread_);
466 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
467}
468
469TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) {
kulkarni.a4015690f12014-10-10 13:50:06470 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31471 TextureLayer::CreateForMailbox(nullptr);
[email protected]9794fb32013-08-29 09:49:59472 ASSERT_TRUE(test_layer.get());
473
skyostil0fd1dad2015-04-13 20:11:48474 main_thread_.message_loop()->task_runner()->PostTask(
475 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
476 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59477
478 Wait(main_thread_);
479
480 // The texture layer is attached to compositor1, and passes a reference to its
481 // impl tree.
danakj60bc3bc2016-04-09 00:24:48482 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
skyostil0fd1dad2015-04-13 20:11:48483 main_thread_.message_loop()->task_runner()->PostTask(
484 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
485 base::Unretained(this), &compositor1));
[email protected]9794fb32013-08-29 09:49:59486
487 // Then the texture layer is removed and attached to compositor2, and passes a
488 // reference to its impl tree.
danakj60bc3bc2016-04-09 00:24:48489 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
skyostil0fd1dad2015-04-13 20:11:48490 main_thread_.message_loop()->task_runner()->PostTask(
491 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
492 base::Unretained(this), &compositor2));
[email protected]9794fb32013-08-29 09:49:59493
494 Wait(main_thread_);
495 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
496
497 // One compositor destroys their impl tree.
dyen398dd0142016-01-21 22:05:56498 compositor1->Run(SyncTokenFromUInt(100), false,
499 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59500
501 // Then the main thread reference is destroyed.
skyostil0fd1dad2015-04-13 20:11:48502 main_thread_.message_loop()->task_runner()->PostTask(
503 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
504 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59505
506 Wait(main_thread_);
507
508 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
509 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
510
511 // The second impl reference is destroyed last, causing the mailbox to be
512 // released back to the embedder with the last sync point from the impl tree.
513 EXPECT_CALL(test_data_.mock_callback_,
dyen398dd0142016-01-21 22:05:56514 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(200), true))
dyencc16ed4d2015-11-03 20:03:04515 .Times(1);
[email protected]9794fb32013-08-29 09:49:59516
dyen398dd0142016-01-21 22:05:56517 compositor2->Run(SyncTokenFromUInt(200), true,
518 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59519 Wait(main_thread_);
520 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
521}
522
523TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) {
kulkarni.a4015690f12014-10-10 13:50:06524 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31525 TextureLayer::CreateForMailbox(nullptr);
[email protected]9794fb32013-08-29 09:49:59526 ASSERT_TRUE(test_layer.get());
527
skyostil0fd1dad2015-04-13 20:11:48528 main_thread_.message_loop()->task_runner()->PostTask(
529 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
530 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59531
532 Wait(main_thread_);
533
534 // The texture layer is attached to compositor1, and passes a reference to its
535 // impl tree.
danakj60bc3bc2016-04-09 00:24:48536 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
skyostil0fd1dad2015-04-13 20:11:48537 main_thread_.message_loop()->task_runner()->PostTask(
538 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
539 base::Unretained(this), &compositor1));
[email protected]9794fb32013-08-29 09:49:59540
541 // Then the texture layer is removed and attached to compositor2, and passes a
542 // reference to its impl tree.
danakj60bc3bc2016-04-09 00:24:48543 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
skyostil0fd1dad2015-04-13 20:11:48544 main_thread_.message_loop()->task_runner()->PostTask(
545 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
546 base::Unretained(this), &compositor2));
[email protected]9794fb32013-08-29 09:49:59547
548 Wait(main_thread_);
549 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
550
551 // The main thread reference is destroyed first.
skyostil0fd1dad2015-04-13 20:11:48552 main_thread_.message_loop()->task_runner()->PostTask(
553 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
554 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59555
556 // One compositor destroys their impl tree.
dyen398dd0142016-01-21 22:05:56557 compositor2->Run(SyncTokenFromUInt(200), false,
558 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59559
560 Wait(main_thread_);
561
562 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
563 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
564
565 // The second impl reference is destroyed last, causing the mailbox to be
566 // released back to the embedder with the last sync point from the impl tree.
567 EXPECT_CALL(test_data_.mock_callback_,
dyen398dd0142016-01-21 22:05:56568 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(100), true))
dyencc16ed4d2015-11-03 20:03:04569 .Times(1);
[email protected]9794fb32013-08-29 09:49:59570
dyen398dd0142016-01-21 22:05:56571 compositor1->Run(SyncTokenFromUInt(100), true,
572 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59573 Wait(main_thread_);
574 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
575}
576
577TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) {
kulkarni.a4015690f12014-10-10 13:50:06578 scoped_refptr<TextureLayer> test_layer =
loyso0940d412016-03-14 01:30:31579 TextureLayer::CreateForMailbox(nullptr);
[email protected]9794fb32013-08-29 09:49:59580 ASSERT_TRUE(test_layer.get());
581
skyostil0fd1dad2015-04-13 20:11:48582 main_thread_.message_loop()->task_runner()->PostTask(
583 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
584 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59585
586 Wait(main_thread_);
587
588 // The texture layer is attached to compositor1, and passes a reference to its
589 // impl tree.
danakj60bc3bc2016-04-09 00:24:48590 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
skyostil0fd1dad2015-04-13 20:11:48591 main_thread_.message_loop()->task_runner()->PostTask(
592 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
593 base::Unretained(this), &compositor1));
[email protected]9794fb32013-08-29 09:49:59594
595 // Then the texture layer is removed and attached to compositor2, and passes a
596 // reference to its impl tree.
danakj60bc3bc2016-04-09 00:24:48597 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
skyostil0fd1dad2015-04-13 20:11:48598 main_thread_.message_loop()->task_runner()->PostTask(
599 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
600 base::Unretained(this), &compositor2));
[email protected]9794fb32013-08-29 09:49:59601
602 Wait(main_thread_);
603 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
604
605 // The main thread reference is destroyed first.
skyostil0fd1dad2015-04-13 20:11:48606 main_thread_.message_loop()->task_runner()->PostTask(
607 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
608 base::Unretained(this)));
[email protected]9794fb32013-08-29 09:49:59609
610 EXPECT_CALL(test_data_.mock_callback_,
dyen398dd0142016-01-21 22:05:56611 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(200), true))
dyencc16ed4d2015-11-03 20:03:04612 .Times(1);
[email protected]9794fb32013-08-29 09:49:59613
614 bool manual_reset = false;
615 bool initially_signaled = false;
616 base::WaitableEvent begin_capture(manual_reset, initially_signaled);
617 base::WaitableEvent wait_for_capture(manual_reset, initially_signaled);
618 base::WaitableEvent stop_capture(manual_reset, initially_signaled);
619
620 // Post a task to start capturing tasks on the main thread. This will block
621 // the main thread until we signal the |stop_capture| event.
skyostil0fd1dad2015-04-13 20:11:48622 main_thread_.message_loop()->task_runner()->PostTask(
[email protected]9794fb32013-08-29 09:49:59623 FROM_HERE,
624 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait,
skyostil0fd1dad2015-04-13 20:11:48625 base::Unretained(this), &begin_capture, &wait_for_capture,
[email protected]9794fb32013-08-29 09:49:59626 &stop_capture));
627
628 // Before the main thread capturing starts, one compositor destroys their
629 // impl reference. Since capturing did not start, this gets post-tasked to
630 // the main thread.
dyen398dd0142016-01-21 22:05:56631 compositor1->Run(SyncTokenFromUInt(100), false,
632 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59633
634 // Start capturing on the main thread.
635 begin_capture.Signal();
636 wait_for_capture.Wait();
637
638 // Meanwhile, the second compositor released its impl reference, but this task
639 // gets shortcutted directly to the main thread. This means the reference is
640 // released before compositor1, whose reference will be released later when
641 // the post-task is serviced. But since it was destroyed _on the impl thread_
642 // last, its sync point values should be used.
dyen398dd0142016-01-21 22:05:56643 compositor2->Run(SyncTokenFromUInt(200), true,
644 main_thread_task_runner_.get());
[email protected]9794fb32013-08-29 09:49:59645
646 stop_capture.Signal();
647 Wait(main_thread_);
648
649 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
650}
651
[email protected]e216fef02013-03-20 22:56:10652class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
[email protected]28571b042013-03-14 07:59:15653 public:
654 TextureLayerImplWithMailboxThreadedCallback()
655 : callback_count_(0),
656 commit_count_(0) {}
657
658 // Make sure callback is received on main and doesn't block the impl thread.
dyencc16ed4d2015-11-03 20:03:04659 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
[email protected]9794fb32013-08-29 09:49:59660 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
[email protected]7ba3ca72013-04-11 06:37:25661 EXPECT_FALSE(lost_resource);
[email protected]28571b042013-03-14 07:59:15662 ++callback_count_;
663 }
664
665 void SetMailbox(char mailbox_char) {
[email protected]9794fb32013-08-29 09:49:59666 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
danakj60bc3bc2016-04-09 00:24:48667 std::unique_ptr<SingleReleaseCallback> callback =
668 SingleReleaseCallback::Create(base::Bind(
[email protected]28571b042013-03-14 07:59:15669 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback,
670 base::Unretained(this)));
dyene5db881b2016-03-01 19:47:03671 layer_->SetTextureMailbox(
672 TextureMailbox(MailboxFromChar(mailbox_char),
673 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)),
674 GL_TEXTURE_2D),
675 std::move(callback));
[email protected]28571b042013-03-14 07:59:15676 }
677
dcheng716bedf2014-10-21 09:51:08678 void BeginTest() override {
[email protected]9794fb32013-08-29 09:49:59679 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
680
[email protected]28571b042013-03-14 07:59:15681 gfx::Size bounds(100, 100);
loyso0940d412016-03-14 01:30:31682 root_ = Layer::Create();
[email protected]28571b042013-03-14 07:59:15683 root_->SetBounds(bounds);
684
loyso0940d412016-03-14 01:30:31685 layer_ = TextureLayer::CreateForMailbox(nullptr);
[email protected]28571b042013-03-14 07:59:15686 layer_->SetIsDrawable(true);
[email protected]28571b042013-03-14 07:59:15687 layer_->SetBounds(bounds);
688
689 root_->AddChild(layer_);
[email protected]e216fef02013-03-20 22:56:10690 layer_tree_host()->SetRootLayer(root_);
[email protected]18ce59702013-04-09 04:58:40691 layer_tree_host()->SetViewportSize(bounds);
[email protected]28571b042013-03-14 07:59:15692 SetMailbox('1');
693 EXPECT_EQ(0, callback_count_);
694
695 // Case #1: change mailbox before the commit. The old mailbox should be
696 // released immediately.
697 SetMailbox('2');
698 EXPECT_EQ(1, callback_count_);
[email protected]e216fef02013-03-20 22:56:10699 PostSetNeedsCommitToMainThread();
[email protected]28571b042013-03-14 07:59:15700 }
701
dcheng716bedf2014-10-21 09:51:08702 void DidCommit() override {
[email protected]28571b042013-03-14 07:59:15703 ++commit_count_;
704 switch (commit_count_) {
705 case 1:
706 // Case #2: change mailbox after the commit (and draw), where the
707 // layer draws. The old mailbox should be released during the next
708 // commit.
709 SetMailbox('3');
710 EXPECT_EQ(1, callback_count_);
711 break;
712 case 2:
[email protected]28571b042013-03-14 07:59:15713 EXPECT_EQ(2, callback_count_);
714 // Case #3: change mailbox when the layer doesn't draw. The old
715 // mailbox should be released during the next commit.
716 layer_->SetBounds(gfx::Size());
717 SetMailbox('4');
718 break;
[email protected]9794fb32013-08-29 09:49:59719 case 3:
[email protected]28571b042013-03-14 07:59:15720 EXPECT_EQ(3, callback_count_);
721 // Case #4: release mailbox that was committed but never drawn. The
722 // old mailbox should be released during the next commit.
danakj968153f32014-10-15 22:52:16723 layer_->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]28571b042013-03-14 07:59:15724 break;
[email protected]9794fb32013-08-29 09:49:59725 case 4:
danakj431a1202015-06-17 19:09:33726 // With impl painting, the texture mailbox will still be on the impl
727 // thread when the commit finishes, because the layer is not drawble
728 // when it has no texture mailbox, and thus does not block the commit
729 // on activation. So, we wait for activation.
730 // TODO(danakj): fix this. crbug.com/277953
731 layer_tree_host()->SetNeedsCommit();
732 break;
[email protected]9794fb32013-08-29 09:49:59733 case 5:
[email protected]28571b042013-03-14 07:59:15734 EXPECT_EQ(4, callback_count_);
[email protected]7096acc2013-06-18 21:12:43735 // Restore a mailbox for the next step.
736 SetMailbox('5');
737 break;
[email protected]9794fb32013-08-29 09:49:59738 case 6:
[email protected]7096acc2013-06-18 21:12:43739 // Case #5: remove layer from tree. Callback should *not* be called, the
740 // mailbox is returned to the main thread.
741 EXPECT_EQ(4, callback_count_);
742 layer_->RemoveFromParent();
743 break;
[email protected]9794fb32013-08-29 09:49:59744 case 7:
danakj431a1202015-06-17 19:09:33745 // With impl painting, the texture mailbox will still be on the impl
746 // thread when the commit finishes, because the layer is not around to
747 // block the commit on activation anymore. So, we wait for activation.
748 // TODO(danakj): fix this. crbug.com/277953
749 layer_tree_host()->SetNeedsCommit();
750 break;
[email protected]9794fb32013-08-29 09:49:59751 case 8:
[email protected]7096acc2013-06-18 21:12:43752 EXPECT_EQ(4, callback_count_);
753 // Resetting the mailbox will call the callback now.
danakj968153f32014-10-15 22:52:16754 layer_->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]7096acc2013-06-18 21:12:43755 EXPECT_EQ(5, callback_count_);
[email protected]e216fef02013-03-20 22:56:10756 EndTest();
[email protected]28571b042013-03-14 07:59:15757 break;
758 default:
759 NOTREACHED();
760 break;
[email protected]de44a152013-01-08 15:28:46761 }
[email protected]28571b042013-03-14 07:59:15762 }
[email protected]de44a152013-01-08 15:28:46763
dcheng716bedf2014-10-21 09:51:08764 void AfterTest() override {}
[email protected]de44a152013-01-08 15:28:46765
[email protected]28571b042013-03-14 07:59:15766 private:
[email protected]9794fb32013-08-29 09:49:59767 base::ThreadChecker main_thread_;
[email protected]28571b042013-03-14 07:59:15768 int callback_count_;
769 int commit_count_;
770 scoped_refptr<Layer> root_;
771 scoped_refptr<TextureLayer> layer_;
[email protected]de44a152013-01-08 15:28:46772};
773
[email protected]4145d172013-05-10 16:54:36774SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
775 TextureLayerImplWithMailboxThreadedCallback);
[email protected]de44a152013-01-08 15:28:46776
[email protected]74b43cc2013-08-30 06:29:27777
[email protected]74b43cc2013-08-30 06:29:27778class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest {
779 protected:
[email protected]98ea818e2014-01-24 10:22:08780 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {}
[email protected]74b43cc2013-08-30 06:29:27781
dyene5db881b2016-03-01 19:47:03782 static void ReleaseCallback(const gpu::SyncToken& original_sync_token,
783 const gpu::SyncToken& release_sync_token,
dyencc16ed4d2015-11-03 20:03:04784 bool lost_resource) {}
[email protected]74b43cc2013-08-30 06:29:27785
786 void SetMailbox(char mailbox_char) {
dyene5db881b2016-03-01 19:47:03787 const gpu::SyncToken sync_token =
788 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char));
danakj60bc3bc2016-04-09 00:24:48789 std::unique_ptr<SingleReleaseCallback> callback =
790 SingleReleaseCallback::Create(base::Bind(
791 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback,
792 sync_token));
dyencc16ed4d2015-11-03 20:03:04793 layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char),
dyene5db881b2016-03-01 19:47:03794 sync_token, GL_TEXTURE_2D),
danakja04855a2015-11-18 20:39:10795 std::move(callback));
[email protected]74b43cc2013-08-30 06:29:27796 }
797
dcheng716bedf2014-10-21 09:51:08798 void BeginTest() override {
[email protected]74b43cc2013-08-30 06:29:27799 gfx::Size bounds(100, 100);
loyso0940d412016-03-14 01:30:31800 root_ = Layer::Create();
[email protected]74b43cc2013-08-30 06:29:27801 root_->SetBounds(bounds);
802
loyso0940d412016-03-14 01:30:31803 layer_ = TextureLayer::CreateForMailbox(nullptr);
[email protected]74b43cc2013-08-30 06:29:27804 layer_->SetIsDrawable(true);
[email protected]74b43cc2013-08-30 06:29:27805 layer_->SetBounds(bounds);
806
807 root_->AddChild(layer_);
808 layer_tree_host()->SetRootLayer(root_);
809 layer_tree_host()->SetViewportSize(bounds);
810 SetMailbox('1');
811
812 PostSetNeedsCommitToMainThread();
813 }
814
dcheng716bedf2014-10-21 09:51:08815 void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override {
danakj3c3973b2015-08-25 21:50:18816 base::AutoLock lock(activate_count_lock_);
[email protected]74b43cc2013-08-30 06:29:27817 ++activate_count_;
818 }
819
dcheng716bedf2014-10-21 09:51:08820 void DidCommit() override {
danakj3c3973b2015-08-25 21:50:18821 // The first frame doesn't cause anything to be returned so it does not
822 // need to wait for activation.
823 if (layer_tree_host()->source_frame_number() > 1) {
824 base::AutoLock lock(activate_count_lock_);
825 // The activate happened before commit is done on the main side.
826 EXPECT_EQ(activate_count_, layer_tree_host()->source_frame_number());
827 }
828
[email protected]98ea818e2014-01-24 10:22:08829 switch (layer_tree_host()->source_frame_number()) {
[email protected]74b43cc2013-08-30 06:29:27830 case 1:
831 // The first mailbox has been activated. Set a new mailbox, and
832 // expect the next commit to finish *after* it is activated.
833 SetMailbox('2');
[email protected]74b43cc2013-08-30 06:29:27834 break;
835 case 2:
836 // The second mailbox has been activated. Remove the layer from
837 // the tree to cause another commit/activation. The commit should
838 // finish *after* the layer is removed from the active tree.
839 layer_->RemoveFromParent();
[email protected]74b43cc2013-08-30 06:29:27840 break;
841 case 3:
842 EndTest();
843 break;
844 }
845 }
846
dcheng716bedf2014-10-21 09:51:08847 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
danakj3c3973b2015-08-25 21:50:18848 // The activate didn't happen before commit is done on the impl side (but it
849 // should happen before the main thread is done).
850 EXPECT_EQ(activate_count_, host_impl->sync_tree()->source_frame_number());
[email protected]74b43cc2013-08-30 06:29:27851 }
852
dcheng716bedf2014-10-21 09:51:08853 void AfterTest() override {}
[email protected]74b43cc2013-08-30 06:29:27854
danakj3c3973b2015-08-25 21:50:18855 base::Lock activate_count_lock_;
[email protected]74b43cc2013-08-30 06:29:27856 int activate_count_;
857 scoped_refptr<Layer> root_;
858 scoped_refptr<TextureLayer> layer_;
859};
860
861SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
862 TextureLayerMailboxIsActivatedDuringCommit);
863
[email protected]de44a152013-01-08 15:28:46864class TextureLayerImplWithMailboxTest : public TextureLayerTest {
[email protected]28571b042013-03-14 07:59:15865 protected:
[email protected]408b5e22013-03-19 09:48:09866 TextureLayerImplWithMailboxTest()
867 : fake_client_(
868 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)) {}
869
dcheng93a52eb2014-12-23 02:14:23870 void SetUp() override {
[email protected]28571b042013-03-14 07:59:15871 TextureLayerTest::SetUp();
danakjcf610582015-06-16 22:48:56872 layer_tree_host_ =
873 MockLayerTreeHost::Create(&fake_client_, &task_graph_runner_);
sievers71c62dd52015-10-07 01:44:39874 host_impl_.SetVisible(true);
revemand180dfc32015-09-24 00:19:43875 EXPECT_TRUE(host_impl_.InitializeRenderer(output_surface_.get()));
[email protected]28571b042013-03-14 07:59:15876 }
[email protected]de44a152013-01-08 15:28:46877
[email protected]0ec335c42013-07-04 06:17:08878 bool WillDraw(TextureLayerImpl* layer, DrawMode mode) {
879 bool will_draw = layer->WillDraw(
880 mode, host_impl_.active_tree()->resource_provider());
881 if (will_draw)
882 layer->DidDraw(host_impl_.active_tree()->resource_provider());
883 return will_draw;
884 }
885
[email protected]408b5e22013-03-19 09:48:09886 FakeLayerTreeHostClient fake_client_;
[email protected]de44a152013-01-08 15:28:46887};
888
[email protected]ffbb2212013-06-02 23:47:59889// Test conditions for results of TextureLayerImpl::WillDraw under
890// different configurations of different mailbox, texture_id, and draw_mode.
891TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) {
skyostil3976a3f2014-09-04 22:07:23892 EXPECT_CALL(
893 test_data_.mock_callback_,
dyencc16ed4d2015-11-03 20:03:04894 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _))
[email protected]0ec335c42013-07-04 06:17:08895 .Times(AnyNumber());
dyencc16ed4d2015-11-03 20:03:04896 EXPECT_CALL(
897 test_data_.mock_callback_,
898 ReleaseImpl2(test_data_.shared_bitmap_.get(), gpu::SyncToken(), false, _))
[email protected]0ec335c42013-07-04 06:17:08899 .Times(AnyNumber());
[email protected]ffbb2212013-06-02 23:47:59900 // Hardware mode.
901 {
danakj60bc3bc2016-04-09 00:24:48902 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11903 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]9260757f2013-09-17 01:24:16904 impl_layer->SetTextureMailbox(
905 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:23906 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]0ec335c42013-07-04 06:17:08907 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
[email protected]ffbb2212013-06-02 23:47:59908 }
909
910 {
danakj60bc3bc2016-04-09 00:24:48911 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11912 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
danakj968153f32014-10-15 22:52:16913 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]0ec335c42013-07-04 06:17:08914 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
915 }
916
917 {
918 // Software resource.
danakj60bc3bc2016-04-09 00:24:48919 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11920 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]9260757f2013-09-17 01:24:16921 impl_layer->SetTextureMailbox(
922 test_data_.mailbox3_,
skyostil3976a3f2014-09-04 22:07:23923 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_));
[email protected]3e44d7a2013-07-30 00:03:10924 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
[email protected]ffbb2212013-06-02 23:47:59925 }
926
[email protected]0ec335c42013-07-04 06:17:08927 // Software mode.
928 {
danakj60bc3bc2016-04-09 00:24:48929 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11930 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]9260757f2013-09-17 01:24:16931 impl_layer->SetTextureMailbox(
932 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:23933 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]0ec335c42013-07-04 06:17:08934 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
935 }
936
937 {
danakj60bc3bc2016-04-09 00:24:48938 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11939 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
danakj968153f32014-10-15 22:52:16940 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]0ec335c42013-07-04 06:17:08941 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
942 }
943
944 {
945 // Software resource.
danakj60bc3bc2016-04-09 00:24:48946 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11947 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]9260757f2013-09-17 01:24:16948 impl_layer->SetTextureMailbox(
949 test_data_.mailbox3_,
skyostil3976a3f2014-09-04 22:07:23950 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_));
[email protected]0ec335c42013-07-04 06:17:08951 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
952 }
953
[email protected]ffbb2212013-06-02 23:47:59954 // Resourceless software mode.
955 {
danakj60bc3bc2016-04-09 00:24:48956 std::unique_ptr<TextureLayerImpl> impl_layer =
[email protected]17e08432014-04-10 00:41:11957 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]9260757f2013-09-17 01:24:16958 impl_layer->SetTextureMailbox(
959 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:23960 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]0ec335c42013-07-04 06:17:08961 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE));
[email protected]ffbb2212013-06-02 23:47:59962 }
[email protected]ffbb2212013-06-02 23:47:59963}
964
[email protected]28571b042013-03-14 07:59:15965TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) {
966 host_impl_.CreatePendingTree();
danakj60bc3bc2016-04-09 00:24:48967 std::unique_ptr<TextureLayerImpl> pending_layer;
[email protected]17e08432014-04-10 00:41:11968 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1);
[email protected]28571b042013-03-14 07:59:15969 ASSERT_TRUE(pending_layer);
[email protected]de44a152013-01-08 15:28:46970
danakj60bc3bc2016-04-09 00:24:48971 std::unique_ptr<LayerImpl> active_layer(
[email protected]28571b042013-03-14 07:59:15972 pending_layer->CreateLayerImpl(host_impl_.active_tree()));
[email protected]ed511b8d2013-03-25 03:29:29973 ASSERT_TRUE(active_layer);
[email protected]de44a152013-01-08 15:28:46974
[email protected]9260757f2013-09-17 01:24:16975 pending_layer->SetTextureMailbox(
976 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:23977 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]421e84f2013-02-22 03:27:15978
[email protected]28571b042013-03-14 07:59:15979 // Test multiple commits without an activation.
skyostil3976a3f2014-09-04 22:07:23980 EXPECT_CALL(
981 test_data_.mock_callback_,
dyencc16ed4d2015-11-03 20:03:04982 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _))
[email protected]28571b042013-03-14 07:59:15983 .Times(1);
[email protected]9260757f2013-09-17 01:24:16984 pending_layer->SetTextureMailbox(
985 test_data_.mailbox2_,
skyostil3976a3f2014-09-04 22:07:23986 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox2_impl_));
[email protected]28571b042013-03-14 07:59:15987 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]421e84f2013-02-22 03:27:15988
[email protected]28571b042013-03-14 07:59:15989 // Test callback after activation.
[email protected]ed511b8d2013-03-25 03:29:29990 pending_layer->PushPropertiesTo(active_layer.get());
991 active_layer->DidBecomeActive();
[email protected]421e84f2013-02-22 03:27:15992
skyostil3976a3f2014-09-04 22:07:23993 EXPECT_CALL(test_data_.mock_callback_, ReleaseImpl(_, _, _, _)).Times(0);
[email protected]9260757f2013-09-17 01:24:16994 pending_layer->SetTextureMailbox(
995 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:23996 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]28571b042013-03-14 07:59:15997 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]421e84f2013-02-22 03:27:15998
[email protected]7ba3ca72013-04-11 06:37:25999 EXPECT_CALL(test_data_.mock_callback_,
skyostil3976a3f2014-09-04 22:07:231000 ReleaseImpl(test_data_.mailbox_name2_, _, false, _)).Times(1);
[email protected]ed511b8d2013-03-25 03:29:291001 pending_layer->PushPropertiesTo(active_layer.get());
1002 active_layer->DidBecomeActive();
[email protected]28571b042013-03-14 07:59:151003 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]de44a152013-01-08 15:28:461004
[email protected]28571b042013-03-14 07:59:151005 // Test resetting the mailbox.
[email protected]7ba3ca72013-04-11 06:37:251006 EXPECT_CALL(test_data_.mock_callback_,
skyostil3976a3f2014-09-04 22:07:231007 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1);
danakj968153f32014-10-15 22:52:161008 pending_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]ed511b8d2013-03-25 03:29:291009 pending_layer->PushPropertiesTo(active_layer.get());
1010 active_layer->DidBecomeActive();
[email protected]28571b042013-03-14 07:59:151011 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]de44a152013-01-08 15:28:461012
[email protected]28571b042013-03-14 07:59:151013 // Test destructor.
skyostil3976a3f2014-09-04 22:07:231014 EXPECT_CALL(
1015 test_data_.mock_callback_,
dyencc16ed4d2015-11-03 20:03:041016 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _))
[email protected]28571b042013-03-14 07:59:151017 .Times(1);
[email protected]9260757f2013-09-17 01:24:161018 pending_layer->SetTextureMailbox(
1019 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:231020 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]de44a152013-01-08 15:28:461021}
1022
[email protected]28571b042013-03-14 07:59:151023TEST_F(TextureLayerImplWithMailboxTest,
1024 TestDestructorCallbackOnCreatedResource) {
danakj60bc3bc2016-04-09 00:24:481025 std::unique_ptr<TextureLayerImpl> impl_layer;
[email protected]17e08432014-04-10 00:41:111026 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1);
[email protected]28571b042013-03-14 07:59:151027 ASSERT_TRUE(impl_layer);
[email protected]de44a152013-01-08 15:28:461028
[email protected]7ba3ca72013-04-11 06:37:251029 EXPECT_CALL(test_data_.mock_callback_,
skyostil3976a3f2014-09-04 22:07:231030 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1);
[email protected]9260757f2013-09-17 01:24:161031 impl_layer->SetTextureMailbox(
1032 test_data_.mailbox1_,
skyostil3976a3f2014-09-04 22:07:231033 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]ffbb2212013-06-02 23:47:591034 impl_layer->DidBecomeActive();
1035 EXPECT_TRUE(impl_layer->WillDraw(
1036 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider()));
[email protected]28571b042013-03-14 07:59:151037 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider());
danakj968153f32014-10-15 22:52:161038 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr);
[email protected]de44a152013-01-08 15:28:461039}
1040
[email protected]28571b042013-03-14 07:59:151041TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) {
1042 ResourceProvider* provider = host_impl_.active_tree()->resource_provider();
jbaumanbbd425e2015-05-19 00:33:351043 ResourceId id = provider->CreateResourceFromTextureMailbox(
skyostil3976a3f2014-09-04 22:07:231044 test_data_.mailbox1_,
1045 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
[email protected]28571b042013-03-14 07:59:151046 provider->AllocateForTesting(id);
[email protected]de44a152013-01-08 15:28:461047
[email protected]28571b042013-03-14 07:59:151048 // Transfer some resources to the parent.
1049 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1050 resource_ids_to_transfer.push_back(id);
1051 TransferableResourceArray list;
1052 provider->PrepareSendToParent(resource_ids_to_transfer, &list);
1053 EXPECT_TRUE(provider->InUseByConsumer(id));
skyostil3976a3f2014-09-04 22:07:231054 EXPECT_CALL(test_data_.mock_callback_, ReleaseImpl(_, _, _, _)).Times(0);
[email protected]28571b042013-03-14 07:59:151055 provider->DeleteResource(id);
1056 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
[email protected]7ba3ca72013-04-11 06:37:251057 EXPECT_CALL(test_data_.mock_callback_,
skyostil3976a3f2014-09-04 22:07:231058 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1);
[email protected]e00bab022013-08-19 00:42:451059 ReturnedResourceArray returned;
1060 TransferableResource::ReturnResources(list, &returned);
1061 provider->ReceiveReturnsFromParent(returned);
[email protected]de44a152013-01-08 15:28:461062}
1063
[email protected]4bad8b62013-10-24 01:27:291064// Checks that TextureLayer::Update does not cause an extra commit when setting
1065// the texture mailbox.
1066class TextureLayerNoExtraCommitForMailboxTest
1067 : public LayerTreeTest,
1068 public TextureLayerClient {
1069 public:
[email protected]4bad8b62013-10-24 01:27:291070 // TextureLayerClient implementation.
dcheng716bedf2014-10-21 09:51:081071 bool PrepareTextureMailbox(
[email protected]df41e252014-02-03 23:39:501072 TextureMailbox* texture_mailbox,
danakj60bc3bc2016-04-09 00:24:481073 std::unique_ptr<SingleReleaseCallback>* release_callback,
mostynbf68776d82014-10-06 18:07:371074 bool use_shared_memory) override {
[email protected]cce34bd2013-12-02 23:24:451075 if (layer_tree_host()->source_frame_number() == 1) {
[email protected]9f35bd22014-06-03 15:25:461076 // Once this has been committed, the mailbox will be released.
[email protected]df41e252014-02-03 23:39:501077 *texture_mailbox = TextureMailbox();
[email protected]cce34bd2013-12-02 23:24:451078 return true;
1079 }
[email protected]4bad8b62013-10-24 01:27:291080
dyene5db881b2016-03-01 19:47:031081 *texture_mailbox = TextureMailbox(MailboxFromChar('1'),
1082 SyncTokenFromUInt(0x123), GL_TEXTURE_2D);
[email protected]4bad8b62013-10-24 01:27:291083 *release_callback = SingleReleaseCallback::Create(
1084 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased,
1085 base::Unretained(this)));
[email protected]4bad8b62013-10-24 01:27:291086 return true;
1087 }
1088
dyencc16ed4d2015-11-03 20:03:041089 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
[email protected]9f35bd22014-06-03 15:25:461090 // Source frame number during callback is the same as the source frame
1091 // on which it was released.
1092 EXPECT_EQ(1, layer_tree_host()->source_frame_number());
dyene5db881b2016-03-01 19:47:031093 EXPECT_TRUE(sync_token.HasData());
[email protected]cce34bd2013-12-02 23:24:451094 EndTest();
[email protected]4bad8b62013-10-24 01:27:291095 }
1096
dcheng716bedf2014-10-21 09:51:081097 void SetupTree() override {
loyso0940d412016-03-14 01:30:311098 scoped_refptr<Layer> root = Layer::Create();
[email protected]4bad8b62013-10-24 01:27:291099 root->SetBounds(gfx::Size(10, 10));
[email protected]4bad8b62013-10-24 01:27:291100 root->SetIsDrawable(true);
1101
loyso0940d412016-03-14 01:30:311102 texture_layer_ = TextureLayer::CreateForMailbox(this);
[email protected]4bad8b62013-10-24 01:27:291103 texture_layer_->SetBounds(gfx::Size(10, 10));
[email protected]4bad8b62013-10-24 01:27:291104 texture_layer_->SetIsDrawable(true);
[email protected]0d7fb302014-01-23 21:30:471105 root->AddChild(texture_layer_);
[email protected]4bad8b62013-10-24 01:27:291106
1107 layer_tree_host()->SetRootLayer(root);
1108 LayerTreeTest::SetupTree();
1109 }
1110
dcheng716bedf2014-10-21 09:51:081111 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
[email protected]4bad8b62013-10-24 01:27:291112
dcheng716bedf2014-10-21 09:51:081113 void DidCommitAndDrawFrame() override {
[email protected]4bad8b62013-10-24 01:27:291114 switch (layer_tree_host()->source_frame_number()) {
1115 case 1:
[email protected]4ea293f72014-08-13 03:03:171116 EXPECT_FALSE(proxy()->MainFrameWillHappenForTesting());
[email protected]cce34bd2013-12-02 23:24:451117 // Invalidate the texture layer to clear the mailbox before
1118 // ending the test.
1119 texture_layer_->SetNeedsDisplay();
1120 break;
1121 case 2:
[email protected]4bad8b62013-10-24 01:27:291122 break;
1123 default:
1124 NOTREACHED();
1125 break;
1126 }
1127 }
1128
dcheng716bedf2014-10-21 09:51:081129 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
[email protected]cce34bd2013-12-02 23:24:451130 ASSERT_TRUE(result);
1131 DelegatedFrameData* delegated_frame_data =
1132 output_surface()->last_sent_frame().delegated_frame_data.get();
1133 if (!delegated_frame_data)
1134 return;
1135
1136 // Return all resources immediately.
1137 TransferableResourceArray resources_to_return =
1138 output_surface()->resources_held_by_parent();
1139
1140 CompositorFrameAck ack;
1141 for (size_t i = 0; i < resources_to_return.size(); ++i)
1142 output_surface()->ReturnResource(resources_to_return[i].id, &ack);
1143 host_impl->ReclaimResources(&ack);
[email protected]cce34bd2013-12-02 23:24:451144 }
1145
dcheng716bedf2014-10-21 09:51:081146 void AfterTest() override {}
[email protected]4bad8b62013-10-24 01:27:291147
1148 private:
[email protected]4bad8b62013-10-24 01:27:291149 scoped_refptr<TextureLayer> texture_layer_;
[email protected]4bad8b62013-10-24 01:27:291150};
1151
[email protected]cce34bd2013-12-02 23:24:451152SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerNoExtraCommitForMailboxTest);
[email protected]4bad8b62013-10-24 01:27:291153
[email protected]b04264f92013-09-13 23:37:291154// Checks that changing a mailbox in the client for a TextureLayer that's
1155// invisible correctly works and uses the new mailbox as soon as the layer
1156// becomes visible (and returns the old one).
1157class TextureLayerChangeInvisibleMailboxTest
1158 : public LayerTreeTest,
1159 public TextureLayerClient {
1160 public:
1161 TextureLayerChangeInvisibleMailboxTest()
1162 : mailbox_changed_(true),
1163 mailbox_returned_(0),
1164 prepare_called_(0),
1165 commit_count_(0) {
1166 mailbox_ = MakeMailbox('1');
1167 }
1168
1169 // TextureLayerClient implementation.
dcheng716bedf2014-10-21 09:51:081170 bool PrepareTextureMailbox(
[email protected]e51444a2013-12-10 23:05:011171 TextureMailbox* mailbox,
danakj60bc3bc2016-04-09 00:24:481172 std::unique_ptr<SingleReleaseCallback>* release_callback,
mostynbf68776d82014-10-06 18:07:371173 bool use_shared_memory) override {
[email protected]b04264f92013-09-13 23:37:291174 ++prepare_called_;
1175 if (!mailbox_changed_)
1176 return false;
1177 *mailbox = mailbox_;
[email protected]9260757f2013-09-17 01:24:161178 *release_callback = SingleReleaseCallback::Create(
1179 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased,
1180 base::Unretained(this)));
[email protected]b04264f92013-09-13 23:37:291181 return true;
1182 }
1183
1184 TextureMailbox MakeMailbox(char name) {
dyene5db881b2016-03-01 19:47:031185 return TextureMailbox(MailboxFromChar(name),
1186 SyncTokenFromUInt(static_cast<uint32_t>(name)),
dyencc16ed4d2015-11-03 20:03:041187 GL_TEXTURE_2D);
[email protected]b04264f92013-09-13 23:37:291188 }
1189
dyencc16ed4d2015-11-03 20:03:041190 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
dyene5db881b2016-03-01 19:47:031191 EXPECT_TRUE(sync_token.HasData());
[email protected]b04264f92013-09-13 23:37:291192 ++mailbox_returned_;
1193 }
1194
dcheng716bedf2014-10-21 09:51:081195 void SetupTree() override {
loyso0940d412016-03-14 01:30:311196 scoped_refptr<Layer> root = Layer::Create();
[email protected]b04264f92013-09-13 23:37:291197 root->SetBounds(gfx::Size(10, 10));
[email protected]b04264f92013-09-13 23:37:291198 root->SetIsDrawable(true);
1199
loyso0940d412016-03-14 01:30:311200 solid_layer_ = SolidColorLayer::Create();
[email protected]b04264f92013-09-13 23:37:291201 solid_layer_->SetBounds(gfx::Size(10, 10));
1202 solid_layer_->SetIsDrawable(true);
1203 solid_layer_->SetBackgroundColor(SK_ColorWHITE);
1204 root->AddChild(solid_layer_);
1205
loyso0940d412016-03-14 01:30:311206 parent_layer_ = Layer::Create();
[email protected]b04264f92013-09-13 23:37:291207 parent_layer_->SetBounds(gfx::Size(10, 10));
1208 parent_layer_->SetIsDrawable(true);
1209 root->AddChild(parent_layer_);
1210
loyso0940d412016-03-14 01:30:311211 texture_layer_ = TextureLayer::CreateForMailbox(this);
[email protected]b04264f92013-09-13 23:37:291212 texture_layer_->SetBounds(gfx::Size(10, 10));
[email protected]b04264f92013-09-13 23:37:291213 texture_layer_->SetIsDrawable(true);
1214 parent_layer_->AddChild(texture_layer_);
1215
1216 layer_tree_host()->SetRootLayer(root);
1217 LayerTreeTest::SetupTree();
1218 }
1219
dcheng716bedf2014-10-21 09:51:081220 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
[email protected]b04264f92013-09-13 23:37:291221
dcheng716bedf2014-10-21 09:51:081222 void DidCommitAndDrawFrame() override {
[email protected]b04264f92013-09-13 23:37:291223 ++commit_count_;
1224 switch (commit_count_) {
1225 case 1:
1226 // We should have updated the layer, committing the texture.
1227 EXPECT_EQ(1, prepare_called_);
1228 // Make layer invisible.
1229 parent_layer_->SetOpacity(0.f);
1230 break;
1231 case 2:
1232 // Layer shouldn't have been updated.
1233 EXPECT_EQ(1, prepare_called_);
1234 // Change the texture.
1235 mailbox_ = MakeMailbox('2');
1236 mailbox_changed_ = true;
1237 texture_layer_->SetNeedsDisplay();
1238 // Force a change to make sure we draw a frame.
1239 solid_layer_->SetBackgroundColor(SK_ColorGRAY);
1240 break;
1241 case 3:
1242 // Layer shouldn't have been updated.
1243 EXPECT_EQ(1, prepare_called_);
1244 // So the old mailbox isn't returned yet.
1245 EXPECT_EQ(0, mailbox_returned_);
1246 // Make layer visible again.
1247 parent_layer_->SetOpacity(1.f);
1248 break;
1249 case 4:
1250 // Layer should have been updated.
1251 EXPECT_EQ(2, prepare_called_);
1252 // So the old mailbox should have been returned already.
1253 EXPECT_EQ(1, mailbox_returned_);
1254 texture_layer_->ClearClient();
1255 break;
1256 case 5:
1257 EXPECT_EQ(2, mailbox_returned_);
1258 EndTest();
1259 break;
1260 default:
1261 NOTREACHED();
1262 break;
1263 }
1264 }
1265
dcheng716bedf2014-10-21 09:51:081266 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
[email protected]b04264f92013-09-13 23:37:291267 ASSERT_TRUE(result);
1268 DelegatedFrameData* delegated_frame_data =
1269 output_surface()->last_sent_frame().delegated_frame_data.get();
1270 if (!delegated_frame_data)
1271 return;
1272
1273 // Return all resources immediately.
1274 TransferableResourceArray resources_to_return =
1275 output_surface()->resources_held_by_parent();
1276
1277 CompositorFrameAck ack;
1278 for (size_t i = 0; i < resources_to_return.size(); ++i)
1279 output_surface()->ReturnResource(resources_to_return[i].id, &ack);
[email protected]a7335e0b2013-09-18 09:34:511280 host_impl->ReclaimResources(&ack);
[email protected]b04264f92013-09-13 23:37:291281 }
1282
dcheng716bedf2014-10-21 09:51:081283 void AfterTest() override {}
[email protected]b04264f92013-09-13 23:37:291284
1285 private:
1286 scoped_refptr<SolidColorLayer> solid_layer_;
1287 scoped_refptr<Layer> parent_layer_;
1288 scoped_refptr<TextureLayer> texture_layer_;
1289
1290 // Used on the main thread.
1291 bool mailbox_changed_;
1292 TextureMailbox mailbox_;
1293 int mailbox_returned_;
1294 int prepare_called_;
1295 int commit_count_;
1296};
1297
1298SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerChangeInvisibleMailboxTest);
1299
[email protected]0d7fb302014-01-23 21:30:471300// Test that TextureLayerImpl::ReleaseResources can be called which releases
1301// the mailbox back to TextureLayerClient.
1302class TextureLayerReleaseResourcesBase
1303 : public LayerTreeTest,
1304 public TextureLayerClient {
1305 public:
1306 // TextureLayerClient implementation.
dcheng716bedf2014-10-21 09:51:081307 bool PrepareTextureMailbox(
[email protected]0d7fb302014-01-23 21:30:471308 TextureMailbox* mailbox,
danakj60bc3bc2016-04-09 00:24:481309 std::unique_ptr<SingleReleaseCallback>* release_callback,
mostynbf68776d82014-10-06 18:07:371310 bool use_shared_memory) override {
dyene5db881b2016-03-01 19:47:031311 *mailbox = TextureMailbox(MailboxFromChar('1'), SyncTokenFromUInt(1),
1312 GL_TEXTURE_2D);
[email protected]0d7fb302014-01-23 21:30:471313 *release_callback = SingleReleaseCallback::Create(
1314 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased,
1315 base::Unretained(this)));
1316 return true;
1317 }
1318
dyencc16ed4d2015-11-03 20:03:041319 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
[email protected]0d7fb302014-01-23 21:30:471320 mailbox_released_ = true;
1321 }
1322
dcheng716bedf2014-10-21 09:51:081323 void SetupTree() override {
[email protected]0d7fb302014-01-23 21:30:471324 LayerTreeTest::SetupTree();
1325
1326 scoped_refptr<TextureLayer> texture_layer =
loyso0940d412016-03-14 01:30:311327 TextureLayer::CreateForMailbox(this);
[email protected]0d7fb302014-01-23 21:30:471328 texture_layer->SetBounds(gfx::Size(10, 10));
[email protected]0d7fb302014-01-23 21:30:471329 texture_layer->SetIsDrawable(true);
1330
1331 layer_tree_host()->root_layer()->AddChild(texture_layer);
jaydasikabd6f15a2016-04-21 19:45:371332 texture_layer_id_ = texture_layer->id();
[email protected]0d7fb302014-01-23 21:30:471333 }
1334
dcheng716bedf2014-10-21 09:51:081335 void BeginTest() override {
[email protected]0d7fb302014-01-23 21:30:471336 mailbox_released_ = false;
1337 PostSetNeedsCommitToMainThread();
1338 }
1339
dcheng716bedf2014-10-21 09:51:081340 void DidCommitAndDrawFrame() override { EndTest(); }
[email protected]0d7fb302014-01-23 21:30:471341
dcheng716bedf2014-10-21 09:51:081342 void AfterTest() override { EXPECT_TRUE(mailbox_released_); }
[email protected]0d7fb302014-01-23 21:30:471343
jaydasikabd6f15a2016-04-21 19:45:371344 protected:
1345 int texture_layer_id_;
1346
[email protected]0d7fb302014-01-23 21:30:471347 private:
1348 bool mailbox_released_;
1349};
1350
1351class TextureLayerReleaseResourcesAfterCommit
1352 : public TextureLayerReleaseResourcesBase {
1353 public:
dcheng716bedf2014-10-21 09:51:081354 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
kulkarni.a4015690f12014-10-10 13:50:061355 LayerTreeImpl* tree = nullptr;
danakj009cdfdf2015-02-17 22:35:141356 tree = host_impl->sync_tree();
jaydasikabd6f15a2016-04-21 19:45:371357 tree->LayerById(texture_layer_id_)->ReleaseResources();
[email protected]0d7fb302014-01-23 21:30:471358 }
1359};
1360
1361SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterCommit);
1362
1363class TextureLayerReleaseResourcesAfterActivate
1364 : public TextureLayerReleaseResourcesBase {
1365 public:
dcheng716bedf2014-10-21 09:51:081366 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
jaydasikabd6f15a2016-04-21 19:45:371367 host_impl->active_tree()->LayerById(texture_layer_id_)->ReleaseResources();
[email protected]0d7fb302014-01-23 21:30:471368 }
1369};
1370
1371SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterActivate);
1372
[email protected]9c2bd822013-07-26 12:30:171373class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest {
1374 public:
dyencc16ed4d2015-11-03 20:03:041375 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
[email protected]9794fb32013-08-29 09:49:591376 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
[email protected]9c2bd822013-07-26 12:30:171377 EXPECT_FALSE(lost_resource);
1378 ++callback_count_;
1379 EndTest();
1380 }
1381
1382 void SetMailbox(char mailbox_char) {
[email protected]9794fb32013-08-29 09:49:591383 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
danakj60bc3bc2016-04-09 00:24:481384 std::unique_ptr<SingleReleaseCallback> callback =
1385 SingleReleaseCallback::Create(base::Bind(
[email protected]9c2bd822013-07-26 12:30:171386 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback,
1387 base::Unretained(this)));
dyene5db881b2016-03-01 19:47:031388 layer_->SetTextureMailbox(
1389 TextureMailbox(MailboxFromChar(mailbox_char),
1390 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)),
1391 GL_TEXTURE_2D),
1392 std::move(callback));
[email protected]9c2bd822013-07-26 12:30:171393 }
1394
dcheng716bedf2014-10-21 09:51:081395 void SetupTree() override {
[email protected]9c2bd822013-07-26 12:30:171396 gfx::Size bounds(100, 100);
loyso0940d412016-03-14 01:30:311397 root_ = Layer::Create();
[email protected]9c2bd822013-07-26 12:30:171398 root_->SetBounds(bounds);
1399
loyso0940d412016-03-14 01:30:311400 layer_ = TextureLayer::CreateForMailbox(nullptr);
[email protected]9c2bd822013-07-26 12:30:171401 layer_->SetIsDrawable(true);
[email protected]9c2bd822013-07-26 12:30:171402 layer_->SetBounds(bounds);
1403
1404 root_->AddChild(layer_);
1405 layer_tree_host()->SetRootLayer(root_);
1406 layer_tree_host()->SetViewportSize(bounds);
1407 }
1408
dcheng716bedf2014-10-21 09:51:081409 void BeginTest() override {
[email protected]9794fb32013-08-29 09:49:591410 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1411
[email protected]9c2bd822013-07-26 12:30:171412 callback_count_ = 0;
1413
1414 // Set the mailbox on the main thread.
1415 SetMailbox('1');
1416 EXPECT_EQ(0, callback_count_);
1417
1418 PostSetNeedsCommitToMainThread();
1419 }
1420
dcheng716bedf2014-10-21 09:51:081421 void DidCommitAndDrawFrame() override {
[email protected]9c2bd822013-07-26 12:30:171422 switch (layer_tree_host()->source_frame_number()) {
1423 case 1:
1424 // Delete the TextureLayer on the main thread while the mailbox is in
1425 // the impl tree.
1426 layer_->RemoveFromParent();
kulkarni.a4015690f12014-10-10 13:50:061427 layer_ = nullptr;
[email protected]9c2bd822013-07-26 12:30:171428 break;
1429 }
1430 }
1431
dcheng716bedf2014-10-21 09:51:081432 void AfterTest() override { EXPECT_EQ(1, callback_count_); }
[email protected]9c2bd822013-07-26 12:30:171433
1434 private:
[email protected]9794fb32013-08-29 09:49:591435 base::ThreadChecker main_thread_;
[email protected]9c2bd822013-07-26 12:30:171436 int callback_count_;
1437 scoped_refptr<Layer> root_;
1438 scoped_refptr<TextureLayer> layer_;
1439};
1440
1441SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1442 TextureLayerWithMailboxMainThreadDeleted);
1443
1444class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest {
1445 public:
dyencc16ed4d2015-11-03 20:03:041446 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
[email protected]9794fb32013-08-29 09:49:591447 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
[email protected]9c2bd822013-07-26 12:30:171448 EXPECT_FALSE(lost_resource);
1449 ++callback_count_;
1450 EndTest();
1451 }
1452
1453 void SetMailbox(char mailbox_char) {
[email protected]9794fb32013-08-29 09:49:591454 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
danakj60bc3bc2016-04-09 00:24:481455 std::unique_ptr<SingleReleaseCallback> callback =
1456 SingleReleaseCallback::Create(base::Bind(
[email protected]9c2bd822013-07-26 12:30:171457 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback,
1458 base::Unretained(this)));
dyene5db881b2016-03-01 19:47:031459 layer_->SetTextureMailbox(
1460 TextureMailbox(MailboxFromChar(mailbox_char),
1461 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)),
1462 GL_TEXTURE_2D),
1463 std::move(callback));
[email protected]9c2bd822013-07-26 12:30:171464 }
1465
dcheng716bedf2014-10-21 09:51:081466 void SetupTree() override {
[email protected]9c2bd822013-07-26 12:30:171467 gfx::Size bounds(100, 100);
loyso0940d412016-03-14 01:30:311468 root_ = Layer::Create();
[email protected]9c2bd822013-07-26 12:30:171469 root_->SetBounds(bounds);
1470
loyso0940d412016-03-14 01:30:311471 layer_ = TextureLayer::CreateForMailbox(nullptr);
[email protected]9c2bd822013-07-26 12:30:171472 layer_->SetIsDrawable(true);
[email protected]9c2bd822013-07-26 12:30:171473 layer_->SetBounds(bounds);
1474
1475 root_->AddChild(layer_);
1476 layer_tree_host()->SetRootLayer(root_);
1477 layer_tree_host()->SetViewportSize(bounds);
1478 }
1479
dcheng716bedf2014-10-21 09:51:081480 void BeginTest() override {
[email protected]9794fb32013-08-29 09:49:591481 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1482
[email protected]9c2bd822013-07-26 12:30:171483 callback_count_ = 0;
1484
1485 // Set the mailbox on the main thread.
1486 SetMailbox('1');
1487 EXPECT_EQ(0, callback_count_);
1488
1489 PostSetNeedsCommitToMainThread();
1490 }
1491
dcheng716bedf2014-10-21 09:51:081492 void DidCommitAndDrawFrame() override {
[email protected]9c2bd822013-07-26 12:30:171493 switch (layer_tree_host()->source_frame_number()) {
1494 case 1:
1495 // Remove the TextureLayer on the main thread while the mailbox is in
1496 // the impl tree, but don't delete the TextureLayer until after the impl
1497 // tree side is deleted.
1498 layer_->RemoveFromParent();
1499 break;
1500 case 2:
kulkarni.a4015690f12014-10-10 13:50:061501 layer_ = nullptr;
[email protected]9c2bd822013-07-26 12:30:171502 break;
1503 }
1504 }
1505
dcheng716bedf2014-10-21 09:51:081506 void AfterTest() override { EXPECT_EQ(1, callback_count_); }
[email protected]9c2bd822013-07-26 12:30:171507
1508 private:
[email protected]9794fb32013-08-29 09:49:591509 base::ThreadChecker main_thread_;
[email protected]9c2bd822013-07-26 12:30:171510 int callback_count_;
1511 scoped_refptr<Layer> root_;
1512 scoped_refptr<TextureLayer> layer_;
1513};
1514
1515SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1516 TextureLayerWithMailboxImplThreadDeleted);
1517
[email protected]ba565742012-11-10 09:29:481518} // namespace
1519} // namespace cc