| 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 #include "ui/gl/gl_surface_glx.h" | 5 #include "ui/gl/gl_surface_glx.h" |
| 6 | 6 |
| 7 extern "C" { | 7 extern "C" { |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 } | 9 } |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 : parent_window_(window), | 506 : parent_window_(window), |
| 507 window_(0), | 507 window_(0), |
| 508 glx_window_(0), | 508 glx_window_(0), |
| 509 config_(nullptr), | 509 config_(nullptr), |
| 510 visual_id_(CopyFromParent) {} | 510 visual_id_(CopyFromParent) {} |
| 511 | 511 |
| 512 GLXDrawable NativeViewGLSurfaceGLX::GetDrawableHandle() const { | 512 GLXDrawable NativeViewGLSurfaceGLX::GetDrawableHandle() const { |
| 513 return glx_window_; | 513 return glx_window_; |
| 514 } | 514 } |
| 515 | 515 |
| 516 bool NativeViewGLSurfaceGLX::Initialize(GLSurface::Format format) { | 516 bool NativeViewGLSurfaceGLX::Initialize(GLSurfaceFormat format) { |
| 517 XWindowAttributes attributes; | 517 XWindowAttributes attributes; |
| 518 if (!XGetWindowAttributes(g_display, parent_window_, &attributes)) { | 518 if (!XGetWindowAttributes(g_display, parent_window_, &attributes)) { |
| 519 LOG(ERROR) << "XGetWindowAttributes failed for window " << parent_window_ | 519 LOG(ERROR) << "XGetWindowAttributes failed for window " << parent_window_ |
| 520 << "."; | 520 << "."; |
| 521 return false; | 521 return false; |
| 522 } | 522 } |
| 523 size_ = gfx::Size(attributes.width, attributes.height); | 523 size_ = gfx::Size(attributes.width, attributes.height); |
| 524 visual_id_ = XVisualIDFromVisual(attributes.visual); | 524 visual_id_ = XVisualIDFromVisual(attributes.visual); |
| 525 // Create a child window, with a CopyFromParent visual (to avoid inducing | 525 // Create a child window, with a CopyFromParent visual (to avoid inducing |
| 526 // extra blits in the driver), that we can resize exactly in Resize(), | 526 // extra blits in the driver), that we can resize exactly in Resize(), |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 } | 650 } |
| 651 | 651 |
| 652 UnmappedNativeViewGLSurfaceGLX::UnmappedNativeViewGLSurfaceGLX( | 652 UnmappedNativeViewGLSurfaceGLX::UnmappedNativeViewGLSurfaceGLX( |
| 653 const gfx::Size& size) | 653 const gfx::Size& size) |
| 654 : size_(size), config_(nullptr), window_(0), glx_window_(0) { | 654 : size_(size), config_(nullptr), window_(0), glx_window_(0) { |
| 655 // Ensure that we don't create a window with zero size. | 655 // Ensure that we don't create a window with zero size. |
| 656 if (size_.GetArea() == 0) | 656 if (size_.GetArea() == 0) |
| 657 size_.SetSize(1, 1); | 657 size_.SetSize(1, 1); |
| 658 } | 658 } |
| 659 | 659 |
| 660 bool UnmappedNativeViewGLSurfaceGLX::Initialize(GLSurface::Format format) { | 660 bool UnmappedNativeViewGLSurfaceGLX::Initialize(GLSurfaceFormat format) { |
| 661 DCHECK(!window_); | 661 DCHECK(!window_); |
| 662 | 662 |
| 663 gfx::AcceleratedWidget parent_window = DefaultRootWindow(g_display); | 663 gfx::AcceleratedWidget parent_window = DefaultRootWindow(g_display); |
| 664 | 664 |
| 665 XSetWindowAttributes attrs; | 665 XSetWindowAttributes attrs; |
| 666 attrs.border_pixel = 0; | 666 attrs.border_pixel = 0; |
| 667 attrs.colormap = g_colormap; | 667 attrs.colormap = g_colormap; |
| 668 window_ = XCreateWindow(g_display, parent_window, 0, 0, size_.width(), | 668 window_ = XCreateWindow(g_display, parent_window, 0, 0, size_.width(), |
| 669 size_.height(), 0, g_depth, InputOutput, g_visual, | 669 size_.height(), 0, g_depth, InputOutput, g_visual, |
| 670 CWBorderPixel | CWColormap, &attrs); | 670 CWBorderPixel | CWColormap, &attrs); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 | 711 |
| 712 unsigned long UnmappedNativeViewGLSurfaceGLX::GetCompatibilityKey() { | 712 unsigned long UnmappedNativeViewGLSurfaceGLX::GetCompatibilityKey() { |
| 713 return XVisualIDFromVisual(g_visual); | 713 return XVisualIDFromVisual(g_visual); |
| 714 } | 714 } |
| 715 | 715 |
| 716 UnmappedNativeViewGLSurfaceGLX::~UnmappedNativeViewGLSurfaceGLX() { | 716 UnmappedNativeViewGLSurfaceGLX::~UnmappedNativeViewGLSurfaceGLX() { |
| 717 Destroy(); | 717 Destroy(); |
| 718 } | 718 } |
| 719 | 719 |
| 720 } // namespace gl | 720 } // namespace gl |
| OLD | NEW |