Serenity Operating System
at master 36 lines 1.1 kB view raw
1/* 2 * Copyright (c) 2020, the SerenityOS developers. 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/HashMap.h> 10#include <AK/RefCounted.h> 11#include <AK/RefPtr.h> 12#include <LibGfx/Bitmap.h> 13 14namespace WindowServer { 15 16class MultiScaleBitmaps : public RefCounted<MultiScaleBitmaps> { 17public: 18 static RefPtr<MultiScaleBitmaps> create_empty(); 19 static RefPtr<MultiScaleBitmaps> create(StringView filename, StringView default_filename = {}); 20 21 Gfx::Bitmap const& default_bitmap() const { return bitmap(1); } 22 Gfx::Bitmap const& bitmap(int scale_factor) const; 23 Gfx::Bitmap const* find_bitmap(int scale_factor) const; 24 Gfx::BitmapFormat format() const { return m_format; } 25 bool load(StringView filename, StringView default_filename = {}); 26 void add_bitmap(int scale_factor, NonnullRefPtr<Gfx::Bitmap>&&); 27 bool is_empty() const { return m_bitmaps.is_empty(); } 28 29private: 30 MultiScaleBitmaps() = default; 31 32 HashMap<int, NonnullRefPtr<Gfx::Bitmap>> m_bitmaps; 33 Gfx::BitmapFormat m_format { Gfx::BitmapFormat::Invalid }; 34}; 35 36}