...
 
Commits (14)
......@@ -116,13 +116,14 @@ package-deb-with-wlroots:
<<: *tags
stage: package
image: debian:buster
dependencies: []
before_script: *before_script_debian_buster
script:
- rm -rf "${L5_WORKING_DIR}"; mkdir -p "${L5_WORKING_DIR}"
- git submodule update --init
- dpkg-buildpackage -b -uc -us
# Must not be dynamically linked against wlroots
- ldd debian/phoc/usr/bin/phoc | grep -qs libwlroots && exit 1 || true
- ldd debian/phoc/usr/bin/phoc | grep libwlroots && exit 1 || true
- cp -l ../*.deb ../*.changes ../*.buildinfo "${L5_WORKING_DIR}/"
artifacts:
paths:
......@@ -134,6 +135,7 @@ package-deb-without-wlroots:
image: debian:buster
variables:
DEB_BUILD_PROFILES: ""
dependencies: []
before_script:
- echo "deb http://deb.debian.org/debian/ sid main" > /etc/apt/sources.list.d/sid.list
- apt-get -y update
......@@ -146,7 +148,7 @@ package-deb-without-wlroots:
- rm -rf "${L5_WORKING_DIR}"; mkdir -p "${L5_WORKING_DIR}"
- dpkg-buildpackage -b -uc -us
# Must be dynamically linked against wlroots
- ldd debian/phoc/usr/bin/phoc | grep -qs libwlroots
- ldd debian/phoc/usr/bin/phoc | grep libwlroots
- cp -l ../*.deb ../*.changes ../*.buildinfo "${L5_WORKING_DIR}/"
artifacts:
paths:
......@@ -157,13 +159,14 @@ package-deb-with-wlroots:arm64:
- librem5:arm64
stage: package
image: debian:buster
dependencies: []
before_script: *before_script_debian_buster
script:
- rm -rf "${L5_WORKING_DIR}"; mkdir -p "${L5_WORKING_DIR}"
- git submodule update --init
- dpkg-buildpackage -b -uc -us
# Must not be dynamically linked against wlroots
- ldd debian/phoc/usr/bin/phoc | grep -qs libwlroots && exit 1 || true
- ldd debian/phoc/usr/bin/phoc | grep libwlroots && exit 1 || true
- cp -l ../*.deb ../*.changes ../*.buildinfo "${L5_WORKING_DIR}/"
artifacts:
paths:
......
phoc (0.4.1) amber-phone; urgency=high
[ Sebastian Krzyszkowiak ]
* render: Rework damage tracking debug mode
* render: Use G_(UN)LIKELY for debug flags
* render: Use defines for color values
* cursor: Put a touched view into focus
* debian: Add sign-tags=true to gbp.conf
* gitlab-ci: Un-silence grep invocations
* gitlab-ci: Set package jobs dependencies to empty
* render: Don't try to render a surface with no texture
* cursor: Avoid damaging the whole output in touch points debug mode
* render: Catch up with wlroots' wlr_client_buffer
* render: Make the EGL context current when rendering to texture
[ &t ]
* Add --version flag
[ Yann Büchau ]
* scale-to-fit: Default to "on" without extra argument
-- Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Wed, 22 Jul 2020 15:47:52 +0200
phoc (0.4.0) amber-phone; urgency=high
[ Guido Günther ]
......
......@@ -5,3 +5,6 @@ debian-tag-msg = %(pkg)s v%(version)s
[dch]
multimaint-merge = True
[tag]
sign-tags = true
......@@ -10,7 +10,7 @@ if [ -z "$1" ]; then
fi
case "$2" in
on|1|ON|true)
""|on|1|ON|true)
val=true
;;
*)
......
......@@ -478,26 +478,50 @@ void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
struct wlr_event_touch_down *event) {
PhocServer *server = phoc_server_get_default ();
PhocDesktop *desktop = server->desktop;
struct roots_seat *seat = cursor->seat;
double lx, ly;
wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device,
event->x, event->y, &lx, &ly);
double sx, sy;
struct roots_view *view;
struct wlr_surface *surface = desktop_surface_at(
desktop, lx, ly, &sx, &sy, NULL);
desktop, lx, ly, &sx, &sy, &view);
if (surface && !roots_handle_shell_reveal(surface, lx, ly, PHOC_SHELL_REVEAL_TOUCH_THRESHOLD) &&
roots_seat_allow_input(cursor->seat, surface->resource)) {
wlr_seat_touch_notify_down(cursor->seat->seat, surface,
roots_seat_allow_input(seat, surface->resource)) {
wlr_seat_touch_notify_down(seat->seat, surface,
event->time_msec, event->touch_id, sx, sy);
wlr_seat_touch_point_focus(cursor->seat->seat, surface,
wlr_seat_touch_point_focus(seat->seat, surface,
event->time_msec, event->touch_id, sx, sy);
if (view) {
roots_seat_set_focus(seat, view);
}
if (wlr_surface_is_layer_surface(surface)) {
struct wlr_layer_surface_v1 *layer =
wlr_layer_surface_v1_from_wlr_surface(surface);
if (layer->current.keyboard_interactive) {
roots_seat_set_focus_layer(seat, layer);
}
}
}
if (server->debug_flags & PHOC_SERVER_DEBUG_FLAG_TOUCH_POINTS) {
struct roots_output *output;
wl_list_for_each(output, &desktop->outputs, link) {
output_damage_whole(output);
if (wlr_output_layout_contains_point(desktop->layout, output->wlr_output, lx, ly)) {
double ox = lx, oy = ly;
wlr_output_layout_output_coords(desktop->layout, output->wlr_output, &ox, &oy);
struct wlr_box box = {
.x = ox,
.y = oy,
.width = 1,
.height = 1
};
wlr_output_damage_add_box(output->damage, &box);
}
}
}
}
......
......@@ -19,6 +19,13 @@
#include "settings.h"
#include "server.h"
static void
print_version (void)
{
printf ("Phoc %s - Phone compositor\n", PHOC_VERSION);
exit (0);
}
static void
setup_signals (void)
{
......@@ -93,6 +100,7 @@ main(int argc, char **argv)
g_autofree gchar *config_path = NULL;
g_autofree gchar *exec = NULL;
PhocServerDebugFlags debug_flags = PHOC_SERVER_DEBUG_FLAG_NONE;
gboolean version = FALSE;
setup_signals();
......@@ -101,6 +109,8 @@ main(int argc, char **argv)
"Path to the configuration file. (default: phoc.ini).", NULL},
{"exec", 'E', 0, G_OPTION_ARG_STRING, &exec,
"Command (session) that will be ran at startup", NULL},
{"version", 0, 0, G_OPTION_ARG_NONE, &version,
"Show version information", NULL},
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
......@@ -112,6 +122,10 @@ main(int argc, char **argv)
return 1;
}
if (version) {
print_version ();
}
debug_flags = parse_debug_env ();
wlr_log_init(WLR_DEBUG, log_glib);
server = phoc_server_get_default ();
......
......@@ -10,12 +10,14 @@
#include <wlr/backend.h>
#include <wlr/config.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/render/gles2.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/util/log.h>
#include <wlr/util/region.h>
#include <wlr/version.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include "layers.h"
......@@ -26,6 +28,12 @@
#define TOUCH_POINT_RADIUS 30
#define TOUCH_POINT_BORDER 0.1
#define COLOR_BLACK {0.0f, 0.0f, 0.0f, 1.0f}
#define COLOR_TRANSPARENT {0.0f, 0.0f, 0.0f, 0.0f}
#define COLOR_TRANSPARENT_WHITE {0.5f, 0.5f, 0.5f, 0.5f}
#define COLOR_TRANSPARENT_YELLOW {0.5f, 0.5f, 0.0f, 0.5f}
#define COLOR_TRANSPARENT_MAGENTA {0.5f, 0.0f, 0.5f, 0.5f}
struct render_data {
pixman_region32_t *damage;
float alpha;
......@@ -96,7 +104,7 @@ static void
collect_touch_points (struct roots_output *output, struct wlr_surface *surface, struct wlr_box box, float scale)
{
PhocServer *server = phoc_server_get_default ();
if (!(server->debug_flags & PHOC_SERVER_DEBUG_FLAG_TOUCH_POINTS)) {
if (G_LIKELY (!(server->debug_flags & PHOC_SERVER_DEBUG_FLAG_TOUCH_POINTS))) {
return;
}
......@@ -279,9 +287,13 @@ static bool scan_out_fullscreen_view(struct roots_output *output) {
wlr_presentation_surface_sampled(output->desktop->presentation, surface);
#if WLR_VERSION_MAJOR == 0 && WLR_VERSION_MINOR < 11
if (!wlr_output_attach_buffer(wlr_output, surface->buffer)) {
return false;
}
#else
wlr_output_attach_buffer(wlr_output, &surface->buffer->base);
#endif
return wlr_output_commit(wlr_output);
}
......@@ -348,14 +360,14 @@ render_touch_point_cb (gpointer data, gpointer user_data)
wlr_render_ellipse (renderer, &point_box, color, wlr_output->transform_matrix);
point_box = wlr_box_from_touch_point (touch_point, TOUCH_POINT_RADIUS * (1.0 - TOUCH_POINT_BORDER) * wlr_output->scale);
wlr_render_ellipse(renderer, &point_box, (float[]){0.5, 0.5, 0.5, 0.5}, wlr_output->transform_matrix);
wlr_render_ellipse(renderer, &point_box, (float[])COLOR_TRANSPARENT_WHITE, wlr_output->transform_matrix);
}
static void
render_touch_points (struct roots_output *output)
{
PhocServer *server = phoc_server_get_default ();
if (!(server->debug_flags & PHOC_SERVER_DEBUG_FLAG_TOUCH_POINTS)) {
if (G_LIKELY (!(server->debug_flags & PHOC_SERVER_DEBUG_FLAG_TOUCH_POINTS))) {
return;
}
g_list_foreach (output->debug_touch_points, render_touch_point_cb, output);
......@@ -389,6 +401,10 @@ damage_touch_points (struct roots_output *output)
static void
view_render_iterator (struct wlr_surface *surface, int sx, int sy, void *data)
{
if (!wlr_surface_has_buffer (surface)) {
return;
}
PhocServer *server = phoc_server_get_default ();
struct wlr_texture *view_texture = wlr_surface_get_texture (surface);
......@@ -423,8 +439,13 @@ view_render_to_buffer (struct roots_view *view, int width, int height, int strid
{
PhocServer *server = phoc_server_get_default ();
struct wlr_surface *surface = view->wlr_surface;
struct wlr_egl *egl = wlr_gles2_renderer_get_egl (server->renderer);
GLuint tex, fbo;
if (!wlr_egl_make_current (egl, EGL_NO_SURFACE, NULL)) {
return;
}
glGenTextures (1, &tex);
glBindTexture (GL_TEXTURE_2D, tex);
glTexImage2D (GL_TEXTURE_2D, 0, GL_BGRA_EXT, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
......@@ -435,7 +456,7 @@ view_render_to_buffer (struct roots_view *view, int width, int height, int strid
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
wlr_renderer_begin (server->renderer, width, height);
wlr_renderer_clear (server->renderer, (float[]){0.0, 0.0, 0.0, 0.0});
wlr_renderer_clear (server->renderer, (float[])COLOR_TRANSPARENT);
wlr_surface_for_each_surface (surface, view_render_iterator, view);
wlr_renderer_end (server->renderer);
......@@ -444,6 +465,10 @@ view_render_to_buffer (struct roots_view *view, int width, int height, int strid
glDeleteFramebuffers (1, &fbo);
glDeleteTextures (1, &tex);
glBindFramebuffer (GL_FRAMEBUFFER, 0);
#if WLR_VERSION_MAJOR > 0 || WLR_VERSION_MINOR >= 11
wlr_egl_unset_current (egl);
#endif
}
static void surface_send_frame_done_iterator(struct roots_output *output,
......@@ -468,7 +493,7 @@ void output_render(struct roots_output *output) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
float clear_color[] = {0.0f, 0.0f, 0.0f, 1.0f};
float clear_color[] = COLOR_BLACK;
const struct wlr_box *output_box =
wlr_output_layout_get_box(desktop->layout, wlr_output);
......@@ -520,6 +545,18 @@ void output_render(struct roots_output *output) {
.alpha = 1.0,
};
enum wl_output_transform transform =
wlr_output_transform_invert(wlr_output->transform);
if (G_UNLIKELY (server->debug_flags & PHOC_SERVER_DEBUG_FLAG_DAMAGE_TRACKING)) {
pixman_region32_union_rect(&buffer_damage, &buffer_damage,
0, 0, wlr_output->width, wlr_output->height);
wlr_region_transform(&buffer_damage, &buffer_damage,
transform, wlr_output->width, wlr_output->height);
needs_frame |= pixman_region32_not_empty(&output->damage->current);
needs_frame |= pixman_region32_not_empty(&output->damage->previous[output->damage->previous_idx]);
}
if (!needs_frame) {
// Output doesn't need swap and isn't damaged, skip rendering completely
wlr_output_rollback(wlr_output);
......@@ -533,10 +570,6 @@ void output_render(struct roots_output *output) {
goto renderer_end;
}
if (server->debug_flags & PHOC_SERVER_DEBUG_FLAG_DAMAGE_TRACKING) {
wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1});
}
int nrects;
pixman_box32_t *rects = pixman_region32_rectangles(&buffer_damage, &nrects);
for (int i = 0; i < nrects; ++i) {
......@@ -597,24 +630,39 @@ renderer_end:
render_touch_points (output);
wlr_renderer_end(renderer);
int width, height;
wlr_output_transformed_resolution(wlr_output, &width, &height);
pixman_region32_t frame_damage;
pixman_region32_init(&frame_damage);
enum wl_output_transform transform =
wlr_output_transform_invert(wlr_output->transform);
wlr_region_transform(&frame_damage, &output->damage->current,
transform, width, height);
if (server->debug_flags & PHOC_SERVER_DEBUG_FLAG_DAMAGE_TRACKING) {
pixman_region32_union_rect(&frame_damage, &frame_damage,
0, 0, wlr_output->width, wlr_output->height);
if (G_UNLIKELY (server->debug_flags & PHOC_SERVER_DEBUG_FLAG_DAMAGE_TRACKING)) {
pixman_region32_t previous_damage;
pixman_region32_init(&previous_damage);
pixman_region32_subtract(&previous_damage,
&output->damage->previous[output->damage->previous_idx], &output->damage->current);
struct wlr_box box;
rects = pixman_region32_rectangles(&previous_damage, &nrects);
for (int i = 0; i < nrects; ++i) {
wlr_box_from_pixman_box32(&box, rects[i]);
wlr_render_rect(renderer, &box, (float[])COLOR_TRANSPARENT_MAGENTA, wlr_output->transform_matrix);
}
rects = pixman_region32_rectangles(&output->damage->current, &nrects);
for (int i = 0; i < nrects; ++i) {
wlr_box_from_pixman_box32(&box, rects[i]);
wlr_render_rect(renderer, &box, (float[])COLOR_TRANSPARENT_YELLOW, wlr_output->transform_matrix);
}
wlr_output_schedule_frame(output->wlr_output);
pixman_region32_fini(&previous_damage);
}
wlr_renderer_end(renderer);
wlr_output_set_damage(wlr_output, &frame_damage);
pixman_region32_fini(&frame_damage);
......