Message ID | 20250724133343.353044-2-uajain@igalia.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Le jeudi 24 juillet 2025 à 19:03 +0530, Umang Jain a écrit : > Split the value_set_rectangle() GValue helper into further > helpers pertaining to libcamera::Point and libcamera::Size. > This would help to cover additional cases where helpers > are needed for Point and Size individually (in subsequent commits). > > The libcamera::Rectangle's GValue helper can be easily > constructed with the new Point and Size helpers. Hence, > this patch does not introduce any functional changes. > > Signed-off-by: Umang Jain <uajain@igalia.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> > --- > src/gstreamer/gstlibcamera-controls.cpp.in | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/src/gstreamer/gstlibcamera-controls.cpp.in > b/src/gstreamer/gstlibcamera-controls.cpp.in > index 2a16b39a..1bc781cc 100644 > --- a/src/gstreamer/gstlibcamera-controls.cpp.in > +++ b/src/gstreamer/gstlibcamera-controls.cpp.in > @@ -17,21 +17,21 @@ > > using namespace libcamera; > > -static void value_set_rectangle(GValue *value, const Rectangle &rect) > +static void value_set_point(GValue *value, const Point &point) > { > - Point top_left = rect.topLeft(); > - Size size = rect.size(); > - > GValue x = G_VALUE_INIT; > g_value_init(&x, G_TYPE_INT); > - g_value_set_int(&x, top_left.x); > + g_value_set_int(&x, point.x); > gst_value_array_append_and_take_value(value, &x); > > GValue y = G_VALUE_INIT; > g_value_init(&y, G_TYPE_INT); > - g_value_set_int(&y, top_left.y); > + g_value_set_int(&y, point.y); > gst_value_array_append_and_take_value(value, &y); > +} > > +static void value_set_size(GValue *value, const Size &size) > +{ > GValue width = G_VALUE_INIT; > g_value_init(&width, G_TYPE_INT); > g_value_set_int(&width, size.width); > @@ -43,6 +43,12 @@ static void value_set_rectangle(GValue *value, const > Rectangle &rect) > gst_value_array_append_and_take_value(value, &height); > } > > +static void value_set_rectangle(GValue *value, const Rectangle &rect) > +{ > + value_set_point(value, rect.topLeft()); > + value_set_size(value, rect.size()); > +} > + > static Rectangle value_get_rectangle(const GValue *value) > { > const GValue *r;
diff --git a/src/gstreamer/gstlibcamera-controls.cpp.in b/src/gstreamer/gstlibcamera-controls.cpp.in index 2a16b39a..1bc781cc 100644 --- a/src/gstreamer/gstlibcamera-controls.cpp.in +++ b/src/gstreamer/gstlibcamera-controls.cpp.in @@ -17,21 +17,21 @@ using namespace libcamera; -static void value_set_rectangle(GValue *value, const Rectangle &rect) +static void value_set_point(GValue *value, const Point &point) { - Point top_left = rect.topLeft(); - Size size = rect.size(); - GValue x = G_VALUE_INIT; g_value_init(&x, G_TYPE_INT); - g_value_set_int(&x, top_left.x); + g_value_set_int(&x, point.x); gst_value_array_append_and_take_value(value, &x); GValue y = G_VALUE_INIT; g_value_init(&y, G_TYPE_INT); - g_value_set_int(&y, top_left.y); + g_value_set_int(&y, point.y); gst_value_array_append_and_take_value(value, &y); +} +static void value_set_size(GValue *value, const Size &size) +{ GValue width = G_VALUE_INIT; g_value_init(&width, G_TYPE_INT); g_value_set_int(&width, size.width); @@ -43,6 +43,12 @@ static void value_set_rectangle(GValue *value, const Rectangle &rect) gst_value_array_append_and_take_value(value, &height); } +static void value_set_rectangle(GValue *value, const Rectangle &rect) +{ + value_set_point(value, rect.topLeft()); + value_set_size(value, rect.size()); +} + static Rectangle value_get_rectangle(const GValue *value) { const GValue *r;
Split the value_set_rectangle() GValue helper into further helpers pertaining to libcamera::Point and libcamera::Size. This would help to cover additional cases where helpers are needed for Point and Size individually (in subsequent commits). The libcamera::Rectangle's GValue helper can be easily constructed with the new Point and Size helpers. Hence, this patch does not introduce any functional changes. Signed-off-by: Umang Jain <uajain@igalia.com> --- src/gstreamer/gstlibcamera-controls.cpp.in | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)