Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / cc / layers / texture_layer.cc
index 90c48c8..5d386ca 100644 (file)
 
 namespace cc {
 
-scoped_refptr<TextureLayer> TextureLayer::Create(TextureLayerClient* client) {
-  return scoped_refptr<TextureLayer>(new TextureLayer(client, false));
-}
-
 scoped_refptr<TextureLayer> TextureLayer::CreateForMailbox(
     TextureLayerClient* client) {
-  return scoped_refptr<TextureLayer>(new TextureLayer(client, true));
+  return scoped_refptr<TextureLayer>(new TextureLayer(client));
 }
 
-TextureLayer::TextureLayer(TextureLayerClient* client, bool uses_mailbox)
+TextureLayer::TextureLayer(TextureLayerClient* client)
     : Layer(),
       client_(client),
-      uses_mailbox_(uses_mailbox),
       flipped_(true),
       uv_top_left_(0.f, 0.f),
       uv_bottom_right_(1.f, 1.f),
       premultiplied_alpha_(true),
       blend_background_color_(false),
       rate_limit_context_(false),
-      content_committed_(false),
-      texture_id_(0),
       needs_set_mailbox_(false) {
   vertex_opacity_[0] = 1.0f;
   vertex_opacity_[1] = 1.0f;
@@ -51,15 +44,16 @@ void TextureLayer::ClearClient() {
   if (rate_limit_context_ && client_ && layer_tree_host())
     layer_tree_host()->StopRateLimiter();
   client_ = NULL;
-  if (uses_mailbox_)
-    SetTextureMailbox(TextureMailbox(), scoped_ptr<SingleReleaseCallback>());
-  else
-    SetTextureId(0);
+  ClearTexture();
+  UpdateDrawsContent(HasDrawableContent());
+}
+
+void TextureLayer::ClearTexture() {
+  SetTextureMailbox(TextureMailbox(), scoped_ptr<SingleReleaseCallback>());
 }
 
 scoped_ptr<LayerImpl> TextureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
-  return TextureLayerImpl::Create(tree_impl, id(), uses_mailbox_).
-      PassAs<LayerImpl>();
+  return TextureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
 }
 
 void TextureLayer::SetFlipped(bool flipped) {
@@ -119,25 +113,11 @@ 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,
     bool requires_commit,
     bool allow_mailbox_reuse) {
-  DCHECK(uses_mailbox_);
   DCHECK(!mailbox.IsValid() || !holder_ref_ ||
          !mailbox.Equals(holder_ref_->holder()->mailbox()) ||
          allow_mailbox_reuse);
@@ -157,6 +137,7 @@ void TextureLayer::SetTextureMailboxInternal(
   else
     SetNeedsPushProperties();
 
+  UpdateDrawsContent(HasDrawableContent());
   // The active frame needs to be replaced and the mailbox returned before the
   // commit is called complete.
   SetNextCommitWaitsForActivation();
@@ -190,14 +171,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,19 +185,13 @@ void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) {
   }
 
   if (layer_tree_host()) {
-    if (texture_id_) {
-      layer_tree_host()->AcquireLayerTextures();
-      // The texture id needs to be removed from the active tree before the
-      // commit is called complete.
-      SetNextCommitWaitsForActivation();
-    }
     if (rate_limit_context_ && client_)
       layer_tree_host()->StopRateLimiter();
   }
   // If we're removed from the tree, the TextureLayerImpl will be destroyed, and
   // we will need to set the mailbox again on a new TextureLayerImpl the next
   // time we push.
-  if (!host && uses_mailbox_ && holder_ref_) {
+  if (!host && holder_ref_) {
     needs_set_mailbox_ = true;
     // The active frame needs to be replaced and the mailbox returned before the
     // commit is called complete.
@@ -233,37 +200,28 @@ void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) {
   Layer::SetLayerTreeHost(host);
 }
 
-bool TextureLayer::DrawsContent() const {
-  return (client_ || texture_id_ || holder_ref_) && Layer::DrawsContent();
+bool TextureLayer::HasDrawableContent() const {
+  return (client_ || holder_ref_) && Layer::HasDrawableContent();
 }
 
 bool TextureLayer::Update(ResourceUpdateQueue* queue,
                           const OcclusionTracker<Layer>* occlusion) {
   bool updated = Layer::Update(queue, occlusion);
   if (client_) {
-    if (uses_mailbox_) {
-      TextureMailbox mailbox;
-      scoped_ptr<SingleReleaseCallback> release_callback;
-      if (client_->PrepareTextureMailbox(
-              &mailbox,
-              &release_callback,
-              layer_tree_host()->UsingSharedMemoryResources())) {
-        // Already within a commit, no need to do another one immediately.
-        bool requires_commit = false;
-        bool allow_mailbox_reuse = false;
-        SetTextureMailboxInternal(mailbox,
-                                  release_callback.Pass(),
-                                  requires_commit,
-                                  allow_mailbox_reuse);
-        updated = true;
-      }
-    } else {
-      texture_id_ = client_->PrepareTexture();
+    TextureMailbox mailbox;
+    scoped_ptr<SingleReleaseCallback> release_callback;
+    if (client_->PrepareTextureMailbox(
+            &mailbox,
+            &release_callback,
+            layer_tree_host()->UsingSharedMemoryResources())) {
+      // Already within a commit, no need to do another one immediately.
+      bool requires_commit = false;
+      bool allow_mailbox_reuse = false;
+      SetTextureMailboxInternal(mailbox,
+                                release_callback.Pass(),
+                                requires_commit,
+                                allow_mailbox_reuse);
       updated = true;
-      SetNeedsPushProperties();
-      // The texture id needs to be removed from the active tree before the
-      // commit is called complete.
-      SetNextCommitWaitsForActivation();
     }
   }
 
@@ -283,7 +241,7 @@ void TextureLayer::PushPropertiesTo(LayerImpl* layer) {
   texture_layer->SetVertexOpacity(vertex_opacity_);
   texture_layer->SetPremultipliedAlpha(premultiplied_alpha_);
   texture_layer->SetBlendBackgroundColor(blend_background_color_);
-  if (uses_mailbox_ && needs_set_mailbox_) {
+  if (needs_set_mailbox_) {
     TextureMailbox texture_mailbox;
     scoped_ptr<SingleReleaseCallback> release_callback;
     if (holder_ref_) {
@@ -293,9 +251,6 @@ void TextureLayer::PushPropertiesTo(LayerImpl* layer) {
     }
     texture_layer->SetTextureMailbox(texture_mailbox, release_callback.Pass());
     needs_set_mailbox_ = false;
-  } else {
-    texture_layer->SetTextureId(texture_id_);
-    content_committed_ = DrawsContent();
   }
 }