summaryrefslogtreecommitdiff
path: root/include/mbgl/style/sources/image_source.hpp
blob: 5d2e72027fb14228c875f4086ffa5d2653d9bc63 (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
#pragma once

#include <mbgl/style/source.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/optional.hpp>

namespace mbgl {
class LatLng;
class AsyncRequest;

namespace style {

class ImageSource final : public Source {
public:
    ImageSource(std::string id, std::array<LatLng, 4>);
    ~ImageSource() override;

    optional<std::string> getURL() const;

    void setURL(const std::string& url);
    void setImage(PremultipliedImage&&);
    void setSourceData(SourceData) override;
    SourceDataResult getSourceData() const override;

    void setCoordinates(const std::array<LatLng, 4>&);
    std::array<LatLng, 4> getCoordinates() const;

    class Impl;
    const Impl& impl() const;

    void loadDescription(FileSource&) final;

    bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;

    mapbox::base::WeakPtr<Source> makeWeakPtr() override { return weakFactory.makeWeakPtr(); }

    Value serialize() const override;

protected:
    Mutable<Source::Impl> createMutable() const noexcept final;

private:
    optional<std::string> url;
    std::unique_ptr<AsyncRequest> req;
    mapbox::base::WeakPtrFactory<Source> weakFactory{this};
};

} // namespace style
} // namespace mbgl