weston/clients
Pekka Paalanen 319397e050
gl-renderer, simple-dmabuf-v4l: fix dmabuf y-invert
Invert the Y_INVERT flag for the EGL import fo dmabufs. This fixes
weston-simple-dmabuf-intel to show the same image on both GL-composited
and with direct scanout on a hardware plane. Before, the image would
y-flip when switching between these two cases. Now the orientation also
matches the color values written in simple-dmabuf-intel.c.

The GL-renderer uses the OpenGL convention of texture coordinates, where
the origin is at the bottom-left of an image. This can be observed in
texture_region() where the texcoords are inverted if y_invert is false,
since the surface coordinates have origin at top-left.  Both wl_shm and
dmabuf buffers have origin at the top-left.

When wl_shm buffer is imported with glTexImage2D, it gets inverted
because glTexImage2D is defined to read in the bottom row first. The shm
data is top row first. This incidentally also means, that buffer pixel
0,0 ends up at texture coordinates 0,0. This is now inverted compared to
the GL coordinate convention, and therefore gl_renderer_attach_shm()
sets y_inverted to true. This causes texture_region() to NOT invert the
texcoords. Wayland surface coordinates have origin at top-left, hence
the double-inversion.

Dmabuf buffers also have the origin at top-left. However, they are
imported via EGL to GL, where they should get the GL oriented
coordinates but they do not. It is as if pixel 0,0 ends up at texcoords
0,0 - the same thing as with wl_shm buffers. Therefore we need to invert
the invert flag.

Too bad EGL_EXT_image_dma_buf_import does not seem to specify the image
orientation. The GL spec implied result seems to conflict with the
reality in Mesa 11.2.2.

I asked about this in the Mesa developer mailing list. The question with
no answers:
https://lists.freedesktop.org/archives/mesa-dev/2016-June/120249.html
and the thread I hijacked to get some answers:
https://lists.freedesktop.org/archives/mesa-dev/2016-June/120733.html
which culminated to the conclusion:
https://lists.freedesktop.org/archives/mesa-dev/2016-June/120955.html
that supports this patch.

simple-dmabuf-v4l is equally fixed to not add Y_INVERT. There is no
rational reason to have it, and removing is necessary together with the
GL-renderer change to keep the image the right way up. This has been
tested with VIVID.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-08-15 19:07:48 +02:00
..
calibrator.c Moved helper macro to a discrete include file. 2015-06-15 17:11:45 -07:00
clickdot.c clients & tests: Unify multiple definitions of x*alloc and related functions 2016-03-17 14:13:13 +02:00
cliptest.c Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
confine.c clients/confine: Toggle maximized state with 'm' 2016-07-26 17:21:15 +08:00
desktop-shell.c config-parser: Add weston_config_section_get_color 2016-07-26 15:57:14 -07:00
dnd.c clients & tests: Unify multiple definitions of x*alloc and related functions 2016-03-17 14:13:13 +02:00
editor.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
eventdemo.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
flower.c client: fix spelling mistake 2016-04-05 16:00:21 -07:00
fullscreen.c clients: Use zalloc 2016-03-09 22:54:54 -08:00
gears.c
image.c cosmetic: Remove a few double semicolons 2015-10-07 11:22:03 -07:00
ivi-shell-user-interface.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
keyboard.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
multi-resource.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
nested-client.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
nested.c clients/nested: use weston_check_egl_extension over strstr 2016-07-22 15:29:04 +01:00
presentation-shm.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
resizor.c clients/resizor: Use pointer locking for resizing window 2016-07-26 17:21:15 +08:00
scaler.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
screenshot.c clients & tests: Unify multiple definitions of x*alloc and related functions 2016-03-17 14:13:13 +02:00
simple-damage.c clients/simple-damage: Port to xdg_shell unstable v6 2016-08-15 20:15:58 +08:00
simple-dmabuf-intel.c clients/simple-dmabuf-intel: Port to xdg_shell unstable v6 2016-08-15 20:15:58 +08:00
simple-dmabuf-v4l.c gl-renderer, simple-dmabuf-v4l: fix dmabuf y-invert 2016-08-15 19:07:48 +02:00
simple-egl.c clients/simple-egl: Port to xdg_shell unstable v6 2016-08-15 20:15:58 +08:00
simple-shm.c clients/simple-shm: Port to xdg_shell unstable v6 2016-08-15 20:15:58 +08:00
simple-touch.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
smoke.c client: fix spelling mistake 2016-04-05 16:00:21 -07:00
stacking.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
subsurfaces.c clients & tests: Unify multiple definitions of x*alloc and related functions 2016-03-17 14:13:13 +02:00
terminal.c terminal: Document console codes less cryptically 2016-06-16 11:10:35 -07:00
transformed.c
weston-info.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
weston-simple-im.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
window.c toytoolkit: Port to xdg_shell unstable v6 2016-08-15 20:15:58 +08:00
window.h include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00