summaryrefslogtreecommitdiff
path: root/platform/default/mbgl/gl/headless_backend.hpp
blob: 775703753353b130a07c2c457ef555b6c9dfc226 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once

#include <mbgl/renderer/renderer_backend.hpp>

#include <memory>
#include <functional>

namespace mbgl {

class HeadlessBackend : public RendererBackend {
public:
    HeadlessBackend(Size = { 256, 256 });
    ~HeadlessBackend() override;

    void bind() override;
    Size getFramebufferSize() const override;
    void updateAssumedState() override;

    void setSize(Size);
    PremultipliedImage readStillImage();

    class Impl {
    public:
        virtual ~Impl() = default;
        virtual gl::ProcAddress getExtensionFunctionPointer(const char*) = 0;
        virtual void activateContext() = 0;
        virtual void deactivateContext() {}
    };

private:
    // Implementation specific functions
    gl::ProcAddress getExtensionFunctionPointer(const char*) override;

    void activate() override;
    void deactivate() override;

    void createImpl();

private:
    std::unique_ptr<Impl> impl;

    Size size;
    float pixelRatio;
    bool active = false;

    class View;
    std::unique_ptr<View> view;
};

} // namespace mbgl