Fix transparency and compositing order in immediate mode rendering - #1297
Merged
Conversation
This commit addresses issues with how transparent, alpha-blended, gradient-blended, and rounded-corner widgets (especially root widgets) are composited in immediate rendering mode. The background and any underlying widgets must be painted *before* overlapping transparent elements to ensure correct blending. Changes include: - Modifying `calcWidgetClipRegion` to ensure areas under transparent widgets remain visible for underlying layers. - Refactoring `paint()` to ensure the desktop background is painted first in immediate mode, and root widgets are iterated back-to-front for painting. - Removing pre-clearing in `paintLayer` to allow blending against existing content. - Adjusting `addRootWidget` to ensure widgets with identical z-positions are consistently stacked with the last-added on top. - Ensuring `eWindow` also sets alpha blend on its child widget for visibility.
This commit addresses issues with how transparent, alpha-blended, gradient-blended, and rounded-corner widgets (especially root widgets) are composited in immediate rendering mode. The background and any underlying widgets must be painted *before* overlapping transparent elements to ensure correct blending. Changes include: - Modifying `calcWidgetClipRegion` to ensure areas under transparent widgets remain visible for underlying layers. - Refactoring `paint()` to ensure the desktop background is painted first in immediate mode, and root widgets are iterated back-to-front for painting. - Removing pre-clearing in `paintLayer` to allow blending against existing content. - Adjusting `addRootWidget` to ensure widgets with identical z-positions are consistently stacked with the last-added on top. - Ensuring `eWindow` also sets alpha blend on its child widget for visibility.
…en-alphablend-fix
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.
This pull request refactors and improves the painting and compositing logic for root widgets and their children in the GUI system. The main focus is on ensuring correct compositing order, handling of transparency, alpha blending, gradients, and rounded corners, and improving clarity and maintainability. The changes also update method signatures and add documentation to clarify behavior.
Painting and compositing improvements:
m_root) to always be sorted front-to-back in immediate mode and back-to-front in buffered mode, ensuring correct z-ordering and compositing. The insertion logic now uses<=to make sure newly added widgets with the same z-position appear on top.eWidgetDesktop::paint()to paint the background first and then root widgets back-to-front in immediate mode, ensuring that transparent, blended, or rounded widgets composite correctly on top of what is behind them.Clip region and visibility calculation:
calcWidgetClipRegionby removing theparentparameter and clarifying the logic for when a widget should subtract its region from the parent's visible region. Now, regions are only subtracted for fully opaque, non-gradient, non-alphablended, and non-rounded widgets. [1] [2] [3]API and maintainability improvements:
eWidgetDesktopandeWindowto reflect the new logic and added documentation for clarity. AddedsetWidgetAlphaBlendtoeWindowto ensure both the window and its child use the correct alpha blending setting. [1] [2] [3]