| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_android_synchron
ous_impl.h" | 5 #include "content/renderer/media/android/stream_texture_factory_android_synchron
ous_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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } // namespace | 117 } // namespace |
| 118 | 118 |
| 119 StreamTextureFactorySynchronousImpl::StreamTextureFactorySynchronousImpl( | 119 StreamTextureFactorySynchronousImpl::StreamTextureFactorySynchronousImpl( |
| 120 ContextProvider* context_provider, | 120 ContextProvider* context_provider, |
| 121 int view_id) | 121 int view_id) |
| 122 : context_provider_(context_provider), view_id_(view_id) {} | 122 : context_provider_(context_provider), view_id_(view_id) {} |
| 123 | 123 |
| 124 StreamTextureFactorySynchronousImpl::~StreamTextureFactorySynchronousImpl() {} | 124 StreamTextureFactorySynchronousImpl::~StreamTextureFactorySynchronousImpl() {} |
| 125 | 125 |
| 126 StreamTextureProxy* StreamTextureFactorySynchronousImpl::CreateProxy() { | 126 StreamTextureProxy* StreamTextureFactorySynchronousImpl::CreateProxy() { |
| 127 if (!context_provider_) |
| 128 return NULL; |
| 127 return new StreamTextureProxyImpl(context_provider_); | 129 return new StreamTextureProxyImpl(context_provider_); |
| 128 } | 130 } |
| 129 | 131 |
| 130 void StreamTextureFactorySynchronousImpl::EstablishPeer(int32 stream_id, | 132 void StreamTextureFactorySynchronousImpl::EstablishPeer(int32 stream_id, |
| 131 int player_id) { | 133 int player_id) { |
| 134 DCHECK(context_provider_); |
| 132 scoped_refptr<gfx::SurfaceTexture> surface_texture = | 135 scoped_refptr<gfx::SurfaceTexture> surface_texture = |
| 133 context_provider_->GetSurfaceTexture(stream_id); | 136 context_provider_->GetSurfaceTexture(stream_id); |
| 134 if (surface_texture) { | 137 if (surface_texture) { |
| 135 SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer( | 138 SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer( |
| 136 base::Process::Current().handle(), | 139 base::Process::Current().handle(), |
| 137 surface_texture, | 140 surface_texture, |
| 138 view_id_, | 141 view_id_, |
| 139 player_id); | 142 player_id); |
| 140 } | 143 } |
| 141 } | 144 } |
| 142 | 145 |
| 143 unsigned StreamTextureFactorySynchronousImpl::CreateStreamTexture( | 146 unsigned StreamTextureFactorySynchronousImpl::CreateStreamTexture( |
| 144 unsigned texture_target, | 147 unsigned texture_target, |
| 145 unsigned* texture_id, | 148 unsigned* texture_id, |
| 146 gpu::Mailbox* texture_mailbox, | 149 gpu::Mailbox* texture_mailbox, |
| 147 unsigned* texture_mailbox_sync_point) { | 150 unsigned* texture_mailbox_sync_point) { |
| 151 DCHECK(context_provider_); |
| 148 WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); | 152 WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); |
| 149 unsigned stream_id = 0; | 153 unsigned stream_id = 0; |
| 150 if (context->makeContextCurrent()) { | 154 if (context->makeContextCurrent()) { |
| 151 *texture_id = context->createTexture(); | 155 *texture_id = context->createTexture(); |
| 152 stream_id = context->createStreamTextureCHROMIUM(*texture_id); | 156 stream_id = context->createStreamTextureCHROMIUM(*texture_id); |
| 153 | 157 |
| 154 context->genMailboxCHROMIUM(texture_mailbox->name); | 158 context->genMailboxCHROMIUM(texture_mailbox->name); |
| 155 context->bindTexture(texture_target, *texture_id); | 159 context->bindTexture(texture_target, *texture_id); |
| 156 context->produceTextureCHROMIUM(texture_target, texture_mailbox->name); | 160 context->produceTextureCHROMIUM(texture_target, texture_mailbox->name); |
| 157 | 161 |
| 158 context->flush(); | 162 context->flush(); |
| 159 *texture_mailbox_sync_point = context->insertSyncPoint(); | 163 *texture_mailbox_sync_point = context->insertSyncPoint(); |
| 160 } | 164 } |
| 161 return stream_id; | 165 return stream_id; |
| 162 } | 166 } |
| 163 | 167 |
| 164 void StreamTextureFactorySynchronousImpl::DestroyStreamTexture( | 168 void StreamTextureFactorySynchronousImpl::DestroyStreamTexture( |
| 165 unsigned texture_id) { | 169 unsigned texture_id) { |
| 170 DCHECK(context_provider_); |
| 166 WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); | 171 WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); |
| 167 if (context->makeContextCurrent()) { | 172 if (context->makeContextCurrent()) { |
| 168 context->destroyStreamTextureCHROMIUM(texture_id); | 173 context->destroyStreamTextureCHROMIUM(texture_id); |
| 169 context->deleteTexture(texture_id); | 174 context->deleteTexture(texture_id); |
| 170 context->flush(); | 175 context->flush(); |
| 171 } | 176 } |
| 172 } | 177 } |
| 173 | 178 |
| 174 void StreamTextureFactorySynchronousImpl::SetStreamTextureSize( | 179 void StreamTextureFactorySynchronousImpl::SetStreamTextureSize( |
| 175 int32 stream_id, | 180 int32 stream_id, |
| 176 const gfx::Size& size) {} | 181 const gfx::Size& size) {} |
| 177 | 182 |
| 178 } // namespace content | 183 } // namespace content |
| OLD | NEW |