Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 67526aee79823a036158c5b198798d2ac4b01c7d
https://github.com/WebKit/WebKit/commit/67526aee79823a036158c5b198798d2ac4b01c7d
Author: Nikolas Zimmermann <[email protected]>
Date: 2026-02-24 (Tue, 24 Feb 2026)
Changed paths:
M Source/WebCore/platform/Skia.cmake
M Source/WebCore/platform/SourcesSkia.txt
M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h
M
Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.cpp
A Source/WebCore/platform/graphics/skia/SkiaImageAtlasLayout.cpp
A Source/WebCore/platform/graphics/skia/SkiaImageAtlasLayout.h
A Source/WebCore/platform/graphics/skia/SkiaImageAtlasLayoutBuilder.cpp
A Source/WebCore/platform/graphics/skia/SkiaImageAtlasLayoutBuilder.h
M Source/WebCore/platform/graphics/skia/SkiaPaintingEngine.cpp
M Source/WebCore/platform/graphics/skia/SkiaRecordingResult.cpp
M Source/WebCore/platform/graphics/skia/SkiaRecordingResult.h
Log Message:
-----------
[GTK][WPE] Add texture atlas layout computation for batching raster image
uploads
https://bugs.webkit.org/show_bug.cgi?id=306901
Reviewed by Carlos Garcia Campos.
During Skia canvas recording, raster (non-GPU backed) images drawn via
drawNativeImage() are now collected by a new SkiaImageAtlasLayoutBuilder.
When recording ends, the builder computes optimal packing layouts that
group multiple small-to-medium raster images (8x8 to 512x512) into
shared atlas textures (up to 4096x4096). This precomputed layout is
stored as SkiaImageAtlasLayout objects in the recording result. In
future this will be used to batch individual texture uploads into fewer,
larger GPU texture transfers.
The packing uses SkiaTextureAtlasPacker with both MaxRects and ShelfNextFit
algorithms, selecting whichever produces a tighter bounding box. When
all images don't fit in a single atlas, multiple ones are created.
SkiaImageAtlasLayout is ThreadSafeRefCounted and read-only after creation,
allowing it to be shared across worker threads during parallel replay
without synchronization. It stores the computed atlas dimensions and the
mapping of each raster SkImage to its rectangle within the atlas.
Not testable yet, still preparing.
* Source/WebCore/platform/Skia.cmake:
* Source/WebCore/platform/SourcesSkia.txt:
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContextSkia::drawNativeImage):
(WebCore::GraphicsContextSkia::beginRecording):
(WebCore::GraphicsContextSkia::endRecording):
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h:
* Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.cpp:
(WebCore::ImageBufferSkiaAcceleratedBackend::flushCanvasRecordingContextIfNeeded):
* Source/WebCore/platform/graphics/skia/SkiaImageAtlasLayout.cpp: Copied from
Source/WebCore/platform/graphics/skia/SkiaRecordingResult.cpp.
(WebCore::SkiaImageAtlasLayout::SkiaImageAtlasLayout):
(WebCore::SkiaImageAtlasLayout::create):
* Source/WebCore/platform/graphics/skia/SkiaImageAtlasLayout.h: Copied from
Source/WebCore/platform/graphics/skia/SkiaRecordingResult.h.
* Source/WebCore/platform/graphics/skia/SkiaImageAtlasLayoutBuilder.cpp: Added.
(WebCore::SkiaImageAtlasLayoutBuilder::collectRasterImage):
(WebCore::computeBoundingBoxArea):
(WebCore::packWithBestAlgorithm):
(WebCore::SkiaImageAtlasLayoutBuilder::finalize):
(WebCore::SkiaImageAtlasLayoutBuilder::calculateOptimalAtlasSize):
(WebCore::SkiaImageAtlasLayoutBuilder::packMultipleAtlases):
(WebCore::SkiaImageAtlasLayoutBuilder::findMaxPackableBatch):
(WebCore::SkiaImageAtlasLayoutBuilder::createAtlasLayout):
* Source/WebCore/platform/graphics/skia/SkiaImageAtlasLayoutBuilder.h: Added.
(WebCore::SkiaImageAtlasLayoutBuilder::isCollected const):
(WebCore::SkiaImageAtlasLayoutBuilder::imageCount const):
* Source/WebCore/platform/graphics/skia/SkiaPaintingEngine.cpp:
(WebCore::SkiaPaintingEngine::record):
* Source/WebCore/platform/graphics/skia/SkiaRecordingResult.cpp:
(WebCore::SkiaRecordingResult::SkiaRecordingResult):
(WebCore::SkiaRecordingResult::create):
* Source/WebCore/platform/graphics/skia/SkiaRecordingResult.h:
Canonical link: https://commits.webkit.org/308117@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications