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

Side by Side Diff: chrome/browser/renderer_host/accelerated_surface_container_touch.cc

Issue 8060045: Use shared D3D9 texture to transport the compositor's backing buffer to the browser... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/renderer_host/render_widget_host_view_views.h » ('j') | gpu/DEPS » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/renderer_host/accelerated_surface_container_touch.h" 5 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.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/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 DCHECK(instance); 162 DCHECK(instance);
163 instance->MakeSharedContextCurrent(); 163 instance->MakeSharedContextCurrent();
164 164
165 if (!AcceleratedSurfaceContainerTouchGLX::InitializeOneOff()) 165 if (!AcceleratedSurfaceContainerTouchGLX::InitializeOneOff())
166 return false; 166 return false;
167 167
168 // Create pixmap from window. 168 // Create pixmap from window.
169 // We receive a window here rather than a pixmap directly because drivers 169 // We receive a window here rather than a pixmap directly because drivers
170 // require (or required) that the pixmap used to create the GL texture be 170 // require (or required) that the pixmap used to create the GL texture be
171 // created in the same process as the texture. 171 // created in the same process as the texture.
172 Display* dpy = gfx::GLSurfaceGLX::GetDisplay(); 172 Display* dpy = static_cast<Display*>(instance->GetDisplay());
173 pixmap_ = XCompositeNameWindowPixmap(dpy, *surface_id); 173 pixmap_ = XCompositeNameWindowPixmap(dpy, *surface_id);
174 174
175 // Wrap the pixmap in a GLXPixmap 175 // Wrap the pixmap in a GLXPixmap
176 const int pixmapAttribs[] = { 176 const int pixmapAttribs[] = {
177 GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, 177 GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
178 GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT, 178 GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
179 0 179 0
180 }; 180 };
181 181
182 glx_pixmap_ = glXCreatePixmap( 182 glx_pixmap_ = glXCreatePixmap(
183 dpy, fbconfig_.Get(), pixmap_, pixmapAttribs); 183 dpy, fbconfig_.Get(), pixmap_, pixmapAttribs);
184 184
185 // Create texture. 185 // Create texture.
186 glGenTextures(1, &texture_id_); 186 glGenTextures(1, &texture_id_);
187 glBindTexture(GL_TEXTURE_2D, texture_id_); 187 glBindTexture(GL_TEXTURE_2D, texture_id_);
188 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 188 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
189 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 189 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
190 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 190 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
191 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 191 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
192 192
193 return true; 193 return true;
194 } 194 }
195 195
196 AcceleratedSurfaceContainerTouchGLX::~AcceleratedSurfaceContainerTouchGLX() { 196 AcceleratedSurfaceContainerTouchGLX::~AcceleratedSurfaceContainerTouchGLX() {
197 ui::SharedResources* instance = ui::SharedResources::GetInstance(); 197 ui::SharedResources* instance = ui::SharedResources::GetInstance();
198 DCHECK(instance); 198 DCHECK(instance);
199 instance->MakeSharedContextCurrent(); 199 instance->MakeSharedContextCurrent();
200 200
201 Display* dpy = gfx::GLSurfaceGLX::GetDisplay(); 201 Display* dpy = static_cast<Display*>(instance->GetDisplay());
202 if (glx_pixmap_) 202 if (glx_pixmap_)
203 glXDestroyGLXPixmap(dpy, glx_pixmap_); 203 glXDestroyGLXPixmap(dpy, glx_pixmap_);
204 if (pixmap_) 204 if (pixmap_)
205 XFreePixmap(dpy, pixmap_); 205 XFreePixmap(dpy, pixmap_);
206 } 206 }
207 207
208 void AcceleratedSurfaceContainerTouchGLX::Draw( 208 void AcceleratedSurfaceContainerTouchGLX::Draw(
209 const ui::TextureDrawParams& params, 209 const ui::TextureDrawParams& params,
210 const gfx::Rect& clip_bounds_in_texture) { 210 const gfx::Rect& clip_bounds_in_texture) {
211 ui::SharedResources* instance = ui::SharedResources::GetInstance(); 211 ui::SharedResources* instance = ui::SharedResources::GetInstance();
212 DCHECK(instance); 212 DCHECK(instance);
213 213
214 Display* dpy = gfx::GLSurfaceGLX::GetDisplay(); 214 Display* dpy = static_cast<Display*>(instance->GetDisplay());
215 215
216 glBindTexture(GL_TEXTURE_2D, texture_id_); 216 glBindTexture(GL_TEXTURE_2D, texture_id_);
217 glXBindTexImageEXT(dpy, glx_pixmap_, GLX_FRONT_LEFT_EXT, NULL); 217 glXBindTexImageEXT(dpy, glx_pixmap_, GLX_FRONT_LEFT_EXT, NULL);
218 DrawInternal(*instance->program_no_swizzle(), 218 DrawInternal(*instance->program_no_swizzle(),
219 params, 219 params,
220 clip_bounds_in_texture); 220 clip_bounds_in_texture);
221 glXReleaseTexImageEXT(dpy, glx_pixmap_, GLX_FRONT_LEFT_EXT); 221 glXReleaseTexImageEXT(dpy, glx_pixmap_, GLX_FRONT_LEFT_EXT);
222 } 222 }
223 223
224 // static 224 // static
225 bool AcceleratedSurfaceContainerTouchGLX::InitializeOneOff() 225 bool AcceleratedSurfaceContainerTouchGLX::InitializeOneOff()
226 { 226 {
227 static bool initialized = false; 227 static bool initialized = false;
228 if (initialized) 228 if (initialized)
229 return true; 229 return true;
230 230
231 Display* dpy = gfx::GLSurfaceGLX::GetDisplay(); 231 ui::SharedResources* instance = ui::SharedResources::GetInstance();
232 DCHECK(instance);
233
234 Display* dpy = static_cast<Display*>(instance->GetDisplay());
232 int event_base, error_base; 235 int event_base, error_base;
233 if (XCompositeQueryExtension(dpy, &event_base, &error_base)) { 236 if (XCompositeQueryExtension(dpy, &event_base, &error_base)) {
234 int major = 0, minor = 2; 237 int major = 0, minor = 2;
235 XCompositeQueryVersion(dpy, &major, &minor); 238 XCompositeQueryVersion(dpy, &major, &minor);
236 if (major == 0 && minor < 2) { 239 if (major == 0 && minor < 2) {
237 LOG(ERROR) << "Pixmap from window not supported."; 240 LOG(ERROR) << "Pixmap from window not supported.";
238 return false; 241 return false;
239 } 242 }
240 } 243 }
241 244
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 return NULL; 387 return NULL;
385 } 388 }
386 } 389 }
387 390
388 void AcceleratedSurfaceContainerTouch::SetCanvas( 391 void AcceleratedSurfaceContainerTouch::SetCanvas(
389 const SkCanvas& canvas, 392 const SkCanvas& canvas,
390 const gfx::Point& origin, 393 const gfx::Point& origin,
391 const gfx::Size& overall_size) { 394 const gfx::Size& overall_size) {
392 NOTREACHED(); 395 NOTREACHED();
393 } 396 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/renderer_host/render_widget_host_view_views.h » ('j') | gpu/DEPS » ('J')

Powered by Google App Engine
This is Rietveld 408576698