Commit d7d6d28e authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

USE_X11 and USE_OZONE: //gpu: choose between ozone and x11 path

This patch resolves mostly to the following pattern:

#if defined(USE_X11)
DoThis();
#elif defined(USE_OZONE)
OzonePlatform::DoThat();
#endif

Two ifdefs are combined to a single ifdef now with
if (IsUsingOzonePlatform()) condition is added.

-----

PS: Please note that this is a temp solution that will help to choose
between ozone and non-ozone X11 build. The switch that will be used
to choose the path is --enable-features=UseOzonePlatform. Once
non-Ozone X11 path is removed (hopefully by Q1 2021 depending on how
th finch trial goes), the wrapper will be removed.

Please also note that it's impossible to build use_x11 && use_ozone
without some hacks in PlatformCursor code. The changes to that are
on their way to upstream.

----

Bug: 1085700
Change-Id: Ie8f8560ffb9ab7ab24b10412a5a612c3cc279373
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250250
Commit-Queue: Maksim Sisov (GMT+3) <msisov@igalia.com>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790369}
parent ce4162e0
...@@ -324,7 +324,10 @@ target(link_target_type, "gles2_sources") { ...@@ -324,7 +324,10 @@ target(link_target_type, "gles2_sources") {
] ]
if (use_ozone) { if (use_ozone) {
deps += [ "//ui/ozone" ] deps += [
"//ui/base:features",
"//ui/ozone",
]
} }
if (enable_vulkan) { if (enable_vulkan) {
......
...@@ -118,6 +118,10 @@ ...@@ -118,6 +118,10 @@
#include <OpenGL/CGLIOSurface.h> #include <OpenGL/CGLIOSurface.h>
#endif // OS_MACOSX #endif // OS_MACOSX
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h" // nogncheck
#endif
// Note: this undefs far and near so include this after other Windows headers. // Note: this undefs far and near so include this after other Windows headers.
#include "third_party/angle/src/image_util/loadimage.h" #include "third_party/angle/src/image_util/loadimage.h"
...@@ -3216,14 +3220,14 @@ bool BackTexture::AllocateNativeGpuMemoryBuffer(const gfx::Size& size, ...@@ -3216,14 +3220,14 @@ bool BackTexture::AllocateNativeGpuMemoryBuffer(const gfx::Size& size,
bool is_cleared = false; bool is_cleared = false;
gfx::BufferFormat buffer_format = gfx::BufferFormat::RGBA_8888; gfx::BufferFormat buffer_format = gfx::BufferFormat::RGBA_8888;
if (format == GL_RGB) { if (format == GL_RGB) {
buffer_format = gfx::BufferFormat::RGBX_8888;
#if defined(USE_OZONE) #if defined(USE_OZONE)
// BGRX format is preferred for Ozone as it matches the format used by the // BGRX format is preferred for Ozone as it matches the format used by the
// buffer queue and is as a result guaranteed to work on all devices. // buffer queue and is as a result guaranteed to work on all devices.
// TODO(reveman): Define this format in one place instead of having to // TODO(reveman): Define this format in one place instead of having to
// duplicate BGRX_8888. // duplicate BGRX_8888.
buffer_format = gfx::BufferFormat::BGRX_8888; if (features::IsUsingOzonePlatform())
#else buffer_format = gfx::BufferFormat::BGRX_8888;
buffer_format = gfx::BufferFormat::RGBX_8888;
#endif #endif
} }
scoped_refptr<gl::GLImage> image = scoped_refptr<gl::GLImage> image =
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/notreached.h" #include "base/notreached.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "gpu/ipc/common/gpu_memory_buffer_impl_shared_memory.h" #include "gpu/ipc/common/gpu_memory_buffer_impl_shared_memory.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/buffer_format_util.h" #include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/buffer_usage_util.h" #include "ui/gfx/buffer_usage_util.h"
...@@ -46,8 +47,12 @@ namespace gpu { ...@@ -46,8 +47,12 @@ namespace gpu {
GpuMemoryBufferSupport::GpuMemoryBufferSupport() { GpuMemoryBufferSupport::GpuMemoryBufferSupport() {
#if defined(USE_OZONE) #if defined(USE_OZONE)
client_native_pixmap_factory_ = ui::CreateClientNativePixmapFactoryOzone(); if (features::IsUsingOzonePlatform()) {
#elif defined(OS_LINUX) client_native_pixmap_factory_ = ui::CreateClientNativePixmapFactoryOzone();
return;
}
#endif
#if defined(OS_LINUX)
client_native_pixmap_factory_.reset( client_native_pixmap_factory_.reset(
gfx::CreateClientNativePixmapFactoryDmabuf()); gfx::CreateClientNativePixmapFactoryDmabuf());
#endif #endif
...@@ -116,10 +121,13 @@ bool GpuMemoryBufferSupport::IsNativeGpuMemoryBufferConfigurationSupported( ...@@ -116,10 +121,13 @@ bool GpuMemoryBufferSupport::IsNativeGpuMemoryBufferConfigurationSupported(
} }
NOTREACHED(); NOTREACHED();
return false; return false;
#elif defined(USE_OZONE) #elif defined(USE_OZONE) || defined(USE_X11)
return ui::OzonePlatform::GetInstance()->IsNativePixmapConfigSupported(format, #if defined(USE_OZONE)
usage); if (features::IsUsingOzonePlatform()) {
#elif defined(USE_X11) return ui::OzonePlatform::GetInstance()->IsNativePixmapConfigSupported(
format, usage);
}
#endif
// On X11, GPU memory buffer support can only be determined after GPU // On X11, GPU memory buffer support can only be determined after GPU
// initialization. // initialization.
// viz::HostGpuMemoryBufferManager::IsNativeGpuMemoryBufferConfiguration() // viz::HostGpuMemoryBufferManager::IsNativeGpuMemoryBufferConfiguration()
......
...@@ -165,6 +165,7 @@ if (enable_vulkan) { ...@@ -165,6 +165,7 @@ if (enable_vulkan) {
sources = [ "tests/native_window.h" ] sources = [ "tests/native_window.h" ]
deps = [ deps = [
"//ui/base:features",
"//ui/gfx", "//ui/gfx",
"//ui/gfx:native_widget_types", "//ui/gfx:native_widget_types",
] ]
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "gpu/vulkan/tests/native_window.h" #include "gpu/vulkan/tests/native_window.h"
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "ui/base/ui_base_features.h"
#include "ui/platform_window/platform_window_delegate.h" #include "ui/platform_window/platform_window_delegate.h"
#include "ui/platform_window/platform_window_init_properties.h" #include "ui/platform_window/platform_window_init_properties.h"
...@@ -26,15 +27,23 @@ class Window : public ui::PlatformWindowDelegate { ...@@ -26,15 +27,23 @@ class Window : public ui::PlatformWindowDelegate {
void Initialize(const gfx::Rect& bounds) { void Initialize(const gfx::Rect& bounds) {
DCHECK(!platform_window_); DCHECK(!platform_window_);
#if defined(USE_OZONE)
ui::PlatformWindowInitProperties props(bounds); #if defined(USE_OZONE) || defined(USE_X11)
platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow(
this, std::move(props));
#elif defined(USE_X11)
ui::PlatformWindowInitProperties props(bounds); ui::PlatformWindowInitProperties props(bounds);
auto x11_window = std::make_unique<ui::X11Window>(this); #if defined(USE_OZONE)
x11_window->Initialize(std::move(props)); if (features::IsUsingOzonePlatform()) {
platform_window_ = std::move(x11_window); platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow(
this, std::move(props));
}
#endif
#if defined(USE_X11)
if (!platform_window_) {
DCHECK(!features::IsUsingOzonePlatform());
auto x11_window = std::make_unique<ui::X11Window>(this);
x11_window->Initialize(std::move(props));
platform_window_ = std::move(x11_window);
}
#endif
#else #else
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment