mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
566512fb28
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 |
||
---|---|---|
.. | ||
apz | ||
client | ||
composite | ||
d3d11 | ||
ipc | ||
layerviewer | ||
opengl | ||
wr | ||
AndroidHardwareBuffer.cpp | ||
AndroidHardwareBuffer.h | ||
AnimationHelper.cpp | ||
AnimationHelper.h | ||
AnimationInfo.cpp | ||
AnimationInfo.h | ||
AnimationStorageData.h | ||
AtomicRefCountedWithFinalize.h | ||
AxisPhysicsModel.cpp | ||
AxisPhysicsModel.h | ||
AxisPhysicsMSDModel.cpp | ||
AxisPhysicsMSDModel.h | ||
BSPTree.cpp | ||
BSPTree.h | ||
BufferTexture.cpp | ||
BufferTexture.h | ||
BuildConstants.h | ||
CanvasDrawEventRecorder.cpp | ||
CanvasDrawEventRecorder.h | ||
CanvasRenderer.cpp | ||
CanvasRenderer.h | ||
CompositionRecorder.cpp | ||
CompositionRecorder.h | ||
Compositor.cpp | ||
Compositor.h | ||
CompositorAnimationStorage.cpp | ||
CompositorAnimationStorage.h | ||
CompositorTypes.cpp | ||
CompositorTypes.h | ||
D3D11ShareHandleImage.cpp | ||
D3D11ShareHandleImage.h | ||
D3D11TextureIMFSampleImage.cpp | ||
D3D11TextureIMFSampleImage.h | ||
D3D11YCbCrImage.cpp | ||
D3D11YCbCrImage.h | ||
DcompSurfaceImage.cpp | ||
DcompSurfaceImage.h | ||
DirectionUtils.h | ||
DMABUFSurfaceImage.cpp | ||
DMABUFSurfaceImage.h | ||
Effects.cpp | ||
Effects.h | ||
FrameMetrics.cpp | ||
FrameMetrics.h | ||
GLImages.cpp | ||
GLImages.h | ||
GPUVideoImage.h | ||
ImageContainer.cpp | ||
ImageContainer.h | ||
ImageDataSerializer.cpp | ||
ImageDataSerializer.h | ||
ImageTypes.h | ||
IMFYCbCrImage.cpp | ||
IMFYCbCrImage.h | ||
IPDLActor.h | ||
LayersTypes.cpp | ||
LayersTypes.h | ||
LayerUserData.h | ||
MacIOSurfaceHelpers.cpp | ||
MacIOSurfaceHelpers.h | ||
MacIOSurfaceImage.cpp | ||
MacIOSurfaceImage.h | ||
MemoryPressureObserver.cpp | ||
MemoryPressureObserver.h | ||
moz.build | ||
NativeLayer.h | ||
NativeLayerCA.h | ||
NativeLayerCA.mm | ||
NativeLayerWayland.cpp | ||
NativeLayerWayland.h | ||
OOPCanvasRenderer.h | ||
PersistentBufferProvider.cpp | ||
PersistentBufferProvider.h | ||
ProfilerScreenshots.cpp | ||
ProfilerScreenshots.h | ||
RecordedCanvasEventImpl.h | ||
RemoteTextureMap.cpp | ||
RemoteTextureMap.h | ||
RepaintRequest.cpp | ||
RepaintRequest.h | ||
SampleTime.cpp | ||
SampleTime.h | ||
ScreenshotGrabber.cpp | ||
ScreenshotGrabber.h | ||
ScrollableLayerGuid.cpp | ||
ScrollableLayerGuid.h | ||
ScrollbarData.h | ||
ShareableCanvasRenderer.cpp | ||
ShareableCanvasRenderer.h | ||
SourceSurfaceSharedData.cpp | ||
SourceSurfaceSharedData.h | ||
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 | ||
UpdateImageHelper.h | ||
ZoomConstraints.cpp | ||
ZoomConstraints.h |