Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / renderer / media / android / stream_texture_factory_synchronous_impl.cc
index 75536cb..20c8ee7 100644 (file)
@@ -39,7 +39,6 @@ class StreamTextureProxyImpl
   virtual void Release() OVERRIDE;
 
  private:
-  void BindOnCompositorThread(int stream_id);
   void OnFrameAvailable();
 
   scoped_refptr<base::MessageLoopProxy> loop_;
@@ -60,8 +59,6 @@ class StreamTextureProxyImpl
 StreamTextureProxyImpl::StreamTextureProxyImpl(
     StreamTextureFactorySynchronousImpl::ContextProvider* provider)
     : context_provider_(provider), has_updated_(false) {
-  DCHECK(RenderThreadImpl::current());
-  loop_ = RenderThreadImpl::current()->compositor_message_loop_proxy();
   std::fill(current_matrix_, current_matrix_ + 16, 0);
 }
 
@@ -69,7 +66,7 @@ StreamTextureProxyImpl::~StreamTextureProxyImpl() {}
 
 void StreamTextureProxyImpl::Release() {
   SetClient(NULL);
-  if (!loop_->BelongsToCurrentThread())
+  if (loop_.get() && !loop_->BelongsToCurrentThread())
     loop_->DeleteSoon(FROM_HERE, this);
   else
     delete this;
@@ -81,19 +78,7 @@ void StreamTextureProxyImpl::SetClient(cc::VideoFrameProvider::Client* client) {
 }
 
 void StreamTextureProxyImpl::BindToCurrentThread(int stream_id) {
-  if (loop_->BelongsToCurrentThread()) {
-    BindOnCompositorThread(stream_id);
-    return;
-  }
-
-  // Weakptr is only used on compositor thread loop, so this is safe.
-  loop_->PostTask(FROM_HERE,
-                  base::Bind(&StreamTextureProxyImpl::BindOnCompositorThread,
-                             AsWeakPtr(),
-                             stream_id));
-}
-
-void StreamTextureProxyImpl::BindOnCompositorThread(int stream_id) {
+  loop_ = base::MessageLoopProxy::current();
   surface_texture_ = context_provider_->GetSurfaceTexture(stream_id);
   if (!surface_texture_) {
     LOG(ERROR) << "Failed to get SurfaceTexture for stream.";
@@ -183,8 +168,8 @@ unsigned StreamTextureFactorySynchronousImpl::CreateStreamTexture(
   stream_id = gl->CreateStreamTextureCHROMIUM(*texture_id);
 
   gl->GenMailboxCHROMIUM(texture_mailbox->name);
-  gl->BindTexture(texture_target, *texture_id);
-  gl->ProduceTextureCHROMIUM(texture_target, texture_mailbox->name);
+  gl->ProduceTextureDirectCHROMIUM(
+      *texture_id, texture_target, texture_mailbox->name);
   return stream_id;
 }