[PATCH i-g-t 09/10] lib/igt_chamelium: Add chamelium_frame_eq_or_dump_frame_pair()
Swati Sharma
swati2.sharma at intel.com
Mon Apr 14 11:16:56 UTC 2025
Add chamelium_frame_eq_or_dump_frame_pair() to compare frame
dumps captured from chamelium. If they do not, this saves the
reference and captured frames to a png file. This function does
exact comparison.
Signed-off-by: Swati Sharma <swati2.sharma at intel.com>
---
lib/igt_chamelium.c | 38 ++++++++++++++++++++++++++++++++++++++
lib/igt_chamelium.h | 3 +++
2 files changed, 41 insertions(+)
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index a96e36b5b..463ba31ed 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -1893,6 +1893,44 @@ static void compared_frames_dump(cairo_surface_t *reference,
free(capture_suffix);
}
+/**
+ * chamelium_frame_eq_or_dump_frame_pair:
+ * @chamelium: The chamelium instance the frame dump belongs to
+ * @frame0: The chamelium frame dump to check
+ * @frame1: The chamelium frame dump to check
+ *
+ * Returns bool that the provided captured frame dumps are identical.
+ * If they do not, this saves the frames to a png file.
+ */
+bool chamelium_frame_eq_or_dump_frame_pair(const struct chamelium *chamelium,
+ const struct chamelium_frame_dump *frame0,
+ const struct chamelium_frame_dump *frame1)
+{
+ cairo_surface_t *reference;
+ cairo_surface_t *capture;
+ bool eq;
+
+ /* Grab the captured reference frame from chamelium */
+ reference = convert_frame_dump_argb32(frame0);
+
+ /* Grab the captured frame from chamelium */
+ capture = convert_frame_dump_argb32(frame1);
+
+ if (frame0->size != frame1->size)
+ return false;
+
+ /* Now do the actual comparison */
+ eq = memcmp(frame0->bgr, frame1->bgr, frame0->size) == 0;
+
+ if (!eq && igt_frame_dump_is_enabled())
+ compared_frames_dump(reference, capture, 0, 0);
+
+ cairo_surface_destroy(reference);
+ cairo_surface_destroy(capture);
+
+ return eq;
+}
+
/**
* chamelium_assert_frame_eq:
* @chamelium: The chamelium instance the frame dump belongs to
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index 8882e13fb..b5d13ddc8 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -262,6 +262,9 @@ bool chamelium_frame_match_or_dump_frame_pair(struct chamelium *chamelium,
const struct chamelium_frame_dump *frame0,
const struct chamelium_frame_dump *frame1,
enum chamelium_check check);
+bool chamelium_frame_eq_or_dump_frame_pair(const struct chamelium *chamelium,
+ const struct chamelium_frame_dump *frame0,
+ const struct chamelium_frame_dump *frame1);
void chamelium_crop_analog_frame(struct chamelium_frame_dump *dump, int width,
int height);
void chamelium_destroy_frame_dump(struct chamelium_frame_dump *dump);
--
2.25.1
More information about the igt-dev
mailing list