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

Unified Diff: cc/layers/texture_layer_unittest.cc

Issue 105743004: Add gpu::MailboxHolder to hold state for a gpu::Mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: c301e01d Rebase. Created 6 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: cc/layers/texture_layer_unittest.cc
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc
index 3ae0c2944cd9124d9f97b23239eb79ddbe264cd5..84379a8e3dff14e18e06bf5d272606cfc69d43ba 100644
--- a/cc/layers/texture_layer_unittest.cc
+++ b/cc/layers/texture_layer_unittest.cc
@@ -315,12 +315,14 @@ TEST_F(TextureLayerTest, RateLimiter) {
class MockMailboxCallback {
public:
- MOCK_METHOD3(Release, void(const std::string& mailbox,
- unsigned sync_point,
- bool lost_resource));
- MOCK_METHOD3(Release2, void(base::SharedMemory* shared_memory,
- unsigned sync_point,
- bool lost_resource));
+ MOCK_METHOD3(Release,
+ void(const std::string& mailbox,
+ uint32 sync_point,
+ bool lost_resource));
+ MOCK_METHOD3(Release2,
+ void(base::SharedMemory* shared_memory,
+ uint32 sync_point,
+ bool lost_resource));
};
struct CommonMailboxObjects {
@@ -338,10 +340,10 @@ struct CommonMailboxObjects {
mailbox_name2_);
gpu::Mailbox m1;
m1.SetName(reinterpret_cast<const int8*>(mailbox_name1_.data()));
- mailbox1_ = TextureMailbox(m1, sync_point1_);
+ mailbox1_ = TextureMailbox(m1, 1, sync_point1_);
danakj 2014/01/06 20:13:42 Can you either use GL_TEXTURE_2D here, or make som
sheu 2014/01/06 22:44:44 Done.
gpu::Mailbox m2;
m2.SetName(reinterpret_cast<const int8*>(mailbox_name2_.data()));
- mailbox2_ = TextureMailbox(m2, sync_point2_);
+ mailbox2_ = TextureMailbox(m2, 2, sync_point2_);
gfx::Size size(128, 128);
EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea()));
@@ -360,14 +362,14 @@ struct CommonMailboxObjects {
TextureMailbox mailbox1_;
TextureMailbox mailbox2_;
TextureMailbox mailbox3_;
- unsigned sync_point1_;
- unsigned sync_point2_;
+ uint32 sync_point1_;
+ uint32 sync_point2_;
scoped_ptr<base::SharedMemory> shared_memory_;
};
-class TestMailboxHolder : public TextureLayer::MailboxHolder {
+class TestMailboxHolder : public TextureLayer::TextureMailboxHolder {
public:
- using TextureLayer::MailboxHolder::Create;
+ using TextureLayer::TextureMailboxHolder::Create;
protected:
virtual ~TestMailboxHolder() {}
@@ -754,7 +756,7 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
commit_count_(0) {}
// Make sure callback is received on main and doesn't block the impl thread.
- void ReleaseCallback(unsigned sync_point, bool lost_resource) {
+ void ReleaseCallback(uint32 sync_point, bool lost_resource) {
EXPECT_EQ(true, main_thread_.CalledOnValidThread());
EXPECT_FALSE(lost_resource);
++callback_count_;
@@ -762,12 +764,15 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
void SetMailbox(char mailbox_char) {
EXPECT_EQ(true, main_thread_.CalledOnValidThread());
- TextureMailbox mailbox(std::string(64, mailbox_char));
+ gpu::Mailbox mailbox;
+ mailbox.SetName(
+ reinterpret_cast<const int8*>(std::string(64, mailbox_char).data()));
scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
base::Bind(
&TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback,
base::Unretained(this)));
- layer_->SetTextureMailbox(mailbox, callback.Pass());
+ layer_->SetTextureMailbox(TextureMailbox(mailbox, GL_TEXTURE_2D, 0),
+ callback.Pass());
}
virtual void BeginTest() OVERRIDE {
@@ -1017,14 +1022,17 @@ class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest {
wait_thread_.Start();
}
- static void ReleaseCallback(unsigned sync_point, bool lost_resource) {}
+ static void ReleaseCallback(uint32 sync_point, bool lost_resource) {}
void SetMailbox(char mailbox_char) {
- TextureMailbox mailbox(std::string(64, mailbox_char));
+ gpu::Mailbox mailbox;
+ mailbox.SetName(
+ reinterpret_cast<const int8*>(std::string(64, mailbox_char).data()));
scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
base::Bind(
&TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback));
- layer_->SetTextureMailbox(mailbox, callback.Pass());
+ layer_->SetTextureMailbox(TextureMailbox(mailbox, GL_TEXTURE_2D, 0),
+ callback.Pass());
}
virtual void BeginTest() OVERRIDE {
@@ -1689,22 +1697,24 @@ class TextureLayerNoExtraCommitForMailboxTest
return 0;
}
virtual bool PrepareTextureMailbox(
- TextureMailbox* mailbox,
+ TextureMailbox* texture_mailbox,
scoped_ptr<SingleReleaseCallback>* release_callback,
bool use_shared_memory) OVERRIDE {
if (layer_tree_host()->source_frame_number() == 1) {
- *mailbox = TextureMailbox();
+ *texture_mailbox = TextureMailbox();
return true;
}
- *mailbox = TextureMailbox(std::string(64, '1'));
+ gpu::Mailbox mailbox;
+ mailbox.SetName(reinterpret_cast<const int8*>(std::string(64, '1').data()));
+ *texture_mailbox = TextureMailbox(mailbox, GL_TEXTURE_2D, 0);
*release_callback = SingleReleaseCallback::Create(
base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased,
base::Unretained(this)));
return true;
}
- void MailboxReleased(unsigned sync_point, bool lost_resource) {
+ void MailboxReleased(uint32 sync_point, bool lost_resource) {
EXPECT_EQ(2, layer_tree_host()->source_frame_number());
EndTest();
}
@@ -1821,10 +1831,13 @@ class TextureLayerChangeInvisibleMailboxTest
}
TextureMailbox MakeMailbox(char name) {
- return TextureMailbox(std::string(64, name));
+ gpu::Mailbox mailbox;
+ mailbox.SetName(
danakj 2014/01/06 20:13:42 Would it make sense to add a gpu::Mailbox::SetName
sheu 2014/01/06 22:44:44 It's done this way only for unittests -- it's real
danakj 2014/01/06 23:28:33 Then a helper method here or somewhere to produce
+ reinterpret_cast<const int8*>(std::string(64, name).data()));
+ return TextureMailbox(mailbox, GL_TEXTURE_2D, 0);
}
- void MailboxReleased(unsigned sync_point, bool lost_resource) {
+ void MailboxReleased(uint32 sync_point, bool lost_resource) {
++mailbox_returned_;
}
@@ -2015,7 +2028,7 @@ SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerLostContextTest);
class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest {
public:
- void ReleaseCallback(unsigned sync_point, bool lost_resource) {
+ void ReleaseCallback(uint32 sync_point, bool lost_resource) {
EXPECT_EQ(true, main_thread_.CalledOnValidThread());
EXPECT_FALSE(lost_resource);
++callback_count_;
@@ -2024,12 +2037,15 @@ class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest {
void SetMailbox(char mailbox_char) {
EXPECT_EQ(true, main_thread_.CalledOnValidThread());
- TextureMailbox mailbox(std::string(64, mailbox_char));
+ gpu::Mailbox mailbox;
+ mailbox.SetName(
+ reinterpret_cast<const int8*>(std::string(64, mailbox_char).data()));
scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
base::Bind(
&TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback,
base::Unretained(this)));
- layer_->SetTextureMailbox(mailbox, callback.Pass());
+ layer_->SetTextureMailbox(TextureMailbox(mailbox, GL_TEXTURE_2D, 0),
+ callback.Pass());
}
virtual void SetupTree() OVERRIDE {
@@ -2087,7 +2103,7 @@ SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest {
public:
- void ReleaseCallback(unsigned sync_point, bool lost_resource) {
+ void ReleaseCallback(uint32 sync_point, bool lost_resource) {
EXPECT_EQ(true, main_thread_.CalledOnValidThread());
EXPECT_FALSE(lost_resource);
++callback_count_;
@@ -2096,12 +2112,15 @@ class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest {
void SetMailbox(char mailbox_char) {
EXPECT_EQ(true, main_thread_.CalledOnValidThread());
- TextureMailbox mailbox(std::string(64, mailbox_char));
+ gpu::Mailbox mailbox;
+ mailbox.SetName(
+ reinterpret_cast<const int8*>(std::string(64, mailbox_char).data()));
scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
base::Bind(
&TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback,
base::Unretained(this)));
- layer_->SetTextureMailbox(mailbox, callback.Pass());
+ layer_->SetTextureMailbox(TextureMailbox(mailbox, GL_TEXTURE_2D, 0),
+ callback.Pass());
}
virtual void SetupTree() OVERRIDE {

Powered by Google App Engine
This is Rietveld 408576698