Commit graph

5 commits

Author SHA1 Message Date
Aliaksandr Kalenik
d341ed5448 LibGfx: Make Skia image cache eviction pressure-based
DecodedImageFrameSkiaImageCache used to treat each display-list
flush as a cache generation. That worked poorly for the compositor,
where all contexts share one DisplayListPlayerSkia and therefore one
decoded-frame cache. A busy context could advance the generation
counter enough to evict images from another context even when the
shared cache was still comfortably under its entry and byte limits.

Track recency from actual image-cache hits and inserts instead, and
evict the least-recently used entries only when the existing global
entry or byte caps are exceeded. This keeps cross-context reuse while
making eviction respond to memory pressure rather than unrelated
presentation churn.

Prune the decoded-image cache before handing the surface to the shared
SkiaBackendContext flush cleanup, so any SkImage references released
by the cache are visible to Skia's resource cleanup in the same flush
path.
2026-05-28 02:50:55 +01:00
Andreas Kling
419fe89f6e LibGfx+LibWeb: Bound Skia cache growth
Set an explicit resource cache limit on Skia GPU contexts and ask
Skia to perform deferred cleanup from the compositor at a throttled
cadence. When resource usage crosses high watermarks, request more
aggressive cleanup and purge scratch resources only as a last step.

Also cap the decoded frame Skia image cache by approximate bitmap
bytes and entry count so route changes and pointer-driven repaint
churn cannot keep an unbounded number of uploaded image textures
alive.
2026-05-16 15:54:44 +02:00
Aliaksandr Kalenik
9d605f1237 LibGfx: Hide Skia types behind pImpl in DecodedImageFrameSkiaImageCache
Move the cache's Skia-dependent members (sk_sp<SkImage>, the
DecodedImageFrame-keyed HashMap, and the SkColorSpace-based key traits)
into a private Impl struct defined in the .cpp file. The header now only
needs forward declarations for SkImage and sk_sp, so including the cache
no longer drags in Skia headers into translation units that just want to
hold a pointer to the cache.
2026-05-10 19:49:29 +02:00
Aliaksandr Kalenik
f8640d813a LibGfx+LibWeb: Make DecodedImageFrame a value type
DecodedImageFrame only wraps a ref-counted Bitmap and color-space
metadata. The frame object itself does not provide shared mutable
state or lifetime ownership beyond those members, so ref-counting it
adds an unnecessary layer of indirection.
2026-05-07 16:08:13 +02:00
Aliaksandr Kalenik
76c79ee522 LibGfx: Remove ImmutableBitmap
DecodedImageFrame now owns decoded bitmap pixels directly, so the
separate ImmutableBitmap wrapper no longer carries useful semantics.
Remove the class and pass decoded image frames or bitmaps at the
boundaries where pixels are actually required.

The Skia image cache now keys off DecodedImageFrame, matching the
display-list commands that paint decoded images. Video frames stay
owned by LibMedia, with the explicit YUV-to-bitmap conversion living
at HTMLVideoElement's decoded-frame entry point for canvas and WebGL
callers.
2026-05-05 14:39:17 -05:00
Renamed from Libraries/LibGfx/ImmutableBitmapSkiaImageCache.cpp (Browse further)