mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:37:44 +00:00
WindowServer: Load multiple scaled versions of Bitmaps and Cursors
This enables rendering of mixed-scale screen layouts with e.g. high resolution cursors and window button icons on high-dpi screens while using lower resolution bitmaps on regular screens.
This commit is contained in:
parent
aa15bf81e4
commit
61af9d882e
15 changed files with 269 additions and 99 deletions
32
Userland/Services/WindowServer/MultiScaleBitmaps.h
Normal file
32
Userland/Services/WindowServer/MultiScaleBitmaps.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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; }
|
||||
|
||||
private:
|
||||
MultiScaleBitmaps() = default;
|
||||
bool load(StringView const& filename, StringView const& default_filename);
|
||||
|
||||
HashMap<int, NonnullRefPtr<Gfx::Bitmap>> m_bitmaps;
|
||||
Gfx::BitmapFormat m_format { Gfx::BitmapFormat::Invalid };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue