diff options
Diffstat (limited to 'include/mbgl/map/view.hpp')
-rw-r--r-- | include/mbgl/map/view.hpp | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp index 6f481c4458..fd11080064 100644 --- a/include/mbgl/map/view.hpp +++ b/include/mbgl/map/view.hpp @@ -30,44 +30,42 @@ enum MapChange : uint8_t { class View { public: - // Called from the main thread directly after initialization. Must always return the same value, - // i.e. it may not change over time. + virtual ~View() = default; + + // Called directly after initialization. Must always return the same value, i.e. it may + // not change over time. virtual float getPixelRatio() const = 0; - // Called from the main thread when the View signaled a dimension change. Must return the - // logical dimension of this map in pixels. + // Called when the View signaled a dimension change. Must return the logical dimension + // of this map in pixels. virtual std::array<uint16_t, 2> getSize() const = 0; - // Called from the main thread for every frame that is being rendered. Must return the absolute - // dimensions of the current framebuffer. Typically, this is the logical width scaled by the - // pixel ratio, but in case the view was moved to display with a different pixel ratio, it can - // also be different from that rule. + // Called for every frame that is being rendered. Must return the absolute dimensions of + // the current framebuffer. Typically, this is the logical width scaled by the pixel ratio, + // but in case the view was moved to display with a different pixel ratio, it can also be + // different from that rule. virtual std::array<uint16_t, 2> getFramebufferSize() const = 0; - // Called from the main thread when this View is associated with a Map object. - virtual void initialize(Map *map_); - - // Called from the render thread. Makes the GL context active in the current - // thread. This is typically just called once at the beginning of the - // renderer setup since the render thread doesn't switch the contexts. + // Called when this View is associated with a Map object. + virtual void initialize(Map*); + + // Called when the view's GL context needs to be made active or inactive. These are called, + // as a matched pair, in four situations: + // + // 1. When releasing GL resources during Map destruction + // 2. When calling a CustomLayerInitializeFunction, during Map::addCustomLayer + // 3. When calling a CustomLayerDeinitializeFunction, during Map::removeCustomLayer + // 4. When rendering for Map::renderStill + // + // They are *not* called for Map::render; it is assumed that the correct context is already + // activated prior to calling Map::render. virtual void activate() = 0; - - // Called from the render thread. Makes the GL context inactive in the current - // thread. This is called once just before the rendering thread terminates. virtual void deactivate() = 0; - virtual void notify() = 0; - - // Called from the render thread. The implementation must trigger a rerender. - // (map->renderSync() from the main thread must be called as a result of this) + // Called when the map needs to be rendered; the view should call Map::render() at some point + // in the near future. (Not called for Map::renderStill() mode.) virtual void invalidate() = 0; - // Called from the render thread before the render begins. - virtual void beforeRender() = 0; - - // Called from the render thread after the render is complete. - virtual void afterRender() = 0; - // Reads the pixel data from the current framebuffer. If your View implementation // doesn't support reading from the framebuffer, return a null pointer. virtual PremultipliedImage readStillImage(); |