| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 308 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 309 | 309 |
| 310 // Stop rate limiter when we're removed from the tree. | 310 // Stop rate limiter when we're removed from the tree. |
| 311 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); | 311 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); |
| 312 layer_tree_host_->SetRootLayer(NULL); | 312 layer_tree_host_->SetRootLayer(NULL); |
| 313 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 313 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 314 } | 314 } |
| 315 | 315 |
| 316 class MockMailboxCallback { | 316 class MockMailboxCallback { |
| 317 public: | 317 public: |
| 318 MOCK_METHOD3(Release, void(const std::string& mailbox, | 318 MOCK_METHOD3(Release, |
| 319 unsigned sync_point, | 319 void(const std::string& mailbox, |
| 320 bool lost_resource)); | 320 uint32 sync_point, |
| 321 MOCK_METHOD3(Release2, void(base::SharedMemory* shared_memory, | 321 bool lost_resource)); |
| 322 unsigned sync_point, | 322 MOCK_METHOD3(Release2, |
| 323 bool lost_resource)); | 323 void(base::SharedMemory* shared_memory, |
| 324 uint32 sync_point, |
| 325 bool lost_resource)); |
| 324 }; | 326 }; |
| 325 | 327 |
| 326 struct CommonMailboxObjects { | 328 struct CommonMailboxObjects { |
| 327 CommonMailboxObjects() | 329 CommonMailboxObjects() |
| 328 : mailbox_name1_(64, '1'), | 330 : mailbox_name1_(64, '1'), |
| 329 mailbox_name2_(64, '2'), | 331 mailbox_name2_(64, '2'), |
| 330 sync_point1_(1), | 332 sync_point1_(1), |
| 331 sync_point2_(2), | 333 sync_point2_(2), |
| 332 shared_memory_(new base::SharedMemory) { | 334 shared_memory_(new base::SharedMemory) { |
| 333 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, | 335 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, |
| 334 base::Unretained(&mock_callback_), | 336 base::Unretained(&mock_callback_), |
| 335 mailbox_name1_); | 337 mailbox_name1_); |
| 336 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, | 338 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, |
| 337 base::Unretained(&mock_callback_), | 339 base::Unretained(&mock_callback_), |
| 338 mailbox_name2_); | 340 mailbox_name2_); |
| 339 gpu::Mailbox m1; | 341 gpu::Mailbox m1; |
| 340 m1.SetName(reinterpret_cast<const int8*>(mailbox_name1_.data())); | 342 m1.SetName(reinterpret_cast<const int8*>(mailbox_name1_.data())); |
| 341 mailbox1_ = TextureMailbox(m1, sync_point1_); | 343 mailbox1_ = TextureMailbox(m1, 1, sync_point1_); |
| 342 gpu::Mailbox m2; | 344 gpu::Mailbox m2; |
| 343 m2.SetName(reinterpret_cast<const int8*>(mailbox_name2_.data())); | 345 m2.SetName(reinterpret_cast<const int8*>(mailbox_name2_.data())); |
| 344 mailbox2_ = TextureMailbox(m2, sync_point2_); | 346 mailbox2_ = TextureMailbox(m2, 2, sync_point2_); |
| 345 | 347 |
| 346 gfx::Size size(128, 128); | 348 gfx::Size size(128, 128); |
| 347 EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea())); | 349 EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea())); |
| 348 release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2, | 350 release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2, |
| 349 base::Unretained(&mock_callback_), | 351 base::Unretained(&mock_callback_), |
| 350 shared_memory_.get()); | 352 shared_memory_.get()); |
| 351 mailbox3_ = TextureMailbox(shared_memory_.get(), size); | 353 mailbox3_ = TextureMailbox(shared_memory_.get(), size); |
| 352 } | 354 } |
| 353 | 355 |
| 354 std::string mailbox_name1_; | 356 std::string mailbox_name1_; |
| 355 std::string mailbox_name2_; | 357 std::string mailbox_name2_; |
| 356 MockMailboxCallback mock_callback_; | 358 MockMailboxCallback mock_callback_; |
| 357 ReleaseCallback release_mailbox1_; | 359 ReleaseCallback release_mailbox1_; |
| 358 ReleaseCallback release_mailbox2_; | 360 ReleaseCallback release_mailbox2_; |
| 359 ReleaseCallback release_mailbox3_; | 361 ReleaseCallback release_mailbox3_; |
| 360 TextureMailbox mailbox1_; | 362 TextureMailbox mailbox1_; |
| 361 TextureMailbox mailbox2_; | 363 TextureMailbox mailbox2_; |
| 362 TextureMailbox mailbox3_; | 364 TextureMailbox mailbox3_; |
| 363 unsigned sync_point1_; | 365 uint32 sync_point1_; |
| 364 unsigned sync_point2_; | 366 uint32 sync_point2_; |
| 365 scoped_ptr<base::SharedMemory> shared_memory_; | 367 scoped_ptr<base::SharedMemory> shared_memory_; |
| 366 }; | 368 }; |
| 367 | 369 |
| 368 class TestMailboxHolder : public TextureLayer::MailboxHolder { | 370 class TestMailboxHolder : public TextureLayer::TextureMailboxHolder { |
| 369 public: | 371 public: |
| 370 using TextureLayer::MailboxHolder::Create; | 372 using TextureLayer::TextureMailboxHolder::Create; |
| 371 | 373 |
| 372 protected: | 374 protected: |
| 373 virtual ~TestMailboxHolder() {} | 375 virtual ~TestMailboxHolder() {} |
| 374 }; | 376 }; |
| 375 | 377 |
| 376 class TextureLayerWithMailboxTest : public TextureLayerTest { | 378 class TextureLayerWithMailboxTest : public TextureLayerTest { |
| 377 protected: | 379 protected: |
| 378 virtual void TearDown() { | 380 virtual void TearDown() { |
| 379 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 381 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
| 380 EXPECT_CALL(test_data_.mock_callback_, | 382 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_); | 749 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
| 748 } | 750 } |
| 749 | 751 |
| 750 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { | 752 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { |
| 751 public: | 753 public: |
| 752 TextureLayerImplWithMailboxThreadedCallback() | 754 TextureLayerImplWithMailboxThreadedCallback() |
| 753 : callback_count_(0), | 755 : callback_count_(0), |
| 754 commit_count_(0) {} | 756 commit_count_(0) {} |
| 755 | 757 |
| 756 // Make sure callback is received on main and doesn't block the impl thread. | 758 // Make sure callback is received on main and doesn't block the impl thread. |
| 757 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 759 void ReleaseCallback(uint32 sync_point, bool lost_resource) { |
| 758 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 760 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 759 EXPECT_FALSE(lost_resource); | 761 EXPECT_FALSE(lost_resource); |
| 760 ++callback_count_; | 762 ++callback_count_; |
| 761 } | 763 } |
| 762 | 764 |
| 763 void SetMailbox(char mailbox_char) { | 765 void SetMailbox(char mailbox_char) { |
| 764 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 766 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 765 TextureMailbox mailbox(std::string(64, mailbox_char)); | 767 gpu::Mailbox mailbox; |
| 768 mailbox.SetName( |
| 769 reinterpret_cast<const int8*>(std::string(64, mailbox_char).data())); |
| 766 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 770 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 767 base::Bind( | 771 base::Bind( |
| 768 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, | 772 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, |
| 769 base::Unretained(this))); | 773 base::Unretained(this))); |
| 770 layer_->SetTextureMailbox(mailbox, callback.Pass()); | 774 layer_->SetTextureMailbox(TextureMailbox(mailbox, GL_TEXTURE_2D, 0), |
| 775 callback.Pass()); |
| 771 } | 776 } |
| 772 | 777 |
| 773 virtual void BeginTest() OVERRIDE { | 778 virtual void BeginTest() OVERRIDE { |
| 774 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 779 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 775 | 780 |
| 776 gfx::Size bounds(100, 100); | 781 gfx::Size bounds(100, 100); |
| 777 root_ = Layer::Create(); | 782 root_ = Layer::Create(); |
| 778 root_->SetAnchorPoint(gfx::PointF()); | 783 root_->SetAnchorPoint(gfx::PointF()); |
| 779 root_->SetBounds(bounds); | 784 root_->SetBounds(bounds); |
| 780 | 785 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 TextureLayerNoMailboxIsActivatedDuringCommit); | 1015 TextureLayerNoMailboxIsActivatedDuringCommit); |
| 1011 | 1016 |
| 1012 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { | 1017 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { |
| 1013 protected: | 1018 protected: |
| 1014 TextureLayerMailboxIsActivatedDuringCommit() | 1019 TextureLayerMailboxIsActivatedDuringCommit() |
| 1015 : wait_thread_("WAIT"), | 1020 : wait_thread_("WAIT"), |
| 1016 wait_event_(false, false) { | 1021 wait_event_(false, false) { |
| 1017 wait_thread_.Start(); | 1022 wait_thread_.Start(); |
| 1018 } | 1023 } |
| 1019 | 1024 |
| 1020 static void ReleaseCallback(unsigned sync_point, bool lost_resource) {} | 1025 static void ReleaseCallback(uint32 sync_point, bool lost_resource) {} |
| 1021 | 1026 |
| 1022 void SetMailbox(char mailbox_char) { | 1027 void SetMailbox(char mailbox_char) { |
| 1023 TextureMailbox mailbox(std::string(64, mailbox_char)); | 1028 gpu::Mailbox mailbox; |
| 1029 mailbox.SetName( |
| 1030 reinterpret_cast<const int8*>(std::string(64, mailbox_char).data())); |
| 1024 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 1031 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 1025 base::Bind( | 1032 base::Bind( |
| 1026 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); | 1033 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); |
| 1027 layer_->SetTextureMailbox(mailbox, callback.Pass()); | 1034 layer_->SetTextureMailbox(TextureMailbox(mailbox, GL_TEXTURE_2D, 0), |
| 1035 callback.Pass()); |
| 1028 } | 1036 } |
| 1029 | 1037 |
| 1030 virtual void BeginTest() OVERRIDE { | 1038 virtual void BeginTest() OVERRIDE { |
| 1031 activate_count_ = 0; | 1039 activate_count_ = 0; |
| 1032 | 1040 |
| 1033 gfx::Size bounds(100, 100); | 1041 gfx::Size bounds(100, 100); |
| 1034 root_ = Layer::Create(); | 1042 root_ = Layer::Create(); |
| 1035 root_->SetAnchorPoint(gfx::PointF()); | 1043 root_->SetAnchorPoint(gfx::PointF()); |
| 1036 root_->SetBounds(bounds); | 1044 root_->SetBounds(bounds); |
| 1037 | 1045 |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 class TextureLayerNoExtraCommitForMailboxTest | 1690 class TextureLayerNoExtraCommitForMailboxTest |
| 1683 : public LayerTreeTest, | 1691 : public LayerTreeTest, |
| 1684 public TextureLayerClient { | 1692 public TextureLayerClient { |
| 1685 public: | 1693 public: |
| 1686 // TextureLayerClient implementation. | 1694 // TextureLayerClient implementation. |
| 1687 virtual unsigned PrepareTexture() OVERRIDE { | 1695 virtual unsigned PrepareTexture() OVERRIDE { |
| 1688 NOTREACHED(); | 1696 NOTREACHED(); |
| 1689 return 0; | 1697 return 0; |
| 1690 } | 1698 } |
| 1691 virtual bool PrepareTextureMailbox( | 1699 virtual bool PrepareTextureMailbox( |
| 1692 TextureMailbox* mailbox, | 1700 TextureMailbox* texture_mailbox, |
| 1693 scoped_ptr<SingleReleaseCallback>* release_callback, | 1701 scoped_ptr<SingleReleaseCallback>* release_callback, |
| 1694 bool use_shared_memory) OVERRIDE { | 1702 bool use_shared_memory) OVERRIDE { |
| 1695 if (layer_tree_host()->source_frame_number() == 1) { | 1703 if (layer_tree_host()->source_frame_number() == 1) { |
| 1696 *mailbox = TextureMailbox(); | 1704 *texture_mailbox = TextureMailbox(); |
| 1697 return true; | 1705 return true; |
| 1698 } | 1706 } |
| 1699 | 1707 |
| 1700 *mailbox = TextureMailbox(std::string(64, '1')); | 1708 gpu::Mailbox mailbox; |
| 1709 mailbox.SetName(reinterpret_cast<const int8*>(std::string(64, '1').data())); |
| 1710 *texture_mailbox = TextureMailbox(mailbox, GL_TEXTURE_2D, 0); |
| 1701 *release_callback = SingleReleaseCallback::Create( | 1711 *release_callback = SingleReleaseCallback::Create( |
| 1702 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, | 1712 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, |
| 1703 base::Unretained(this))); | 1713 base::Unretained(this))); |
| 1704 return true; | 1714 return true; |
| 1705 } | 1715 } |
| 1706 | 1716 |
| 1707 void MailboxReleased(unsigned sync_point, bool lost_resource) { | 1717 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
| 1708 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); | 1718 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); |
| 1709 EndTest(); | 1719 EndTest(); |
| 1710 } | 1720 } |
| 1711 | 1721 |
| 1712 virtual void SetupTree() OVERRIDE { | 1722 virtual void SetupTree() OVERRIDE { |
| 1713 scoped_refptr<Layer> root = Layer::Create(); | 1723 scoped_refptr<Layer> root = Layer::Create(); |
| 1714 root->SetBounds(gfx::Size(10, 10)); | 1724 root->SetBounds(gfx::Size(10, 10)); |
| 1715 root->SetAnchorPoint(gfx::PointF()); | 1725 root->SetAnchorPoint(gfx::PointF()); |
| 1716 root->SetIsDrawable(true); | 1726 root->SetIsDrawable(true); |
| 1717 | 1727 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1814 if (!mailbox_changed_) | 1824 if (!mailbox_changed_) |
| 1815 return false; | 1825 return false; |
| 1816 *mailbox = mailbox_; | 1826 *mailbox = mailbox_; |
| 1817 *release_callback = SingleReleaseCallback::Create( | 1827 *release_callback = SingleReleaseCallback::Create( |
| 1818 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased, | 1828 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased, |
| 1819 base::Unretained(this))); | 1829 base::Unretained(this))); |
| 1820 return true; | 1830 return true; |
| 1821 } | 1831 } |
| 1822 | 1832 |
| 1823 TextureMailbox MakeMailbox(char name) { | 1833 TextureMailbox MakeMailbox(char name) { |
| 1824 return TextureMailbox(std::string(64, name)); | 1834 gpu::Mailbox mailbox; |
| 1835 mailbox.SetName( |
| 1836 reinterpret_cast<const int8*>(std::string(64, name).data())); |
| 1837 return TextureMailbox(mailbox, 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)); | 2040 gpu::Mailbox mailbox; |
| 2041 mailbox.SetName( |
| 2042 reinterpret_cast<const int8*>(std::string(64, mailbox_char).data())); |
| 2028 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2043 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 2029 base::Bind( | 2044 base::Bind( |
| 2030 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, | 2045 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, |
| 2031 base::Unretained(this))); | 2046 base::Unretained(this))); |
| 2032 layer_->SetTextureMailbox(mailbox, callback.Pass()); | 2047 layer_->SetTextureMailbox(TextureMailbox(mailbox, GL_TEXTURE_2D, 0), |
| 2048 callback.Pass()); |
| 2033 } | 2049 } |
| 2034 | 2050 |
| 2035 virtual void SetupTree() OVERRIDE { | 2051 virtual void SetupTree() OVERRIDE { |
| 2036 gfx::Size bounds(100, 100); | 2052 gfx::Size bounds(100, 100); |
| 2037 root_ = Layer::Create(); | 2053 root_ = Layer::Create(); |
| 2038 root_->SetAnchorPoint(gfx::PointF()); | 2054 root_->SetAnchorPoint(gfx::PointF()); |
| 2039 root_->SetBounds(bounds); | 2055 root_->SetBounds(bounds); |
| 2040 | 2056 |
| 2041 layer_ = TextureLayer::CreateForMailbox(NULL); | 2057 layer_ = TextureLayer::CreateForMailbox(NULL); |
| 2042 layer_->SetIsDrawable(true); | 2058 layer_->SetIsDrawable(true); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 int callback_count_; | 2096 int callback_count_; |
| 2081 scoped_refptr<Layer> root_; | 2097 scoped_refptr<Layer> root_; |
| 2082 scoped_refptr<TextureLayer> layer_; | 2098 scoped_refptr<TextureLayer> layer_; |
| 2083 }; | 2099 }; |
| 2084 | 2100 |
| 2085 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 2101 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 2086 TextureLayerWithMailboxMainThreadDeleted); | 2102 TextureLayerWithMailboxMainThreadDeleted); |
| 2087 | 2103 |
| 2088 class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest { | 2104 class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest { |
| 2089 public: | 2105 public: |
| 2090 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 2106 void ReleaseCallback(uint32 sync_point, bool lost_resource) { |
| 2091 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 2107 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 2092 EXPECT_FALSE(lost_resource); | 2108 EXPECT_FALSE(lost_resource); |
| 2093 ++callback_count_; | 2109 ++callback_count_; |
| 2094 EndTest(); | 2110 EndTest(); |
| 2095 } | 2111 } |
| 2096 | 2112 |
| 2097 void SetMailbox(char mailbox_char) { | 2113 void SetMailbox(char mailbox_char) { |
| 2098 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 2114 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 2099 TextureMailbox mailbox(std::string(64, mailbox_char)); | 2115 gpu::Mailbox mailbox; |
| 2116 mailbox.SetName( |
| 2117 reinterpret_cast<const int8*>(std::string(64, mailbox_char).data())); |
| 2100 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2118 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 2101 base::Bind( | 2119 base::Bind( |
| 2102 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, | 2120 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, |
| 2103 base::Unretained(this))); | 2121 base::Unretained(this))); |
| 2104 layer_->SetTextureMailbox(mailbox, callback.Pass()); | 2122 layer_->SetTextureMailbox(TextureMailbox(mailbox, GL_TEXTURE_2D, 0), |
| 2123 callback.Pass()); |
| 2105 } | 2124 } |
| 2106 | 2125 |
| 2107 virtual void SetupTree() OVERRIDE { | 2126 virtual void SetupTree() OVERRIDE { |
| 2108 gfx::Size bounds(100, 100); | 2127 gfx::Size bounds(100, 100); |
| 2109 root_ = Layer::Create(); | 2128 root_ = Layer::Create(); |
| 2110 root_->SetAnchorPoint(gfx::PointF()); | 2129 root_->SetAnchorPoint(gfx::PointF()); |
| 2111 root_->SetBounds(bounds); | 2130 root_->SetBounds(bounds); |
| 2112 | 2131 |
| 2113 layer_ = TextureLayer::CreateForMailbox(NULL); | 2132 layer_ = TextureLayer::CreateForMailbox(NULL); |
| 2114 layer_->SetIsDrawable(true); | 2133 layer_->SetIsDrawable(true); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2155 int callback_count_; | 2174 int callback_count_; |
| 2156 scoped_refptr<Layer> root_; | 2175 scoped_refptr<Layer> root_; |
| 2157 scoped_refptr<TextureLayer> layer_; | 2176 scoped_refptr<TextureLayer> layer_; |
| 2158 }; | 2177 }; |
| 2159 | 2178 |
| 2160 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 2179 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 2161 TextureLayerWithMailboxImplThreadDeleted); | 2180 TextureLayerWithMailboxImplThreadDeleted); |
| 2162 | 2181 |
| 2163 } // namespace | 2182 } // namespace |
| 2164 } // namespace cc | 2183 } // namespace cc |
| OLD | NEW |