| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 TextureLayerNoMailboxIsActivatedDuringCommit); | 1019 TextureLayerNoMailboxIsActivatedDuringCommit); |
| 1011 | 1020 |
| 1012 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { | 1021 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { |
| 1013 protected: | 1022 protected: |
| 1014 TextureLayerMailboxIsActivatedDuringCommit() | 1023 TextureLayerMailboxIsActivatedDuringCommit() |
| 1015 : wait_thread_("WAIT"), | 1024 : wait_thread_("WAIT"), |
| 1016 wait_event_(false, false) { | 1025 wait_event_(false, false) { |
| 1017 wait_thread_.Start(); | 1026 wait_thread_.Start(); |
| 1018 } | 1027 } |
| 1019 | 1028 |
| 1020 static void ReleaseCallback(unsigned sync_point, bool lost_resource) {} | 1029 static void ReleaseCallback(uint32 sync_point, bool lost_resource) {} |
| 1021 | 1030 |
| 1022 void SetMailbox(char mailbox_char) { | 1031 void SetMailbox(char mailbox_char) { |
| 1023 TextureMailbox mailbox(std::string(64, mailbox_char)); | |
| 1024 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 1032 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 1025 base::Bind( | 1033 base::Bind( |
| 1026 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); | 1034 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); |
| 1027 layer_->SetTextureMailbox(mailbox, callback.Pass()); | 1035 layer_->SetTextureMailbox( |
| 1036 TextureMailbox( |
| 1037 MailboxFromString(std::string(64, mailbox_char)), GL_TEXTURE_2D, 0), |
| 1038 callback.Pass()); |
| 1028 } | 1039 } |
| 1029 | 1040 |
| 1030 virtual void BeginTest() OVERRIDE { | 1041 virtual void BeginTest() OVERRIDE { |
| 1031 activate_count_ = 0; | 1042 activate_count_ = 0; |
| 1032 | 1043 |
| 1033 gfx::Size bounds(100, 100); | 1044 gfx::Size bounds(100, 100); |
| 1034 root_ = Layer::Create(); | 1045 root_ = Layer::Create(); |
| 1035 root_->SetAnchorPoint(gfx::PointF()); | 1046 root_->SetAnchorPoint(gfx::PointF()); |
| 1036 root_->SetBounds(bounds); | 1047 root_->SetBounds(bounds); |
| 1037 | 1048 |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 class TextureLayerNoExtraCommitForMailboxTest | 1693 class TextureLayerNoExtraCommitForMailboxTest |
| 1683 : public LayerTreeTest, | 1694 : public LayerTreeTest, |
| 1684 public TextureLayerClient { | 1695 public TextureLayerClient { |
| 1685 public: | 1696 public: |
| 1686 // TextureLayerClient implementation. | 1697 // TextureLayerClient implementation. |
| 1687 virtual unsigned PrepareTexture() OVERRIDE { | 1698 virtual unsigned PrepareTexture() OVERRIDE { |
| 1688 NOTREACHED(); | 1699 NOTREACHED(); |
| 1689 return 0; | 1700 return 0; |
| 1690 } | 1701 } |
| 1691 virtual bool PrepareTextureMailbox( | 1702 virtual bool PrepareTextureMailbox( |
| 1692 TextureMailbox* mailbox, | 1703 TextureMailbox* texture_mailbox, |
| 1693 scoped_ptr<SingleReleaseCallback>* release_callback, | 1704 scoped_ptr<SingleReleaseCallback>* release_callback, |
| 1694 bool use_shared_memory) OVERRIDE { | 1705 bool use_shared_memory) OVERRIDE { |
| 1695 if (layer_tree_host()->source_frame_number() == 1) { | 1706 if (layer_tree_host()->source_frame_number() == 1) { |
| 1696 *mailbox = TextureMailbox(); | 1707 *texture_mailbox = TextureMailbox(); |
| 1697 return true; | 1708 return true; |
| 1698 } | 1709 } |
| 1699 | 1710 |
| 1700 *mailbox = TextureMailbox(std::string(64, '1')); | 1711 *texture_mailbox = TextureMailbox( |
| 1712 MailboxFromString(std::string(64, '1')), GL_TEXTURE_2D, 0); |
| 1701 *release_callback = SingleReleaseCallback::Create( | 1713 *release_callback = SingleReleaseCallback::Create( |
| 1702 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, | 1714 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, |
| 1703 base::Unretained(this))); | 1715 base::Unretained(this))); |
| 1704 return true; | 1716 return true; |
| 1705 } | 1717 } |
| 1706 | 1718 |
| 1707 void MailboxReleased(unsigned sync_point, bool lost_resource) { | 1719 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
| 1708 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); | 1720 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); |
| 1709 EndTest(); | 1721 EndTest(); |
| 1710 } | 1722 } |
| 1711 | 1723 |
| 1712 virtual void SetupTree() OVERRIDE { | 1724 virtual void SetupTree() OVERRIDE { |
| 1713 scoped_refptr<Layer> root = Layer::Create(); | 1725 scoped_refptr<Layer> root = Layer::Create(); |
| 1714 root->SetBounds(gfx::Size(10, 10)); | 1726 root->SetBounds(gfx::Size(10, 10)); |
| 1715 root->SetAnchorPoint(gfx::PointF()); | 1727 root->SetAnchorPoint(gfx::PointF()); |
| 1716 root->SetIsDrawable(true); | 1728 root->SetIsDrawable(true); |
| 1717 | 1729 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1814 if (!mailbox_changed_) | 1826 if (!mailbox_changed_) |
| 1815 return false; | 1827 return false; |
| 1816 *mailbox = mailbox_; | 1828 *mailbox = mailbox_; |
| 1817 *release_callback = SingleReleaseCallback::Create( | 1829 *release_callback = SingleReleaseCallback::Create( |
| 1818 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased, | 1830 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased, |
| 1819 base::Unretained(this))); | 1831 base::Unretained(this))); |
| 1820 return true; | 1832 return true; |
| 1821 } | 1833 } |
| 1822 | 1834 |
| 1823 TextureMailbox MakeMailbox(char name) { | 1835 TextureMailbox MakeMailbox(char name) { |
| 1824 return TextureMailbox(std::string(64, name)); | 1836 return TextureMailbox( |
| 1837 MailboxFromString(std::string(64, name)), GL_TEXTURE_2D, 0); |
| 1825 } | 1838 } |
| 1826 | 1839 |
| 1827 void MailboxReleased(unsigned sync_point, bool lost_resource) { | 1840 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
| 1828 ++mailbox_returned_; | 1841 ++mailbox_returned_; |
| 1829 } | 1842 } |
| 1830 | 1843 |
| 1831 virtual void SetupTree() OVERRIDE { | 1844 virtual void SetupTree() OVERRIDE { |
| 1832 scoped_refptr<Layer> root = Layer::Create(); | 1845 scoped_refptr<Layer> root = Layer::Create(); |
| 1833 root->SetBounds(gfx::Size(10, 10)); | 1846 root->SetBounds(gfx::Size(10, 10)); |
| 1834 root->SetAnchorPoint(gfx::PointF()); | 1847 root->SetAnchorPoint(gfx::PointF()); |
| 1835 root->SetIsDrawable(true); | 1848 root->SetIsDrawable(true); |
| 1836 | 1849 |
| 1837 solid_layer_ = SolidColorLayer::Create(); | 1850 solid_layer_ = SolidColorLayer::Create(); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2008 private: | 2021 private: |
| 2009 scoped_refptr<TextureLayer> texture_layer_; | 2022 scoped_refptr<TextureLayer> texture_layer_; |
| 2010 bool context_lost_; | 2023 bool context_lost_; |
| 2011 int draw_count_; | 2024 int draw_count_; |
| 2012 }; | 2025 }; |
| 2013 | 2026 |
| 2014 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerLostContextTest); | 2027 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerLostContextTest); |
| 2015 | 2028 |
| 2016 class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest { | 2029 class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest { |
| 2017 public: | 2030 public: |
| 2018 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 2031 void ReleaseCallback(uint32 sync_point, bool lost_resource) { |
| 2019 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 2032 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 2020 EXPECT_FALSE(lost_resource); | 2033 EXPECT_FALSE(lost_resource); |
| 2021 ++callback_count_; | 2034 ++callback_count_; |
| 2022 EndTest(); | 2035 EndTest(); |
| 2023 } | 2036 } |
| 2024 | 2037 |
| 2025 void SetMailbox(char mailbox_char) { | 2038 void SetMailbox(char mailbox_char) { |
| 2026 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 2039 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 2027 TextureMailbox mailbox(std::string(64, mailbox_char)); | |
| 2028 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2040 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 2029 base::Bind( | 2041 base::Bind( |
| 2030 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, | 2042 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, |
| 2031 base::Unretained(this))); | 2043 base::Unretained(this))); |
| 2032 layer_->SetTextureMailbox(mailbox, callback.Pass()); | 2044 layer_->SetTextureMailbox( |
| 2045 TextureMailbox( |
| 2046 MailboxFromString(std::string(64, mailbox_char)), GL_TEXTURE_2D, 0), |
| 2047 callback.Pass()); |
| 2033 } | 2048 } |
| 2034 | 2049 |
| 2035 virtual void SetupTree() OVERRIDE { | 2050 virtual void SetupTree() OVERRIDE { |
| 2036 gfx::Size bounds(100, 100); | 2051 gfx::Size bounds(100, 100); |
| 2037 root_ = Layer::Create(); | 2052 root_ = Layer::Create(); |
| 2038 root_->SetAnchorPoint(gfx::PointF()); | 2053 root_->SetAnchorPoint(gfx::PointF()); |
| 2039 root_->SetBounds(bounds); | 2054 root_->SetBounds(bounds); |
| 2040 | 2055 |
| 2041 layer_ = TextureLayer::CreateForMailbox(NULL); | 2056 layer_ = TextureLayer::CreateForMailbox(NULL); |
| 2042 layer_->SetIsDrawable(true); | 2057 layer_->SetIsDrawable(true); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 int callback_count_; | 2095 int callback_count_; |
| 2081 scoped_refptr<Layer> root_; | 2096 scoped_refptr<Layer> root_; |
| 2082 scoped_refptr<TextureLayer> layer_; | 2097 scoped_refptr<TextureLayer> layer_; |
| 2083 }; | 2098 }; |
| 2084 | 2099 |
| 2085 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 2100 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 2086 TextureLayerWithMailboxMainThreadDeleted); | 2101 TextureLayerWithMailboxMainThreadDeleted); |
| 2087 | 2102 |
| 2088 class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest { | 2103 class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest { |
| 2089 public: | 2104 public: |
| 2090 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 2105 void ReleaseCallback(uint32 sync_point, bool lost_resource) { |
| 2091 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 2106 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 2092 EXPECT_FALSE(lost_resource); | 2107 EXPECT_FALSE(lost_resource); |
| 2093 ++callback_count_; | 2108 ++callback_count_; |
| 2094 EndTest(); | 2109 EndTest(); |
| 2095 } | 2110 } |
| 2096 | 2111 |
| 2097 void SetMailbox(char mailbox_char) { | 2112 void SetMailbox(char mailbox_char) { |
| 2098 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 2113 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 2099 TextureMailbox mailbox(std::string(64, mailbox_char)); | |
| 2100 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2114 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 2101 base::Bind( | 2115 base::Bind( |
| 2102 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, | 2116 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, |
| 2103 base::Unretained(this))); | 2117 base::Unretained(this))); |
| 2104 layer_->SetTextureMailbox(mailbox, callback.Pass()); | 2118 layer_->SetTextureMailbox( |
| 2119 TextureMailbox( |
| 2120 MailboxFromString(std::string(64, mailbox_char)), GL_TEXTURE_2D, 0), |
| 2121 callback.Pass()); |
| 2105 } | 2122 } |
| 2106 | 2123 |
| 2107 virtual void SetupTree() OVERRIDE { | 2124 virtual void SetupTree() OVERRIDE { |
| 2108 gfx::Size bounds(100, 100); | 2125 gfx::Size bounds(100, 100); |
| 2109 root_ = Layer::Create(); | 2126 root_ = Layer::Create(); |
| 2110 root_->SetAnchorPoint(gfx::PointF()); | 2127 root_->SetAnchorPoint(gfx::PointF()); |
| 2111 root_->SetBounds(bounds); | 2128 root_->SetBounds(bounds); |
| 2112 | 2129 |
| 2113 layer_ = TextureLayer::CreateForMailbox(NULL); | 2130 layer_ = TextureLayer::CreateForMailbox(NULL); |
| 2114 layer_->SetIsDrawable(true); | 2131 layer_->SetIsDrawable(true); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2155 int callback_count_; | 2172 int callback_count_; |
| 2156 scoped_refptr<Layer> root_; | 2173 scoped_refptr<Layer> root_; |
| 2157 scoped_refptr<TextureLayer> layer_; | 2174 scoped_refptr<TextureLayer> layer_; |
| 2158 }; | 2175 }; |
| 2159 | 2176 |
| 2160 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 2177 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 2161 TextureLayerWithMailboxImplThreadDeleted); | 2178 TextureLayerWithMailboxImplThreadDeleted); |
| 2162 | 2179 |
| 2163 } // namespace | 2180 } // namespace |
| 2164 } // namespace cc | 2181 } // namespace cc |
| OLD | NEW |