OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
35 | 35 |
36 using ::testing::Mock; | 36 using ::testing::Mock; |
37 using ::testing::_; | 37 using ::testing::_; |
38 using ::testing::AtLeast; | 38 using ::testing::AtLeast; |
39 using ::testing::AnyNumber; | 39 using ::testing::AnyNumber; |
40 | 40 |
41 namespace cc { | 41 namespace cc { |
42 namespace { | 42 namespace { |
43 | 43 |
| 44 gpu::Mailbox MailboxFromString(const std::string& string) { |
| 45 gpu::Mailbox mailbox; |
| 46 mailbox.SetName(reinterpret_cast<const int8*>(string.data())); |
| 47 return mailbox; |
| 48 } |
| 49 |
44 class MockLayerTreeHost : public LayerTreeHost { | 50 class MockLayerTreeHost : public LayerTreeHost { |
45 public: | 51 public: |
46 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) | 52 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) |
47 : LayerTreeHost(client, NULL, LayerTreeSettings()) { | 53 : LayerTreeHost(client, NULL, LayerTreeSettings()) { |
48 InitializeSingleThreaded(client); | 54 InitializeSingleThreaded(client); |
49 } | 55 } |
50 | 56 |
51 MOCK_METHOD0(AcquireLayerTextures, void()); | 57 MOCK_METHOD0(AcquireLayerTextures, void()); |
52 MOCK_METHOD0(SetNeedsCommit, void()); | 58 MOCK_METHOD0(SetNeedsCommit, void()); |
53 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 59 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 314 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
309 | 315 |
310 // Stop rate limiter when we're removed from the tree. | 316 // Stop rate limiter when we're removed from the tree. |
311 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); | 317 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); |
312 layer_tree_host_->SetRootLayer(NULL); | 318 layer_tree_host_->SetRootLayer(NULL); |
313 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 319 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
314 } | 320 } |
315 | 321 |
316 class MockMailboxCallback { | 322 class MockMailboxCallback { |
317 public: | 323 public: |
318 MOCK_METHOD3(Release, void(const std::string& mailbox, | 324 MOCK_METHOD3(Release, |
319 unsigned sync_point, | 325 void(const std::string& mailbox, |
320 bool lost_resource)); | 326 uint32 sync_point, |
321 MOCK_METHOD3(Release2, void(base::SharedMemory* shared_memory, | 327 bool lost_resource)); |
322 unsigned sync_point, | 328 MOCK_METHOD3(Release2, |
323 bool lost_resource)); | 329 void(base::SharedMemory* shared_memory, |
| 330 uint32 sync_point, |
| 331 bool lost_resource)); |
324 }; | 332 }; |
325 | 333 |
326 struct CommonMailboxObjects { | 334 struct CommonMailboxObjects { |
327 CommonMailboxObjects() | 335 CommonMailboxObjects() |
328 : mailbox_name1_(64, '1'), | 336 : mailbox_name1_(64, '1'), |
329 mailbox_name2_(64, '2'), | 337 mailbox_name2_(64, '2'), |
330 sync_point1_(1), | 338 sync_point1_(1), |
331 sync_point2_(2), | 339 sync_point2_(2), |
332 shared_memory_(new base::SharedMemory) { | 340 shared_memory_(new base::SharedMemory) { |
333 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, | 341 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, |
334 base::Unretained(&mock_callback_), | 342 base::Unretained(&mock_callback_), |
335 mailbox_name1_); | 343 mailbox_name1_); |
336 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, | 344 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, |
337 base::Unretained(&mock_callback_), | 345 base::Unretained(&mock_callback_), |
338 mailbox_name2_); | 346 mailbox_name2_); |
339 gpu::Mailbox m1; | 347 const uint32 arbitrary_target1 = 1; |
340 m1.SetName(reinterpret_cast<const int8*>(mailbox_name1_.data())); | 348 const uint32 arbitrary_target2 = 2; |
341 mailbox1_ = TextureMailbox(m1, sync_point1_); | 349 mailbox1_ = TextureMailbox( |
342 gpu::Mailbox m2; | 350 MailboxFromString(mailbox_name1_), arbitrary_target1, sync_point1_); |
343 m2.SetName(reinterpret_cast<const int8*>(mailbox_name2_.data())); | 351 mailbox2_ = TextureMailbox( |
344 mailbox2_ = TextureMailbox(m2, sync_point2_); | 352 MailboxFromString(mailbox_name2_), arbitrary_target2, sync_point2_); |
345 | |
346 gfx::Size size(128, 128); | 353 gfx::Size size(128, 128); |
347 EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea())); | 354 EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea())); |
348 release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2, | 355 release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2, |
349 base::Unretained(&mock_callback_), | 356 base::Unretained(&mock_callback_), |
350 shared_memory_.get()); | 357 shared_memory_.get()); |
351 mailbox3_ = TextureMailbox(shared_memory_.get(), size); | 358 mailbox3_ = TextureMailbox(shared_memory_.get(), size); |
352 } | 359 } |
353 | 360 |
354 std::string mailbox_name1_; | 361 std::string mailbox_name1_; |
355 std::string mailbox_name2_; | 362 std::string mailbox_name2_; |
356 MockMailboxCallback mock_callback_; | 363 MockMailboxCallback mock_callback_; |
357 ReleaseCallback release_mailbox1_; | 364 ReleaseCallback release_mailbox1_; |
358 ReleaseCallback release_mailbox2_; | 365 ReleaseCallback release_mailbox2_; |
359 ReleaseCallback release_mailbox3_; | 366 ReleaseCallback release_mailbox3_; |
360 TextureMailbox mailbox1_; | 367 TextureMailbox mailbox1_; |
361 TextureMailbox mailbox2_; | 368 TextureMailbox mailbox2_; |
362 TextureMailbox mailbox3_; | 369 TextureMailbox mailbox3_; |
363 unsigned sync_point1_; | 370 uint32 sync_point1_; |
364 unsigned sync_point2_; | 371 uint32 sync_point2_; |
365 scoped_ptr<base::SharedMemory> shared_memory_; | 372 scoped_ptr<base::SharedMemory> shared_memory_; |
366 }; | 373 }; |
367 | 374 |
368 class TestMailboxHolder : public TextureLayer::MailboxHolder { | 375 class TestMailboxHolder : public TextureLayer::TextureMailboxHolder { |
369 public: | 376 public: |
370 using TextureLayer::MailboxHolder::Create; | 377 using TextureLayer::TextureMailboxHolder::Create; |
371 | 378 |
372 protected: | 379 protected: |
373 virtual ~TestMailboxHolder() {} | 380 virtual ~TestMailboxHolder() {} |
374 }; | 381 }; |
375 | 382 |
376 class TextureLayerWithMailboxTest : public TextureLayerTest { | 383 class TextureLayerWithMailboxTest : public TextureLayerTest { |
377 protected: | 384 protected: |
378 virtual void TearDown() { | 385 virtual void TearDown() { |
379 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 386 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
380 EXPECT_CALL(test_data_.mock_callback_, | 387 EXPECT_CALL(test_data_.mock_callback_, |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 754 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
748 } | 755 } |
749 | 756 |
750 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { | 757 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { |
751 public: | 758 public: |
752 TextureLayerImplWithMailboxThreadedCallback() | 759 TextureLayerImplWithMailboxThreadedCallback() |
753 : callback_count_(0), | 760 : callback_count_(0), |
754 commit_count_(0) {} | 761 commit_count_(0) {} |
755 | 762 |
756 // Make sure callback is received on main and doesn't block the impl thread. | 763 // Make sure callback is received on main and doesn't block the impl thread. |
757 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 764 void ReleaseCallback(uint32 sync_point, bool lost_resource) { |
758 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 765 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
759 EXPECT_FALSE(lost_resource); | 766 EXPECT_FALSE(lost_resource); |
760 ++callback_count_; | 767 ++callback_count_; |
761 } | 768 } |
762 | 769 |
763 void SetMailbox(char mailbox_char) { | 770 void SetMailbox(char mailbox_char) { |
764 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 771 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
765 TextureMailbox mailbox(std::string(64, mailbox_char)); | |
766 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 772 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
767 base::Bind( | 773 base::Bind( |
768 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, | 774 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, |
769 base::Unretained(this))); | 775 base::Unretained(this))); |
770 layer_->SetTextureMailbox(mailbox, callback.Pass()); | 776 layer_->SetTextureMailbox( |
| 777 TextureMailbox( |
| 778 MailboxFromString(std::string(64, mailbox_char)), GL_TEXTURE_2D, 0), |
| 779 callback.Pass()); |
771 } | 780 } |
772 | 781 |
773 virtual void BeginTest() OVERRIDE { | 782 virtual void BeginTest() OVERRIDE { |
774 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 783 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
775 | 784 |
776 gfx::Size bounds(100, 100); | 785 gfx::Size bounds(100, 100); |
777 root_ = Layer::Create(); | 786 root_ = Layer::Create(); |
778 root_->SetAnchorPoint(gfx::PointF()); | 787 root_->SetAnchorPoint(gfx::PointF()); |
779 root_->SetBounds(bounds); | 788 root_->SetBounds(bounds); |
780 | 789 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 scoped_refptr<TextureLayer> layer_; | 979 scoped_refptr<TextureLayer> layer_; |
971 }; | 980 }; |
972 | 981 |
973 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 982 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
974 TextureLayerNoMailboxIsActivatedDuringCommit); | 983 TextureLayerNoMailboxIsActivatedDuringCommit); |
975 | 984 |
976 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { | 985 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { |
977 protected: | 986 protected: |
978 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {} | 987 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {} |
979 | 988 |
980 static void ReleaseCallback(unsigned sync_point, bool lost_resource) {} | 989 static void ReleaseCallback(uint32 sync_point, bool lost_resource) {} |
981 | 990 |
982 void SetMailbox(char mailbox_char) { | 991 void SetMailbox(char mailbox_char) { |
983 TextureMailbox mailbox(std::string(64, mailbox_char)); | |
984 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 992 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
985 base::Bind( | 993 base::Bind( |
986 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); | 994 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); |
987 layer_->SetTextureMailbox(mailbox, callback.Pass()); | 995 layer_->SetTextureMailbox( |
| 996 TextureMailbox( |
| 997 MailboxFromString(std::string(64, mailbox_char)), GL_TEXTURE_2D, 0), |
| 998 callback.Pass()); |
988 } | 999 } |
989 | 1000 |
990 virtual void BeginTest() OVERRIDE { | 1001 virtual void BeginTest() OVERRIDE { |
991 gfx::Size bounds(100, 100); | 1002 gfx::Size bounds(100, 100); |
992 root_ = Layer::Create(); | 1003 root_ = Layer::Create(); |
993 root_->SetAnchorPoint(gfx::PointF()); | 1004 root_->SetAnchorPoint(gfx::PointF()); |
994 root_->SetBounds(bounds); | 1005 root_->SetBounds(bounds); |
995 | 1006 |
996 layer_ = TextureLayer::CreateForMailbox(NULL); | 1007 layer_ = TextureLayer::CreateForMailbox(NULL); |
997 layer_->SetIsDrawable(true); | 1008 layer_->SetIsDrawable(true); |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1613 class TextureLayerNoExtraCommitForMailboxTest | 1624 class TextureLayerNoExtraCommitForMailboxTest |
1614 : public LayerTreeTest, | 1625 : public LayerTreeTest, |
1615 public TextureLayerClient { | 1626 public TextureLayerClient { |
1616 public: | 1627 public: |
1617 // TextureLayerClient implementation. | 1628 // TextureLayerClient implementation. |
1618 virtual unsigned PrepareTexture() OVERRIDE { | 1629 virtual unsigned PrepareTexture() OVERRIDE { |
1619 NOTREACHED(); | 1630 NOTREACHED(); |
1620 return 0; | 1631 return 0; |
1621 } | 1632 } |
1622 virtual bool PrepareTextureMailbox( | 1633 virtual bool PrepareTextureMailbox( |
1623 TextureMailbox* mailbox, | 1634 TextureMailbox* texture_mailbox, |
1624 scoped_ptr<SingleReleaseCallback>* release_callback, | 1635 scoped_ptr<SingleReleaseCallback>* release_callback, |
1625 bool use_shared_memory) OVERRIDE { | 1636 bool use_shared_memory) OVERRIDE { |
1626 if (layer_tree_host()->source_frame_number() == 1) { | 1637 if (layer_tree_host()->source_frame_number() == 1) { |
1627 *mailbox = TextureMailbox(); | 1638 *texture_mailbox = TextureMailbox(); |
1628 return true; | 1639 return true; |
1629 } | 1640 } |
1630 | 1641 |
1631 *mailbox = TextureMailbox(std::string(64, '1')); | 1642 *texture_mailbox = TextureMailbox( |
| 1643 MailboxFromString(std::string(64, '1')), GL_TEXTURE_2D, 0); |
1632 *release_callback = SingleReleaseCallback::Create( | 1644 *release_callback = SingleReleaseCallback::Create( |
1633 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, | 1645 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, |
1634 base::Unretained(this))); | 1646 base::Unretained(this))); |
1635 return true; | 1647 return true; |
1636 } | 1648 } |
1637 | 1649 |
1638 void MailboxReleased(unsigned sync_point, bool lost_resource) { | 1650 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
1639 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); | 1651 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); |
1640 EndTest(); | 1652 EndTest(); |
1641 } | 1653 } |
1642 | 1654 |
1643 virtual void SetupTree() OVERRIDE { | 1655 virtual void SetupTree() OVERRIDE { |
1644 scoped_refptr<Layer> root = Layer::Create(); | 1656 scoped_refptr<Layer> root = Layer::Create(); |
1645 root->SetBounds(gfx::Size(10, 10)); | 1657 root->SetBounds(gfx::Size(10, 10)); |
1646 root->SetAnchorPoint(gfx::PointF()); | 1658 root->SetAnchorPoint(gfx::PointF()); |
1647 root->SetIsDrawable(true); | 1659 root->SetIsDrawable(true); |
1648 | 1660 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 if (!mailbox_changed_) | 1744 if (!mailbox_changed_) |
1733 return false; | 1745 return false; |
1734 *mailbox = mailbox_; | 1746 *mailbox = mailbox_; |
1735 *release_callback = SingleReleaseCallback::Create( | 1747 *release_callback = SingleReleaseCallback::Create( |
1736 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased, | 1748 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased, |
1737 base::Unretained(this))); | 1749 base::Unretained(this))); |
1738 return true; | 1750 return true; |
1739 } | 1751 } |
1740 | 1752 |
1741 TextureMailbox MakeMailbox(char name) { | 1753 TextureMailbox MakeMailbox(char name) { |
1742 return TextureMailbox(std::string(64, name)); | 1754 return TextureMailbox( |
| 1755 MailboxFromString(std::string(64, name)), GL_TEXTURE_2D, 0); |
1743 } | 1756 } |
1744 | 1757 |
1745 void MailboxReleased(unsigned sync_point, bool lost_resource) { | 1758 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
1746 ++mailbox_returned_; | 1759 ++mailbox_returned_; |
1747 } | 1760 } |
1748 | 1761 |
1749 virtual void SetupTree() OVERRIDE { | 1762 virtual void SetupTree() OVERRIDE { |
1750 scoped_refptr<Layer> root = Layer::Create(); | 1763 scoped_refptr<Layer> root = Layer::Create(); |
1751 root->SetBounds(gfx::Size(10, 10)); | 1764 root->SetBounds(gfx::Size(10, 10)); |
1752 root->SetAnchorPoint(gfx::PointF()); | 1765 root->SetAnchorPoint(gfx::PointF()); |
1753 root->SetIsDrawable(true); | 1766 root->SetIsDrawable(true); |
1754 | 1767 |
1755 solid_layer_ = SolidColorLayer::Create(); | 1768 solid_layer_ = SolidColorLayer::Create(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 public: | 1878 public: |
1866 // TextureLayerClient implementation. | 1879 // TextureLayerClient implementation. |
1867 virtual unsigned PrepareTexture() OVERRIDE { | 1880 virtual unsigned PrepareTexture() OVERRIDE { |
1868 NOTREACHED(); | 1881 NOTREACHED(); |
1869 return 0; | 1882 return 0; |
1870 } | 1883 } |
1871 virtual bool PrepareTextureMailbox( | 1884 virtual bool PrepareTextureMailbox( |
1872 TextureMailbox* mailbox, | 1885 TextureMailbox* mailbox, |
1873 scoped_ptr<SingleReleaseCallback>* release_callback, | 1886 scoped_ptr<SingleReleaseCallback>* release_callback, |
1874 bool use_shared_memory) OVERRIDE { | 1887 bool use_shared_memory) OVERRIDE { |
1875 *mailbox = TextureMailbox(std::string(64, '1')); | 1888 *mailbox = TextureMailbox( |
| 1889 MailboxFromString(std::string(64, '1')), GL_TEXTURE_2D, 0); |
1876 *release_callback = SingleReleaseCallback::Create( | 1890 *release_callback = SingleReleaseCallback::Create( |
1877 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased, | 1891 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased, |
1878 base::Unretained(this))); | 1892 base::Unretained(this))); |
1879 return true; | 1893 return true; |
1880 } | 1894 } |
1881 | 1895 |
1882 void MailboxReleased(unsigned sync_point, bool lost_resource) { | 1896 void MailboxReleased(unsigned sync_point, bool lost_resource) { |
1883 mailbox_released_ = true; | 1897 mailbox_released_ = true; |
1884 } | 1898 } |
1885 | 1899 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 private: | 2021 private: |
2008 scoped_refptr<TextureLayer> texture_layer_; | 2022 scoped_refptr<TextureLayer> texture_layer_; |
2009 bool context_lost_; | 2023 bool context_lost_; |
2010 int draw_count_; | 2024 int draw_count_; |
2011 }; | 2025 }; |
2012 | 2026 |
2013 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerLostContextTest); | 2027 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerLostContextTest); |
2014 | 2028 |
2015 class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest { | 2029 class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest { |
2016 public: | 2030 public: |
2017 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 2031 void ReleaseCallback(uint32 sync_point, bool lost_resource) { |
2018 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 2032 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
2019 EXPECT_FALSE(lost_resource); | 2033 EXPECT_FALSE(lost_resource); |
2020 ++callback_count_; | 2034 ++callback_count_; |
2021 EndTest(); | 2035 EndTest(); |
2022 } | 2036 } |
2023 | 2037 |
2024 void SetMailbox(char mailbox_char) { | 2038 void SetMailbox(char mailbox_char) { |
2025 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 2039 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
2026 TextureMailbox mailbox(std::string(64, mailbox_char)); | |
2027 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2040 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
2028 base::Bind( | 2041 base::Bind( |
2029 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, | 2042 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, |
2030 base::Unretained(this))); | 2043 base::Unretained(this))); |
2031 layer_->SetTextureMailbox(mailbox, callback.Pass()); | 2044 layer_->SetTextureMailbox( |
| 2045 TextureMailbox( |
| 2046 MailboxFromString(std::string(64, mailbox_char)), GL_TEXTURE_2D, 0), |
| 2047 callback.Pass()); |
2032 } | 2048 } |
2033 | 2049 |
2034 virtual void SetupTree() OVERRIDE { | 2050 virtual void SetupTree() OVERRIDE { |
2035 gfx::Size bounds(100, 100); | 2051 gfx::Size bounds(100, 100); |
2036 root_ = Layer::Create(); | 2052 root_ = Layer::Create(); |
2037 root_->SetAnchorPoint(gfx::PointF()); | 2053 root_->SetAnchorPoint(gfx::PointF()); |
2038 root_->SetBounds(bounds); | 2054 root_->SetBounds(bounds); |
2039 | 2055 |
2040 layer_ = TextureLayer::CreateForMailbox(NULL); | 2056 layer_ = TextureLayer::CreateForMailbox(NULL); |
2041 layer_->SetIsDrawable(true); | 2057 layer_->SetIsDrawable(true); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 int callback_count_; | 2095 int callback_count_; |
2080 scoped_refptr<Layer> root_; | 2096 scoped_refptr<Layer> root_; |
2081 scoped_refptr<TextureLayer> layer_; | 2097 scoped_refptr<TextureLayer> layer_; |
2082 }; | 2098 }; |
2083 | 2099 |
2084 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 2100 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
2085 TextureLayerWithMailboxMainThreadDeleted); | 2101 TextureLayerWithMailboxMainThreadDeleted); |
2086 | 2102 |
2087 class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest { | 2103 class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest { |
2088 public: | 2104 public: |
2089 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 2105 void ReleaseCallback(uint32 sync_point, bool lost_resource) { |
2090 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 2106 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
2091 EXPECT_FALSE(lost_resource); | 2107 EXPECT_FALSE(lost_resource); |
2092 ++callback_count_; | 2108 ++callback_count_; |
2093 EndTest(); | 2109 EndTest(); |
2094 } | 2110 } |
2095 | 2111 |
2096 void SetMailbox(char mailbox_char) { | 2112 void SetMailbox(char mailbox_char) { |
2097 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 2113 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
2098 TextureMailbox mailbox(std::string(64, mailbox_char)); | |
2099 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2114 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
2100 base::Bind( | 2115 base::Bind( |
2101 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, | 2116 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, |
2102 base::Unretained(this))); | 2117 base::Unretained(this))); |
2103 layer_->SetTextureMailbox(mailbox, callback.Pass()); | 2118 layer_->SetTextureMailbox( |
| 2119 TextureMailbox( |
| 2120 MailboxFromString(std::string(64, mailbox_char)), GL_TEXTURE_2D, 0), |
| 2121 callback.Pass()); |
2104 } | 2122 } |
2105 | 2123 |
2106 virtual void SetupTree() OVERRIDE { | 2124 virtual void SetupTree() OVERRIDE { |
2107 gfx::Size bounds(100, 100); | 2125 gfx::Size bounds(100, 100); |
2108 root_ = Layer::Create(); | 2126 root_ = Layer::Create(); |
2109 root_->SetAnchorPoint(gfx::PointF()); | 2127 root_->SetAnchorPoint(gfx::PointF()); |
2110 root_->SetBounds(bounds); | 2128 root_->SetBounds(bounds); |
2111 | 2129 |
2112 layer_ = TextureLayer::CreateForMailbox(NULL); | 2130 layer_ = TextureLayer::CreateForMailbox(NULL); |
2113 layer_->SetIsDrawable(true); | 2131 layer_->SetIsDrawable(true); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2154 int callback_count_; | 2172 int callback_count_; |
2155 scoped_refptr<Layer> root_; | 2173 scoped_refptr<Layer> root_; |
2156 scoped_refptr<TextureLayer> layer_; | 2174 scoped_refptr<TextureLayer> layer_; |
2157 }; | 2175 }; |
2158 | 2176 |
2159 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 2177 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
2160 TextureLayerWithMailboxImplThreadDeleted); | 2178 TextureLayerWithMailboxImplThreadDeleted); |
2161 | 2179 |
2162 } // namespace | 2180 } // namespace |
2163 } // namespace cc | 2181 } // namespace cc |
OLD | NEW |