gecko-dev/gfx/layers
Jamie Nicol 566512fb28 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 09:10:24 +00:00
..
apz Bug 1916897 - Get rid of ScrollDirection::eVertical from APZHandledResult::mOverscrollDirections if mayTriggerPullToRefresh is false. r=botond,geckoview-reviewers,owlish 2024-09-08 21:57:30 +00:00
client Bug 1899874: Plumb forceSoftwareRendering down the stack. r=jgilbert 2024-08-07 00:31:45 +00:00
composite Bug 1913568 - Add support for normalized UV coordinates to webrender. r=gfx-reviewers,nical 2024-09-09 09:10:23 +00:00
d3d11 Bug 1913568 - Add support for normalized UV coordinates to webrender. r=gfx-reviewers,nical 2024-09-09 09:10:23 +00:00
ipc Bug 1915228 - Remove expired telemetry scalars gfx.canvas.remote.activated and gfx.canvas.remote.deactivated_no_device, r=TravisLong. 2024-08-28 19:44:32 +00:00
layerviewer
opengl Bug 1913568 - Handle SurfaceTexture transforms in webrender, for reals this time. r=gfx-reviewers,media-playback-reviewers,padenot,nical 2024-09-09 09:10:24 +00:00
wr Bug 1913568 - Add support for normalized UV coordinates to webrender. r=gfx-reviewers,nical 2024-09-09 09:10:23 +00:00
AndroidHardwareBuffer.cpp
AndroidHardwareBuffer.h
AnimationHelper.cpp Bug 1626165 - Part 2: Replace the start value and start time of the transition on the compositor. r=layout-reviewers,firefox-animation-reviewers,hiro 2024-06-26 21:33:10 +00:00
AnimationHelper.h Bug 1626165 - Part 2: Replace the start value and start time of the transition on the compositor. r=layout-reviewers,firefox-animation-reviewers,hiro 2024-06-26 21:33:10 +00:00
AnimationInfo.cpp Bug 1626165 - Part 2: Replace the start value and start time of the transition on the compositor. r=layout-reviewers,firefox-animation-reviewers,hiro 2024-06-26 21:33:10 +00:00
AnimationInfo.h
AnimationStorageData.h
AtomicRefCountedWithFinalize.h
AxisPhysicsModel.cpp
AxisPhysicsModel.h Bug 1519636 - Reformat recent changes to the Google coding style r=emilio,necko-reviewers,geckoview-reviewers,application-update-reviewers,media-playback-reviewers,devtools-reviewers,anti-tracking-reviewers,profiler-reviewers,win-reviewers,migration-reviewers,padenot,mconley,nchevobbe,kershaw,gstoll,mstange,bytesized,m_kato 2024-07-17 11:15:31 +00:00
AxisPhysicsMSDModel.cpp
AxisPhysicsMSDModel.h
BSPTree.cpp
BSPTree.h
BufferTexture.cpp Bug 1906527 Part 1: Rename SurfaceFormat::YUV422 to YUY2, and rename YUV to YUV420. r=jgilbert 2024-08-05 17:59:15 +00:00
BufferTexture.h
BuildConstants.h
CanvasDrawEventRecorder.cpp Bug 1454819 - Simplify SharedMemory classes r=ipc-reviewers,nika 2024-08-06 18:16:08 +00:00
CanvasDrawEventRecorder.h Bug 1454819 - Simplify SharedMemory classes r=ipc-reviewers,nika 2024-08-06 18:16:08 +00:00
CanvasRenderer.cpp Bug 1898238 - Use SharedSurface_EGLImage for out-of-process webgl and accelerated canvas on Android. r=sotaro,jgilbert 2024-07-22 20:23:39 +00:00
CanvasRenderer.h Bug 1898238 - Use SharedSurface_EGLImage for out-of-process webgl and accelerated canvas on Android. r=sotaro,jgilbert 2024-07-22 20:23:39 +00:00
CompositionRecorder.cpp
CompositionRecorder.h
Compositor.cpp
Compositor.h
CompositorAnimationStorage.cpp Bug 1913090 - Remove unused mTransformInDevSpace member from AnimationTransform struct r=gregp,tnikkel 2024-08-16 20:14:46 +00:00
CompositorAnimationStorage.h Bug 1913090 - Remove unused mTransformInDevSpace member from AnimationTransform struct r=gregp,tnikkel 2024-08-16 20:14:46 +00:00
CompositorTypes.cpp
CompositorTypes.h Bug 1898142 - Deliver image usage type to WebRenderImageHost r=gfx-reviewers,lsalzman 2024-05-22 23:03:22 +00:00
D3D11ShareHandleImage.cpp
D3D11ShareHandleImage.h
D3D11TextureIMFSampleImage.cpp
D3D11TextureIMFSampleImage.h
D3D11YCbCrImage.cpp Bug 1906527 Part 1: Rename SurfaceFormat::YUV422 to YUY2, and rename YUV to YUV420. r=jgilbert 2024-08-05 17:59:15 +00:00
D3D11YCbCrImage.h Bug 1901928 - Remvoe D3D11YCbCrImage class r=gfx-reviewers,lsalzman 2024-06-12 16:40:32 +00:00
DcompSurfaceImage.cpp Bug 1913568 - Add support for normalized UV coordinates to webrender. r=gfx-reviewers,nical 2024-09-09 09:10:23 +00:00
DcompSurfaceImage.h Bug 1900677 - Add a capability to recycle DataSourceSurface allocated in CanvasTranslator::LookupSourceSurfaceFromSurfaceDescriptor() if possible r=gfx-reviewers,lsalzman 2024-06-06 03:25:53 +00:00
DirectionUtils.h
DMABUFSurfaceImage.cpp
DMABUFSurfaceImage.h
Effects.cpp
Effects.h Bug 1906527 Part 1: Rename SurfaceFormat::YUV422 to YUY2, and rename YUV to YUV420. r=jgilbert 2024-08-05 17:59:15 +00:00
FrameMetrics.cpp Bug 1902313 - Propagate overflow styles to APZ. r=hiro 2024-06-24 21:14:40 +00:00
FrameMetrics.h Bug 1902313 - Propagate overflow styles to APZ. r=hiro 2024-06-24 21:14:40 +00:00
GLImages.cpp
GLImages.h
GPUVideoImage.h
ImageContainer.cpp Bug 1907121 - Move YCbCrUtils API assertions to caller side r=gfx-reviewers,nical 2024-07-18 21:02:33 +00:00
ImageContainer.h Bug 1902157 - Change NVImage::SetData return type to nsresult r=media-playback-reviewers,padenot 2024-06-14 17:39:32 +00:00
ImageDataSerializer.cpp Bug 1906527 Part 1: Rename SurfaceFormat::YUV422 to YUY2, and rename YUV to YUV420. r=jgilbert 2024-08-05 17:59:15 +00:00
ImageDataSerializer.h
ImageTypes.h Bug 1901928 - Remvoe D3D11YCbCrImage class r=gfx-reviewers,lsalzman 2024-06-12 16:40:32 +00:00
IMFYCbCrImage.cpp
IMFYCbCrImage.h
IPDLActor.h
LayersTypes.cpp Bug 1901475 - Prevent to convert video from YUV to RGB if video is not updated in CanvasTranslator::LookupSourceSurfaceFromSurfaceDescriptor() r=gfx-reviewers,lsalzman 2024-06-11 04:19:40 +00:00
LayersTypes.h Bug 1910990 - Don't use ID3D11Query to wait for video copy complete for remote canvas. with AMD GPUs r=gfx-reviewers,lsalzman 2024-08-02 23:51:44 +00:00
LayerUserData.h
MacIOSurfaceHelpers.cpp Bug 1906527 Part 1: Rename SurfaceFormat::YUV422 to YUY2, and rename YUV to YUV420. r=jgilbert 2024-08-05 17:59:15 +00:00
MacIOSurfaceHelpers.h Bug 1900677 - Add a capability to recycle DataSourceSurface allocated in CanvasTranslator::LookupSourceSurfaceFromSurfaceDescriptor() if possible r=gfx-reviewers,lsalzman 2024-06-06 03:25:53 +00:00
MacIOSurfaceImage.cpp Bug 1906527 Part 3: Add YUV422P10 and NV16 formats. r=gfx-reviewers,ahale 2024-08-05 17:59:15 +00:00
MacIOSurfaceImage.h Bug 1906527 Part 3: Add YUV422P10 and NV16 formats. r=gfx-reviewers,ahale 2024-08-05 17:59:15 +00:00
MemoryPressureObserver.cpp
MemoryPressureObserver.h
moz.build Bug 1911971 - Use ID3D11VideoProcessor for color conversion in DXGITextureHostD3D11::GetAsSurfaceWithDevice() r=gfx-reviewers,lsalzman 2024-08-14 11:01:25 +00:00
NativeLayer.h
NativeLayerCA.h
NativeLayerCA.mm Bug 1914284: Make macOS use regular layers for video unless necessary for correctness or power savings. r=mac-reviewers,mstange 2024-08-29 05:14:10 +00:00
NativeLayerWayland.cpp
NativeLayerWayland.h
OOPCanvasRenderer.h
PersistentBufferProvider.cpp
PersistentBufferProvider.h
ProfilerScreenshots.cpp
ProfilerScreenshots.h
RecordedCanvasEventImpl.h Bug 1454819 - Simplify SharedMemory classes r=ipc-reviewers,nika 2024-08-06 18:16:08 +00:00
RemoteTextureMap.cpp Bug 1898238 - Keep SharedSurface_EGLImages alive but do not recycle them. r=sotaro,jgilbert 2024-07-22 20:23:38 +00:00
RemoteTextureMap.h Bug 1863257 - Remove sync wait in compositor thread of main thread canvas by RemoteTextureMap::WaitForRemoteTextureOwner() r=gfx-reviewers,lsalzman 2024-05-20 00:29:19 +00:00
RepaintRequest.cpp
RepaintRequest.h
SampleTime.cpp
SampleTime.h
ScreenshotGrabber.cpp
ScreenshotGrabber.h
ScrollableLayerGuid.cpp Bug 1893683 - Remove ns{A,C}String and other xpcom dependencies from nsStringBuffer. r=smaug,media-playback-reviewers,karlt 2024-05-09 08:34:35 +00:00
ScrollableLayerGuid.h
ScrollbarData.h
ShareableCanvasRenderer.cpp Bug 1899096 - Update FwdTransactionTracker::mFwdTransactionId in ShareableCanvasRenderer::UpdateCompositableClient() even when canvas is not dirty r=gfx-reviewers,lsalzman 2024-05-27 16:39:17 +00:00
ShareableCanvasRenderer.h
SourceSurfaceSharedData.cpp Bug 1454819 - Simplify SharedMemory classes r=ipc-reviewers,nika 2024-08-06 18:16:08 +00:00
SourceSurfaceSharedData.h Bug 1454819 - Simplify SharedMemory classes r=ipc-reviewers,nika 2024-08-06 18:16:08 +00:00
SurfacePool.h
SurfacePoolCA.h
SurfacePoolCA.mm
SurfacePoolWayland.cpp
SurfacePoolWayland.h
SyncObject.cpp
SyncObject.h
TextureSourceProvider.cpp
TextureSourceProvider.h
TextureWrapperImage.cpp
TextureWrapperImage.h
TransactionIdAllocator.h
TreeTraversal.h Bug 1519636 - Reformat recent changes to the Google coding style r=emilio,necko-reviewers,geckoview-reviewers,application-update-reviewers,media-playback-reviewers,devtools-reviewers,anti-tracking-reviewers,profiler-reviewers,win-reviewers,migration-reviewers,padenot,mconley,nchevobbe,kershaw,gstoll,mstange,bytesized,m_kato 2024-07-17 11:15:31 +00:00
UpdateImageHelper.h
ZoomConstraints.cpp
ZoomConstraints.h