From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 1/2] lib/igt_fb: Use cairo conversion in igt_fb_convert_with_stride, v3.
Date: Fri, 10 May 2019 14:33:48 +0200 [thread overview]
Message-ID: <20190510123349.5072-1-maarten.lankhorst@linux.intel.com> (raw)
Ever since commit 3fa65f4b532bd9a5b ("fb: Add support for conversions
through pixman") we can generate a valid cairo surface for any plane,
use this to avoid having to implement our own conversion routine.
Instead of duplicating this functionality in igt_fb_convert_with_stride,
we can simply convert this to a few cairo calls, because we now support
cairo calls to any of the supported framebuffer formats.
This is required to make this function more generic, and convert from any
format/modifier to any other format/modifier.
Changes since v1:
- Return fb_id in the cairo case.
Changes since v2:
- Remove the manual conversion fallback.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
lib/igt_fb.c | 59 +++++++++++-----------------------------------------
1 file changed, 12 insertions(+), 47 deletions(-)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index d4929019971c..d7ccbc19b834 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -3102,58 +3102,23 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
uint64_t dst_modifier,
unsigned int dst_stride)
{
- struct fb_convert cvt = { };
- struct igt_fb linear;
- void *dst_ptr, *src_ptr;
- uint64_t base_modifier;
+ /* Use the cairo api to convert */
+ cairo_surface_t *surf = igt_get_cairo_surface(src->fd, src);
+ cairo_t *cr;
int fb_id;
- if (is_vc4_device(src->fd))
- base_modifier = fourcc_mod_broadcom_mod(dst_modifier);
- else
- base_modifier = dst_modifier;
-
- fb_id = igt_create_fb_with_bo_size(src->fd, src->width, src->height,
- dst_fourcc,
- LOCAL_DRM_FORMAT_MOD_NONE, &linear,
- 0, dst_stride);
+ fb_id = igt_create_fb_with_bo_size(src->fd, src->width,
+ src->height, dst_fourcc,
+ dst_modifier, dst, 0,
+ dst_stride);
igt_assert(fb_id > 0);
- src_ptr = igt_fb_map_buffer(src->fd, src);
- igt_assert(src_ptr);
-
- dst_ptr = igt_fb_map_buffer(linear.fd, &linear);
- igt_assert(dst_ptr);
-
- cvt.dst.ptr = dst_ptr;
- cvt.dst.fb = &linear;
- cvt.src.ptr = src_ptr;
- cvt.src.fb = src;
- fb_convert(&cvt);
-
- igt_fb_unmap_buffer(dst, dst_ptr);
- igt_fb_unmap_buffer(src, src_ptr);
-
- switch (base_modifier) {
- case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED:
- fb_id = igt_vc4_fb_t_tiled_convert(dst, &linear);
- break;
- case DRM_FORMAT_MOD_BROADCOM_SAND32:
- case DRM_FORMAT_MOD_BROADCOM_SAND64:
- case DRM_FORMAT_MOD_BROADCOM_SAND128:
- case DRM_FORMAT_MOD_BROADCOM_SAND256:
- fb_id = vc4_fb_sand_tiled_convert(dst, &linear, dst_modifier);
- break;
- default:
- igt_assert(dst_modifier == LOCAL_DRM_FORMAT_MOD_NONE);
- }
-
- igt_assert(fb_id > 0);
+ cr = igt_get_cairo_ctx(dst->fd, dst);
+ cairo_set_source_surface(cr, surf, 0, 0);
+ cairo_paint(cr);
+ igt_put_cairo_ctx(dst->fd, dst, cr);
- if (dst_modifier == LOCAL_DRM_FORMAT_MOD_NONE)
- *dst = linear;
- else
- igt_remove_fb(linear.fd, &linear);
+ cairo_surface_destroy(surf);
return fb_id;
}
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2019-05-10 12:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-10 12:33 Maarten Lankhorst [this message]
2019-05-10 12:33 ` [igt-dev] [PATCH i-g-t 2/2] tests/kms_chamelium: Fix *-cmp-random and *-crc-random tests, v4 Maarten Lankhorst
2019-05-10 13:08 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib/igt_fb: Use cairo conversion in igt_fb_convert_with_stride, v3 Patchwork
2019-05-10 13:43 ` [igt-dev] [PATCH i-g-t 1/2] " Paul Kocialkowski
2019-05-10 14:19 ` Maarten Lankhorst
2019-05-10 15:10 ` Paul Kocialkowski
2019-05-10 16:02 ` Maarten Lankhorst
2019-05-14 6:34 ` Juha-Pekka Heikkila
2019-05-16 12:59 ` Maarten Lankhorst
2019-05-10 15:01 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/2] " Patchwork
2019-05-10 16:36 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib/igt_fb: Use cairo conversion in igt_fb_convert_with_stride, v3. (rev2) Patchwork
2019-05-10 19:05 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2019-04-05 12:52 [igt-dev] [PATCH i-g-t 1/2] lib/igt_fb: Use cairo conversion in igt_fb_convert_with_stride, v3 Maarten Lankhorst
2019-04-05 13:54 ` Paul Kocialkowski
2019-04-05 15:38 ` Maarten Lankhorst
2019-04-08 8:50 ` Maxime Ripard
2019-04-08 11:04 ` Maarten Lankhorst
2019-04-09 14:59 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190510123349.5072-1-maarten.lankhorst@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox