mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:47:35 +00:00
WindowServer: Don't lookup configuration values in compose()
The compose() function is supposed to be fast since it can execute 60 times per second. Let's not do obviously avoidable things like configuration value lookups in there. :^)
This commit is contained in:
parent
ffa241250b
commit
bc67b04399
3 changed files with 26 additions and 10 deletions
|
@ -112,11 +112,20 @@ void Compositor::init_bitmaps()
|
||||||
invalidate_screen();
|
invalidate_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Compositor::did_construct_window_manager(Badge<WindowManager>)
|
||||||
|
{
|
||||||
|
auto& wm = WindowManager::the();
|
||||||
|
m_wallpaper_mode = mode_to_enum(wm.config()->read_entry("Background", "Mode", "simple"));
|
||||||
|
m_custom_background_color = Color::from_string(wm.config()->read_entry("Background", "Color", ""));
|
||||||
|
|
||||||
|
invalidate_screen();
|
||||||
|
invalidate_occlusions();
|
||||||
|
compose();
|
||||||
|
}
|
||||||
|
|
||||||
void Compositor::compose()
|
void Compositor::compose()
|
||||||
{
|
{
|
||||||
auto& wm = WindowManager::the();
|
auto& wm = WindowManager::the();
|
||||||
if (m_wallpaper_mode == WallpaperMode::Unchecked)
|
|
||||||
m_wallpaper_mode = mode_to_enum(wm.config()->read_entry("Background", "Mode", "simple"));
|
|
||||||
auto& ws = Screen::the();
|
auto& ws = Screen::the();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -185,10 +194,8 @@ void Compositor::compose()
|
||||||
});
|
});
|
||||||
|
|
||||||
Color background_color = wm.palette().desktop_background();
|
Color background_color = wm.palette().desktop_background();
|
||||||
String background_color_entry = wm.config()->read_entry("Background", "Color", "");
|
if (m_custom_background_color.has_value())
|
||||||
if (!background_color_entry.is_empty()) {
|
background_color = m_custom_background_color.value();
|
||||||
background_color = Color::from_string(background_color_entry).value_or(background_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef COMPOSE_DEBUG
|
#ifdef COMPOSE_DEBUG
|
||||||
dbg() << "COMPOSE: invalidated: window:" << m_invalidated_window << " cursor:" << m_invalidated_cursor << " any: " << m_invalidated_any;
|
dbg() << "COMPOSE: invalidated: window:" << m_invalidated_window << " cursor:" << m_invalidated_cursor << " any: " << m_invalidated_any;
|
||||||
|
@ -600,6 +607,12 @@ void Compositor::start_compose_async_timer()
|
||||||
|
|
||||||
bool Compositor::set_background_color(const String& background_color)
|
bool Compositor::set_background_color(const String& background_color)
|
||||||
{
|
{
|
||||||
|
auto color = Color::from_string(background_color);
|
||||||
|
if (!color.has_value())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_custom_background_color = color;
|
||||||
|
|
||||||
auto& wm = WindowManager::the();
|
auto& wm = WindowManager::the();
|
||||||
wm.config()->write_entry("Background", "Color", background_color);
|
wm.config()->write_entry("Background", "Color", background_color);
|
||||||
bool ret_val = wm.config()->sync();
|
bool ret_val = wm.config()->sync();
|
||||||
|
|
|
@ -29,14 +29,15 @@
|
||||||
#include <AK/OwnPtr.h>
|
#include <AK/OwnPtr.h>
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
#include <LibCore/Object.h>
|
#include <LibCore/Object.h>
|
||||||
|
#include <LibGfx/Color.h>
|
||||||
#include <LibGfx/DisjointRectSet.h>
|
#include <LibGfx/DisjointRectSet.h>
|
||||||
#include <LibGfx/Forward.h>
|
|
||||||
|
|
||||||
namespace WindowServer {
|
namespace WindowServer {
|
||||||
|
|
||||||
class ClientConnection;
|
class ClientConnection;
|
||||||
class Cursor;
|
class Cursor;
|
||||||
class Window;
|
class Window;
|
||||||
|
class WindowManager;
|
||||||
|
|
||||||
enum class WallpaperMode {
|
enum class WallpaperMode {
|
||||||
Simple,
|
Simple,
|
||||||
|
@ -73,6 +74,8 @@ public:
|
||||||
|
|
||||||
void invalidate_occlusions() { m_occlusions_dirty = true; }
|
void invalidate_occlusions() { m_occlusions_dirty = true; }
|
||||||
|
|
||||||
|
void did_construct_window_manager(Badge<WindowManager>);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Compositor();
|
Compositor();
|
||||||
void init_bitmaps();
|
void init_bitmaps();
|
||||||
|
@ -125,6 +128,8 @@ private:
|
||||||
|
|
||||||
RefPtr<Core::Timer> m_display_link_notify_timer;
|
RefPtr<Core::Timer> m_display_link_notify_timer;
|
||||||
size_t m_display_link_count { 0 };
|
size_t m_display_link_count { 0 };
|
||||||
|
|
||||||
|
Optional<Gfx::Color> m_custom_background_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,9 +74,7 @@ WindowManager::WindowManager(const Gfx::PaletteImpl& palette)
|
||||||
|
|
||||||
reload_config(false);
|
reload_config(false);
|
||||||
|
|
||||||
Compositor::the().invalidate_screen();
|
Compositor::the().did_construct_window_manager({});
|
||||||
Compositor::the().invalidate_occlusions();
|
|
||||||
Compositor::the().compose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowManager::~WindowManager()
|
WindowManager::~WindowManager()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue