diff options
author | Tom <tomut@yahoo.com> | 2021-02-12 14:25:08 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-13 00:39:33 +0100 |
commit | 0138f13bfe907769bbc693a426ee837b066f519f (patch) | |
tree | 7ca1f605a630a71d8e421354cc5c000f421ca8c3 /Userland/Services | |
parent | 9ae02d4c926d332747ce574ab35cba4c062b862d (diff) | |
download | serenity-0138f13bfe907769bbc693a426ee837b066f519f.zip |
WindowServer: Improvements to support alpha channel in window frames
This fixes some issues handling the alpha channel that may be present
in rendered window frames.
Fixes #5303
Diffstat (limited to 'Userland/Services')
-rw-r--r-- | Userland/Services/WindowServer/WindowFrame.cpp | 18 | ||||
-rw-r--r-- | Userland/Services/WindowServer/WindowFrame.h | 11 |
2 files changed, 19 insertions, 10 deletions
diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp index 9c17e967d9..349ab999a3 100644 --- a/Userland/Services/WindowServer/WindowFrame.cpp +++ b/Userland/Services/WindowServer/WindowFrame.cpp @@ -221,6 +221,8 @@ Gfx::Bitmap* WindowFrame::window_shadow() const bool WindowFrame::frame_has_alpha() const { + if (m_has_alpha_channel) + return true; if (auto* shadow_bitmap = window_shadow(); shadow_bitmap && shadow_bitmap->format() == Gfx::BitmapFormat::RGBA32) return true; return false; @@ -347,12 +349,27 @@ void WindowFrame::render(Gfx::Painter& painter) } } +void WindowFrame::theme_changed() +{ + m_dirty = m_shadow_dirty = true; + m_top_bottom = nullptr; + m_left_right = nullptr; + m_bottom_y = m_right_x = 0; + + layout_buttons(); + set_button_icons(); + + m_has_alpha_channel = Gfx::WindowTheme::current().frame_uses_alpha(window_state_for_theme(), WindowManager::the().palette()); +} + void WindowFrame::render_to_cache() { if (!m_dirty) return; m_dirty = false; + m_has_alpha_channel = Gfx::WindowTheme::current().frame_uses_alpha(window_state_for_theme(), WindowManager::the().palette()); + static Gfx::Bitmap* s_tmp_bitmap; auto frame_rect = rect(); auto total_frame_rect = frame_rect; @@ -387,6 +404,7 @@ void WindowFrame::render_to_cache() Gfx::IntPoint update_location(m_shadow_dirty ? Gfx::IntPoint { 0, 0 } : m_shadow_offset); Gfx::Painter painter(*s_tmp_bitmap); + // Clear the frame area, not including the window content area, which we don't care about for (auto& rect : frame_rect_to_update.shatter(window_rect)) painter.clear_rect({ rect.location() - frame_rect_to_update.location(), rect.size() }, { 255, 255, 255, 0 }); diff --git a/Userland/Services/WindowServer/WindowFrame.h b/Userland/Services/WindowServer/WindowFrame.h index 992ce11921..872597f29a 100644 --- a/Userland/Services/WindowServer/WindowFrame.h +++ b/Userland/Services/WindowServer/WindowFrame.h @@ -88,16 +88,7 @@ public: m_shadow_dirty |= re_render_shadow; } - void theme_changed() - { - m_dirty = m_shadow_dirty = true; - m_top_bottom = nullptr; - m_left_right = nullptr; - m_bottom_y = m_right_x = 0; - - layout_buttons(); - set_button_icons(); - } + void theme_changed(); private: void paint_simple_rect_shadow(Gfx::Painter&, const Gfx::IntRect&, const Gfx::Bitmap&) const; |