virtual void Release() OVERRIDE;
private:
- void BindOnCompositorThread(int stream_id);
void OnFrameAvailable();
scoped_refptr<base::MessageLoopProxy> loop_;
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);
}
void StreamTextureProxyImpl::Release() {
SetClient(NULL);
- if (!loop_->BelongsToCurrentThread())
+ if (loop_.get() && !loop_->BelongsToCurrentThread())
loop_->DeleteSoon(FROM_HERE, this);
else
delete this;
}
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.";
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;
}