diff options
author | Tom <tomut@yahoo.com> | 2021-06-18 19:21:30 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-20 14:57:26 +0200 |
commit | 61af9d882e33ac3c9bec583e4651326cac338b29 (patch) | |
tree | e53a017a375055c2852049c1715296f7215b5e0e /Userland/Services/WindowServer/MultiScaleBitmaps.h | |
parent | aa15bf81e48637cf6365f15f4eaada645eae4040 (diff) | |
download | serenity-61af9d882e33ac3c9bec583e4651326cac338b29.zip |
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.
Diffstat (limited to 'Userland/Services/WindowServer/MultiScaleBitmaps.h')
-rw-r--r-- | Userland/Services/WindowServer/MultiScaleBitmaps.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Userland/Services/WindowServer/MultiScaleBitmaps.h b/Userland/Services/WindowServer/MultiScaleBitmaps.h new file mode 100644 index 0000000000..90e4c95cdf --- /dev/null +++ b/Userland/Services/WindowServer/MultiScaleBitmaps.h @@ -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 }; +}; + +} |