Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Added CircleBucket class stub
Browse files Browse the repository at this point in the history
Part of #1740.
  • Loading branch information
brunoabinader committed Jun 18, 2015
1 parent fe78d92 commit aa781d6
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/mbgl/map/tile_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <mbgl/map/sprite.hpp>
#include <mbgl/renderer/fill_bucket.hpp>
#include <mbgl/renderer/line_bucket.hpp>
#include <mbgl/renderer/circle_bucket.hpp>
#include <mbgl/renderer/symbol_bucket.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/style/style.hpp>
Expand Down Expand Up @@ -112,15 +113,18 @@ std::unique_ptr<Bucket> TileParser::createBucket(const StyleBucket &bucketDesc)

auto layer = geometryTile.getLayer(bucketDesc.source_layer);
if (layer) {
if (bucketDesc.type == StyleLayerType::Fill) {
switch (bucketDesc.type) {
case StyleLayerType::Fill:
return createFillBucket(*layer, bucketDesc);
} else if (bucketDesc.type == StyleLayerType::Line) {
case StyleLayerType::Line:
return createLineBucket(*layer, bucketDesc);
} else if (bucketDesc.type == StyleLayerType::Symbol) {
case StyleLayerType::Circle:
return createCircleBucket(*layer, bucketDesc);
case StyleLayerType::Symbol:
return createSymbolBucket(*layer, bucketDesc);
} else if (bucketDesc.type == StyleLayerType::Raster) {
case StyleLayerType::Raster:
return nullptr;
} else {
default:
Log::Warning(Event::ParseTile, "unknown bucket render type for layer '%s' (source layer '%s')",
bucketDesc.name.c_str(), bucketDesc.source_layer.c_str());
}
Expand Down Expand Up @@ -177,6 +181,17 @@ std::unique_ptr<Bucket> TileParser::createLineBucket(const GeometryTileLayer& la
return bucket->hasData() ? std::move(bucket) : nullptr;
}

std::unique_ptr<Bucket> TileParser::createCircleBucket(const GeometryTileLayer& layer,
const StyleBucket& bucket_desc) {
auto bucket = std::make_unique<CircleBucket>(tile.circleVertexBuffer,
tile.triangleElementsBuffer);

// Circle does not have layout properties to apply.

addBucketGeometries(bucket, layer, bucket_desc.filter);
return bucket->hasData() ? std::move(bucket) : nullptr;
}

std::unique_ptr<Bucket> TileParser::createSymbolBucket(const GeometryTileLayer& layer,
const StyleBucket& bucket_desc) {
auto bucket = std::make_unique<SymbolBucket>(*tile.getCollision(), tile.id.overscaling);
Expand Down
1 change: 1 addition & 0 deletions src/mbgl/map/tile_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class TileParser : private util::noncopyable {
std::unique_ptr<Bucket> createBucket(const StyleBucket&);
std::unique_ptr<Bucket> createFillBucket(const GeometryTileLayer&, const StyleBucket&);
std::unique_ptr<Bucket> createLineBucket(const GeometryTileLayer&, const StyleBucket&);
std::unique_ptr<Bucket> createCircleBucket(const GeometryTileLayer&, const StyleBucket&);
std::unique_ptr<Bucket> createSymbolBucket(const GeometryTileLayer&, const StyleBucket&);

template <class Bucket>
Expand Down
35 changes: 35 additions & 0 deletions src/mbgl/renderer/circle_bucket.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <mbgl/renderer/circle_bucket.hpp>

using namespace mbgl;

CircleBucket::CircleBucket(CircleVertexBuffer& vertexBuffer,
TriangleElementsBuffer& elementsBuffer)
: vertexBuffer_(vertexBuffer)
, elementsBuffer_(elementsBuffer) {
}

CircleBucket::~CircleBucket() {
// Do not remove. header file only contains forward definitions to unique pointers.
}

void CircleBucket::upload() {
vertexBuffer_.upload();
elementsBuffer_.upload();
uploaded = true;
}

void CircleBucket::render(Painter& /* painter */,
const StyleLayer& /* layer_desc */,
const TileID& /* id */,
const mat4& /* matrix */) {
// XXX Just a stub for now.
//painter.renderCircle(*this, layer_desc, id, matrix);
}

bool CircleBucket::hasData() const {
return !triangleGroups_.empty();
}

void CircleBucket::addGeometry(const GeometryCollection& /* geometryCollection */) {
// XXX Just a stub for now.
}
41 changes: 41 additions & 0 deletions src/mbgl/renderer/circle_bucket.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef MBGL_RENDERER_CIRCLE_BUCKET
#define MBGL_RENDERER_CIRCLE_BUCKET

#include <mbgl/renderer/bucket.hpp>

#include <mbgl/map/geometry_tile.hpp>

#include <mbgl/geometry/elements_buffer.hpp>
#include <mbgl/geometry/circle_buffer.hpp>

#include <mbgl/style/style_bucket.hpp>
#include <mbgl/style/style_layout.hpp>

namespace mbgl {

class CircleVertexBuffer;
class CircleElementsBuffer;

class CircleBucket : public Bucket {
using TriangleGroup = ElementGroup<3>;

public:
CircleBucket(CircleVertexBuffer &vertexBuffer, TriangleElementsBuffer &elementsBuffer);
~CircleBucket() override;

void upload() override;
void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override;

bool hasData() const;
void addGeometry(const GeometryCollection&);

private:
CircleVertexBuffer& vertexBuffer_;
TriangleElementsBuffer& elementsBuffer_;

std::vector<std::unique_ptr<TriangleGroup>> triangleGroups_;
};

} // namespace mbgl

#endif // MBGL_RENDERER_CIRCLE_BUCKET

0 comments on commit aa781d6

Please sign in to comment.