MyCurry/src/gamelib/drawing_queue.hpp

71 lines
2.0 KiB
C++

/*
Copyright 2016, 2017 Michele "King_DuckZ" Santullo
This file is part of MyCurry.
MyCurry is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MyCurry is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MyCurry. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "safe_ptr.hh"
#include "rect.hpp"
#include "sizenotifiable.hpp"
#include <memory>
#include <cstdint>
namespace cloonel {
class SDLMain;
} //namespace cloonel
namespace curry {
class Texture;
class DrawingQueue : public cloonel::SizeNotifiable<cloonel::regbehaviours::AutoRegister> {
typedef cloonel::SizeNotifiable<cloonel::regbehaviours::AutoRegister> SizeNotifiableBase;
public:
struct ItemInfo;
DrawingQueue (cloonel::SDLMain* parSDLMain, const cloonel::DeferredRegister& parDeferredRegister);
virtual ~DrawingQueue() noexcept;
bool add_layer (uint16_t parName);
std::size_t default_layer_id() const;
void flush_to_renderer();
void add_for_rendering (uint16_t parName, ItemInfo&& parItem);
private:
void draw_clipped (Texture& parTexture, Rect<float> parSrc, Rect<float> parDest);
virtual void OnResChanged ( const cloonel::SizeRatio& parSizeRatio ) override;
struct LocalData;
std::unique_ptr<LocalData> m_local_data;
};
struct DrawingQueue::ItemInfo {
ItemInfo();
ItemInfo (ItemInfo&&);
ItemInfo (const ItemInfo&) = delete;
~ItemInfo() noexcept;
ItemInfo& operator= (ItemInfo&&);
ItemInfo& operator= (const ItemInfo&) = delete;
Rect<float> source;
Rect<float> destination;
Kakoune::SafePtr<Texture> texture;
};
} //namespace curry