0

[XProto] Remove gfx::GetXDisplay() and //ui/gfx/x/x11_types.{h,cc}

R=sky
BUG=1066670

Change-Id: I5c97675cd5c8e2257f326c6beb0d9b8efe0f05cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2477656
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821631}
This commit is contained in:
Tom Anderson
2020-10-28 07:14:14 +00:00
committed by Commit Bot
parent 850acd3e9d
commit e4fc22a977
79 changed files with 82 additions and 176 deletions
chrome
components/viz/service/display_embedder
content
gpu/vulkan/x
media
remoting/host/linux
services/device/wake_lock/power_save_blocker
ui

@ -13,7 +13,6 @@
#include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
using content::BrowserThread;

@ -6,7 +6,6 @@
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) {
DCHECK(id.type == content::DesktopMediaID::TYPE_WINDOW);

@ -186,8 +186,7 @@ bool ConvertCharToKeyCode(base::char16 key,
ui::KeyboardCode* key_code,
int* necessary_modifiers,
std::string* error_msg) {
XDisplay* display = gfx::GetXDisplay();
if (!display) {
if (!x11::Connection::Get()->Ready()) {
return ConvertCharToKeyCodeOzone(key, key_code, necessary_modifiers,
error_msg);
}

@ -11,7 +11,6 @@
#include "components/viz/service/display_embedder/skia_output_device_offscreen.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
namespace viz {

@ -16,7 +16,6 @@
#include "third_party/skia/include/core/SkImageInfo.h"
#include "ui/base/x/x11_shm_image_pool.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto_types.h"
namespace viz {

@ -12,7 +12,6 @@
#include "components/viz/service/viz_service_export.h"
#include "ui/base/x/x11_software_bitmap_presenter.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11_types.h"
namespace viz {

@ -226,7 +226,6 @@
#include "gpu/config/gpu_driver_bug_workaround_type.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/x/x11_util.h" // nogncheck
#include "ui/gfx/x/x11_types.h" // nogncheck
#endif
#if defined(USE_NSS_CERTS)
@ -581,7 +580,7 @@ int BrowserMainLoop::EarlyInitialization() {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform() && UsingInProcessGpu() &&
!gfx::GetXDisplay()) {
!x11::Connection::Get()->Ready()) {
LOG(ERROR) << "Failed to open an X11 connection.";
}
#endif
@ -1434,7 +1433,7 @@ bool BrowserMainLoop::InitializeToolkit() {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform() &&
!parsed_command_line_.HasSwitch(switches::kHeadless) &&
!gfx::GetXDisplay()) {
!x11::Connection::Get()->Ready()) {
LOG(ERROR) << "Unable to open X display.";
return false;
}

@ -82,7 +82,6 @@
#include "ui/base/x/x11_util.h" // nogncheck
#include "ui/gfx/linux/gpu_memory_buffer_support_x11.h" // nogncheck
#include "ui/gfx/x/x11_switches.h" // nogncheck
#include "ui/gfx/x/x11_types.h" // nogncheck
#endif
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
@ -285,7 +284,7 @@ int GpuMain(const MainFunctionParams& parameters) {
if (!features::IsUsingOzonePlatform()) {
// We need a UI loop so that we can grab the Expose events. See
// GLSurfaceGLX and https://crbug.com/326995.
if (!gfx::GetXDisplay())
if (!x11::Connection::Get()->Ready())
return RESULT_CODE_GPU_DEAD_ON_ARRIVAL;
main_thread_task_executor =
std::make_unique<base::SingleThreadTaskExecutor>(

@ -68,7 +68,6 @@
#include "ui/gtk/gtk_ui.h"
#include "ui/gtk/gtk_ui_delegate.h"
#if defined(USE_X11)
#include "ui/gfx/x/x11_types.h" // nogncheck
#include "ui/gtk/x/gtk_ui_delegate_x11.h" // nogncheck
#endif
#endif

@ -20,7 +20,6 @@
#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11_types.h"
namespace gpu {
@ -39,7 +38,7 @@ bool InitializeVulkanFunctionPointers(
VulkanImplementationX11::VulkanImplementationX11(bool use_swiftshader)
: VulkanImplementation(use_swiftshader) {
gfx::GetXDisplay();
x11::Connection::Get();
}
VulkanImplementationX11::~VulkanImplementationX11() = default;

@ -10,7 +10,6 @@
#include "base/component_export.h"
#include "gpu/vulkan/vulkan_implementation.h"
#include "gpu/vulkan/vulkan_instance.h"
#include "ui/gfx/x/x11_types.h"
namespace gpu {

@ -10,7 +10,6 @@
#include "base/macros.h"
#include "gpu/vulkan/vulkan_surface.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
namespace gpu {

@ -24,7 +24,6 @@
#include "ui/base/ui_base_features.h"
#include "ui/events/devices/x11/xinput_util.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xinput.h"
namespace media {

@ -8,7 +8,6 @@
#include "media/gpu/vaapi/vaapi_wrapper.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_image_glx.h"
#include "ui/gl/scoped_binders.h"

@ -59,13 +59,14 @@
#include "ui/gl/gl_implementation.h"
#if defined(USE_X11)
#include "ui/gfx/x/x11_types.h" // nogncheck
typedef XID Drawable;
extern "C" {
#include "media/gpu/vaapi/va_x11.sigs"
}
#include "ui/gfx/x/connection.h" // nogncheck
#endif
#if defined(USE_OZONE)
@ -504,7 +505,7 @@ bool VADisplayState::InitializeVaDisplay_Locked() {
case gl::kGLImplementationDesktopGL:
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform()) {
va_display_ = vaGetDisplay(gfx::GetXDisplay());
va_display_ = vaGetDisplay(x11::Connection::Get()->display());
if (!vaDisplayIsValid(va_display_))
va_display_ = vaGetDisplayDRM(drm_fd_.get());
}
@ -513,14 +514,14 @@ bool VADisplayState::InitializeVaDisplay_Locked() {
case gl::kGLImplementationEGLANGLE:
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
va_display_ = vaGetDisplay(gfx::GetXDisplay());
va_display_ = vaGetDisplay(x11::Connection::Get()->display());
#endif // USE_X11
break;
// Cannot infer platform from GL, try all available displays
case gl::kGLImplementationNone:
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform()) {
va_display_ = vaGetDisplay(gfx::GetXDisplay());
va_display_ = vaGetDisplay(x11::Connection::Get()->display());
if (vaDisplayIsValid(va_display_))
break;
}

@ -7,7 +7,6 @@
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "remoting/host/linux/unicode_to_keysym.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xkb.h"
#include "ui/gfx/x/xproto.h"
#include "ui/gfx/x/xtest.h"

@ -33,7 +33,6 @@
#include "ui/base/x/x11_util.h" // nogncheck
#include "ui/gfx/x/connection.h" // nogncheck
#include "ui/gfx/x/screensaver.h" // nogncheck
#include "ui/gfx/x/x11_types.h" // nogncheck
#endif
#if defined(USE_OZONE)

@ -6,7 +6,6 @@
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/screensaver.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {

@ -17,7 +17,6 @@
#include "base/timer/timer.h"
#include "ui/base/x/selection_utils.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {

@ -14,7 +14,6 @@
#include "ui/events/platform/platform_event_source.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
namespace ui {

@ -17,7 +17,6 @@
#include "base/timer/timer.h"
#include "ui/events/platform_event.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {
class XEventDispatcher;

@ -20,7 +20,6 @@
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
namespace ui {

@ -14,7 +14,6 @@
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/events/platform_event.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {

@ -12,7 +12,6 @@
#include "ui/events/test/x11_event_waiter.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/x/keysyms/keysyms.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
#include "ui/gfx/x/xproto_util.h"

@ -15,7 +15,6 @@
#include "ui/display/display_change_notifier.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
namespace views {
class DesktopScreenX11Test;

@ -8,7 +8,6 @@
#include "base/component_export.h"
#include "base/time/time.h"
#include "ui/display/display.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {

@ -9,7 +9,7 @@
#include "base/component_export.h"
#include "base/macros.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
// A process wide singleton cache for X menus.
namespace base {

@ -13,7 +13,6 @@
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {

@ -6,7 +6,6 @@
#define UI_BASE_X_X11_MOVE_LOOP_H_
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {

@ -6,7 +6,6 @@
#define UI_BASE_X_X11_POINTER_GRAB_H_
#include "base/component_export.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
namespace ui {

@ -24,7 +24,6 @@
#include "ui/base/x/x11_util.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
#include "ui/gfx/x/xproto_types.h"

@ -15,7 +15,6 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
class SkCanvas;

@ -31,8 +31,8 @@
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/platform_event.h"
#include "ui/gfx/icc_profile.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto_types.h"
typedef unsigned long Cursor;

@ -20,7 +20,7 @@
#include "ui/gfx/geometry/vector2d_f.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/connection.h"
namespace ui {
class MouseEvent;

@ -23,7 +23,6 @@
#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/sync.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xfixes.h"
#include "ui/gfx/x/xproto.h"

@ -12,7 +12,7 @@
#include "ui/compositor/compositor.h"
#include "ui/compositor/test/test_compositor_host.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
namespace ui {

@ -27,7 +27,6 @@
#include "ui/events/x/x11_event_translation.h" // nogncheck
#include "ui/gfx/x/event.h" // nogncheck
#include "ui/gfx/x/keysyms/keysyms.h" // nogncheck
#include "ui/gfx/x/x11_types.h" // nogncheck
#include "ui/gfx/x/xproto.h" // nogncheck
#endif

@ -20,7 +20,6 @@
#include "ui/events/platform_event.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xinput.h"
namespace ui {

@ -8,6 +8,7 @@
#include "base/memory/singleton.h"
#include "ui/events/devices/x11/device_data_manager_x11.h"
#include "ui/gfx/x/connection.h"
namespace ui {

@ -10,7 +10,6 @@
#include "base/macros.h"
#include "ui/events/devices/x11/events_devices_x11_export.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xinput.h"
namespace base {

@ -17,7 +17,6 @@
#include "ui/events/devices/x11/events_devices_x11_export.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/sequential_id_generator.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xinput.h"
namespace base {

@ -16,8 +16,8 @@
#include "base/optional.h"
#include "ui/events/events_export.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
namespace gfx {
class Point;

@ -30,9 +30,9 @@
#include "ui/events/devices/device_util_linux.h"
#include "ui/events/devices/input_device.h"
#include "ui/events/devices/touchscreen_device.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/extension_manager.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {

@ -13,7 +13,6 @@
#include "ui/events/types/event_type.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {

@ -10,7 +10,6 @@
#include "base/callback.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {

@ -17,7 +17,6 @@
#include "ui/events/x/events_x_export.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xinput.h"
namespace ui {

@ -11,7 +11,7 @@
#include "base/threading/thread_checker.h"
#include "ui/events/keyboard_hook_base.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/connection.h"
namespace ui {

@ -11,7 +11,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "ui/events/x/events_x_export.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/connection.h"
namespace base {
template <typename T>

@ -22,7 +22,6 @@
#include "ui/gfx/linux/gbm_wrapper.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/dri3.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {

@ -120,8 +120,6 @@ component("x") {
"x11_atom_cache.h",
"x11_path.cc",
"x11_path.h",
"x11_types.cc",
"x11_types.h",
]
defines = [ "GFX_IMPLEMENTATION" ]

@ -10,7 +10,7 @@
#include "base/macros.h"
#include "ui/gfx/gfx_export.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
namespace base {
template <typename T>

@ -1,21 +0,0 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/gfx/x/x11_types.h"
#include <string.h>
#include "base/command_line.h"
#include "base/logging.h"
#include "build/build_config.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11_switches.h"
namespace gfx {
XDisplay* GetXDisplay() {
return x11::Connection::Get()->display();
}
} // namespace gfx

@ -1,34 +0,0 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_GFX_X_X11_UTIL_H_
#define UI_GFX_X_X11_UTIL_H_
#include <stdint.h>
#include <memory>
#include "ui/gfx/gfx_export.h"
#include "ui/gfx/x/connection.h"
extern "C" {
int XFree(void*);
}
namespace gfx {
template <class T, class R, R (*F)(T*)>
struct XObjectDeleter {
inline void operator()(void* ptr) const { F(static_cast<T*>(ptr)); }
};
template <class T, class D = XObjectDeleter<void, int, XFree>>
using XScopedPtr = std::unique_ptr<T, D>;
// Get the XDisplay singleton. Prefer x11::Connection::Get() instead.
GFX_EXPORT XDisplay* GetXDisplay();
} // namespace gfx
#endif // UI_GFX_X_X11_UTIL_H_

@ -11,7 +11,7 @@
#include "ui/gl/gl_bindings.h"
#if defined(USE_GLX)
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/connection.h"
#endif
#if defined(USE_EGL)

@ -150,10 +150,6 @@ GLXContext CreateHighestVersionContext(x11::Connection* connection,
GLContextGLX::GLContextGLX(GLShareGroup* share_group)
: GLContextReal(share_group) {}
XDisplay* GLContextGLX::display() {
return connection_->display();
}
bool GLContextGLX::Initialize(GLSurface* compatible_surface,
const GLContextAttribs& attribs) {
// webgl_compatibility_context and disabling bind_generates_resource are not
@ -179,7 +175,8 @@ bool GLContextGLX::Initialize(GLSurface* compatible_surface,
} else {
DVLOG(1) << "GLX_ARB_create_context not supported.";
context_ = glXCreateNewContext(
display(), static_cast<GLXFBConfig>(compatible_surface->GetConfig()),
connection_->display(),
static_cast<GLXFBConfig>(compatible_surface->GetConfig()),
GLX_RGBA_TYPE, share_handle, true);
if (!context_) {
LOG(ERROR) << "Failed to create GL context with glXCreateNewContext.";
@ -193,7 +190,8 @@ bool GLContextGLX::Initialize(GLSurface* compatible_surface,
DVLOG(1) << (compatible_surface->IsOffscreen() ? "Offscreen" : "Onscreen")
<< " context was "
<< (glXIsDirect(display(), static_cast<GLXContext>(context_))
<< (glXIsDirect(connection_->display(),
static_cast<GLXContext>(context_))
? "direct"
: "indirect")
<< ".";
@ -203,7 +201,8 @@ bool GLContextGLX::Initialize(GLSurface* compatible_surface,
void GLContextGLX::Destroy() {
if (context_) {
glXDestroyContext(display(), static_cast<GLXContext>(context_));
glXDestroyContext(connection_->display(),
static_cast<GLXContext>(context_));
context_ = nullptr;
}
}
@ -216,7 +215,8 @@ bool GLContextGLX::MakeCurrentImpl(GLSurface* surface) {
ScopedReleaseCurrent release_current;
TRACE_EVENT0("gpu", "GLContextGLX::MakeCurrent");
if (!glXMakeContextCurrent(
display(), reinterpret_cast<GLXDrawable>(surface->GetHandle()),
connection_->display(),
reinterpret_cast<GLXDrawable>(surface->GetHandle()),
reinterpret_cast<GLXDrawable>(surface->GetHandle()),
static_cast<GLXContext>(context_))) {
LOG(ERROR) << "Couldn't make context current with X drawable.";
@ -243,7 +243,7 @@ void GLContextGLX::ReleaseCurrent(GLSurface* surface) {
return;
SetCurrent(nullptr);
if (!glXMakeContextCurrent(display(), 0, 0, 0))
if (!glXMakeContextCurrent(connection_->display(), 0, 0, 0))
LOG(ERROR) << "glXMakeCurrent failed in ReleaseCurrent";
}

@ -9,7 +9,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/connection.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_export.h"
@ -22,8 +22,6 @@ class GL_EXPORT GLContextGLX : public GLContextReal {
public:
explicit GLContextGLX(GLShareGroup* share_group);
XDisplay* display();
// Implement GLContext.
bool Initialize(GLSurface* compatible_surface,
const GLContextAttribs& attribs) override;

@ -7,7 +7,6 @@
#include "base/memory/scoped_refptr.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_surface_glx_x11.h"

@ -19,7 +19,7 @@ namespace gl {
inline EGLDisplay FromXDisplay() {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform()) {
if (auto* x_display = gfx::GetXDisplay()) {
if (auto* x_display = x11::Connection::Get()->display()) {
return eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(x_display));
}
}

@ -9,7 +9,7 @@
#include "base/macros.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/glx.h"
#include "ui/gl/gl_export.h"
#include "ui/gl/gl_image.h"

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <dlfcn.h>
#include <memory>
#include "base/logging.h"
@ -10,6 +12,7 @@
#include "ui/gl/gl_image_glx.h"
#include "ui/gl/gl_surface_glx.h"
#include "ui/gl/gl_visual_picker_glx.h"
#include "ui/gl/glx_util.h"
namespace gl {
namespace {
@ -35,7 +38,7 @@ GLImageGLX::GLImageGLX(const gfx::Size& size, gfx::BufferFormat format)
GLImageGLX::~GLImageGLX() {
if (glx_pixmap_)
glXDestroyGLXPixmap(gfx::GetXDisplay(), glx_pixmap_);
glXDestroyGLXPixmap(x11::Connection::Get()->display(), glx_pixmap_);
}
bool GLImageGLX::Initialize(x11::Pixmap pixmap) {
@ -43,16 +46,13 @@ bool GLImageGLX::Initialize(x11::Pixmap pixmap) {
GLVisualPickerGLX::GetInstance()->GetFbConfigForFormat(format_);
auto* connection = x11::Connection::Get();
int attrs[] = {GLX_FBCONFIG_ID, static_cast<uint32_t>(fbconfig_id), 0};
int nitems;
gfx::XScopedPtr<GLXFBConfig> configs(glXChooseFBConfig(
connection->display(), connection->DefaultScreenId(), attrs, &nitems));
if (!nitems)
GLXFBConfig config = GetGlxFbConfigForXProtoFbConfig(connection, fbconfig_id);
if (!config)
return false;
int pixmap_attribs[] = {GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
GLX_TEXTURE_FORMAT_EXT, TextureFormat(format_), 0};
glx_pixmap_ = glXCreatePixmap(gfx::GetXDisplay(), *configs,
glx_pixmap_ = glXCreatePixmap(x11::Connection::Get()->display(), config,
static_cast<::Pixmap>(pixmap), pixmap_attribs);
if (!glx_pixmap_) {
DVLOG(0) << "glXCreatePixmap failed.";
@ -86,8 +86,8 @@ bool GLImageGLX::BindTexImage(unsigned target) {
if (target != GL_TEXTURE_2D)
return false;
glXBindTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT,
nullptr);
glXBindTexImageEXT(x11::Connection::Get()->display(), glx_pixmap_,
GLX_FRONT_LEFT_EXT, nullptr);
return true;
}
@ -95,7 +95,8 @@ void GLImageGLX::ReleaseTexImage(unsigned target) {
DCHECK_NE(0u, glx_pixmap_);
DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target);
glXReleaseTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT);
glXReleaseTexImageEXT(x11::Connection::Get()->display(), glx_pixmap_,
GLX_FRONT_LEFT_EXT);
}
bool GLImageGLX::CopyTexImage(unsigned target) {

@ -10,7 +10,6 @@
#include "base/macros.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/x/glx.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_export.h"
#include "ui/gl/gl_image.h"

@ -7,6 +7,7 @@
#include "base/posix/eintr_wrapper.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/linux/native_pixmap_dmabuf.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/dri3.h"
#include "ui/gfx/x/xproto_types.h"
#include "ui/gl/buffer_format_utils.h"

@ -30,7 +30,6 @@
#include "ui/gfx/x/dri2.h"
#include "ui/gfx/x/glx.h"
#include "ui/gfx/x/present.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xf86vidmode.h"
#include "ui/gfx/x/xproto.h"
#include "ui/gfx/x/xproto_util.h"
@ -467,13 +466,13 @@ bool GLSurfaceGLX::InitializeOneOff() {
// http://crbug.com/245466
setenv("force_s3tc_enable", "true", 1);
if (!gfx::GetXDisplay()) {
LOG(ERROR) << "XOpenDisplay failed.";
if (!x11::Connection::Get()->Ready()) {
LOG(ERROR) << "Could not open X11 connection.";
return false;
}
int major = 0, minor = 0;
if (!glXQueryVersion(gfx::GetXDisplay(), &major, &minor)) {
if (!glXQueryVersion(x11::Connection::Get()->display(), &major, &minor)) {
LOG(ERROR) << "glxQueryVersion failed";
return false;
}
@ -631,7 +630,7 @@ bool GLSurfaceGLX::IsOMLSyncControlSupported() {
}
void* GLSurfaceGLX::GetDisplay() {
return gfx::GetXDisplay();
return x11::Connection::Get()->display();
}
GLSurfaceGLX::~GLSurfaceGLX() = default;
@ -695,8 +694,9 @@ bool NativeViewGLSurfaceGLX::Initialize(GLSurfaceFormat format) {
LOG(ERROR) << "Failed to get GLXConfig";
return false;
}
glx_window_ = static_cast<x11::Glx::Window>(glXCreateWindow(
gfx::GetXDisplay(), config_, static_cast<uint32_t>(window_), nullptr));
glx_window_ = static_cast<x11::Glx::Window>(
glXCreateWindow(x11::Connection::Get()->display(), config_,
static_cast<uint32_t>(window_), nullptr));
if (!GetDrawableHandle()) {
LOG(ERROR) << "glXCreateWindow failed";
return false;
@ -734,7 +734,7 @@ void NativeViewGLSurfaceGLX::Destroy() {
presentation_helper_ = nullptr;
vsync_provider_ = nullptr;
if (GetDrawableHandle()) {
glXDestroyWindow(gfx::GetXDisplay(), GetDrawableHandle());
glXDestroyWindow(x11::Connection::Get()->display(), GetDrawableHandle());
glx_window_ = {};
}
if (window_ != x11::Window::None) {
@ -818,8 +818,8 @@ gfx::SwapResult NativeViewGLSurfaceGLX::PostSubBuffer(
GLSurfacePresentationHelper::ScopedSwapBuffers scoped_swap_buffers(
presentation_helper_.get(), std::move(callback));
glXCopySubBufferMESA(gfx::GetXDisplay(), GetDrawableHandle(), x, y, width,
height);
glXCopySubBufferMESA(x11::Connection::Get()->display(), GetDrawableHandle(),
x, y, width, height);
return scoped_swap_buffers.result();
}
@ -836,7 +836,8 @@ void NativeViewGLSurfaceGLX::SetVSyncEnabled(bool enabled) {
DCHECK(GLContext::GetCurrent() && GLContext::GetCurrent()->IsCurrent(this));
int interval = enabled ? 1 : 0;
if (GLSurfaceGLX::IsEXTSwapControlSupported()) {
glXSwapIntervalEXT(gfx::GetXDisplay(), GetDrawableHandle(), interval);
glXSwapIntervalEXT(x11::Connection::Get()->display(), GetDrawableHandle(),
interval);
} else if (GLSurfaceGLX::IsMESASwapControlSupported()) {
glXSwapIntervalMESA(interval);
} else if (interval == 0) {
@ -898,8 +899,9 @@ bool UnmappedNativeViewGLSurfaceGLX::Initialize(GLSurfaceFormat format) {
LOG(ERROR) << "Failed to get GLXConfig";
return false;
}
glx_window_ = static_cast<x11::Glx::Window>(glXCreateWindow(
gfx::GetXDisplay(), config_, static_cast<uint32_t>(window_), nullptr));
glx_window_ = static_cast<x11::Glx::Window>(
glXCreateWindow(x11::Connection::Get()->display(), config_,
static_cast<uint32_t>(window_), nullptr));
if (glx_window_ == x11::Glx::Window{}) {
LOG(ERROR) << "glXCreateWindow failed";
return false;
@ -910,7 +912,8 @@ bool UnmappedNativeViewGLSurfaceGLX::Initialize(GLSurfaceFormat format) {
void UnmappedNativeViewGLSurfaceGLX::Destroy() {
config_ = nullptr;
if (glx_window_ != x11::Glx::Window{}) {
glXDestroyWindow(gfx::GetXDisplay(), static_cast<uint32_t>(glx_window_));
glXDestroyWindow(x11::Connection::Get()->display(),
static_cast<uint32_t>(glx_window_));
glx_window_ = {};
}
if (window_ != x11::Window::None) {

@ -16,7 +16,6 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/glx.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_export.h"
#include "ui/gl/gl_surface.h"

@ -4,7 +4,6 @@
#include "ui/gl/gl_surface_glx_x11.h"
#include "ui/gfx/x/x11_types.h"
using ui::X11EventSource;

@ -12,7 +12,6 @@
#include "base/memory/singleton.h"
#include "base/stl_util.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface_glx.h"

@ -9,7 +9,6 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "ui/gfx/x/glx.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h"
namespace gl {
@ -74,7 +73,12 @@ void XlibFree(void* data) {
GLXFBConfig GetFbConfigForWindow(x11::Connection* connection,
x11::Window window) {
auto xproto_config = GetConfigForWindow(connection, window);
return GetGlxFbConfigForXProtoFbConfig(
connection, GetConfigForWindow(connection, window));
}
GLXFBConfig GetGlxFbConfigForXProtoFbConfig(x11::Connection* connection,
x11::Glx::FbConfig xproto_config) {
if (xproto_config == x11::Glx::FbConfig{})
return nullptr;
int attrib_list[] = {GLX_FBCONFIG_ID, static_cast<int>(xproto_config), 0};

@ -5,7 +5,8 @@
#ifndef UI_GL_GLX_UTIL_H_
#define UI_GL_GLX_UTIL_H_
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/glx.h"
#include "ui/gl/gl_export.h"
using GLXFBConfig = struct __GLXFBConfigRec*;
@ -15,6 +16,10 @@ namespace gl {
GL_EXPORT GLXFBConfig GetFbConfigForWindow(x11::Connection* connection,
x11::Window window);
}
GL_EXPORT GLXFBConfig
GetGlxFbConfigForXProtoFbConfig(x11::Connection* connection,
x11::Glx::FbConfig xproto_config);
} // namespace gl
#endif // UI_GL_GLX_UTIL_H_

@ -10,7 +10,7 @@
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "ui/gfx/switches.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/connection.h"
#include "ui/gl/buildflags.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_egl_api_implementation.h"
@ -154,8 +154,9 @@ bool InitializeGLOneOffPlatformX11() {
case kGLImplementationEGLANGLE:
// Set utility class that helps to initialize egl platform.
gl::GLDisplayEglUtil::SetInstance(gl::GLDisplayEglUtilX11::GetInstance());
if (!GLSurfaceEGL::InitializeOneOff(EGLDisplayPlatform(
reinterpret_cast<EGLNativeDisplayType>(gfx::GetXDisplay())))) {
if (!GLSurfaceEGL::InitializeOneOff(
EGLDisplayPlatform(reinterpret_cast<EGLNativeDisplayType>(
x11::Connection::Get()->display())))) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false;
}

@ -7,7 +7,6 @@
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkPixmap.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
namespace ui {

@ -26,7 +26,6 @@
#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/ozone/common/stub_overlay_manager.h"
#include "ui/ozone/platform/x11/gl_egl_utility_x11.h"
#include "ui/ozone/platform/x11/x11_clipboard_ozone.h"

@ -14,7 +14,6 @@
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/extension_manager.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
#include "ui/gfx/x/xproto_util.h"

@ -12,7 +12,6 @@
#include "base/containers/flat_map.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xfixes.h"
#include "ui/gfx/x/xproto.h"
#include "ui/ozone/public/platform_clipboard.h"

@ -9,7 +9,6 @@
#include "gpu/vulkan/buildflags.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_surface_egl_x11_gles2.h"
#include "ui/ozone/common/egl_util.h"
@ -58,8 +57,8 @@ class GLOzoneEGLX11 : public GLOzoneEGL {
protected:
// GLOzoneEGL:
gl::EGLDisplayPlatform GetNativeDisplay() override {
return gl::EGLDisplayPlatform(
reinterpret_cast<EGLNativeDisplayType>(gfx::GetXDisplay()));
return gl::EGLDisplayPlatform(reinterpret_cast<EGLNativeDisplayType>(
x11::Connection::Get()->display()));
}
bool LoadGLES2Bindings(gl::GLImplementation implementation) override {

@ -7,6 +7,7 @@
#include "base/check.h"
#include "base/notreached.h"
#include "ui/events/x/events_x_utils.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/xproto.h"
#include "ui/gfx/x/xproto_types.h"

@ -24,7 +24,6 @@
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/keysyms/keysyms.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
#if defined(USE_OZONE)

@ -20,7 +20,6 @@
#if defined(USE_X11)
#include "ui/base/x/x11_util.h" // nogncheck
#include "ui/gfx/x/x11_types.h" // nogncheck
#endif
namespace views {

@ -24,7 +24,6 @@
#include "ui/events/test/event_generator.h"
#include "ui/gfx/font_render_params.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"

@ -31,7 +31,6 @@
#include "ui/base/x/x11_util.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"