Commit 09a4d450 authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

exo: Fix simple client gbm build.

The refactoring introduced in crrev.com/c/653037 introduced a new
main file for simple client that included client_base.h.

The memory layout of ClientBase depends on the define OZONE_PLATFORM_GBM.
On ozone gbm platform, when building wayland_simple_client, the define
would be present while building simple.cc but no when building simple_main.cc.

This meant that the allocated layout for Simple would be different than
the memory layout expected by the ctor, and it caused surprising bugs.

This CL renames the define OZONE_PLATFORM_GBM to USE_GBM and moves it to
a public_configs of client_support. In this way any target depending on
client_support will build with that define.

Additionally, this CL adds explicit minigbm dependencies where needed.

Bug: 
Test: wayland_simple_client stopped behaving in unexpected ways.
Change-Id: I17327b47b4ac3cac889d0452467c453ecc1ec165
Reviewed-on: https://chromium-review.googlesource.com/690804
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Commit-Queue: David Reveman <reveman@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505264}
parent 461626b0
...@@ -112,7 +112,13 @@ source_set("unit_tests") { ...@@ -112,7 +112,13 @@ source_set("unit_tests") {
] ]
} }
source_set("client_lib") { config("client_support_config") {
if (ozone_platform_gbm) {
defines = [ "USE_GBM" ]
}
}
source_set("client_support") {
sources = [ sources = [
"clients/client_base.cc", "clients/client_base.cc",
"clients/client_base.h", "clients/client_base.h",
...@@ -139,12 +145,11 @@ source_set("client_lib") { ...@@ -139,12 +145,11 @@ source_set("client_lib") {
":libdrm", ":libdrm",
"//ui/gl:gl_config", "//ui/gl:gl_config",
] ]
defines = [ "OZONE_PLATFORM_GBM" ] deps += [ "//ui/ozone" ]
deps += [ public_deps += [ "//third_party/minigbm" ]
"//third_party/minigbm",
"//ui/ozone",
]
} }
public_configs = [ ":client_support_config" ]
} }
executable("wayland_rects_client") { executable("wayland_rects_client") {
...@@ -153,7 +158,7 @@ executable("wayland_rects_client") { ...@@ -153,7 +158,7 @@ executable("wayland_rects_client") {
] ]
deps = [ deps = [
":client_lib", ":client_support",
"//base", "//base",
"//build/config:exe_and_shlib_deps", "//build/config:exe_and_shlib_deps",
"//skia", "//skia",
...@@ -169,7 +174,7 @@ executable("wayland_rects_client") { ...@@ -169,7 +174,7 @@ executable("wayland_rects_client") {
":libdrm", ":libdrm",
"//ui/gl:gl_config", "//ui/gl:gl_config",
] ]
defines = [ "OZONE_PLATFORM_GBM" ] defines = [ "USE_GBM" ]
deps += [ "//third_party/minigbm" ] deps += [ "//third_party/minigbm" ]
} }
} }
...@@ -181,7 +186,7 @@ source_set("simple") { ...@@ -181,7 +186,7 @@ source_set("simple") {
] ]
deps = [ deps = [
":client_lib", ":client_support",
"//base", "//base",
"//skia", "//skia",
"//third_party/wayland:wayland_client", "//third_party/wayland:wayland_client",
...@@ -196,8 +201,6 @@ source_set("simple") { ...@@ -196,8 +201,6 @@ source_set("simple") {
":libdrm", ":libdrm",
"//ui/gl:gl_config", "//ui/gl:gl_config",
] ]
defines = [ "OZONE_PLATFORM_GBM" ]
deps += [ "//third_party/minigbm" ]
} }
} }
...@@ -206,7 +209,7 @@ executable("wayland_simple_client") { ...@@ -206,7 +209,7 @@ executable("wayland_simple_client") {
"clients/simple_main.cc", "clients/simple_main.cc",
] ]
deps = [ deps = [
":client_lib", ":client_support",
":simple", ":simple",
"//base", "//base",
"//build/config:exe_and_shlib_deps", "//build/config:exe_and_shlib_deps",
...@@ -219,7 +222,7 @@ executable("wayland_subsurface_client") { ...@@ -219,7 +222,7 @@ executable("wayland_subsurface_client") {
] ]
deps = [ deps = [
":client_lib", ":client_support",
"//base", "//base",
"//build/config:exe_and_shlib_deps", "//build/config:exe_and_shlib_deps",
"//skia", "//skia",
...@@ -251,7 +254,7 @@ test("wayland_client_perftests") { ...@@ -251,7 +254,7 @@ test("wayland_client_perftests") {
] ]
deps = [ deps = [
":client_lib", ":client_support",
":simple", ":simple",
":wayland", ":wayland",
"//ash:test_support_without_content", "//ash:test_support_without_content",
...@@ -276,18 +279,6 @@ test("wayland_client_perftests") { ...@@ -276,18 +279,6 @@ test("wayland_client_perftests") {
"//ash/resources:ash_test_resources_100_percent", "//ash/resources:ash_test_resources_100_percent",
"//ash/resources:ash_test_resources_200_percent", "//ash/resources:ash_test_resources_200_percent",
] ]
if (ozone_platform_gbm) {
configs += [
"//components/exo/wayland:libdrm",
"//ui/gl:gl_config",
]
defines = [ "OZONE_PLATFORM_GBM" ]
deps += [
"//third_party/minigbm",
"//ui/ozone",
]
}
} }
if (ozone_platform_gbm) { if (ozone_platform_gbm) {
...@@ -297,7 +288,7 @@ if (ozone_platform_gbm) { ...@@ -297,7 +288,7 @@ if (ozone_platform_gbm) {
] ]
deps = [ deps = [
":client_lib", ":client_support",
"//base", "//base",
"//skia", "//skia",
"//third_party/wayland:wayland_client", "//third_party/wayland:wayland_client",
...@@ -310,7 +301,6 @@ if (ozone_platform_gbm) { ...@@ -310,7 +301,6 @@ if (ozone_platform_gbm) {
":libdrm", ":libdrm",
"//ui/gl:gl_config", "//ui/gl:gl_config",
] ]
defines = [ "OZONE_PLATFORM_GBM" ]
deps += [ "//third_party/minigbm" ] deps += [ "//third_party/minigbm" ]
} }
} }
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "ui/gl/gl_surface_egl.h" #include "ui/gl/gl_surface_egl.h"
#include "ui/gl/init/gl_factory.h" #include "ui/gl/init/gl_factory.h"
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
#include <drm_fourcc.h> #include <drm_fourcc.h>
#include <gbm.h> #include <gbm.h>
#include <xf86drm.h> #include <xf86drm.h>
...@@ -72,12 +72,12 @@ namespace { ...@@ -72,12 +72,12 @@ namespace {
// Buffer format. // Buffer format.
const int32_t kShmFormat = WL_SHM_FORMAT_ARGB8888; const int32_t kShmFormat = WL_SHM_FORMAT_ARGB8888;
const SkColorType kColorType = kBGRA_8888_SkColorType; const SkColorType kColorType = kBGRA_8888_SkColorType;
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
const GrPixelConfig kGrPixelConfig = kBGRA_8888_GrPixelConfig; const GrPixelConfig kGrPixelConfig = kBGRA_8888_GrPixelConfig;
#endif #endif
const size_t kBytesPerPixel = 4; const size_t kBytesPerPixel = 4;
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
// DRI render node path template. // DRI render node path template.
const char kDriRenderNodeTemplate[] = "/dev/dri/renderD%u"; const char kDriRenderNodeTemplate[] = "/dev/dri/renderD%u";
#endif #endif
...@@ -125,7 +125,7 @@ void BufferRelease(void* data, wl_buffer* /* buffer */) { ...@@ -125,7 +125,7 @@ void BufferRelease(void* data, wl_buffer* /* buffer */) {
buffer->busy = false; buffer->busy = false;
} }
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
const GrGLInterface* GrGLCreateNativeInterface() { const GrGLInterface* GrGLCreateNativeInterface() {
return GrGLAssembleInterface(nullptr, [](void* ctx, const char name[]) { return GrGLAssembleInterface(nullptr, [](void* ctx, const char name[]) {
return eglGetProcAddress(name); return eglGetProcAddress(name);
...@@ -143,7 +143,7 @@ wl_buffer_listener g_buffer_listener = {BufferRelease}; ...@@ -143,7 +143,7 @@ wl_buffer_listener g_buffer_listener = {BufferRelease};
// ClientBase::InitParams, public: // ClientBase::InitParams, public:
ClientBase::InitParams::InitParams() { ClientBase::InitParams::InitParams() {
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
drm_format = DRM_FORMAT_ABGR8888; drm_format = DRM_FORMAT_ABGR8888;
bo_usage = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING | GBM_BO_USE_TEXTURING; bo_usage = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING | GBM_BO_USE_TEXTURING;
#endif #endif
...@@ -273,7 +273,7 @@ bool ClientBase::Init(const InitParams& params) { ...@@ -273,7 +273,7 @@ bool ClientBase::Init(const InitParams& params) {
return false; return false;
} }
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
sk_sp<const GrGLInterface> native_interface; sk_sp<const GrGLInterface> native_interface;
if (params.use_drm) { if (params.use_drm) {
// Number of files to look for when discovering DRM devices. // Number of files to look for when discovering DRM devices.
...@@ -462,7 +462,7 @@ std::unique_ptr<ClientBase::Buffer> ClientBase::CreateDrmBuffer( ...@@ -462,7 +462,7 @@ std::unique_ptr<ClientBase::Buffer> ClientBase::CreateDrmBuffer(
int32_t drm_format, int32_t drm_format,
int32_t bo_usage) { int32_t bo_usage) {
std::unique_ptr<Buffer> buffer; std::unique_ptr<Buffer> buffer;
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
if (device_) { if (device_) {
buffer = std::make_unique<Buffer>(); buffer = std::make_unique<Buffer>();
buffer->bo.reset(gbm_bo_create(device_.get(), size.width(), size.height(), buffer->bo.reset(gbm_bo_create(device_.get(), size.width(), size.height(),
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#include "ui/gl/scoped_make_current.h" #include "ui/gl/scoped_make_current.h"
#if defined(USE_GBM)
#include <gbm.h>
#endif
namespace base { namespace base {
class CommandLine; class CommandLine;
class MessageLoopForUI; class MessageLoopForUI;
...@@ -69,7 +73,7 @@ class ClientBase { ...@@ -69,7 +73,7 @@ class ClientBase {
std::unique_ptr<wl_buffer> buffer; std::unique_ptr<wl_buffer> buffer;
bool busy = false; bool busy = false;
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
std::unique_ptr<gbm_bo> bo; std::unique_ptr<gbm_bo> bo;
std::unique_ptr<ScopedEglImage> egl_image; std::unique_ptr<ScopedEglImage> egl_image;
std::unique_ptr<ScopedEglSync> egl_sync; std::unique_ptr<ScopedEglSync> egl_sync;
...@@ -104,7 +108,7 @@ class ClientBase { ...@@ -104,7 +108,7 @@ class ClientBase {
std::unique_ptr<wl_surface> surface_; std::unique_ptr<wl_surface> surface_;
std::unique_ptr<wl_shell_surface> shell_surface_; std::unique_ptr<wl_shell_surface> shell_surface_;
Globals globals_; Globals globals_;
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
std::unique_ptr<base::MessageLoopForUI> ui_loop_; std::unique_ptr<base::MessageLoopForUI> ui_loop_;
base::ScopedFD drm_fd_; base::ScopedFD drm_fd_;
std::unique_ptr<gbm_device> device_; std::unique_ptr<gbm_device> device_;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_enums.h" #include "ui/gl/gl_enums.h"
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
#include <gbm.h> #include <gbm.h>
#endif #endif
...@@ -48,7 +48,7 @@ DEFAULT_DELETER(zaura_surface, zaura_surface_destroy) ...@@ -48,7 +48,7 @@ DEFAULT_DELETER(zaura_surface, zaura_surface_destroy)
DEFAULT_DELETER(zwp_linux_buffer_params_v1, zwp_linux_buffer_params_v1_destroy) DEFAULT_DELETER(zwp_linux_buffer_params_v1, zwp_linux_buffer_params_v1_destroy)
DEFAULT_DELETER(zwp_linux_dmabuf_v1, zwp_linux_dmabuf_v1_destroy) DEFAULT_DELETER(zwp_linux_dmabuf_v1, zwp_linux_dmabuf_v1_destroy)
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
DEFAULT_DELETER(gbm_bo, gbm_bo_destroy) DEFAULT_DELETER(gbm_bo, gbm_bo_destroy)
DEFAULT_DELETER(gbm_device, gbm_device_destroy) DEFAULT_DELETER(gbm_device, gbm_device_destroy)
#endif #endif
...@@ -57,7 +57,7 @@ namespace exo { ...@@ -57,7 +57,7 @@ namespace exo {
namespace wayland { namespace wayland {
namespace clients { namespace clients {
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
GLuint DeleteTextureTraits::InvalidValue() { GLuint DeleteTextureTraits::InvalidValue() {
return 0; return 0;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "base/scoped_generic.h" #include "base/scoped_generic.h"
#include "components/exo/wayland/aura-shell-client-protocol.h" #include "components/exo/wayland/aura-shell-client-protocol.h"
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
#include <gbm.h> #include <gbm.h>
#endif #endif
...@@ -50,7 +50,7 @@ DEFAULT_DELETER_FDECL(zaura_surface) ...@@ -50,7 +50,7 @@ DEFAULT_DELETER_FDECL(zaura_surface)
DEFAULT_DELETER_FDECL(zwp_linux_buffer_params_v1) DEFAULT_DELETER_FDECL(zwp_linux_buffer_params_v1)
DEFAULT_DELETER_FDECL(zwp_linux_dmabuf_v1) DEFAULT_DELETER_FDECL(zwp_linux_dmabuf_v1)
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
DEFAULT_DELETER_FDECL(gbm_bo) DEFAULT_DELETER_FDECL(gbm_bo)
DEFAULT_DELETER_FDECL(gbm_device) DEFAULT_DELETER_FDECL(gbm_device)
#endif #endif
...@@ -59,7 +59,7 @@ namespace exo { ...@@ -59,7 +59,7 @@ namespace exo {
namespace wayland { namespace wayland {
namespace clients { namespace clients {
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
struct DeleteTextureTraits { struct DeleteTextureTraits {
static unsigned InvalidValue(); static unsigned InvalidValue();
static void Free(unsigned texture); static void Free(unsigned texture);
......
...@@ -390,7 +390,7 @@ int RectsClient::Run(const ClientBase::InitParams& params, ...@@ -390,7 +390,7 @@ int RectsClient::Run(const ClientBase::InitParams& params,
if (gr_context) { if (gr_context) {
gr_context->flush(); gr_context->flush();
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
if (egl_sync_type_) { if (egl_sync_type_) {
buffer->egl_sync.reset(new ScopedEglSync(eglCreateSyncKHR( buffer->egl_sync.reset(new ScopedEglSync(eglCreateSyncKHR(
eglGetCurrentDisplay(), egl_sync_type_, nullptr))); eglGetCurrentDisplay(), egl_sync_type_, nullptr)));
...@@ -423,7 +423,7 @@ int RectsClient::Run(const ClientBase::InitParams& params, ...@@ -423,7 +423,7 @@ int RectsClient::Run(const ClientBase::InitParams& params,
surface_size_.height()); surface_size_.height());
wl_surface_attach(surface, frame->buffer->buffer.get(), 0, 0); wl_surface_attach(surface, frame->buffer->buffer.get(), 0, 0);
#if defined(OZONE_PLATFORM_GBM) #if defined(USE_GBM)
if (frame->buffer->egl_sync) { if (frame->buffer->egl_sync) {
eglClientWaitSyncKHR(eglGetCurrentDisplay(), eglClientWaitSyncKHR(eglGetCurrentDisplay(),
frame->buffer->egl_sync->get(), frame->buffer->egl_sync->get(),
......
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