diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-04-01 16:56:24 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-04-05 11:49:17 +0200 |
commit | 66c020034e8260e5e071481e68ab61cd264723ba (patch) | |
tree | b5263772d72175474d91ce2daa9dc037b99fab0d /include/mbgl/gl | |
parent | a782a6d15b80dd83105604f3f779f6c83ba222e5 (diff) | |
download | qtlocation-mapboxgl-66c020034e8260e5e071481e68ab61cd264723ba.tar.gz |
[core] refactor RendererBackend
Diffstat (limited to 'include/mbgl/gl')
-rw-r--r-- | include/mbgl/gl/renderer_backend.hpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/include/mbgl/gl/renderer_backend.hpp b/include/mbgl/gl/renderer_backend.hpp new file mode 100644 index 0000000000..7ef8759477 --- /dev/null +++ b/include/mbgl/gl/renderer_backend.hpp @@ -0,0 +1,59 @@ +#pragma once + +#include <mbgl/gfx/renderer_backend.hpp> +#include <mbgl/util/image.hpp> +#include <mbgl/util/size.hpp> +#include <mbgl/util/util.hpp> + +namespace mbgl { +namespace gl { + +class Context; +using ProcAddress = void (*)(); +using FramebufferID = uint32_t; + +class RendererBackend : public gfx::RendererBackend { +public: + RendererBackend(); + ~RendererBackend() override; + + // Returns the backend's context which manages OpenGL state. + Context& getGLContext(); + + // Called prior to rendering to update the internally assumed OpenGL state. + virtual void updateAssumedState() = 0; + +protected: + std::unique_ptr<gfx::Context> createContext() override; + + // Called with the name of an OpenGL extension that should be loaded. RendererBackend implementations + // must call the API-specific version that obtains the function pointer for this function, + // or a null pointer if unsupported/unavailable. + virtual ProcAddress getExtensionFunctionPointer(const char*) = 0; + + // Reads the color pixel data from the currently bound framebuffer. + PremultipliedImage readFramebuffer(const Size&); + + // A constant to signal that a framebuffer is bound, but with an unknown ID. + static constexpr const FramebufferID ImplicitFramebufferBinding = + std::numeric_limits<FramebufferID>::max(); + + // Tells the renderer that OpenGL state has already been set by the windowing toolkit. + // It sets the internal assumed state to the supplied values. + void assumeFramebufferBinding(FramebufferID fbo); + void assumeViewport(int32_t x, int32_t y, const Size&); + void assumeScissorTest(bool); + + // Returns true when assumed framebuffer binding hasn't changed from the implicit binding. + bool implicitFramebufferBound(); + +public: + // Triggers an OpenGL state update if the internal assumed state doesn't match the + // supplied values. + void setFramebufferBinding(FramebufferID fbo); + void setViewport(int32_t x, int32_t y, const Size&); + void setScissorTest(bool); +}; + +} // namespace gl +} // namespace mbgl |