| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/image_transport_factory_android.h" | 5 #include "content/browser/renderer_host/image_transport_factory_android.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 8 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 9 #include "content/common/gpu/gpu_process_launch_causes.h" | 9 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 11 #include "third_party/khronos/GLES2/gl2.h" |
| 11 | 12 |
| 12 using content::BrowserGpuChannelHostFactory; | 13 using content::BrowserGpuChannelHostFactory; |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 // static | 17 // static |
| 17 ImageTransportFactoryAndroid* ImageTransportFactoryAndroid::GetInstance() { | 18 ImageTransportFactoryAndroid* ImageTransportFactoryAndroid::GetInstance() { |
| 18 return Singleton<ImageTransportFactoryAndroid>::get(); | 19 return Singleton<ImageTransportFactoryAndroid>::get(); |
| 19 } | 20 } |
| 20 | 21 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 41 | 42 |
| 42 gfx::GLSurfaceHandle ImageTransportFactoryAndroid::CreateSharedSurfaceHandle() { | 43 gfx::GLSurfaceHandle ImageTransportFactoryAndroid::CreateSharedSurfaceHandle() { |
| 43 if (!context_->makeContextCurrent()) { | 44 if (!context_->makeContextCurrent()) { |
| 44 NOTREACHED() << "Failed to make shared graphics context current"; | 45 NOTREACHED() << "Failed to make shared graphics context current"; |
| 45 return gfx::GLSurfaceHandle(); | 46 return gfx::GLSurfaceHandle(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( | 49 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( |
| 49 gfx::kNullPluginWindow, true); | 50 gfx::kNullPluginWindow, true); |
| 50 handle.parent_gpu_process_id = context_->GetGPUProcessID(); | 51 handle.parent_gpu_process_id = context_->GetGPUProcessID(); |
| 51 handle.parent_client_id = context_->GetChannelID(); | |
| 52 handle.parent_context_id = context_->GetContextID(); | |
| 53 handle.parent_texture_id[0] = context_->createTexture(); | |
| 54 handle.parent_texture_id[1] = context_->createTexture(); | |
| 55 handle.sync_point = context_->insertSyncPoint(); | |
| 56 context_->flush(); | 52 context_->flush(); |
| 57 return handle; | 53 return handle; |
| 58 } | 54 } |
| 59 | 55 |
| 60 void ImageTransportFactoryAndroid::DestroySharedSurfaceHandle( | 56 void ImageTransportFactoryAndroid::DestroySharedSurfaceHandle( |
| 61 const gfx::GLSurfaceHandle& handle) { | 57 const gfx::GLSurfaceHandle& handle) { |
| 62 if (!context_->makeContextCurrent()) { | 58 if (!context_->makeContextCurrent()) { |
| 63 NOTREACHED() << "Failed to make shared graphics context current"; | 59 NOTREACHED() << "Failed to make shared graphics context current"; |
| 64 return; | 60 return; |
| 65 } | 61 } |
| 66 | |
| 67 context_->deleteTexture(handle.parent_texture_id[0]); | |
| 68 context_->deleteTexture(handle.parent_texture_id[1]); | |
| 69 context_->finish(); | |
| 70 } | 62 } |
| 71 | 63 |
| 72 uint32_t ImageTransportFactoryAndroid::InsertSyncPoint() { | 64 uint32_t ImageTransportFactoryAndroid::InsertSyncPoint() { |
| 73 return context_->insertSyncPoint(); | 65 return context_->insertSyncPoint(); |
| 74 } | 66 } |
| 75 | 67 |
| 68 uint32_t ImageTransportFactoryAndroid::CreateTexture() { |
| 69 return context_->createTexture(); |
| 70 } |
| 71 |
| 72 void ImageTransportFactoryAndroid::DeleteTexture(uint32_t id) { |
| 73 context_->deleteTexture(id); |
| 74 } |
| 75 |
| 76 void ImageTransportFactoryAndroid::AcquireTexture( |
| 77 uint32 texture_id, const signed char* mailbox_name) { |
| 78 context_->bindTexture(GL_TEXTURE_2D, texture_id); |
| 79 context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name); |
| 80 } |
| 81 |
| 82 void ImageTransportFactoryAndroid::ReleaseTexture( |
| 83 uint32 texture_id, const signed char* mailbox_name) { |
| 84 context_->bindTexture(GL_TEXTURE_2D, texture_id); |
| 85 context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name); |
| 86 } |
| 87 |
| 76 WebGraphicsContext3DCommandBufferImpl* | 88 WebGraphicsContext3DCommandBufferImpl* |
| 77 ImageTransportFactoryAndroid::GetContext3D() { | 89 ImageTransportFactoryAndroid::GetContext3D() { |
| 78 return context_.get(); | 90 return context_.get(); |
| 79 } | 91 } |
| 80 | 92 |
| 81 } // namespace content | 93 } // namespace content |
| OLD | NEW |