Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: content/browser/renderer_host/image_transport_factory_android.cc

Issue 11194042: Implement TextureImageTransportSurface using texture mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win_aura DCHECK() Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/renderer_host/compositor_impl_android.h" 9 #include "content/browser/renderer_host/compositor_impl_android.h"
10 #include "content/common/gpu/gpu_process_launch_causes.h" 10 #include "content/common/gpu/gpu_process_launch_causes.h"
11 #include "content/common/gpu/client/gl_helper.h" 11 #include "content/common/gpu/client/gl_helper.h"
12 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 12 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
14 #include "third_party/khronos/GLES2/gl2.h"
14 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" 15 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 namespace { 19 namespace {
19 20
20 static ImageTransportFactoryAndroid* g_factory = NULL; 21 static ImageTransportFactoryAndroid* g_factory = NULL;
21 22
22 class DirectGLImageTransportFactory : public ImageTransportFactoryAndroid { 23 class DirectGLImageTransportFactory : public ImageTransportFactoryAndroid {
23 public: 24 public:
24 DirectGLImageTransportFactory(); 25 DirectGLImageTransportFactory();
25 virtual ~DirectGLImageTransportFactory(); 26 virtual ~DirectGLImageTransportFactory();
26 27
27 virtual gfx::GLSurfaceHandle CreateSharedSurfaceHandle() OVERRIDE { 28 virtual gfx::GLSurfaceHandle CreateSharedSurfaceHandle() OVERRIDE {
28 return gfx::GLSurfaceHandle(); 29 return gfx::GLSurfaceHandle();
29 } 30 }
30 virtual void DestroySharedSurfaceHandle( 31 virtual void DestroySharedSurfaceHandle(
31 const gfx::GLSurfaceHandle& handle) OVERRIDE {} 32 const gfx::GLSurfaceHandle& handle) OVERRIDE {}
32 virtual uint32_t InsertSyncPoint() OVERRIDE { return 0; } 33 virtual uint32_t InsertSyncPoint() OVERRIDE { return 0; }
34 virtual uint32_t CreateTexture() OVERRIDE {
35 return context_->createTexture();
36 }
37 virtual void DeleteTexture(uint32_t id) OVERRIDE {
38 context_->deleteTexture(id);
39 }
40 virtual void AcquireTexture(
41 uint32 texture_id, const signed char* mailbox_name) OVERRIDE {}
42 virtual void ReleaseTexture(
43 uint32 texture_id, const signed char* mailbox_name) OVERRIDE {}
33 virtual WebKit::WebGraphicsContext3D* GetContext3D() OVERRIDE { 44 virtual WebKit::WebGraphicsContext3D* GetContext3D() OVERRIDE {
34 return context_.get(); 45 return context_.get();
35 } 46 }
36 virtual GLHelper* GetGLHelper() OVERRIDE { return NULL; } 47 virtual GLHelper* GetGLHelper() OVERRIDE { return NULL; }
37 48
38 private: 49 private:
39 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessImpl> context_; 50 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessImpl> context_;
40 51
41 DISALLOW_COPY_AND_ASSIGN(DirectGLImageTransportFactory); 52 DISALLOW_COPY_AND_ASSIGN(DirectGLImageTransportFactory);
42 }; 53 };
(...skipping 14 matching lines...) Expand all
57 68
58 class CmdBufferImageTransportFactory : public ImageTransportFactoryAndroid { 69 class CmdBufferImageTransportFactory : public ImageTransportFactoryAndroid {
59 public: 70 public:
60 CmdBufferImageTransportFactory(); 71 CmdBufferImageTransportFactory();
61 virtual ~CmdBufferImageTransportFactory(); 72 virtual ~CmdBufferImageTransportFactory();
62 73
63 virtual gfx::GLSurfaceHandle CreateSharedSurfaceHandle() OVERRIDE; 74 virtual gfx::GLSurfaceHandle CreateSharedSurfaceHandle() OVERRIDE;
64 virtual void DestroySharedSurfaceHandle( 75 virtual void DestroySharedSurfaceHandle(
65 const gfx::GLSurfaceHandle& handle) OVERRIDE; 76 const gfx::GLSurfaceHandle& handle) OVERRIDE;
66 virtual uint32_t InsertSyncPoint() OVERRIDE; 77 virtual uint32_t InsertSyncPoint() OVERRIDE;
78 virtual uint32_t CreateTexture() OVERRIDE;
79 virtual void DeleteTexture(uint32_t id) OVERRIDE;
80 virtual void AcquireTexture(
81 uint32 texture_id, const signed char* mailbox_name) OVERRIDE;
82 virtual void ReleaseTexture(
83 uint32 texture_id, const signed char* mailbox_name) OVERRIDE;
67 virtual WebKit::WebGraphicsContext3D* GetContext3D() OVERRIDE { 84 virtual WebKit::WebGraphicsContext3D* GetContext3D() OVERRIDE {
68 return context_.get(); 85 return context_.get();
69 } 86 }
70 virtual GLHelper* GetGLHelper() OVERRIDE; 87 virtual GLHelper* GetGLHelper() OVERRIDE;
71 88
72 private: 89 private:
73 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_; 90 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_;
74 scoped_ptr<GLHelper> gl_helper_; 91 scoped_ptr<GLHelper> gl_helper_;
75 92
76 DISALLOW_COPY_AND_ASSIGN(CmdBufferImageTransportFactory); 93 DISALLOW_COPY_AND_ASSIGN(CmdBufferImageTransportFactory);
(...skipping 21 matching lines...) Expand all
98 gfx::GLSurfaceHandle 115 gfx::GLSurfaceHandle
99 CmdBufferImageTransportFactory::CreateSharedSurfaceHandle() { 116 CmdBufferImageTransportFactory::CreateSharedSurfaceHandle() {
100 if (!context_->makeContextCurrent()) { 117 if (!context_->makeContextCurrent()) {
101 NOTREACHED() << "Failed to make shared graphics context current"; 118 NOTREACHED() << "Failed to make shared graphics context current";
102 return gfx::GLSurfaceHandle(); 119 return gfx::GLSurfaceHandle();
103 } 120 }
104 121
105 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( 122 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle(
106 gfx::kNullPluginWindow, true); 123 gfx::kNullPluginWindow, true);
107 handle.parent_gpu_process_id = context_->GetGPUProcessID(); 124 handle.parent_gpu_process_id = context_->GetGPUProcessID();
108 handle.parent_client_id = context_->GetChannelID();
109 handle.parent_context_id = context_->GetContextID();
110 handle.parent_texture_id[0] = context_->createTexture();
111 handle.parent_texture_id[1] = context_->createTexture();
112 handle.sync_point = context_->insertSyncPoint();
113 context_->flush(); 125 context_->flush();
114 return handle; 126 return handle;
115 } 127 }
116 128
117 void CmdBufferImageTransportFactory::DestroySharedSurfaceHandle( 129 void CmdBufferImageTransportFactory::DestroySharedSurfaceHandle(
118 const gfx::GLSurfaceHandle& handle) { 130 const gfx::GLSurfaceHandle& handle) {
119 if (!context_->makeContextCurrent()) { 131 if (!context_->makeContextCurrent()) {
120 NOTREACHED() << "Failed to make shared graphics context current"; 132 NOTREACHED() << "Failed to make shared graphics context current";
121 return; 133 return;
122 } 134 }
123
124 context_->deleteTexture(handle.parent_texture_id[0]);
125 context_->deleteTexture(handle.parent_texture_id[1]);
126 context_->finish();
127 } 135 }
128 136
129 uint32_t CmdBufferImageTransportFactory::InsertSyncPoint() { 137 uint32_t CmdBufferImageTransportFactory::InsertSyncPoint() {
130 return context_->insertSyncPoint(); 138 return context_->insertSyncPoint();
131 } 139 }
132 140
141 uint32_t CmdBufferImageTransportFactory::CreateTexture() {
142 return context_->createTexture();
143 }
144
145 void CmdBufferImageTransportFactory::DeleteTexture(uint32_t id) {
146 context_->deleteTexture(id);
147 }
148
149 void CmdBufferImageTransportFactory::AcquireTexture(
150 uint32 texture_id, const signed char* mailbox_name) {
151 context_->bindTexture(GL_TEXTURE_2D, texture_id);
152 context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name);
153 context_->flush();
154 }
155
156 void CmdBufferImageTransportFactory::ReleaseTexture(
157 uint32 texture_id, const signed char* mailbox_name) {
158 context_->bindTexture(GL_TEXTURE_2D, texture_id);
159 context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name);
160 }
161
133 GLHelper* CmdBufferImageTransportFactory::GetGLHelper() { 162 GLHelper* CmdBufferImageTransportFactory::GetGLHelper() {
134 if (!gl_helper_.get()) 163 if (!gl_helper_.get())
135 gl_helper_.reset(new GLHelper(GetContext3D(), NULL)); 164 gl_helper_.reset(new GLHelper(GetContext3D(), NULL));
136 165
137 return gl_helper_.get(); 166 return gl_helper_.get();
138 } 167 }
139 168
140 } // anonymous namespace 169 } // anonymous namespace
141 170
142 // static 171 // static
143 ImageTransportFactoryAndroid* ImageTransportFactoryAndroid::GetInstance() { 172 ImageTransportFactoryAndroid* ImageTransportFactoryAndroid::GetInstance() {
144 if (!g_factory) { 173 if (!g_factory) {
145 if (CompositorImpl::UsesDirectGL()) 174 if (CompositorImpl::UsesDirectGL())
146 g_factory = new DirectGLImageTransportFactory(); 175 g_factory = new DirectGLImageTransportFactory();
147 else 176 else
148 g_factory = new CmdBufferImageTransportFactory(); 177 g_factory = new CmdBufferImageTransportFactory();
149 } 178 }
150 179
151 return g_factory; 180 return g_factory;
152 } 181 }
153 182
154 ImageTransportFactoryAndroid::ImageTransportFactoryAndroid() { 183 ImageTransportFactoryAndroid::ImageTransportFactoryAndroid() {
155 } 184 }
156 185
157 ImageTransportFactoryAndroid::~ImageTransportFactoryAndroid() { 186 ImageTransportFactoryAndroid::~ImageTransportFactoryAndroid() {
158 } 187 }
159 188
160 } // namespace content 189 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698