gecko-dev/gfx
Jamie Nicol 0c43a18e35 Bug 1913568 - Handle SurfaceTexture transforms in webrender, for reals this time. r=gfx-reviewers,media-playback-reviewers,padenot,nical
On Android, SurfaceTextures provide a transform that should be applied
to texture coordinates when sampling from the texture. Usually this is
simply a y-flip, but sometimes it includes a scale and slight
translation, eg when the video frame is contained within a larger
texture. Previously we ignored this transform but performed a y-flip,
meaning we rendered correctly most of the time, but not all of the
time.

Our first attempt to fix this was in bug 1731980. When rendering as a
compositor surface with RenderCompositorOGLSWGL, we supplied the
transform to CompositorOGL's shaders, which correctly fixed the bug
for this rendering path.

However, the attempted fix for hardware webrender in fact made things
worse. As UV coordinates are supplied to webrender unnormalized, then
the shaders normalize them by dividing by the actual texture size,
this effectively handled the scale component of the transform. (Though
not quite scaling by the correct amount, and ignoring the translation
component, sometimes resulting in a pixel-wide green seam being
visible at the video's edges.) When we additionally applied the
transformation to the coordinates, it resulted in the scale being
applied twice, and the video being rendered too far zoomed
in.

To make matters worse, when we received subsequent bug reports of
incorrect rendering on various devices we mistakenly assumed that the
devices must be buggy, rather than our code being incorrect. We
therefore reverted to ignoring the transform on these devices, thereby
breaking the software webrender path again.

Additionally, on devices without GL_OES_EGL_image_external_essl3
support, we must sample from the SurfaceTexture using an ESSL1
shader. This means we do not have access to the correct texture size,
meaning we cannot correctly normalize the UV coordinates. This results
in the video being rendered too far zoomed out. And in the
non-compositor-surface software webrender path, we were accidentally
downscaling the texture when reading back into a CPU buffer, resulting
in the video being rendered at the correct zoom, but being very
blurry.

This patch aims to handle the transform correctly, in all rendering
paths, hopefully once and for all.

For hardware webrender, we now supply the texture coordinates to
webrender already normalized, using the functionality added in the
previous patch. This avoids the shaders scaling the coordinates again,
or using an incorrect texture size to do so.

For RenderCompositorOGLSWGL, we continue to apply the transform using
CompositorOGL's shaders.

In the non-compositor-surface software webrender path, we make
GLReadPixelsHelper apply the transform when reading from the
SurfaceTexture in to the CPU buffer. Again using functionality added
earlier in this patch series. This avoids downscaling the image. We
can then provide the default untransformed and unnormalized UVs to
webrender. As a result we can now remove the virtual function
RenderTextureHost::GetUvCoords(), added in bug 1731980, as it no
longer serves any purpose: we no longer want to share the
implementation between RenderAndroidSurfaceTextureHost::Lock and
RenderTextureHostSWGL::LockSWGL.

Finally, we remove all transform overrides on the devices we
mistakenly assumed were buggy.

Differential Revision: https://phabricator.services.mozilla.com/D220582
2024-09-09 14:06:26 +00:00
..
2d Bug 1917156 - Implement RemoveAllClips for DrawTargetRecording. r=aosmond 2024-09-06 15:20:15 +00:00
angle Bug 1910306 - [angle] Cherry-pick zero-initialization of unwritten GLSL out params. r=gfx-reviewers,nical 2024-07-31 15:04:25 +00:00
cairo Bug 1909566 - pixman: Adjust arm assembly for binutils change. r=gfx-reviewers,lsalzman 2024-07-24 05:23:50 +00:00
config Bug 1901257 - Add a pref to control the threshold for slow cpu frames. r=gfx-reviewers,gw 2024-06-11 10:33:44 +00:00
docs
gl Bug 1913568 - Add texture transform support to GLReadTexImageHelper. r=gfx-reviewers,nical 2024-09-09 14:06:26 +00:00
graphite2 Bug 1893001 - Fall through to the lower block for Android builds. r=jfkthame 2024-07-23 17:02:39 +00:00
harfbuzz Bug 1914333 - Backport -fstrict-flex-arrays=2 support for harfbuzz r=gfx-reviewers,nical 2024-09-03 09:28:01 +00:00
ipc Bug 1908725 - Part 4: Switch some basic uses of OtherPid over to OtherChildID, r=smaug 2024-08-07 20:39:40 +00:00
layers Bug 1913568 - Handle SurfaceTexture transforms in webrender, for reals this time. r=gfx-reviewers,media-playback-reviewers,padenot,nical 2024-09-09 14:06:26 +00:00
ots Bug 1909426 - Vendor latest revision of OTS code from upstream. r=gfx-reviewers,lsalzman 2024-07-24 10:26:01 +00:00
qcms Bug 1915813 - Fix a crash with Microsoft TTD. r=gfx-reviewers,nical,jrmuizel 2024-09-09 09:00:48 +00:00
skia Bug 1909796 - Allow clip paths larger than int32. r=aosmond 2024-08-07 04:42:48 +00:00
src Bug 1914831 - Misc clean-ups to our DOMRect and rounding code. r=longsonr 2024-08-26 14:20:26 +00:00
tests Bug 1914345 Part 3 - Increase fuzziness for Android R-nofis r=emilio 2024-08-27 20:49:49 +00:00
thebes Bug 1915433 - Simplify CMS and gfxPlatform initialization. r=gfx-reviewers,bradwerth 2024-09-04 16:31:05 +00:00
vr Bug 1916919 - Don't include useless <iostream> in openvr r=emilio,glandium 2024-09-06 07:39:14 +00:00
webrender_bindings Bug 1913568 - Handle SurfaceTexture transforms in webrender, for reals this time. r=gfx-reviewers,media-playback-reviewers,padenot,nical 2024-09-09 14:06:26 +00:00
wgpu_bindings Bug 1917513 - Add a way to expose if webgpu::Adapter and webgpu::Device support ExternalTexture usage in SwapChain r=webgpu-reviewers,nical 2024-09-09 12:56:07 +00:00
wr Bug 1913568 - Add support for normalized UV coordinates to webrender. r=gfx-reviewers,nical 2024-09-09 14:06:26 +00:00
ycbcr Bug 1907121 - Return error for non-I444 Identity color space in ConvertYCbCrToRGB32 r=gfx-reviewers,nical 2024-07-18 21:02:34 +00:00
metrics.yaml
moz.build