mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-06-14 14:32:57 -04:00
output: add brightness state
This commit is contained in:
parent
15a378316e
commit
82d2cc7c23
3 changed files with 29 additions and 0 deletions
|
|
@ -78,6 +78,7 @@ enum wlr_output_state_field {
|
||||||
WLR_OUTPUT_STATE_COLOR_TRANSFORM = 1 << 12,
|
WLR_OUTPUT_STATE_COLOR_TRANSFORM = 1 << 12,
|
||||||
WLR_OUTPUT_STATE_IMAGE_DESCRIPTION = 1 << 13,
|
WLR_OUTPUT_STATE_IMAGE_DESCRIPTION = 1 << 13,
|
||||||
WLR_OUTPUT_STATE_COLOR_REPRESENTATION = 1 << 14,
|
WLR_OUTPUT_STATE_COLOR_REPRESENTATION = 1 << 14,
|
||||||
|
WLR_OUTPUT_STATE_BRIGHTNESS = 1 << 15,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum wlr_output_state_mode_type {
|
enum wlr_output_state_mode_type {
|
||||||
|
|
@ -165,6 +166,8 @@ struct wlr_output_state {
|
||||||
struct wlr_color_transform *color_transform;
|
struct wlr_color_transform *color_transform;
|
||||||
|
|
||||||
struct wlr_output_image_description *image_description;
|
struct wlr_output_image_description *image_description;
|
||||||
|
|
||||||
|
float brightness;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_output_impl;
|
struct wlr_output_impl;
|
||||||
|
|
@ -213,11 +216,14 @@ struct wlr_output {
|
||||||
enum wlr_color_encoding color_encoding;
|
enum wlr_color_encoding color_encoding;
|
||||||
enum wlr_color_range color_range;
|
enum wlr_color_range color_range;
|
||||||
const struct wlr_output_image_description *image_description;
|
const struct wlr_output_image_description *image_description;
|
||||||
|
float brightness;
|
||||||
|
|
||||||
// Indicates whether making changes to adaptive sync status is supported.
|
// Indicates whether making changes to adaptive sync status is supported.
|
||||||
// If false, changes to adaptive sync status is guaranteed to fail. If
|
// If false, changes to adaptive sync status is guaranteed to fail. If
|
||||||
// true, changes may either succeed or fail.
|
// true, changes may either succeed or fail.
|
||||||
bool adaptive_sync_supported;
|
bool adaptive_sync_supported;
|
||||||
|
// Indicates whether brightness changes are supported.
|
||||||
|
bool brightness_supported;
|
||||||
|
|
||||||
bool needs_frame;
|
bool needs_frame;
|
||||||
// damage for cursors and fullscreen surface, in output-local coordinates
|
// damage for cursors and fullscreen surface, in output-local coordinates
|
||||||
|
|
@ -632,6 +638,8 @@ void wlr_output_state_set_color_transform(struct wlr_output_state *state,
|
||||||
bool wlr_output_state_set_image_description(struct wlr_output_state *state,
|
bool wlr_output_state_set_image_description(struct wlr_output_state *state,
|
||||||
const struct wlr_output_image_description *image_desc);
|
const struct wlr_output_image_description *image_desc);
|
||||||
|
|
||||||
|
void wlr_output_state_set_brightness(struct wlr_output_state *state, float value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the color encoding and range of the primary scanout buffer.
|
* Set the color encoding and range of the primary scanout buffer.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,10 @@ static void output_apply_state(struct wlr_output *output,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state->committed & WLR_OUTPUT_STATE_BRIGHTNESS) {
|
||||||
|
output->brightness = state->brightness;
|
||||||
|
}
|
||||||
|
|
||||||
bool geometry_updated = state->committed &
|
bool geometry_updated = state->committed &
|
||||||
(WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_TRANSFORM |
|
(WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_TRANSFORM |
|
||||||
WLR_OUTPUT_STATE_SUBPIXEL);
|
WLR_OUTPUT_STATE_SUBPIXEL);
|
||||||
|
|
@ -359,6 +363,7 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
||||||
.render_format = DRM_FORMAT_XRGB8888,
|
.render_format = DRM_FORMAT_XRGB8888,
|
||||||
.transform = WL_OUTPUT_TRANSFORM_NORMAL,
|
.transform = WL_OUTPUT_TRANSFORM_NORMAL,
|
||||||
.scale = 1,
|
.scale = 1,
|
||||||
|
.brightness = 1,
|
||||||
.commit_seq = 0,
|
.commit_seq = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -590,6 +595,10 @@ static uint32_t output_compare_state(struct wlr_output *output,
|
||||||
output->color_range == state->color_range) {
|
output->color_range == state->color_range) {
|
||||||
fields |= WLR_OUTPUT_STATE_COLOR_REPRESENTATION;
|
fields |= WLR_OUTPUT_STATE_COLOR_REPRESENTATION;
|
||||||
}
|
}
|
||||||
|
if ((state->committed & WLR_OUTPUT_STATE_BRIGHTNESS) &&
|
||||||
|
output->brightness == state->brightness) {
|
||||||
|
fields |= WLR_OUTPUT_STATE_BRIGHTNESS;
|
||||||
|
}
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -687,6 +696,7 @@ static bool output_basic_test(struct wlr_output *output,
|
||||||
{ WLR_OUTPUT_STATE_SUBPIXEL, "subpixel" },
|
{ WLR_OUTPUT_STATE_SUBPIXEL, "subpixel" },
|
||||||
{ WLR_OUTPUT_STATE_COLOR_TRANSFORM, "color transform" },
|
{ WLR_OUTPUT_STATE_COLOR_TRANSFORM, "color transform" },
|
||||||
{ WLR_OUTPUT_STATE_IMAGE_DESCRIPTION, "image description" },
|
{ WLR_OUTPUT_STATE_IMAGE_DESCRIPTION, "image description" },
|
||||||
|
{ WLR_OUTPUT_STATE_BRIGHTNESS, "brightness" },
|
||||||
};
|
};
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
for (size_t i = 0; i < sizeof(needs_enabled) / sizeof(needs_enabled[0]); i++) {
|
for (size_t i = 0; i < sizeof(needs_enabled) / sizeof(needs_enabled[0]); i++) {
|
||||||
|
|
@ -726,6 +736,12 @@ static bool output_basic_test(struct wlr_output *output,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((state->committed & WLR_OUTPUT_STATE_BRIGHTNESS) &&
|
||||||
|
!output->brightness_supported) {
|
||||||
|
wlr_log(WLR_DEBUG, "Brightness is not supported for this output");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,11 @@ void wlr_output_state_set_color_encoding_and_range(
|
||||||
state->color_range = range;
|
state->color_range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_output_state_set_brightness(struct wlr_output_state *state, float value) {
|
||||||
|
state->committed |= WLR_OUTPUT_STATE_BRIGHTNESS;
|
||||||
|
state->brightness = value;
|
||||||
|
}
|
||||||
|
|
||||||
bool wlr_output_state_copy(struct wlr_output_state *dst,
|
bool wlr_output_state_copy(struct wlr_output_state *dst,
|
||||||
const struct wlr_output_state *src) {
|
const struct wlr_output_state *src) {
|
||||||
struct wlr_output_state copy = *src;
|
struct wlr_output_state copy = *src;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue