| 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_impl.h" | 5 #include "content/renderer/media/android/stream_texture_factory_impl.h" |
| 6 | 6 |
| 7 #include "cc/output/context_provider.h" | 7 #include "cc/output/context_provider.h" |
| 8 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 8 #include "content/common/gpu/client/gpu_channel_host.h" | 9 #include "content/common/gpu/client/gpu_channel_host.h" |
| 9 #include "content/common/gpu/gpu_messages.h" | 10 #include "content/common/gpu/gpu_messages.h" |
| 10 #include "content/renderer/gpu/stream_texture_host_android.h" | 11 #include "content/renderer/gpu/stream_texture_host_android.h" |
| 11 #include "gpu/command_buffer/client/gles2_interface.h" | 12 #include "gpu/command_buffer/client/gles2_interface.h" |
| 12 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 void StreamTextureProxyImpl::OnMatrixChanged(const float matrix[16]) { | 104 void StreamTextureProxyImpl::OnMatrixChanged(const float matrix[16]) { |
| 104 base::AutoLock lock(lock_); | 105 base::AutoLock lock(lock_); |
| 105 if (client_) | 106 if (client_) |
| 106 client_->DidUpdateMatrix(matrix); | 107 client_->DidUpdateMatrix(matrix); |
| 107 } | 108 } |
| 108 | 109 |
| 109 } // namespace | 110 } // namespace |
| 110 | 111 |
| 111 // static | 112 // static |
| 112 scoped_refptr<StreamTextureFactoryImpl> StreamTextureFactoryImpl::Create( | 113 scoped_refptr<StreamTextureFactoryImpl> StreamTextureFactoryImpl::Create( |
| 113 const scoped_refptr<cc::ContextProvider>& context_provider, | 114 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 114 GpuChannelHost* channel, | 115 GpuChannelHost* channel) { |
| 115 int frame_id) { | 116 return new StreamTextureFactoryImpl(context_provider, channel); |
| 116 return new StreamTextureFactoryImpl(context_provider, channel, frame_id); | |
| 117 } | 117 } |
| 118 | 118 |
| 119 StreamTextureFactoryImpl::StreamTextureFactoryImpl( | 119 StreamTextureFactoryImpl::StreamTextureFactoryImpl( |
| 120 const scoped_refptr<cc::ContextProvider>& context_provider, | 120 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 121 GpuChannelHost* channel, | 121 GpuChannelHost* channel) |
| 122 int frame_id) | 122 : context_provider_(context_provider), channel_(channel) { |
| 123 : context_provider_(context_provider), | |
| 124 channel_(channel), | |
| 125 frame_id_(frame_id) { | |
| 126 DCHECK(channel); | 123 DCHECK(channel); |
| 127 } | 124 } |
| 128 | 125 |
| 129 StreamTextureFactoryImpl::~StreamTextureFactoryImpl() {} | 126 StreamTextureFactoryImpl::~StreamTextureFactoryImpl() {} |
| 130 | 127 |
| 131 StreamTextureProxy* StreamTextureFactoryImpl::CreateProxy() { | 128 StreamTextureProxy* StreamTextureFactoryImpl::CreateProxy() { |
| 132 DCHECK(channel_.get()); | 129 DCHECK(channel_.get()); |
| 133 StreamTextureHost* host = new StreamTextureHost(channel_.get()); | 130 StreamTextureHost* host = new StreamTextureHost(channel_.get()); |
| 134 return new StreamTextureProxyImpl(host); | 131 return new StreamTextureProxyImpl(host); |
| 135 } | 132 } |
| 136 | 133 |
| 137 void StreamTextureFactoryImpl::EstablishPeer(int32 stream_id, int player_id) { | 134 void StreamTextureFactoryImpl::EstablishPeer(int32 stream_id, |
| 135 int player_id, |
| 136 int frame_id) { |
| 138 DCHECK(channel_.get()); | 137 DCHECK(channel_.get()); |
| 139 channel_->Send( | 138 channel_->Send( |
| 140 new GpuStreamTextureMsg_EstablishPeer(stream_id, frame_id_, player_id)); | 139 new GpuStreamTextureMsg_EstablishPeer(stream_id, frame_id, player_id)); |
| 141 } | 140 } |
| 142 | 141 |
| 143 unsigned StreamTextureFactoryImpl::CreateStreamTexture( | 142 unsigned StreamTextureFactoryImpl::CreateStreamTexture( |
| 144 unsigned texture_target, | 143 unsigned texture_target, |
| 145 unsigned* texture_id, | 144 unsigned* texture_id, |
| 146 gpu::Mailbox* texture_mailbox) { | 145 gpu::Mailbox* texture_mailbox) { |
| 147 GLuint stream_id = 0; | 146 GLuint stream_id = 0; |
| 148 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 147 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 149 gl->GenTextures(1, texture_id); | 148 gl->GenTextures(1, texture_id); |
| 150 | 149 gl->ShallowFlushCHROMIUM(); |
| 151 stream_id = gl->CreateStreamTextureCHROMIUM(*texture_id); | 150 stream_id = context_provider_->GetCommandBufferProxy()->CreateStreamTexture( |
| 152 | 151 *texture_id); |
| 153 gl->GenMailboxCHROMIUM(texture_mailbox->name); | 152 gl->GenMailboxCHROMIUM(texture_mailbox->name); |
| 154 gl->ProduceTextureDirectCHROMIUM( | 153 gl->ProduceTextureDirectCHROMIUM( |
| 155 *texture_id, texture_target, texture_mailbox->name); | 154 *texture_id, texture_target, texture_mailbox->name); |
| 156 return stream_id; | 155 return stream_id; |
| 157 } | 156 } |
| 158 | 157 |
| 159 void StreamTextureFactoryImpl::SetStreamTextureSize(int32 stream_id, | 158 void StreamTextureFactoryImpl::SetStreamTextureSize(int32 stream_id, |
| 160 const gfx::Size& size) { | 159 const gfx::Size& size) { |
| 161 channel_->Send(new GpuStreamTextureMsg_SetSize(stream_id, size)); | 160 channel_->Send(new GpuStreamTextureMsg_SetSize(stream_id, size)); |
| 162 } | 161 } |
| 163 | 162 |
| 164 gpu::gles2::GLES2Interface* StreamTextureFactoryImpl::ContextGL() { | 163 gpu::gles2::GLES2Interface* StreamTextureFactoryImpl::ContextGL() { |
| 165 return context_provider_->ContextGL(); | 164 return context_provider_->ContextGL(); |
| 166 } | 165 } |
| 167 | 166 |
| 168 void StreamTextureFactoryImpl::AddObserver( | 167 void StreamTextureFactoryImpl::AddObserver( |
| 169 StreamTextureFactoryContextObserver* obs) { | 168 StreamTextureFactoryContextObserver* obs) { |
| 170 } | 169 } |
| 171 | 170 |
| 172 void StreamTextureFactoryImpl::RemoveObserver( | 171 void StreamTextureFactoryImpl::RemoveObserver( |
| 173 StreamTextureFactoryContextObserver* obs) { | 172 StreamTextureFactoryContextObserver* obs) { |
| 174 } | 173 } |
| 175 | 174 |
| 176 } // namespace content | 175 } // namespace content |
| OLD | NEW |