Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / cc / layers / texture_layer.cc
index 45a456e..bc6b58a 100644 (file)
@@ -13,7 +13,6 @@
 #include "cc/resources/single_release_callback.h"
 #include "cc/trees/blocking_task_runner.h"
 #include "cc/trees/layer_tree_host.h"
-#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
 
 namespace cc {
 
@@ -50,7 +49,7 @@ TextureLayer::~TextureLayer() {
 
 void TextureLayer::ClearClient() {
   if (rate_limit_context_ && client_ && layer_tree_host())
-    layer_tree_host()->StopRateLimiter(client_->Context3d());
+    layer_tree_host()->StopRateLimiter();
   client_ = NULL;
   if (uses_mailbox_)
     SetTextureMailbox(TextureMailbox(), scoped_ptr<SingleReleaseCallback>());
@@ -70,7 +69,8 @@ void TextureLayer::SetFlipped(bool flipped) {
   SetNeedsCommit();
 }
 
-void TextureLayer::SetUV(gfx::PointF top_left, gfx::PointF bottom_right) {
+void TextureLayer::SetUV(const gfx::PointF& top_left,
+                         const gfx::PointF& bottom_right) {
   if (uv_top_left_ == top_left && uv_bottom_right_ == bottom_right)
     return;
   uv_top_left_ = top_left;
@@ -114,7 +114,7 @@ void TextureLayer::SetBlendBackgroundColor(bool blend) {
 
 void TextureLayer::SetRateLimitContext(bool rate_limit) {
   if (!rate_limit && rate_limit_context_ && client_ && layer_tree_host())
-    layer_tree_host()->StopRateLimiter(client_->Context3d());
+    layer_tree_host()->StopRateLimiter();
 
   rate_limit_context_ = rate_limit;
 }
@@ -142,10 +142,12 @@ void TextureLayer::SetTextureMailboxInternal(
   DCHECK_EQ(mailbox.IsValid(), !!release_callback);
 
   // If we never commited the mailbox, we need to release it here.
-  if (mailbox.IsValid())
-    holder_ref_ = MailboxHolder::Create(mailbox, release_callback.Pass());
-  else
+  if (mailbox.IsValid()) {
+    holder_ref_ =
+        TextureMailboxHolder::Create(mailbox, release_callback.Pass());
+  } else {
     holder_ref_.reset();
+  }
   needs_set_mailbox_ = true;
   // If we are within a commit, no need to do it again immediately after.
   if (requires_commit)
@@ -168,7 +170,8 @@ void TextureLayer::SetTextureMailbox(
 }
 
 void TextureLayer::WillModifyTexture() {
-  if (layer_tree_host() && (DrawsContent() || content_committed_)) {
+  if (!uses_mailbox_ && layer_tree_host() && (DrawsContent() ||
+      content_committed_)) {
     layer_tree_host()->AcquireLayerTextures();
     content_committed_ = false;
   }
@@ -178,7 +181,7 @@ void TextureLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) {
   Layer::SetNeedsDisplayRect(dirty_rect);
 
   if (rate_limit_context_ && client_ && layer_tree_host() && DrawsContent())
-    layer_tree_host()->StartRateLimiter(client_->Context3d());
+    layer_tree_host()->StartRateLimiter();
 }
 
 void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) {
@@ -195,7 +198,7 @@ void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) {
       SetNextCommitWaitsForActivation();
     }
     if (rate_limit_context_ && client_)
-      layer_tree_host()->StopRateLimiter(client_->Context3d());
+      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
@@ -233,10 +236,6 @@ bool TextureLayer::Update(ResourceUpdateQueue* queue,
       }
     } else {
       texture_id_ = client_->PrepareTexture();
-      DCHECK_EQ(!!texture_id_, !!client_->Context3d());
-      if (client_->Context3d() &&
-          client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR)
-        texture_id_ = 0;
       updated = true;
       SetNeedsPushProperties();
       // The texture id needs to be removed from the active tree before the
@@ -255,26 +254,26 @@ void TextureLayer::PushPropertiesTo(LayerImpl* layer) {
   Layer::PushPropertiesTo(layer);
 
   TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer);
-  texture_layer->set_flipped(flipped_);
-  texture_layer->set_uv_top_left(uv_top_left_);
-  texture_layer->set_uv_bottom_right(uv_bottom_right_);
-  texture_layer->set_vertex_opacity(vertex_opacity_);
-  texture_layer->set_premultiplied_alpha(premultiplied_alpha_);
-  texture_layer->set_blend_background_color(blend_background_color_);
+  texture_layer->SetFlipped(flipped_);
+  texture_layer->SetUVTopLeft(uv_top_left_);
+  texture_layer->SetUVBottomRight(uv_bottom_right_);
+  texture_layer->SetVertexOpacity(vertex_opacity_);
+  texture_layer->SetPremultipliedAlpha(premultiplied_alpha_);
+  texture_layer->SetBlendBackgroundColor(blend_background_color_);
   if (uses_mailbox_ && needs_set_mailbox_) {
     TextureMailbox texture_mailbox;
     scoped_ptr<SingleReleaseCallback> release_callback;
     if (holder_ref_) {
-      MailboxHolder* holder = holder_ref_->holder();
+      TextureMailboxHolder* holder = holder_ref_->holder();
       texture_mailbox = holder->mailbox();
       release_callback = holder->GetCallbackForImplThread();
     }
     texture_layer->SetTextureMailbox(texture_mailbox, release_callback.Pass());
     needs_set_mailbox_ = false;
   } else {
-    texture_layer->set_texture_id(texture_id_);
+    texture_layer->SetTextureId(texture_id_);
+    content_committed_ = DrawsContent();
   }
-  content_committed_ = DrawsContent();
 }
 
 Region TextureLayer::VisibleContentOpaqueRegion() const {
@@ -287,17 +286,18 @@ Region TextureLayer::VisibleContentOpaqueRegion() const {
   return Region();
 }
 
-TextureLayer::MailboxHolder::MainThreadReference::MainThreadReference(
-    MailboxHolder* holder)
+TextureLayer::TextureMailboxHolder::MainThreadReference::MainThreadReference(
+    TextureMailboxHolder* holder)
     : holder_(holder) {
   holder_->InternalAddRef();
 }
 
-TextureLayer::MailboxHolder::MainThreadReference::~MainThreadReference() {
+TextureLayer::TextureMailboxHolder::MainThreadReference::
+    ~MainThreadReference() {
   holder_->InternalRelease();
 }
 
-TextureLayer::MailboxHolder::MailboxHolder(
+TextureLayer::TextureMailboxHolder::TextureMailboxHolder(
     const TextureMailbox& mailbox,
     scoped_ptr<SingleReleaseCallback> release_callback)
     : message_loop_(BlockingTaskRunner::current()),
@@ -305,42 +305,42 @@ TextureLayer::MailboxHolder::MailboxHolder(
       mailbox_(mailbox),
       release_callback_(release_callback.Pass()),
       sync_point_(mailbox.sync_point()),
-      is_lost_(false) {
-}
+      is_lost_(false) {}
 
-TextureLayer::MailboxHolder::~MailboxHolder() {
+TextureLayer::TextureMailboxHolder::~TextureMailboxHolder() {
   DCHECK_EQ(0u, internal_references_);
 }
 
-scoped_ptr<TextureLayer::MailboxHolder::MainThreadReference>
-TextureLayer::MailboxHolder::Create(
+scoped_ptr<TextureLayer::TextureMailboxHolder::MainThreadReference>
+TextureLayer::TextureMailboxHolder::Create(
     const TextureMailbox& mailbox,
     scoped_ptr<SingleReleaseCallback> release_callback) {
   return scoped_ptr<MainThreadReference>(new MainThreadReference(
-      new MailboxHolder(mailbox, release_callback.Pass())));
+      new TextureMailboxHolder(mailbox, release_callback.Pass())));
 }
 
-void TextureLayer::MailboxHolder::Return(unsigned sync_point, bool is_lost) {
+void TextureLayer::TextureMailboxHolder::Return(uint32 sync_point,
+                                                bool is_lost) {
   base::AutoLock lock(arguments_lock_);
   sync_point_ = sync_point;
   is_lost_ = is_lost;
 }
 
 scoped_ptr<SingleReleaseCallback>
-TextureLayer::MailboxHolder::GetCallbackForImplThread() {
+TextureLayer::TextureMailboxHolder::GetCallbackForImplThread() {
   // We can't call GetCallbackForImplThread if we released the main thread
   // reference.
   DCHECK_GT(internal_references_, 0u);
   InternalAddRef();
   return SingleReleaseCallback::Create(
-      base::Bind(&MailboxHolder::ReturnAndReleaseOnImplThread, this));
+      base::Bind(&TextureMailboxHolder::ReturnAndReleaseOnImplThread, this));
 }
 
-void TextureLayer::MailboxHolder::InternalAddRef() {
+void TextureLayer::TextureMailboxHolder::InternalAddRef() {
   ++internal_references_;
 }
 
-void TextureLayer::MailboxHolder::InternalRelease() {
+void TextureLayer::TextureMailboxHolder::InternalRelease() {
   DCHECK(message_loop_->BelongsToCurrentThread());
   if (!--internal_references_) {
     release_callback_->Run(sync_point_, is_lost_);
@@ -349,11 +349,12 @@ void TextureLayer::MailboxHolder::InternalRelease() {
   }
 }
 
-void TextureLayer::MailboxHolder::ReturnAndReleaseOnImplThread(
-    unsigned sync_point, bool is_lost) {
+void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread(
+    uint32 sync_point,
+    bool is_lost) {
   Return(sync_point, is_lost);
-  message_loop_->PostTask(FROM_HERE,
-                          base::Bind(&MailboxHolder::InternalRelease, this));
+  message_loop_->PostTask(
+      FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this));
 }
 
 }  // namespace cc