OLD | NEW |
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 extern "C" { | 5 extern "C" { |
6 #include <X11/Xlib.h> | 6 #include <X11/Xlib.h> |
7 } | 7 } |
8 | 8 |
9 #include "ui/gl/gl_surface_glx.h" | 9 #include "ui/gl/gl_surface_glx.h" |
10 | 10 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 310 |
311 SGIVideoSyncThread* SGIVideoSyncThread::g_video_sync_thread = NULL; | 311 SGIVideoSyncThread* SGIVideoSyncThread::g_video_sync_thread = NULL; |
312 | 312 |
313 // In order to take advantage of GLX_SGI_video_sync, we need a display | 313 // In order to take advantage of GLX_SGI_video_sync, we need a display |
314 // for use on a separate thread. We must allocate this before the sandbox | 314 // for use on a separate thread. We must allocate this before the sandbox |
315 // goes up (rather than on-demand when we start the thread). | 315 // goes up (rather than on-demand when we start the thread). |
316 Display* SGIVideoSyncProviderThreadShim::display_ = NULL; | 316 Display* SGIVideoSyncProviderThreadShim::display_ = NULL; |
317 | 317 |
318 } // namespace | 318 } // namespace |
319 | 319 |
320 GLSurfaceGLX::GLSurfaceGLX() {} | 320 GLSurfaceGLX::GLSurfaceGLX( |
| 321 const gfx::SurfaceConfiguration& requested_configuration) |
| 322 : GLSurface(requested_configuration) { |
| 323 } |
321 | 324 |
322 bool GLSurfaceGLX::InitializeOneOff() { | 325 bool GLSurfaceGLX::InitializeOneOff() { |
323 static bool initialized = false; | 326 static bool initialized = false; |
324 if (initialized) | 327 if (initialized) |
325 return true; | 328 return true; |
326 | 329 |
327 // http://crbug.com/245466 | 330 // http://crbug.com/245466 |
328 setenv("force_s3tc_enable", "true", 1); | 331 setenv("force_s3tc_enable", "true", 1); |
329 | 332 |
330 // SGIVideoSyncProviderShim (if instantiated) will issue X commands on | 333 // SGIVideoSyncProviderShim (if instantiated) will issue X commands on |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 bool GLSurfaceGLX::IsOMLSyncControlSupported() { | 400 bool GLSurfaceGLX::IsOMLSyncControlSupported() { |
398 return g_glx_oml_sync_control_supported; | 401 return g_glx_oml_sync_control_supported; |
399 } | 402 } |
400 | 403 |
401 void* GLSurfaceGLX::GetDisplay() { | 404 void* GLSurfaceGLX::GetDisplay() { |
402 return g_display; | 405 return g_display; |
403 } | 406 } |
404 | 407 |
405 GLSurfaceGLX::~GLSurfaceGLX() {} | 408 GLSurfaceGLX::~GLSurfaceGLX() {} |
406 | 409 |
407 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window) | 410 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX( |
408 : parent_window_(window), | 411 gfx::AcceleratedWidget window, |
| 412 const gfx::SurfaceConfiguration& requested_configuration) |
| 413 : GLSurfaceGLX(requested_configuration), |
| 414 parent_window_(window), |
409 window_(0), | 415 window_(0), |
410 config_(NULL) { | 416 config_(NULL) { |
411 } | 417 } |
412 | 418 |
413 gfx::AcceleratedWidget NativeViewGLSurfaceGLX::GetDrawableHandle() const { | 419 gfx::AcceleratedWidget NativeViewGLSurfaceGLX::GetDrawableHandle() const { |
414 return window_; | 420 return window_; |
415 } | 421 } |
416 | 422 |
417 bool NativeViewGLSurfaceGLX::Initialize() { | 423 bool NativeViewGLSurfaceGLX::Initialize() { |
418 XWindowAttributes attributes; | 424 XWindowAttributes attributes; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 // attempting to use GLX_ARB_create_context_robustness, in which | 528 // attempting to use GLX_ARB_create_context_robustness, in which |
523 // case we need a GLXFBConfig for the window in order to create a | 529 // case we need a GLXFBConfig for the window in order to create a |
524 // context for it. | 530 // context for it. |
525 // | 531 // |
526 // TODO(kbr): this is not a reliable code path. On platforms which | 532 // TODO(kbr): this is not a reliable code path. On platforms which |
527 // support it, we should use glXChooseFBConfig in the browser | 533 // support it, we should use glXChooseFBConfig in the browser |
528 // process to choose the FBConfig and from there the X Visual to | 534 // process to choose the FBConfig and from there the X Visual to |
529 // use when creating the window in the first place. Then we can | 535 // use when creating the window in the first place. Then we can |
530 // pass that FBConfig down rather than attempting to reconstitute | 536 // pass that FBConfig down rather than attempting to reconstitute |
531 // it. | 537 // it. |
| 538 // |
| 539 // TODO(iansf): Perhaps instead of kbr's suggestion above, we can |
| 540 // now use GLSurface::GetSurfaceConfiguration to use the returned |
| 541 // gfx::SurfaceConfiguration with glXChooseFBConfig in a manner |
| 542 // similar to that used in NativeViewGLSurfaceEGL::GetConfig. |
532 | 543 |
533 XWindowAttributes attributes; | 544 XWindowAttributes attributes; |
534 if (!XGetWindowAttributes( | 545 if (!XGetWindowAttributes( |
535 g_display, | 546 g_display, |
536 window_, | 547 window_, |
537 &attributes)) { | 548 &attributes)) { |
538 LOG(ERROR) << "XGetWindowAttributes failed for window " << | 549 LOG(ERROR) << "XGetWindowAttributes failed for window " << |
539 window_ << "."; | 550 window_ << "."; |
540 return NULL; | 551 return NULL; |
541 } | 552 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 } | 594 } |
584 | 595 |
585 VSyncProvider* NativeViewGLSurfaceGLX::GetVSyncProvider() { | 596 VSyncProvider* NativeViewGLSurfaceGLX::GetVSyncProvider() { |
586 return vsync_provider_.get(); | 597 return vsync_provider_.get(); |
587 } | 598 } |
588 | 599 |
589 NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() { | 600 NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() { |
590 Destroy(); | 601 Destroy(); |
591 } | 602 } |
592 | 603 |
593 PbufferGLSurfaceGLX::PbufferGLSurfaceGLX(const gfx::Size& size) | 604 PbufferGLSurfaceGLX::PbufferGLSurfaceGLX( |
594 : size_(size), | 605 const gfx::Size& size, |
| 606 const gfx::SurfaceConfiguration& requested_configuration) |
| 607 : GLSurfaceGLX(requested_configuration), |
| 608 size_(size), |
595 config_(NULL), | 609 config_(NULL), |
596 pbuffer_(0) { | 610 pbuffer_(0) { |
597 // Some implementations of Pbuffer do not support having a 0 size. For such | 611 // Some implementations of Pbuffer do not support having a 0 size. For such |
598 // cases use a (1, 1) surface. | 612 // cases use a (1, 1) surface. |
599 if (size_.GetArea() == 0) | 613 if (size_.GetArea() == 0) |
600 size_.SetSize(1, 1); | 614 size_.SetSize(1, 1); |
601 } | 615 } |
602 | 616 |
603 bool PbufferGLSurfaceGLX::Initialize() { | 617 bool PbufferGLSurfaceGLX::Initialize() { |
604 DCHECK(!pbuffer_); | 618 DCHECK(!pbuffer_); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 | 688 |
675 void* PbufferGLSurfaceGLX::GetConfig() { | 689 void* PbufferGLSurfaceGLX::GetConfig() { |
676 return config_; | 690 return config_; |
677 } | 691 } |
678 | 692 |
679 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { | 693 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { |
680 Destroy(); | 694 Destroy(); |
681 } | 695 } |
682 | 696 |
683 } // namespace gfx | 697 } // namespace gfx |
OLD | NEW |