From f78c6603d2ddff1461ad626e38edc9803ca390b6 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Tue, 23 Jul 2024 16:58:05 +0800 Subject: [PATCH] backends/native: Add set/get_damage functions to MetaFrameNative (cherry picked from commit 90f5ce55a9b6a3addf82a32a0ea920aa5c969c07) Part-of: Signed-off-by: Mingi Sung --- src/backends/native/meta-frame-native.c | 31 +++++++++++++++++++++++++ src/backends/native/meta-frame-native.h | 9 +++++++ 2 files changed, 40 insertions(+) diff --git a/src/backends/native/meta-frame-native.c b/src/backends/native/meta-frame-native.c index 70461be32..8dc9dba9b 100644 --- a/src/backends/native/meta-frame-native.c +++ b/src/backends/native/meta-frame-native.c @@ -31,6 +31,11 @@ struct _MetaFrameNative CoglScanout *scanout; MetaKmsUpdate *kms_update; + + struct { + int n_rectangles; + int *rectangles; /* 4 x n_rectangles */ + } damage; }; static void @@ -38,6 +43,7 @@ meta_frame_native_release (ClutterFrame *frame) { MetaFrameNative *frame_native = meta_frame_native_from_frame (frame); + g_clear_pointer (&frame_native->damage.rectangles, g_free); g_clear_object (&frame_native->buffer); g_clear_object (&frame_native->scanout); @@ -108,3 +114,28 @@ meta_frame_native_get_scanout (MetaFrameNative *frame_native) { return frame_native->scanout; } + +void +meta_frame_native_set_damage (MetaFrameNative *frame_native, + const int *rectangles, + int n_rectangles) +{ + size_t rectangles_size; + + rectangles_size = n_rectangles * 4 * sizeof (int); + + frame_native->damage.rectangles = + g_realloc (frame_native->damage.rectangles, rectangles_size); + memcpy (frame_native->damage.rectangles, rectangles, rectangles_size); + frame_native->damage.n_rectangles = n_rectangles; +} + +int +meta_frame_native_get_damage (MetaFrameNative *frame_native, + int **rectangles) +{ + if (rectangles) + *rectangles = frame_native->damage.rectangles; + + return frame_native->damage.n_rectangles; +} diff --git a/src/backends/native/meta-frame-native.h b/src/backends/native/meta-frame-native.h index 3df4eff78..84bd43b8c 100644 --- a/src/backends/native/meta-frame-native.h +++ b/src/backends/native/meta-frame-native.h @@ -47,3 +47,12 @@ void meta_frame_native_set_scanout (MetaFrameNative *frame_native, CoglScanout *scanout); CoglScanout * meta_frame_native_get_scanout (MetaFrameNative *frame_native); + +void +meta_frame_native_set_damage (MetaFrameNative *frame_native, + const int *rectangles, + int n_rectangles); + +int +meta_frame_native_get_damage (MetaFrameNative *frame_native, + int **rectangles);