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/gl_helper.h" | 10 #include "content/common/gpu/client/gl_helper.h" |
11 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 11 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
| 13 #include "third_party/khronos/GLES2/gl2.h" |
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 |
21 ImageTransportFactoryAndroid::ImageTransportFactoryAndroid() { | 22 ImageTransportFactoryAndroid::ImageTransportFactoryAndroid() { |
22 WebKit::WebGraphicsContext3D::Attributes attrs; | 23 WebKit::WebGraphicsContext3D::Attributes attrs; |
(...skipping 18 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 |
76 WebKit::WebGraphicsContext3D* ImageTransportFactoryAndroid::GetContext3D() { | 68 WebKit::WebGraphicsContext3D* ImageTransportFactoryAndroid::GetContext3D() { |
77 return context_.get(); | 69 return context_.get(); |
78 } | 70 } |
79 | 71 |
| 72 uint32_t ImageTransportFactoryAndroid::CreateTexture() { |
| 73 return context_->createTexture(); |
| 74 } |
| 75 |
| 76 void ImageTransportFactoryAndroid::DeleteTexture(uint32_t id) { |
| 77 context_->deleteTexture(id); |
| 78 } |
| 79 |
| 80 void ImageTransportFactoryAndroid::AcquireTexture( |
| 81 uint32 texture_id, const signed char* mailbox_name) { |
| 82 context_->bindTexture(GL_TEXTURE_2D, texture_id); |
| 83 context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name); |
| 84 context_->flush(); |
| 85 } |
| 86 |
| 87 void ImageTransportFactoryAndroid::ReleaseTexture( |
| 88 uint32 texture_id, const signed char* mailbox_name) { |
| 89 context_->bindTexture(GL_TEXTURE_2D, texture_id); |
| 90 context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name); |
| 91 } |
| 92 |
80 GLHelper* ImageTransportFactoryAndroid::GetGLHelper() { | 93 GLHelper* ImageTransportFactoryAndroid::GetGLHelper() { |
81 if (!gl_helper_.get()) | 94 if (!gl_helper_.get()) |
82 gl_helper_.reset(new GLHelper(GetContext3D(), NULL)); | 95 gl_helper_.reset(new GLHelper(GetContext3D(), NULL)); |
83 | 96 |
84 return gl_helper_.get(); | 97 return gl_helper_.get(); |
85 } | 98 } |
86 | 99 |
87 } // namespace content | 100 } // namespace content |
OLD | NEW |