#pragma once #include #include #include #include #include #include namespace mbgl { namespace gl { class Context; } // namespace gl class RenderLayer; class PatternDependency; using PatternLayerMap = std::unordered_map; class Bucket : private util::noncopyable { public: Bucket(style::LayerType layerType_) : layerType(layerType_) { } virtual ~Bucket() = default; // Check whether this bucket is of the given subtype. template bool is() const; // Dynamically cast this bucket to the given subtype. template T* as() { return is() ? reinterpret_cast(this) : nullptr; } template const T* as() const { return is() ? reinterpret_cast(this) : nullptr; } // Feature geometries are also used to populate the feature index. // Obtaining these is a costly operation, so we do it only once, and // pass-by-const-ref the geometries as a second parameter. virtual void addFeature(const GeometryTileFeature&, const GeometryCollection&, const ImagePositions&, const PatternLayerMap&) {}; virtual void populateFeatureBuffers(const ImagePositions&) {}; virtual void addPatternDependencies(const std::vector&, ImageDependencies&) {}; // 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::Context&) = 0; virtual bool hasData() const = 0; virtual float getQueryRadius(const RenderLayer&) const { return 0; }; bool needsUpload() const { return hasData() && !uploaded; } protected: style::LayerType layerType; std::atomic uploaded { false }; }; } // namespace mbgl