summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-03 14:40:57 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-03 14:40:57 +0000
commit67dbcf209c7b2c81712623815e8ada0cdaf9e8d5 (patch)
tree33a1b122e66c7a3cbd924f74f3ffd35f1a101ef9
parentee70451f8c386f8cca7c085ab69c5bd4431bd462 (diff)
downloadchromium_src-67dbcf209c7b2c81712623815e8ada0cdaf9e8d5.zip
chromium_src-67dbcf209c7b2c81712623815e8ada0cdaf9e8d5.tar.gz
chromium_src-67dbcf209c7b2c81712623815e8ada0cdaf9e8d5.tar.bz2
cc: Remove TextureLayer::SetTextureId and TextureLayer::WillModifyTexture
These are not used anymore except for clearing the client-provided texture, so this removes 1 of 4 TextureLayer paths, and simplifies externally-exposed state. BUG=337922 Review URL: https://codereview.chromium.org/213743005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261380 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/layers/texture_layer.cc48
-rw-r--r--cc/layers/texture_layer.h20
-rw-r--r--cc/layers/texture_layer_unittest.cc321
-rw-r--r--content/shell/renderer/test_runner/TestPlugin.cpp7
-rw-r--r--ui/compositor/layer.cc2
-rw-r--r--webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc4
6 files changed, 238 insertions, 164 deletions
diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc
index 90c48c8..4285ee0 100644
--- a/cc/layers/texture_layer.cc
+++ b/cc/layers/texture_layer.cc
@@ -35,7 +35,7 @@ TextureLayer::TextureLayer(TextureLayerClient* client, bool uses_mailbox)
premultiplied_alpha_(true),
blend_background_color_(false),
rate_limit_context_(false),
- content_committed_(false),
+ impl_may_draw_client_data_(false),
texture_id_(0),
needs_set_mailbox_(false) {
vertex_opacity_[0] = 1.0f;
@@ -51,10 +51,24 @@ void TextureLayer::ClearClient() {
if (rate_limit_context_ && client_ && layer_tree_host())
layer_tree_host()->StopRateLimiter();
client_ = NULL;
- if (uses_mailbox_)
+ ClearTexture();
+}
+
+void TextureLayer::ClearTexture() {
+ if (uses_mailbox_) {
SetTextureMailbox(TextureMailbox(), scoped_ptr<SingleReleaseCallback>());
- else
- SetTextureId(0);
+ } else if (texture_id_) {
+ if (impl_may_draw_client_data_) {
+ DCHECK(layer_tree_host());
+ layer_tree_host()->AcquireLayerTextures();
+ impl_may_draw_client_data_ = false;
+ }
+ texture_id_ = 0;
+ SetNeedsCommit();
+ // The texture id needs to be removed from the active tree before the
+ // commit is called complete.
+ SetNextCommitWaitsForActivation();
+ }
}
scoped_ptr<LayerImpl> TextureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
@@ -119,19 +133,6 @@ void TextureLayer::SetRateLimitContext(bool rate_limit) {
rate_limit_context_ = rate_limit;
}
-void TextureLayer::SetTextureId(unsigned id) {
- DCHECK(!uses_mailbox_);
- if (texture_id_ == id)
- return;
- if (texture_id_ && layer_tree_host())
- layer_tree_host()->AcquireLayerTextures();
- texture_id_ = id;
- SetNeedsCommit();
- // The texture id needs to be removed from the active tree before the
- // commit is called complete.
- SetNextCommitWaitsForActivation();
-}
-
void TextureLayer::SetTextureMailboxInternal(
const TextureMailbox& mailbox,
scoped_ptr<SingleReleaseCallback> release_callback,
@@ -190,14 +191,6 @@ void TextureLayer::SetTextureMailboxWithoutReleaseCallback(
mailbox, release.Pass(), requires_commit, allow_mailbox_reuse);
}
-void TextureLayer::WillModifyTexture() {
- if (!uses_mailbox_ && layer_tree_host() && (DrawsContent() ||
- content_committed_)) {
- layer_tree_host()->AcquireLayerTextures();
- content_committed_ = false;
- }
-}
-
void TextureLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) {
Layer::SetNeedsDisplayRect(dirty_rect);
@@ -212,11 +205,12 @@ void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) {
}
if (layer_tree_host()) {
- if (texture_id_) {
+ if (impl_may_draw_client_data_) {
layer_tree_host()->AcquireLayerTextures();
// The texture id needs to be removed from the active tree before the
// commit is called complete.
SetNextCommitWaitsForActivation();
+ impl_may_draw_client_data_ = false;
}
if (rate_limit_context_ && client_)
layer_tree_host()->StopRateLimiter();
@@ -295,7 +289,7 @@ void TextureLayer::PushPropertiesTo(LayerImpl* layer) {
needs_set_mailbox_ = false;
} else {
texture_layer->SetTextureId(texture_id_);
- content_committed_ = DrawsContent();
+ impl_may_draw_client_data_ = texture_id_ && Layer::DrawsContent();
}
}
diff --git a/cc/layers/texture_layer.h b/cc/layers/texture_layer.h
index 009a217..c2af7eb 100644
--- a/cc/layers/texture_layer.h
+++ b/cc/layers/texture_layer.h
@@ -90,8 +90,20 @@ class CC_EXPORT TextureLayer : public Layer {
static scoped_refptr<TextureLayer> CreateForMailbox(
TextureLayerClient* client);
+ // Resets the client, which also resets the texture. This may synchronize with
+ // the impl thread if it is currently drawing a texture from the client, that
+ // was given via TextureLayerClient::PrepareTexture. After this call it is
+ // safe to destroy that texture. Note: it doesn't synchronize for mailboxes,
+ // those can only be destroyed after the release callback has been called.
void ClearClient();
+ // Resets the texture. This may synchronize with the impl thread if it is
+ // currently drawing a texture from the client, that was given via
+ // TextureLayerClient::PrepareTexture. After this call it is safe to destroy
+ // that texture. Note: it doesn't synchronize for mailboxes, those can only be
+ // destroyed after the release callback has been called.
+ void ClearTexture();
+
virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
OVERRIDE;
@@ -122,10 +134,6 @@ class CC_EXPORT TextureLayer : public Layer {
// Requires a non-nil client. Defaults to false.
void SetRateLimitContext(bool rate_limit);
- // Code path for plugins which supply their own texture ID.
- // DEPRECATED. DO NOT USE.
- void SetTextureId(unsigned texture_id);
-
// Code path for plugins which supply their own mailbox.
bool uses_mailbox() const { return uses_mailbox_; }
void SetTextureMailbox(const TextureMailbox& mailbox,
@@ -137,8 +145,6 @@ class CC_EXPORT TextureLayer : public Layer {
// TODO(danakj): Remove this when pepper doesn't need it. crbug.com/350204
void SetTextureMailboxWithoutReleaseCallback(const TextureMailbox& mailbox);
- void WillModifyTexture();
-
virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE;
virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE;
@@ -170,7 +176,7 @@ class CC_EXPORT TextureLayer : public Layer {
bool premultiplied_alpha_;
bool blend_background_color_;
bool rate_limit_context_;
- bool content_committed_;
+ bool impl_may_draw_client_data_;
unsigned texture_id_;
scoped_ptr<TextureMailboxHolder::MainThreadReference> holder_ref_;
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc
index e037693..e385f1b2 100644
--- a/cc/layers/texture_layer_unittest.cc
+++ b/cc/layers/texture_layer_unittest.cc
@@ -37,6 +37,7 @@ using ::testing::Mock;
using ::testing::_;
using ::testing::AtLeast;
using ::testing::AnyNumber;
+using ::testing::InvokeWithoutArgs;
namespace cc {
namespace {
@@ -61,6 +62,93 @@ class MockLayerTreeHost : public LayerTreeHost {
MOCK_METHOD0(StopRateLimiter, void());
};
+class FakeTextureLayerClient : public TextureLayerClient {
+ public:
+ FakeTextureLayerClient() : texture_(0), mailbox_changed_(true) {}
+
+ virtual unsigned PrepareTexture() OVERRIDE { return texture_; }
+
+ virtual bool PrepareTextureMailbox(
+ TextureMailbox* mailbox,
+ scoped_ptr<SingleReleaseCallback>* release_callback,
+ bool use_shared_memory) OVERRIDE {
+ if (!mailbox_changed_)
+ return false;
+
+ *mailbox = mailbox_;
+ *release_callback = release_callback_.Pass();
+ mailbox_changed_ = false;
+ return true;
+ }
+
+ void set_texture(unsigned texture) { texture_ = texture; }
+
+ void set_mailbox(const TextureMailbox& mailbox,
+ scoped_ptr<SingleReleaseCallback> release_callback) {
+ mailbox_ = mailbox;
+ release_callback_ = release_callback.Pass();
+ mailbox_changed_ = true;
+ }
+
+ private:
+ unsigned texture_;
+ TextureMailbox mailbox_;
+ scoped_ptr<SingleReleaseCallback> release_callback_;
+ bool mailbox_changed_;
+ DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient);
+};
+
+class MockMailboxCallback {
+ public:
+ MOCK_METHOD3(Release,
+ void(const gpu::Mailbox& mailbox,
+ uint32 sync_point,
+ bool lost_resource));
+ MOCK_METHOD3(Release2,
+ void(base::SharedMemory* shared_memory,
+ uint32 sync_point,
+ bool lost_resource));
+};
+
+struct CommonMailboxObjects {
+ CommonMailboxObjects()
+ : mailbox_name1_(MailboxFromChar('1')),
+ mailbox_name2_(MailboxFromChar('2')),
+ sync_point1_(1),
+ sync_point2_(2),
+ shared_memory_(new base::SharedMemory) {
+ release_mailbox1_ = base::Bind(&MockMailboxCallback::Release,
+ base::Unretained(&mock_callback_),
+ mailbox_name1_);
+ release_mailbox2_ = base::Bind(&MockMailboxCallback::Release,
+ base::Unretained(&mock_callback_),
+ mailbox_name2_);
+ const uint32 arbitrary_target1 = GL_TEXTURE_2D;
+ const uint32 arbitrary_target2 = GL_TEXTURE_EXTERNAL_OES;
+ mailbox1_ = TextureMailbox(mailbox_name1_, arbitrary_target1, sync_point1_);
+ mailbox2_ = TextureMailbox(mailbox_name2_, arbitrary_target2, sync_point2_);
+ gfx::Size size(128, 128);
+ EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea()));
+ release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2,
+ base::Unretained(&mock_callback_),
+ shared_memory_.get());
+ mailbox3_ = TextureMailbox(shared_memory_.get(), size);
+ }
+
+ gpu::Mailbox mailbox_name1_;
+ gpu::Mailbox mailbox_name2_;
+ MockMailboxCallback mock_callback_;
+ ReleaseCallback release_mailbox1_;
+ ReleaseCallback release_mailbox2_;
+ ReleaseCallback release_mailbox3_;
+ TextureMailbox mailbox1_;
+ TextureMailbox mailbox2_;
+ TextureMailbox mailbox3_;
+ uint32 sync_point1_;
+ uint32 sync_point2_;
+ scoped_ptr<base::SharedMemory> shared_memory_;
+};
+
class TextureLayerTest : public testing::Test {
public:
TextureLayerTest()
@@ -71,6 +159,9 @@ class TextureLayerTest : public testing::Test {
protected:
virtual void SetUp() {
layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_));
+ EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
+ layer_tree_host_->SetViewportSize(gfx::Size(10, 10));
+ Mock::VerifyAndClearExpectations(layer_tree_host_.get());
}
virtual void TearDown() {
@@ -89,96 +180,155 @@ class TextureLayerTest : public testing::Test {
FakeLayerTreeHostImpl host_impl_;
};
-TEST_F(TextureLayerTest, SyncImplWhenChangingTextureId) {
- scoped_refptr<TextureLayer> test_layer = TextureLayer::Create(NULL);
+TEST_F(TextureLayerTest, SyncImplWhenClearingTexture) {
+ scoped_ptr<TestWebGraphicsContext3D> context(
+ TestWebGraphicsContext3D::Create());
+ FakeTextureLayerClient client;
+ scoped_refptr<TextureLayer> test_layer = TextureLayer::Create(&client);
ASSERT_TRUE(test_layer.get());
+ test_layer->SetIsDrawable(true);
+ test_layer->SetBounds(gfx::Size(10, 10));
- EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AnyNumber());
+ EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
layer_tree_host_->SetRootLayer(test_layer);
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get());
+ // Clearing the texture before we gave one should not sync.
EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
- EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
- test_layer->SetTextureId(1);
+ EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
+ test_layer->ClearTexture();
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+ // Give a texture to the layer through the client.
+ EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
+ EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(AtLeast(1));
+ client.set_texture(context->createTexture());
+ test_layer->SetNeedsDisplay();
+ Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+ // Force a commit.
+ layer_tree_host_->Composite(base::TimeTicks());
+
+ // Clearing the texture should sync.
EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AtLeast(1));
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
- test_layer->SetTextureId(2);
+ test_layer->ClearTexture();
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
- EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AtLeast(1));
+ // But only once.
+ EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
+ EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
+ test_layer->ClearTexture();
+ Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+
+ // Force a commit to give another texture.
+ EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(AtLeast(1));
+ test_layer->SetNeedsDisplay();
+ Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+ layer_tree_host_->Composite(base::TimeTicks());
+
+ // Make undrawable and commit.
+ EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
+ test_layer->SetIsDrawable(false);
+ Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+ layer_tree_host_->Composite(base::TimeTicks());
+
+ // Clearing textures should not sync.
+ EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
- test_layer->SetTextureId(0);
+ test_layer->ClearTexture();
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
}
-TEST_F(TextureLayerTest, SyncImplWhenDrawing) {
- gfx::RectF dirty_rect(0.f, 0.f, 1.f, 1.f);
-
- scoped_refptr<TextureLayer> test_layer = TextureLayer::Create(NULL);
+TEST_F(TextureLayerTest, SyncImplWhenClearingMailbox) {
+ CommonMailboxObjects mailboxes;
+ FakeTextureLayerClient client;
+ scoped_refptr<TextureLayer> test_layer =
+ TextureLayer::CreateForMailbox(&client);
ASSERT_TRUE(test_layer.get());
- scoped_ptr<TextureLayerImpl> impl_layer;
- impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1, false);
- ASSERT_TRUE(impl_layer);
-
- EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AnyNumber());
+ test_layer->SetIsDrawable(true);
+ test_layer->SetBounds(gfx::Size(10, 10));
+ EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
layer_tree_host_->SetRootLayer(test_layer);
- test_layer->SetTextureId(1);
- test_layer->SetIsDrawable(true);
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get());
- EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(1);
- EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
- test_layer->WillModifyTexture();
+ // Clearing the mailbox before we gave one should not sync.
+ EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
+ EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
+ test_layer->ClearTexture();
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+ // Give a mailbox to the layer through the client.
EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
- EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1);
- test_layer->SetNeedsDisplayRect(dirty_rect);
+ client.set_mailbox(
+ mailboxes.mailbox1_,
+ SingleReleaseCallback::Create(mailboxes.release_mailbox1_));
+ EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(AtLeast(1));
+ test_layer->SetNeedsDisplay();
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+ // Force a commit.
+ layer_tree_host_->Composite(base::TimeTicks());
+ // Clearing the mailbox should not sync.
EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
- EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
- test_layer->PushPropertiesTo(impl_layer.get()); // fake commit
- test_layer->SetIsDrawable(false);
+ EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
+ test_layer->ClearTexture();
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
- // Verify that non-drawable layers don't signal the compositor,
- // except for the first draw after last commit, which must acquire
- // the texture.
- EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(1);
- EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
- test_layer->WillModifyTexture();
- test_layer->SetNeedsDisplayRect(dirty_rect);
- test_layer->PushPropertiesTo(impl_layer.get()); // fake commit
+ // Commit will return mailbox1.
+ EXPECT_CALL(mailboxes.mock_callback_,
+ Release(mailboxes.mailbox_name1_, _, false));
+ layer_tree_host_->Composite(base::TimeTicks());
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
- // Second draw with layer in non-drawable state: no texture
- // acquisition.
+ // Force a commit to give another mailbox.
EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
- EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
- test_layer->WillModifyTexture();
- test_layer->SetNeedsDisplayRect(dirty_rect);
+ client.set_mailbox(
+ mailboxes.mailbox2_,
+ SingleReleaseCallback::Create(mailboxes.release_mailbox2_));
+ EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(AtLeast(1));
+ test_layer->SetNeedsDisplay();
+ Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+ layer_tree_host_->Composite(base::TimeTicks());
+
+ // Make undrawable and commit.
+ EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
+ test_layer->SetIsDrawable(false);
+ layer_tree_host_->Composite(base::TimeTicks());
+ Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+
+ // Clearing textures should not sync.
+ EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
+ EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
+ test_layer->ClearTexture();
+ Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+
+ // Commit will return the mailbox.
+ EXPECT_CALL(mailboxes.mock_callback_,
+ Release(mailboxes.mailbox_name2_, _, false));
+ layer_tree_host_->Composite(base::TimeTicks());
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
}
TEST_F(TextureLayerTest, SyncImplWhenRemovingFromTree) {
+ scoped_ptr<TestWebGraphicsContext3D> context(
+ TestWebGraphicsContext3D::Create());
scoped_refptr<Layer> root_layer = Layer::Create();
ASSERT_TRUE(root_layer.get());
scoped_refptr<Layer> child_layer = Layer::Create();
ASSERT_TRUE(child_layer.get());
root_layer->AddChild(child_layer);
- scoped_refptr<TextureLayer> test_layer = TextureLayer::Create(NULL);
+ FakeTextureLayerClient client;
+ scoped_refptr<TextureLayer> test_layer = TextureLayer::Create(&client);
+ test_layer->SetIsDrawable(true);
+ test_layer->SetBounds(gfx::Size(10, 10));
ASSERT_TRUE(test_layer.get());
- test_layer->SetTextureId(0);
child_layer->AddChild(test_layer);
- EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AnyNumber());
+ EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
layer_tree_host_->SetRootLayer(root_layer);
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
@@ -193,10 +343,14 @@ TEST_F(TextureLayerTest, SyncImplWhenRemovingFromTree) {
child_layer->AddChild(test_layer);
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+ // Give a texture to the layer through the client.
EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0);
- EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
- test_layer->SetTextureId(1);
+ EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(AtLeast(1));
+ client.set_texture(context->createTexture());
+ test_layer->SetNeedsDisplay();
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+ // Force a commit.
+ layer_tree_host_->Composite(base::TimeTicks());
EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AtLeast(1));
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
@@ -217,10 +371,6 @@ TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) {
0.5f, 0.5f, 0.5f, 0.5f));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true));
- EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTextureId(1));
-
- // Calling SetTextureId can call AcquireLayerTextures.
- EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AnyNumber());
}
TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) {
@@ -250,27 +400,6 @@ TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) {
layer->VisibleContentOpaqueRegion().ToString());
}
-class FakeTextureLayerClient : public TextureLayerClient {
- public:
- FakeTextureLayerClient() {}
-
- virtual unsigned PrepareTexture() OVERRIDE {
- return 0;
- }
-
- virtual bool PrepareTextureMailbox(
- TextureMailbox* mailbox,
- scoped_ptr<SingleReleaseCallback>* release_callback,
- bool use_shared_memory) OVERRIDE {
- *mailbox = TextureMailbox();
- *release_callback = scoped_ptr<SingleReleaseCallback>();
- return true;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient);
-};
-
TEST_F(TextureLayerTest, RateLimiter) {
FakeTextureLayerClient client;
scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(
@@ -316,61 +445,11 @@ TEST_F(TextureLayerTest, RateLimiter) {
// Stop rate limiter when we're removed from the tree.
EXPECT_CALL(*layer_tree_host_, StopRateLimiter());
+ EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
layer_tree_host_->SetRootLayer(NULL);
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
}
-class MockMailboxCallback {
- public:
- MOCK_METHOD3(Release,
- void(const gpu::Mailbox& mailbox,
- uint32 sync_point,
- bool lost_resource));
- MOCK_METHOD3(Release2,
- void(base::SharedMemory* shared_memory,
- uint32 sync_point,
- bool lost_resource));
-};
-
-struct CommonMailboxObjects {
- CommonMailboxObjects()
- : mailbox_name1_(MailboxFromChar('1')),
- mailbox_name2_(MailboxFromChar('2')),
- sync_point1_(1),
- sync_point2_(2),
- shared_memory_(new base::SharedMemory) {
- release_mailbox1_ = base::Bind(&MockMailboxCallback::Release,
- base::Unretained(&mock_callback_),
- mailbox_name1_);
- release_mailbox2_ = base::Bind(&MockMailboxCallback::Release,
- base::Unretained(&mock_callback_),
- mailbox_name2_);
- const uint32 arbitrary_target1 = 1;
- const uint32 arbitrary_target2 = 2;
- mailbox1_ = TextureMailbox(mailbox_name1_, arbitrary_target1, sync_point1_);
- mailbox2_ = TextureMailbox(mailbox_name2_, arbitrary_target2, sync_point2_);
- gfx::Size size(128, 128);
- EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea()));
- release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2,
- base::Unretained(&mock_callback_),
- shared_memory_.get());
- mailbox3_ = TextureMailbox(shared_memory_.get(), size);
- }
-
- gpu::Mailbox mailbox_name1_;
- gpu::Mailbox mailbox_name2_;
- MockMailboxCallback mock_callback_;
- ReleaseCallback release_mailbox1_;
- ReleaseCallback release_mailbox2_;
- ReleaseCallback release_mailbox3_;
- TextureMailbox mailbox1_;
- TextureMailbox mailbox2_;
- TextureMailbox mailbox3_;
- uint32 sync_point1_;
- uint32 sync_point2_;
- scoped_ptr<base::SharedMemory> shared_memory_;
-};
-
class TestMailboxHolder : public TextureLayer::TextureMailboxHolder {
public:
using TextureLayer::TextureMailboxHolder::Create;
diff --git a/content/shell/renderer/test_runner/TestPlugin.cpp b/content/shell/renderer/test_runner/TestPlugin.cpp
index 91045ce..5fdec5d 100644
--- a/content/shell/renderer/test_runner/TestPlugin.cpp
+++ b/content/shell/renderer/test_runner/TestPlugin.cpp
@@ -222,11 +222,8 @@ bool TestPlugin::initialize(WebPluginContainer* container)
void TestPlugin::destroy()
{
- if (m_layer.get()) {
- m_layer->WillModifyTexture();
- m_layer->SetTextureMailbox(cc::TextureMailbox(),
- scoped_ptr<cc::SingleReleaseCallback>());
- }
+ if (m_layer.get())
+ m_layer->ClearTexture();
if (m_container)
m_container->setWebLayer(0);
m_webLayer.reset();
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index 1637d5e..e4161d8 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -458,7 +458,7 @@ void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
}
if (texture_layer_.get())
- texture_layer_->WillModifyTexture();
+ texture_layer_->ClearClient();
// TODO(piman): delegated_renderer_layer_ cleanup.
cc_layer_->RemoveAllChildren();
diff --git a/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc b/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc
index 8657b38..bdec725 100644
--- a/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc
+++ b/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc
@@ -39,9 +39,7 @@ blink::WebLayer* WebExternalTextureLayerImpl::layer() { return layer_.get(); }
void WebExternalTextureLayerImpl::clearTexture() {
TextureLayer *layer = static_cast<TextureLayer*>(layer_->layer());
- layer->WillModifyTexture();
- layer->SetTextureMailbox(cc::TextureMailbox(),
- scoped_ptr<cc::SingleReleaseCallback>());
+ layer->ClearTexture();
}
void WebExternalTextureLayerImpl::setOpaque(bool opaque) {