weston/libweston
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
..
animation.c libweston: fix animation crash when a view has no output assigned 2016-08-12 13:28:30 +03:00
bindings.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
clipboard.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
compositor-drm.c compositor-drm: Stop sending uninit data to the kernel 2016-08-15 17:35:42 +02:00
compositor-drm.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
compositor-fbdev.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
compositor-fbdev.h include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
compositor-headless.c compositor-headless: Use non-cast functions to retrieve backend and output objects 2016-08-05 16:40:05 +03:00
compositor-headless.h include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
compositor-rdp.c libweston/compositor-rdp: fix no-break space U+A0 (U8+C2A0) 2016-08-15 16:09:26 +02:00
compositor-rdp.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
compositor-wayland.c compositor-wayland: Use non-cast functions to retrieve backend and output objects 2016-08-05 16:45:07 +03:00
compositor-wayland.h include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
compositor-x11.c compositor-x11: remove redundant state arg of x11_backend_deliver_button_event 2016-08-15 17:45:08 +02:00
compositor-x11.h include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
compositor.c libweston: Silence tautological-compare warning 2016-08-15 16:32:25 +02:00
compositor.h libweston-desktop: Implement xdg_shell_v6 2016-08-15 17:46:15 +08:00
data-device.c libweston: Rename weston_surface::configure to ::committed 2016-08-14 09:28:50 +02:00
dbus.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
dbus.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
gl-renderer.c gl-renderer, simple-dmabuf-v4l: fix dmabuf y-invert 2016-08-15 19:07:48 +02:00
gl-renderer.h include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
input.c libweston: Rename weston_surface::configure to ::committed 2016-08-14 09:28:50 +02:00
launcher-direct.c Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
launcher-impl.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
launcher-logind.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
launcher-util.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
launcher-util.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
launcher-weston-launch.c libweston/launcher-weston-launch: Silence unused-function warning 2016-08-15 16:33:42 +02:00
libbacklight.c Switch to use safe_strtoint instead of strtol 2016-08-06 18:19:22 -07:00
libbacklight.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
libinput-device.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
libinput-device.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
libinput-seat.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
libinput-seat.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
libweston.pc.in libweston: fix major in libweston.pc 2016-08-02 14:19:11 +03:00
linux-dmabuf.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
linux-dmabuf.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
log.c Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
noop-renderer.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
pixman-renderer.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
pixman-renderer.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
plugin-registry.c compositor: add plugin-registry 2016-07-01 14:10:26 +03:00
plugin-registry.h compositor: add plugin-registry 2016-07-01 14:10:26 +03:00
screenshooter.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
spring-tool.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00
timeline-object.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
timeline.c Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
timeline.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
vaapi-recorder.c Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
vaapi-recorder.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
version.h.in Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
vertex-clipping.c Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
vertex-clipping.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
weston-egl-ext.h weston-egl-ext.h: add EGL platform definitions 2016-07-22 15:29:18 +01:00
weston-launch.c weston-launch: Only run a login shell for new sessions 2016-08-15 16:58:23 +02:00
weston-launch.h Rename src/ to libweston/ 2016-06-23 17:44:54 +03:00
zoom.c include stdint.h for int32_t/uint32_t 2016-07-26 16:26:08 -07:00