summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/bucket.hpp
blob: c7ebe480ed9ef8999e9e6de477758272d05d9b8f (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
51
52
53
54
55
56
57
#pragma once

#include <mbgl/gl/gl.hpp>
#include <mbgl/renderer/render_pass.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/mat4.hpp>

#include <atomic>

#define BUFFER_OFFSET_0  ((GLbyte*)nullptr)
#define BUFFER_OFFSET(i) ((BUFFER_OFFSET_0) + (i))

namespace mbgl {

class Painter;
class UnwrappedTileID;
class CollisionTile;

namespace gl {
class ObjectStore;
}

namespace style {
class Layer;
}

class Bucket : private util::noncopyable {
public:
    Bucket() : uploaded(false) {}

    // As long as this bucket has a Prepare render pass, this function is getting called. Typically,
    // this only happens once when the bucket is being rendered for the first time.
    virtual void upload(gl::ObjectStore&) = 0;

    // Every time this bucket is getting rendered, this function is called. This happens either
    // once or twice (for Opaque and Transparent render passes).
    virtual void render(Painter&, const style::Layer&, const UnwrappedTileID&, const mat4&) = 0;

    virtual ~Bucket() = default;

    virtual bool hasData() const = 0;

    virtual bool needsClipping() const = 0;

    inline bool needsUpload() const {
        return !uploaded;
    }

    virtual void placeFeatures(CollisionTile&) {}
    virtual void swapRenderData() {}

protected:
    std::atomic<bool> uploaded;

};

} // namespace mbgl