mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 04:45:58 +01:00
output: add wlr_output_state_set_gamma_lut()
This commit is contained in:
parent
6e635d2fd3
commit
5d5cf34486
3 changed files with 27 additions and 17 deletions
|
@ -571,6 +571,8 @@ void wlr_output_state_set_subpixel(struct wlr_output_state *state,
|
|||
enum wl_output_subpixel subpixel);
|
||||
void wlr_output_state_set_buffer(struct wlr_output_state *state,
|
||||
struct wlr_buffer *buffer);
|
||||
bool wlr_output_state_set_gamma_lut(struct wlr_output_state *state,
|
||||
size_t ramp_size, const uint16_t *r, const uint16_t *g, const uint16_t *b);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -945,23 +945,7 @@ void wlr_output_send_request_state(struct wlr_output *output,
|
|||
|
||||
void wlr_output_set_gamma(struct wlr_output *output, size_t size,
|
||||
const uint16_t *r, const uint16_t *g, const uint16_t *b) {
|
||||
uint16_t *gamma_lut = NULL;
|
||||
if (size > 0) {
|
||||
gamma_lut = malloc(3 * size * sizeof(uint16_t));
|
||||
if (gamma_lut == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return;
|
||||
}
|
||||
memcpy(gamma_lut, r, size * sizeof(uint16_t));
|
||||
memcpy(gamma_lut + size, g, size * sizeof(uint16_t));
|
||||
memcpy(gamma_lut + 2 * size, b, size * sizeof(uint16_t));
|
||||
}
|
||||
|
||||
output_state_clear_gamma_lut(&output->pending);
|
||||
|
||||
output->pending.gamma_lut_size = size;
|
||||
output->pending.gamma_lut = gamma_lut;
|
||||
output->pending.committed |= WLR_OUTPUT_STATE_GAMMA_LUT;
|
||||
wlr_output_state_set_gamma_lut(&output->pending, size, r, g, b);
|
||||
}
|
||||
|
||||
size_t wlr_output_get_gamma_size(struct wlr_output *output) {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "types/wlr_output.h"
|
||||
|
||||
void wlr_output_state_finish(struct wlr_output_state *state) {
|
||||
|
@ -73,3 +75,25 @@ void wlr_output_state_set_buffer(struct wlr_output_state *state,
|
|||
wlr_buffer_unlock(state->buffer);
|
||||
state->buffer = wlr_buffer_lock(buffer);
|
||||
}
|
||||
|
||||
bool wlr_output_state_set_gamma_lut(struct wlr_output_state *state,
|
||||
size_t ramp_size, const uint16_t *r, const uint16_t *g, const uint16_t *b) {
|
||||
uint16_t *gamma_lut = NULL;
|
||||
if (ramp_size > 0) {
|
||||
gamma_lut = realloc(state->gamma_lut, 3 * ramp_size * sizeof(uint16_t));
|
||||
if (gamma_lut == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return false;
|
||||
}
|
||||
memcpy(gamma_lut, r, ramp_size * sizeof(uint16_t));
|
||||
memcpy(gamma_lut + ramp_size, g, ramp_size * sizeof(uint16_t));
|
||||
memcpy(gamma_lut + 2 * ramp_size, b, ramp_size * sizeof(uint16_t));
|
||||
} else {
|
||||
free(state->gamma_lut);
|
||||
}
|
||||
|
||||
state->committed |= WLR_OUTPUT_STATE_GAMMA_LUT;
|
||||
state->gamma_lut_size = ramp_size;
|
||||
state->gamma_lut = gamma_lut;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue