diff options
Diffstat (limited to 'include/mbgl/platform/default')
-rw-r--r-- | include/mbgl/platform/default/glfw_view.hpp | 12 | ||||
-rw-r--r-- | include/mbgl/platform/default/headless_view.hpp | 41 | ||||
-rw-r--r-- | include/mbgl/platform/default/offscreen_view.hpp | 33 |
3 files changed, 41 insertions, 45 deletions
diff --git a/include/mbgl/platform/default/glfw_view.hpp b/include/mbgl/platform/default/glfw_view.hpp index a115d03d7f..e832cd70d1 100644 --- a/include/mbgl/platform/default/glfw_view.hpp +++ b/include/mbgl/platform/default/glfw_view.hpp @@ -19,6 +19,8 @@ public: float getPixelRatio() const; + void setMap(mbgl::Map*); + // Callback called when the user presses the key mapped to style change. // The expected action is to set a new style, different to the current one. void setChangeStyleCallback(std::function<void()> callback); @@ -29,18 +31,18 @@ public: void run(); -private: // mbgl::View implementation - void initialize(mbgl::Map*) override; + void updateViewBinding(); void bind() override; - std::array<uint16_t, 2> getSize() const override; - std::array<uint16_t, 2> getFramebufferSize() const override; + std::array<uint16_t, 2> getSize() const; + std::array<uint16_t, 2> getFramebufferSize() const; // mbgl::Backend implementation void activate() override; void deactivate() override; void invalidate() override; +private: // Window callbacks static void onKey(GLFWwindow *window, int key, int scancode, int action, int mods); static void onScroll(GLFWwindow *window, double xoffset, double yoffset); @@ -76,6 +78,8 @@ private: std::function<void(mbgl::MapChange)> mapChangeCallback; private: + mbgl::Map* map = nullptr; + bool fullscreen = false; const bool benchmark = false; bool tracking = false; diff --git a/include/mbgl/platform/default/headless_view.hpp b/include/mbgl/platform/default/headless_view.hpp deleted file mode 100644 index 27af4fc9d9..0000000000 --- a/include/mbgl/platform/default/headless_view.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include <mbgl/map/view.hpp> -#include <mbgl/gl/types.hpp> - -namespace mbgl { - -class HeadlessView : public View { -public: - HeadlessView(float pixelRatio = 1, uint16_t width = 256, uint16_t height = 256); - ~HeadlessView() override; - - void bind() override; - - std::array<uint16_t, 2> getSize() const override; - std::array<uint16_t, 2> getFramebufferSize() const override; - - - PremultipliedImage readStillImage(std::array<uint16_t, 2> size = {{ 0, 0 }}) override; - - float getPixelRatio() const; - - void resize(uint16_t width, uint16_t height); - -private: - void clearBuffers(); - void resizeFramebuffer(); - void bindFramebuffer(); - -private: - const float pixelRatio; - std::array<uint16_t, 2> dimensions; - - bool needsResize = false; - - gl::FramebufferID fbo = 0; - gl::RenderbufferID fboDepthStencil = 0; - gl::RenderbufferID fboColor = 0; -}; - -} // namespace mbgl diff --git a/include/mbgl/platform/default/offscreen_view.hpp b/include/mbgl/platform/default/offscreen_view.hpp new file mode 100644 index 0000000000..034aa3aaf3 --- /dev/null +++ b/include/mbgl/platform/default/offscreen_view.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include <mbgl/map/view.hpp> +#include <mbgl/gl/framebuffer.hpp> +#include <mbgl/gl/renderbuffer.hpp> +#include <mbgl/util/optional.hpp> +#include <mbgl/util/image.hpp> + +namespace mbgl { + +namespace gl { +class Context; +} // namespace gl + +class OffscreenView : public View { +public: + OffscreenView(gl::Context&, std::array<uint16_t, 2> size = {{ 256, 256 }}); + + void bind() override; + + PremultipliedImage readStillImage(); + + std::array<uint16_t, 2> getSize() const; + +private: + gl::Context& context; + std::array<uint16_t, 2> size; + optional<gl::Framebuffer> framebuffer; + optional<gl::Renderbuffer<gl::RenderbufferType::RGBA>> color; + optional<gl::Renderbuffer<gl::RenderbufferType::DepthStencil>> depthStencil; +}; + +} // namespace mbgl |