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

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: Created 8 years, 1 month 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/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/khronos/GLES2/gl2.h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
13 14
14 using content::BrowserGpuChannelHostFactory; 15 using content::BrowserGpuChannelHostFactory;
15 16
16 namespace content { 17 namespace content {
17 18
18 // static 19 // static
19 ImageTransportFactoryAndroid* ImageTransportFactoryAndroid::GetInstance() { 20 ImageTransportFactoryAndroid* ImageTransportFactoryAndroid::GetInstance() {
20 return Singleton<ImageTransportFactoryAndroid>::get(); 21 return Singleton<ImageTransportFactoryAndroid>::get();
21 } 22 }
(...skipping 21 matching lines...) Expand all
43 44
44 gfx::GLSurfaceHandle ImageTransportFactoryAndroid::CreateSharedSurfaceHandle() { 45 gfx::GLSurfaceHandle ImageTransportFactoryAndroid::CreateSharedSurfaceHandle() {
45 if (!context_->makeContextCurrent()) { 46 if (!context_->makeContextCurrent()) {
46 NOTREACHED() << "Failed to make shared graphics context current"; 47 NOTREACHED() << "Failed to make shared graphics context current";
47 return gfx::GLSurfaceHandle(); 48 return gfx::GLSurfaceHandle();
48 } 49 }
49 50
50 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( 51 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle(
51 gfx::kNullPluginWindow, true); 52 gfx::kNullPluginWindow, true);
52 handle.parent_gpu_process_id = context_->GetGPUProcessID(); 53 handle.parent_gpu_process_id = context_->GetGPUProcessID();
53 handle.parent_client_id = context_->GetChannelID();
54 handle.parent_context_id = context_->GetContextID();
55 handle.parent_texture_id[0] = context_->createTexture();
56 handle.parent_texture_id[1] = context_->createTexture();
57 handle.sync_point = context_->insertSyncPoint();
58 context_->flush(); 54 context_->flush();
59 return handle; 55 return handle;
60 } 56 }
61 57
62 void ImageTransportFactoryAndroid::DestroySharedSurfaceHandle( 58 void ImageTransportFactoryAndroid::DestroySharedSurfaceHandle(
63 const gfx::GLSurfaceHandle& handle) { 59 const gfx::GLSurfaceHandle& handle) {
64 if (!context_->makeContextCurrent()) { 60 if (!context_->makeContextCurrent()) {
65 NOTREACHED() << "Failed to make shared graphics context current"; 61 NOTREACHED() << "Failed to make shared graphics context current";
66 return; 62 return;
67 } 63 }
68
69 context_->deleteTexture(handle.parent_texture_id[0]);
70 context_->deleteTexture(handle.parent_texture_id[1]);
71 context_->finish();
72 } 64 }
73 65
74 uint32_t ImageTransportFactoryAndroid::InsertSyncPoint() { 66 uint32_t ImageTransportFactoryAndroid::InsertSyncPoint() {
75 return context_->insertSyncPoint(); 67 return context_->insertSyncPoint();
76 } 68 }
77 69
78 WebKit::WebGraphicsContext3D* ImageTransportFactoryAndroid::GetContext3D() { 70 WebKit::WebGraphicsContext3D* ImageTransportFactoryAndroid::GetContext3D() {
79 return context_.get(); 71 return context_.get();
80 } 72 }
81 73
74 uint32_t ImageTransportFactoryAndroid::CreateTexture() {
75 return context_->createTexture();
76 }
77
78 void ImageTransportFactoryAndroid::DeleteTexture(uint32_t id) {
79 context_->deleteTexture(id);
80 }
81
82 void ImageTransportFactoryAndroid::AcquireTexture(
83 uint32 texture_id, const signed char* mailbox_name) {
84 context_->bindTexture(GL_TEXTURE_2D, texture_id);
85 context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name);
86 }
87
88 void ImageTransportFactoryAndroid::ReleaseTexture(
89 uint32 texture_id, const signed char* mailbox_name) {
90 context_->bindTexture(GL_TEXTURE_2D, texture_id);
91 context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name);
92 }
93
82 GLHelper* ImageTransportFactoryAndroid::GetGLHelper() { 94 GLHelper* ImageTransportFactoryAndroid::GetGLHelper() {
83 if (!gl_helper_.get()) 95 if (!gl_helper_.get())
84 gl_helper_.reset(new GLHelper(GetContext3D(), NULL)); 96 gl_helper_.reset(new GLHelper(GetContext3D(), NULL));
85 97
86 return gl_helper_.get(); 98 return gl_helper_.get();
87 } 99 }
88 100
89 } // namespace content 101 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698