Commit d72d9e05 authored by nick@chromium.org's avatar nick@chromium.org

Re-land "cc: Remove TextureLayer::SetTextureId and TextureLayer::WillModifyTexture"

Reason for re-land: Change was found not guilty; charges were dropped.

> Revert 261380 "cc: Remove TextureLayer::SetTextureId and Texture..."
> 
> [Reason for revert: failure in WindowUtilTest.RecreateLayers
>  in test suite wm_core_unittests
>  on bot Linux ChromiumOS Tests (dbg)(1) Build]
> 
> > 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
> 
> TBR=piman@chromium.org
> 
> Review URL: https://codereview.chromium.org/224153003

TBR=nick@chromium.org

Review URL: https://codereview.chromium.org/224363003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261490 0039d316-1c4b-4281-b951-d872f2087c98
parent 5f0a1175
......@@ -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();
}
}
......
......@@ -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_;
......
This diff is collapsed.
......@@ -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();
......
......@@ -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();
......
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment