| 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_impl.h" | 5 #include "content/renderer/media/android/stream_texture_factory_android_impl.h" |
| 6 | 6 |
| 7 #include "content/common/gpu/client/gpu_channel_host.h" | 7 #include "content/common/gpu/client/gpu_channel_host.h" |
| 8 #include "content/common/gpu/gpu_messages.h" | 8 #include "content/common/gpu/gpu_messages.h" |
| 9 #include "content/renderer/gpu/stream_texture_host_android.h" | 9 #include "content/renderer/gpu/stream_texture_host_android.h" |
| 10 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 10 #include "gpu/command_buffer/client/gles2_interface.h" |
| 11 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 class StreamTextureProxyImpl : public StreamTextureProxy, | 17 class StreamTextureProxyImpl : public StreamTextureProxy, |
| 18 public StreamTextureHost::Listener { | 18 public StreamTextureHost::Listener { |
| 19 public: | 19 public: |
| 20 explicit StreamTextureProxyImpl(StreamTextureHost* host); | 20 explicit StreamTextureProxyImpl(StreamTextureHost* host); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 void StreamTextureProxyImpl::OnMatrixChanged(const float matrix[16]) { | 74 void StreamTextureProxyImpl::OnMatrixChanged(const float matrix[16]) { |
| 75 base::AutoLock lock(client_lock_); | 75 base::AutoLock lock(client_lock_); |
| 76 if (client_) | 76 if (client_) |
| 77 client_->DidUpdateMatrix(matrix); | 77 client_->DidUpdateMatrix(matrix); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace | 80 } // namespace |
| 81 | 81 |
| 82 StreamTextureFactoryImpl::StreamTextureFactoryImpl( | 82 StreamTextureFactoryImpl::StreamTextureFactoryImpl( |
| 83 blink::WebGraphicsContext3D* context, | 83 gpu::gles2::GLES2Interface* gl, |
| 84 GpuChannelHost* channel, | 84 GpuChannelHost* channel, |
| 85 int view_id) | 85 int view_id) |
| 86 : context_(context), channel_(channel), view_id_(view_id) { | 86 : gl_(gl), channel_(channel), view_id_(view_id) { |
| 87 DCHECK(context_); | 87 DCHECK(gl_); |
| 88 DCHECK(channel); | 88 DCHECK(channel); |
| 89 } | 89 } |
| 90 | 90 |
| 91 StreamTextureFactoryImpl::~StreamTextureFactoryImpl() {} | 91 StreamTextureFactoryImpl::~StreamTextureFactoryImpl() {} |
| 92 | 92 |
| 93 StreamTextureProxy* StreamTextureFactoryImpl::CreateProxy() { | 93 StreamTextureProxy* StreamTextureFactoryImpl::CreateProxy() { |
| 94 DCHECK(channel_.get()); | 94 DCHECK(channel_.get()); |
| 95 StreamTextureHost* host = new StreamTextureHost(channel_.get()); | 95 StreamTextureHost* host = new StreamTextureHost(channel_.get()); |
| 96 return new StreamTextureProxyImpl(host); | 96 return new StreamTextureProxyImpl(host); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void StreamTextureFactoryImpl::EstablishPeer(int32 stream_id, int player_id) { | 99 void StreamTextureFactoryImpl::EstablishPeer(int32 stream_id, int player_id) { |
| 100 DCHECK(channel_.get()); | 100 DCHECK(channel_.get()); |
| 101 channel_->Send( | 101 channel_->Send( |
| 102 new GpuChannelMsg_EstablishStreamTexture(stream_id, view_id_, player_id)); | 102 new GpuChannelMsg_EstablishStreamTexture(stream_id, view_id_, player_id)); |
| 103 } | 103 } |
| 104 | 104 |
| 105 unsigned StreamTextureFactoryImpl::CreateStreamTexture( | 105 unsigned StreamTextureFactoryImpl::CreateStreamTexture( |
| 106 unsigned texture_target, | 106 unsigned texture_target, |
| 107 unsigned* texture_id, | 107 unsigned* texture_id, |
| 108 gpu::Mailbox* texture_mailbox, | 108 gpu::Mailbox* texture_mailbox, |
| 109 unsigned* texture_mailbox_sync_point) { | 109 unsigned* texture_mailbox_sync_point) { |
| 110 unsigned stream_id = 0; | 110 unsigned stream_id = 0; |
| 111 if (context_->makeContextCurrent()) { | 111 gl_->GenTextures(1, texture_id); |
| 112 *texture_id = context_->createTexture(); | |
| 113 stream_id = context_->createStreamTextureCHROMIUM(*texture_id); | |
| 114 | 112 |
| 115 context_->genMailboxCHROMIUM(texture_mailbox->name); | 113 stream_id = gl_->CreateStreamTextureCHROMIUM(*texture_id); |
| 116 context_->bindTexture(texture_target, *texture_id); | |
| 117 context_->produceTextureCHROMIUM(texture_target, texture_mailbox->name); | |
| 118 | 114 |
| 119 context_->flush(); | 115 gl_->GenMailboxCHROMIUM(texture_mailbox->name); |
| 120 *texture_mailbox_sync_point = context_->insertSyncPoint(); | 116 gl_->BindTexture(texture_target, *texture_id); |
| 121 } | 117 gl_->ProduceTextureCHROMIUM(texture_target, texture_mailbox->name); |
| 118 |
| 119 gl_->Flush(); |
| 120 *texture_mailbox_sync_point = gl_->InsertSyncPointCHROMIUM(); |
| 122 return stream_id; | 121 return stream_id; |
| 123 } | 122 } |
| 124 | 123 |
| 125 void StreamTextureFactoryImpl::DestroyStreamTexture(unsigned texture_id) { | 124 void StreamTextureFactoryImpl::DestroyStreamTexture(unsigned texture_id) { |
| 126 if (context_->makeContextCurrent()) { | 125 // TODO(sievers): Make the DestroyStreamTexture implicit when the last |
| 127 // TODO(sievers): Make the destroyStreamTexture implicit when the last | 126 // texture referencing it is lost. |
| 128 // texture referencing it is lost. | 127 gl_->DestroyStreamTextureCHROMIUM(texture_id); |
| 129 context_->destroyStreamTextureCHROMIUM(texture_id); | 128 gl_->DeleteTextures(1, &texture_id); |
| 130 context_->deleteTexture(texture_id); | 129 gl_->Flush(); |
| 131 context_->flush(); | |
| 132 } | |
| 133 } | 130 } |
| 134 | 131 |
| 135 void StreamTextureFactoryImpl::SetStreamTextureSize( | 132 void StreamTextureFactoryImpl::SetStreamTextureSize( |
| 136 int32 stream_id, const gfx::Size& size) { | 133 int32 stream_id, const gfx::Size& size) { |
| 137 channel_->Send(new GpuChannelMsg_SetStreamTextureSize(stream_id, size)); | 134 channel_->Send(new GpuChannelMsg_SetStreamTextureSize(stream_id, size)); |
| 138 } | 135 } |
| 139 | 136 |
| 140 blink::WebGraphicsContext3D* StreamTextureFactoryImpl::Context3d() { | 137 gpu::gles2::GLES2Interface* StreamTextureFactoryImpl::ContextGL() { |
| 141 return context_; | 138 return gl_; |
| 142 } | 139 } |
| 143 | 140 |
| 144 } // namespace content | 141 } // namespace content |
| OLD | NEW |