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" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/message_loop/message_loop_proxy.h" | 13 #include "base/message_loop/message_loop_proxy.h" |
14 #include "base/process/process.h" | 14 #include "base/process/process.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "cc/output/context_provider.h" | 16 #include "cc/output/context_provider.h" |
17 #include "content/common/android/surface_texture_peer.h" | 17 #include "content/common/android/surface_texture_peer.h" |
18 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 18 #include "gpu/command_buffer/client/gles2_interface.h" |
19 #include "ui/gl/android/surface_texture.h" | 19 #include "ui/gl/android/surface_texture.h" |
20 | 20 |
| 21 using gpu::gles2::GLES2Interface; |
| 22 |
21 namespace content { | 23 namespace content { |
22 | 24 |
23 namespace { | 25 namespace { |
24 | 26 |
25 class StreamTextureProxyImpl | 27 class StreamTextureProxyImpl |
26 : public StreamTextureProxy, | 28 : public StreamTextureProxy, |
27 public base::SupportsWeakPtr<StreamTextureProxyImpl> { | 29 public base::SupportsWeakPtr<StreamTextureProxyImpl> { |
28 public: | 30 public: |
29 explicit StreamTextureProxyImpl( | 31 explicit StreamTextureProxyImpl( |
30 StreamTextureFactorySynchronousImpl::ContextProvider* provider); | 32 StreamTextureFactorySynchronousImpl::ContextProvider* provider); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 player_id); | 149 player_id); |
148 } | 150 } |
149 } | 151 } |
150 | 152 |
151 unsigned StreamTextureFactorySynchronousImpl::CreateStreamTexture( | 153 unsigned StreamTextureFactorySynchronousImpl::CreateStreamTexture( |
152 unsigned texture_target, | 154 unsigned texture_target, |
153 unsigned* texture_id, | 155 unsigned* texture_id, |
154 gpu::Mailbox* texture_mailbox, | 156 gpu::Mailbox* texture_mailbox, |
155 unsigned* texture_mailbox_sync_point) { | 157 unsigned* texture_mailbox_sync_point) { |
156 DCHECK(context_provider_); | 158 DCHECK(context_provider_); |
157 blink::WebGraphicsContext3D* context = context_provider_->Context3d(); | |
158 unsigned stream_id = 0; | 159 unsigned stream_id = 0; |
159 if (context->makeContextCurrent()) { | 160 GLES2Interface* gl = context_provider_->ContextGL(); |
160 *texture_id = context->createTexture(); | 161 gl->GenTextures(1, texture_id); |
161 stream_id = context->createStreamTextureCHROMIUM(*texture_id); | 162 stream_id = gl->CreateStreamTextureCHROMIUM(*texture_id); |
162 | 163 |
163 context->genMailboxCHROMIUM(texture_mailbox->name); | 164 gl->GenMailboxCHROMIUM(texture_mailbox->name); |
164 context->bindTexture(texture_target, *texture_id); | 165 gl->BindTexture(texture_target, *texture_id); |
165 context->produceTextureCHROMIUM(texture_target, texture_mailbox->name); | 166 gl->ProduceTextureCHROMIUM(texture_target, texture_mailbox->name); |
166 | 167 |
167 context->flush(); | 168 gl->Flush(); |
168 *texture_mailbox_sync_point = context->insertSyncPoint(); | 169 *texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); |
169 } | |
170 return stream_id; | 170 return stream_id; |
171 } | 171 } |
172 | 172 |
173 void StreamTextureFactorySynchronousImpl::DestroyStreamTexture( | 173 void StreamTextureFactorySynchronousImpl::DestroyStreamTexture( |
174 unsigned texture_id) { | 174 unsigned texture_id) { |
175 DCHECK(context_provider_); | 175 DCHECK(context_provider_); |
176 blink::WebGraphicsContext3D* context = context_provider_->Context3d(); | 176 GLES2Interface* gl = context_provider_->ContextGL(); |
177 if (context->makeContextCurrent()) { | 177 gl->DestroyStreamTextureCHROMIUM(texture_id); |
178 context->destroyStreamTextureCHROMIUM(texture_id); | 178 gl->DeleteTextures(1, &texture_id); |
179 context->deleteTexture(texture_id); | 179 gl->Flush(); |
180 context->flush(); | |
181 } | |
182 } | 180 } |
183 | 181 |
184 void StreamTextureFactorySynchronousImpl::SetStreamTextureSize( | 182 void StreamTextureFactorySynchronousImpl::SetStreamTextureSize( |
185 int32 stream_id, | 183 int32 stream_id, |
186 const gfx::Size& size) {} | 184 const gfx::Size& size) {} |
187 | 185 |
188 blink::WebGraphicsContext3D* | 186 gpu::gles2::GLES2Interface* |
189 StreamTextureFactorySynchronousImpl::Context3d() { | 187 StreamTextureFactorySynchronousImpl::ContextGL() { |
190 DCHECK(context_provider_); | 188 DCHECK(context_provider_); |
191 return context_provider_->Context3d(); | 189 return context_provider_->ContextGL(); |
192 } | 190 } |
193 | 191 |
194 } // namespace content | 192 } // namespace content |
OLD | NEW |