mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-07 04:58:16 +02:00
libweston: add weston_color_gamut_from_protocol()
Reduce 4 copies of a piece of code into one. Usable for both client and server side. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
71594a97f8
commit
bf513a362a
4 changed files with 42 additions and 32 deletions
|
|
@ -142,6 +142,13 @@ struct weston_color_gamut {
|
|||
struct weston_CIExy white_point;
|
||||
};
|
||||
|
||||
void
|
||||
weston_color_gamut_from_protocol(struct weston_color_gamut *dst,
|
||||
int32_t r_x, int32_t r_y,
|
||||
int32_t g_x, int32_t g_y,
|
||||
int32_t b_x, int32_t b_y,
|
||||
int32_t w_x, int32_t w_y);
|
||||
|
||||
enum weston_npm_direction {
|
||||
WESTON_NPM_FORWARD,
|
||||
WESTON_NPM_INVERSE
|
||||
|
|
|
|||
|
|
@ -1342,14 +1342,7 @@ cm_creator_params_set_primaries(struct wl_client *client, struct wl_resource *re
|
|||
wl_resource_get_user_data(resource);
|
||||
struct weston_color_gamut primaries;
|
||||
|
||||
primaries.primary[0].x = r_x / 1000000.0f;
|
||||
primaries.primary[0].y = r_y / 1000000.0f;
|
||||
primaries.primary[1].x = g_x / 1000000.0f;
|
||||
primaries.primary[1].y = g_y / 1000000.0f;
|
||||
primaries.primary[2].x = b_x / 1000000.0f;
|
||||
primaries.primary[2].y = b_y / 1000000.0f;
|
||||
primaries.white_point.x = w_x / 1000000.0f;
|
||||
primaries.white_point.y = w_y / 1000000.0f;
|
||||
weston_color_gamut_from_protocol(&primaries, r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y);
|
||||
|
||||
if (!weston_color_profile_param_builder_set_primaries(cm_creator_params->builder,
|
||||
&primaries))
|
||||
|
|
@ -1433,14 +1426,7 @@ cm_creator_params_set_mastering_display_primaries(struct wl_client *client,
|
|||
wl_resource_get_user_data(resource);
|
||||
struct weston_color_gamut primaries;
|
||||
|
||||
primaries.primary[0].x = r_x / 1000000.0f;
|
||||
primaries.primary[0].y = r_y / 1000000.0f;
|
||||
primaries.primary[1].x = g_x / 1000000.0f;
|
||||
primaries.primary[1].y = g_y / 1000000.0f;
|
||||
primaries.primary[2].x = b_x / 1000000.0f;
|
||||
primaries.primary[2].y = b_y / 1000000.0f;
|
||||
primaries.white_point.x = w_x / 1000000.0f;
|
||||
primaries.white_point.y = w_y / 1000000.0f;
|
||||
weston_color_gamut_from_protocol(&primaries, r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y);
|
||||
|
||||
if (!weston_color_profile_param_builder_set_target_primaries(cm_creator_params->builder,
|
||||
&primaries))
|
||||
|
|
|
|||
|
|
@ -145,6 +145,36 @@ weston_color_profile_init(struct weston_color_profile *cprof,
|
|||
cprof->id = weston_idalloc_get_id(cm->compositor->color_profile_id_generator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize gamut from protocol integer-encoded values
|
||||
*
|
||||
* The color_management_v1 Wayland protocol encodes colorimetric coordinates
|
||||
* into integers by multiplying them with one million. This function does the
|
||||
* decoding.
|
||||
*
|
||||
* \param[out] dst Gamut record to initialize.
|
||||
* \param r_x,r_y Red primary
|
||||
* \param g_x,g_y Green primary
|
||||
* \param b_x,b_y Blue primary
|
||||
* \param w_x,w_y White point
|
||||
*/
|
||||
WL_EXPORT void
|
||||
weston_color_gamut_from_protocol(struct weston_color_gamut *dst,
|
||||
int32_t r_x, int32_t r_y,
|
||||
int32_t g_x, int32_t g_y,
|
||||
int32_t b_x, int32_t b_y,
|
||||
int32_t w_x, int32_t w_y)
|
||||
{
|
||||
dst->primary[0].x = r_x / 1000000.0f;
|
||||
dst->primary[0].y = r_y / 1000000.0f;
|
||||
dst->primary[1].x = g_x / 1000000.0f;
|
||||
dst->primary[1].y = g_y / 1000000.0f;
|
||||
dst->primary[2].x = b_x / 1000000.0f;
|
||||
dst->primary[2].y = b_y / 1000000.0f;
|
||||
dst->white_point.x = w_x / 1000000.0f;
|
||||
dst->white_point.y = w_y / 1000000.0f;
|
||||
}
|
||||
|
||||
static void
|
||||
weston_color_gamut_fprint(FILE *fp,
|
||||
const char *indent,
|
||||
|
|
|
|||
|
|
@ -319,14 +319,7 @@ image_descr_info_primaries(void *data,
|
|||
|
||||
image_descr_info_received(info, IMAGE_DESCR_INFO_EVENT_PRIMARIES);
|
||||
|
||||
info->primaries.primary[0].x = r_x / 1000000.0f;
|
||||
info->primaries.primary[0].y = r_y / 1000000.0f;
|
||||
info->primaries.primary[1].x = g_x / 1000000.0f;
|
||||
info->primaries.primary[1].y = g_y / 1000000.0f;
|
||||
info->primaries.primary[2].x = b_x / 1000000.0f;
|
||||
info->primaries.primary[2].y = b_y / 1000000.0f;
|
||||
info->primaries.white_point.x = w_x / 1000000.0f;
|
||||
info->primaries.white_point.y = w_y / 1000000.0f;
|
||||
weston_color_gamut_from_protocol(&info->primaries, r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -386,14 +379,8 @@ image_descr_info_target_primaries(void *data,
|
|||
|
||||
image_descr_info_received(info, IMAGE_DESCR_INFO_EVENT_TARGET_PRIMARIES);
|
||||
|
||||
info->target_primaries.primary[0].x = r_x / 1000000.0f;
|
||||
info->target_primaries.primary[0].y = r_y / 1000000.0f;
|
||||
info->target_primaries.primary[1].x = g_x / 1000000.0f;
|
||||
info->target_primaries.primary[1].y = g_y / 1000000.0f;
|
||||
info->target_primaries.primary[2].x = b_x / 1000000.0f;
|
||||
info->target_primaries.primary[2].y = b_y / 1000000.0f;
|
||||
info->target_primaries.white_point.x = w_x / 1000000.0f;
|
||||
info->target_primaries.white_point.y = w_y / 1000000.0f;
|
||||
weston_color_gamut_from_protocol(&info->target_primaries,
|
||||
r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue