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

Immersive backend #393

Open
wants to merge 49 commits into
base: v0.2.0-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
43aea67
move screen backend to backend/screen/
Aki-7 Mar 18, 2023
c90b561
rename screen backend to layer shell
Aki-7 Mar 18, 2023
2fb034c
change directory structure of backend
Aki-7 Mar 18, 2023
fec90fa
Enable to detect HMD
Aki-7 Mar 22, 2023
68b7375
refactor immersive backend
Aki-7 Apr 1, 2023
72be179
Enable to start session
Aki-7 Apr 2, 2023
4199368
fix backend mock
Aki-7 Apr 2, 2023
0cd855d
create dispatcher
Aki-7 Apr 2, 2023
1c8d16e
xr compositor
Aki-7 Apr 2, 2023
0c4a437
virtual object
Aki-7 Apr 8, 2023
2ef3347
zwn_gl global object
Aki-7 Apr 13, 2023
0cc73a7
add zn_client_gl_context
Aki-7 Apr 13, 2023
ecb9747
add gl_rendering_unit
Aki-7 Apr 15, 2023
7cb5b36
add gl_buffer
Aki-7 Apr 15, 2023
a064d57
gl_buffer::data
Aki-7 Apr 16, 2023
1cad059
add gl-base-technique
Aki-7 Apr 21, 2023
e18f76a
add gl-shader
Aki-7 Apr 26, 2023
175409b
remove lease buffer
Aki-7 Apr 26, 2023
6330d32
add gl-program
Aki-7 Apr 26, 2023
f4ade2e
VirtualObject::Commit
Aki-7 Apr 26, 2023
da7ca05
GlBaseTechnique::BindProgram
Aki-7 Apr 26, 2023
54e9eac
Refactor getting user_data from wl_resource
Aki-7 Apr 26, 2023
7a37790
add GlTexture
Aki-7 Apr 26, 2023
26ef997
add GlVertexArray
Aki-7 Apr 28, 2023
1b1c453
implement some methods of GlBaseTechnique
Aki-7 Apr 28, 2023
a3e94f0
fix protocol
Aki-7 Apr 29, 2023
20e2549
separate zwn-gl protocols implementations to a static library
Aki-7 Apr 29, 2023
080641e
add zn_xr_shell
Aki-7 Apr 29, 2023
274efcc
add zn_bounded
Aki-7 May 3, 2023
b8725f7
zn_bounded configure
Aki-7 May 7, 2023
8123e7a
inode
Aki-7 May 10, 2023
d5471d7
inode move
Aki-7 May 10, 2023
dc29a74
gl_rendering_unit.change_visibility
Aki-7 May 11, 2023
bec1f7f
virtual_object.change_visibility
Aki-7 May 14, 2023
8ba72f0
fix test
Aki-7 Jul 8, 2023
bfab3dd
binding
Aki-7 Jul 8, 2023
3433d70
send xr_system status on bind
Aki-7 Jul 12, 2023
3ac192d
xdg toplevel
Aki-7 Jul 14, 2023
1091611
use zwin v0.2.0 branch
Aki-7 Jul 14, 2023
7d7a34e
fix clang-tidy error
Aki-7 Jul 15, 2023
0ec0cbb
subsurface
Aki-7 Jul 22, 2023
042097b
organize zen apis
Aki-7 Jul 22, 2023
56f77cb
snode root
Aki-7 Jul 23, 2023
76c7191
change display mode
Aki-7 Jul 23, 2023
a0462b7
fix test
Aki-7 Jul 23, 2023
02929bd
inode mapping
Aki-7 Jul 25, 2023
337ba04
add inline
Aki-7 Jul 25, 2023
f0d0acc
rename header files
Aki-7 Jul 25, 2023
ff2640c
draw box
Aki-7 Jan 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ Checks: "

cppcoreguidelines-*,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-macro-usage,

google-*,

misc-*,
-misc-no-recursion,

modernize-*,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,

performance-*,
portability-*,

Expand All @@ -28,5 +34,8 @@ Checks: "

*-cloexec-*,
"
CheckOptions:
- key: 'cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor'
value: 'true'
WarningsAsErrors: '*'
FormatStyle: file
30 changes: 26 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,22 @@ jobs:
steps:
- name: Install dependencies
run: |
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" | sudo tee -a /etc/apt/sources.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install \
libwayland-dev libwlroots-dev libpixman-1-dev \
libxkbcommon-dev libglu1-mesa-dev libglew-dev \
meson libfreetype-dev librsvg2-dev libcglm-dev clang-15
meson libfreetype-dev librsvg2-dev libcglm-dev

- name: Install clang15
if: matrix.clang-version == 15
run: |
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" | sudo tee -a /etc/apt/sources.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install clang-15 clang-format-15 clang-tidy-15
sudo ln -sf /usr/bin/clang-tidy-15 /usr/bin/clang-tidy
sudo ln -sf /usr/bin/clang-format-15 /usr/bin/clang-format

- uses: actions/setup-python@v1
with:
Expand All @@ -46,12 +54,25 @@ jobs:
unzip grpc-dev.zip
working-directory: ./grpc-dev

- name: Clone zen-protocols
uses: actions/checkout@v2
with:
repository: zwin-project/zen-protocols
path: zen-protocols

- name: Install zen-protocols
working-directory: ./zen-protocols
run: |
meson build
sudo ninja -C build install

- name: Clone zen-remote
uses: actions/checkout@v2
with:
repository: zwin-project/zen-remote
path: zen-remote
submodules: recursive
ref: 'v0.2.0'

- name: Build zen-remote
working-directory: ./zen-remote
Expand All @@ -65,6 +86,7 @@ jobs:
with:
repository: zwin-project/zwin
path: zwin
ref: 'v0.2.0'

- name: Build zwin
working-directory: ./zwin
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Akihiro Kiuchi & Taishi Eguchi
Copyright (c) 2023 Zwin Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 13 additions & 0 deletions common/include/zen-common/cpp-util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#ifdef __cplusplus

// NOLINTBEGIN(bugprone-macro-parentheses)
#define DISABLE_MOVE_AND_COPY(Class) \
Class(const Class &) = delete; \
Class(Class &&) = delete; \
Class &operator=(const Class &) = delete; \
Class &operator=(Class &&) = delete
// NOLINTEND(bugprone-macro-parentheses)

#endif
22 changes: 22 additions & 0 deletions common/include/zen-common/delay-signal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <wayland-server.h>

struct zn_delay_signal {
struct wl_signal signal;
struct wl_event_source *idle; // @nonnull, @ref
};

/// The signal handlers will be called at the next idle time.
/// No user data is allowed as it's hard to manage the ownership of the data.
/// In there is already a scheduled signal, this signal scheduling will be
/// ignored.
void zn_delay_signal_schedule(
struct zn_delay_signal *self, struct wl_display *display);

void zn_delay_signal_add(
struct zn_delay_signal *self, struct wl_listener *listener);

void zn_delay_signal_init(struct zn_delay_signal *self);

void zn_delay_signal_release(struct zn_delay_signal *self);
11 changes: 7 additions & 4 deletions common/include/zen-common/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <stdbool.h>
#include <string.h>

#include "util.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -36,7 +38,8 @@ void zn_vlog_(zn_log_importance_t verbosity, const char *format, va_list args)

void zn_abort_(const char *format, ...) ATTRIB_PRINTF(1, 2);

bool zn_assert_(bool condition, const char *format, ...) ATTRIB_PRINTF(2, 3);
bool zn_assert_handler_(const char *format, ...)
ATTRIB_PRINTF(1, 2) CLANG_ANALYZER_NORETURN;

#define zn_log(verb, fmt, ...) \
zn_log_(verb, "[zen] [%s:%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
Expand All @@ -59,9 +62,9 @@ bool zn_assert_(bool condition, const char *format, ...) ATTRIB_PRINTF(2, 3);
#define zn_abort(fmt, ...) \
zn_abort_("[zen] [%s:%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__)

#define zn_assert(cond, fmt, ...) \
zn_assert_(cond, "[zen] [%s:%d] %s: " fmt, __FILE__, __LINE__, __func__, \
##__VA_ARGS__)
#define zn_assert(cond, fmt, ...) \
(cond || zn_assert_handler_( \
"[zen] [%s:%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__))

#define zn_warn_once(fmt, ...) \
{ \
Expand Down
24 changes: 11 additions & 13 deletions common/include/zen-common/util.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <stddef.h>
#include <stdlib.h>
#include <stddef.h> // NOLINT(modernize-deprecated-headers)
#include <stdlib.h> // NOLINT(modernize-deprecated-headers)

#ifdef __cplusplus
extern "C" {
Expand All @@ -28,11 +28,19 @@ extern "C" {
#endif
#endif

#ifndef CLANG_ANALYZER_NORETURN
#if __has_feature(attribute_analyzer_noreturn)
#define CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
#else
#define CLANG_ANALYZER_NORETURN
#endif
#endif

/** Allocate memory and set to zero */
UNUSED static inline void *
zalloc(size_t size)
{
return calloc(1, size);
return calloc(1, size); // NOLINT(cppcoreguidelines-*)
}

#define ZN_MAX(a, b) ((a) > (b) ? (a) : (b))
Expand All @@ -42,16 +50,6 @@ zalloc(size_t size)
#define zn_container_of(ptr, sample, member) \
(__typeof__(sample))((char *)(ptr)-offsetof(__typeof__(*(sample)), member))

#ifdef __cplusplus

#define DISABLE_MOVE_AND_COPY(Class) \
Class(const Class &) = delete; \
Class(Class &&) = delete; \
Class &operator=(const Class &) = delete; \
Class &operator=(Class &&) = delete

#endif

#ifdef __cplusplus
}
#endif
26 changes: 26 additions & 0 deletions common/include/zen-common/wl-array.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <cglm/types.h>
#include <stdbool.h>
#include <wayland-util.h>

#ifdef __cplusplus
extern "C" {
#endif

/// @return true if successful, false otherwise
bool zn_wl_array_to_int64_t(struct wl_array *array, int64_t *value);

/// @return true if successful, false otherwise
bool zn_wl_array_to_uint64_t(struct wl_array *array, uint64_t *value);

/// @return true if successful, false otherwise
/// @param array must be initialized
bool zn_wl_array_from_vec3(struct wl_array *array, vec3 value);

/// @return true if successful, false otherwise
bool zn_wl_array_to_vec3(struct wl_array *array, vec3 value);

#ifdef __cplusplus
}
#endif
2 changes: 2 additions & 0 deletions common/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
_zen_common_srcs = [
'src/cairo/rounded.c',
'src/delay-signal.c',
'src/log.c',
'src/signal.c',
'src/terminate.c',
'src/wl-array.c',
'src/wlr/box.c',
]

Expand Down
49 changes: 49 additions & 0 deletions common/src/delay-signal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "zen-common/delay-signal.h"

#include "zen-common/signal.h"
#include "zen-common/util.h"

static void
zn_delay_signal_idle_timer(void *data)
{
struct zn_delay_signal *self = data;

self->idle = NULL;

zn_signal_emit_mutable(&self->signal, NULL);
}

void
zn_delay_signal_schedule(
struct zn_delay_signal *self, struct wl_display *display)
{
if (self->idle) {
return;
}

struct wl_event_loop *loop = wl_display_get_event_loop(display);

self->idle = wl_event_loop_add_idle(loop, zn_delay_signal_idle_timer, self);
}

void
zn_delay_signal_add(struct zn_delay_signal *self, struct wl_listener *listener)
{
wl_signal_add(&self->signal, listener);
}

void
zn_delay_signal_init(struct zn_delay_signal *self)
{
wl_signal_init(&self->signal);
self->idle = NULL;
}

void
zn_delay_signal_release(struct zn_delay_signal *self)
{
wl_list_remove(&self->signal.listener_list);
if (self->idle) {
wl_event_source_remove(self->idle);
}
}
6 changes: 1 addition & 5 deletions common/src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,8 @@ zn_abort_(const char *format, ...)
}

bool
zn_assert_(bool condition, const char *format, ...)
zn_assert_handler_(const char *format, ...)
{
if (condition) {
return true;
}

va_list args;
va_start(args, format);
zn_vlog_(ZEN_ERROR, format, args);
Expand Down
52 changes: 52 additions & 0 deletions common/src/wl-array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "zen-common/wl-array.h"

#include <string.h>

bool
zn_wl_array_to_int64_t(struct wl_array *array, int64_t *value)
{
if (array->size != sizeof(*value)) {
return false;
}

memcpy(value, array->data, array->size);

return true;
}

bool
zn_wl_array_to_uint64_t(struct wl_array *array, uint64_t *value)
{
if (array->size != sizeof(*value)) {
return false;
}

memcpy(value, array->data, array->size);

return true;
}

bool
zn_wl_array_from_vec3(struct wl_array *array, vec3 value)
{
void *data = wl_array_add(array, sizeof(vec3));
if (data == NULL) {
return false;
}

memcpy(data, value, sizeof(vec3));

return true;
}

bool
zn_wl_array_to_vec3(struct wl_array *array, vec3 value)
{
if (array->size != sizeof(vec3)) {
return false;
}

memcpy(value, array->data, array->size);

return true;
}
Loading
Loading