Commit f33bddae authored by Harish Krupo's avatar Harish Krupo

[DO NOT MERGE] Implement the colorspace-unstable-v1 protocol

This is just a placeholder to get data from clients to test our HDR
stack. The actual protocol is being discussed here:
https://patchwork.freedesktop.org/series/57657/

v2: Use the common color primary definitions (Pekka)
Signed-off-by: Harish Krupo's avatarHarish Krupo <harish.krupo.kps@intel.com>
parent 474debed
......@@ -46,6 +46,7 @@ extern "C" {
#include <libweston/zalloc.h>
#include <libweston/timeline-object.h>
#include <libweston/hdr_metadata_defs.h>
#include <libweston/colorspace.h>
struct weston_geometry {
int32_t x, y;
......@@ -1391,6 +1392,8 @@ struct weston_surface_state {
/* zwp_surface_synchronization_v1.get_release */
struct weston_buffer_release_reference buffer_release_ref;
struct weston_hdr_metadata *hdr_metadata;
uint32_t colorspace;
};
struct weston_surface_activation_data {
......@@ -1522,6 +1525,7 @@ struct weston_surface {
struct weston_buffer_release_reference buffer_release_ref;
struct wl_resource *hdr_surface_resource;
struct weston_hdr_metadata *hdr_metadata;
uint32_t colorspace;
};
struct weston_subsurface {
......@@ -2393,6 +2397,8 @@ void
weston_buffer_send_server_error(struct weston_buffer *buffer,
const char *msg);
int weston_hdr_metadata_setup(struct weston_compositor *compositor);
int weston_colorspace_setup(struct weston_compositor *compositor);
#ifdef __cplusplus
}
......
/*
* Copyright © 2017 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include <string.h>
#include <libweston/libweston.h>
#include "colorspace-unstable-v1-server-protocol.h"
static void
colorspace_destroy_request(struct wl_client *client,
struct wl_resource *resource)
{
wl_resource_destroy(resource);
}
static void
colorspace_set_request(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *surface_resource,
uint32_t chromacities)
{
static uint32_t colorspace_names[] = {
[ZWP_COLORSPACE_V1_CHROMACITIES_UNDEFINED] = WESTON_CS_UNDEFINED,
[ZWP_COLORSPACE_V1_CHROMACITIES_BT470M] = WESTON_CS_BT470M,
[ZWP_COLORSPACE_V1_CHROMACITIES_BT470BG] = WESTON_CS_BT470BG,
[ZWP_COLORSPACE_V1_CHROMACITIES_SMPTE170M] = WESTON_CS_SMPTE170M,
[ZWP_COLORSPACE_V1_CHROMACITIES_BT709] = WESTON_CS_BT709,
[ZWP_COLORSPACE_V1_CHROMACITIES_BT2020] = WESTON_CS_BT2020,
[ZWP_COLORSPACE_V1_CHROMACITIES_ADOBERGB] = WESTON_CS_ADOBERGB,
[ZWP_COLORSPACE_V1_CHROMACITIES_DCI_P3] = WESTON_CS_DCI_P3,
[ZWP_COLORSPACE_V1_CHROMACITIES_PROPHOTORGB] = WESTON_CS_PROPHOTORGB,
[ZWP_COLORSPACE_V1_CHROMACITIES_CIERGB] = WESTON_CS_CIERGB,
[ZWP_COLORSPACE_V1_CHROMACITIES_AP0] = WESTON_CS_AP0,
[ZWP_COLORSPACE_V1_CHROMACITIES_AP1] = WESTON_CS_AP1,
};
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
surface->pending.colorspace = colorspace_names[chromacities];
}
static const struct zwp_colorspace_v1_interface
zwp_colorspace_implementation = {
.destroy = colorspace_destroy_request,
.set = colorspace_set_request,
};
static void
bind_colorspace(struct wl_client *client,
void *data, uint32_t version, uint32_t id)
{
struct weston_compositor *compositor = data;
struct wl_resource *resource;
resource = wl_resource_create(client, &zwp_colorspace_v1_interface,
version, id);
if (resource == NULL) {
wl_client_post_no_memory(client);
return;
}
wl_resource_set_implementation(resource, &zwp_colorspace_implementation,
compositor, NULL);
}
WL_EXPORT int
weston_colorspace_setup(struct weston_compositor *compositor)
{
if (!wl_global_create(compositor->wl_display,
&zwp_colorspace_v1_interface, 1,
compositor, bind_colorspace))
return -1;
return 0;
}
......@@ -7622,6 +7622,10 @@ drm_backend_create(struct weston_compositor *compositor,
weston_log("Error: initializing hdr metadata "
"support failed.\n");
if (weston_colorspace_setup(compositor) < 0)
weston_log("Error: initializing colorspace "
"support failed.\n");
ret = weston_plugin_api_register(compositor, WESTON_DRM_OUTPUT_API_NAME,
&api, sizeof(api));
......
......@@ -452,8 +452,8 @@ weston_surface_state_init(struct weston_surface_state *state)
state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
state->buffer_viewport.surface.width = -1;
state->buffer_viewport.changed = 0;
state->acquire_fence_fd = -1;
state->colorspace = WESTON_CS_BT709;
}
static void
......@@ -531,6 +531,7 @@ weston_surface_create(struct weston_compositor *compositor)
weston_matrix_init(&surface->buffer_to_surface_matrix);
weston_matrix_init(&surface->surface_to_buffer_matrix);
surface->colorspace = WESTON_CS_BT709;
wl_list_init(&surface->pointer_constraints);
......@@ -3385,6 +3386,8 @@ weston_surface_commit_state(struct weston_surface *surface,
surface->hdr_metadata = NULL;
}
surface->colorspace = state->colorspace;
wl_signal_emit(&surface->commit_signal, surface);
}
......
......@@ -28,6 +28,7 @@ srcs_libweston = [
'weston-debug.c',
'zoom.c',
'hdr_metadata.c',
'colorspace.c',
'../shared/matrix.c',
'../shared/colorspace.c',
linux_dmabuf_unstable_v1_protocol_c,
......@@ -58,6 +59,8 @@ srcs_libweston = [
weston_debug_server_protocol_h,
hdr_metadata_unstable_v1_protocol_c,
hdr_metadata_unstable_v1_server_protocol_h,
colorspace_unstable_v1_protocol_c,
colorspace_unstable_v1_server_protocol_h,
]
if get_option('renderer-gl')
......
......@@ -38,6 +38,7 @@ generated_protocols = [
[ 'xdg-shell', 'v6' ],
[ 'xdg-shell', 'stable' ],
[ 'hdr-metadata', 'v1' ],
[ 'colorspace', 'v1' ],
]
foreach proto: generated_protocols
......
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