1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-06 17:57:34 +00:00
serenity/Userland/Services/WindowServer/MultiScaleBitmaps.h
Tom 75dc94064d WindowServer: Reload icons on scale changes
Since MultiScaleBitmaps only loads icons for the scales in use, we need
to unconditionally reload them so that we pick up the correct bitmaps
for a scale that hasn't been previously used.
2021-06-20 14:57:26 +02:00

32 lines
868 B
C++

/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/HashMap.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <LibGfx/Bitmap.h>
namespace WindowServer {
class MultiScaleBitmaps : public RefCounted<MultiScaleBitmaps> {
public:
static RefPtr<MultiScaleBitmaps> create(StringView const& filename, StringView const& default_filename = {});
Gfx::Bitmap const& default_bitmap() const { return bitmap(1); }
Gfx::Bitmap const& bitmap(int scale_factor) const;
Gfx::BitmapFormat format() const { return m_format; }
bool load(StringView const& filename, StringView const& default_filename = {});
private:
MultiScaleBitmaps() = default;
HashMap<int, NonnullRefPtr<Gfx::Bitmap>> m_bitmaps;
Gfx::BitmapFormat m_format { Gfx::BitmapFormat::Invalid };
};
}