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

Side by Side Diff: ui/gl/gl_surface_x11.cc

Issue 1168993002: Update the native_viewport interface to allow specification of the surface configuration, currently… (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Final cleanups Created 5 years, 6 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
« no previous file with comments | « ui/gl/gl_surface_stub.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/gl/gl_surface.h" 5 #include "ui/gl/gl_surface.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "ui/gfx/native_widget_types.h" 11 #include "ui/gfx/native_widget_types.h"
12 #include "ui/gfx/x/x11_types.h" 12 #include "ui/gfx/x/x11_types.h"
13 #include "ui/gl/gl_bindings.h" 13 #include "ui/gl/gl_bindings.h"
14 #include "ui/gl/gl_implementation.h" 14 #include "ui/gl/gl_implementation.h"
15 #include "ui/gl/gl_surface_egl.h" 15 #include "ui/gl/gl_surface_egl.h"
16 #include "ui/gl/gl_surface_glx.h" 16 #include "ui/gl/gl_surface_glx.h"
17 #include "ui/gl/gl_surface_osmesa.h" 17 #include "ui/gl/gl_surface_osmesa.h"
18 #include "ui/gl/gl_surface_stub.h" 18 #include "ui/gl/gl_surface_stub.h"
19 19
20 namespace gfx { 20 namespace gfx {
21 21
22 // This OSMesa GL surface can use XLib to swap the contents of the buffer to a 22 // This OSMesa GL surface can use XLib to swap the contents of the buffer to a
23 // view. 23 // view.
24 class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa { 24 class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa {
25 public: 25 public:
26 explicit NativeViewGLSurfaceOSMesa(gfx::AcceleratedWidget window); 26 NativeViewGLSurfaceOSMesa(
27 gfx::AcceleratedWidget window,
28 const gfx::SurfaceConfiguration& requested_configuration);
27 29
28 static bool InitializeOneOff(); 30 static bool InitializeOneOff();
29 31
30 // Implement a subset of GLSurface. 32 // Implement a subset of GLSurface.
31 bool Initialize() override; 33 bool Initialize() override;
32 void Destroy() override; 34 void Destroy() override;
33 bool Resize(const gfx::Size& new_size) override; 35 bool Resize(const gfx::Size& new_size) override;
34 bool IsOffscreen() override; 36 bool IsOffscreen() override;
35 bool SwapBuffers() override; 37 bool SwapBuffers() override;
36 bool SupportsPostSubBuffer() override; 38 bool SupportsPostSubBuffer() override;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 72 }
71 break; 73 break;
72 default: 74 default:
73 break; 75 break;
74 } 76 }
75 77
76 return true; 78 return true;
77 } 79 }
78 80
79 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( 81 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa(
80 gfx::AcceleratedWidget window) 82 gfx::AcceleratedWidget window,
81 : GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, gfx::Size(1, 1)), 83 const gfx::SurfaceConfiguration& requested_configuration)
84 : GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA,
85 gfx::Size(1, 1),
86 requested_configuration),
82 xdisplay_(gfx::GetXDisplay()), 87 xdisplay_(gfx::GetXDisplay()),
83 window_graphics_context_(0), 88 window_graphics_context_(0),
84 window_(window), 89 window_(window),
85 pixmap_graphics_context_(0), 90 pixmap_graphics_context_(0),
86 pixmap_(0) { 91 pixmap_(0) {
87 DCHECK(xdisplay_); 92 DCHECK(xdisplay_);
88 DCHECK(window_); 93 DCHECK(window_);
89 } 94 }
90 95
91 // static 96 // static
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 y); 270 y);
266 271
267 return true; 272 return true;
268 } 273 }
269 274
270 NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() { 275 NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() {
271 Destroy(); 276 Destroy();
272 } 277 }
273 278
274 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( 279 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
275 gfx::AcceleratedWidget window) { 280 gfx::AcceleratedWidget window,
281 const gfx::SurfaceConfiguration& requested_configuration) {
276 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface"); 282 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface");
277 switch (GetGLImplementation()) { 283 switch (GetGLImplementation()) {
278 case kGLImplementationOSMesaGL: { 284 case kGLImplementationOSMesaGL: {
279 scoped_refptr<GLSurface> surface( 285 scoped_refptr<GLSurface> surface(
280 new NativeViewGLSurfaceOSMesa(window)); 286 new NativeViewGLSurfaceOSMesa(window, requested_configuration));
281 if (!surface->Initialize()) 287 if (!surface->Initialize())
282 return NULL; 288 return NULL;
283 289
284 return surface; 290 return surface;
285 } 291 }
286 case kGLImplementationDesktopGL: { 292 case kGLImplementationDesktopGL: {
287 scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceGLX(window)); 293 scoped_refptr<GLSurface> surface(
294 new NativeViewGLSurfaceGLX(window, requested_configuration));
288 if (!surface->Initialize()) 295 if (!surface->Initialize())
289 return NULL; 296 return NULL;
290 297
291 return surface; 298 return surface;
292 } 299 }
293 case kGLImplementationEGLGLES2: { 300 case kGLImplementationEGLGLES2: {
294 DCHECK(window != gfx::kNullAcceleratedWidget); 301 DCHECK(window != gfx::kNullAcceleratedWidget);
295 scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL(window)); 302 scoped_refptr<GLSurface> surface(
303 new NativeViewGLSurfaceEGL(window, requested_configuration));
296 if (!surface->Initialize()) 304 if (!surface->Initialize())
297 return NULL; 305 return NULL;
298 306
299 return surface; 307 return surface;
300 } 308 }
301 case kGLImplementationMockGL: 309 case kGLImplementationMockGL:
302 return new GLSurfaceStub; 310 return new GLSurfaceStub(requested_configuration);
303 default: 311 default:
304 NOTREACHED(); 312 NOTREACHED();
305 return NULL; 313 return NULL;
306 } 314 }
307 } 315 }
308 316
309 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( 317 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
310 const gfx::Size& size) { 318 const gfx::Size& size,
319 const gfx::SurfaceConfiguration& requested_configuration) {
311 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface"); 320 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface");
312 switch (GetGLImplementation()) { 321 switch (GetGLImplementation()) {
313 case kGLImplementationOSMesaGL: { 322 case kGLImplementationOSMesaGL: {
314 scoped_refptr<GLSurface> surface( 323 scoped_refptr<GLSurface> surface(
315 new GLSurfaceOSMesa(OSMesaSurfaceFormatRGBA, size)); 324 new GLSurfaceOSMesa(OSMesaSurfaceFormatRGBA,
325 size,
326 requested_configuration));
316 if (!surface->Initialize()) 327 if (!surface->Initialize())
317 return NULL; 328 return NULL;
318 329
319 return surface; 330 return surface;
320 } 331 }
321 case kGLImplementationDesktopGL: { 332 case kGLImplementationDesktopGL: {
322 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceGLX(size)); 333 scoped_refptr<GLSurface> surface(
334 new PbufferGLSurfaceGLX(size, requested_configuration));
323 if (!surface->Initialize()) 335 if (!surface->Initialize())
324 return NULL; 336 return NULL;
325 337
326 return surface; 338 return surface;
327 } 339 }
328 case kGLImplementationEGLGLES2: { 340 case kGLImplementationEGLGLES2: {
329 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(size)); 341 scoped_refptr<GLSurface> surface(
342 new PbufferGLSurfaceEGL(size, requested_configuration));
330 if (!surface->Initialize()) 343 if (!surface->Initialize())
331 return NULL; 344 return NULL;
332 345
333 return surface; 346 return surface;
334 } 347 }
335 case kGLImplementationMockGL: 348 case kGLImplementationMockGL:
336 return new GLSurfaceStub; 349 return new GLSurfaceStub(requested_configuration);
337 default: 350 default:
338 NOTREACHED(); 351 NOTREACHED();
339 return NULL; 352 return NULL;
340 } 353 }
341 } 354 }
342 355
343 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { 356 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() {
344 return gfx::GetXDisplay(); 357 return gfx::GetXDisplay();
345 } 358 }
346 359
347 } // namespace gfx 360 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_stub.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698