Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unstable dmabuf-pool API #130

Merged
merged 1 commit into from Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 66 additions & 0 deletions include/wpe/unstable/dmabuf-pool-entry.h
@@ -0,0 +1,66 @@
/*
* Copyright (C) 2020 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if !defined(__WPE_FDO_DMABUF_H_INSIDE__) && !defined(WPE_FDO_COMPILATION)
#error "Only <wpe/unstable/fdo-dmabuf.h> can be included directly."
#endif

#pragma once

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

struct wpe_dmabuf_pool_entry;

struct wpe_dmabuf_pool_entry_init {
uint32_t width;
uint32_t height;
uint32_t format;

unsigned num_planes;
int fds[4];
uint32_t strides[4];
uint32_t offsets[4];
uint64_t modifiers[4];
};

struct wpe_dmabuf_pool_entry*
wpe_dmabuf_pool_entry_create(const struct wpe_dmabuf_pool_entry_init*);

void
wpe_dmabuf_pool_entry_destroy(struct wpe_dmabuf_pool_entry*);

void
wpe_dmabuf_pool_entry_set_user_data(struct wpe_dmabuf_pool_entry*, void*);

void*
wpe_dmabuf_pool_entry_get_user_data(struct wpe_dmabuf_pool_entry*);

#ifdef __cplusplus
}
#endif
38 changes: 38 additions & 0 deletions include/wpe/unstable/fdo-dmabuf.h
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2020 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef __WEBKIT_WEB_EXTENSION_H__
#error "Headers <wpe/unstable/fdo-dmabuf.h> and <wpe/webkit-web-extension.h> cannot be included together."
#endif

#pragma once

#define __WPE_FDO_DMABUF_H_INSIDE__

#include "dmabuf-pool-entry.h"
#include "initialize-dmabuf.h"
#include "view-backend-dmabuf-pool-fdo.h"

#undef __WPE_FDO_DMABUF_H_INSIDE__
43 changes: 43 additions & 0 deletions include/wpe/unstable/initialize-dmabuf.h
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2020 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if !defined(__WPE_FDO_DMABUF_H_INSIDE__) && !defined(WPE_FDO_COMPILATION)
#error "Only <wpe/unstable/fdo-dmabuf.h> can be included directly."
#endif

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>

bool
wpe_fdo_initialize_dmabuf(void);

#ifdef __cplusplus
}
#endif
68 changes: 68 additions & 0 deletions include/wpe/unstable/view-backend-dmabuf-pool-fdo.h
@@ -0,0 +1,68 @@
/*
* Copyright (C) 2020 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if !defined(__WPE_FDO_DMABUF_H_INSIDE__) && !defined(WPE_FDO_COMPILATION)
#error "Only <wpe/unstable/fdo-dmabuf.h> can be included directly."
#endif

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <wpe/wpe.h>

struct wpe_dmabuf_pool_entry;

struct wpe_view_backend_dmabuf_pool_fdo_client {
struct wpe_dmabuf_pool_entry* (*create_entry)(void*);
void (*destroy_entry)(void*, struct wpe_dmabuf_pool_entry*);
void (*commit_entry)(void*, struct wpe_dmabuf_pool_entry*);

void (*_wpe_reserved0)(void);
void (*_wpe_reserved1)(void);
void (*_wpe_reserved2)(void);
void (*_wpe_reserved3)(void);
};

struct wpe_view_backend_dmabuf_pool_fdo*
wpe_view_backend_dmabuf_pool_fdo_create(const struct wpe_view_backend_dmabuf_pool_fdo_client*, void*, uint32_t width, uint32_t height);

void
wpe_view_backend_dmabuf_pool_fdo_destroy(struct wpe_view_backend_dmabuf_pool_fdo*);

struct wpe_view_backend*
wpe_view_backend_dmabuf_pool_fdo_get_view_backend(struct wpe_view_backend_dmabuf_pool_fdo*);

void
wpe_view_backend_dmabuf_pool_fdo_dispatch_frame_complete(struct wpe_view_backend_dmabuf_pool_fdo*);

void
wpe_view_backend_dmabuf_pool_fdo_dispatch_release_entry(struct wpe_view_backend_dmabuf_pool_fdo*, struct wpe_dmabuf_pool_entry*);

#ifdef __cplusplus
}
#endif
32 changes: 32 additions & 0 deletions meson.build
Expand Up @@ -32,23 +32,28 @@ soversion_micro = soversion[1] # Revision
soversion = '@0@.@1@.@2@'.format(soversion_major, soversion_minor, soversion_micro)

sources = [
'src/dmabuf-pool-entry.cpp',
'src/egl-client-dmabuf-pool.cpp',
'src/egl-client-wayland.cpp',
'src/exported-buffer-shm.cpp',
'src/exported-image-egl.cpp',
'src/fdo.cpp',
'src/initialize-dmabuf.cpp',
'src/initialize-egl.cpp',
'src/initialize-eglstream.cpp',
'src/initialize-shm.cpp',
'src/ipc.cpp',
'src/renderer-backend-egl.cpp',
'src/renderer-host.cpp',
'src/version.c',
'src/view-backend-dmabuf-pool-fdo.cpp',
'src/view-backend-exportable-fdo.cpp',
'src/view-backend-exportable-fdo-egl.cpp',
'src/view-backend-exportable-fdo-eglstream.cpp',
'src/view-backend-private.cpp',
'src/ws.cpp',
'src/ws-client.cpp',
'src/ws-dmabuf-pool.cpp',
'src/ws-egl.cpp',
'src/ws-eglstream.cpp',
'src/ws-shm.cpp',
Expand Down Expand Up @@ -78,10 +83,14 @@ extensions_api_headers = [
]

unstable_api_headers = [
'include/wpe/unstable/dmabuf-pool-entry.h',
'include/wpe/unstable/fdo-dmabuf.h',
'include/wpe/unstable/fdo-eglstream.h',
'include/wpe/unstable/fdo-shm.h',
'include/wpe/unstable/initialize-dmabuf.h',
'include/wpe/unstable/initialize-shm.h',
'include/wpe/unstable/initialize-eglstream.h',
'include/wpe/unstable/view-backend-dmabuf-pool-fdo.h',
'include/wpe/unstable/view-backend-exportable-eglstream.h',
]

Expand Down Expand Up @@ -196,6 +205,26 @@ wayland_eglstream_controller_proto_source = custom_target(
command: [wayland_scanner, wayland_scanner_code, '@INPUT@', '@OUTPUT@'],
)

# Wayland extension: dmabuf pool
wpe_dmabuf_pool_client_proto_header = custom_target(
'dmabuf-pool-client-proto-header',
input: 'src/dmabuf-pool/wpe-dmabuf-pool.xml',
output: '@BASENAME@-client-protocol.h',
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
)
wpe_dmabuf_pool_server_proto_header = custom_target(
'dmabuf-pool-server-proto-header',
input: 'src/dmabuf-pool/wpe-dmabuf-pool.xml',
output: '@BASENAME@-server-protocol.h',
command: [wayland_scanner, 'server-header', '@INPUT@', '@OUTPUT@'],
)
wpe_dmabuf_pool_proto_source = custom_target(
'dmabuf-pool-proto-source',
input: 'src/dmabuf-pool/wpe-dmabuf-pool.xml',
output: '@BASENAME@-protocol.c',
command: [wayland_scanner, wayland_scanner_code, '@INPUT@', '@OUTPUT@'],
)

cxx = meson.get_compiler('cpp')

# Switch to the 'cpp_eh=none' default option when updating to Meson 0.51 or newer, see
Expand Down Expand Up @@ -285,6 +314,9 @@ generated_sources = [
wpe_video_plane_display_dmabuf_server_proto_header,
wayland_eglstream_controller_proto_source,
wayland_eglstream_controller_server_proto_header,
wpe_dmabuf_pool_client_proto_header,
wpe_dmabuf_pool_server_proto_header,
wpe_dmabuf_pool_proto_source,
]

lib = shared_library('WPEBackend-fdo-' + api_version,
Expand Down
1 change: 1 addition & 0 deletions src/bridge/wpe-bridge.xml
Expand Up @@ -29,6 +29,7 @@
<interface name="wpe_bridge" version="1">
<enum name="client_implementation_type">
<entry name="wayland" value="0"/>
<entry name="dmabuf_pool" value="1"/>
</enum>

<request name="initialize">
Expand Down
48 changes: 48 additions & 0 deletions src/dmabuf-pool-entry-private.h
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2020 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#include "wpe/unstable/dmabuf-pool-entry.h"

#include <array>

struct wl_resource;

struct wpe_dmabuf_pool_entry {
struct wl_resource* bufferResource { nullptr };

void* data { nullptr };

uint32_t width { 0 };
uint32_t height { 0 };
uint32_t format { 0 };

unsigned num_planes { 0 };
std::array<int, 4> fds { -1, -1, -1, -1 };
std::array<uint32_t, 4> strides { };
std::array<uint32_t, 4> offsets { };
std::array<uint64_t, 4> modifiers { };
};