Files
MapLibreParticleLab/platform/default/include/mbgl/gfx/headless_backend.hpp
Tim Sylvester 25c1f3c7a6 Rebase fill-extrusion work to eliminate dependence on render target branch (#1618)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Alex Cristici <alex.cristici@gmail.com>
Co-authored-by: mwilsnd <mwilsnd@gmail.com>
Co-authored-by: Stefan Karschti <stefan.karschti@gmail.com>
Co-authored-by: Bart Louwers <bart@emeel.net>
Co-authored-by: Alex Cristici <alex@skoon.energy>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
Co-authored-by: Wei Chen <alanchenboy@gmail.com>
Co-authored-by: Siarhei Fedartsou <siarhei.fedartsou@gmail.com>
Co-authored-by: tdcosta100 <tdcosta100@gmail.com>
2023-09-15 16:02:26 -07:00

44 lines
1.3 KiB
C++

#pragma once
#include <mbgl/gfx/renderable.hpp>
#include <mbgl/gfx/backend.hpp>
#include <mbgl/gfx/renderer_backend.hpp>
#include <mbgl/util/image.hpp>
#include <memory>
namespace mbgl {
namespace gfx {
// Common headless backend interface, provides HeadlessBackend backend factory
// and enables extending gfx::Renderable with platform specific implementation
// of readStillImage.
class HeadlessBackend : public gfx::Renderable {
public:
enum class SwapBehaviour {
NoFlush,
Flush
};
// Factory.
static std::unique_ptr<HeadlessBackend> Create(const Size size = {256, 256},
SwapBehaviour swapBehavior = SwapBehaviour::NoFlush,
const gfx::ContextMode contextMode = gfx::ContextMode::Unique) {
#if MLN_RENDER_BACKEND_METAL
throw std::runtime_error("Not yet implemented");
#else // MLN_RENDER_BACKEND_OPENGL
return Backend::Create<HeadlessBackend, Size, SwapBehaviour, gfx::ContextMode>(size, swapBehavior, contextMode);
#endif
}
virtual PremultipliedImage readStillImage() = 0;
virtual RendererBackend* getRendererBackend() = 0;
void setSize(Size);
protected:
HeadlessBackend(Size);
};
} // namespace gfx
} // namespace mbgl