Cache solid alpha pictures at 256 discrete levels - #48
Open
jEsuSdA wants to merge 1 commit into
Open
Conversation
…erver round-trips Creating a solid alpha picture via solid_picture() involves multiple X server round-trips: XCreatePixmap, XRenderCreatePicture, XRenderFillRectangle. Currently, every window with opacity < OPAQUE creates its own alpha picture in paint_all(), and determine_mode() destroys it when the mode changes. For a desktop with many translucent windows, this means dozens of redundant picture creations per frame. Add a global cache of 256 discrete alpha levels (indexed by opacity>>24). When a window needs an alpha picture, it reuses the cached one instead of creating a new one. The border alpha picture (for frame opacity) is also cached once. Since the pictures are now shared across windows, they must never be freed per-window. determine_mode() and finish_destroy_win() now only null the pointers, never calling XRenderFreePicture(). This fixes the double-free that would otherwise occur when two windows share the same cached picture. Impact: eliminates redundant alpha picture creation/destruction, reducing server round-trips especially for desktops with many translucent windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Caches solid alpha pictures at 256 discrete levels to eliminate redundant X server round-trips for translucent windows. Also fixes a double-free bug that would occur if the cached pictures were freed per-window.
Problem
Creating a solid alpha picture via
solid_picture()involves multiple X server round-trips:XCreatePixmap,XRenderCreatePicture,XRenderFillRectangle. Every window with opacity <OPAQUEcreates its own alpha picture inpaint_all(), anddetermine_mode()destroys it when the mode changes. For a desktop with many translucent windows, this means dozens of redundant picture creations per frame.Solution
Global cache
g_alpha_pict_cache[256]— indexed byopacity >> 24(0-255). Each level is created on first demand and reused for all windows with that opacity level.g_border_alpha_pict— cached once for frame opacity (shared across all windows with frame opacity).No per-window free
Since the pictures are now shared across windows, they must never be freed per-window:
determine_mode()now only nulls the pointers, never callingXRenderFreePicture()finish_destroy_win()now only nulls the pointersThis fixes the double-free that would occur when two windows share the same cached picture.
Changes
fastcompmgr.cis touchedmake clean && makeproduces zero warnings, zero errorsImpact
Eliminates redundant alpha picture creation/destruction, reducing server round-trips especially for desktops with many translucent windows.