mirror of
https://github.com/yshui/picom.git
synced 2025-03-17 17:24:25 -04:00
backend: xrender: implement read_pixel
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
1ada765436
commit
d9c9742132
2 changed files with 27 additions and 1 deletions
|
@ -16,4 +16,6 @@ AnalyzeTemporaryDtors: false
|
|||
FormatStyle: file
|
||||
CheckOptions:
|
||||
- key: readability-magic-numbers.IgnoredIntegerValues
|
||||
value: 4;8;16;24;32;1;2;3;4096;65536
|
||||
value: 4;8;16;24;32;1;2;3;4096;65536;
|
||||
- key: readability-magic-numbers.IgnoredFloatingPointValues
|
||||
value: 255.0;
|
||||
|
|
|
@ -559,6 +559,29 @@ static void get_blur_size(void *blur_context, int *width, int *height) {
|
|||
*height = ctx->resize_height;
|
||||
}
|
||||
|
||||
static bool
|
||||
read_pixel(backend_t *backend_data, void *image_data, int x, int y, struct color *output) {
|
||||
auto xd = (struct _xrender_data *)backend_data;
|
||||
auto img = (struct _xrender_image_data *)image_data;
|
||||
|
||||
auto r = XCB_AWAIT(xcb_get_image, xd->base.c, XCB_IMAGE_FORMAT_XY_PIXMAP, img->pixmap,
|
||||
to_i16_checked(x), to_i16_checked(y), 1, 1, (uint32_t)-1L);
|
||||
|
||||
if (!r) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Color format seems to be BGRA8888, see glamor_format_for_pixmap from the
|
||||
// Xserver codebase.
|
||||
uint8_t *pixels = xcb_get_image_data(r);
|
||||
output->blue = pixels[0] / 255.0;
|
||||
output->green = pixels[1] / 255.0;
|
||||
output->red = pixels[2] / 255.0;
|
||||
output->alpha = pixels[3] / 255.0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static backend_t *backend_xrender_init(session_t *ps) {
|
||||
auto xd = ccalloc(1, struct _xrender_data);
|
||||
init_backend_base(&xd->base, ps);
|
||||
|
@ -655,6 +678,7 @@ struct backend_operations xrender_ops = {
|
|||
.max_buffer_age = 2,
|
||||
|
||||
.image_op = image_op,
|
||||
.read_pixel = read_pixel,
|
||||
.copy = copy,
|
||||
.create_blur_context = create_blur_context,
|
||||
.destroy_blur_context = destroy_blur_context,
|
||||
|
|
Loading…
Add table
Reference in a new issue