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