Chromium Code Reviews| 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 int frame_id) { |
| 116 return new StreamTextureFactoryImpl(context_provider, channel, frame_id); | 117 return new StreamTextureFactoryImpl(context_provider, channel, frame_id); |
| 117 } | 118 } |
| 118 | 119 |
| 119 StreamTextureFactoryImpl::StreamTextureFactoryImpl( | 120 StreamTextureFactoryImpl::StreamTextureFactoryImpl( |
| 120 const scoped_refptr<cc::ContextProvider>& context_provider, | 121 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 121 GpuChannelHost* channel, | 122 GpuChannelHost* channel, |
| 122 int frame_id) | 123 int frame_id) |
| 123 : context_provider_(context_provider), | 124 : context_provider_(context_provider), |
| 124 channel_(channel), | 125 channel_(channel), |
| 125 frame_id_(frame_id) { | 126 frame_id_(frame_id) { |
| 126 DCHECK(channel); | 127 DCHECK(channel); |
| 127 } | 128 } |
| 128 | 129 |
| 129 StreamTextureFactoryImpl::~StreamTextureFactoryImpl() {} | 130 StreamTextureFactoryImpl::~StreamTextureFactoryImpl() {} |
| 130 | 131 |
| 131 StreamTextureProxy* StreamTextureFactoryImpl::CreateProxy() { | 132 StreamTextureProxy* StreamTextureFactoryImpl::CreateProxy() { |
| 132 DCHECK(channel_.get()); | 133 DCHECK(channel_.get()); |
| 133 StreamTextureHost* host = new StreamTextureHost(channel_.get()); | 134 StreamTextureHost* host = new StreamTextureHost(channel_.get()); |
| 134 return new StreamTextureProxyImpl(host); | 135 return new StreamTextureProxyImpl(host); |
| 135 } | 136 } |
| 136 | 137 |
| 137 void StreamTextureFactoryImpl::EstablishPeer(int32 stream_id, int player_id) { | 138 void StreamTextureFactoryImpl::EstablishPeer(int32 stream_id, int player_id) { |
| 138 DCHECK(channel_.get()); | 139 DCHECK(channel_.get()); |
| 139 channel_->Send( | 140 channel_->Send( |
| 140 new GpuStreamTextureMsg_EstablishPeer(stream_id, frame_id_, player_id)); | 141 new GpuStreamTextureMsg_EstablishPeer(stream_id, frame_id_, player_id)); |
| 141 } | 142 } |
| 142 | 143 |
| 143 unsigned StreamTextureFactoryImpl::CreateStreamTexture( | 144 unsigned StreamTextureFactoryImpl::CreateStreamTexture( |
| 144 unsigned texture_target, | 145 unsigned texture_target, |
| 145 unsigned* texture_id, | 146 unsigned* texture_id, |
| 146 gpu::Mailbox* texture_mailbox) { | 147 gpu::Mailbox* texture_mailbox) { |
| 147 GLuint stream_id = 0; | 148 GLuint stream_id = 0; |
| 148 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 149 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 149 gl->GenTextures(1, texture_id); | 150 gl->GenTextures(1, texture_id); |
| 150 | 151 gl->Flush(); |
|
no sievers
2015/10/26 21:35:33
ShallowFlushCHROMIUM() is good enough (and same as
sivag
2015/10/27 15:42:44
Done.
| |
| 151 stream_id = gl->CreateStreamTextureCHROMIUM(*texture_id); | 152 stream_id = |
| 152 | 153 context_provider_->GetCommandBufferProxy()->CreateStreamTexture( |
| 154 *texture_id); | |
| 153 gl->GenMailboxCHROMIUM(texture_mailbox->name); | 155 gl->GenMailboxCHROMIUM(texture_mailbox->name); |
| 154 gl->ProduceTextureDirectCHROMIUM( | 156 gl->ProduceTextureDirectCHROMIUM( |
| 155 *texture_id, texture_target, texture_mailbox->name); | 157 *texture_id, texture_target, texture_mailbox->name); |
| 156 return stream_id; | 158 return stream_id; |
| 157 } | 159 } |
| 158 | 160 |
| 159 void StreamTextureFactoryImpl::SetStreamTextureSize(int32 stream_id, | 161 void StreamTextureFactoryImpl::SetStreamTextureSize(int32 stream_id, |
| 160 const gfx::Size& size) { | 162 const gfx::Size& size) { |
| 161 channel_->Send(new GpuStreamTextureMsg_SetSize(stream_id, size)); | 163 channel_->Send(new GpuStreamTextureMsg_SetSize(stream_id, size)); |
| 162 } | 164 } |
| 163 | 165 |
| 164 gpu::gles2::GLES2Interface* StreamTextureFactoryImpl::ContextGL() { | 166 gpu::gles2::GLES2Interface* StreamTextureFactoryImpl::ContextGL() { |
| 165 return context_provider_->ContextGL(); | 167 return context_provider_->ContextGL(); |
| 166 } | 168 } |
| 167 | 169 |
| 168 void StreamTextureFactoryImpl::AddObserver( | 170 void StreamTextureFactoryImpl::AddObserver( |
| 169 StreamTextureFactoryContextObserver* obs) { | 171 StreamTextureFactoryContextObserver* obs) { |
| 170 } | 172 } |
| 171 | 173 |
| 172 void StreamTextureFactoryImpl::RemoveObserver( | 174 void StreamTextureFactoryImpl::RemoveObserver( |
| 173 StreamTextureFactoryContextObserver* obs) { | 175 StreamTextureFactoryContextObserver* obs) { |
| 174 } | 176 } |
| 175 | 177 |
| 176 } // namespace content | 178 } // namespace content |
| OLD | NEW |