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

[wip] V8 #2052

Merged
merged 14 commits into from
Aug 24, 2015
4 changes: 2 additions & 2 deletions include/mbgl/storage/resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ struct Resource {
Source,
Tile,
Glyphs,
JSON,
Image
SpriteImage,
SpriteJSON
};

const Kind kind;
Expand Down
15 changes: 15 additions & 0 deletions include/mbgl/style/style_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ struct LineProperties {
}
};

struct CircleProperties {
inline CircleProperties() {}
float radius = 5.0f;
Color color = {{ 0, 0, 0, 1 }};
float opacity = 1.0f;
std::array<float, 2> translate = {{ 0, 0 }};
TranslateAnchorType translateAnchor = TranslateAnchorType::Map;
float blur = 0;

inline bool isVisible() const {
return radius > 0 && color[3] > 0 && opacity > 0;
}
};

struct SymbolProperties {
inline SymbolProperties() {}

Expand Down Expand Up @@ -100,6 +114,7 @@ struct BackgroundProperties {
typedef mapbox::util::variant<
FillProperties,
LineProperties,
CircleProperties,
SymbolProperties,
RasterProperties,
BackgroundProperties,
Expand Down
2 changes: 2 additions & 0 deletions include/mbgl/style/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum class StyleLayerType : uint8_t {
Unknown,
Fill,
Line,
Circle,
Symbol,
Raster,
Background
Expand All @@ -36,6 +37,7 @@ MBGL_DEFINE_ENUM_CLASS(StyleLayerTypeClass, StyleLayerType, {
{ StyleLayerType::Unknown, "unknown" },
{ StyleLayerType::Fill, "fill" },
{ StyleLayerType::Line, "line" },
{ StyleLayerType::Circle, "circle" },
{ StyleLayerType::Symbol, "symbol" },
{ StyleLayerType::Raster, "raster" },
{ StyleLayerType::Background, "background" },
Expand Down
2 changes: 1 addition & 1 deletion ios/benchmark/MBXBenchViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ - (void)viewDidLoad
{
[super viewDidLoad];

NSURL* url = [[NSURL alloc] initWithString:@"asset://styles/mapbox-streets-v7.json"];
NSURL* url = [[NSURL alloc] initWithString:@"asset://styles/streets-v8.json"];
self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds styleURL:url];
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.mapView.delegate = self;
Expand Down
2 changes: 1 addition & 1 deletion ios/benchmark/fo/MBXBenchViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ - (void)viewDidLoad
{
[super viewDidLoad];

NSURL* url = [[NSURL alloc] initWithString:@"asset://styles/mapbox-streets-v7.json"];
NSURL* url = [[NSURL alloc] initWithString:@"asset://styles/streets-v8.json"];
self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds accessToken:nil styleURL:url];
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.mapView.delegate = self;
Expand Down
10 changes: 5 additions & 5 deletions platform/default/default_styles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ namespace mbgl {
namespace util {

const std::vector<std::pair<std::string, std::string>> defaultStyles = {
{ "asset://styles/mapbox-streets-v7.json", "Mapbox Streets" },
{ "asset://styles/emerald-v7.json", "Emerald" },
{ "asset://styles/light-v7.json", "Light" },
{ "asset://styles/dark-v7.json", "Dark" },
{ "asset://styles/satellite-v7.json", "Satellite" }
{ "asset://styles/streets-v8.json", "Mapbox Streets" },
{ "asset://styles/emerald-v8.json", "Emerald" },
{ "asset://styles/light-v8.json", "Light" },
{ "asset://styles/dark-v8.json", "Dark" },
{ "asset://styles/satellite-v8.json", "Satellite" }
};

} // end namespace util
Expand Down
2 changes: 1 addition & 1 deletion platform/default/sqlite_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void SQLiteCache::Impl::put(const Resource& resource, std::shared_ptr<const Resp
putStmt->bind(6 /* expires */, response->expires);

std::string data;
if (resource.kind != Resource::Image) {
if (resource.kind != Resource::SpriteImage) {
// Do not compress images, since they are typically compressed already.
data = util::compress(response->data);
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/ios/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ cp -pv LICENSE.md "${OUTPUT}/static"
mkdir -p "${OUTPUT}/static/${NAME}.bundle"
cp -pv platform/ios/resources/* "${OUTPUT}/static/${NAME}.bundle"
mkdir -p "${OUTPUT}/static/${NAME}.bundle/styles"
cp -pv styles/styles/{dark,emerald,light,mapbox-streets,satellite}-v7.json "${OUTPUT}/static/${NAME}.bundle/styles"
cp -pv styles/styles/{dark,emerald,light,streets,satellite}-v8.json "${OUTPUT}/static/${NAME}.bundle/styles"

step "Creating API Docs..."
if [ -z `which appledoc` ]; then
Expand Down
13 changes: 13 additions & 0 deletions src/mbgl/geometry/circle_buffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <mbgl/geometry/circle_buffer.hpp>

#include <mbgl/platform/gl.hpp>

#include <climits>

using namespace mbgl;

void CircleVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey) {
vertex_type *vertices = static_cast<vertex_type *>(addElement());
vertices[0] = (x * 2) + ((ex + 1) / 2);
vertices[1] = (y * 2) + ((ey + 1) / 2);
}
27 changes: 27 additions & 0 deletions src/mbgl/geometry/circle_buffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef MBGL_GEOMETRY_CIRCLE_BUFFER
#define MBGL_GEOMETRY_CIRCLE_BUFFER

#include <mbgl/geometry/buffer.hpp>

namespace mbgl {

class CircleVertexBuffer : public Buffer<
4 // 2 bytes per short * 4 of them.
> {
public:
typedef int16_t vertex_type;

/*
* Add a vertex to this buffer
*
* @param {number} x vertex position
* @param {number} y vertex position
* @param {number} ex extrude normal
* @param {number} ey extrude normal
*/
void add(vertex_type x, vertex_type y, float ex, float ey);
};

}

#endif // MBGL_GEOMETRY_CIRCLE_BUFFER
5 changes: 3 additions & 2 deletions src/mbgl/map/sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <mbgl/util/raster.hpp>
#include <mbgl/util/thread.hpp>
#include <mbgl/util/uv_detail.hpp>
#include <mbgl/util/mapbox.hpp>

#include <rapidjson/document.h>

Expand Down Expand Up @@ -49,7 +50,7 @@ Sprite::Sprite(const std::string& baseUrl, float pixelRatio_)
loader = std::make_unique<Loader>();

FileSource* fs = util::ThreadContext::getFileSource();
loader->jsonRequest = fs->request({ Resource::Kind::JSON, jsonURL }, util::RunLoop::getLoop(),
loader->jsonRequest = fs->request({ Resource::Kind::SpriteJSON, jsonURL }, util::RunLoop::getLoop(),
[this, jsonURL](const Response& res) {
loader->jsonRequest = nullptr;
if (res.status == Response::Successful) {
Expand All @@ -65,7 +66,7 @@ Sprite::Sprite(const std::string& baseUrl, float pixelRatio_)
});

loader->spriteRequest =
fs->request({ Resource::Kind::Image, spriteURL }, util::RunLoop::getLoop(),
fs->request({ Resource::Kind::SpriteImage, spriteURL }, util::RunLoop::getLoop(),
[this, spriteURL](const Response& res) {
loader->spriteRequest = nullptr;
if (res.status == Response::Successful) {
Expand Down
46 changes: 34 additions & 12 deletions src/mbgl/map/tile_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <mbgl/geometry/glyph_atlas.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/platform/log.hpp>
#include <mbgl/util/constants.hpp>
Expand Down Expand Up @@ -47,8 +48,8 @@ Bucket* TileWorker::getBucket(const StyleLayer& layer) const {
TileParseResult TileWorker::parse(const GeometryTile& geometryTile) {
partialParse = false;

for (const auto& layer : layers) {
parseLayer(*layer, geometryTile);
for (auto i = layers.rbegin(); i != layers.rend(); i++) {
parseLayer(**i, geometryTile);
}

return partialParse ? TileData::State::partial : TileData::State::parsed;
Expand All @@ -57,8 +58,8 @@ TileParseResult TileWorker::parse(const GeometryTile& geometryTile) {
void TileWorker::redoPlacement(float angle, bool collisionDebug) {
collision->reset(angle, 0);
collision->setDebug(collisionDebug);
for (const auto& layer_desc : layers) {
auto bucket = getBucket(*layer_desc);
for (auto i = layers.rbegin(); i != layers.rend(); i++) {
auto bucket = getBucket(**i);
if (bucket) {
bucket->placeFeatures();
}
Expand Down Expand Up @@ -139,15 +140,22 @@ void TileWorker::parseLayer(const StyleLayer& layer, const GeometryTile& geometr

std::unique_ptr<Bucket> bucket;

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

std::unique_ptr<Bucket> TileWorker::createCircleBucket(const GeometryTileLayer& layer,
const StyleBucket& bucket_desc) {
auto bucket = std::make_unique<CircleBucket>(circleVertexBuffer,
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> TileWorker::createSymbolBucket(const GeometryTileLayer& layer,
const StyleBucket& bucket_desc) {
auto bucket = std::make_unique<SymbolBucket>(*collision, id.overscaling);
Expand All @@ -215,14 +234,13 @@ std::unique_ptr<Bucket> TileWorker::createSymbolBucket(const GeometryTileLayer&
layout.icon.rotation_alignment = RotationAlignmentType::Map;
layout.text.rotation_alignment = RotationAlignmentType::Map;
};
applyLayoutProperty(PropertyKey::SymbolMinDistance, bucket_desc.layout, layout.min_distance, z);
applyLayoutProperty(PropertyKey::SymbolSpacing, bucket_desc.layout, layout.spacing, z);
applyLayoutProperty(PropertyKey::SymbolAvoidEdges, bucket_desc.layout, layout.avoid_edges, z);

applyLayoutProperty(PropertyKey::IconAllowOverlap, bucket_desc.layout, layout.icon.allow_overlap, z);
applyLayoutProperty(PropertyKey::IconIgnorePlacement, bucket_desc.layout, layout.icon.ignore_placement, z);
applyLayoutProperty(PropertyKey::IconOptional, bucket_desc.layout, layout.icon.optional, z);
applyLayoutProperty(PropertyKey::IconRotationAlignment, bucket_desc.layout, layout.icon.rotation_alignment, z);
applyLayoutProperty(PropertyKey::IconMaxSize, bucket_desc.layout, layout.icon.max_size, z);
applyLayoutProperty(PropertyKey::IconImage, bucket_desc.layout, layout.icon.image, z);
applyLayoutProperty(PropertyKey::IconPadding, bucket_desc.layout, layout.icon.padding, z);
applyLayoutProperty(PropertyKey::IconRotate, bucket_desc.layout, layout.icon.rotate, z);
Expand All @@ -232,7 +250,6 @@ std::unique_ptr<Bucket> TileWorker::createSymbolBucket(const GeometryTileLayer&
applyLayoutProperty(PropertyKey::TextRotationAlignment, bucket_desc.layout, layout.text.rotation_alignment, z);
applyLayoutProperty(PropertyKey::TextField, bucket_desc.layout, layout.text.field, z);
applyLayoutProperty(PropertyKey::TextFont, bucket_desc.layout, layout.text.font, z);
applyLayoutProperty(PropertyKey::TextMaxSize, bucket_desc.layout, layout.text.max_size, z);
applyLayoutProperty(PropertyKey::TextMaxWidth, bucket_desc.layout, layout.text.max_width, z);
applyLayoutProperty(PropertyKey::TextLineHeight, bucket_desc.layout, layout.text.line_height, z);
applyLayoutProperty(PropertyKey::TextLetterSpacing, bucket_desc.layout, layout.text.letter_spacing, z);
Expand All @@ -248,6 +265,11 @@ std::unique_ptr<Bucket> TileWorker::createSymbolBucket(const GeometryTileLayer&
applyLayoutProperty(PropertyKey::TextOffset, bucket_desc.layout, layout.text.offset, z);
applyLayoutProperty(PropertyKey::TextAllowOverlap, bucket_desc.layout, layout.text.allow_overlap, z);

applyLayoutProperty(PropertyKey::IconSize, bucket_desc.layout, layout.icon.size, z + 1);
applyLayoutProperty(PropertyKey::IconSize, bucket_desc.layout, layout.icon.max_size, 18);
applyLayoutProperty(PropertyKey::TextSize, bucket_desc.layout, layout.text.size, z + 1);
applyLayoutProperty(PropertyKey::TextSize, bucket_desc.layout, layout.text.max_size, 18);

if (bucket->needsDependencies(layer, bucket_desc.filter, *style.glyphStore, *style.sprite)) {
partialParse = true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/mbgl/map/tile_worker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <mbgl/geometry/elements_buffer.hpp>
#include <mbgl/geometry/fill_buffer.hpp>
#include <mbgl/geometry/line_buffer.hpp>
#include <mbgl/geometry/circle_buffer.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/ptr.hpp>
#include <mbgl/style/filter_expression.hpp>
Expand Down Expand Up @@ -52,6 +53,7 @@ class TileWorker : public util::noncopyable {

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 All @@ -68,6 +70,7 @@ class TileWorker : public util::noncopyable {

FillVertexBuffer fillVertexBuffer;
LineVertexBuffer lineVertexBuffer;
CircleVertexBuffer circleVertexBuffer;

TriangleElementsBuffer triangleElementsBuffer;
LineElementsBuffer lineElementsBuffer;
Expand Down
Loading