| 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.h" | 5 #include "content/renderer/media/android/stream_texture_factory.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" |
| 8 #include "cc/output/context_provider.h" | 9 #include "cc/output/context_provider.h" |
| 9 #include "content/common/gpu/client/context_provider_command_buffer.h" | 10 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 10 #include "gpu/command_buffer/client/gles2_interface.h" | 11 #include "gpu/command_buffer/client/gles2_interface.h" |
| 11 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 12 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 12 #include "gpu/ipc/client/gpu_channel_host.h" | 13 #include "gpu/ipc/client/gpu_channel_host.h" |
| 13 #include "gpu/ipc/common/gpu_messages.h" | 14 #include "gpu/ipc/common/gpu_messages.h" |
| 14 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 StreamTextureProxy::StreamTextureProxy(StreamTextureHost* host) : host_(host) {} | 19 StreamTextureProxy::StreamTextureProxy(std::unique_ptr<StreamTextureHost> host) |
| 20 : host_(std::move(host)) {} |
| 19 | 21 |
| 20 StreamTextureProxy::~StreamTextureProxy() {} | 22 StreamTextureProxy::~StreamTextureProxy() {} |
| 21 | 23 |
| 22 void StreamTextureProxy::Release() { | 24 void StreamTextureProxy::Release() { |
| 23 { | 25 { |
| 24 // Cannot call |received_frame_cb_| after returning from here. | 26 // Cannot call |received_frame_cb_| after returning from here. |
| 25 base::AutoLock lock(lock_); | 27 base::AutoLock lock(lock_); |
| 26 received_frame_cb_.Reset(); | 28 received_frame_cb_.Reset(); |
| 27 } | 29 } |
| 28 // Release is analogous to the destructor, so there should be no more external | 30 // Release is analogous to the destructor, so there should be no more external |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 89 |
| 88 StreamTextureFactory::StreamTextureFactory( | 90 StreamTextureFactory::StreamTextureFactory( |
| 89 scoped_refptr<ContextProviderCommandBuffer> context_provider) | 91 scoped_refptr<ContextProviderCommandBuffer> context_provider) |
| 90 : context_provider_(std::move(context_provider)), | 92 : context_provider_(std::move(context_provider)), |
| 91 channel_(context_provider_->GetCommandBufferProxy()->channel()) { | 93 channel_(context_provider_->GetCommandBufferProxy()->channel()) { |
| 92 DCHECK(channel_); | 94 DCHECK(channel_); |
| 93 } | 95 } |
| 94 | 96 |
| 95 StreamTextureFactory::~StreamTextureFactory() {} | 97 StreamTextureFactory::~StreamTextureFactory() {} |
| 96 | 98 |
| 97 StreamTextureProxy* StreamTextureFactory::CreateProxy( | 99 ScopedStreamTextureProxy StreamTextureFactory::CreateProxy( |
| 98 unsigned texture_target, | 100 unsigned texture_target, |
| 99 unsigned* texture_id, | 101 unsigned* texture_id, |
| 100 gpu::Mailbox* texture_mailbox) { | 102 gpu::Mailbox* texture_mailbox) { |
| 101 int32_t route_id = | 103 int32_t route_id = |
| 102 CreateStreamTexture(texture_target, texture_id, texture_mailbox); | 104 CreateStreamTexture(texture_target, texture_id, texture_mailbox); |
| 103 if (!route_id) | 105 if (!route_id) |
| 104 return nullptr; | 106 return ScopedStreamTextureProxy(); |
| 105 StreamTextureHost* host = new StreamTextureHost(channel_, route_id); | 107 return ScopedStreamTextureProxy(new StreamTextureProxy( |
| 106 return new StreamTextureProxy(host); | 108 base::MakeUnique<StreamTextureHost>(channel_, route_id))); |
| 107 } | 109 } |
| 108 | 110 |
| 109 unsigned StreamTextureFactory::CreateStreamTexture( | 111 unsigned StreamTextureFactory::CreateStreamTexture( |
| 110 unsigned texture_target, | 112 unsigned texture_target, |
| 111 unsigned* texture_id, | 113 unsigned* texture_id, |
| 112 gpu::Mailbox* texture_mailbox) { | 114 gpu::Mailbox* texture_mailbox) { |
| 113 GLuint route_id = 0; | 115 GLuint route_id = 0; |
| 114 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 116 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 115 gl->GenTextures(1, texture_id); | 117 gl->GenTextures(1, texture_id); |
| 116 gl->ShallowFlushCHROMIUM(); | 118 gl->ShallowFlushCHROMIUM(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 128 texture_mailbox->name); | 130 texture_mailbox->name); |
| 129 } | 131 } |
| 130 return route_id; | 132 return route_id; |
| 131 } | 133 } |
| 132 | 134 |
| 133 gpu::gles2::GLES2Interface* StreamTextureFactory::ContextGL() { | 135 gpu::gles2::GLES2Interface* StreamTextureFactory::ContextGL() { |
| 134 return context_provider_->ContextGL(); | 136 return context_provider_->ContextGL(); |
| 135 } | 137 } |
| 136 | 138 |
| 137 } // namespace content | 139 } // namespace content |
| OLD | NEW |