Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: cc/layers/texture_layer_unittest.cc

Issue 227413011: Remove old texture path in TextureLayer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/texture_layer_impl_unittest.cc ('k') | cc/scheduler/scheduler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/texture_layer.h" 5 #include "cc/layers/texture_layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 return mailbox; 48 return mailbox;
49 } 49 }
50 50
51 class MockLayerTreeHost : public LayerTreeHost { 51 class MockLayerTreeHost : public LayerTreeHost {
52 public: 52 public:
53 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) 53 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client)
54 : LayerTreeHost(client, NULL, LayerTreeSettings()) { 54 : LayerTreeHost(client, NULL, LayerTreeSettings()) {
55 InitializeSingleThreaded(client); 55 InitializeSingleThreaded(client);
56 } 56 }
57 57
58 MOCK_METHOD0(AcquireLayerTextures, void());
59 MOCK_METHOD0(SetNeedsCommit, void()); 58 MOCK_METHOD0(SetNeedsCommit, void());
60 MOCK_METHOD0(SetNeedsUpdateLayers, void()); 59 MOCK_METHOD0(SetNeedsUpdateLayers, void());
61 MOCK_METHOD0(StartRateLimiter, void()); 60 MOCK_METHOD0(StartRateLimiter, void());
62 MOCK_METHOD0(StopRateLimiter, void()); 61 MOCK_METHOD0(StopRateLimiter, void());
63 }; 62 };
64 63
65 class FakeTextureLayerClient : public TextureLayerClient { 64 class FakeTextureLayerClient : public TextureLayerClient {
66 public: 65 public:
67 FakeTextureLayerClient() : texture_(0), mailbox_changed_(true) {} 66 FakeTextureLayerClient() : mailbox_changed_(true) {}
68
69 virtual unsigned PrepareTexture() OVERRIDE { return texture_; }
70 67
71 virtual bool PrepareTextureMailbox( 68 virtual bool PrepareTextureMailbox(
72 TextureMailbox* mailbox, 69 TextureMailbox* mailbox,
73 scoped_ptr<SingleReleaseCallback>* release_callback, 70 scoped_ptr<SingleReleaseCallback>* release_callback,
74 bool use_shared_memory) OVERRIDE { 71 bool use_shared_memory) OVERRIDE {
75 if (!mailbox_changed_) 72 if (!mailbox_changed_)
76 return false; 73 return false;
77 74
78 *mailbox = mailbox_; 75 *mailbox = mailbox_;
79 *release_callback = release_callback_.Pass(); 76 *release_callback = release_callback_.Pass();
80 mailbox_changed_ = false; 77 mailbox_changed_ = false;
81 return true; 78 return true;
82 } 79 }
83 80
84 void set_texture(unsigned texture) { texture_ = texture; }
85
86 void set_mailbox(const TextureMailbox& mailbox, 81 void set_mailbox(const TextureMailbox& mailbox,
87 scoped_ptr<SingleReleaseCallback> release_callback) { 82 scoped_ptr<SingleReleaseCallback> release_callback) {
88 mailbox_ = mailbox; 83 mailbox_ = mailbox;
89 release_callback_ = release_callback.Pass(); 84 release_callback_ = release_callback.Pass();
90 mailbox_changed_ = true; 85 mailbox_changed_ = true;
91 } 86 }
92 87
93 private: 88 private:
94 unsigned texture_;
95 TextureMailbox mailbox_; 89 TextureMailbox mailbox_;
96 scoped_ptr<SingleReleaseCallback> release_callback_; 90 scoped_ptr<SingleReleaseCallback> release_callback_;
97 bool mailbox_changed_; 91 bool mailbox_changed_;
98 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient); 92 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient);
99 }; 93 };
100 94
101 class MockMailboxCallback { 95 class MockMailboxCallback {
102 public: 96 public:
103 MOCK_METHOD3(Release, 97 MOCK_METHOD3(Release,
104 void(const gpu::Mailbox& mailbox, 98 void(const gpu::Mailbox& mailbox,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 protected: 153 protected:
160 virtual void SetUp() { 154 virtual void SetUp() {
161 layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_)); 155 layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_));
162 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); 156 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
163 layer_tree_host_->SetViewportSize(gfx::Size(10, 10)); 157 layer_tree_host_->SetViewportSize(gfx::Size(10, 10));
164 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 158 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
165 } 159 }
166 160
167 virtual void TearDown() { 161 virtual void TearDown() {
168 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 162 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
169 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AnyNumber());
170 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); 163 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
171 164
172 layer_tree_host_->SetRootLayer(NULL); 165 layer_tree_host_->SetRootLayer(NULL);
173 layer_tree_host_.reset(); 166 layer_tree_host_.reset();
174 } 167 }
175 168
176 scoped_ptr<MockLayerTreeHost> layer_tree_host_; 169 scoped_ptr<MockLayerTreeHost> layer_tree_host_;
177 FakeImplProxy proxy_; 170 FakeImplProxy proxy_;
178 FakeLayerTreeHostClient fake_client_; 171 FakeLayerTreeHostClient fake_client_;
179 TestSharedBitmapManager shared_bitmap_manager_; 172 TestSharedBitmapManager shared_bitmap_manager_;
180 FakeLayerTreeHostImpl host_impl_; 173 FakeLayerTreeHostImpl host_impl_;
181 }; 174 };
182 175
183 TEST_F(TextureLayerTest, SyncImplWhenClearingTexture) {
184 scoped_ptr<TestWebGraphicsContext3D> context(
185 TestWebGraphicsContext3D::Create());
186 FakeTextureLayerClient client;
187 scoped_refptr<TextureLayer> test_layer = TextureLayer::Create(&client);
188 ASSERT_TRUE(test_layer.get());
189 test_layer->SetIsDrawable(true);
190 test_layer->SetBounds(gfx::Size(10, 10));
191
192 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
193 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
194 layer_tree_host_->SetRootLayer(test_layer);
195 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
196 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get());
197
198 // Clearing the texture before we gave one should not sync.
199 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
200 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
201 test_layer->ClearTexture();
202 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
203
204 // Give a texture to the layer through the client.
205 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
206 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(AtLeast(1));
207 client.set_texture(context->createTexture());
208 test_layer->SetNeedsDisplay();
209 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
210 // Force a commit.
211 layer_tree_host_->Composite(base::TimeTicks());
212
213 // Clearing the texture should sync.
214 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AtLeast(1));
215 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
216 test_layer->ClearTexture();
217 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
218
219 // But only once.
220 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
221 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
222 test_layer->ClearTexture();
223 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
224
225 // Force a commit to give another texture.
226 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(AtLeast(1));
227 test_layer->SetNeedsDisplay();
228 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
229 layer_tree_host_->Composite(base::TimeTicks());
230
231 // Make undrawable and commit.
232 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
233 test_layer->SetIsDrawable(false);
234 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
235 layer_tree_host_->Composite(base::TimeTicks());
236
237 // Clearing textures should not sync.
238 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
239 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
240 test_layer->ClearTexture();
241 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
242 }
243
244 TEST_F(TextureLayerTest, SyncImplWhenClearingMailbox) {
245 CommonMailboxObjects mailboxes;
246 FakeTextureLayerClient client;
247 scoped_refptr<TextureLayer> test_layer =
248 TextureLayer::CreateForMailbox(&client);
249 ASSERT_TRUE(test_layer.get());
250 test_layer->SetIsDrawable(true);
251 test_layer->SetBounds(gfx::Size(10, 10));
252 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
253 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
254 layer_tree_host_->SetRootLayer(test_layer);
255 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
256 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get());
257
258 // Clearing the mailbox before we gave one should not sync.
259 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
260 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
261 test_layer->ClearTexture();
262 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
263
264 // Give a mailbox to the layer through the client.
265 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
266 client.set_mailbox(
267 mailboxes.mailbox1_,
268 SingleReleaseCallback::Create(mailboxes.release_mailbox1_));
269 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(AtLeast(1));
270 test_layer->SetNeedsDisplay();
271 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
272 // Force a commit.
273 layer_tree_host_->Composite(base::TimeTicks());
274
275 // Clearing the mailbox should not sync.
276 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
277 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
278 test_layer->ClearTexture();
279 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
280
281 // Commit will return mailbox1.
282 EXPECT_CALL(mailboxes.mock_callback_,
283 Release(mailboxes.mailbox_name1_, _, false));
284 layer_tree_host_->Composite(base::TimeTicks());
285 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
286
287 // Force a commit to give another mailbox.
288 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
289 client.set_mailbox(
290 mailboxes.mailbox2_,
291 SingleReleaseCallback::Create(mailboxes.release_mailbox2_));
292 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(AtLeast(1));
293 test_layer->SetNeedsDisplay();
294 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
295 layer_tree_host_->Composite(base::TimeTicks());
296
297 // Make undrawable and commit.
298 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
299 test_layer->SetIsDrawable(false);
300 layer_tree_host_->Composite(base::TimeTicks());
301 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
302
303 // Clearing textures should not sync.
304 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
305 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
306 test_layer->ClearTexture();
307 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
308
309 // Commit will return the mailbox.
310 EXPECT_CALL(mailboxes.mock_callback_,
311 Release(mailboxes.mailbox_name2_, _, false));
312 layer_tree_host_->Composite(base::TimeTicks());
313 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
314 }
315
316 TEST_F(TextureLayerTest, SyncImplWhenRemovingFromTree) {
317 scoped_ptr<TestWebGraphicsContext3D> context(
318 TestWebGraphicsContext3D::Create());
319 scoped_refptr<Layer> root_layer = Layer::Create();
320 ASSERT_TRUE(root_layer.get());
321 scoped_refptr<Layer> child_layer = Layer::Create();
322 ASSERT_TRUE(child_layer.get());
323 root_layer->AddChild(child_layer);
324 FakeTextureLayerClient client;
325 scoped_refptr<TextureLayer> test_layer = TextureLayer::Create(&client);
326 test_layer->SetIsDrawable(true);
327 test_layer->SetBounds(gfx::Size(10, 10));
328 ASSERT_TRUE(test_layer.get());
329 child_layer->AddChild(test_layer);
330
331 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
332 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
333 layer_tree_host_->SetRootLayer(root_layer);
334 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
335
336 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
337 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
338 test_layer->RemoveFromParent();
339 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
340
341 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
342 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
343 child_layer->AddChild(test_layer);
344 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
345
346 // Give a texture to the layer through the client.
347 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
348 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(AtLeast(1));
349 client.set_texture(context->createTexture());
350 test_layer->SetNeedsDisplay();
351 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
352 // Force a commit.
353 layer_tree_host_->Composite(base::TimeTicks());
354
355 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AtLeast(1));
356 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
357 test_layer->RemoveFromParent();
358 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
359 }
360
361 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { 176 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) {
362 scoped_refptr<TextureLayer> test_layer = TextureLayer::Create(NULL); 177 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL);
363 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); 178 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer));
364 179
365 // Test properties that should call SetNeedsCommit. All properties need to 180 // Test properties that should call SetNeedsCommit. All properties need to
366 // be set to new values in order for SetNeedsCommit to be called. 181 // be set to new values in order for SetNeedsCommit to be called.
367 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); 182 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false));
368 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( 183 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV(
369 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); 184 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f)));
370 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( 185 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity(
371 0.5f, 0.5f, 0.5f, 0.5f)); 186 0.5f, 0.5f, 0.5f, 0.5f));
372 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); 187 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false));
373 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); 188 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true));
374 } 189 }
375 190
376 TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) { 191 TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) {
377 const gfx::Size layer_bounds(100, 100); 192 const gfx::Size layer_bounds(100, 100);
378 const gfx::Rect layer_rect(layer_bounds); 193 const gfx::Rect layer_rect(layer_bounds);
379 const Region layer_region(layer_rect); 194 const Region layer_region(layer_rect);
380 195
381 scoped_refptr<TextureLayer> layer = TextureLayer::Create(NULL); 196 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(NULL);
382 layer->SetBounds(layer_bounds); 197 layer->SetBounds(layer_bounds);
383 layer->draw_properties().visible_content_rect = layer_rect; 198 layer->draw_properties().visible_content_rect = layer_rect;
384 layer->SetBlendBackgroundColor(true); 199 layer->SetBlendBackgroundColor(true);
385 200
386 // Verify initial conditions. 201 // Verify initial conditions.
387 EXPECT_FALSE(layer->contents_opaque()); 202 EXPECT_FALSE(layer->contents_opaque());
388 EXPECT_EQ(0u, layer->background_color()); 203 EXPECT_EQ(0u, layer->background_color());
389 EXPECT_EQ(Region().ToString(), 204 EXPECT_EQ(Region().ToString(),
390 layer->VisibleContentOpaqueRegion().ToString()); 205 layer->VisibleContentOpaqueRegion().ToString());
391 206
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 TextureLayerTest::TearDown(); 284 TextureLayerTest::TearDown();
470 } 285 }
471 286
472 CommonMailboxObjects test_data_; 287 CommonMailboxObjects test_data_;
473 }; 288 };
474 289
475 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { 290 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) {
476 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); 291 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL);
477 ASSERT_TRUE(test_layer.get()); 292 ASSERT_TRUE(test_layer.get());
478 293
479 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
480 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); 294 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
481 layer_tree_host_->SetRootLayer(test_layer); 295 layer_tree_host_->SetRootLayer(test_layer);
482 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 296 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
483 297
484 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
485 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 298 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
486 test_layer->SetTextureMailbox( 299 test_layer->SetTextureMailbox(
487 test_data_.mailbox1_, 300 test_data_.mailbox1_,
488 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 301 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
489 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 302 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
490 303
491 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
492 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 304 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
493 EXPECT_CALL(test_data_.mock_callback_, 305 EXPECT_CALL(test_data_.mock_callback_,
494 Release(test_data_.mailbox_name1_, 306 Release(test_data_.mailbox_name1_,
495 test_data_.sync_point1_, 307 test_data_.sync_point1_,
496 false)) 308 false))
497 .Times(1); 309 .Times(1);
498 test_layer->SetTextureMailbox( 310 test_layer->SetTextureMailbox(
499 test_data_.mailbox2_, 311 test_data_.mailbox2_,
500 SingleReleaseCallback::Create(test_data_.release_mailbox2_)); 312 SingleReleaseCallback::Create(test_data_.release_mailbox2_));
501 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 313 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
502 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 314 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
503 315
504 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
505 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 316 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
506 EXPECT_CALL(test_data_.mock_callback_, 317 EXPECT_CALL(test_data_.mock_callback_,
507 Release(test_data_.mailbox_name2_, 318 Release(test_data_.mailbox_name2_,
508 test_data_.sync_point2_, 319 test_data_.sync_point2_,
509 false)) 320 false))
510 .Times(1); 321 .Times(1);
511 test_layer->SetTextureMailbox(TextureMailbox(), 322 test_layer->SetTextureMailbox(TextureMailbox(),
512 scoped_ptr<SingleReleaseCallback>()); 323 scoped_ptr<SingleReleaseCallback>());
513 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 324 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
514 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 325 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
515 326
516 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
517 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 327 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
518 test_layer->SetTextureMailbox( 328 test_layer->SetTextureMailbox(
519 test_data_.mailbox3_, 329 test_data_.mailbox3_,
520 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); 330 SingleReleaseCallback::Create(test_data_.release_mailbox3_));
521 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 331 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
522 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 332 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
523 333
524 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
525 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 334 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
526 EXPECT_CALL(test_data_.mock_callback_, 335 EXPECT_CALL(test_data_.mock_callback_,
527 Release2(test_data_.shared_memory_.get(), 336 Release2(test_data_.shared_memory_.get(),
528 0, false)) 337 0, false))
529 .Times(1); 338 .Times(1);
530 test_layer->SetTextureMailbox(TextureMailbox(), 339 test_layer->SetTextureMailbox(TextureMailbox(),
531 scoped_ptr<SingleReleaseCallback>()); 340 scoped_ptr<SingleReleaseCallback>());
532 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 341 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
533 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 342 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
534 343
535 // Test destructor. 344 // Test destructor.
536 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 345 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
537 test_layer->SetTextureMailbox( 346 test_layer->SetTextureMailbox(
538 test_data_.mailbox1_, 347 test_data_.mailbox1_,
539 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 348 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
540 } 349 }
541 350
542 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { 351 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) {
543 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); 352 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL);
544 ASSERT_TRUE(test_layer.get()); 353 ASSERT_TRUE(test_layer.get());
545 354
546 // These use the same gpu::Mailbox, but different sync points. 355 // These use the same gpu::Mailbox, but different sync points.
547 TextureMailbox mailbox1(MailboxFromChar('a'), GL_TEXTURE_2D, 1); 356 TextureMailbox mailbox1(MailboxFromChar('a'), GL_TEXTURE_2D, 1);
548 TextureMailbox mailbox2(MailboxFromChar('a'), GL_TEXTURE_2D, 2); 357 TextureMailbox mailbox2(MailboxFromChar('a'), GL_TEXTURE_2D, 2);
549 358
550 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
551 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); 359 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
552 layer_tree_host_->SetRootLayer(test_layer); 360 layer_tree_host_->SetRootLayer(test_layer);
553 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 361 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
554 362
555 // Set the mailbox the first time. It should cause a commit. 363 // Set the mailbox the first time. It should cause a commit.
556 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
557 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 364 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
558 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox1); 365 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox1);
559 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 366 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
560 367
561 // Set the mailbox again with a new sync point, as the backing texture has 368 // Set the mailbox again with a new sync point, as the backing texture has
562 // been updated. It should cause a new commit. 369 // been updated. It should cause a new commit.
563 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
564 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 370 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
565 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox2); 371 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox2);
566 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 372 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
567 } 373 }
568 374
569 class TextureLayerMailboxHolderTest : public TextureLayerTest { 375 class TextureLayerMailboxHolderTest : public TextureLayerTest {
570 public: 376 public:
571 TextureLayerMailboxHolderTest() 377 TextureLayerMailboxHolderTest()
572 : main_thread_("MAIN") { 378 : main_thread_("MAIN") {
573 main_thread_.Start(); 379 main_thread_.Start();
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 int callback_count_; 794 int callback_count_;
989 int commit_count_; 795 int commit_count_;
990 scoped_refptr<Layer> root_; 796 scoped_refptr<Layer> root_;
991 scoped_refptr<TextureLayer> layer_; 797 scoped_refptr<TextureLayer> layer_;
992 }; 798 };
993 799
994 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 800 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
995 TextureLayerImplWithMailboxThreadedCallback); 801 TextureLayerImplWithMailboxThreadedCallback);
996 802
997 803
998 class TextureLayerNoMailboxIsActivatedDuringCommit : public LayerTreeTest,
999 public TextureLayerClient {
1000 protected:
1001 TextureLayerNoMailboxIsActivatedDuringCommit()
1002 : texture_(0u), activate_count_(0) {}
1003
1004 virtual void BeginTest() OVERRIDE {
1005 gfx::Size bounds(100, 100);
1006 root_ = Layer::Create();
1007 root_->SetAnchorPoint(gfx::PointF());
1008 root_->SetBounds(bounds);
1009
1010 layer_ = TextureLayer::Create(this);
1011 layer_->SetIsDrawable(true);
1012 layer_->SetAnchorPoint(gfx::PointF());
1013 layer_->SetBounds(bounds);
1014
1015 root_->AddChild(layer_);
1016 layer_tree_host()->SetRootLayer(root_);
1017 layer_tree_host()->SetViewportSize(bounds);
1018
1019 PostSetNeedsCommitToMainThread();
1020 }
1021
1022 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
1023 OVERRIDE {
1024 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create();
1025 texture_ = provider->UnboundTestContext3d()->createExternalTexture();
1026 return FakeOutputSurface::Create3d(provider);
1027 }
1028
1029 // TextureLayerClient implementation.
1030 virtual unsigned PrepareTexture() OVERRIDE {
1031 return texture_;
1032 }
1033 virtual bool PrepareTextureMailbox(
1034 TextureMailbox* mailbox,
1035 scoped_ptr<SingleReleaseCallback>* release_callback,
1036 bool use_shared_memory) OVERRIDE {
1037 return false;
1038 }
1039
1040 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1041 ++activate_count_;
1042 }
1043
1044 virtual void DidCommit() OVERRIDE {
1045 switch (layer_tree_host()->source_frame_number()) {
1046 case 1:
1047 // The first texture has been activated. Invalidate the layer so it
1048 // grabs a new texture id from the client.
1049 layer_->SetNeedsDisplay();
1050 break;
1051 case 2:
1052 // The second mailbox has been activated. Remove the layer from
1053 // the tree to cause another commit/activation. The commit should
1054 // finish *after* the layer is removed from the active tree.
1055 layer_->RemoveFromParent();
1056 break;
1057 case 3:
1058 EndTest();
1059 break;
1060 }
1061 }
1062
1063 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
1064 switch (host_impl->active_tree()->source_frame_number()) {
1065 case 2: {
1066 // The activate for the 2nd texture should have happened before now.
1067 EXPECT_EQ(2, activate_count_);
1068 break;
1069 }
1070 case 3: {
1071 // The activate to remove the layer should have happened before now.
1072 EXPECT_EQ(3, activate_count_);
1073 break;
1074 }
1075 }
1076 }
1077
1078 virtual void AfterTest() OVERRIDE {}
1079
1080 unsigned texture_;
1081 int activate_count_;
1082 scoped_refptr<Layer> root_;
1083 scoped_refptr<TextureLayer> layer_;
1084 };
1085
1086 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1087 TextureLayerNoMailboxIsActivatedDuringCommit);
1088
1089 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { 804 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest {
1090 protected: 805 protected:
1091 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {} 806 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {}
1092 807
1093 static void ReleaseCallback(uint32 sync_point, bool lost_resource) {} 808 static void ReleaseCallback(uint32 sync_point, bool lost_resource) {}
1094 809
1095 void SetMailbox(char mailbox_char) { 810 void SetMailbox(char mailbox_char) {
1096 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 811 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
1097 base::Bind( 812 base::Bind(
1098 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); 813 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 Release(test_data_.mailbox_name1_, 916 Release(test_data_.mailbox_name1_,
1202 test_data_.sync_point1_, 917 test_data_.sync_point1_,
1203 false)) 918 false))
1204 .Times(AnyNumber()); 919 .Times(AnyNumber());
1205 EXPECT_CALL(test_data_.mock_callback_, 920 EXPECT_CALL(test_data_.mock_callback_,
1206 Release2(test_data_.shared_memory_.get(), 0, false)) 921 Release2(test_data_.shared_memory_.get(), 0, false))
1207 .Times(AnyNumber()); 922 .Times(AnyNumber());
1208 // Hardware mode. 923 // Hardware mode.
1209 { 924 {
1210 scoped_ptr<TextureLayerImpl> impl_layer = 925 scoped_ptr<TextureLayerImpl> impl_layer =
1211 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); 926 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1212 impl_layer->SetDrawsContent(true); 927 impl_layer->SetDrawsContent(true);
1213 impl_layer->SetTextureMailbox( 928 impl_layer->SetTextureMailbox(
1214 test_data_.mailbox1_, 929 test_data_.mailbox1_,
1215 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 930 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
1216 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); 931 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
1217 } 932 }
1218 933
1219 { 934 {
1220 scoped_ptr<TextureLayerImpl> impl_layer = 935 scoped_ptr<TextureLayerImpl> impl_layer =
1221 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); 936 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1222 impl_layer->SetDrawsContent(true); 937 impl_layer->SetDrawsContent(true);
1223 impl_layer->SetTextureMailbox(TextureMailbox(), 938 impl_layer->SetTextureMailbox(TextureMailbox(),
1224 scoped_ptr<SingleReleaseCallback>()); 939 scoped_ptr<SingleReleaseCallback>());
1225 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); 940 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
1226 } 941 }
1227 942
1228 { 943 {
1229 // Software resource. 944 // Software resource.
1230 scoped_ptr<TextureLayerImpl> impl_layer = 945 scoped_ptr<TextureLayerImpl> impl_layer =
1231 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); 946 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1232 impl_layer->SetDrawsContent(true); 947 impl_layer->SetDrawsContent(true);
1233 impl_layer->SetTextureMailbox( 948 impl_layer->SetTextureMailbox(
1234 test_data_.mailbox3_, 949 test_data_.mailbox3_,
1235 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); 950 SingleReleaseCallback::Create(test_data_.release_mailbox3_));
1236 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); 951 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
1237 } 952 }
1238 953
1239 {
1240 scoped_ptr<TextureLayerImpl> impl_layer =
1241 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false);
1242 impl_layer->SetDrawsContent(true);
1243 ContextProvider* context_provider =
1244 host_impl_.output_surface()->context_provider();
1245 GLuint texture = 0;
1246 context_provider->ContextGL()->GenTextures(1, &texture);
1247 impl_layer->SetTextureId(texture);
1248 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
1249 }
1250
1251 {
1252 scoped_ptr<TextureLayerImpl> impl_layer =
1253 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false);
1254 impl_layer->SetDrawsContent(true);
1255 impl_layer->SetTextureId(0);
1256 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
1257 }
1258
1259 // Software mode. 954 // Software mode.
1260 { 955 {
1261 scoped_ptr<TextureLayerImpl> impl_layer = 956 scoped_ptr<TextureLayerImpl> impl_layer =
1262 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); 957 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1263 impl_layer->SetDrawsContent(true); 958 impl_layer->SetDrawsContent(true);
1264 impl_layer->SetTextureMailbox( 959 impl_layer->SetTextureMailbox(
1265 test_data_.mailbox1_, 960 test_data_.mailbox1_,
1266 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 961 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
1267 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); 962 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
1268 } 963 }
1269 964
1270 { 965 {
1271 scoped_ptr<TextureLayerImpl> impl_layer = 966 scoped_ptr<TextureLayerImpl> impl_layer =
1272 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); 967 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1273 impl_layer->SetDrawsContent(true); 968 impl_layer->SetDrawsContent(true);
1274 impl_layer->SetTextureMailbox(TextureMailbox(), 969 impl_layer->SetTextureMailbox(TextureMailbox(),
1275 scoped_ptr<SingleReleaseCallback>()); 970 scoped_ptr<SingleReleaseCallback>());
1276 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); 971 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
1277 } 972 }
1278 973
1279 { 974 {
1280 // Software resource. 975 // Software resource.
1281 scoped_ptr<TextureLayerImpl> impl_layer = 976 scoped_ptr<TextureLayerImpl> impl_layer =
1282 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); 977 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1283 impl_layer->SetDrawsContent(true); 978 impl_layer->SetDrawsContent(true);
1284 impl_layer->SetTextureMailbox( 979 impl_layer->SetTextureMailbox(
1285 test_data_.mailbox3_, 980 test_data_.mailbox3_,
1286 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); 981 SingleReleaseCallback::Create(test_data_.release_mailbox3_));
1287 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); 982 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
1288 } 983 }
1289 984
1290 {
1291 scoped_ptr<TextureLayerImpl> impl_layer =
1292 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false);
1293 impl_layer->SetDrawsContent(true);
1294 ContextProvider* context_provider =
1295 host_impl_.output_surface()->context_provider();
1296 GLuint texture = 0;
1297 context_provider->ContextGL()->GenTextures(1, &texture);
1298 impl_layer->SetTextureId(texture);
1299 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
1300 }
1301
1302 {
1303 scoped_ptr<TextureLayerImpl> impl_layer =
1304 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false);
1305 impl_layer->SetDrawsContent(true);
1306 impl_layer->SetTextureId(0);
1307 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
1308 }
1309
1310 // Resourceless software mode. 985 // Resourceless software mode.
1311 { 986 {
1312 scoped_ptr<TextureLayerImpl> impl_layer = 987 scoped_ptr<TextureLayerImpl> impl_layer =
1313 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); 988 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1314 impl_layer->SetDrawsContent(true); 989 impl_layer->SetDrawsContent(true);
1315 impl_layer->SetTextureMailbox( 990 impl_layer->SetTextureMailbox(
1316 test_data_.mailbox1_, 991 test_data_.mailbox1_,
1317 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 992 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
1318 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); 993 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE));
1319 } 994 }
1320
1321 {
1322 scoped_ptr<TextureLayerImpl> impl_layer =
1323 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false);
1324 impl_layer->SetDrawsContent(true);
1325 ContextProvider* context_provider =
1326 host_impl_.output_surface()->context_provider();
1327 GLuint texture = 0;
1328 context_provider->ContextGL()->GenTextures(1, &texture);
1329 impl_layer->SetTextureId(texture);
1330 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE));
1331 }
1332 } 995 }
1333 996
1334 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { 997 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) {
1335 host_impl_.CreatePendingTree(); 998 host_impl_.CreatePendingTree();
1336 scoped_ptr<TextureLayerImpl> pending_layer; 999 scoped_ptr<TextureLayerImpl> pending_layer;
1337 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); 1000 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1);
1338 ASSERT_TRUE(pending_layer); 1001 ASSERT_TRUE(pending_layer);
1339 1002
1340 scoped_ptr<LayerImpl> active_layer( 1003 scoped_ptr<LayerImpl> active_layer(
1341 pending_layer->CreateLayerImpl(host_impl_.active_tree())); 1004 pending_layer->CreateLayerImpl(host_impl_.active_tree()));
1342 ASSERT_TRUE(active_layer); 1005 ASSERT_TRUE(active_layer);
1343 1006
1344 pending_layer->SetTextureMailbox( 1007 pending_layer->SetTextureMailbox(
1345 test_data_.mailbox1_, 1008 test_data_.mailbox1_,
1346 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 1009 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
1347 1010
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 false)) 1053 false))
1391 .Times(1); 1054 .Times(1);
1392 pending_layer->SetTextureMailbox( 1055 pending_layer->SetTextureMailbox(
1393 test_data_.mailbox1_, 1056 test_data_.mailbox1_,
1394 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 1057 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
1395 } 1058 }
1396 1059
1397 TEST_F(TextureLayerImplWithMailboxTest, 1060 TEST_F(TextureLayerImplWithMailboxTest,
1398 TestDestructorCallbackOnCreatedResource) { 1061 TestDestructorCallbackOnCreatedResource) {
1399 scoped_ptr<TextureLayerImpl> impl_layer; 1062 scoped_ptr<TextureLayerImpl> impl_layer;
1400 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); 1063 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1401 ASSERT_TRUE(impl_layer); 1064 ASSERT_TRUE(impl_layer);
1402 1065
1403 EXPECT_CALL(test_data_.mock_callback_, 1066 EXPECT_CALL(test_data_.mock_callback_,
1404 Release(test_data_.mailbox_name1_, _, false)) 1067 Release(test_data_.mailbox_name1_, _, false))
1405 .Times(1); 1068 .Times(1);
1406 impl_layer->SetTextureMailbox( 1069 impl_layer->SetTextureMailbox(
1407 test_data_.mailbox1_, 1070 test_data_.mailbox1_,
1408 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 1071 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
1409 impl_layer->SetDrawsContent(true); 1072 impl_layer->SetDrawsContent(true);
1410 impl_layer->DidBecomeActive(); 1073 impl_layer->DidBecomeActive();
(...skipping 22 matching lines...) Expand all
1433 provider->DeleteResource(id); 1096 provider->DeleteResource(id);
1434 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 1097 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
1435 EXPECT_CALL(test_data_.mock_callback_, 1098 EXPECT_CALL(test_data_.mock_callback_,
1436 Release(test_data_.mailbox_name1_, _, false)) 1099 Release(test_data_.mailbox_name1_, _, false))
1437 .Times(1); 1100 .Times(1);
1438 ReturnedResourceArray returned; 1101 ReturnedResourceArray returned;
1439 TransferableResource::ReturnResources(list, &returned); 1102 TransferableResource::ReturnResources(list, &returned);
1440 provider->ReceiveReturnsFromParent(returned); 1103 provider->ReceiveReturnsFromParent(returned);
1441 } 1104 }
1442 1105
1443 // Check that ClearClient correctly clears the state so that the impl side
1444 // doesn't try to use a texture that could have been destroyed.
1445 class TextureLayerClientTest
1446 : public LayerTreeTest,
1447 public TextureLayerClient {
1448 public:
1449 TextureLayerClientTest()
1450 : texture_(0),
1451 commit_count_(0),
1452 expected_used_textures_on_draw_(0),
1453 expected_used_textures_on_commit_(0) {}
1454
1455 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
1456 OVERRIDE {
1457 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create();
1458 texture_ = provider->UnboundTestContext3d()->createExternalTexture();
1459 return FakeOutputSurface::Create3d(provider);
1460 }
1461
1462 virtual unsigned PrepareTexture() OVERRIDE { return texture_; }
1463
1464 virtual bool PrepareTextureMailbox(
1465 TextureMailbox* mailbox,
1466 scoped_ptr<SingleReleaseCallback>* release_callback,
1467 bool use_shared_memory) OVERRIDE {
1468 return false;
1469 }
1470
1471 virtual void SetupTree() OVERRIDE {
1472 scoped_refptr<Layer> root = Layer::Create();
1473 root->SetBounds(gfx::Size(10, 10));
1474 root->SetAnchorPoint(gfx::PointF());
1475 root->SetIsDrawable(true);
1476
1477 texture_layer_ = TextureLayer::Create(this);
1478 texture_layer_->SetBounds(gfx::Size(10, 10));
1479 texture_layer_->SetAnchorPoint(gfx::PointF());
1480 texture_layer_->SetIsDrawable(true);
1481 root->AddChild(texture_layer_);
1482
1483 layer_tree_host()->SetRootLayer(root);
1484 LayerTreeTest::SetupTree();
1485 {
1486 base::AutoLock lock(lock_);
1487 expected_used_textures_on_commit_ = 1;
1488 }
1489 }
1490
1491 virtual void BeginTest() OVERRIDE {
1492 PostSetNeedsCommitToMainThread();
1493 }
1494
1495 virtual void DidCommitAndDrawFrame() OVERRIDE {
1496 ++commit_count_;
1497 switch (commit_count_) {
1498 case 1:
1499 texture_layer_->ClearClient();
1500 texture_layer_->SetNeedsDisplay();
1501 {
1502 base::AutoLock lock(lock_);
1503 expected_used_textures_on_commit_ = 0;
1504 }
1505 break;
1506 case 2:
1507 EndTest();
1508 break;
1509 default:
1510 NOTREACHED();
1511 break;
1512 }
1513 }
1514
1515 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
1516 base::AutoLock lock(lock_);
1517 expected_used_textures_on_draw_ = expected_used_textures_on_commit_;
1518 }
1519
1520 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
1521 LayerTreeHostImpl* host_impl,
1522 LayerTreeHostImpl::FrameData* frame_data,
1523 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
1524 ContextForImplThread(host_impl)->ResetUsedTextures();
1525 return DrawSwapReadbackResult::DRAW_SUCCESS;
1526 }
1527
1528 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1529 bool result) OVERRIDE {
1530 ASSERT_TRUE(result);
1531 EXPECT_EQ(expected_used_textures_on_draw_,
1532 ContextForImplThread(host_impl)->NumUsedTextures());
1533 }
1534
1535 virtual void AfterTest() OVERRIDE {}
1536
1537 private:
1538 TestWebGraphicsContext3D* ContextForImplThread(LayerTreeHostImpl* host_impl) {
1539 return static_cast<TestContextProvider*>(
1540 host_impl->output_surface()->context_provider().get())->TestContext3d();
1541 }
1542
1543 scoped_refptr<TextureLayer> texture_layer_;
1544 unsigned texture_;
1545 int commit_count_;
1546
1547 // Used only on thread.
1548 unsigned expected_used_textures_on_draw_;
1549
1550 // Used on either thread, protected by lock_.
1551 base::Lock lock_;
1552 unsigned expected_used_textures_on_commit_;
1553 };
1554
1555 // The TextureLayerClient does not use mailboxes, so can't use a delegating
1556 // renderer.
1557 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerClientTest);
1558
1559
1560 // Checks that changing a texture in the client for a TextureLayer that's
1561 // invisible correctly works without drawing a deleted texture. See
1562 // crbug.com/266628
1563 class TextureLayerChangeInvisibleTest
1564 : public LayerTreeTest,
1565 public TextureLayerClient {
1566 public:
1567 TextureLayerChangeInvisibleTest()
1568 : texture_(0u),
1569 prepare_called_(0),
1570 commit_count_(0),
1571 expected_texture_on_draw_(0) {}
1572
1573 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
1574 OVERRIDE {
1575 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create();
1576 texture_ = provider->UnboundTestContext3d()->createExternalTexture();
1577 return FakeOutputSurface::Create3d(provider);
1578 }
1579
1580 // TextureLayerClient implementation.
1581 virtual unsigned PrepareTexture() OVERRIDE {
1582 ++prepare_called_;
1583 return texture_;
1584 }
1585 virtual bool PrepareTextureMailbox(
1586 TextureMailbox* mailbox,
1587 scoped_ptr<SingleReleaseCallback>* release_callback,
1588 bool use_shared_memory) OVERRIDE {
1589 return false;
1590 }
1591
1592 virtual void SetupTree() OVERRIDE {
1593 scoped_refptr<Layer> root = Layer::Create();
1594 root->SetBounds(gfx::Size(10, 10));
1595 root->SetAnchorPoint(gfx::PointF());
1596 root->SetIsDrawable(true);
1597
1598 solid_layer_ = SolidColorLayer::Create();
1599 solid_layer_->SetBounds(gfx::Size(10, 10));
1600 solid_layer_->SetIsDrawable(true);
1601 solid_layer_->SetBackgroundColor(SK_ColorWHITE);
1602 root->AddChild(solid_layer_);
1603
1604 parent_layer_ = Layer::Create();
1605 parent_layer_->SetBounds(gfx::Size(10, 10));
1606 parent_layer_->SetIsDrawable(true);
1607 root->AddChild(parent_layer_);
1608
1609 texture_layer_ = TextureLayer::Create(this);
1610 texture_layer_->SetBounds(gfx::Size(10, 10));
1611 texture_layer_->SetAnchorPoint(gfx::PointF());
1612 texture_layer_->SetIsDrawable(true);
1613 parent_layer_->AddChild(texture_layer_);
1614
1615 layer_tree_host()->SetRootLayer(root);
1616 LayerTreeTest::SetupTree();
1617 }
1618
1619 virtual void BeginTest() OVERRIDE {
1620 PostSetNeedsCommitToMainThread();
1621 }
1622
1623 virtual void DidCommitAndDrawFrame() OVERRIDE {
1624 ++commit_count_;
1625 switch (commit_count_) {
1626 case 1:
1627 // We should have updated the layer, committing the texture.
1628 EXPECT_EQ(1, prepare_called_);
1629 // Make layer invisible.
1630 parent_layer_->SetOpacity(0.f);
1631 break;
1632 case 2: {
1633 // Layer shouldn't have been updated.
1634 EXPECT_EQ(1, prepare_called_);
1635 texture_layer_->SetNeedsDisplay();
1636 // Force a change to make sure we draw a frame.
1637 solid_layer_->SetBackgroundColor(SK_ColorGRAY);
1638 break;
1639 }
1640 case 3:
1641 EXPECT_EQ(1, prepare_called_);
1642 // Make layer visible again.
1643 parent_layer_->SetOpacity(1.f);
1644 break;
1645 case 4: {
1646 // Layer should have been updated.
1647 EXPECT_EQ(2, prepare_called_);
1648 texture_layer_->ClearClient();
1649 texture_ = 0;
1650 break;
1651 }
1652 case 5:
1653 EndTest();
1654 break;
1655 default:
1656 NOTREACHED();
1657 break;
1658 }
1659 }
1660
1661 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
1662 ASSERT_TRUE(proxy()->IsMainThreadBlocked());
1663 // This is the only texture that can be drawn this frame.
1664 expected_texture_on_draw_ = texture_;
1665 }
1666
1667 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
1668 LayerTreeHostImpl* host_impl,
1669 LayerTreeHostImpl::FrameData* frame_data,
1670 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
1671 ContextForImplThread(host_impl)->ResetUsedTextures();
1672 return DrawSwapReadbackResult::DRAW_SUCCESS;
1673 }
1674
1675 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1676 bool result) OVERRIDE {
1677 ASSERT_TRUE(result);
1678 TestWebGraphicsContext3D* context = ContextForImplThread(host_impl);
1679 int used_textures = context->NumUsedTextures();
1680 switch (host_impl->active_tree()->source_frame_number()) {
1681 case 0:
1682 EXPECT_EQ(1, used_textures);
1683 EXPECT_TRUE(context->UsedTexture(expected_texture_on_draw_));
1684 break;
1685 case 1:
1686 case 2:
1687 EXPECT_EQ(0, used_textures);
1688 break;
1689 case 3:
1690 EXPECT_EQ(1, used_textures);
1691 EXPECT_TRUE(context->UsedTexture(expected_texture_on_draw_));
1692 break;
1693 default:
1694 break;
1695 }
1696 }
1697
1698 virtual void AfterTest() OVERRIDE {}
1699
1700 private:
1701 TestWebGraphicsContext3D* ContextForImplThread(LayerTreeHostImpl* host_impl) {
1702 return static_cast<TestContextProvider*>(
1703 host_impl->output_surface()->context_provider().get())->TestContext3d();
1704 }
1705
1706 scoped_refptr<SolidColorLayer> solid_layer_;
1707 scoped_refptr<Layer> parent_layer_;
1708 scoped_refptr<TextureLayer> texture_layer_;
1709
1710 // Used on the main thread, and on the impl thread while the main thread is
1711 // blocked.
1712 unsigned texture_;
1713
1714 // Used on the main thread.
1715 int prepare_called_;
1716 int commit_count_;
1717
1718 // Used on the compositor thread.
1719 unsigned expected_texture_on_draw_;
1720 };
1721
1722 // The TextureLayerChangeInvisibleTest does not use mailboxes, so can't use a
1723 // delegating renderer.
1724 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerChangeInvisibleTest);
1725
1726 // Checks that TextureLayer::Update does not cause an extra commit when setting 1106 // Checks that TextureLayer::Update does not cause an extra commit when setting
1727 // the texture mailbox. 1107 // the texture mailbox.
1728 class TextureLayerNoExtraCommitForMailboxTest 1108 class TextureLayerNoExtraCommitForMailboxTest
1729 : public LayerTreeTest, 1109 : public LayerTreeTest,
1730 public TextureLayerClient { 1110 public TextureLayerClient {
1731 public: 1111 public:
1732 // TextureLayerClient implementation. 1112 // TextureLayerClient implementation.
1733 virtual unsigned PrepareTexture() OVERRIDE {
1734 NOTREACHED();
1735 return 0;
1736 }
1737 virtual bool PrepareTextureMailbox( 1113 virtual bool PrepareTextureMailbox(
1738 TextureMailbox* texture_mailbox, 1114 TextureMailbox* texture_mailbox,
1739 scoped_ptr<SingleReleaseCallback>* release_callback, 1115 scoped_ptr<SingleReleaseCallback>* release_callback,
1740 bool use_shared_memory) OVERRIDE { 1116 bool use_shared_memory) OVERRIDE {
1741 if (layer_tree_host()->source_frame_number() == 1) { 1117 if (layer_tree_host()->source_frame_number() == 1) {
1742 *texture_mailbox = TextureMailbox(); 1118 *texture_mailbox = TextureMailbox();
1743 return true; 1119 return true;
1744 } 1120 }
1745 1121
1746 *texture_mailbox = TextureMailbox(MailboxFromChar('1'), GL_TEXTURE_2D, 0); 1122 *texture_mailbox = TextureMailbox(MailboxFromChar('1'), GL_TEXTURE_2D, 0);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 public: 1203 public:
1828 TextureLayerChangeInvisibleMailboxTest() 1204 TextureLayerChangeInvisibleMailboxTest()
1829 : mailbox_changed_(true), 1205 : mailbox_changed_(true),
1830 mailbox_returned_(0), 1206 mailbox_returned_(0),
1831 prepare_called_(0), 1207 prepare_called_(0),
1832 commit_count_(0) { 1208 commit_count_(0) {
1833 mailbox_ = MakeMailbox('1'); 1209 mailbox_ = MakeMailbox('1');
1834 } 1210 }
1835 1211
1836 // TextureLayerClient implementation. 1212 // TextureLayerClient implementation.
1837 virtual unsigned PrepareTexture() OVERRIDE {
1838 NOTREACHED();
1839 return 0;
1840 }
1841
1842 virtual bool PrepareTextureMailbox( 1213 virtual bool PrepareTextureMailbox(
1843 TextureMailbox* mailbox, 1214 TextureMailbox* mailbox,
1844 scoped_ptr<SingleReleaseCallback>* release_callback, 1215 scoped_ptr<SingleReleaseCallback>* release_callback,
1845 bool use_shared_memory) OVERRIDE { 1216 bool use_shared_memory) OVERRIDE {
1846 ++prepare_called_; 1217 ++prepare_called_;
1847 if (!mailbox_changed_) 1218 if (!mailbox_changed_)
1848 return false; 1219 return false;
1849 *mailbox = mailbox_; 1220 *mailbox = mailbox_;
1850 *release_callback = SingleReleaseCallback::Create( 1221 *release_callback = SingleReleaseCallback::Create(
1851 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased, 1222 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 1343
1973 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerChangeInvisibleMailboxTest); 1344 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerChangeInvisibleMailboxTest);
1974 1345
1975 // Test that TextureLayerImpl::ReleaseResources can be called which releases 1346 // Test that TextureLayerImpl::ReleaseResources can be called which releases
1976 // the mailbox back to TextureLayerClient. 1347 // the mailbox back to TextureLayerClient.
1977 class TextureLayerReleaseResourcesBase 1348 class TextureLayerReleaseResourcesBase
1978 : public LayerTreeTest, 1349 : public LayerTreeTest,
1979 public TextureLayerClient { 1350 public TextureLayerClient {
1980 public: 1351 public:
1981 // TextureLayerClient implementation. 1352 // TextureLayerClient implementation.
1982 virtual unsigned PrepareTexture() OVERRIDE {
1983 NOTREACHED();
1984 return 0;
1985 }
1986 virtual bool PrepareTextureMailbox( 1353 virtual bool PrepareTextureMailbox(
1987 TextureMailbox* mailbox, 1354 TextureMailbox* mailbox,
1988 scoped_ptr<SingleReleaseCallback>* release_callback, 1355 scoped_ptr<SingleReleaseCallback>* release_callback,
1989 bool use_shared_memory) OVERRIDE { 1356 bool use_shared_memory) OVERRIDE {
1990 *mailbox = TextureMailbox(MailboxFromChar('1'), GL_TEXTURE_2D, 0); 1357 *mailbox = TextureMailbox(MailboxFromChar('1'), GL_TEXTURE_2D, 0);
1991 *release_callback = SingleReleaseCallback::Create( 1358 *release_callback = SingleReleaseCallback::Create(
1992 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased, 1359 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased,
1993 base::Unretained(this))); 1360 base::Unretained(this)));
1994 return true; 1361 return true;
1995 } 1362 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 class TextureLayerReleaseResourcesAfterActivate 1412 class TextureLayerReleaseResourcesAfterActivate
2046 : public TextureLayerReleaseResourcesBase { 1413 : public TextureLayerReleaseResourcesBase {
2047 public: 1414 public:
2048 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1415 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2049 host_impl->active_tree()->root_layer()->children()[0]->ReleaseResources(); 1416 host_impl->active_tree()->root_layer()->children()[0]->ReleaseResources();
2050 } 1417 }
2051 }; 1418 };
2052 1419
2053 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterActivate); 1420 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterActivate);
2054 1421
2055 // Test recovering from a lost context.
2056 class TextureLayerLostContextTest
2057 : public LayerTreeTest,
2058 public TextureLayerClient {
2059 public:
2060 TextureLayerLostContextTest()
2061 : context_lost_(false),
2062 draw_count_(0) {}
2063
2064 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
2065 OVERRIDE {
2066 return FakeOutputSurface::Create3d();
2067 }
2068
2069 virtual unsigned PrepareTexture() OVERRIDE {
2070 if (draw_count_ == 0)
2071 context_lost_ = true;
2072 if (context_lost_)
2073 return 0u;
2074 return 1u;
2075 }
2076
2077 virtual bool PrepareTextureMailbox(
2078 TextureMailbox* mailbox,
2079 scoped_ptr<SingleReleaseCallback>* release_callback,
2080 bool use_shared_memory) OVERRIDE {
2081 return false;
2082 }
2083
2084 virtual void SetupTree() OVERRIDE {
2085 scoped_refptr<Layer> root = Layer::Create();
2086 root->SetBounds(gfx::Size(10, 10));
2087 root->SetIsDrawable(true);
2088
2089 texture_layer_ = TextureLayer::Create(this);
2090 texture_layer_->SetBounds(gfx::Size(10, 10));
2091 texture_layer_->SetIsDrawable(true);
2092 root->AddChild(texture_layer_);
2093
2094 layer_tree_host()->SetRootLayer(root);
2095 LayerTreeTest::SetupTree();
2096 }
2097
2098 virtual void BeginTest() OVERRIDE {
2099 PostSetNeedsCommitToMainThread();
2100 }
2101
2102 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
2103 LayerTreeHostImpl* host_impl,
2104 LayerTreeHostImpl::FrameData* frame_data,
2105 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
2106 LayerImpl* root = host_impl->RootLayer();
2107 TextureLayerImpl* texture_layer =
2108 static_cast<TextureLayerImpl*>(root->children()[0]);
2109 if (++draw_count_ == 1)
2110 EXPECT_EQ(0u, texture_layer->texture_id());
2111 else
2112 EXPECT_EQ(1u, texture_layer->texture_id());
2113 return DrawSwapReadbackResult::DRAW_SUCCESS;
2114 }
2115
2116 virtual void DidCommitAndDrawFrame() OVERRIDE {
2117 EndTest();
2118 }
2119
2120 virtual void AfterTest() OVERRIDE {}
2121
2122 private:
2123 scoped_refptr<TextureLayer> texture_layer_;
2124 bool context_lost_;
2125 int draw_count_;
2126 };
2127
2128 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerLostContextTest);
2129
2130 class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest { 1422 class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest {
2131 public: 1423 public:
2132 void ReleaseCallback(uint32 sync_point, bool lost_resource) { 1424 void ReleaseCallback(uint32 sync_point, bool lost_resource) {
2133 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 1425 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
2134 EXPECT_FALSE(lost_resource); 1426 EXPECT_FALSE(lost_resource);
2135 ++callback_count_; 1427 ++callback_count_;
2136 EndTest(); 1428 EndTest();
2137 } 1429 }
2138 1430
2139 void SetMailbox(char mailbox_char) { 1431 void SetMailbox(char mailbox_char) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 int callback_count_; 1563 int callback_count_;
2272 scoped_refptr<Layer> root_; 1564 scoped_refptr<Layer> root_;
2273 scoped_refptr<TextureLayer> layer_; 1565 scoped_refptr<TextureLayer> layer_;
2274 }; 1566 };
2275 1567
2276 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1568 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
2277 TextureLayerWithMailboxImplThreadDeleted); 1569 TextureLayerWithMailboxImplThreadDeleted);
2278 1570
2279 } // namespace 1571 } // namespace
2280 } // namespace cc 1572 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer_impl_unittest.cc ('k') | cc/scheduler/scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698