// This file is part of Desktop App Toolkit, // a set of libraries for developing nice desktop applications. // // For license and copyright information please follow this link: // https://github.com/desktop-app/legal/blob/master/LEGAL // #pragma once #include "ui/gl/gl_detection.h" #include class Painter; class QOpenGLWidget; namespace Ui { class RpWidgetWrap; } // namespace Ui namespace Ui::GL { class Renderer { public: virtual void init( not_null widget, QOpenGLFunctions &f) { } virtual void deinit( not_null widget, QOpenGLFunctions *f) { } virtual void resize( not_null widget, QOpenGLFunctions &f, int w, int h) { } virtual void paint( not_null widget, QOpenGLFunctions &f); [[nodiscard]] virtual std::optional clearColor() { return std::nullopt; } virtual void paintFallback( Painter &&p, const QRegion &clip, Backend backend) { } virtual ~Renderer() = default; }; struct ChosenRenderer { std::unique_ptr renderer; Backend backend = Backend::Raster; }; [[nodiscard]] std::unique_ptr CreateSurface( Fn chooseRenderer); [[nodiscard]] std::unique_ptr CreateSurface( QWidget *parent, ChosenRenderer chosen); } // namespace Ui::GL