diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-07-01 12:39:21 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-07-08 10:40:05 +0200 |
commit | 675ddddee78fa36d60d55c266033f05edda4be48 (patch) | |
tree | e7e09473400600070778b620d1cd1eb0a78d7b7d /include/mbgl/platform | |
parent | 3a07cb2f1edb4e8f5e076ec0fef32f733676a95c (diff) | |
download | qtlocation-mapboxgl-675ddddee78fa36d60d55c266033f05edda4be48.tar.gz |
Make pixelRatio constant across a Map object lifetime
also moves framebuffer size out of TransformState into its own object
Diffstat (limited to 'include/mbgl/platform')
-rw-r--r-- | include/mbgl/platform/default/glfw_view.hpp | 10 | ||||
-rw-r--r-- | include/mbgl/platform/default/headless_view.hpp | 25 |
2 files changed, 19 insertions, 16 deletions
diff --git a/include/mbgl/platform/default/glfw_view.hpp b/include/mbgl/platform/default/glfw_view.hpp index 6e03953cbd..cb40db1248 100644 --- a/include/mbgl/platform/default/glfw_view.hpp +++ b/include/mbgl/platform/default/glfw_view.hpp @@ -15,6 +15,10 @@ public: GLFWView(bool fullscreen = false); ~GLFWView(); + float getPixelRatio() const override; + std::array<uint16_t, 2> getSize() const override; + std::array<uint16_t, 2> getFramebufferSize() const override; + void initialize(mbgl::Map *map) override; void activate() override; void deactivate() override; @@ -24,7 +28,8 @@ public: static void onKey(GLFWwindow *window, int key, int scancode, int action, int mods); static void onScroll(GLFWwindow *window, double xoffset, double yoffset); - static void onResize(GLFWwindow *window, int width, int height); + static void onWindowResize(GLFWwindow *window, int width, int height); + static void onFramebufferResize(GLFWwindow *window, int width, int height); static void onMouseClick(GLFWwindow *window, int button, int action, int modifiers); static void onMouseMove(GLFWwindow *window, double x, double y); @@ -57,6 +62,9 @@ private: int width = 1024; int height = 768; + int fbWidth; + int fbHeight; + float pixelRatio; double lastX = 0, lastY = 0; diff --git a/include/mbgl/platform/default/headless_view.hpp b/include/mbgl/platform/default/headless_view.hpp index 61e60ebaff..ce0ff2a685 100644 --- a/include/mbgl/platform/default/headless_view.hpp +++ b/include/mbgl/platform/default/headless_view.hpp @@ -25,18 +25,23 @@ class HeadlessDisplay; class HeadlessView : public View { public: - HeadlessView(uint16_t width = 256, uint16_t height = 256, float pixelRatio = 1); - HeadlessView(std::shared_ptr<HeadlessDisplay> display, uint16_t width = 256, uint16_t height = 256, float pixelRatio = 1); + HeadlessView(float pixelRatio, uint16_t width = 256, uint16_t height = 256); + HeadlessView(std::shared_ptr<HeadlessDisplay> display, float pixelRatio, uint16_t width = 256, uint16_t height = 256); ~HeadlessView(); + float getPixelRatio() const override; + std::array<uint16_t, 2> getSize() const override; + std::array<uint16_t, 2> getFramebufferSize() const override; + void activate() override; void deactivate() override; void notify() override; - void resize(uint16_t width, uint16_t height, float pixelRatio) override; void invalidate() override; void swap() override; std::unique_ptr<StillImage> readStillImage() override; + void resize(uint16_t width, uint16_t height); + private: void createContext(); void loadExtensions(); @@ -45,18 +50,8 @@ private: private: std::shared_ptr<HeadlessDisplay> display; - - struct Dimensions { - inline Dimensions(uint16_t width = 0, uint16_t height = 0, float pixelRatio = 0); - inline uint16_t pixelWidth() const { return width * pixelRatio; } - inline uint16_t pixelHeight() const { return height * pixelRatio; } - - uint16_t width = 0; - uint16_t height = 0; - float pixelRatio = 0; - }; - - Dimensions dimensions; + const float pixelRatio; + std::array<uint16_t, 2> dimensions; #if MBGL_USE_CGL CGLContextObj glContext = nullptr; |