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

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

Issue 9194005: gpu: reference target surfaces through a globally unique surface id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 months 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_client.h" 5 #include "content/browser/renderer_host/image_transport_client.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/extensions/Xcomposite.h> 8 #include <X11/extensions/Xcomposite.h>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 virtual ~ImageTransportClientEGL() { 49 virtual ~ImageTransportClientEGL() {
50 if (image_) { 50 if (image_) {
51 scoped_ptr<gfx::ScopedMakeCurrent> bind( 51 scoped_ptr<gfx::ScopedMakeCurrent> bind(
52 resources_->GetScopedMakeCurrent()); 52 resources_->GetScopedMakeCurrent());
53 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_); 53 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_);
54 glFlush(); 54 glFlush();
55 } 55 }
56 } 56 }
57 57
58 virtual unsigned int Initialize(uint64* surface_id) { 58 virtual unsigned int Initialize(uint64* surface_handle) {
59 scoped_ptr<gfx::ScopedMakeCurrent> bind(resources_->GetScopedMakeCurrent()); 59 scoped_ptr<gfx::ScopedMakeCurrent> bind(resources_->GetScopedMakeCurrent());
60 image_ = eglCreateImageKHR( 60 image_ = eglCreateImageKHR(
61 gfx::GLSurfaceEGL::GetHardwareDisplay(), EGL_NO_CONTEXT, 61 gfx::GLSurfaceEGL::GetHardwareDisplay(), EGL_NO_CONTEXT,
62 EGL_NATIVE_PIXMAP_KHR, reinterpret_cast<void*>(*surface_id), NULL); 62 EGL_NATIVE_PIXMAP_KHR, reinterpret_cast<void*>(*surface_handle), NULL);
63 if (!image_) 63 if (!image_)
64 return 0; 64 return 0;
65 GLuint texture = CreateTexture(); 65 GLuint texture = CreateTexture();
66 glBindTexture(GL_TEXTURE_2D, texture); 66 glBindTexture(GL_TEXTURE_2D, texture);
67 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image_); 67 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image_);
68 glFlush(); 68 glFlush();
69 return texture; 69 return texture;
70 } 70 }
71 71
72 virtual void Acquire() { } 72 virtual void Acquire() { }
(...skipping 20 matching lines...) Expand all
93 } 93 }
94 94
95 virtual ~ImageTransportClientGLX() { 95 virtual ~ImageTransportClientGLX() {
96 Display* dpy = static_cast<Display*>(resources_->GetDisplay()); 96 Display* dpy = static_cast<Display*>(resources_->GetDisplay());
97 if (glx_pixmap_) 97 if (glx_pixmap_)
98 glXDestroyGLXPixmap(dpy, glx_pixmap_); 98 glXDestroyGLXPixmap(dpy, glx_pixmap_);
99 if (pixmap_) 99 if (pixmap_)
100 XFreePixmap(dpy, pixmap_); 100 XFreePixmap(dpy, pixmap_);
101 } 101 }
102 102
103 virtual unsigned int Initialize(uint64* surface_id) { 103 virtual unsigned int Initialize(uint64* surface_handle) {
104 TRACE_EVENT0("renderer_host", "ImageTransportClientGLX::Initialize"); 104 TRACE_EVENT0("renderer_host", "ImageTransportClientGLX::Initialize");
105 Display* dpy = static_cast<Display*>(resources_->GetDisplay()); 105 Display* dpy = static_cast<Display*>(resources_->GetDisplay());
106 106
107 scoped_ptr<gfx::ScopedMakeCurrent> bind(resources_->GetScopedMakeCurrent()); 107 scoped_ptr<gfx::ScopedMakeCurrent> bind(resources_->GetScopedMakeCurrent());
108 if (!InitializeOneOff(dpy)) 108 if (!InitializeOneOff(dpy))
109 return 0; 109 return 0;
110 110
111 // Create pixmap from window. 111 // Create pixmap from window.
112 // We receive a window here rather than a pixmap directly because drivers 112 // We receive a window here rather than a pixmap directly because drivers
113 // require (or required) that the pixmap used to create the GL texture be 113 // require (or required) that the pixmap used to create the GL texture be
114 // created in the same process as the texture. 114 // created in the same process as the texture.
115 pixmap_ = XCompositeNameWindowPixmap(dpy, *surface_id); 115 pixmap_ = XCompositeNameWindowPixmap(dpy, *surface_handle);
116 116
117 const int pixmapAttribs[] = { 117 const int pixmapAttribs[] = {
118 GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, 118 GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
119 GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT, 119 GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
120 0 120 0
121 }; 121 };
122 122
123 glx_pixmap_ = glXCreatePixmap(dpy, fbconfig_.Get(), pixmap_, pixmapAttribs); 123 glx_pixmap_ = glXCreatePixmap(dpy, fbconfig_.Get(), pixmap_, pixmapAttribs);
124 124
125 texture_ = CreateTexture(); 125 texture_ = CreateTexture();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 ImageTransportClientOSMesa(ui::SharedResources* resources, 226 ImageTransportClientOSMesa(ui::SharedResources* resources,
227 const gfx::Size& size) 227 const gfx::Size& size)
228 : resources_(resources), 228 : resources_(resources),
229 size_(size), 229 size_(size),
230 texture_(0) { 230 texture_(0) {
231 } 231 }
232 232
233 virtual ~ImageTransportClientOSMesa() { 233 virtual ~ImageTransportClientOSMesa() {
234 } 234 }
235 235
236 virtual unsigned int Initialize(uint64* surface_id) { 236 virtual unsigned int Initialize(uint64* surface_handle) {
237 // We expect to make the id here, so don't want the other end giving us one 237 // We expect to make the id here, so don't want the other end giving us one
jonathan.backer 2012/01/16 19:47:26 s/id/handle?
piman 2012/01/17 19:40:54 Done. Thanks.
238 DCHECK_EQ(*surface_id, static_cast<uint64>(0)); 238 DCHECK_EQ(*surface_handle, static_cast<uint64>(0));
239 239
240 // It's possible that this ID gneration could clash with IDs from other 240 // It's possible that this ID gneration could clash with IDs from other
241 // AcceleratedSurfaceContainerTouch* objects, however we should never have 241 // AcceleratedSurfaceContainerTouch* objects, however we should never have
242 // ids active from more than one type at the same time, so we have free 242 // ids active from more than one type at the same time, so we have free
243 // reign of the id namespace. 243 // reign of the id namespace.
244 *surface_id = next_id_++; 244 *surface_handle = next_id_++;
jonathan.backer 2012/01/16 19:47:26 s/next_id_/next_handle_?
piman 2012/01/17 19:40:54 Done.
245 245
246 shared_mem_.reset( 246 shared_mem_.reset(
247 TransportDIB::Create(size_.GetArea() * 4, // GL_RGBA=4 B/px 247 TransportDIB::Create(size_.GetArea() * 4, // GL_RGBA=4 B/px
248 *surface_id)); 248 *surface_handle));
249 if (!shared_mem_.get()) 249 if (!shared_mem_.get())
250 return 0; 250 return 0;
251 251
252 scoped_ptr<gfx::ScopedMakeCurrent> bind(resources_->GetScopedMakeCurrent()); 252 scoped_ptr<gfx::ScopedMakeCurrent> bind(resources_->GetScopedMakeCurrent());
253 texture_ = CreateTexture(); 253 texture_ = CreateTexture();
254 return texture_; 254 return texture_;
255 } 255 }
256 256
257 virtual void Acquire() { 257 virtual void Acquire() {
258 glBindTexture(GL_TEXTURE_2D, texture_); 258 glBindTexture(GL_TEXTURE_2D, texture_);
(...skipping 29 matching lines...) Expand all
288 case gfx::kGLImplementationDesktopGL: 288 case gfx::kGLImplementationDesktopGL:
289 return new ImageTransportClientGLX(resources); 289 return new ImageTransportClientGLX(resources);
290 #endif 290 #endif
291 case gfx::kGLImplementationEGLGLES2: 291 case gfx::kGLImplementationEGLGLES2:
292 return new ImageTransportClientEGL(resources); 292 return new ImageTransportClientEGL(resources);
293 default: 293 default:
294 NOTREACHED(); 294 NOTREACHED();
295 return NULL; 295 return NULL;
296 } 296 }
297 } 297 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698