| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/android/stream_texture_factory_synchronous_impl
.h" | 5 #include "content/renderer/media/android/stream_texture_factory_synchronous_impl
.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 if (!context_provider_.get()) | 173 if (!context_provider_.get()) |
| 174 return NULL; | 174 return NULL; |
| 175 | 175 |
| 176 if (observer_ && !had_proxy) | 176 if (observer_ && !had_proxy) |
| 177 context_provider_->AddObserver(observer_); | 177 context_provider_->AddObserver(observer_); |
| 178 return new StreamTextureProxyImpl(context_provider_.get()); | 178 return new StreamTextureProxyImpl(context_provider_.get()); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void StreamTextureFactorySynchronousImpl::EstablishPeer(int32 stream_id, | 181 void StreamTextureFactorySynchronousImpl::EstablishPeer(int32 stream_id, |
| 182 int player_id) { | 182 int player_id, |
| 183 int frame_id) { |
| 183 DCHECK(context_provider_.get()); | 184 DCHECK(context_provider_.get()); |
| 184 scoped_refptr<gfx::SurfaceTexture> surface_texture = | 185 scoped_refptr<gfx::SurfaceTexture> surface_texture = |
| 185 context_provider_->GetSurfaceTexture(stream_id); | 186 context_provider_->GetSurfaceTexture(stream_id); |
| 186 if (surface_texture.get()) { | 187 if (surface_texture.get()) { |
| 187 SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer( | 188 SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer( |
| 188 base::GetCurrentProcessHandle(), | 189 base::GetCurrentProcessHandle(), |
| 189 surface_texture, | 190 surface_texture, |
| 190 frame_id_, | 191 frame_id_, |
| 191 player_id); | 192 player_id); |
| 192 } | 193 } |
| 193 } | 194 } |
| 194 | 195 |
| 195 unsigned StreamTextureFactorySynchronousImpl::CreateStreamTexture( | 196 unsigned StreamTextureFactorySynchronousImpl::CreateStreamTexture( |
| 196 unsigned texture_target, | 197 unsigned texture_target, |
| 197 unsigned* texture_id, | 198 unsigned* texture_id, |
| 198 gpu::Mailbox* texture_mailbox) { | 199 gpu::Mailbox* texture_mailbox) { |
| 199 DCHECK(context_provider_.get()); | 200 DCHECK(context_provider_.get()); |
| 200 unsigned stream_id = 0; | 201 unsigned stream_id = 0; |
| 201 GLES2Interface* gl = context_provider_->ContextGL(); | 202 GLES2Interface* gl = context_provider_->ContextGL(); |
| 202 gl->GenTextures(1, texture_id); | 203 gl->GenTextures(1, texture_id); |
| 203 stream_id = gl->CreateStreamTextureCHROMIUM(*texture_id); | 204 gl->ShallowFlushCHROMIUM(); |
| 204 | 205 stream_id = context_provider_->CreateStreamTexture(*texture_id); |
| 205 gl->GenMailboxCHROMIUM(texture_mailbox->name); | 206 gl->GenMailboxCHROMIUM(texture_mailbox->name); |
| 206 gl->ProduceTextureDirectCHROMIUM( | 207 gl->ProduceTextureDirectCHROMIUM( |
| 207 *texture_id, texture_target, texture_mailbox->name); | 208 *texture_id, texture_target, texture_mailbox->name); |
| 208 return stream_id; | 209 return stream_id; |
| 209 } | 210 } |
| 210 | 211 |
| 211 void StreamTextureFactorySynchronousImpl::SetStreamTextureSize( | 212 void StreamTextureFactorySynchronousImpl::SetStreamTextureSize( |
| 212 int32 stream_id, | 213 int32 stream_id, |
| 213 const gfx::Size& size) {} | 214 const gfx::Size& size) {} |
| 214 | 215 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 227 | 228 |
| 228 void StreamTextureFactorySynchronousImpl::RemoveObserver( | 229 void StreamTextureFactorySynchronousImpl::RemoveObserver( |
| 229 StreamTextureFactoryContextObserver* obs) { | 230 StreamTextureFactoryContextObserver* obs) { |
| 230 DCHECK_EQ(observer_, obs); | 231 DCHECK_EQ(observer_, obs); |
| 231 observer_ = NULL; | 232 observer_ = NULL; |
| 232 if (context_provider_.get()) | 233 if (context_provider_.get()) |
| 233 context_provider_->RemoveObserver(obs); | 234 context_provider_->RemoveObserver(obs); |
| 234 } | 235 } |
| 235 | 236 |
| 236 } // namespace content | 237 } // namespace content |
| OLD | NEW |