Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8ba6cece950097ec28e13e6cb79fd8049e0efee4
https://github.com/WebKit/WebKit/commit/8ba6cece950097ec28e13e6cb79fd8049e0efee4
Author: Nikolas Zimmermann <[email protected]>
Date: 2025-12-23 (Tue, 23 Dec 2025)
Changed paths:
M Source/WebCore/platform/graphics/ImageBuffer.cpp
M Source/WebCore/platform/graphics/NativeImage.cpp
M Source/WebCore/platform/graphics/NativeImage.h
M Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp
M Source/WebCore/platform/graphics/skia/GraphicsContextGLSkia.cpp
M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h
M
Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.cpp
M Source/WebCore/platform/graphics/skia/ImageBufferUtilitiesSkia.cpp
M Source/WebCore/platform/graphics/skia/ImageBufferUtilitiesSkia.h
M Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp
M
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedPlatformLayerBufferNativeImage.cpp
M
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTileBuffer.cpp
Log Message:
-----------
[Skia] Fix GrDirectContext management for GPU resources
https://bugs.webkit.org/show_bug.cgi?id=304568
Reviewed by Carlos Garcia Campos.
WebKit stores GrDirectContext instances in thread_local statics within
PlatformDisplay. Operations on GPU-backed resources must use the context
that created them, not the current thread's context obtained via
PlatformDisplay::sharedDisplay().skiaGrContext().
The GL contexts used are sharing contexts, also stored in thread_local
statics. Therefore we can safely make the current thread's GL context
current before flushing with the correct GrDirectContext.
For NativeImage, store the GrDirectContext at creation time and access
it via grContext(). The following places previously used the shared
display's context incorrectly:
- GraphicsContextGLSkia::extractImage() for readPixels on texture-backed images
- VideoFrameGStreamer::fromNativeImage() for readPixels
- NativeImageSkia::singlePixelSolidColor() for readPixels
- ImageBufferUtilitiesSkia::encodeAcceleratedImage() for encoding
- CoordinatedPlatformLayerBufferNativeImage for flushAndSubmit
Storing a pointer to GrDirectContext is safe, as the GrDirectContext lives
as long as PlatformDisplay::clearGLContexts() is called, which only happens
upon process destruction for the Gtk/WPE ports.
For SkSurface, use surface->recordingContext()->asDirectContext() to
obtain the surface's own context. The following places previously used
the shared display's context incorrectly:
- ImageBufferSkiaAcceleratedBackend::createNativeImageReference() for flush
- CoordinatedTileBuffer::completePainting() for flushAndSubmit
Note: When checking a SkImage for validity to decide if we need texture
rewrapping, we need to use the destination context (from current thread)
not the source image's context.
Covered by existing tests (when run with SKIA_DEBUG=ON builds).
We cannot yet turn on SKIA_DEBUG in our debug builds, as there are other
kind of assertions that need to be fixed first.
* Source/WebCore/platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::toData):
* Source/WebCore/platform/graphics/NativeImage.cpp:
* Source/WebCore/platform/graphics/NativeImage.h:
(WebCore::NativeImage::grContext const):
* Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp:
(WebCore::VideoFrame::fromNativeImage):
* Source/WebCore/platform/graphics/skia/GraphicsContextGLSkia.cpp:
(WebCore::GraphicsContextGLImageExtractor::extractImage):
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContextSkia::drawNativeImage):
(WebCore::GraphicsContextSkia::setupFillSource):
(WebCore::GraphicsContextSkia::setupStrokeSource):
(WebCore::GraphicsContextSkia::clipToImageBuffer):
(WebCore::GraphicsContextSkia::drawPattern):
(WebCore::createFenceAfterFlush):
(WebCore::GraphicsContextSkia::createAcceleratedRenderingFence):
(WebCore::GraphicsContextSkia::trackAcceleratedRenderingFenceIfNeeded):
(WebCore::createAcceleratedRenderingFenceInternal): Deleted.
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h:
* Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.cpp:
(WebCore::ImageBufferSkiaAcceleratedBackend::createNativeImageReference):
* Source/WebCore/platform/graphics/skia/ImageBufferUtilitiesSkia.cpp:
(WebCore::encodeAcceleratedImage):
(WebCore::encodeData):
* Source/WebCore/platform/graphics/skia/ImageBufferUtilitiesSkia.h:
* Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp:
(WebCore::NativeImage::create):
(WebCore::NativeImage::createTransient):
(WebCore::NativeImage::NativeImage):
(WebCore::NativeImage::singlePixelSolidColor const):
*
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedPlatformLayerBufferNativeImage.cpp:
(WebCore::CoordinatedPlatformLayerBufferNativeImage::CoordinatedPlatformLayerBufferNativeImage):
* Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTileBuffer.cpp:
(WebCore::CoordinatedAcceleratedTileBuffer::completePainting):
Canonical link: https://commits.webkit.org/304898@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications