From aa781d6036720f976dc89f90caacee380c6ce277 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 17 Jun 2015 16:08:58 +0300 Subject: [PATCH] Added CircleBucket class stub Part of #1740. --- src/mbgl/map/tile_parser.cpp | 25 ++++++++++++++---- src/mbgl/map/tile_parser.hpp | 1 + src/mbgl/renderer/circle_bucket.cpp | 35 ++++++++++++++++++++++++ src/mbgl/renderer/circle_bucket.hpp | 41 +++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 src/mbgl/renderer/circle_bucket.cpp create mode 100644 src/mbgl/renderer/circle_bucket.hpp diff --git a/src/mbgl/map/tile_parser.cpp b/src/mbgl/map/tile_parser.cpp index 61af227034b..d4953d5d7a9 100644 --- a/src/mbgl/map/tile_parser.cpp +++ b/src/mbgl/map/tile_parser.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -112,15 +113,18 @@ std::unique_ptr 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()); } @@ -177,6 +181,17 @@ std::unique_ptr TileParser::createLineBucket(const GeometryTileLayer& la return bucket->hasData() ? std::move(bucket) : nullptr; } +std::unique_ptr TileParser::createCircleBucket(const GeometryTileLayer& layer, + const StyleBucket& bucket_desc) { + auto bucket = std::make_unique(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 TileParser::createSymbolBucket(const GeometryTileLayer& layer, const StyleBucket& bucket_desc) { auto bucket = std::make_unique(*tile.getCollision(), tile.id.overscaling); diff --git a/src/mbgl/map/tile_parser.hpp b/src/mbgl/map/tile_parser.hpp index 88e56878045..e22fe65c77d 100644 --- a/src/mbgl/map/tile_parser.hpp +++ b/src/mbgl/map/tile_parser.hpp @@ -53,6 +53,7 @@ class TileParser : private util::noncopyable { std::unique_ptr createBucket(const StyleBucket&); std::unique_ptr createFillBucket(const GeometryTileLayer&, const StyleBucket&); std::unique_ptr createLineBucket(const GeometryTileLayer&, const StyleBucket&); + std::unique_ptr createCircleBucket(const GeometryTileLayer&, const StyleBucket&); std::unique_ptr createSymbolBucket(const GeometryTileLayer&, const StyleBucket&); template diff --git a/src/mbgl/renderer/circle_bucket.cpp b/src/mbgl/renderer/circle_bucket.cpp new file mode 100644 index 00000000000..30cd981e954 --- /dev/null +++ b/src/mbgl/renderer/circle_bucket.cpp @@ -0,0 +1,35 @@ +#include + +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. +} diff --git a/src/mbgl/renderer/circle_bucket.hpp b/src/mbgl/renderer/circle_bucket.hpp new file mode 100644 index 00000000000..6c5fb4ba62a --- /dev/null +++ b/src/mbgl/renderer/circle_bucket.hpp @@ -0,0 +1,41 @@ +#ifndef MBGL_RENDERER_CIRCLE_BUCKET +#define MBGL_RENDERER_CIRCLE_BUCKET + +#include + +#include + +#include +#include + +#include +#include + +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> triangleGroups_; +}; + +} // namespace mbgl + +#endif // MBGL_RENDERER_CIRCLE_BUCKET