18
.clang-format
Normal file
18
.clang-format
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
BasedOnStyle: Google
|
||||
AccessModifierOffset: -4
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortLambdasOnASingleLine: Inline
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
ColumnLimit: 120
|
||||
IncludeBlocks: Preserve
|
||||
IndentWidth: 4
|
||||
Language: Cpp
|
||||
PackConstructorInitializers: Never
|
||||
PenaltyBreakAssignment: 80
|
||||
SortIncludes: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
Standard: c++17
|
||||
...
|
||||
7
.pre-commit-config.yaml
Normal file
7
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: v14.0.6
|
||||
hooks:
|
||||
- id: clang-format
|
||||
files: '.*\.(hpp|cpp|h)'
|
||||
exclude: '(vendor/.*|platform/(ios|darwin)/.*|test/ios/.*|render-test/ios/.*|benchmark/ios/.*)'
|
||||
@@ -1,5 +1,16 @@
|
||||
# Developing
|
||||
|
||||
|
||||
## Pre-commit hooks
|
||||
|
||||
Install [pre-commit](https://pre-commit.com/) and run
|
||||
|
||||
```
|
||||
pre-commit install
|
||||
```
|
||||
|
||||
to install the pre-commit hooks configured in `.pre-commit-config.yml`.
|
||||
|
||||
## Render Tests
|
||||
|
||||
To check that the output of the rendering is correct, we compare actual rendered PNGs for simple styles with expected PNGs. The content of the tests is stored in the MapLibre GL JS submodule which means that GL JS and Native are in fact quasi pixel-identical in their rendering.
|
||||
@@ -76,6 +87,7 @@ or any of the platform make files:
|
||||
* iOS developers can use [Xcode](https://developer.apple.com/support/debugging/). See also [Advanced Debugging with Xcode and LLDB](https://developer.apple.com/videos/play/wwdc2018/412/).
|
||||
|
||||
## Static Analysis
|
||||
|
||||
We use [`clang-tidy`](https://clang.llvm.org/extra/clang-tidy/) for static analysis and run it on CI for each pull request. If you want to run it locally use `-DMLN_WITH_CLANG_TIDY=ON` CMake option and just run regular build. For the list of enabled checks please see:
|
||||
[`.clang-tidy`](.clang-tidy) and [`test/.clang-tidy`](test/.clang-tidy)(for tests we are less strict and use different set of checks).
|
||||
|
||||
@@ -166,3 +178,6 @@ autoload -Uz compinit && compinit
|
||||
### Kotlin and Java compatibility
|
||||
|
||||
We are moving the Android SDK to Kotlin, which is backward compatible with Java, but if you need a Java version of the Android SDK there is a `before-kotlin-port` tag available.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,19 +21,20 @@ public:
|
||||
NetworkStatus::Set(NetworkStatus::Status::Offline);
|
||||
|
||||
map.getStyle().loadJSON(util::read_file("benchmark/fixtures/api/style.json"));
|
||||
map.jumpTo(CameraOptions().withCenter(LatLng { 40.726989, -73.992857 }).withZoom(15.0)); // Manhattan
|
||||
map.getStyle().addImage(std::make_unique<style::Image>("test-icon",
|
||||
decodeImage(util::read_file("benchmark/fixtures/api/default_marker.png")), 1.0f));
|
||||
map.jumpTo(CameraOptions().withCenter(LatLng{40.726989, -73.992857}).withZoom(15.0)); // Manhattan
|
||||
map.getStyle().addImage(std::make_unique<style::Image>(
|
||||
"test-icon", decodeImage(util::read_file("benchmark/fixtures/api/default_marker.png")), 1.0f));
|
||||
|
||||
frontend.render(map);
|
||||
}
|
||||
|
||||
util::RunLoop loop;
|
||||
HeadlessFrontend frontend { { 1000, 1000 }, 1 };
|
||||
Map map { frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
|
||||
ResourceOptions().withCachePath("benchmark/fixtures/api/cache.db").withAssetPath(".").withApiKey("foobar") };
|
||||
ScreenBox box{{ 0, 0 }, { 1000, 1000 }};
|
||||
HeadlessFrontend frontend{{1000, 1000}, 1};
|
||||
Map map{frontend,
|
||||
MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
|
||||
ResourceOptions().withCachePath("benchmark/fixtures/api/cache.db").withAssetPath(".").withApiKey("foobar")};
|
||||
ScreenBox box{{0, 0}, {1000, 1000}};
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
@@ -74,7 +75,7 @@ static void API_queryRenderedFeaturesLayerFromLowDensity(::benchmark::State& sta
|
||||
QueryBenchmark bench;
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
bench.frontend.getRenderer()->queryRenderedFeatures(bench.box, {{{ "testlayer" }}, {}});
|
||||
bench.frontend.getRenderer()->queryRenderedFeatures(bench.box, {{{"testlayer"}}, {}});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@ static void API_queryRenderedFeaturesLayerFromHighDensity(::benchmark::State& st
|
||||
QueryBenchmark bench;
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
bench.frontend.getRenderer()->queryRenderedFeatures(bench.box, {{{"road-street" }}, {}});
|
||||
bench.frontend.getRenderer()->queryRenderedFeatures(bench.box, {{{"road-street"}}, {}});
|
||||
}
|
||||
}
|
||||
BENCHMARK(API_queryPixelsForLatLngs);
|
||||
|
||||
@@ -22,22 +22,20 @@ using namespace mbgl;
|
||||
|
||||
namespace {
|
||||
|
||||
static std::string cachePath { "benchmark/fixtures/api/cache.db" };
|
||||
constexpr double pixelRatio { 1.0 };
|
||||
constexpr Size size { 1000, 1000 };
|
||||
static std::string cachePath{"benchmark/fixtures/api/cache.db"};
|
||||
constexpr double pixelRatio{1.0};
|
||||
constexpr Size size{1000, 1000};
|
||||
|
||||
class RenderBenchmark {
|
||||
public:
|
||||
RenderBenchmark() {
|
||||
NetworkStatus::Set(NetworkStatus::Status::Offline);
|
||||
}
|
||||
RenderBenchmark() { NetworkStatus::Set(NetworkStatus::Status::Offline); }
|
||||
|
||||
util::RunLoop loop;
|
||||
};
|
||||
|
||||
void prepare(Map& map, std::optional<std::string> json = std::nullopt) {
|
||||
map.getStyle().loadJSON(json ? *json : util::read_file("benchmark/fixtures/api/style.json"));
|
||||
map.jumpTo(CameraOptions().withCenter(LatLng { 40.726989, -73.992857 }).withZoom(15.0)); // Manhattan
|
||||
map.jumpTo(CameraOptions().withCenter(LatLng{40.726989, -73.992857}).withZoom(15.0)); // Manhattan
|
||||
|
||||
auto image = decodeImage(util::read_file("benchmark/fixtures/api/default_marker.png"));
|
||||
map.getStyle().addImage(std::make_unique<style::Image>("test-icon", std::move(image), 1.0f));
|
||||
@@ -55,10 +53,11 @@ void prepare_map2(Map& map, std::optional<std::string> json = std::nullopt) {
|
||||
|
||||
static void API_renderStill_reuse_map(::benchmark::State& state) {
|
||||
RenderBenchmark bench;
|
||||
HeadlessFrontend frontend { size, pixelRatio };
|
||||
Map map { frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withApiKey("foobar") };
|
||||
HeadlessFrontend frontend{size, pixelRatio};
|
||||
Map map{frontend,
|
||||
MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withApiKey("foobar")};
|
||||
prepare(map);
|
||||
|
||||
for (auto _ : state) {
|
||||
@@ -68,10 +67,11 @@ static void API_renderStill_reuse_map(::benchmark::State& state) {
|
||||
|
||||
static void API_renderStill_reuse_map_formatted_labels(::benchmark::State& state) {
|
||||
RenderBenchmark bench;
|
||||
HeadlessFrontend frontend { size, pixelRatio };
|
||||
Map map { frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withApiKey("foobar") };
|
||||
HeadlessFrontend frontend{size, pixelRatio};
|
||||
Map map{frontend,
|
||||
MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withApiKey("foobar")};
|
||||
prepare(map, util::read_file("benchmark/fixtures/api/style_formatted_labels.json"));
|
||||
|
||||
for (auto _ : state) {
|
||||
@@ -81,13 +81,14 @@ static void API_renderStill_reuse_map_formatted_labels(::benchmark::State& state
|
||||
|
||||
static void API_renderStill_reuse_map_switch_styles(::benchmark::State& state) {
|
||||
RenderBenchmark bench;
|
||||
HeadlessFrontend frontend { size, pixelRatio };
|
||||
Map map { frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withApiKey("foobar") };
|
||||
HeadlessFrontend frontend{size, pixelRatio};
|
||||
Map map{frontend,
|
||||
MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withApiKey("foobar")};
|
||||
|
||||
for (auto _ : state) {
|
||||
prepare(map, { "{}" });
|
||||
prepare(map, {"{}"});
|
||||
frontend.render(map);
|
||||
prepare(map);
|
||||
frontend.render(map);
|
||||
@@ -98,10 +99,11 @@ static void API_renderStill_recreate_map(::benchmark::State& state) {
|
||||
RenderBenchmark bench;
|
||||
|
||||
for (auto _ : state) {
|
||||
HeadlessFrontend frontend { size, pixelRatio };
|
||||
Map map { frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withApiKey("foobar") };
|
||||
HeadlessFrontend frontend{size, pixelRatio};
|
||||
Map map{frontend,
|
||||
MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cachePath).withApiKey("foobar")};
|
||||
prepare(map);
|
||||
frontend.render(map);
|
||||
}
|
||||
|
||||
@@ -21,13 +21,14 @@ static std::string createFunctionJSON(size_t stopCount) {
|
||||
|
||||
static void Parse_CameraFunction(benchmark::State& state) {
|
||||
size_t stopCount = state.range(0);
|
||||
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
conversion::Error error;
|
||||
state.PauseTiming();
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
state.ResumeTiming();
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, false, false);
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, false, false);
|
||||
if (!result) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
@@ -39,23 +40,20 @@ static void Evaluate_CameraFunction(benchmark::State& state) {
|
||||
size_t stopCount = state.range(0);
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
conversion::Error error;
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, false, false);
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, false, false);
|
||||
if (!function) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
|
||||
while(state.KeepRunning()) {
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
float z = 24.0f * static_cast<float>(rand() % 100) / 100;
|
||||
function->asExpression().evaluate(z);
|
||||
}
|
||||
|
||||
|
||||
state.SetLabel(std::to_string(stopCount).c_str());
|
||||
}
|
||||
|
||||
BENCHMARK(Parse_CameraFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_CameraFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Parse_CameraFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_CameraFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
@@ -18,7 +18,7 @@ static std::string createFunctionJSON(size_t stopCount) {
|
||||
std::string value = std::to_string(100.0f / stopCount * innerStop);
|
||||
|
||||
if (stops.size() > 1) stops += ",";
|
||||
stops += R"([{"zoom":)" + zoom + R"(,"value":)" + value + "}, " + value + "]";
|
||||
stops += R"([{"zoom":)" + zoom + R"(,"value":)" + value + "}, " + value + "]";
|
||||
}
|
||||
}
|
||||
stops += "]";
|
||||
@@ -33,7 +33,8 @@ static void Parse_CompositeFunction(benchmark::State& state) {
|
||||
state.PauseTiming();
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
state.ResumeTiming();
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, true, false);
|
||||
if (!result) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
@@ -45,23 +46,21 @@ static void Evaluate_CompositeFunction(benchmark::State& state) {
|
||||
size_t stopCount = state.range(0);
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
conversion::Error error;
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, true, false);
|
||||
if (!function) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
|
||||
while(state.KeepRunning()) {
|
||||
while (state.KeepRunning()) {
|
||||
float z = 24.0f * static_cast<float>(rand() % 100) / 100;
|
||||
function->asExpression().evaluate(z, StubGeometryTileFeature(PropertyMap { { "x", static_cast<int64_t>(rand() % 100) } }), -1.0f);
|
||||
function->asExpression().evaluate(
|
||||
z, StubGeometryTileFeature(PropertyMap{{"x", static_cast<int64_t>(rand() % 100)}}), -1.0f);
|
||||
}
|
||||
|
||||
state.SetLabel(std::to_string(stopCount).c_str());
|
||||
}
|
||||
|
||||
BENCHMARK(Parse_CompositeFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_CompositeFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Parse_CompositeFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_CompositeFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
@@ -28,7 +28,8 @@ static void Parse_SourceFunction(benchmark::State& state) {
|
||||
state.PauseTiming();
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
state.ResumeTiming();
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, true, false);
|
||||
if (!result) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
@@ -40,22 +41,20 @@ static void Evaluate_SourceFunction(benchmark::State& state) {
|
||||
size_t stopCount = state.range(0);
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
conversion::Error error;
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, true, false);
|
||||
if (!function) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
|
||||
while(state.KeepRunning()) {
|
||||
function->asExpression().evaluate(StubGeometryTileFeature(PropertyMap { { "x", static_cast<int64_t>(rand() % 100) } }), -1.0f);
|
||||
while (state.KeepRunning()) {
|
||||
function->asExpression().evaluate(
|
||||
StubGeometryTileFeature(PropertyMap{{"x", static_cast<int64_t>(rand() % 100)}}), -1.0f);
|
||||
}
|
||||
|
||||
state.SetLabel(std::to_string(stopCount).c_str());
|
||||
}
|
||||
|
||||
BENCHMARK(Parse_SourceFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_SourceFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Parse_SourceFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_SourceFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
@@ -22,7 +22,7 @@ static void Parse_Filter(benchmark::State& state) {
|
||||
|
||||
static void Parse_EvaluateFilter(benchmark::State& state) {
|
||||
const style::Filter filter = parse(R"FILTER(["==", "foo", "bar"])FILTER");
|
||||
const StubGeometryTileFeature feature = { {}, FeatureType::Unknown , {}, {{ "foo", std::string("bar") }} };
|
||||
const StubGeometryTileFeature feature = {{}, FeatureType::Unknown, {}, {{"foo", std::string("bar")}}};
|
||||
const style::expression::EvaluationContext context(&feature);
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
|
||||
@@ -7,11 +7,8 @@ using namespace mbgl;
|
||||
class FakeTile {
|
||||
public:
|
||||
FakeTile(TileMask mask_)
|
||||
: mask(std::move(mask_)) {
|
||||
}
|
||||
void setMask(TileMask mask_) {
|
||||
mask = std::move(mask_);
|
||||
}
|
||||
: mask(std::move(mask_)) {}
|
||||
void setMask(TileMask mask_) { mask = std::move(mask_); }
|
||||
|
||||
const bool usedByRenderedLayers = true;
|
||||
TileMask mask;
|
||||
@@ -19,13 +16,13 @@ public:
|
||||
|
||||
static void TileMaskGeneration(benchmark::State& state) {
|
||||
std::map<UnwrappedTileID, FakeTile> renderables = {
|
||||
{ UnwrappedTileID{ 12, 1028, 1456 }, TileMask{} },
|
||||
{ UnwrappedTileID{ 13, 2056, 2912 }, TileMask{} },
|
||||
{ UnwrappedTileID{ 13, 2056, 2913 }, TileMask{} },
|
||||
{ UnwrappedTileID{ 14, 4112, 5824 }, TileMask{} },
|
||||
{ UnwrappedTileID{ 14, 4112, 5827 }, TileMask{} },
|
||||
{ UnwrappedTileID{ 14, 4114, 5824 }, TileMask{} },
|
||||
{ UnwrappedTileID{ 14, 4114, 5825 }, TileMask{} },
|
||||
{UnwrappedTileID{12, 1028, 1456}, TileMask{}},
|
||||
{UnwrappedTileID{13, 2056, 2912}, TileMask{}},
|
||||
{UnwrappedTileID{13, 2056, 2913}, TileMask{}},
|
||||
{UnwrappedTileID{14, 4112, 5824}, TileMask{}},
|
||||
{UnwrappedTileID{14, 4112, 5827}, TileMask{}},
|
||||
{UnwrappedTileID{14, 4114, 5824}, TileMask{}},
|
||||
{UnwrappedTileID{14, 4114, 5825}, TileMask{}},
|
||||
};
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
using namespace mbgl;
|
||||
|
||||
static void Parse_VectorTile(benchmark::State& state) {
|
||||
auto data = std::make_shared<std::string>(util::read_file("test/fixtures/api/assets/streets/10-163-395.vector.pbf"));
|
||||
auto data = std::make_shared<std::string>(
|
||||
util::read_file("test/fixtures/api/assets/streets/10-163-395.vector.pbf"));
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
std::size_t length = 0;
|
||||
|
||||
@@ -8,34 +8,29 @@ using namespace mbgl;
|
||||
class StubGeometryTileFeature : public GeometryTileFeature {
|
||||
public:
|
||||
StubGeometryTileFeature(PropertyMap properties_)
|
||||
: properties(std::move(properties_)) {
|
||||
}
|
||||
: properties(std::move(properties_)) {}
|
||||
|
||||
StubGeometryTileFeature(FeatureIdentifier id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_)
|
||||
StubGeometryTileFeature(FeatureIdentifier id_,
|
||||
FeatureType type_,
|
||||
GeometryCollection geometry_,
|
||||
PropertyMap properties_)
|
||||
: properties(std::move(properties_)),
|
||||
id(std::move(id_)),
|
||||
type(type_),
|
||||
geometry(std::move(geometry_)) {
|
||||
}
|
||||
geometry(std::move(geometry_)) {}
|
||||
|
||||
PropertyMap properties;
|
||||
FeatureIdentifier id;
|
||||
FeatureType type = FeatureType::Point;
|
||||
GeometryCollection geometry;
|
||||
|
||||
FeatureType getType() const override {
|
||||
return type;
|
||||
}
|
||||
FeatureType getType() const override { return type; }
|
||||
|
||||
FeatureIdentifier getID() const override {
|
||||
return id;
|
||||
}
|
||||
FeatureIdentifier getID() const override { return id; }
|
||||
|
||||
std::optional<Value> getValue(const std::string& key) const override {
|
||||
return properties.count(key) ? properties.at(key) : std::optional<Value>();
|
||||
}
|
||||
|
||||
const GeometryCollection& getGeometries() const override {
|
||||
return geometry;
|
||||
}
|
||||
const GeometryCollection& getGeometries() const override { return geometry; }
|
||||
};
|
||||
|
||||
@@ -30,7 +30,8 @@ public:
|
||||
db.clearAmbientCache();
|
||||
|
||||
for (unsigned i = 0; i < tileCount; ++i) {
|
||||
const Resource ambient = Resource::tile("mapbox://tile_ambient" + util::toString(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource ambient = Resource::tile(
|
||||
"mapbox://tile_ambient" + util::toString(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(ambient, response);
|
||||
}
|
||||
}
|
||||
@@ -43,14 +44,16 @@ public:
|
||||
db.deleteRegion(std::move(regions[0]));
|
||||
}
|
||||
|
||||
OfflineTilePyramidRegionDefinition definition{ "mapbox://style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineRegionMetadata metadata{{ 1, 2, 3 }};
|
||||
OfflineTilePyramidRegionDefinition definition{
|
||||
"mapbox://style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true};
|
||||
OfflineRegionMetadata metadata{{1, 2, 3}};
|
||||
|
||||
auto region = db.createRegion(definition, metadata);
|
||||
regionID = region->getID();
|
||||
|
||||
for (unsigned i = 0; i < tileCount; ++i) {
|
||||
const Resource offline = Resource::tile("mapbox://tile_offline_region" + util::toString(i), 1.0, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource offline = Resource::tile(
|
||||
"mapbox://tile_offline_region" + util::toString(i), 1.0, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.putRegionResource(regionID, offline, response);
|
||||
}
|
||||
}
|
||||
@@ -78,8 +81,8 @@ BENCHMARK_F(OfflineDatabase, InsertTileRegion)(benchmark::State& state) {
|
||||
using namespace mbgl;
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
const Resource offline = Resource::tile("mapbox://InsertTileRegion" +
|
||||
util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource offline = Resource::tile(
|
||||
"mapbox://InsertTileRegion" + util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.putRegionResource(regionID, offline, response);
|
||||
}
|
||||
}
|
||||
@@ -99,8 +102,8 @@ BENCHMARK_F(OfflineDatabase, InsertTileCache)(benchmark::State& state) {
|
||||
using namespace mbgl;
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
const Resource ambient = Resource::tile("mapbox://InsertTileCache" +
|
||||
util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource ambient = Resource::tile(
|
||||
"mapbox://InsertTileCache" + util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(ambient, response);
|
||||
}
|
||||
}
|
||||
@@ -112,8 +115,8 @@ BENCHMARK_F(OfflineDatabase, InsertBigTileCache)(benchmark::State& state) {
|
||||
big.data = std::make_shared<std::string>(util::DEFAULT_MAX_CACHE_SIZE / 100, 0);
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
const Resource ambient = Resource::tile("mapbox://InsertTileCache" +
|
||||
util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource ambient = Resource::tile(
|
||||
"mapbox://InsertTileCache" + util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(ambient, big);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +129,8 @@ BENCHMARK_F(OfflineDatabase, GetTile)(benchmark::State& state) {
|
||||
std::uniform_int_distribution<> dis(0, tileCount - 1);
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
auto res = db.get(Resource::tile("mapbox://tile_ambient" + util::toString(dis(gen)), 1, 0, 0, 0, Tileset::Scheme::XYZ));
|
||||
auto res = db.get(
|
||||
Resource::tile("mapbox://tile_ambient" + util::toString(dis(gen)), 1, 0, 0, 0, Tileset::Scheme::XYZ));
|
||||
assert(res != std::nullopt);
|
||||
}
|
||||
}
|
||||
@@ -138,15 +142,16 @@ BENCHMARK_F(OfflineDatabase, AddTilesToFullDatabase)(benchmark::State& state) {
|
||||
db.setMaximumAmbientCacheSize(50 * 1024 * 5);
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
const Resource ambient = Resource::tile("mapbox://AddTilesToFullDatabase" +
|
||||
util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource ambient = Resource::tile(
|
||||
"mapbox://AddTilesToFullDatabase" + util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(ambient, response);
|
||||
}
|
||||
|
||||
Log::removeObserver();
|
||||
}
|
||||
|
||||
BENCHMARK_F(OfflineDatabase, AddTilesToDisabledDatabase)(benchmark::State& state) {
|
||||
BENCHMARK_F(OfflineDatabase, AddTilesToDisabledDatabase)
|
||||
(benchmark::State& state) {
|
||||
using namespace mbgl;
|
||||
|
||||
auto regions = db.listRegions().value();
|
||||
@@ -158,13 +163,14 @@ BENCHMARK_F(OfflineDatabase, AddTilesToDisabledDatabase)(benchmark::State& state
|
||||
db.setMaximumAmbientCacheSize(0);
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
const Resource ambient = Resource::tile("mapbox://AddTilesToFullDatabase" +
|
||||
util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource ambient = Resource::tile(
|
||||
"mapbox://AddTilesToFullDatabase" + util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(ambient, response);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_F(OfflineDatabase, GetTileFromDisabledDatabase)(benchmark::State& state) {
|
||||
BENCHMARK_F(OfflineDatabase, GetTileFromDisabledDatabase)
|
||||
(benchmark::State& state) {
|
||||
using namespace mbgl;
|
||||
|
||||
auto regions = db.listRegions().value();
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
static const LatLngBounds sanFrancisco =
|
||||
LatLngBounds::hull({ 37.6609, -122.5744 }, { 37.8271, -122.3204 });
|
||||
static const LatLngBounds sanFrancisco = LatLngBounds::hull({37.6609, -122.5744}, {37.8271, -122.3204});
|
||||
|
||||
static void TileCountBounds(benchmark::State& state) {
|
||||
std::size_t length = 0;
|
||||
@@ -21,9 +20,9 @@ static void TileCountBounds(benchmark::State& state) {
|
||||
|
||||
static void TileCoverPitchedViewport(benchmark::State& state) {
|
||||
Transform transform;
|
||||
transform.resize({ 512, 512 });
|
||||
transform.resize({512, 512});
|
||||
// slightly offset center so that tile order is better defined
|
||||
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.1, -0.1 }).withZoom(8.0).withBearing(5.0).withPitch(40.0));
|
||||
transform.jumpTo(CameraOptions().withCenter(LatLng{0.1, -0.1}).withZoom(8.0).withBearing(5.0).withPitch(40.0));
|
||||
|
||||
std::size_t length = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -43,32 +42,18 @@ static void TileCoverBounds(benchmark::State& state) {
|
||||
}
|
||||
|
||||
static const auto geomPolygon = Polygon<double>{
|
||||
{
|
||||
{-122.5143814086914,37.779127216982424},
|
||||
{-122.50811576843262,37.72721239056709},
|
||||
{-122.50313758850099,37.70820178063929},
|
||||
{-122.3938751220703,37.707454835665274},
|
||||
{-122.37567901611328,37.70663997801684},
|
||||
{-122.36297607421874,37.71343018466285},
|
||||
{-122.354736328125,37.727280276860036},
|
||||
{-122.36469268798828,37.73868429065797},
|
||||
{-122.38014221191408,37.75442980295571},
|
||||
{-122.38391876220702,37.78753873820529},
|
||||
{-122.35919952392578,37.8065289741725},
|
||||
{-122.35679626464844,37.820632846207864},
|
||||
{-122.3712158203125,37.835276322922695},
|
||||
{-122.3818588256836,37.82958198283902},
|
||||
{-122.37190246582031,37.80788523279169},
|
||||
{-122.38735198974608,37.791337175930686},
|
||||
{-122.40966796874999,37.812767557570204},
|
||||
{-122.46425628662108,37.807071480609274},
|
||||
{-122.46803283691405,37.810326435534755},
|
||||
{-122.47901916503906,37.81168262440736},
|
||||
{-122.48966217041016,37.78916666399649},
|
||||
{-122.50579833984375,37.78781006166096},
|
||||
{-122.5143814086914,37.779127216982424}
|
||||
}
|
||||
};
|
||||
{{-122.5143814086914, 37.779127216982424}, {-122.50811576843262, 37.72721239056709},
|
||||
{-122.50313758850099, 37.70820178063929}, {-122.3938751220703, 37.707454835665274},
|
||||
{-122.37567901611328, 37.70663997801684}, {-122.36297607421874, 37.71343018466285},
|
||||
{-122.354736328125, 37.727280276860036}, {-122.36469268798828, 37.73868429065797},
|
||||
{-122.38014221191408, 37.75442980295571}, {-122.38391876220702, 37.78753873820529},
|
||||
{-122.35919952392578, 37.8065289741725}, {-122.35679626464844, 37.820632846207864},
|
||||
{-122.3712158203125, 37.835276322922695}, {-122.3818588256836, 37.82958198283902},
|
||||
{-122.37190246582031, 37.80788523279169}, {-122.38735198974608, 37.791337175930686},
|
||||
{-122.40966796874999, 37.812767557570204}, {-122.46425628662108, 37.807071480609274},
|
||||
{-122.46803283691405, 37.810326435534755}, {-122.47901916503906, 37.81168262440736},
|
||||
{-122.48966217041016, 37.78916666399649}, {-122.50579833984375, 37.78781006166096},
|
||||
{-122.5143814086914, 37.779127216982424}}};
|
||||
|
||||
static void TileCoverPolygon(benchmark::State& state) {
|
||||
std::size_t length = 0;
|
||||
@@ -95,4 +80,3 @@ BENCHMARK(TileCountPolygon);
|
||||
BENCHMARK(TileCoverPitchedViewport);
|
||||
BENCHMARK(TileCoverBounds);
|
||||
BENCHMARK(TileCoverPolygon);
|
||||
|
||||
|
||||
123
bin/offline.cpp
123
bin/offline.cpp
@@ -24,52 +24,47 @@ std::string readFile(const std::string& fileName) {
|
||||
if (!stream.good()) {
|
||||
throw std::runtime_error("Cannot read file: " + fileName);
|
||||
}
|
||||
|
||||
|
||||
std::stringstream buffer;
|
||||
buffer << stream.rdbuf();
|
||||
stream.close();
|
||||
|
||||
|
||||
return buffer.str();
|
||||
}
|
||||
|
||||
mapbox::geometry::geometry<double> parseGeometry(const std::string& json) {
|
||||
using namespace mapbox::geojson;
|
||||
auto geojson = parse(json);
|
||||
return geojson.match(
|
||||
[](const geometry& geom) {
|
||||
return geom;
|
||||
},
|
||||
[](const feature& feature) {
|
||||
return feature.geometry;
|
||||
},
|
||||
[](const feature_collection& featureCollection) {
|
||||
if (featureCollection.size() < 1) {
|
||||
throw std::runtime_error("No features in feature collection");
|
||||
}
|
||||
geometry_collection geometries;
|
||||
|
||||
for (auto feature : featureCollection) {
|
||||
geometries.push_back(feature.geometry);
|
||||
}
|
||||
|
||||
return geometries;
|
||||
});
|
||||
return geojson.match([](const geometry& geom) { return geom; },
|
||||
[](const feature& feature) { return feature.geometry; },
|
||||
[](const feature_collection& featureCollection) {
|
||||
if (featureCollection.size() < 1) {
|
||||
throw std::runtime_error("No features in feature collection");
|
||||
}
|
||||
geometry_collection geometries;
|
||||
|
||||
for (auto feature : featureCollection) {
|
||||
geometries.push_back(feature.geometry);
|
||||
}
|
||||
|
||||
return geometries;
|
||||
});
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, mbgl::Response::Error::Reason r) {
|
||||
switch (r) {
|
||||
case mbgl::Response::Error::Reason::Success:
|
||||
return os << "Response::Error::Reason::Success";
|
||||
case mbgl::Response::Error::Reason::NotFound:
|
||||
return os << "Response::Error::Reason::NotFound";
|
||||
case mbgl::Response::Error::Reason::Server:
|
||||
return os << "Response::Error::Reason::Server";
|
||||
case mbgl::Response::Error::Reason::Connection:
|
||||
return os << "Response::Error::Reason::Connection";
|
||||
case mbgl::Response::Error::Reason::RateLimit:
|
||||
return os << "Response::Error::Reason::RateLimit";
|
||||
case mbgl::Response::Error::Reason::Other:
|
||||
return os << "Response::Error::Reason::Other";
|
||||
case mbgl::Response::Error::Reason::Success:
|
||||
return os << "Response::Error::Reason::Success";
|
||||
case mbgl::Response::Error::Reason::NotFound:
|
||||
return os << "Response::Error::Reason::NotFound";
|
||||
case mbgl::Response::Error::Reason::Server:
|
||||
return os << "Response::Error::Reason::Server";
|
||||
case mbgl::Response::Error::Reason::Connection:
|
||||
return os << "Response::Error::Reason::Connection";
|
||||
case mbgl::Response::Error::Reason::RateLimit:
|
||||
return os << "Response::Error::Reason::RateLimit";
|
||||
case mbgl::Response::Error::Reason::Other:
|
||||
return os << "Response::Error::Reason::Other";
|
||||
}
|
||||
|
||||
// The above switch is exhaustive, but placate GCC nonetheless:
|
||||
@@ -77,7 +72,7 @@ std::ostream& operator<<(std::ostream& os, mbgl::Response::Error::Reason r) {
|
||||
return os;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char* argv[]) {
|
||||
args::ArgumentParser argumentParser("Mapbox GL offline tool");
|
||||
args::HelpFlag helpFlag(argumentParser, "help", "Display this help menu", {'h', "help"});
|
||||
|
||||
@@ -85,10 +80,11 @@ int main(int argc, char *argv[]) {
|
||||
args::ValueFlag<std::string> styleValue(argumentParser, "URL", "Map stylesheet", {'s', "style"});
|
||||
args::ValueFlag<std::string> outputValue(argumentParser, "file", "Output database file name", {'o', "output"});
|
||||
args::ValueFlag<std::string> apiBaseValue(argumentParser, "URL", "API Base URL", {'a', "apiBaseURL"});
|
||||
|
||||
|
||||
args::Group mergeGroup(argumentParser, "Merge databases:", args::Group::Validators::AllOrNone);
|
||||
args::ValueFlag<std::string> mergePathValue(mergeGroup, "merge", "Database to merge from", {'m', "merge"});
|
||||
args::ValueFlag<std::string> inputValue(mergeGroup, "input", "Database to merge into. Use with --merge option.", {'i', "input"});
|
||||
args::ValueFlag<std::string> inputValue(
|
||||
mergeGroup, "input", "Database to merge into. Use with --merge option.", {'i', "input"});
|
||||
|
||||
// LatLngBounds
|
||||
args::Group latLngBoundsGroup(argumentParser, "LatLng bounds:", args::Group::Validators::AllOrNone);
|
||||
@@ -99,12 +95,17 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Geometry
|
||||
args::Group geoJSONGroup(argumentParser, "GeoJson geometry:", args::Group::Validators::AllOrNone);
|
||||
args::ValueFlag<std::string> geometryValue(geoJSONGroup, "file", "GeoJSON Feature file containing the region geometry (can't be a FeatureCollection)", {"geojson"});
|
||||
args::ValueFlag<std::string> geometryValue(geoJSONGroup,
|
||||
"file",
|
||||
"GeoJSON Feature file containing the region geometry (can't be a "
|
||||
"FeatureCollection)",
|
||||
{"geojson"});
|
||||
|
||||
args::ValueFlag<double> minZoomValue(argumentParser, "number", "Min zoom level", {"minZoom"});
|
||||
args::ValueFlag<double> maxZoomValue(argumentParser, "number", "Max zoom level", {"maxZoom"});
|
||||
args::ValueFlag<double> pixelRatioValue(argumentParser, "number", "Pixel ratio", {"pixelRatio"});
|
||||
args::ValueFlag<bool> includeIdeographsValue(argumentParser, "boolean", "Include CJK glyphs", {"includeIdeographs"});
|
||||
args::ValueFlag<bool> includeIdeographsValue(
|
||||
argumentParser, "boolean", "Include CJK glyphs", {"includeIdeographs"});
|
||||
|
||||
try {
|
||||
argumentParser.ParseCLI(argc, argv);
|
||||
@@ -122,10 +123,10 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
auto mapTilerConfiguration = mbgl::TileServerOptions::MapTilerConfiguration();
|
||||
|
||||
|
||||
std::string style = styleValue ? args::get(styleValue) : mapTilerConfiguration.defaultStyles().at(0).getUrl();
|
||||
std::cout << " Style: " << style << std::endl;
|
||||
|
||||
|
||||
std::optional<std::string> mergePath = std::nullopt;
|
||||
if (mergePathValue) mergePath = args::get(mergePathValue);
|
||||
std::optional<std::string> inputDb = std::nullopt;
|
||||
@@ -136,16 +137,17 @@ int main(int argc, char *argv[]) {
|
||||
const double pixelRatio = pixelRatioValue ? args::get(pixelRatioValue) : 1.0;
|
||||
const bool includeIdeographs = includeIdeographsValue ? args::get(includeIdeographsValue) : false;
|
||||
const std::string output = outputValue ? args::get(outputValue) : "offline.db";
|
||||
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
|
||||
OfflineRegionDefinition definition = [&]() {
|
||||
if (geometryValue) {
|
||||
try {
|
||||
std::string json = readFile(geometryValue.Get());
|
||||
auto geometry = parseGeometry(json);
|
||||
return OfflineRegionDefinition{ OfflineGeometryRegionDefinition(style, geometry, minZoom, maxZoom, static_cast<float>(pixelRatio), includeIdeographs) };
|
||||
} catch(const std::runtime_error& e) {
|
||||
return OfflineRegionDefinition{OfflineGeometryRegionDefinition(
|
||||
style, geometry, minZoom, maxZoom, static_cast<float>(pixelRatio), includeIdeographs)};
|
||||
} catch (const std::runtime_error& e) {
|
||||
std::cerr << "Could not parse geojson file " << geometryValue.Get() << ": " << e.what() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
@@ -156,13 +158,14 @@ int main(int argc, char *argv[]) {
|
||||
const double south = southValue ? args::get(southValue) : 38.1;
|
||||
const double east = eastValue ? args::get(eastValue) : -121.7;
|
||||
LatLngBounds boundingBox = LatLngBounds::hull(LatLng(north, west), LatLng(south, east));
|
||||
return OfflineRegionDefinition{ OfflineTilePyramidRegionDefinition(style, boundingBox, minZoom, maxZoom, static_cast<float>(pixelRatio), includeIdeographs) };
|
||||
return OfflineRegionDefinition{OfflineTilePyramidRegionDefinition(
|
||||
style, boundingBox, minZoom, maxZoom, static_cast<float>(pixelRatio), includeIdeographs)};
|
||||
}
|
||||
}();
|
||||
|
||||
const char* apiEnv = getenv("MLN_API_KEY");
|
||||
const std::string apiKey = tokenValue ? args::get(tokenValue) : (apiEnv ? apiEnv : std::string());
|
||||
|
||||
|
||||
if (apiBaseValue) {
|
||||
mapTilerConfiguration.withBaseURL(args::get(apiBaseValue));
|
||||
}
|
||||
@@ -171,9 +174,7 @@ int main(int argc, char *argv[]) {
|
||||
std::shared_ptr<DatabaseFileSource> fileSource = std::static_pointer_cast<DatabaseFileSource>(
|
||||
std::shared_ptr<FileSource>(FileSourceManager::get()->getFileSource(
|
||||
FileSourceType::Database,
|
||||
ResourceOptions().withApiKey(apiKey)
|
||||
.withTileServerOptions(mapTilerConfiguration)
|
||||
.withCachePath(output),
|
||||
ResourceOptions().withApiKey(apiKey).withTileServerOptions(mapTilerConfiguration).withCachePath(output),
|
||||
ClientOptions())));
|
||||
|
||||
std::unique_ptr<OfflineRegion> region;
|
||||
@@ -183,17 +184,17 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
int retCode = 0;
|
||||
std::cout << "Start Merge" << std::endl;
|
||||
inputSource.mergeOfflineRegions(*mergePath, [&] (mbgl::expected<std::vector<OfflineRegion>, std::exception_ptr> result) {
|
||||
|
||||
if (!result) {
|
||||
std::cerr << "Error merging database: " << util::toString(result.error()) << std::endl;
|
||||
retCode = 1;
|
||||
} else {
|
||||
std::cout << " Added " << result->size() << " Regions" << std::endl;
|
||||
std::cout << "Finished Merge" << std::endl;
|
||||
}
|
||||
loop.stop();
|
||||
});
|
||||
inputSource.mergeOfflineRegions(
|
||||
*mergePath, [&](mbgl::expected<std::vector<OfflineRegion>, std::exception_ptr> result) {
|
||||
if (!result) {
|
||||
std::cerr << "Error merging database: " << util::toString(result.error()) << std::endl;
|
||||
retCode = 1;
|
||||
} else {
|
||||
std::cout << " Added " << result->size() << " Regions" << std::endl;
|
||||
std::cout << "Finished Merge" << std::endl;
|
||||
}
|
||||
loop.stop();
|
||||
});
|
||||
loop.run();
|
||||
return retCode;
|
||||
}
|
||||
@@ -260,7 +261,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
};
|
||||
|
||||
std::signal(SIGINT, [] (int) { stop(); });
|
||||
std::signal(SIGINT, [](int) { stop(); });
|
||||
|
||||
fileSource->createOfflineRegion(
|
||||
definition, metadata, [&](mbgl::expected<OfflineRegion, std::exception_ptr> region_) {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char* argv[]) {
|
||||
args::ArgumentParser argumentParser("Mapbox GL render tool");
|
||||
args::HelpFlag helpFlag(argumentParser, "help", "Display this help menu", {"help"});
|
||||
|
||||
@@ -22,7 +22,8 @@ int main(int argc, char *argv[]) {
|
||||
args::ValueFlag<std::string> styleValue(argumentParser, "URL", "Map stylesheet", {'s', "style"});
|
||||
args::ValueFlag<std::string> outputValue(argumentParser, "file", "Output file name", {'o', "output"});
|
||||
args::ValueFlag<std::string> cacheValue(argumentParser, "file", "Cache database file name", {'c', "cache"});
|
||||
args::ValueFlag<std::string> assetsValue(argumentParser, "file", "Directory to which asset:// URLs will resolve", {'a', "assets"});
|
||||
args::ValueFlag<std::string> assetsValue(
|
||||
argumentParser, "file", "Directory to which asset:// URLs will resolve", {'a', "assets"});
|
||||
|
||||
args::Flag debugFlag(argumentParser, "debug", "Debug mode", {"debug"});
|
||||
|
||||
@@ -78,31 +79,36 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
util::RunLoop loop;
|
||||
|
||||
HeadlessFrontend frontend({ width, height }, static_cast<float>(pixelRatio));
|
||||
Map map(frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(static_cast<float>(pixelRatio)),
|
||||
ResourceOptions().withCachePath(cache_file).withAssetPath(asset_root).withApiKey(apikey).withTileServerOptions(mapTilerConfiguration));
|
||||
HeadlessFrontend frontend({width, height}, static_cast<float>(pixelRatio));
|
||||
Map map(frontend,
|
||||
MapObserver::nullObserver(),
|
||||
MapOptions()
|
||||
.withMapMode(MapMode::Static)
|
||||
.withSize(frontend.getSize())
|
||||
.withPixelRatio(static_cast<float>(pixelRatio)),
|
||||
ResourceOptions()
|
||||
.withCachePath(cache_file)
|
||||
.withAssetPath(asset_root)
|
||||
.withApiKey(apikey)
|
||||
.withTileServerOptions(mapTilerConfiguration));
|
||||
|
||||
if (style.find("://") == std::string::npos) {
|
||||
style = std::string("file://") + style;
|
||||
}
|
||||
|
||||
map.getStyle().loadURL(style);
|
||||
map.jumpTo(CameraOptions()
|
||||
.withCenter(LatLng { lat, lon })
|
||||
.withZoom(zoom)
|
||||
.withBearing(bearing)
|
||||
.withPitch(pitch));
|
||||
map.jumpTo(CameraOptions().withCenter(LatLng{lat, lon}).withZoom(zoom).withBearing(bearing).withPitch(pitch));
|
||||
|
||||
if (debug) {
|
||||
map.setDebug(debug ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus : mbgl::MapDebugOptions::NoDebug);
|
||||
map.setDebug(debug ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus
|
||||
: mbgl::MapDebugOptions::NoDebug);
|
||||
}
|
||||
|
||||
try {
|
||||
std::ofstream out(output, std::ios::binary);
|
||||
out << encodePNG(frontend.render(map).image);
|
||||
out.close();
|
||||
} catch(std::exception& e) {
|
||||
} catch (std::exception& e) {
|
||||
std::cout << "Error: " << e.what() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ document.getElementById('toggle-sequence').addEventListener('click', function (e
|
||||
std::string createResultItem(const TestRunOutput& result, const std::string& status, bool shouldHide) {
|
||||
std::ostringstream html;
|
||||
html << "<div class=\"test " << status << (shouldHide ? " hide" : "") << "\">\n";
|
||||
html << R"(<h2><span class="label">)" << status << "</span> " << result.id << "</h2>\n";
|
||||
html << R"(<h2><span class="label">)" << status << "</span> " << result.id << "</h2>\n";
|
||||
|
||||
html << "<p><pre>"s << result.expression << "</pre></p>\n"s;
|
||||
if (result.passed) {
|
||||
@@ -98,11 +98,11 @@ std::string createResultPage(const TestStats& stats, bool shuffle, uint32_t seed
|
||||
|
||||
// Failed tests
|
||||
if (unsuccessful) {
|
||||
resultsPage << "<p><strong>Failed tests:</strong>";
|
||||
resultsPage << "<p><strong>Failed tests:</strong>";
|
||||
for (const auto& failed : stats.failed) {
|
||||
resultsPage << failed.id << " ";
|
||||
}
|
||||
resultsPage << "<p><strong>Errored tests:</strong>";
|
||||
resultsPage << "<p><strong>Errored tests:</strong>";
|
||||
for (const auto& errored : stats.errored) {
|
||||
resultsPage << errored.id << " ";
|
||||
}
|
||||
@@ -127,9 +127,9 @@ std::string createResultPage(const TestStats& stats, bool shuffle, uint32_t seed
|
||||
// Script
|
||||
resultsPage << resultsScript;
|
||||
|
||||
// Tests
|
||||
// Tests
|
||||
resultsPage << "<div class=\"tests\">\n";
|
||||
const auto appendResult = [&] (const auto& results, const std::string& status, bool hide = false) {
|
||||
const auto appendResult = [&](const auto& results, const std::string& status, bool hide = false) {
|
||||
for (const auto& result : results) {
|
||||
resultsPage << createResultItem(result, status, hide);
|
||||
}
|
||||
@@ -153,16 +153,21 @@ void printStats(const TestStats& stats) {
|
||||
printf(ANSI_COLOR_GREEN "%zu passed (%.1lf%%)" ANSI_COLOR_RESET "\n", passedTests, 100.0 * passedTests / count);
|
||||
}
|
||||
if (std::size_t ignorePassedTests = stats.ignorePassed.size()) {
|
||||
printf(ANSI_COLOR_YELLOW "%zu passed but were ignored (%.1lf%%)" ANSI_COLOR_RESET "\n", ignorePassedTests, 100.0 * ignorePassedTests / count);
|
||||
printf(ANSI_COLOR_YELLOW "%zu passed but were ignored (%.1lf%%)" ANSI_COLOR_RESET "\n",
|
||||
ignorePassedTests,
|
||||
100.0 * ignorePassedTests / count);
|
||||
}
|
||||
if (std::size_t ignoreFailedTests = stats.ignoreFailed.size()) {
|
||||
printf(ANSI_COLOR_LIGHT_GRAY "%zu ignored (%.1lf%%)" ANSI_COLOR_RESET "\n", ignoreFailedTests, 100.0 * ignoreFailedTests / count);
|
||||
printf(ANSI_COLOR_LIGHT_GRAY "%zu ignored (%.1lf%%)" ANSI_COLOR_RESET "\n",
|
||||
ignoreFailedTests,
|
||||
100.0 * ignoreFailedTests / count);
|
||||
}
|
||||
if (std::size_t failedTests = stats.failed.size()) {
|
||||
printf(ANSI_COLOR_RED "%zu failed (%.1lf%%)" ANSI_COLOR_RESET "\n", failedTests, 100.0 * failedTests / count);
|
||||
}
|
||||
if (std::size_t erroredTests = stats.errored.size()) {
|
||||
printf(ANSI_COLOR_RED "%zu errored (%.1lf%%)" ANSI_COLOR_RESET "\n", erroredTests, 100.0 * erroredTests / count);
|
||||
printf(
|
||||
ANSI_COLOR_RED "%zu errored (%.1lf%%)" ANSI_COLOR_RESET "\n", erroredTests, 100.0 * erroredTests / count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#define ANSI_COLOR_RED "\x1b[31m"
|
||||
#define ANSI_COLOR_GREEN "\x1b[32m"
|
||||
#define ANSI_COLOR_YELLOW "\x1b[33m"
|
||||
#define ANSI_COLOR_RED "\x1b[31m"
|
||||
#define ANSI_COLOR_GREEN "\x1b[32m"
|
||||
#define ANSI_COLOR_YELLOW "\x1b[33m"
|
||||
#define ANSI_COLOR_LIGHT_GRAY "\x1b[90m"
|
||||
#define ANSI_COLOR_RESET "\x1b[0m"
|
||||
#define ANSI_COLOR_RESET "\x1b[0m"
|
||||
|
||||
class TestStats;
|
||||
|
||||
|
||||
@@ -28,29 +28,27 @@ using namespace std::literals;
|
||||
namespace {
|
||||
|
||||
void writeJSON(rapidjson::PrettyWriter<rapidjson::StringBuffer>& writer, const Value& value) {
|
||||
value.match(
|
||||
[&] (const NullValue&) { writer.Null(); },
|
||||
[&] (bool b) { writer.Bool(b); },
|
||||
[&] (uint64_t u) { writer.Uint64(u); },
|
||||
[&] (int64_t i) { writer.Int64(i); },
|
||||
[&] (double d) { d == std::floor(d) ? writer.Int64(static_cast<int64_t>(d)) : writer.Double(d); },
|
||||
[&] (const std::string& s) { writer.String(s); },
|
||||
[&] (const std::vector<Value>& arr) {
|
||||
writer.StartArray();
|
||||
for(const auto& item : arr) {
|
||||
writeJSON(writer, item);
|
||||
}
|
||||
writer.EndArray();
|
||||
},
|
||||
[&] (const std::unordered_map<std::string, Value>& obj) {
|
||||
writer.StartObject();
|
||||
for(const auto& entry : obj) {
|
||||
writer.Key(entry.first.c_str());
|
||||
writeJSON(writer, entry.second);
|
||||
}
|
||||
writer.EndObject();
|
||||
}
|
||||
);
|
||||
value.match([&](const NullValue&) { writer.Null(); },
|
||||
[&](bool b) { writer.Bool(b); },
|
||||
[&](uint64_t u) { writer.Uint64(u); },
|
||||
[&](int64_t i) { writer.Int64(i); },
|
||||
[&](double d) { d == std::floor(d) ? writer.Int64(static_cast<int64_t>(d)) : writer.Double(d); },
|
||||
[&](const std::string& s) { writer.String(s); },
|
||||
[&](const std::vector<Value>& arr) {
|
||||
writer.StartArray();
|
||||
for (const auto& item : arr) {
|
||||
writeJSON(writer, item);
|
||||
}
|
||||
writer.EndArray();
|
||||
},
|
||||
[&](const std::unordered_map<std::string, Value>& obj) {
|
||||
writer.StartObject();
|
||||
for (const auto& entry : obj) {
|
||||
writer.Key(entry.first.c_str());
|
||||
writeJSON(writer, entry.second);
|
||||
}
|
||||
writer.EndObject();
|
||||
});
|
||||
}
|
||||
|
||||
using ErrorMessage = std::string;
|
||||
@@ -58,21 +56,21 @@ using JSONReply = variant<JSDocument, ErrorMessage>;
|
||||
JSONReply readJson(const filesystem::path& jsonPath) {
|
||||
auto maybeJSON = util::readFile(jsonPath);
|
||||
if (!maybeJSON) {
|
||||
return { "Unable to open file "s + jsonPath.string() };
|
||||
return {"Unable to open file "s + jsonPath.string()};
|
||||
}
|
||||
|
||||
JSDocument document;
|
||||
document.Parse<rapidjson::kParseFullPrecisionFlag>(*maybeJSON);
|
||||
if (document.HasParseError()) {
|
||||
return { formatJSONParseError(document) };
|
||||
return {formatJSONParseError(document)};
|
||||
}
|
||||
|
||||
return { std::move(document) };
|
||||
return {std::move(document)};
|
||||
}
|
||||
|
||||
std::string toString(const JSValue& value) {
|
||||
assert(value.IsString());
|
||||
return { value.GetString(), value.GetStringLength() };
|
||||
return {value.GetString(), value.GetStringLength()};
|
||||
}
|
||||
|
||||
std::optional<Value> toValue(const JSValue& jsvalue) {
|
||||
@@ -314,10 +312,9 @@ bool parseInputs(const JSValue& inputsValue, TestData& data) {
|
||||
std::tuple<filesystem::path, std::vector<filesystem::path>, bool, uint32_t> parseArguments(int argc, char** argv) {
|
||||
args::ArgumentParser argumentParser("Mapbox GL Expression Test Runner");
|
||||
|
||||
args::HelpFlag helpFlag(argumentParser, "help", "Display this help menu", { 'h', "help" });
|
||||
args::HelpFlag helpFlag(argumentParser, "help", "Display this help menu", {'h', "help"});
|
||||
args::Flag shuffleFlag(argumentParser, "shuffle", "Toggle shuffling the tests order", {'s', "shuffle"});
|
||||
args::ValueFlag<uint32_t> seedValue(argumentParser, "seed", "Shuffle seed (default: random)",
|
||||
{ "seed" });
|
||||
args::ValueFlag<uint32_t> seedValue(argumentParser, "seed", "Shuffle seed (default: random)", {"seed"});
|
||||
args::PositionalList<std::string> testNameValues(argumentParser, "URL", "Test name(s)");
|
||||
args::ValueFlag<std::string> testFilterValue(argumentParser, "filter", "Test filter regex", {'f', "filter"});
|
||||
|
||||
@@ -342,7 +339,7 @@ std::tuple<filesystem::path, std::vector<filesystem::path>, bool, uint32_t> pars
|
||||
exit(2);
|
||||
}
|
||||
|
||||
filesystem::path rootPath {std::string(TEST_RUNNER_ROOT_PATH).append("/metrics/integration/expression-tests")};
|
||||
filesystem::path rootPath{std::string(TEST_RUNNER_ROOT_PATH).append("/metrics/integration/expression-tests")};
|
||||
if (!filesystem::exists(rootPath)) {
|
||||
Log::Error(Event::General, "Test path '" + rootPath.string() + "' does not exist.");
|
||||
exit(3);
|
||||
@@ -377,10 +374,10 @@ std::tuple<filesystem::path, std::vector<filesystem::path>, bool, uint32_t> pars
|
||||
}
|
||||
}
|
||||
|
||||
return Arguments{ std::move(rootPath),
|
||||
std::move(testPaths),
|
||||
shuffleFlag ? args::get(shuffleFlag) : false,
|
||||
seedValue ? args::get(seedValue) : 1u };
|
||||
return Arguments{std::move(rootPath),
|
||||
std::move(testPaths),
|
||||
shuffleFlag ? args::get(shuffleFlag) : false,
|
||||
seedValue ? args::get(seedValue) : 1u};
|
||||
}
|
||||
|
||||
Ignores parseExpressionIgnores() {
|
||||
@@ -392,12 +389,12 @@ Ignores parseExpressionIgnores() {
|
||||
}
|
||||
|
||||
for (const auto& property : maybeIgnores.get<JSDocument>().GetObject()) {
|
||||
std::string id{ toString(property.name) };
|
||||
std::string id{toString(property.name)};
|
||||
// Keep only expression-test ignores
|
||||
if (id.rfind("expression-tests", 0) != 0) {
|
||||
continue;
|
||||
}
|
||||
std::string reason{ toString(property.value) };
|
||||
std::string reason{toString(property.value)};
|
||||
ignores.emplace_back(std::move(id), std::move(reason));
|
||||
}
|
||||
|
||||
@@ -474,7 +471,8 @@ Value toValue(const Compiled& compiled) {
|
||||
std::optional<Value> toValue(const expression::Value& exprValue) {
|
||||
return exprValue.match(
|
||||
[](const Color& c) -> std::optional<Value> {
|
||||
std::vector<Value> color { static_cast<double>(c.r), static_cast<double>(c.g), static_cast<double>(c.b), static_cast<double>(c.a) };
|
||||
std::vector<Value> color{
|
||||
static_cast<double>(c.r), static_cast<double>(c.g), static_cast<double>(c.b), static_cast<double>(c.a)};
|
||||
return {Value{std::move(color)}};
|
||||
},
|
||||
[](const expression::Formatted& formatted) -> std::optional<Value> { return {formatted.toObject()}; },
|
||||
@@ -503,11 +501,10 @@ std::unique_ptr<style::expression::Expression> parseExpression(const JSValue& va
|
||||
std::optional<PropertySpec>& spec,
|
||||
TestResult& result) {
|
||||
std::optional<style::expression::type::Type> expected = spec ? toExpressionType(*spec) : std::nullopt;
|
||||
expression::ParsingContext ctx = expected ? expression::ParsingContext(*expected) :
|
||||
expression::ParsingContext();
|
||||
expression::ParsingContext ctx = expected ? expression::ParsingContext(*expected) : expression::ParsingContext();
|
||||
Convertible convertible(&value);
|
||||
expression::ParseResult parsed;
|
||||
if (value.IsObject() && !value.IsArray() && expected){
|
||||
if (value.IsObject() && !value.IsArray() && expected) {
|
||||
Error error;
|
||||
parsed = convertFunctionToExpression(*expected, convertible, error, false /*convert tokens*/);
|
||||
if (!parsed) {
|
||||
|
||||
@@ -32,10 +32,8 @@ struct Input {
|
||||
|
||||
struct Compiled {
|
||||
bool operator==(const Compiled& other) const {
|
||||
bool typeEqual = success == other.success &&
|
||||
isFeatureConstant == other.isFeatureConstant &&
|
||||
isZoomConstant == other.isZoomConstant &&
|
||||
serializedType == other.serializedType &&
|
||||
bool typeEqual = success == other.success && isFeatureConstant == other.isFeatureConstant &&
|
||||
isZoomConstant == other.isZoomConstant && serializedType == other.serializedType &&
|
||||
errors == other.errors;
|
||||
return typeEqual;
|
||||
}
|
||||
@@ -99,4 +97,3 @@ std::unique_ptr<style::expression::Expression> parseExpression(const JSValue&,
|
||||
std::unique_ptr<style::expression::Expression> parseExpression(const std::optional<Value>&,
|
||||
std::optional<PropertySpec>&,
|
||||
TestResult&);
|
||||
|
||||
|
||||
@@ -18,15 +18,16 @@ using namespace std::literals;
|
||||
namespace {
|
||||
|
||||
std::string simpleDiff(const Value& result, const Value& expected) {
|
||||
std::vector<std::string> resultTokens {tokenize(toJSON(result, 2, true))};
|
||||
std::vector<std::string> expectedTokens {tokenize(toJSON(expected, 2, true))};
|
||||
std::vector<std::string> resultTokens{tokenize(toJSON(result, 2, true))};
|
||||
std::vector<std::string> expectedTokens{tokenize(toJSON(expected, 2, true))};
|
||||
std::size_t maxLength = std::max(resultTokens.size(), expectedTokens.size());
|
||||
std::ostringstream diff;
|
||||
const auto flush = [] (const std::vector<std::string>& vec, std::size_t pos, std::ostringstream& out, std::string separator) {
|
||||
for (std::size_t j = pos; j < vec.size(); ++j) {
|
||||
out << separator << vec[j] << std::endl;
|
||||
}
|
||||
};
|
||||
const auto flush =
|
||||
[](const std::vector<std::string>& vec, std::size_t pos, std::ostringstream& out, std::string separator) {
|
||||
for (std::size_t j = pos; j < vec.size(); ++j) {
|
||||
out << separator << vec[j] << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
for (std::size_t i = 0; i < maxLength; ++i) {
|
||||
if (resultTokens.size() <= i) {
|
||||
@@ -109,8 +110,8 @@ TestRunOutput runExpressionTest(TestData& data, const std::string& rootPath, con
|
||||
evaluationResult = expression->evaluate(
|
||||
input.zoom, input.feature, input.heatmapDensity, input.availableImages, *input.canonical);
|
||||
} else {
|
||||
evaluationResult =
|
||||
expression->evaluate(input.zoom, input.feature, input.heatmapDensity, input.availableImages);
|
||||
evaluationResult = expression->evaluate(
|
||||
input.zoom, input.feature, input.heatmapDensity, input.availableImages);
|
||||
}
|
||||
if (!evaluationResult) {
|
||||
std::unordered_map<std::string, Value> error{{"error", Value{evaluationResult.error().message}}};
|
||||
@@ -138,8 +139,7 @@ TestRunOutput runExpressionTest(TestData& data, const std::string& rootPath, con
|
||||
auto recompiledExpression = parseExpression(data.result.serialized, data.spec, data.recompiled);
|
||||
if (recompiledExpression) {
|
||||
evaluateExpression(recompiledExpression, data.recompiled);
|
||||
rewriteRoundtrippedType(data.expected.compiled.serializedType,
|
||||
data.recompiled.compiled.serializedType);
|
||||
rewriteRoundtrippedType(data.expected.compiled.serializedType, data.recompiled.compiled.serializedType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ TestRunOutput runExpressionTest(TestData& data, const std::string& rootPath, con
|
||||
|
||||
if (data.expected.compiled.success) {
|
||||
serializationOk = compileOk && deepEqual(data.result.serialized, data.expected.serialized);
|
||||
recompileOk = compileOk && data.recompiled.compiled == data.expected.compiled;
|
||||
recompileOk = compileOk && data.recompiled.compiled == data.expected.compiled;
|
||||
roundTripOk = recompileOk && deepEqual(data.recompiled.outputs, data.expected.outputs);
|
||||
}
|
||||
|
||||
@@ -168,36 +168,28 @@ TestRunOutput runExpressionTest(TestData& data, const std::string& rootPath, con
|
||||
if (!compileOk) {
|
||||
auto resultValue = toValue(data.result.compiled);
|
||||
auto expectedValue = toValue(data.expected.compiled);
|
||||
output.text += "Compiled expression difference:\n"s +
|
||||
simpleDiff(resultValue, expectedValue) +
|
||||
"\n"s;
|
||||
output.text += "Compiled expression difference:\n"s + simpleDiff(resultValue, expectedValue) + "\n"s;
|
||||
}
|
||||
|
||||
if (compileOk && !serializationOk) {
|
||||
auto diff = simpleDiff(data.expected.serialized.value_or(Value{}),
|
||||
data.result.serialized.value_or(Value{}));
|
||||
auto diff = simpleDiff(data.expected.serialized.value_or(Value{}), data.result.serialized.value_or(Value{}));
|
||||
output.text += "Serialized expression difference:\n"s + diff + "\n"s;
|
||||
}
|
||||
|
||||
if (compileOk && !recompileOk) {
|
||||
auto recompiledValue = toValue(data.recompiled.compiled);
|
||||
auto expectedValue = toValue(data.expected.compiled);
|
||||
output.text += "Recompiled expression difference:\n"s +
|
||||
simpleDiff(recompiledValue, expectedValue) +
|
||||
"\n"s;
|
||||
output.text += "Recompiled expression difference:\n"s + simpleDiff(recompiledValue, expectedValue) + "\n"s;
|
||||
}
|
||||
|
||||
if (compileOk && !evalOk) {
|
||||
auto diff = simpleDiff(data.expected.outputs.value_or(Value{}),
|
||||
data.result.outputs.value_or(Value{}));
|
||||
auto diff = simpleDiff(data.expected.outputs.value_or(Value{}), data.result.outputs.value_or(Value{}));
|
||||
output.text += "Expression outputs difference:\n"s + diff + "\n"s;
|
||||
}
|
||||
|
||||
if (recompileOk && !roundTripOk) {
|
||||
auto diff = simpleDiff(data.expected.outputs.value_or(Value{}),
|
||||
data.recompiled.outputs.value_or(Value{}));
|
||||
output.text += "Roundtripped through serialize expression outputs difference:\n"s +
|
||||
diff + "\n"s;
|
||||
auto diff = simpleDiff(data.expected.outputs.value_or(Value{}), data.recompiled.outputs.value_or(Value{}));
|
||||
output.text += "Roundtripped through serialize expression outputs difference:\n"s + diff + "\n"s;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
class TestData;
|
||||
|
||||
struct TestRunOutput {
|
||||
TestRunOutput(std::string id_) : id(std::move(id_)) {}
|
||||
TestRunOutput(std::string id_)
|
||||
: id(std::move(id_)) {}
|
||||
std::string id;
|
||||
bool passed = false;
|
||||
std::string text;
|
||||
@@ -17,8 +18,7 @@ struct TestRunOutput {
|
||||
class TestStats {
|
||||
public:
|
||||
std::size_t testCount() const {
|
||||
return passed.size() + failed.size() + errored.size() +
|
||||
ignorePassed.size() + ignoreFailed.size();
|
||||
return passed.size() + failed.size() + errored.size() + ignorePassed.size() + ignoreFailed.size();
|
||||
}
|
||||
|
||||
std::vector<TestRunOutput> passed;
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include <random>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
try {
|
||||
int main(int argc, char** argv) try {
|
||||
// Parse args
|
||||
std::vector<mbgl::filesystem::path> testPaths;
|
||||
mbgl::filesystem::path rootPath;
|
||||
@@ -19,7 +18,7 @@ try {
|
||||
|
||||
if (shuffle) {
|
||||
printf(ANSI_COLOR_YELLOW "Shuffle seed: %d" ANSI_COLOR_RESET "\n", seed);
|
||||
std::seed_seq sequence { seed };
|
||||
std::seed_seq sequence{seed};
|
||||
std::mt19937 shuffler(sequence);
|
||||
std::shuffle(testPaths.begin(), testPaths.end(), shuffler);
|
||||
}
|
||||
@@ -28,13 +27,15 @@ try {
|
||||
TestStats stats;
|
||||
for (const auto& path : testPaths) {
|
||||
const auto& expectation = path.parent_path().string();
|
||||
std::string id = expectation.substr(rootPath.string().length() + 1, expectation.length() - rootPath.string().length());
|
||||
std::string id = expectation.substr(rootPath.string().length() + 1,
|
||||
expectation.length() - rootPath.string().length());
|
||||
stats.ids.emplace_back(id);
|
||||
|
||||
bool shouldIgnore = false;
|
||||
std::string ignoreReason;
|
||||
const std::string ignoreName = "expression-tests/" + id;
|
||||
const auto it = std::find_if(ignores.cbegin(), ignores.cend(), [&ignoreName] (const auto& ignore) { return ignore.id == ignoreName; });
|
||||
const auto it = std::find_if(
|
||||
ignores.cbegin(), ignores.cend(), [&ignoreName](const auto& ignore) { return ignore.id == ignoreName; });
|
||||
if (it != ignores.end()) {
|
||||
shouldIgnore = true;
|
||||
ignoreReason = (*it).reason;
|
||||
@@ -54,10 +55,14 @@ try {
|
||||
if (shouldIgnore) {
|
||||
if (testRun->passed) {
|
||||
stats.ignorePassed.emplace_back(std::move(*testRun));
|
||||
printf(ANSI_COLOR_YELLOW "* PASSED ignored test %s (%s)" ANSI_COLOR_RESET "\n", id.c_str(), ignoreReason.c_str());
|
||||
printf(ANSI_COLOR_YELLOW "* PASSED ignored test %s (%s)" ANSI_COLOR_RESET "\n",
|
||||
id.c_str(),
|
||||
ignoreReason.c_str());
|
||||
} else {
|
||||
stats.ignoreFailed.emplace_back(std::move(*testRun));
|
||||
printf(ANSI_COLOR_LIGHT_GRAY "* FAILED ignored test %s (%s)" ANSI_COLOR_RESET "\n", id.c_str(), ignoreReason.c_str());
|
||||
printf(ANSI_COLOR_LIGHT_GRAY "* FAILED ignored test %s (%s)" ANSI_COLOR_RESET "\n",
|
||||
id.c_str(),
|
||||
ignoreReason.c_str());
|
||||
}
|
||||
} else {
|
||||
if (testRun->passed) {
|
||||
@@ -72,10 +77,9 @@ try {
|
||||
|
||||
printStats(stats);
|
||||
writeHTMLResults(stats, rootPath.string(), shuffle, seed);
|
||||
|
||||
|
||||
return stats.errored.size() + stats.failed.size() == 0 ? 0 : 1;
|
||||
}
|
||||
catch (std::exception const& ex) {
|
||||
} catch (std::exception const& ex) {
|
||||
std::cerr << "Caught an exception while running tests:\n" << ex.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
// Strip precision for numbers, so that we can compare evaluated results with fixtures.
|
||||
// Copied from JS expression harness.
|
||||
// Strip precision for numbers, so that we can compare evaluated results with
|
||||
// fixtures. Copied from JS expression harness.
|
||||
Value stripPrecision(const Value& value) {
|
||||
const double decimalSigFigs = 6;
|
||||
if (auto num = numericValue<double>(value)) {
|
||||
|
||||
@@ -15,38 +15,44 @@
|
||||
namespace mbgl {
|
||||
|
||||
/**
|
||||
An `Actor<O>` is an owning reference to an asynchronous object of type `O`: an "actor".
|
||||
Communication with an actor happens via message passing: you send a message to the object
|
||||
(using `invoke`), passing a pointer to the member function to call and arguments which
|
||||
are then forwarded to the actor.
|
||||
An `Actor<O>` is an owning reference to an asynchronous object of type `O`:
|
||||
an "actor". Communication with an actor happens via message passing: you send
|
||||
a message to the object (using `invoke`), passing a pointer to the member
|
||||
function to call and arguments which are then forwarded to the actor.
|
||||
|
||||
The actor receives messages sent to it asynchronously, in a manner defined its `Scheduler`.
|
||||
To store incoming messages before their receipt, each actor has a `Mailbox`, which acts as
|
||||
a FIFO queue. Messages sent from actor S to actor R are guaranteed to be processed in the
|
||||
order sent. However, relative order of messages sent by two *different* actors S1 and S2
|
||||
to R is *not* guaranteed (and can't be: S1 and S2 may be acting asynchronously with respect
|
||||
The actor receives messages sent to it asynchronously, in a manner defined
|
||||
its `Scheduler`. To store incoming messages before their receipt, each actor
|
||||
has a `Mailbox`, which acts as a FIFO queue. Messages sent from actor S to
|
||||
actor R are guaranteed to be processed in the order sent. However, relative
|
||||
order of messages sent by two *different* actors S1 and S2 to R is *not*
|
||||
guaranteed (and can't be: S1 and S2 may be acting asynchronously with respect
|
||||
to each other).
|
||||
|
||||
An `Actor<O>` can be converted to an `ActorRef<O>`, a non-owning value object representing
|
||||
a (weak) reference to the actor. Messages can be sent via the `Ref` as well.
|
||||
An `Actor<O>` can be converted to an `ActorRef<O>`, a non-owning value
|
||||
object representing a (weak) reference to the actor. Messages can be sent via
|
||||
the `Ref` as well.
|
||||
|
||||
It's safe -- and encouraged -- to pass `Ref`s between actors via messages. This is how two-way
|
||||
communication and other forms of collaboration between multiple actors is accomplished.
|
||||
It's safe -- and encouraged -- to pass `Ref`s between actors via messages.
|
||||
This is how two-way communication and other forms of collaboration between
|
||||
multiple actors is accomplished.
|
||||
|
||||
It's safe for a `Ref` to outlive its `Actor` -- the reference is "weak", and does not extend
|
||||
the lifetime of the owning Actor, and sending a message to a `Ref` whose `Actor` has died is
|
||||
a no-op. (In the future, a dead-letters queue or log may be implemented.)
|
||||
It's safe for a `Ref` to outlive its `Actor` -- the reference is "weak", and
|
||||
does not extend the lifetime of the owning Actor, and sending a message to a
|
||||
`Ref` whose `Actor` has died is a no-op. (In the future, a dead-letters queue
|
||||
or log may be implemented.)
|
||||
|
||||
Construction and destruction of an Actor is synchronous: the corresponding `O`
|
||||
object is constructed synchronously by the `Actor` constructor, and destructed synchronously
|
||||
by the `~Actor` destructor, after ensuring that the `O` is not currently receiving an
|
||||
asynchronous message. The constructor of `O` is passed an `ActorRef<O>` referring to itself
|
||||
(which it can use to self-send messages), followed by the forwarded arguments passed to
|
||||
`Actor<O>`. Asynchronous object construction can be accomplished by directly using the
|
||||
lower-level types, `AspiringActor<O>` and `EstablishedActor<O>`.
|
||||
Construction and destruction of an Actor is synchronous: the corresponding
|
||||
`O` object is constructed synchronously by the `Actor` constructor, and
|
||||
destructed synchronously by the `~Actor` destructor, after ensuring that the
|
||||
`O` is not currently receiving an asynchronous message. The constructor of
|
||||
`O` is passed an `ActorRef<O>` referring to itself (which it can use to
|
||||
self-send messages), followed by the forwarded arguments passed to
|
||||
`Actor<O>`. Asynchronous object construction can be accomplished by directly
|
||||
using the lower-level types, `AspiringActor<O>` and `EstablishedActor<O>`.
|
||||
|
||||
Please don't send messages that contain shared pointers or references. That subverts the
|
||||
purpose of the actor model: prohibiting direct concurrent access to shared state.
|
||||
Please don't send messages that contain shared pointers or references. That
|
||||
subverts the purpose of the actor model: prohibiting direct concurrent access
|
||||
to shared state.
|
||||
*/
|
||||
template <class Object>
|
||||
class Actor {
|
||||
@@ -57,13 +63,12 @@ public:
|
||||
|
||||
template <class... Args>
|
||||
Actor(std::shared_ptr<Scheduler> scheduler, Args&&... args)
|
||||
: retainer(std::move(scheduler)), target(*retainer, parent, std::forward<Args>(args)...) {}
|
||||
: retainer(std::move(scheduler)),
|
||||
target(*retainer, parent, std::forward<Args>(args)...) {}
|
||||
|
||||
Actor(const Actor&) = delete;
|
||||
|
||||
ActorRef<std::decay_t<Object>> self() {
|
||||
return parent.self();
|
||||
}
|
||||
ActorRef<std::decay_t<Object>> self() { return parent.self(); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<Scheduler> retainer;
|
||||
|
||||
@@ -8,24 +8,25 @@
|
||||
namespace mbgl {
|
||||
|
||||
/**
|
||||
An `ActorRef<O>` is a *non*-owning, weak reference to an actor of type `O`. You can send it
|
||||
messages just like an `Actor<O>`. It's a value object: safe to copy and pass between actors
|
||||
via messages.
|
||||
An `ActorRef<O>` is a *non*-owning, weak reference to an actor of type `O`.
|
||||
You can send it messages just like an `Actor<O>`. It's a value object: safe
|
||||
to copy and pass between actors via messages.
|
||||
|
||||
An `ActorRef<O>` does not extend the lifetime of the corresponding `Actor<O>`. That's determined
|
||||
entirely by whichever object owns the `Actor<O>` -- the actor's "supervisor".
|
||||
An `ActorRef<O>` does not extend the lifetime of the corresponding
|
||||
`Actor<O>`. That's determined entirely by whichever object owns the
|
||||
`Actor<O>` -- the actor's "supervisor".
|
||||
|
||||
It's safe for a `Ref` to outlive its `Actor` -- the reference is "weak", and does not extend
|
||||
the lifetime of the owning Actor, and sending a message to a `Ref` whose `Actor` has died is
|
||||
a no-op. (In the future, a dead-letters queue or log may be implemented.)
|
||||
It's safe for a `Ref` to outlive its `Actor` -- the reference is "weak", and
|
||||
does not extend the lifetime of the owning Actor, and sending a message to a
|
||||
`Ref` whose `Actor` has died is a no-op. (In the future, a dead-letters queue
|
||||
or log may be implemented.)
|
||||
*/
|
||||
template <class Object>
|
||||
class ActorRef {
|
||||
public:
|
||||
ActorRef(Object& object_, std::weak_ptr<Mailbox> weakMailbox_)
|
||||
: object(&object_),
|
||||
weakMailbox(std::move(weakMailbox_)) {
|
||||
}
|
||||
weakMailbox(std::move(weakMailbox_)) {}
|
||||
|
||||
template <typename Fn, class... Args>
|
||||
void invoke(Fn fn, Args&&... args) const {
|
||||
@@ -43,11 +44,7 @@ public:
|
||||
auto future = promise.get_future();
|
||||
|
||||
if (auto mailbox = weakMailbox.lock()) {
|
||||
mailbox->push(
|
||||
actor::makeMessage(
|
||||
std::move(promise), *object, fn, std::forward<Args>(args)...
|
||||
)
|
||||
);
|
||||
mailbox->push(actor::makeMessage(std::move(promise), *object, fn, std::forward<Args>(args)...));
|
||||
} else {
|
||||
promise.set_exception(std::make_exception_ptr(std::runtime_error("Actor has gone away")));
|
||||
}
|
||||
|
||||
@@ -18,41 +18,40 @@ template <class Object>
|
||||
class Actor;
|
||||
|
||||
/**
|
||||
An `AspiringActor<O>` is one half of the pair of types that comprise an actor (see `Actor<O>`),
|
||||
the other half being `EstablishedActor<O>`. It is responsible for:
|
||||
An `AspiringActor<O>` is one half of the pair of types that comprise an
|
||||
actor (see `Actor<O>`), the other half being `EstablishedActor<O>`. It is
|
||||
responsible for:
|
||||
- ownership of the actor's `Mailbox`
|
||||
- allocating the memory for (but *not* constructing) the target object `O`
|
||||
|
||||
Using these two pieces--the mailbox and a stable address for `O`--an `AspiringActor<O>` can
|
||||
accept messages for the target object, or provide `ActorRef<O>`s that do so, before the object
|
||||
has actually been constructed by the corresponding `EstablishedActor<O>`. (Such messages are
|
||||
queued in the mailbox until after the object is constructed.)
|
||||
|
||||
This allows for an `AspiringActor<O>` to be created and safely used by a thread other than the
|
||||
one on which the target object will (eventually) live.
|
||||
|
||||
Using these two pieces--the mailbox and a stable address for `O`--an
|
||||
`AspiringActor<O>` can accept messages for the target object, or provide
|
||||
`ActorRef<O>`s that do so, before the object has actually been constructed by
|
||||
the corresponding `EstablishedActor<O>`. (Such messages are queued in the
|
||||
mailbox until after the object is constructed.)
|
||||
|
||||
This allows for an `AspiringActor<O>` to be created and safely used by a
|
||||
thread other than the one on which the target object will (eventually) live.
|
||||
*/
|
||||
template <class Object>
|
||||
class AspiringActor {
|
||||
public:
|
||||
AspiringActor() : mailbox(std::make_shared<Mailbox>()) {
|
||||
AspiringActor()
|
||||
: mailbox(std::make_shared<Mailbox>()) {
|
||||
// mailbox starts closed because the `Object` hasn't yet been constructed
|
||||
assert(!mailbox->isOpen());
|
||||
}
|
||||
|
||||
|
||||
AspiringActor(const AspiringActor&) = delete;
|
||||
|
||||
ActorRef<std::decay_t<Object>> self() {
|
||||
return ActorRef<std::decay_t<Object>>(object(), mailbox);
|
||||
}
|
||||
|
||||
|
||||
ActorRef<std::decay_t<Object>> self() { return ActorRef<std::decay_t<Object>>(object(), mailbox); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<Mailbox> mailbox;
|
||||
std::aligned_storage_t<sizeof(Object)> objectStorage;
|
||||
|
||||
Object& object() {
|
||||
return *reinterpret_cast<Object *>(&objectStorage);
|
||||
}
|
||||
|
||||
|
||||
Object& object() { return *reinterpret_cast<Object*>(&objectStorage); }
|
||||
|
||||
friend class EstablishedActor<Object>;
|
||||
friend class Actor<Object>;
|
||||
};
|
||||
|
||||
@@ -13,64 +13,70 @@
|
||||
namespace mbgl {
|
||||
|
||||
/**
|
||||
An `EstablishedActor<O>` is one half of the pair of types that comprise an actor (see `Actor<O>`),
|
||||
the other half being `AspiringActor<O>`. It is responsible for managing the lifetime of the
|
||||
target object `O` and the open/closed state of the parent's `mailbox`.
|
||||
|
||||
The `O` object's lifetime is contained by that of its owning `EstablishedActor<O>`: the
|
||||
`EstablishedActor` constructor executes the `O` constructor via "placement new", constructing
|
||||
it at the address provided by the parent `AspiringActor`, and the `~EstablishedActor` destructor
|
||||
similarly executes the `~O` destructor (after closing the mailbox). `EstablishedActor` should
|
||||
therefore live entirely on the thread intended to own `O`.
|
||||
An `EstablishedActor<O>` is one half of the pair of types that comprise an
|
||||
actor (see `Actor<O>`), the other half being `AspiringActor<O>`. It is
|
||||
responsible for managing the lifetime of the target object `O` and the
|
||||
open/closed state of the parent's `mailbox`.
|
||||
|
||||
The `O` object's lifetime is contained by that of its owning
|
||||
`EstablishedActor<O>`: the `EstablishedActor` constructor executes the `O`
|
||||
constructor via "placement new", constructing it at the address provided by
|
||||
the parent `AspiringActor`, and the `~EstablishedActor` destructor similarly
|
||||
executes the `~O` destructor (after closing the mailbox). `EstablishedActor`
|
||||
should therefore live entirely on the thread intended to own `O`.
|
||||
*/
|
||||
template <class Object>
|
||||
class EstablishedActor {
|
||||
public:
|
||||
// Construct the Object from a parameter pack `args` (i.e. `Object(args...)`)
|
||||
template <typename U = Object, class... Args, typename std::enable_if_t<
|
||||
std::is_constructible_v<U, Args...> ||
|
||||
std::is_constructible_v<U, ActorRef<U>, Args...>
|
||||
> * = nullptr>
|
||||
EstablishedActor(Scheduler& scheduler, AspiringActor<Object>& parent_, Args&& ... args)
|
||||
: parent(parent_) {
|
||||
template <typename U = Object,
|
||||
class... Args,
|
||||
typename std::enable_if_t<std::is_constructible_v<U, Args...> ||
|
||||
std::is_constructible_v<U, ActorRef<U>, Args...>>* = nullptr>
|
||||
EstablishedActor(Scheduler& scheduler, AspiringActor<Object>& parent_, Args&&... args)
|
||||
: parent(parent_) {
|
||||
emplaceObject(std::forward<Args>(args)...);
|
||||
parent.mailbox->open(scheduler);
|
||||
}
|
||||
|
||||
// Construct the `Object` from a tuple containing the constructor arguments (i.e.
|
||||
// `Object(std::get<0>(args), std::get<1>(args), ...)`)
|
||||
|
||||
// Construct the `Object` from a tuple containing the constructor arguments
|
||||
// (i.e. `Object(std::get<0>(args), std::get<1>(args), ...)`)
|
||||
template <class ArgsTuple, std::size_t ArgCount = std::tuple_size<std::decay_t<ArgsTuple>>::value>
|
||||
EstablishedActor(Scheduler& scheduler, AspiringActor<Object>& parent_, ArgsTuple&& args)
|
||||
: parent(parent_) {
|
||||
: parent(parent_) {
|
||||
emplaceObject(std::forward<ArgsTuple>(args), std::make_index_sequence<ArgCount>{});
|
||||
parent.mailbox->open(scheduler);
|
||||
}
|
||||
|
||||
|
||||
EstablishedActor(const EstablishedActor&) = delete;
|
||||
|
||||
~EstablishedActor() {
|
||||
parent.mailbox->close();
|
||||
parent.object().~Object();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
// Enabled for Objects with a constructor taking ActorRef<Object> as the first parameter
|
||||
template <typename U = Object, class... Args, typename std::enable_if_t<std::is_constructible_v<U, ActorRef<U>, Args...>> * = nullptr>
|
||||
template <typename U = Object,
|
||||
class... Args,
|
||||
typename std::enable_if_t<std::is_constructible_v<U, ActorRef<U>, Args...>>* = nullptr>
|
||||
void emplaceObject(Args&&... args_) {
|
||||
new (&parent.objectStorage) Object(parent.self(), std::forward<Args>(args_)...);
|
||||
}
|
||||
|
||||
// Enabled for plain Objects
|
||||
template <typename U = Object, class... Args, typename std::enable_if_t<std::is_constructible_v<U, Args...>> * = nullptr>
|
||||
template <typename U = Object,
|
||||
class... Args,
|
||||
typename std::enable_if_t<std::is_constructible_v<U, Args...>>* = nullptr>
|
||||
void emplaceObject(Args&&... args_) {
|
||||
new (&parent.objectStorage) Object(std::forward<Args>(args_)...);
|
||||
}
|
||||
|
||||
|
||||
// Used to expand a tuple holding the constructor arguments
|
||||
template <class ArgsTuple, std::size_t... I>
|
||||
void emplaceObject(ArgsTuple&& args, std::index_sequence<I...>) {
|
||||
emplaceObject(std::move(std::get<I>(std::forward<ArgsTuple>(args)))...);
|
||||
(void) args; // mark args as used: if it's empty tuple, it's not actually used above.
|
||||
(void)args; // mark args as used: if it's empty tuple, it's not actually used above.
|
||||
}
|
||||
|
||||
AspiringActor<Object>& parent;
|
||||
|
||||
@@ -14,13 +14,12 @@ class Message;
|
||||
|
||||
class Mailbox : public std::enable_shared_from_this<Mailbox> {
|
||||
public:
|
||||
|
||||
/// Create a "holding" mailbox, messages to which will remain queued,
|
||||
/// unconsumed, until the mailbox is associated with a Scheduler using
|
||||
/// start(). This allows a Mailbox object to be created on one thread and
|
||||
/// later transferred to a different target thread that may not yet exist.
|
||||
Mailbox();
|
||||
|
||||
|
||||
Mailbox(Scheduler&);
|
||||
|
||||
/// Attach the given scheduler to this mailbox and begin processing messages
|
||||
@@ -43,7 +42,7 @@ private:
|
||||
std::recursive_mutex receivingMutex;
|
||||
std::mutex pushingMutex;
|
||||
|
||||
bool closed { false };
|
||||
bool closed{false};
|
||||
|
||||
std::mutex queueMutex;
|
||||
std::queue<std::unique_ptr<Message>> queue;
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
// A movable type-erasing function wrapper. This allows to store arbitrary invokable
|
||||
// things (like std::function<>, or the result of a movable-only std::bind()) in the queue.
|
||||
// Source: http://stackoverflow.com/a/29642072/331379
|
||||
// A movable type-erasing function wrapper. This allows to store arbitrary
|
||||
// invokable things (like std::function<>, or the result of a movable-only
|
||||
// std::bind()) in the queue. Source: http://stackoverflow.com/a/29642072/331379
|
||||
class Message {
|
||||
public:
|
||||
virtual ~Message() = default;
|
||||
@@ -18,14 +18,11 @@ template <class Object, class MemberFn, class ArgsTuple>
|
||||
class MessageImpl : public Message {
|
||||
public:
|
||||
MessageImpl(Object& object_, MemberFn memberFn_, ArgsTuple argsTuple_)
|
||||
: object(object_),
|
||||
memberFn(memberFn_),
|
||||
argsTuple(std::move(argsTuple_)) {
|
||||
}
|
||||
: object(object_),
|
||||
memberFn(memberFn_),
|
||||
argsTuple(std::move(argsTuple_)) {}
|
||||
|
||||
void operator()() override {
|
||||
invoke(std::make_index_sequence<std::tuple_size_v<ArgsTuple>>());
|
||||
}
|
||||
void operator()() override { invoke(std::make_index_sequence<std::tuple_size_v<ArgsTuple>>()); }
|
||||
|
||||
template <std::size_t... I>
|
||||
void invoke(std::index_sequence<I...>) {
|
||||
@@ -44,12 +41,9 @@ public:
|
||||
: object(object_),
|
||||
memberFn(memberFn_),
|
||||
argsTuple(std::move(argsTuple_)),
|
||||
promise(std::move(promise_)) {
|
||||
}
|
||||
promise(std::move(promise_)) {}
|
||||
|
||||
void operator()() override {
|
||||
promise.set_value(ask(std::make_index_sequence<std::tuple_size_v<ArgsTuple>>()));
|
||||
}
|
||||
void operator()() override { promise.set_value(ask(std::make_index_sequence<std::tuple_size_v<ArgsTuple>>())); }
|
||||
|
||||
template <std::size_t... I>
|
||||
ResultType ask(std::index_sequence<I...>) {
|
||||
@@ -66,11 +60,10 @@ template <class Object, class MemberFn, class ArgsTuple>
|
||||
class AskMessageImpl<void, Object, MemberFn, ArgsTuple> : public Message {
|
||||
public:
|
||||
AskMessageImpl(std::promise<void> promise_, Object& object_, MemberFn memberFn_, ArgsTuple argsTuple_)
|
||||
: object(object_),
|
||||
memberFn(memberFn_),
|
||||
argsTuple(std::move(argsTuple_)),
|
||||
promise(std::move(promise_)) {
|
||||
}
|
||||
: object(object_),
|
||||
memberFn(memberFn_),
|
||||
argsTuple(std::move(argsTuple_)),
|
||||
promise(std::move(promise_)) {}
|
||||
|
||||
void operator()() override {
|
||||
ask(std::make_index_sequence<std::tuple_size_v<ArgsTuple>>());
|
||||
@@ -97,9 +90,13 @@ std::unique_ptr<Message> makeMessage(Object& object, MemberFn memberFn, Args&&..
|
||||
}
|
||||
|
||||
template <class ResultType, class Object, class MemberFn, class... Args>
|
||||
std::unique_ptr<Message> makeMessage(std::promise<ResultType>&& promise, Object& object, MemberFn memberFn, Args&&... args) {
|
||||
std::unique_ptr<Message> makeMessage(std::promise<ResultType>&& promise,
|
||||
Object& object,
|
||||
MemberFn memberFn,
|
||||
Args&&... args) {
|
||||
auto tuple = std::make_tuple(std::forward<Args>(args)...);
|
||||
return std::make_unique<AskMessageImpl<ResultType, Object, MemberFn, decltype(tuple)>>(std::move(promise), object, memberFn, std::move(tuple));
|
||||
return std::make_unique<AskMessageImpl<ResultType, Object, MemberFn, decltype(tuple)>>(
|
||||
std::move(promise), object, memberFn, std::move(tuple));
|
||||
}
|
||||
|
||||
} // namespace actor
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <mapbox/std/weak.hpp>
|
||||
|
||||
#include <functional>
|
||||
@@ -47,16 +46,16 @@ public:
|
||||
/// the given closure to this scheduler, the consequent calls of the
|
||||
/// returned closure are ignored.
|
||||
///
|
||||
/// If this scheduler is already deleted by the time the returnded closure is
|
||||
/// first invoked, the call is ignored.
|
||||
/// If this scheduler is already deleted by the time the returnded closure
|
||||
/// is first invoked, the call is ignored.
|
||||
std::function<void()> bindOnce(std::function<void()>);
|
||||
|
||||
/// Enqueues the given |task| for execution into this scheduler's task queue and
|
||||
/// then enqueues the |reply| with the captured task result to the current
|
||||
/// task queue.
|
||||
/// Enqueues the given |task| for execution into this scheduler's task queue
|
||||
/// and then enqueues the |reply| with the captured task result to the
|
||||
/// current task queue.
|
||||
///
|
||||
/// The |TaskFn| return type must be compatible with the |ReplyFn| argument type.
|
||||
/// Note: the task result is copied and passed by value.
|
||||
/// The |TaskFn| return type must be compatible with the |ReplyFn| argument
|
||||
/// type. Note: the task result is copied and passed by value.
|
||||
template <typename TaskFn, typename ReplyFn>
|
||||
void scheduleAndReplyValue(const TaskFn& task, const ReplyFn& reply) {
|
||||
assert(GetCurrent());
|
||||
@@ -93,7 +92,9 @@ protected:
|
||||
auto scheduled = [replyScheduler = std::move(replyScheduler), task, reply] {
|
||||
auto lock = replyScheduler.lock();
|
||||
if (!replyScheduler) return;
|
||||
auto scheduledReply = [reply, result = task()] { reply(result); };
|
||||
auto scheduledReply = [reply, result = task()] {
|
||||
reply(result);
|
||||
};
|
||||
replyScheduler->schedule(std::move(scheduledReply));
|
||||
};
|
||||
|
||||
@@ -101,4 +102,4 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
} /// namespace mbgl
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -16,17 +16,16 @@ using AnnotationIDs = std::vector<AnnotationID>;
|
||||
|
||||
class SymbolAnnotation {
|
||||
public:
|
||||
SymbolAnnotation(Point<double> geometry_, std::string icon_ = {}) : geometry(geometry_), icon(std::move(icon_)) {}
|
||||
SymbolAnnotation(Point<double> geometry_, std::string icon_ = {})
|
||||
: geometry(geometry_),
|
||||
icon(std::move(icon_)) {}
|
||||
|
||||
Point<double> geometry;
|
||||
std::string icon;
|
||||
};
|
||||
|
||||
using ShapeAnnotationGeometry = variant<
|
||||
LineString<double>,
|
||||
Polygon<double>,
|
||||
MultiLineString<double>,
|
||||
MultiPolygon<double>>;
|
||||
using ShapeAnnotationGeometry =
|
||||
variant<LineString<double>, Polygon<double>, MultiLineString<double>, MultiPolygon<double>>;
|
||||
|
||||
class LineAnnotation {
|
||||
public:
|
||||
@@ -62,9 +61,6 @@ public:
|
||||
style::PropertyValue<Color> outlineColor;
|
||||
};
|
||||
|
||||
using Annotation = variant<
|
||||
SymbolAnnotation,
|
||||
LineAnnotation,
|
||||
FillAnnotation>;
|
||||
using Annotation = variant<SymbolAnnotation, LineAnnotation, FillAnnotation>;
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -11,9 +11,9 @@ class Backend {
|
||||
public:
|
||||
/// @brief The active graphics API/backend type.
|
||||
enum class Type : uint8_t {
|
||||
OpenGL, ///< The OpenGL API backend
|
||||
TYPE_MAX, ///< Not a valid backend type, used to determine the number
|
||||
///< of available backends (ie for array allocation).
|
||||
OpenGL, ///< The OpenGL API backend
|
||||
TYPE_MAX, ///< Not a valid backend type, used to determine the number
|
||||
///< of available backends (ie for array allocation).
|
||||
};
|
||||
|
||||
static constexpr Type DefaultType = Type::OpenGL;
|
||||
@@ -24,9 +24,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static Type GetType() {
|
||||
return Value(DefaultType);
|
||||
}
|
||||
static Type GetType() { return Value(DefaultType); }
|
||||
|
||||
template <typename T, typename... Args>
|
||||
static std::unique_ptr<T> Create(Args... args) {
|
||||
|
||||
@@ -7,10 +7,11 @@ class RendererBackend;
|
||||
|
||||
class BackendScope {
|
||||
public:
|
||||
/// There are two types of scopes: Creating an "Implicit" scope tells Mapbox GL that the
|
||||
/// supporting windowing system has already activated the GL Backend and that no further actions
|
||||
/// are required. Creating an "Explicit" scope actually enables the GL Backend, and disables it
|
||||
/// when the BackendScope is destroyed.
|
||||
/// There are two types of scopes: Creating an "Implicit" scope tells Mapbox
|
||||
/// GL that the supporting windowing system has already activated the GL
|
||||
/// Backend and that no further actions are required. Creating an "Explicit"
|
||||
/// scope actually enables the GL Backend, and disables it when the
|
||||
/// BackendScope is destroyed.
|
||||
enum class ScopeType : bool {
|
||||
Implicit,
|
||||
Explicit,
|
||||
|
||||
@@ -21,14 +21,12 @@ public:
|
||||
class Renderable {
|
||||
protected:
|
||||
Renderable(const Size size_, std::unique_ptr<RenderableResource> resource_)
|
||||
: size(size_), resource(std::move(resource_)) {
|
||||
}
|
||||
: size(size_),
|
||||
resource(std::move(resource_)) {}
|
||||
virtual ~Renderable() = default;
|
||||
|
||||
public:
|
||||
Size getSize() const {
|
||||
return size;
|
||||
}
|
||||
Size getSize() const { return size; }
|
||||
|
||||
template <typename T>
|
||||
T& getResource() const {
|
||||
|
||||
@@ -35,9 +35,7 @@ public:
|
||||
return static_cast<T&>(getContext());
|
||||
}
|
||||
|
||||
bool contextIsShared() const {
|
||||
return contextMode == ContextMode::Shared;
|
||||
}
|
||||
bool contextIsShared() const { return contextMode == ContextMode::Shared; }
|
||||
|
||||
/// Returns a reference to the default surface that should be rendered on.
|
||||
virtual Renderable& getDefaultRenderable() = 0;
|
||||
@@ -45,13 +43,16 @@ public:
|
||||
protected:
|
||||
virtual std::unique_ptr<Context> createContext() = 0;
|
||||
|
||||
/// Called when the backend's GL context needs to be made active or inactive. These are called,
|
||||
/// as a matched pair, exclusively through BackendScope, in two situations:
|
||||
/// Called when the backend's GL context needs to be made active or
|
||||
/// inactive. These are called, as a matched pair, exclusively through
|
||||
/// BackendScope, in two situations:
|
||||
///
|
||||
/// 1. When releasing GL resources during Renderer destruction
|
||||
/// (Including calling CustomLayerHost::deinitialize during RenderCustomLayer destruction)
|
||||
/// (Including calling CustomLayerHost::deinitialize during
|
||||
/// RenderCustomLayer destruction)
|
||||
/// 2. When renderering through Renderer::render()
|
||||
/// (Including calling CustomLayerHost::initialize for newly added custom layers and
|
||||
/// (Including calling CustomLayerHost::initialize for newly added
|
||||
/// custom layers and
|
||||
/// CustomLayerHost::deinitialize on layer removal)
|
||||
virtual void activate() = 0;
|
||||
virtual void deactivate() = 0;
|
||||
|
||||
@@ -13,36 +13,30 @@ class Shader;
|
||||
// * Inherit gfx::Shader
|
||||
// * Declare a public, unique type name (string_view T::Name)
|
||||
// * Be a final class
|
||||
template<typename T>
|
||||
inline constexpr bool is_shader_v =
|
||||
std::is_base_of_v<gfx::Shader, T> &&
|
||||
std::is_same_v<
|
||||
std::remove_cv_t<decltype(T::Name)>,
|
||||
std::string_view> &&
|
||||
std::is_final_v<T>;
|
||||
|
||||
template <typename T>
|
||||
inline constexpr bool is_shader_v = std::is_base_of_v<gfx::Shader, T>&&
|
||||
std::is_same_v<std::remove_cv_t<decltype(T::Name)>, std::string_view>&& std::is_final_v<T>;
|
||||
|
||||
/// @brief A shader is used as the base class for all programs across any supported
|
||||
/// backend API. Shaders are registered with a `gfx::ShaderRegistry` instance.
|
||||
class Shader {
|
||||
public:
|
||||
virtual ~Shader() = default;
|
||||
public:
|
||||
virtual ~Shader() = default;
|
||||
|
||||
/// @brief Get the type name of this shader
|
||||
/// @return Shader type name
|
||||
virtual const std::string_view typeName() const noexcept = 0;
|
||||
/// @brief Get the type name of this shader
|
||||
/// @return Shader type name
|
||||
virtual const std::string_view typeName() const noexcept = 0;
|
||||
|
||||
/// @brief Downcast to a type
|
||||
/// @tparam T Derived type
|
||||
/// @return Type or nullptr if type info was not a match
|
||||
template<typename T,
|
||||
typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
|
||||
T* to() noexcept {
|
||||
if (typeName() != T::Name) {
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<T*>(this);
|
||||
/// @brief Downcast to a type
|
||||
/// @tparam T Derived type
|
||||
/// @return Type or nullptr if type info was not a match
|
||||
template <typename T, typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
|
||||
T* to() noexcept {
|
||||
if (typeName() != T::Name) {
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<T*>(this);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -14,141 +14,128 @@ namespace gfx {
|
||||
/// Using the registry, shaders may be dynamically registered or replaced
|
||||
/// at runtime.
|
||||
class ShaderRegistry {
|
||||
public:
|
||||
explicit ShaderRegistry();
|
||||
ShaderRegistry(const ShaderRegistry&) = delete;
|
||||
ShaderRegistry(ShaderRegistry&&) noexcept = delete;
|
||||
ShaderRegistry& operator=(const ShaderRegistry&) = delete;
|
||||
ShaderRegistry& operator=(ShaderRegistry&&) noexcept = delete;
|
||||
virtual ~ShaderRegistry() = default;
|
||||
public:
|
||||
explicit ShaderRegistry();
|
||||
ShaderRegistry(const ShaderRegistry&) = delete;
|
||||
ShaderRegistry(ShaderRegistry&&) noexcept = delete;
|
||||
ShaderRegistry& operator=(const ShaderRegistry&) = delete;
|
||||
ShaderRegistry& operator=(ShaderRegistry&&) noexcept = delete;
|
||||
virtual ~ShaderRegistry() = default;
|
||||
|
||||
/// @brief Checks if a shader exists in the registry for the given name.
|
||||
/// @param shaderName Name of shader
|
||||
/// @return If a shader is found, true
|
||||
[[nodiscard]] virtual bool isShader(const std::string& shaderName)
|
||||
const noexcept;
|
||||
|
||||
/// @brief Get a shader from the registry by name.
|
||||
/// @param shaderName Name of shader
|
||||
/// @return A `gfx::Shader` or `nullptr` if no shader is found with the
|
||||
/// given name
|
||||
[[nodiscard]] virtual const std::shared_ptr<gfx::Shader> getShader(
|
||||
const std::string& shaderName) const noexcept;
|
||||
/// @brief Checks if a shader exists in the registry for the given name.
|
||||
/// @param shaderName Name of shader
|
||||
/// @return If a shader is found, true
|
||||
[[nodiscard]] virtual bool isShader(const std::string& shaderName) const noexcept;
|
||||
|
||||
/// @brief Replace a matching shader in the registry with the provided
|
||||
/// instance. Shader type-names must match.
|
||||
/// @param shader A `gfx::Shader`. The ShaderRegistry will take ownership.
|
||||
/// @return True if a match was found and the shader was replaced, false
|
||||
/// otherwise.
|
||||
[[nodiscard]] virtual bool replaceShader(
|
||||
std::shared_ptr<Shader>&& shader) noexcept;
|
||||
/// @brief Get a shader from the registry by name.
|
||||
/// @param shaderName Name of shader
|
||||
/// @return A `gfx::Shader` or `nullptr` if no shader is found with the
|
||||
/// given name
|
||||
[[nodiscard]] virtual const std::shared_ptr<gfx::Shader> getShader(const std::string& shaderName) const noexcept;
|
||||
|
||||
/// @brief Replace a matching shader in the registry with the provided
|
||||
/// instance. Shader type-names must match.
|
||||
/// This variant replaces by explicit name.
|
||||
/// @param shader A `gfx::Shader`. The ShaderRegistry will take ownership.
|
||||
/// @param shaderName Unique name to register the shader under.
|
||||
/// @return True if a match was found and the shader was replaced, false
|
||||
/// otherwise.
|
||||
[[nodiscard]] virtual bool replaceShader(
|
||||
std::shared_ptr<Shader>&& shader, const std::string& shaderName) noexcept;
|
||||
|
||||
/// @brief Register a new shader with the registry. If a shader is present
|
||||
/// in the registry with a conflicting name, registration will fail.
|
||||
/// @param shader A `gfx::Shader` to register. The ShaderRegistry will
|
||||
/// take ownership.
|
||||
/// @return True if the shader was registered, false if another shader is
|
||||
/// already present with a conflicting name.
|
||||
[[nodiscard]] virtual bool registerShader(
|
||||
std::shared_ptr<Shader>&& shader) noexcept;
|
||||
|
||||
/// @brief Register a new shader with the registry. If a shader is present
|
||||
/// in the registry with a conflicting name, registration will fail.
|
||||
/// This variant registers using an explicit name.
|
||||
/// @param shader A `gfx::Shader` to register. The ShaderRegistry will
|
||||
/// take ownership.
|
||||
/// @param shaderName Unique name to register the shader under.
|
||||
/// @return True if the shader was registered, false if another shader is
|
||||
/// already present with a conflicting name.
|
||||
[[nodiscard]] virtual bool registerShader(
|
||||
std::shared_ptr<Shader>&& shader, const std::string& shaderName) noexcept;
|
||||
/// @brief Replace a matching shader in the registry with the provided
|
||||
/// instance. Shader type-names must match.
|
||||
/// @param shader A `gfx::Shader`. The ShaderRegistry will take ownership.
|
||||
/// @return True if a match was found and the shader was replaced, false
|
||||
/// otherwise.
|
||||
[[nodiscard]] virtual bool replaceShader(std::shared_ptr<Shader>&& shader) noexcept;
|
||||
|
||||
/// @brief Shorthand helper to quickly get a derived type from the registry.
|
||||
/// @tparam T Derived type, inheriting `gfx::Shader`
|
||||
/// @param shaderName The registry name to look up
|
||||
/// @return T or nullptr if not found in the registry
|
||||
template<typename T,
|
||||
typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
|
||||
std::shared_ptr<T> get(const std::string& shaderName) noexcept {
|
||||
auto shader = getShader(shaderName);
|
||||
if (!shader || shader->typeName() != T::Name) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::static_pointer_cast<T>(shader);
|
||||
/// @brief Replace a matching shader in the registry with the provided
|
||||
/// instance. Shader type-names must match.
|
||||
/// This variant replaces by explicit name.
|
||||
/// @param shader A `gfx::Shader`. The ShaderRegistry will take ownership.
|
||||
/// @param shaderName Unique name to register the shader under.
|
||||
/// @return True if a match was found and the shader was replaced, false
|
||||
/// otherwise.
|
||||
[[nodiscard]] virtual bool replaceShader(std::shared_ptr<Shader>&& shader, const std::string& shaderName) noexcept;
|
||||
|
||||
/// @brief Register a new shader with the registry. If a shader is present
|
||||
/// in the registry with a conflicting name, registration will fail.
|
||||
/// @param shader A `gfx::Shader` to register. The ShaderRegistry will
|
||||
/// take ownership.
|
||||
/// @return True if the shader was registered, false if another shader is
|
||||
/// already present with a conflicting name.
|
||||
[[nodiscard]] virtual bool registerShader(std::shared_ptr<Shader>&& shader) noexcept;
|
||||
|
||||
/// @brief Register a new shader with the registry. If a shader is present
|
||||
/// in the registry with a conflicting name, registration will fail.
|
||||
/// This variant registers using an explicit name.
|
||||
/// @param shader A `gfx::Shader` to register. The ShaderRegistry will
|
||||
/// take ownership.
|
||||
/// @param shaderName Unique name to register the shader under.
|
||||
/// @return True if the shader was registered, false if another shader is
|
||||
/// already present with a conflicting name.
|
||||
[[nodiscard]] virtual bool registerShader(std::shared_ptr<Shader>&& shader, const std::string& shaderName) noexcept;
|
||||
|
||||
/// @brief Shorthand helper to quickly get a derived type from the registry.
|
||||
/// @tparam T Derived type, inheriting `gfx::Shader`
|
||||
/// @param shaderName The registry name to look up
|
||||
/// @return T or nullptr if not found in the registry
|
||||
template <typename T, typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
|
||||
std::shared_ptr<T> get(const std::string& shaderName) noexcept {
|
||||
auto shader = getShader(shaderName);
|
||||
if (!shader || shader->typeName() != T::Name) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::static_pointer_cast<T>(shader);
|
||||
}
|
||||
|
||||
/// @brief Shorthand helper to quickly get a derived type from the registry.
|
||||
/// This variant looks up shaders only by type name.
|
||||
/// @tparam T Derived type, inheriting `gfx::Shader`
|
||||
/// @return T or nullptr if not found in the registry
|
||||
template<typename T,
|
||||
typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
|
||||
std::shared_ptr<T> get() noexcept {
|
||||
auto shader = getShader(std::string(T::Name));
|
||||
if (!shader || shader->typeName() != T::Name) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::static_pointer_cast<T>(shader);
|
||||
/// @brief Shorthand helper to quickly get a derived type from the registry.
|
||||
/// This variant looks up shaders only by type name.
|
||||
/// @tparam T Derived type, inheriting `gfx::Shader`
|
||||
/// @return T or nullptr if not found in the registry
|
||||
template <typename T, typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
|
||||
std::shared_ptr<T> get() noexcept {
|
||||
auto shader = getShader(std::string(T::Name));
|
||||
if (!shader || shader->typeName() != T::Name) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::static_pointer_cast<T>(shader);
|
||||
}
|
||||
|
||||
/// @brief Ensure the destination 'to' is populated with the requested
|
||||
/// shader. If already non-null, does nothing.
|
||||
/// @tparam T Derived type, inheriting `gfx::Shader`
|
||||
/// @param to Location to store the shader
|
||||
/// @param shaderName The registry name to look up
|
||||
/// @return True if 'to' has a valid program object, false otherwise.
|
||||
template<typename T,
|
||||
typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
|
||||
bool populate(std::shared_ptr<T>& to, const std::string& shaderName) noexcept {
|
||||
if (to) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto shader = getShader(shaderName);
|
||||
if (!shader || shader->typeName() != T::Name) {
|
||||
return false;
|
||||
}
|
||||
to = std::static_pointer_cast<T>(shader);
|
||||
/// @brief Ensure the destination 'to' is populated with the requested
|
||||
/// shader. If already non-null, does nothing.
|
||||
/// @tparam T Derived type, inheriting `gfx::Shader`
|
||||
/// @param to Location to store the shader
|
||||
/// @param shaderName The registry name to look up
|
||||
/// @return True if 'to' has a valid program object, false otherwise.
|
||||
template <typename T, typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
|
||||
bool populate(std::shared_ptr<T>& to, const std::string& shaderName) noexcept {
|
||||
if (to) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @brief Ensure the destination 'to' is populated with the requested
|
||||
/// shader. If already non-null, does nothing. This variant looks up
|
||||
/// shaders only by type name.
|
||||
/// @tparam T Derived type, inheriting `gfx::Shader`
|
||||
/// @param to Location to store the shader
|
||||
/// @return True if 'to' has a valid program object, false otherwise.
|
||||
template<typename T,
|
||||
typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
|
||||
bool populate(std::shared_ptr<T>& to) noexcept {
|
||||
if (to) {
|
||||
return true;
|
||||
}
|
||||
auto shader = getShader(shaderName);
|
||||
if (!shader || shader->typeName() != T::Name) {
|
||||
return false;
|
||||
}
|
||||
to = std::static_pointer_cast<T>(shader);
|
||||
return true;
|
||||
}
|
||||
|
||||
auto shader = getShader(std::string(T::Name));
|
||||
if (!shader || shader->typeName() != T::Name) {
|
||||
return false;
|
||||
}
|
||||
to = std::static_pointer_cast<T>(shader);
|
||||
/// @brief Ensure the destination 'to' is populated with the requested
|
||||
/// shader. If already non-null, does nothing. This variant looks up
|
||||
/// shaders only by type name.
|
||||
/// @tparam T Derived type, inheriting `gfx::Shader`
|
||||
/// @param to Location to store the shader
|
||||
/// @return True if 'to' has a valid program object, false otherwise.
|
||||
template <typename T, typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
|
||||
bool populate(std::shared_ptr<T>& to) noexcept {
|
||||
if (to) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<
|
||||
std::string,
|
||||
std::shared_ptr<gfx::Shader>
|
||||
> programs;
|
||||
mutable std::shared_mutex programLock;
|
||||
auto shader = getShader(std::string(T::Name));
|
||||
if (!shader || shader->typeName() != T::Name) {
|
||||
return false;
|
||||
}
|
||||
to = std::static_pointer_cast<T>(shader);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::shared_ptr<gfx::Shader>> programs;
|
||||
mutable std::shared_mutex programLock;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
/**
|
||||
* Parameters that define the current camera position for a `CustomLayerHost::render()` function.
|
||||
* Parameters that define the current camera position for a
|
||||
* `CustomLayerHost::render()` function.
|
||||
*/
|
||||
struct CustomLayerRenderParameters {
|
||||
double width;
|
||||
@@ -26,21 +27,24 @@ class CustomLayerHost {
|
||||
public:
|
||||
virtual ~CustomLayerHost() = default;
|
||||
/**
|
||||
* Initialize any GL state needed by the custom layer. This method is called once, from the
|
||||
* main thread, at a point when the GL context is active but before rendering for the first
|
||||
* time.
|
||||
* Initialize any GL state needed by the custom layer. This method is called
|
||||
* once, from the main thread, at a point when the GL context is active but
|
||||
* before rendering for the first time.
|
||||
*
|
||||
* Resources that are acquired in this method must be released in the `deinitialize` function.
|
||||
* Resources that are acquired in this method must be released in the
|
||||
* `deinitialize` function.
|
||||
*/
|
||||
virtual void initialize() = 0;
|
||||
|
||||
/**
|
||||
* Render the layer. This method is called once per frame. The implementation should not make
|
||||
* any assumptions about the GL state (other than that the correct context is active). It may
|
||||
* make changes to the state, and is not required to reset values such as the depth mask, stencil
|
||||
* mask, and corresponding test flags to their original values.
|
||||
* Make sure that you are drawing your fragments with a z value of 1 to take advantage of the
|
||||
* opaque fragment culling in case there are opaque layers above your custom layer.
|
||||
* Render the layer. This method is called once per frame. The
|
||||
* implementation should not make any assumptions about the GL state (other
|
||||
* than that the correct context is active). It may make changes to the
|
||||
* state, and is not required to reset values such as the depth mask,
|
||||
* stencil mask, and corresponding test flags to their original values. Make
|
||||
* sure that you are drawing your fragments with a z value of 1 to take
|
||||
* advantage of the opaque fragment culling in case there are opaque layers
|
||||
* above your custom layer.
|
||||
*/
|
||||
virtual void render(const CustomLayerRenderParameters&) = 0;
|
||||
|
||||
@@ -53,18 +57,19 @@ public:
|
||||
virtual void contextLost() = 0;
|
||||
|
||||
/**
|
||||
* Destroy any GL state needed by the custom layer, and deallocate context, if necessary. This
|
||||
* method is called once, from the main thread, at a point when the GL context is active.
|
||||
* Destroy any GL state needed by the custom layer, and deallocate context,
|
||||
* if necessary. This method is called once, from the main thread, at a
|
||||
* point when the GL context is active.
|
||||
*
|
||||
* Note that it may be called even when the `initialize` function has not been called.
|
||||
* Note that it may be called even when the `initialize` function has not
|
||||
* been called.
|
||||
*/
|
||||
virtual void deinitialize() = 0;
|
||||
};
|
||||
|
||||
class CustomLayer final : public Layer {
|
||||
public:
|
||||
CustomLayer(const std::string& id,
|
||||
std::unique_ptr<CustomLayerHost> host);
|
||||
CustomLayer(const std::string& id, std::unique_ptr<CustomLayerHost> host);
|
||||
|
||||
CustomLayer(const CustomLayer&) = delete;
|
||||
~CustomLayer() final;
|
||||
|
||||
@@ -10,7 +10,8 @@ namespace mbgl {
|
||||
class CustomLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ public:
|
||||
virtual void bind() = 0;
|
||||
|
||||
virtual void swap() {
|
||||
// Renderable resources that require a swap function to be called explicitly
|
||||
// can override this method.
|
||||
// Renderable resources that require a swap function to be called
|
||||
// explicitly can override this method.
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -22,17 +22,17 @@ public:
|
||||
protected:
|
||||
std::unique_ptr<gfx::Context> createContext() override;
|
||||
|
||||
/// Called with the name of an OpenGL extension that should be loaded. RendererBackend implementations
|
||||
/// must call the API-specific version that obtains the function pointer for this function,
|
||||
/// or a null pointer if unsupported/unavailable.
|
||||
/// Called with the name of an OpenGL extension that should be loaded.
|
||||
/// RendererBackend implementations must call the API-specific version that
|
||||
/// obtains the function pointer for this function, or a null pointer if
|
||||
/// unsupported/unavailable.
|
||||
virtual ProcAddress getExtensionFunctionPointer(const char*) = 0;
|
||||
|
||||
/// Reads the color pixel data from the currently bound framebuffer.
|
||||
PremultipliedImage readFramebuffer(const Size&);
|
||||
|
||||
/// A constant to signal that a framebuffer is bound, but with an unknown ID.
|
||||
static constexpr const FramebufferID ImplicitFramebufferBinding =
|
||||
std::numeric_limits<FramebufferID>::max();
|
||||
static constexpr const FramebufferID ImplicitFramebufferBinding = std::numeric_limits<FramebufferID>::max();
|
||||
|
||||
/// Tells the renderer that OpenGL state has already been set by the windowing toolkit.
|
||||
/// It sets the internal assumed state to the supplied values.
|
||||
@@ -44,8 +44,8 @@ protected:
|
||||
bool implicitFramebufferBound();
|
||||
|
||||
public:
|
||||
/// Triggers an OpenGL state update if the internal assumed state doesn't match the
|
||||
/// supplied values.
|
||||
/// Triggers an OpenGL state update if the internal assumed state doesn't
|
||||
/// match the supplied values.
|
||||
void setFramebufferBinding(FramebufferID fbo);
|
||||
void setViewport(int32_t x, int32_t y, const Size&);
|
||||
void setScissorTest(bool);
|
||||
|
||||
@@ -9,7 +9,9 @@ namespace platform {
|
||||
|
||||
class Collator {
|
||||
public:
|
||||
explicit Collator(bool caseSensitive, bool diacriticSensitive, const std::optional<std::string>& locale = std::nullopt);
|
||||
explicit Collator(bool caseSensitive,
|
||||
bool diacriticSensitive,
|
||||
const std::optional<std::string>& locale = std::nullopt);
|
||||
int compare(const std::string& lhs, const std::string& rhs) const;
|
||||
std::string resolvedLocale() const;
|
||||
bool operator==(const Collator& other) const;
|
||||
|
||||
@@ -7,7 +7,8 @@ namespace mbgl {
|
||||
class BackgroundLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ namespace mbgl {
|
||||
class CircleLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> tileLayer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept final;
|
||||
|
||||
@@ -7,8 +7,11 @@ namespace mbgl {
|
||||
class FillExtrusionLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>, const std::vector<Immutable<style::LayerProperties>>&) noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&,
|
||||
std::unique_ptr<GeometryTileLayer>,
|
||||
const std::vector<Immutable<style::LayerProperties>>&) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,8 +7,11 @@ namespace mbgl {
|
||||
class FillLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>, const std::vector<Immutable<style::LayerProperties>>&) noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&,
|
||||
std::unique_ptr<GeometryTileLayer>,
|
||||
const std::vector<Immutable<style::LayerProperties>>&) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@ namespace mbgl {
|
||||
class HeatmapLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&) noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Bucket> createBucket(const BucketParameters&,
|
||||
const std::vector<Immutable<style::LayerProperties>>&) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ namespace mbgl {
|
||||
class HillshadeLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace mbgl {
|
||||
|
||||
namespace style {
|
||||
class LayerProperties;
|
||||
} // namespace style
|
||||
} // namespace style
|
||||
class Bucket;
|
||||
class BucketParameters;
|
||||
class GeometryTileLayer;
|
||||
@@ -18,22 +18,27 @@ class RenderLayer;
|
||||
|
||||
/**
|
||||
* @brief The LayerFactory abstract class
|
||||
*
|
||||
* This class is responsible for creation of the layer objects that belong to a concrete layer type.
|
||||
*
|
||||
* This class is responsible for creation of the layer objects that belong to a
|
||||
* concrete layer type.
|
||||
*/
|
||||
class LayerFactory {
|
||||
public:
|
||||
virtual ~LayerFactory() = default;
|
||||
/// Returns the layer type data.
|
||||
virtual const style::LayerTypeInfo* getTypeInfo() const noexcept = 0;
|
||||
/// Returns a new Layer instance on success call; returns `nullptr` otherwise.
|
||||
virtual std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept = 0;
|
||||
/// Returns a new Layer instance on success call; returns `nullptr` otherwise.
|
||||
virtual std::unique_ptr<style::Layer> createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept = 0;
|
||||
/// Returns a new RenderLayer instance.
|
||||
virtual std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept = 0;
|
||||
/// Returns a new Bucket instance on success call; returns `nullptr` otherwise.
|
||||
virtual std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&) noexcept;
|
||||
/// Returns a new Layout instance on success call; returns `nullptr` otherwise.
|
||||
virtual std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>, const std::vector<Immutable<style::LayerProperties>>&) noexcept;
|
||||
/// Returns a new Bucket instance on success call; returns `nullptr` otherwise.
|
||||
virtual std::unique_ptr<Bucket> createBucket(const BucketParameters&,
|
||||
const std::vector<Immutable<style::LayerProperties>>&) noexcept;
|
||||
/// Returns a new Layout instance on success call; returns `nullptr` otherwise.
|
||||
virtual std::unique_ptr<Layout> createLayout(const LayoutParameters&,
|
||||
std::unique_ptr<GeometryTileLayer>,
|
||||
const std::vector<Immutable<style::LayerProperties>>&) noexcept;
|
||||
|
||||
protected:
|
||||
std::optional<std::string> getSource(const style::conversion::Convertible& value) const noexcept;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
class LayerProperties;
|
||||
} // namespace style
|
||||
} // namespace style
|
||||
class GeometryTileLayer;
|
||||
class LayerFactory;
|
||||
class RenderLayer;
|
||||
@@ -18,10 +18,10 @@ class LayoutParameters;
|
||||
|
||||
/**
|
||||
* @brief A singleton class responsible for creating layer instances.
|
||||
*
|
||||
*
|
||||
* The LayerManager has implementation per platform. The LayerManager implementation
|
||||
* defines what layer types are available and it can also disable annotations.
|
||||
*
|
||||
*
|
||||
* Linker excludes the unreachable code for the disabled annotations and layers
|
||||
* from the binaries, significantly reducing their size.
|
||||
*/
|
||||
@@ -29,34 +29,40 @@ class LayerManager {
|
||||
public:
|
||||
/**
|
||||
* @brief A singleton getter.
|
||||
*
|
||||
* @return LayerManager*
|
||||
*
|
||||
* @return LayerManager*
|
||||
*/
|
||||
static LayerManager* get() noexcept;
|
||||
|
||||
/// Returns a new Layer instance on success call; returns `nullptr` otherwise.
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& type, const std::string& id,
|
||||
const style::conversion::Convertible& value, style::conversion::Error& error) noexcept;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& type,
|
||||
const std::string& id,
|
||||
const style::conversion::Convertible& value,
|
||||
style::conversion::Error& error) noexcept;
|
||||
/// Returns a new RenderLayer instance on success call; returns `nullptr` otherwise.
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept;
|
||||
/// Returns a new Bucket instance on success call; returns `nullptr` otherwise.
|
||||
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&) noexcept;
|
||||
/// Returns a new Layout instance on success call; returns `nullptr` otherwise.
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>,
|
||||
std::unique_ptr<Bucket> createBucket(const BucketParameters&,
|
||||
const std::vector<Immutable<style::LayerProperties>>&) noexcept;
|
||||
/// Returns a new Layout instance on success call; returns `nullptr` otherwise.
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&,
|
||||
std::unique_ptr<GeometryTileLayer>,
|
||||
const std::vector<Immutable<style::LayerProperties>>&) noexcept;
|
||||
|
||||
/**
|
||||
* @brief a build-time flag to enable/disable annotations in mapbox-gl-native core.
|
||||
*
|
||||
* At the moment, the annotations implementation in core is creating concrete
|
||||
* layer instances apart from LayerManager/LayerFactory code path.
|
||||
*
|
||||
* @brief a build-time flag to enable/disable annotations in
|
||||
* mapbox-gl-native core.
|
||||
*
|
||||
* At the moment, the annotations implementation in core is creating
|
||||
* concrete layer instances apart from LayerManager/LayerFactory code path.
|
||||
*
|
||||
* So, annotations must be disabled if the LayerManager implementation does
|
||||
* not provide line, fill or symbol layers (those, used by the annotations
|
||||
* not provide line, fill or symbol layers (those, used by the annotations
|
||||
* implementation).
|
||||
*
|
||||
* Note: in future, annotations implemantation will be moved from the core to platform
|
||||
* SDK (see https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation)
|
||||
*
|
||||
* Note: in future, annotations implemantation will be moved from the core
|
||||
* to platform SDK (see
|
||||
* https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation)
|
||||
* and this flag won't be needed any more.
|
||||
*/
|
||||
static const bool annotationsEnabled;
|
||||
|
||||
@@ -7,7 +7,8 @@ namespace mbgl {
|
||||
class LineLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> tileLayer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept final;
|
||||
|
||||
@@ -7,7 +7,8 @@ namespace mbgl {
|
||||
class RasterLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ namespace mbgl {
|
||||
class SymbolLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> tileLayer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept final;
|
||||
|
||||
@@ -12,11 +12,20 @@ namespace mbgl {
|
||||
*/
|
||||
struct BoundOptions {
|
||||
/// Sets the latitude and longitude bounds to which the camera center are constrained
|
||||
BoundOptions& withLatLngBounds(LatLngBounds b) { bounds = b; return *this; }
|
||||
BoundOptions& withLatLngBounds(LatLngBounds b) {
|
||||
bounds = b;
|
||||
return *this;
|
||||
}
|
||||
/// Sets the minimum zoom level
|
||||
BoundOptions& withMinZoom(double z) { minZoom = z; return *this; }
|
||||
BoundOptions& withMinZoom(double z) {
|
||||
minZoom = z;
|
||||
return *this;
|
||||
}
|
||||
/// Sets the maximum zoom level
|
||||
BoundOptions& withMaxZoom(double z) { maxZoom = z; return *this; }
|
||||
BoundOptions& withMaxZoom(double z) {
|
||||
maxZoom = z;
|
||||
return *this;
|
||||
}
|
||||
/// Sets the minimum pitch
|
||||
BoundOptions& withMinPitch(double p) {
|
||||
minPitch = p;
|
||||
@@ -44,4 +53,4 @@ struct BoundOptions {
|
||||
std::optional<double> minPitch;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -17,12 +17,30 @@ namespace mbgl {
|
||||
center point when both are set.
|
||||
*/
|
||||
struct CameraOptions {
|
||||
CameraOptions& withCenter(const std::optional<LatLng>& o) { center = o; return *this; }
|
||||
CameraOptions& withPadding(const std::optional<EdgeInsets>& p) { padding = p; return *this; }
|
||||
CameraOptions& withAnchor(const std::optional<ScreenCoordinate>& o) { anchor = o; return *this; }
|
||||
CameraOptions& withZoom(const std::optional<double>& o) { zoom = o; return *this; }
|
||||
CameraOptions& withBearing(const std::optional<double>& o) { bearing = o; return *this; }
|
||||
CameraOptions& withPitch(const std::optional<double>& o) { pitch = o; return *this; }
|
||||
CameraOptions& withCenter(const std::optional<LatLng>& o) {
|
||||
center = o;
|
||||
return *this;
|
||||
}
|
||||
CameraOptions& withPadding(const std::optional<EdgeInsets>& p) {
|
||||
padding = p;
|
||||
return *this;
|
||||
}
|
||||
CameraOptions& withAnchor(const std::optional<ScreenCoordinate>& o) {
|
||||
anchor = o;
|
||||
return *this;
|
||||
}
|
||||
CameraOptions& withZoom(const std::optional<double>& o) {
|
||||
zoom = o;
|
||||
return *this;
|
||||
}
|
||||
CameraOptions& withBearing(const std::optional<double>& o) {
|
||||
bearing = o;
|
||||
return *this;
|
||||
}
|
||||
CameraOptions& withPitch(const std::optional<double>& o) {
|
||||
pitch = o;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Coordinate at the center of the map. */
|
||||
std::optional<LatLng> center;
|
||||
@@ -48,12 +66,8 @@ struct CameraOptions {
|
||||
};
|
||||
|
||||
constexpr bool operator==(const CameraOptions& a, const CameraOptions& b) {
|
||||
return a.center == b.center
|
||||
&& a.padding == b.padding
|
||||
&& a.anchor == b.anchor
|
||||
&& a.zoom == b.zoom
|
||||
&& a.bearing == b.bearing
|
||||
&& a.pitch == b.pitch;
|
||||
return a.center == b.center && a.padding == b.padding && a.anchor == b.anchor && a.zoom == b.zoom &&
|
||||
a.bearing == b.bearing && a.pitch == b.pitch;
|
||||
}
|
||||
|
||||
constexpr bool operator!=(const CameraOptions& a, const CameraOptions& b) {
|
||||
@@ -98,24 +112,26 @@ struct AnimationOptions {
|
||||
: duration(d) {}
|
||||
};
|
||||
|
||||
/** Various options for accessing physical properties of the underlying camera entity.
|
||||
A direct access to these properties allows more flexible and precise controlling of the camera
|
||||
while also being fully compatible and interchangeable with CameraOptions. All fields are optional. */
|
||||
/** Various options for accessing physical properties of the underlying camera
|
||||
entity. A direct access to these properties allows more flexible and precise
|
||||
controlling of the camera while also being fully compatible and
|
||||
interchangeable with CameraOptions. All fields are optional. */
|
||||
struct FreeCameraOptions {
|
||||
/** Position of the camera in slightly modified web mercator coordinates
|
||||
- The size of 1 unit is the width of the projected world instead of the "mercator meter".
|
||||
Coordinate [0, 0, 0] is the north-west corner and [1, 1, 0] is the south-east corner.
|
||||
- Z coordinate is conformal and must respect minimum and maximum zoom values.
|
||||
- The size of 1 unit is the width of the projected world instead of the
|
||||
"mercator meter". Coordinate [0, 0, 0] is the north-west corner and [1,
|
||||
1, 0] is the south-east corner.
|
||||
- Z coordinate is conformal and must respect minimum and maximum zoom
|
||||
values.
|
||||
- Zoom is automatically computed from the altitude (z)
|
||||
*/
|
||||
std::optional<vec3> position = std::nullopt;
|
||||
|
||||
/** Orientation of the camera represented as a unit quaternion [x, y, z, w].
|
||||
The default pose of the camera is such that the forward vector is looking up the -Z axis and
|
||||
the up vector is aligned with north orientation of the map:
|
||||
forward: [0, 0, -1]
|
||||
up: [0, -1, 0]
|
||||
right [1, 0, 0]
|
||||
The default pose of the camera is such that the forward vector is
|
||||
looking up the -Z axis and the up vector is aligned with north
|
||||
orientation of the map: forward: [0, 0, -1] up: [0, -1, 0] right [1,
|
||||
0, 0]
|
||||
|
||||
Orientation can be set freely but certain constraints still apply
|
||||
- Orientation must be representable with only pitch and bearing.
|
||||
@@ -125,17 +141,18 @@ struct FreeCameraOptions {
|
||||
/** Helper function for setting the mercator position as Lat&Lng and altitude in meters */
|
||||
void setLocation(const LatLngAltitude& location);
|
||||
|
||||
/** Helper function for converting mercator position into Lat&Lng and altitude in meters.
|
||||
This function fails to return a value if `position` is invalid or is not set */
|
||||
/** Helper function for converting mercator position into Lat&Lng and
|
||||
altitude in meters. This function fails to return a value if `position`
|
||||
is invalid or is not set */
|
||||
std::optional<LatLngAltitude> getLocation() const;
|
||||
|
||||
/** Helper function for setting orientation of the camera by defining a focus point
|
||||
on the map. Up vector is required in certain scenarios where bearing can't be deduced
|
||||
from the viewing direction */
|
||||
/** Helper function for setting orientation of the camera by defining a
|
||||
focus point on the map. Up vector is required in certain scenarios where
|
||||
bearing can't be deduced from the viewing direction */
|
||||
void lookAtPoint(const LatLng& location, const std::optional<vec3>& upVector = std::nullopt);
|
||||
|
||||
/** Helper function for setting the orientation of the camera as a pitch and a bearing.
|
||||
Both values are in degrees */
|
||||
/** Helper function for setting the orientation of the camera as a pitch and
|
||||
a bearing. Both values are in degrees */
|
||||
void setPitchBearing(double pitch, double bearing);
|
||||
};
|
||||
|
||||
|
||||
@@ -40,16 +40,16 @@ public:
|
||||
const ClientOptions& = ClientOptions());
|
||||
~Map();
|
||||
|
||||
/// Register a callback that will get called (on the render thread) when all resources have
|
||||
/// been loaded and a complete render occurs.
|
||||
using StillImageCallback = std::function<void (std::exception_ptr)>;
|
||||
/// Register a callback that will get called (on the render thread) when all
|
||||
/// resources have been loaded and a complete render occurs.
|
||||
using StillImageCallback = std::function<void(std::exception_ptr)>;
|
||||
void renderStill(StillImageCallback);
|
||||
void renderStill(const CameraOptions&, MapDebugOptions, StillImageCallback);
|
||||
|
||||
/// Triggers a repaint.
|
||||
void triggerRepaint();
|
||||
|
||||
style::Style& getStyle();
|
||||
style::Style& getStyle();
|
||||
const style::Style& getStyle() const;
|
||||
|
||||
void setStyle(std::unique_ptr<style::Style>);
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
void setSize(Size);
|
||||
MapOptions getMapOptions() const;
|
||||
|
||||
//Projection Mode
|
||||
// Projection Mode
|
||||
void setProjectionMode(const ProjectionMode&);
|
||||
ProjectionMode getProjectionMode() const;
|
||||
|
||||
@@ -127,10 +127,11 @@ public:
|
||||
|
||||
// Tile prefetching
|
||||
//
|
||||
/// When loading a map, if `PrefetchZoomDelta` is set to any number greater than 0, the map will
|
||||
/// first request a tile for `zoom - delta` in a attempt to display a full map at lower
|
||||
/// resolution as quick as possible. It will get clamped at the tile source minimum zoom. The
|
||||
/// default `delta` is 4.
|
||||
/// When loading a map, if `PrefetchZoomDelta` is set to any number greater
|
||||
/// than 0, the map will first request a tile for `zoom - delta` in a
|
||||
/// attempt to display a full map at lower resolution as quick as possible.
|
||||
/// It will get clamped at the tile source minimum zoom. The default `delta`
|
||||
/// is 4.
|
||||
void setPrefetchZoomDelta(uint8_t delta);
|
||||
uint8_t getPrefetchZoomDelta() const;
|
||||
|
||||
@@ -141,11 +142,13 @@ public:
|
||||
bool isFullyLoaded() const;
|
||||
void dumpDebugLogs() const;
|
||||
|
||||
/// FreeCameraOptions provides more direct access to the underlying camera entity.
|
||||
/// For backwards compatibility the state set using this API must be representable with
|
||||
/// `CameraOptions` as well. Parameters are clamped to a valid range or discarded as invalid
|
||||
/// if the conversion to the pitch and bearing presentation is ambiguous. For example orientation
|
||||
/// can be invalid if it leads to the camera being upside down or the quaternion has zero length.
|
||||
/// FreeCameraOptions provides more direct access to the underlying camera
|
||||
/// entity. For backwards compatibility the state set using this API must be
|
||||
/// representable with `CameraOptions` as well. Parameters are clamped to a
|
||||
/// valid range or discarded as invalid if the conversion to the pitch and
|
||||
/// bearing presentation is ambiguous. For example orientation can be
|
||||
/// invalid if it leads to the camera being upside down or the quaternion
|
||||
/// has zero length.
|
||||
void setFreeCameraOptions(const FreeCameraOptions& camera);
|
||||
FreeCameraOptions getFreeCameraOptions() const;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
virtual bool onCanRemoveUnusedStyleImage(const std::string&) { return true; }
|
||||
// Observe this event to easily mutate or observe shaders as soon
|
||||
// as the registry becomes available.
|
||||
virtual void onRegisterShaders(gfx::ShaderRegistry&) {};
|
||||
virtual void onRegisterShaders(gfx::ShaderRegistry&){};
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -138,4 +138,4 @@ private:
|
||||
std::unique_ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -15,8 +15,8 @@ using EnumType = uint32_t;
|
||||
|
||||
enum class MapMode : EnumType {
|
||||
Continuous, ///< continually updating map
|
||||
Static, ///< a once-off still image of an arbitrary viewport
|
||||
Tile ///< a once-off still image of a single tile
|
||||
Static, ///< a once-off still image of an arbitrary viewport
|
||||
Tile ///< a once-off still image of a single tile
|
||||
};
|
||||
|
||||
/// We can choose to constrain the map both horizontally or vertically, or only
|
||||
@@ -35,12 +35,12 @@ enum class ViewportMode : EnumType {
|
||||
};
|
||||
|
||||
enum class MapDebugOptions : EnumType {
|
||||
NoDebug = 0,
|
||||
NoDebug = 0,
|
||||
TileBorders = 1 << 1,
|
||||
ParseStatus = 1 << 2,
|
||||
Timestamps = 1 << 3,
|
||||
Collision = 1 << 4,
|
||||
Overdraw = 1 << 5,
|
||||
Timestamps = 1 << 3,
|
||||
Collision = 1 << 4,
|
||||
Overdraw = 1 << 5,
|
||||
StencilClip = 1 << 6,
|
||||
DepthBuffer = 1 << 7,
|
||||
};
|
||||
|
||||
@@ -10,9 +10,18 @@ namespace mbgl {
|
||||
* optional.
|
||||
*/
|
||||
struct ProjectionMode {
|
||||
ProjectionMode& withAxonometric(bool o) { axonometric = o; return *this; }
|
||||
ProjectionMode& withXSkew(double o) { xSkew = o; return *this; }
|
||||
ProjectionMode& withYSkew(double o) { ySkew = o; return *this; }
|
||||
ProjectionMode& withAxonometric(bool o) {
|
||||
axonometric = o;
|
||||
return *this;
|
||||
}
|
||||
ProjectionMode& withXSkew(double o) {
|
||||
xSkew = o;
|
||||
return *this;
|
||||
}
|
||||
ProjectionMode& withYSkew(double o) {
|
||||
ySkew = o;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set to True to enable axonometric rendering, false otherwise.
|
||||
@@ -30,4 +39,4 @@ struct ProjectionMode {
|
||||
std::optional<double> ySkew;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -30,8 +30,7 @@ T log2(T x) {
|
||||
} // namespace mbgl
|
||||
|
||||
// log2 is not available on Android before API 18.
|
||||
#if defined(__ANDROID__) && defined(__GNUC__) && \
|
||||
defined(__ANDROID_API__) && __ANDROID_API__ < 18
|
||||
#if defined(__ANDROID__) && defined(__GNUC__) && defined(__ANDROID_API__) && __ANDROID_API__ < 18
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if_t<std::is_floating_point_v<T>, T> log2(T x) {
|
||||
|
||||
@@ -7,7 +7,13 @@
|
||||
// initialized by the platform at linking time.
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define MBGL_CHECK_ERROR(cmd) ([&]() { struct __MBGL_CHECK_ERROR { ~__MBGL_CHECK_ERROR() noexcept(false) { mbgl::platform::glCheckError(#cmd, __FILE__, __LINE__); } } __MBGL_CHECK_ERROR; return cmd; }())
|
||||
#define MBGL_CHECK_ERROR(cmd) \
|
||||
([&]() { \
|
||||
struct __MBGL_CHECK_ERROR { \
|
||||
~__MBGL_CHECK_ERROR() noexcept(false) { mbgl::platform::glCheckError(#cmd, __FILE__, __LINE__); } \
|
||||
} __MBGL_CHECK_ERROR; \
|
||||
return cmd; \
|
||||
}())
|
||||
#else
|
||||
#define MBGL_CHECK_ERROR(cmd) (cmd)
|
||||
#endif
|
||||
@@ -30,7 +36,7 @@ using GLuint = unsigned int;
|
||||
using GLvoid = void;
|
||||
using GLint64 = int64_t;
|
||||
using GLuint64 = uint64_t;
|
||||
using GLsync = ::__GLsync *;
|
||||
using GLsync = ::__GLsync*;
|
||||
|
||||
#if defined(_WIN32)
|
||||
using GLintptr = long long;
|
||||
@@ -43,505 +49,510 @@ using GLsizeiptr = long;
|
||||
/* OpenGL ES 2.0 */
|
||||
|
||||
/// Pointer to glActiveTexture OpenGL function.
|
||||
extern void (* const glActiveTexture)(GLenum);
|
||||
extern void (*const glActiveTexture)(GLenum);
|
||||
/// Pointer to glAttachShader OpenGL function.
|
||||
extern void (* const glAttachShader)(GLuint, GLuint);
|
||||
extern void (*const glAttachShader)(GLuint, GLuint);
|
||||
/// Pointer to glBindAttribLocation OpenGL function.
|
||||
extern void (* const glBindAttribLocation)(GLuint, GLuint, const GLchar *);
|
||||
extern void (*const glBindAttribLocation)(GLuint, GLuint, const GLchar*);
|
||||
/// Pointer to glBindBuffer OpenGL function.
|
||||
extern void (* const glBindBuffer)(GLenum, GLuint);
|
||||
extern void (*const glBindBuffer)(GLenum, GLuint);
|
||||
/// Pointer to glBindFramebuffer OpenGL function.
|
||||
extern void (* const glBindFramebuffer)(GLenum, GLuint);
|
||||
extern void (*const glBindFramebuffer)(GLenum, GLuint);
|
||||
/// Pointer to glBindRenderbuffer OpenGL function.
|
||||
extern void (* const glBindRenderbuffer)(GLenum, GLuint);
|
||||
extern void (*const glBindRenderbuffer)(GLenum, GLuint);
|
||||
/// Pointer to glBindTexture OpenGL function.
|
||||
extern void (* const glBindTexture)(GLenum, GLuint);
|
||||
extern void (*const glBindTexture)(GLenum, GLuint);
|
||||
/// Pointer to glBlendColor OpenGL function.
|
||||
extern void (* const glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
extern void (*const glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
/// Pointer to glBlendEquation OpenGL function.
|
||||
extern void (* const glBlendEquation)(GLenum);
|
||||
extern void (*const glBlendEquation)(GLenum);
|
||||
/// Pointer to glBlendEquationSeparate OpenGL function.
|
||||
extern void (* const glBlendEquationSeparate)(GLenum, GLenum);
|
||||
extern void (*const glBlendEquationSeparate)(GLenum, GLenum);
|
||||
/// Pointer to glBlendFunc OpenGL function.
|
||||
extern void (* const glBlendFunc)(GLenum, GLenum);
|
||||
extern void (*const glBlendFunc)(GLenum, GLenum);
|
||||
/// Pointer to glBlendFuncSeparate OpenGL function.
|
||||
extern void (* const glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum);
|
||||
extern void (*const glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum);
|
||||
/// Pointer to glBufferData OpenGL function.
|
||||
extern void (* const glBufferData)(GLenum, GLsizeiptr, const void *, GLenum);
|
||||
extern void (*const glBufferData)(GLenum, GLsizeiptr, const void*, GLenum);
|
||||
/// Pointer to glBufferSubData OpenGL function.
|
||||
extern void (* const glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const void *);
|
||||
extern void (*const glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const void*);
|
||||
/// Pointer to glCheckFramebufferStatus OpenGL function.
|
||||
extern GLenum (* const glCheckFramebufferStatus)(GLenum);
|
||||
extern GLenum (*const glCheckFramebufferStatus)(GLenum);
|
||||
/// Pointer to glClear OpenGL function.
|
||||
extern void (* const glClear)(GLbitfield);
|
||||
extern void (*const glClear)(GLbitfield);
|
||||
/// Pointer to glClearColor OpenGL function.
|
||||
extern void (* const glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
extern void (*const glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
/// Pointer to glClearDepthf OpenGL function.
|
||||
extern void (* const glClearDepthf)(GLfloat);
|
||||
extern void (*const glClearDepthf)(GLfloat);
|
||||
/// Pointer to glClearStencil OpenGL function.
|
||||
extern void (* const glClearStencil)(GLint);
|
||||
extern void (*const glClearStencil)(GLint);
|
||||
/// Pointer to glColorMask OpenGL function.
|
||||
extern void (* const glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean);
|
||||
extern void (*const glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean);
|
||||
/// Pointer to glCompileShader OpenGL function.
|
||||
extern void (* const glCompileShader)(GLuint);
|
||||
extern void (*const glCompileShader)(GLuint);
|
||||
/// Pointer to glCompressedTexImage2D OpenGL function.
|
||||
extern void (* const glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const void *);
|
||||
extern void (*const glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const void*);
|
||||
/// Pointer to glCompressedTexSubImage2D OpenGL function.
|
||||
extern void (* const glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void *);
|
||||
extern void (*const glCompressedTexSubImage2D)(
|
||||
GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void*);
|
||||
/// Pointer to glCopyTexImage2D OpenGL function.
|
||||
extern void (* const glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
|
||||
extern void (*const glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
|
||||
/// Pointer to glCopyTexSubImage2D OpenGL function.
|
||||
extern void (* const glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
|
||||
extern void (*const glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
|
||||
/// Pointer to glCreateProgram OpenGL function.
|
||||
extern GLuint (* const glCreateProgram)();
|
||||
extern GLuint (*const glCreateProgram)();
|
||||
/// Pointer to glCreateShader OpenGL function.
|
||||
extern GLuint (* const glCreateShader)(GLenum);
|
||||
extern GLuint (*const glCreateShader)(GLenum);
|
||||
/// Pointer to glCullFace OpenGL function.
|
||||
extern void (* const glCullFace)(GLenum);
|
||||
extern void (*const glCullFace)(GLenum);
|
||||
/// Pointer to glDeleteBuffers OpenGL function.
|
||||
extern void (* const glDeleteBuffers)(GLsizei, const GLuint *);
|
||||
extern void (*const glDeleteBuffers)(GLsizei, const GLuint*);
|
||||
/// Pointer to glDeleteFramebuffers OpenGL function.
|
||||
extern void (* const glDeleteFramebuffers)(GLsizei, const GLuint *);
|
||||
extern void (*const glDeleteFramebuffers)(GLsizei, const GLuint*);
|
||||
/// Pointer to glDeleteProgram OpenGL function.
|
||||
extern void (* const glDeleteProgram)(GLuint);
|
||||
extern void (*const glDeleteProgram)(GLuint);
|
||||
/// Pointer to glDeleteRenderbuffers OpenGL function.
|
||||
extern void (* const glDeleteRenderbuffers)(GLsizei, const GLuint *);
|
||||
extern void (*const glDeleteRenderbuffers)(GLsizei, const GLuint*);
|
||||
/// Pointer to glDeleteShader OpenGL function.
|
||||
extern void (* const glDeleteShader)(GLuint);
|
||||
extern void (*const glDeleteShader)(GLuint);
|
||||
/// Pointer to glDeleteTextures OpenGL function.
|
||||
extern void (* const glDeleteTextures)(GLsizei, const GLuint *);
|
||||
extern void (*const glDeleteTextures)(GLsizei, const GLuint*);
|
||||
/// Pointer to glDepthFunc OpenGL function.
|
||||
extern void (* const glDepthFunc)(GLenum);
|
||||
extern void (*const glDepthFunc)(GLenum);
|
||||
/// Pointer to glDepthMask OpenGL function.
|
||||
extern void (* const glDepthMask)(GLboolean);
|
||||
extern void (*const glDepthMask)(GLboolean);
|
||||
/// Pointer to glDepthRangef OpenGL function.
|
||||
extern void (* const glDepthRangef)(GLfloat, GLfloat);
|
||||
extern void (*const glDepthRangef)(GLfloat, GLfloat);
|
||||
/// Pointer to glDetachShader OpenGL function.
|
||||
extern void (* const glDetachShader)(GLuint, GLuint);
|
||||
extern void (*const glDetachShader)(GLuint, GLuint);
|
||||
/// Pointer to glDisable OpenGL function.
|
||||
extern void (* const glDisable)(GLenum);
|
||||
extern void (*const glDisable)(GLenum);
|
||||
/// Pointer to glDisableVertexAttribArray OpenGL function.
|
||||
extern void (* const glDisableVertexAttribArray)(GLuint);
|
||||
extern void (*const glDisableVertexAttribArray)(GLuint);
|
||||
/// Pointer to glDrawArrays OpenGL function.
|
||||
extern void (* const glDrawArrays)(GLenum, GLint, GLsizei);
|
||||
extern void (*const glDrawArrays)(GLenum, GLint, GLsizei);
|
||||
/// Pointer to glDrawElements OpenGL function.
|
||||
extern void (* const glDrawElements)(GLenum, GLsizei, GLenum, const void *);
|
||||
extern void (*const glDrawElements)(GLenum, GLsizei, GLenum, const void*);
|
||||
/// Pointer to glEnable OpenGL function.
|
||||
extern void (* const glEnable)(GLenum);
|
||||
extern void (*const glEnable)(GLenum);
|
||||
/// Pointer to glEnableVertexAttribArray OpenGL function.
|
||||
extern void (* const glEnableVertexAttribArray)(GLuint);
|
||||
extern void (*const glEnableVertexAttribArray)(GLuint);
|
||||
/// Pointer to glFinish OpenGL function.
|
||||
extern void (* const glFinish)();
|
||||
extern void (*const glFinish)();
|
||||
/// Pointer to glFlush OpenGL function.
|
||||
extern void (* const glFlush)();
|
||||
extern void (*const glFlush)();
|
||||
/// Pointer to glFramebufferRenderbuffer OpenGL function.
|
||||
extern void (* const glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint);
|
||||
extern void (*const glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint);
|
||||
/// Pointer to glFramebufferTexture2D OpenGL function.
|
||||
extern void (* const glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint);
|
||||
extern void (*const glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint);
|
||||
/// Pointer to glFrontFace OpenGL function.
|
||||
extern void (* const glFrontFace)(GLenum);
|
||||
extern void (*const glFrontFace)(GLenum);
|
||||
/// Pointer to glGenBuffers OpenGL function.
|
||||
extern void (* const glGenBuffers)(GLsizei, GLuint *);
|
||||
extern void (*const glGenBuffers)(GLsizei, GLuint*);
|
||||
/// Pointer to glGenerateMipmap OpenGL function.
|
||||
extern void (* const glGenerateMipmap)(GLenum);
|
||||
extern void (*const glGenerateMipmap)(GLenum);
|
||||
/// Pointer to glGenFramebuffers OpenGL function.
|
||||
extern void (* const glGenFramebuffers)(GLsizei, GLuint *);
|
||||
extern void (*const glGenFramebuffers)(GLsizei, GLuint*);
|
||||
/// Pointer to glGenRenderbuffers OpenGL function.
|
||||
extern void (* const glGenRenderbuffers)(GLsizei, GLuint *);
|
||||
extern void (*const glGenRenderbuffers)(GLsizei, GLuint*);
|
||||
/// Pointer to glGenTextures OpenGL function.
|
||||
extern void (* const glGenTextures)(GLsizei, GLuint *);
|
||||
extern void (*const glGenTextures)(GLsizei, GLuint*);
|
||||
/// Pointer to glGetActiveAttrib OpenGL function.
|
||||
extern void (* const glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
|
||||
extern void (*const glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*);
|
||||
/// Pointer to glGetActiveUniform OpenGL function.
|
||||
extern void (* const glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
|
||||
extern void (*const glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*);
|
||||
/// Pointer to glGetAttachedShaders OpenGL function.
|
||||
extern void (* const glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *);
|
||||
extern void (*const glGetAttachedShaders)(GLuint, GLsizei, GLsizei*, GLuint*);
|
||||
/// Pointer to glGetAttribLocation OpenGL function.
|
||||
extern GLint (* const glGetAttribLocation)(GLuint, const GLchar *);
|
||||
extern GLint (*const glGetAttribLocation)(GLuint, const GLchar*);
|
||||
/// Pointer to glGetBooleanv OpenGL function.
|
||||
extern void (* const glGetBooleanv)(GLenum, GLboolean *);
|
||||
extern void (*const glGetBooleanv)(GLenum, GLboolean*);
|
||||
/// Pointer to glGetBufferParameteriv OpenGL function.
|
||||
extern void (* const glGetBufferParameteriv)(GLenum, GLenum, GLint *);
|
||||
extern void (*const glGetBufferParameteriv)(GLenum, GLenum, GLint*);
|
||||
/// Pointer to glGetError OpenGL function.
|
||||
extern GLenum (* const glGetError)();
|
||||
extern GLenum (*const glGetError)();
|
||||
/// Pointer to glGetFloatv OpenGL function.
|
||||
extern void (* const glGetFloatv)(GLenum, GLfloat *);
|
||||
extern void (*const glGetFloatv)(GLenum, GLfloat*);
|
||||
/// Pointer to glGetFramebufferAttachmentParameteriv OpenGL function.
|
||||
extern void (* const glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *);
|
||||
extern void (*const glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint*);
|
||||
/// Pointer to glGetIntegerv OpenGL function.
|
||||
extern void (* const glGetIntegerv)(GLenum, GLint *);
|
||||
extern void (*const glGetIntegerv)(GLenum, GLint*);
|
||||
/// Pointer to glGetProgramInfoLog OpenGL function.
|
||||
extern void (* const glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);
|
||||
extern void (*const glGetProgramInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*);
|
||||
/// Pointer to glGetProgramiv OpenGL function.
|
||||
extern void (* const glGetProgramiv)(GLuint, GLenum, GLint *);
|
||||
extern void (*const glGetProgramiv)(GLuint, GLenum, GLint*);
|
||||
/// Pointer to glGetRenderbufferParameteriv OpenGL function.
|
||||
extern void (* const glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *);
|
||||
extern void (*const glGetRenderbufferParameteriv)(GLenum, GLenum, GLint*);
|
||||
/// Pointer to glGetShaderInfoLog OpenGL function.
|
||||
extern void (* const glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);
|
||||
extern void (*const glGetShaderInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*);
|
||||
/// Pointer to glGetShaderiv OpenGL function.
|
||||
extern void (* const glGetShaderiv)(GLuint, GLenum, GLint *);
|
||||
extern void (*const glGetShaderiv)(GLuint, GLenum, GLint*);
|
||||
/// Pointer to glGetShaderPrecisionFormat OpenGL function.
|
||||
extern void (* const glGetShaderPrecisionFormat)(GLenum, GLenum, GLint *, GLint *);
|
||||
extern void (*const glGetShaderPrecisionFormat)(GLenum, GLenum, GLint*, GLint*);
|
||||
/// Pointer to glGetShaderSource OpenGL function.
|
||||
extern void (* const glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *);
|
||||
extern void (*const glGetShaderSource)(GLuint, GLsizei, GLsizei*, GLchar*);
|
||||
/// Pointer to glGetString OpenGL function.
|
||||
extern const GLubyte *(* const glGetString)(GLenum);
|
||||
extern const GLubyte* (*const glGetString)(GLenum);
|
||||
/// Pointer to glGetTexParameterfv OpenGL function.
|
||||
extern void (* const glGetTexParameterfv)(GLenum, GLenum, GLfloat *);
|
||||
extern void (*const glGetTexParameterfv)(GLenum, GLenum, GLfloat*);
|
||||
/// Pointer to glGetTexParameteriv OpenGL function.
|
||||
extern void (* const glGetTexParameteriv)(GLenum, GLenum, GLint *);
|
||||
extern void (*const glGetTexParameteriv)(GLenum, GLenum, GLint*);
|
||||
/// Pointer to glGetUniformfv OpenGL function.
|
||||
extern void (* const glGetUniformfv)(GLuint, GLint, GLfloat *);
|
||||
extern void (*const glGetUniformfv)(GLuint, GLint, GLfloat*);
|
||||
/// Pointer to glGetUniformiv OpenGL function.
|
||||
extern void (* const glGetUniformiv)(GLuint, GLint, GLint *);
|
||||
extern void (*const glGetUniformiv)(GLuint, GLint, GLint*);
|
||||
/// Pointer to glGetUniformLocation OpenGL function.
|
||||
extern GLint (* const glGetUniformLocation)(GLuint, const GLchar *);
|
||||
extern GLint (*const glGetUniformLocation)(GLuint, const GLchar*);
|
||||
/// Pointer to glGetVertexAttribfv OpenGL function.
|
||||
extern void (* const glGetVertexAttribfv)(GLuint, GLenum, GLfloat *);
|
||||
extern void (*const glGetVertexAttribfv)(GLuint, GLenum, GLfloat*);
|
||||
/// Pointer to glGetVertexAttribiv OpenGL function.
|
||||
extern void (* const glGetVertexAttribiv)(GLuint, GLenum, GLint *);
|
||||
extern void (*const glGetVertexAttribiv)(GLuint, GLenum, GLint*);
|
||||
/// Pointer to glGetVertexAttribPointerv OpenGL function.
|
||||
extern void (* const glGetVertexAttribPointerv)(GLuint, GLenum, void **);
|
||||
extern void (*const glGetVertexAttribPointerv)(GLuint, GLenum, void**);
|
||||
/// Pointer to glHint OpenGL function.
|
||||
extern void (* const glHint)(GLenum, GLenum);
|
||||
extern void (*const glHint)(GLenum, GLenum);
|
||||
/// Pointer to glIsBuffer OpenGL function.
|
||||
extern GLboolean (* const glIsBuffer)(GLuint);
|
||||
extern GLboolean (*const glIsBuffer)(GLuint);
|
||||
/// Pointer to glIsEnabled OpenGL function.
|
||||
extern GLboolean (* const glIsEnabled)(GLenum);
|
||||
extern GLboolean (*const glIsEnabled)(GLenum);
|
||||
/// Pointer to glIsFramebuffer OpenGL function.
|
||||
extern GLboolean (* const glIsFramebuffer)(GLuint);
|
||||
extern GLboolean (*const glIsFramebuffer)(GLuint);
|
||||
/// Pointer to glIsProgram OpenGL function.
|
||||
extern GLboolean (* const glIsProgram)(GLuint);
|
||||
extern GLboolean (*const glIsProgram)(GLuint);
|
||||
/// Pointer to glIsRenderbuffer OpenGL function.
|
||||
extern GLboolean (* const glIsRenderbuffer)(GLuint);
|
||||
extern GLboolean (*const glIsRenderbuffer)(GLuint);
|
||||
/// Pointer to glIsShader OpenGL function.
|
||||
extern GLboolean (* const glIsShader)(GLuint);
|
||||
extern GLboolean (*const glIsShader)(GLuint);
|
||||
/// Pointer to glIsTexture OpenGL function.
|
||||
extern GLboolean (* const glIsTexture)(GLuint);
|
||||
extern GLboolean (*const glIsTexture)(GLuint);
|
||||
/// Pointer to glLineWidth OpenGL function.
|
||||
extern void (* const glLineWidth)(GLfloat);
|
||||
extern void (*const glLineWidth)(GLfloat);
|
||||
/// Pointer to glLinkProgram OpenGL function.
|
||||
extern void (* const glLinkProgram)(GLuint);
|
||||
extern void (*const glLinkProgram)(GLuint);
|
||||
/// Pointer to glPixelStorei OpenGL function.
|
||||
extern void (* const glPixelStorei)(GLenum, GLint);
|
||||
extern void (*const glPixelStorei)(GLenum, GLint);
|
||||
/// Pointer to glPolygonOffset OpenGL function.
|
||||
extern void (* const glPolygonOffset)(GLfloat, GLfloat);
|
||||
extern void (*const glPolygonOffset)(GLfloat, GLfloat);
|
||||
/// Pointer to glReadPixels OpenGL function.
|
||||
extern void (* const glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void *);
|
||||
extern void (*const glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void*);
|
||||
/// Pointer to glReleaseShaderCompiler OpenGL function.
|
||||
extern void (* const glReleaseShaderCompiler)();
|
||||
extern void (*const glReleaseShaderCompiler)();
|
||||
/// Pointer to glRenderbufferStorage OpenGL function.
|
||||
extern void (* const glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei);
|
||||
extern void (*const glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei);
|
||||
/// Pointer to glSampleCoverage OpenGL function.
|
||||
extern void (* const glSampleCoverage)(GLfloat, GLboolean);
|
||||
extern void (*const glSampleCoverage)(GLfloat, GLboolean);
|
||||
/// Pointer to glScissor OpenGL function.
|
||||
extern void (* const glScissor)(GLint, GLint, GLsizei, GLsizei);
|
||||
extern void (*const glScissor)(GLint, GLint, GLsizei, GLsizei);
|
||||
/// Pointer to glShaderBinary OpenGL function.
|
||||
extern void (* const glShaderBinary)(GLsizei, const GLuint *, GLenum, const GLvoid *, GLsizei);
|
||||
extern void (*const glShaderBinary)(GLsizei, const GLuint*, GLenum, const GLvoid*, GLsizei);
|
||||
/// Pointer to glShaderSource OpenGL function.
|
||||
extern void (* const glShaderSource)(GLuint, GLsizei, const GLchar * const*, const GLint *);
|
||||
extern void (*const glShaderSource)(GLuint, GLsizei, const GLchar* const*, const GLint*);
|
||||
/// Pointer to glStencilFunc OpenGL function.
|
||||
extern void (* const glStencilFunc)(GLenum, GLint, GLuint);
|
||||
extern void (*const glStencilFunc)(GLenum, GLint, GLuint);
|
||||
/// Pointer to glStencilFuncSeparate OpenGL function.
|
||||
extern void (* const glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint);
|
||||
extern void (*const glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint);
|
||||
/// Pointer to glStencilMask OpenGL function.
|
||||
extern void (* const glStencilMask)(GLuint);
|
||||
extern void (*const glStencilMask)(GLuint);
|
||||
/// Pointer to glStencilMaskSeparate OpenGL function.
|
||||
extern void (* const glStencilMaskSeparate)(GLenum, GLuint);
|
||||
extern void (*const glStencilMaskSeparate)(GLenum, GLuint);
|
||||
/// Pointer to glStencilOp OpenGL function.
|
||||
extern void (* const glStencilOp)(GLenum, GLenum, GLenum);
|
||||
extern void (*const glStencilOp)(GLenum, GLenum, GLenum);
|
||||
/// Pointer to glStencilOpSeparate OpenGL function.
|
||||
extern void (* const glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum);
|
||||
extern void (*const glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum);
|
||||
/// Pointer to glTexImage2D OpenGL function.
|
||||
extern void (* const glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *);
|
||||
extern void (*const glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void*);
|
||||
/// Pointer to glTexParameterf OpenGL function.
|
||||
extern void (* const glTexParameterf)(GLenum, GLenum, GLfloat);
|
||||
extern void (*const glTexParameterf)(GLenum, GLenum, GLfloat);
|
||||
/// Pointer to glTexParameterfv OpenGL function.
|
||||
extern void (* const glTexParameterfv)(GLenum, GLenum, const GLfloat *);
|
||||
extern void (*const glTexParameterfv)(GLenum, GLenum, const GLfloat*);
|
||||
/// Pointer to glTexParameteri OpenGL function.
|
||||
extern void (* const glTexParameteri)(GLenum, GLenum, GLint);
|
||||
extern void (*const glTexParameteri)(GLenum, GLenum, GLint);
|
||||
/// Pointer to glTexParameteriv OpenGL function.
|
||||
extern void (* const glTexParameteriv)(GLenum, GLenum, const GLint *);
|
||||
extern void (*const glTexParameteriv)(GLenum, GLenum, const GLint*);
|
||||
/// Pointer to glTexSubImage2D OpenGL function.
|
||||
extern void (* const glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void *);
|
||||
extern void (*const glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void*);
|
||||
/// Pointer to glUniform1f OpenGL function.
|
||||
extern void (* const glUniform1f)(GLint, GLfloat);
|
||||
extern void (*const glUniform1f)(GLint, GLfloat);
|
||||
/// Pointer to glUniform1fv OpenGL function.
|
||||
extern void (* const glUniform1fv)(GLint, GLsizei, const GLfloat *);
|
||||
extern void (*const glUniform1fv)(GLint, GLsizei, const GLfloat*);
|
||||
/// Pointer to glUniform1i OpenGL function.
|
||||
extern void (* const glUniform1i)(GLint, GLint);
|
||||
extern void (*const glUniform1i)(GLint, GLint);
|
||||
/// Pointer to glUniform1iv OpenGL function.
|
||||
extern void (* const glUniform1iv)(GLint, GLsizei, const GLint *);
|
||||
extern void (*const glUniform1iv)(GLint, GLsizei, const GLint*);
|
||||
/// Pointer to glUniform2f OpenGL function.
|
||||
extern void (* const glUniform2f)(GLint, GLfloat, GLfloat);
|
||||
extern void (*const glUniform2f)(GLint, GLfloat, GLfloat);
|
||||
/// Pointer to glUniform2fv OpenGL function.
|
||||
extern void (* const glUniform2fv)(GLint, GLsizei, const GLfloat *);
|
||||
extern void (*const glUniform2fv)(GLint, GLsizei, const GLfloat*);
|
||||
/// Pointer to glUniform2i OpenGL function.
|
||||
extern void (* const glUniform2i)(GLint, GLint, GLint);
|
||||
extern void (*const glUniform2i)(GLint, GLint, GLint);
|
||||
/// Pointer to glUniform2iv OpenGL function.
|
||||
extern void (* const glUniform2iv)(GLint, GLsizei, const GLint *);
|
||||
extern void (*const glUniform2iv)(GLint, GLsizei, const GLint*);
|
||||
/// Pointer to glUniform3f OpenGL function.
|
||||
extern void (* const glUniform3f)(GLint, GLfloat, GLfloat, GLfloat);
|
||||
extern void (*const glUniform3f)(GLint, GLfloat, GLfloat, GLfloat);
|
||||
/// Pointer to glUniform3fv OpenGL function.
|
||||
extern void (* const glUniform3fv)(GLint, GLsizei, const GLfloat *);
|
||||
extern void (*const glUniform3fv)(GLint, GLsizei, const GLfloat*);
|
||||
/// Pointer to glUniform3i OpenGL function.
|
||||
extern void (* const glUniform3i)(GLint, GLint, GLint, GLint);
|
||||
extern void (*const glUniform3i)(GLint, GLint, GLint, GLint);
|
||||
/// Pointer to glUniform3iv OpenGL function.
|
||||
extern void (* const glUniform3iv)(GLint, GLsizei, const GLint *);
|
||||
extern void (*const glUniform3iv)(GLint, GLsizei, const GLint*);
|
||||
/// Pointer to glUniform4f OpenGL function.
|
||||
extern void (* const glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
extern void (*const glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
/// Pointer to glUniform4fv OpenGL function.
|
||||
extern void (* const glUniform4fv)(GLint, GLsizei, const GLfloat *);
|
||||
extern void (*const glUniform4fv)(GLint, GLsizei, const GLfloat*);
|
||||
/// Pointer to glUniform4i OpenGL function.
|
||||
extern void (* const glUniform4i)(GLint, GLint, GLint, GLint, GLint);
|
||||
extern void (*const glUniform4i)(GLint, GLint, GLint, GLint, GLint);
|
||||
/// Pointer to glUniform4iv OpenGL function.
|
||||
extern void (* const glUniform4iv)(GLint, GLsizei, const GLint *);
|
||||
extern void (*const glUniform4iv)(GLint, GLsizei, const GLint*);
|
||||
/// Pointer to glUniformMatrix2fv OpenGL function.
|
||||
extern void (* const glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *);
|
||||
extern void (*const glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat*);
|
||||
/// Pointer to glUniformMatrix3fv OpenGL function.
|
||||
extern void (* const glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *);
|
||||
extern void (*const glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat*);
|
||||
/// Pointer to glUniformMatrix4fv OpenGL function.
|
||||
extern void (* const glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *);
|
||||
extern void (*const glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat*);
|
||||
/// Pointer to glUseProgram OpenGL function.
|
||||
extern void (* const glUseProgram)(GLuint);
|
||||
extern void (*const glUseProgram)(GLuint);
|
||||
/// Pointer to glValidateProgram OpenGL function.
|
||||
extern void (* const glValidateProgram)(GLuint);
|
||||
extern void (*const glValidateProgram)(GLuint);
|
||||
/// Pointer to glVertexAttrib1f OpenGL function.
|
||||
extern void (* const glVertexAttrib1f)(GLuint, GLfloat);
|
||||
extern void (*const glVertexAttrib1f)(GLuint, GLfloat);
|
||||
/// Pointer to glVertexAttrib1fv OpenGL function.
|
||||
extern void (* const glVertexAttrib1fv)(GLuint, const GLfloat *);
|
||||
extern void (*const glVertexAttrib1fv)(GLuint, const GLfloat*);
|
||||
/// Pointer to glVertexAttrib2f OpenGL function.
|
||||
extern void (* const glVertexAttrib2f)(GLuint, GLfloat, GLfloat);
|
||||
extern void (*const glVertexAttrib2f)(GLuint, GLfloat, GLfloat);
|
||||
/// Pointer to glVertexAttrib2fv OpenGL function.
|
||||
extern void (* const glVertexAttrib2fv)(GLuint, const GLfloat *);
|
||||
extern void (*const glVertexAttrib2fv)(GLuint, const GLfloat*);
|
||||
/// Pointer to glVertexAttrib3f OpenGL function.
|
||||
extern void (* const glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat);
|
||||
extern void (*const glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat);
|
||||
/// Pointer to glVertexAttrib3fv OpenGL function.
|
||||
extern void (* const glVertexAttrib3fv)(GLuint, const GLfloat *);
|
||||
extern void (*const glVertexAttrib3fv)(GLuint, const GLfloat*);
|
||||
/// Pointer to glVertexAttrib4f OpenGL function.
|
||||
extern void (* const glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
extern void (*const glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
/// Pointer to glVertexAttrib4fv OpenGL function.
|
||||
extern void (* const glVertexAttrib4fv)(GLuint, const GLfloat *);
|
||||
extern void (*const glVertexAttrib4fv)(GLuint, const GLfloat*);
|
||||
/// Pointer to glVertexAttribPointer OpenGL function.
|
||||
extern void (* const glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void *);
|
||||
extern void (*const glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void*);
|
||||
/// Pointer to glViewport OpenGL function.
|
||||
extern void (* const glViewport)(GLint, GLint, GLsizei, GLsizei);
|
||||
extern void (*const glViewport)(GLint, GLint, GLsizei, GLsizei);
|
||||
|
||||
/* OpenGL ES 3.0 */
|
||||
|
||||
/// Pointer to glReadBuffer OpenGL function.
|
||||
extern void (* const glReadBuffer)(GLenum);
|
||||
extern void (*const glReadBuffer)(GLenum);
|
||||
/// Pointer to glDrawRangeElements OpenGL function.
|
||||
extern void (* const glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
|
||||
extern void (*const glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid*);
|
||||
/// Pointer to glTexImage3D OpenGL function.
|
||||
extern void (* const glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
|
||||
extern void (*const glTexImage3D)(
|
||||
GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*);
|
||||
/// Pointer to glTexSubImage3D OpenGL function.
|
||||
extern void (* const glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
|
||||
extern void (*const glTexSubImage3D)(
|
||||
GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*);
|
||||
/// Pointer to glCopyTexSubImage3D OpenGL function.
|
||||
extern void (* const glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
|
||||
extern void (*const glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
|
||||
/// Pointer to glCompressedTexImage3D OpenGL function.
|
||||
extern void (* const glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
|
||||
extern void (*const glCompressedTexImage3D)(
|
||||
GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*);
|
||||
/// Pointer to glCompressedTexSubImage3D OpenGL function.
|
||||
extern void (* const glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
|
||||
extern void (*const glCompressedTexSubImage3D)(
|
||||
GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*);
|
||||
/// Pointer to glGenQueries OpenGL function.
|
||||
extern void (* const glGenQueries)(GLsizei, GLuint *);
|
||||
extern void (*const glGenQueries)(GLsizei, GLuint*);
|
||||
/// Pointer to glDeleteQueries OpenGL function.
|
||||
extern void (* const glDeleteQueries)(GLsizei, const GLuint *);
|
||||
extern void (*const glDeleteQueries)(GLsizei, const GLuint*);
|
||||
/// Pointer to glIsQuery OpenGL function.
|
||||
extern GLboolean (* const glIsQuery)(GLuint);
|
||||
extern GLboolean (*const glIsQuery)(GLuint);
|
||||
/// Pointer to glBeginQuery OpenGL function.
|
||||
extern void (* const glBeginQuery)(GLenum, GLuint);
|
||||
extern void (*const glBeginQuery)(GLenum, GLuint);
|
||||
/// Pointer to glEndQuery OpenGL function.
|
||||
extern void (* const glEndQuery)(GLenum);
|
||||
extern void (*const glEndQuery)(GLenum);
|
||||
/// Pointer to glGetQueryiv OpenGL function.
|
||||
extern void (* const glGetQueryiv)(GLenum, GLenum, GLint *);
|
||||
extern void (*const glGetQueryiv)(GLenum, GLenum, GLint*);
|
||||
/// Pointer to glGetQueryObjectuiv OpenGL function.
|
||||
extern void (* const glGetQueryObjectuiv)(GLuint, GLenum, GLuint *);
|
||||
extern void (*const glGetQueryObjectuiv)(GLuint, GLenum, GLuint*);
|
||||
/// Pointer to glUnmapBuffer OpenGL function.
|
||||
extern GLboolean (* const glUnmapBuffer)(GLenum);
|
||||
extern GLboolean (*const glUnmapBuffer)(GLenum);
|
||||
/// Pointer to glGetBufferPointerv OpenGL function.
|
||||
extern void (* const glGetBufferPointerv)(GLenum, GLenum, GLvoid **);
|
||||
extern void (*const glGetBufferPointerv)(GLenum, GLenum, GLvoid**);
|
||||
/// Pointer to glDrawBuffers OpenGL function.
|
||||
extern void (* const glDrawBuffers)(GLsizei, const GLenum *);
|
||||
extern void (*const glDrawBuffers)(GLsizei, const GLenum*);
|
||||
/// Pointer to glUniformMatrix2x3fv OpenGL function.
|
||||
extern void (* const glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *);
|
||||
extern void (*const glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat*);
|
||||
/// Pointer to glUniformMatrix3x2fv OpenGL function.
|
||||
extern void (* const glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *);
|
||||
extern void (*const glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat*);
|
||||
/// Pointer to glUniformMatrix2x4fv OpenGL function.
|
||||
extern void (* const glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *);
|
||||
extern void (*const glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat*);
|
||||
/// Pointer to glUniformMatrix4x2fv OpenGL function.
|
||||
extern void (* const glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *);
|
||||
extern void (*const glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat*);
|
||||
/// Pointer to glUniformMatrix3x4fv OpenGL function.
|
||||
extern void (* const glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *);
|
||||
extern void (*const glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat*);
|
||||
/// Pointer to glUniformMatrix4x3fv OpenGL function.
|
||||
extern void (* const glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *);
|
||||
extern void (*const glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat*);
|
||||
/// Pointer to glBlitFramebuffer OpenGL function.
|
||||
extern void (* const glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
|
||||
extern void (*const glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
|
||||
/// Pointer to glRenderbufferStorageMultisample OpenGL function.
|
||||
extern void (* const glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei);
|
||||
extern void (*const glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei);
|
||||
/// Pointer to glFramebufferTextureLayer OpenGL function.
|
||||
extern void (* const glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint);
|
||||
extern void (*const glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint);
|
||||
/// Pointer to glMapBufferRange OpenGL function.
|
||||
extern GLvoid* (* const glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield);
|
||||
extern GLvoid* (*const glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield);
|
||||
/// Pointer to glMapBufferRange OpenGL function.
|
||||
extern void (* const glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr);
|
||||
extern void (*const glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr);
|
||||
/// Pointer to glBindVertexArray OpenGL function.
|
||||
extern void (* const glBindVertexArray)(GLuint);
|
||||
extern void (*const glBindVertexArray)(GLuint);
|
||||
/// Pointer to glDeleteVertexArrays OpenGL function.
|
||||
extern void (* const glDeleteVertexArrays)(GLsizei, const GLuint *);
|
||||
extern void (*const glDeleteVertexArrays)(GLsizei, const GLuint*);
|
||||
/// Pointer to glGenVertexArrays OpenGL function.
|
||||
extern void (* const glGenVertexArrays)(GLsizei, GLuint *);
|
||||
extern void (*const glGenVertexArrays)(GLsizei, GLuint*);
|
||||
/// Pointer to glIsVertexArray OpenGL function.
|
||||
extern GLboolean (* const glIsVertexArray)(GLuint);
|
||||
extern GLboolean (*const glIsVertexArray)(GLuint);
|
||||
/// Pointer to glGetIntegeri_v OpenGL function.
|
||||
extern void (* const glGetIntegeri_v)(GLenum, GLuint, GLint *);
|
||||
extern void (*const glGetIntegeri_v)(GLenum, GLuint, GLint*);
|
||||
/// Pointer to glBeginTransformFeedback OpenGL function.
|
||||
extern void (* const glBeginTransformFeedback)(GLenum);
|
||||
extern void (*const glBeginTransformFeedback)(GLenum);
|
||||
/// Pointer to glEndTransformFeedback OpenGL function.
|
||||
extern void (* const glEndTransformFeedback)();
|
||||
extern void (*const glEndTransformFeedback)();
|
||||
/// Pointer to glBindBufferRange OpenGL function.
|
||||
extern void (* const glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr);
|
||||
extern void (*const glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr);
|
||||
/// Pointer to glBindBufferBase OpenGL function.
|
||||
extern void (* const glBindBufferBase)(GLenum, GLuint, GLuint);
|
||||
extern void (*const glBindBufferBase)(GLenum, GLuint, GLuint);
|
||||
/// Pointer to glTransformFeedbackVaryings OpenGL function.
|
||||
extern void (* const glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar * const*, GLenum);
|
||||
extern void (*const glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar* const*, GLenum);
|
||||
/// Pointer to glGetTransformFeedbackVarying OpenGL function.
|
||||
extern void (* const glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *);
|
||||
extern void (*const glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei*, GLsizei*, GLenum*, GLchar*);
|
||||
/// Pointer to glVertexAttribIPointer OpenGL function.
|
||||
extern void (* const glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *);
|
||||
extern void (*const glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid*);
|
||||
/// Pointer to glGetVertexAttribIiv OpenGL function.
|
||||
extern void (* const glGetVertexAttribIiv)(GLuint, GLenum, GLint *);
|
||||
extern void (*const glGetVertexAttribIiv)(GLuint, GLenum, GLint*);
|
||||
/// Pointer to glGetVertexAttribIiv OpenGL function.
|
||||
extern void (* const glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *);
|
||||
extern void (*const glGetVertexAttribIuiv)(GLuint, GLenum, GLuint*);
|
||||
/// Pointer to glVertexAttribI4i OpenGL function.
|
||||
extern void (* const glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint);
|
||||
extern void (*const glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint);
|
||||
/// Pointer to glVertexAttribI4ui OpenGL function.
|
||||
extern void (* const glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint);
|
||||
extern void (*const glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint);
|
||||
/// Pointer to glVertexAttribI4iv OpenGL function.
|
||||
extern void (* const glVertexAttribI4iv)(GLuint, const GLint *);
|
||||
extern void (*const glVertexAttribI4iv)(GLuint, const GLint*);
|
||||
/// Pointer to glVertexAttribI4uiv OpenGL function.
|
||||
extern void (* const glVertexAttribI4uiv)(GLuint, const GLuint *);
|
||||
extern void (*const glVertexAttribI4uiv)(GLuint, const GLuint*);
|
||||
/// Pointer to glGetUniformuiv OpenGL function.
|
||||
extern void (* const glGetUniformuiv)(GLuint, GLint, GLuint *);
|
||||
extern void (*const glGetUniformuiv)(GLuint, GLint, GLuint*);
|
||||
/// Pointer to glGetFragDataLocation OpenGL function.
|
||||
extern GLint (* const glGetFragDataLocation)(GLuint, const GLchar *);
|
||||
extern GLint (*const glGetFragDataLocation)(GLuint, const GLchar*);
|
||||
/// Pointer to glUniform1ui OpenGL function.
|
||||
extern void (* const glUniform1ui)(GLint, GLuint);
|
||||
extern void (*const glUniform1ui)(GLint, GLuint);
|
||||
/// Pointer to glUniform2ui OpenGL function.
|
||||
extern void (* const glUniform2ui)(GLint, GLuint, GLuint);
|
||||
extern void (*const glUniform2ui)(GLint, GLuint, GLuint);
|
||||
/// Pointer to glUniform3ui OpenGL function.
|
||||
extern void (* const glUniform3ui)(GLint, GLuint, GLuint, GLuint);
|
||||
extern void (*const glUniform3ui)(GLint, GLuint, GLuint, GLuint);
|
||||
/// Pointer to glUniform4ui OpenGL function.
|
||||
extern void (* const glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint);
|
||||
extern void (*const glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint);
|
||||
/// Pointer to glUniform1uiv OpenGL function.
|
||||
extern void (* const glUniform1uiv)(GLint, GLsizei, const GLuint *);
|
||||
extern void (*const glUniform1uiv)(GLint, GLsizei, const GLuint*);
|
||||
/// Pointer to glUniform2uiv OpenGL function.
|
||||
extern void (* const glUniform2uiv)(GLint, GLsizei, const GLuint *);
|
||||
extern void (*const glUniform2uiv)(GLint, GLsizei, const GLuint*);
|
||||
/// Pointer to glUniform3uiv OpenGL function.
|
||||
extern void (* const glUniform3uiv)(GLint, GLsizei, const GLuint *);
|
||||
extern void (*const glUniform3uiv)(GLint, GLsizei, const GLuint*);
|
||||
/// Pointer to glUniform4uiv OpenGL function.
|
||||
extern void (* const glUniform4uiv)(GLint, GLsizei, const GLuint *);
|
||||
extern void (*const glUniform4uiv)(GLint, GLsizei, const GLuint*);
|
||||
/// Pointer to glClearBufferiv OpenGL function.
|
||||
extern void (* const glClearBufferiv)(GLenum, GLint, const GLint *);
|
||||
extern void (*const glClearBufferiv)(GLenum, GLint, const GLint*);
|
||||
/// Pointer to glClearBufferuiv OpenGL function.
|
||||
extern void (* const glClearBufferuiv)(GLenum, GLint, const GLuint *);
|
||||
extern void (*const glClearBufferuiv)(GLenum, GLint, const GLuint*);
|
||||
/// Pointer to glClearBufferfv OpenGL function.
|
||||
extern void (* const glClearBufferfv)(GLenum, GLint, const GLfloat *);
|
||||
extern void (*const glClearBufferfv)(GLenum, GLint, const GLfloat*);
|
||||
/// Pointer to glClearBufferfi OpenGL function.
|
||||
extern void (* const glClearBufferfi)(GLenum, GLint, GLfloat, GLint);
|
||||
extern void (*const glClearBufferfi)(GLenum, GLint, GLfloat, GLint);
|
||||
/// Pointer to glGetStringi OpenGL function.
|
||||
extern const GLubyte* (* const glGetStringi)(GLenum, GLuint);
|
||||
extern const GLubyte* (*const glGetStringi)(GLenum, GLuint);
|
||||
/// Pointer to glCopyBufferSubData OpenGL function.
|
||||
extern void (* const glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr);
|
||||
extern void (*const glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr);
|
||||
/// Pointer to glGetUniformIndices OpenGL function.
|
||||
extern void (* const glGetUniformIndices)(GLuint, GLsizei, const GLchar * const*, GLuint *);
|
||||
extern void (*const glGetUniformIndices)(GLuint, GLsizei, const GLchar* const*, GLuint*);
|
||||
/// Pointer to glGetActiveUniformsiv OpenGL function.
|
||||
extern void (* const glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *);
|
||||
extern void (*const glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint*, GLenum, GLint*);
|
||||
/// Pointer to glGetUniformBlockIndex OpenGL function.
|
||||
extern GLuint (* const glGetUniformBlockIndex)(GLuint, const GLchar *);
|
||||
extern GLuint (*const glGetUniformBlockIndex)(GLuint, const GLchar*);
|
||||
/// Pointer to glGetActiveUniformBlockiv OpenGL function.
|
||||
extern void (* const glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *);
|
||||
extern void (*const glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint*);
|
||||
/// Pointer to glGetActiveUniformBlockName OpenGL function.
|
||||
extern void (* const glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *);
|
||||
extern void (*const glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei*, GLchar*);
|
||||
/// Pointer to glUniformBlockBinding OpenGL function.
|
||||
extern void (* const glUniformBlockBinding)(GLuint, GLuint, GLuint);
|
||||
extern void (*const glUniformBlockBinding)(GLuint, GLuint, GLuint);
|
||||
/// Pointer to glDrawArraysInstanced OpenGL function.
|
||||
extern void (* const glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei);
|
||||
extern void (*const glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei);
|
||||
/// Pointer to glDrawElementsInstanced OpenGL function.
|
||||
extern void (* const glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei);
|
||||
extern void (*const glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid*, GLsizei);
|
||||
/// Pointer to glFenceSync OpenGL function.
|
||||
extern GLsync (* const glFenceSync)(GLenum, GLbitfield);
|
||||
extern GLsync (*const glFenceSync)(GLenum, GLbitfield);
|
||||
/// Pointer to glIsSync OpenGL function.
|
||||
extern GLboolean (* const glIsSync)(GLsync);
|
||||
extern GLboolean (*const glIsSync)(GLsync);
|
||||
/// Pointer to glDeleteSync OpenGL function.
|
||||
extern void (* const glDeleteSync)(GLsync);
|
||||
extern void (*const glDeleteSync)(GLsync);
|
||||
/// Pointer to glClientWaitSync OpenGL function.
|
||||
extern GLenum (* const glClientWaitSync)(GLsync, GLbitfield, GLuint64);
|
||||
extern GLenum (*const glClientWaitSync)(GLsync, GLbitfield, GLuint64);
|
||||
/// Pointer to glWaitSync OpenGL function.
|
||||
extern void (* const glWaitSync)(GLsync, GLbitfield, GLuint64);
|
||||
extern void (*const glWaitSync)(GLsync, GLbitfield, GLuint64);
|
||||
/// Pointer to glGetInteger64v OpenGL function.
|
||||
extern void (* const glGetInteger64v)(GLenum, GLint64 *);
|
||||
extern void (*const glGetInteger64v)(GLenum, GLint64*);
|
||||
/// Pointer to glGetSynciv OpenGL function.
|
||||
extern void (* const glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *);
|
||||
extern void (*const glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei*, GLint*);
|
||||
/// Pointer to glGetInteger64i_v OpenGL function.
|
||||
extern void (* const glGetInteger64i_v)(GLenum, GLuint, GLint64 *);
|
||||
extern void (*const glGetInteger64i_v)(GLenum, GLuint, GLint64*);
|
||||
/// Pointer to glGetBufferParameteri64v OpenGL function.
|
||||
extern void (* const glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *);
|
||||
extern void (*const glGetBufferParameteri64v)(GLenum, GLenum, GLint64*);
|
||||
/// Pointer to glGenSamplers OpenGL function.
|
||||
extern void (* const glGenSamplers)(GLsizei, GLuint *);
|
||||
extern void (*const glGenSamplers)(GLsizei, GLuint*);
|
||||
/// Pointer to glDeleteSamplers OpenGL function.
|
||||
extern void (* const glDeleteSamplers)(GLsizei, const GLuint *);
|
||||
extern void (*const glDeleteSamplers)(GLsizei, const GLuint*);
|
||||
/// Pointer to glIsSampler OpenGL function.
|
||||
extern GLboolean (* const glIsSampler)(GLuint);
|
||||
extern GLboolean (*const glIsSampler)(GLuint);
|
||||
/// Pointer to glBindSampler OpenGL function.
|
||||
extern void (* const glBindSampler)(GLuint, GLuint);
|
||||
extern void (*const glBindSampler)(GLuint, GLuint);
|
||||
/// Pointer to glSamplerParameteri OpenGL function.
|
||||
extern void (* const glSamplerParameteri)(GLuint, GLenum, GLint);
|
||||
extern void (*const glSamplerParameteri)(GLuint, GLenum, GLint);
|
||||
/// Pointer to glSamplerParameteriv OpenGL function.
|
||||
extern void (* const glSamplerParameteriv)(GLuint, GLenum, const GLint *);
|
||||
extern void (*const glSamplerParameteriv)(GLuint, GLenum, const GLint*);
|
||||
/// Pointer to glSamplerParameterf OpenGL function.
|
||||
extern void (* const glSamplerParameterf)(GLuint, GLenum, GLfloat);
|
||||
extern void (*const glSamplerParameterf)(GLuint, GLenum, GLfloat);
|
||||
/// Pointer to glSamplerParameterfv OpenGL function.
|
||||
extern void (* const glSamplerParameterfv)(GLuint, GLenum, const GLfloat *);
|
||||
extern void (*const glSamplerParameterfv)(GLuint, GLenum, const GLfloat*);
|
||||
/// Pointer to glGetSamplerParameteriv OpenGL function.
|
||||
extern void (* const glGetSamplerParameteriv)(GLuint, GLenum, GLint *);
|
||||
extern void (*const glGetSamplerParameteriv)(GLuint, GLenum, GLint*);
|
||||
/// Pointer to glGetSamplerParameterfv OpenGL function.
|
||||
extern void (* const glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *);
|
||||
extern void (*const glGetSamplerParameterfv)(GLuint, GLenum, GLfloat*);
|
||||
/// Pointer to glVertexAttribDivisor OpenGL function.
|
||||
extern void (* const glVertexAttribDivisor)(GLuint, GLuint);
|
||||
extern void (*const glVertexAttribDivisor)(GLuint, GLuint);
|
||||
/// Pointer to glBindTransformFeedback OpenGL function.
|
||||
extern void (* const glBindTransformFeedback)(GLenum, GLuint);
|
||||
extern void (*const glBindTransformFeedback)(GLenum, GLuint);
|
||||
/// Pointer to glDeleteTransformFeedbacks OpenGL function.
|
||||
extern void (* const glDeleteTransformFeedbacks)(GLsizei, const GLuint *);
|
||||
extern void (*const glDeleteTransformFeedbacks)(GLsizei, const GLuint*);
|
||||
/// Pointer to glGenTransformFeedbacks OpenGL function.
|
||||
extern void (* const glGenTransformFeedbacks)(GLsizei, GLuint *);
|
||||
extern void (*const glGenTransformFeedbacks)(GLsizei, GLuint*);
|
||||
/// Pointer to glIsTransformFeedback OpenGL function.
|
||||
extern GLboolean (* const glIsTransformFeedback)(GLuint);
|
||||
extern GLboolean (*const glIsTransformFeedback)(GLuint);
|
||||
/// Pointer to glPauseTransformFeedback OpenGL function.
|
||||
extern void (* const glPauseTransformFeedback)();
|
||||
extern void (*const glPauseTransformFeedback)();
|
||||
/// Pointer to glResumeTransformFeedback OpenGL function.
|
||||
extern void (* const glResumeTransformFeedback)();
|
||||
extern void (*const glResumeTransformFeedback)();
|
||||
/// Pointer to glGetProgramBinary OpenGL function.
|
||||
extern void (* const glGetProgramBinary)(GLuint, GLsizei, GLsizei *, GLenum *, GLvoid *);
|
||||
extern void (*const glGetProgramBinary)(GLuint, GLsizei, GLsizei*, GLenum*, GLvoid*);
|
||||
/// Pointer to glProgramBinary OpenGL function.
|
||||
extern void (* const glProgramBinary)(GLuint, GLenum, const GLvoid *, GLsizei);
|
||||
extern void (*const glProgramBinary)(GLuint, GLenum, const GLvoid*, GLsizei);
|
||||
/// Pointer to glProgramParameteri OpenGL function.
|
||||
extern void (* const glProgramParameteri)(GLuint, GLenum, GLint);
|
||||
extern void (*const glProgramParameteri)(GLuint, GLenum, GLint);
|
||||
/// Pointer to glInvalidateFramebuffer OpenGL function.
|
||||
extern void (* const glInvalidateFramebuffer)(GLenum, GLsizei, const GLenum *);
|
||||
extern void (*const glInvalidateFramebuffer)(GLenum, GLsizei, const GLenum*);
|
||||
/// Pointer to glInvalidateSubFramebuffer OpenGL function.
|
||||
extern void (* const glInvalidateSubFramebuffer)(GLenum, GLsizei, const GLenum *, GLint, GLint, GLsizei, GLsizei);
|
||||
extern void (*const glInvalidateSubFramebuffer)(GLenum, GLsizei, const GLenum*, GLint, GLint, GLsizei, GLsizei);
|
||||
/// Pointer to glTexStorage2D OpenGL function.
|
||||
extern void (* const glTexStorage2D)(GLenum, GLsizei, GLenum, GLsizei, GLsizei);
|
||||
extern void (*const glTexStorage2D)(GLenum, GLsizei, GLenum, GLsizei, GLsizei);
|
||||
/// Pointer to glTexStorage3D OpenGL function.
|
||||
extern void (* const glTexStorage3D)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei);
|
||||
extern void (*const glTexStorage3D)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei);
|
||||
/// Pointer to glGetInternalformativ OpenGL function.
|
||||
extern void (* const glGetInternalformativ)(GLenum, GLenum, GLenum, GLsizei, GLint *);
|
||||
extern void (*const glGetInternalformativ)(GLenum, GLenum, GLenum, GLsizei, GLint*);
|
||||
|
||||
#ifndef NDEBUG
|
||||
/// Check for GL errors and print on the console.
|
||||
void glCheckError(const char *cmd, const char *file, int line);
|
||||
void glCheckError(const char* cmd, const char* file, int line);
|
||||
#endif
|
||||
|
||||
} // namespace platform
|
||||
} // namespace platform
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -32,8 +32,9 @@ public:
|
||||
/// for specified key is missing.
|
||||
mapbox::base::Value get(const std::string& key) const noexcept;
|
||||
|
||||
/// Returns values for settings whose keys are equal to the ones provided in `keys` argument.
|
||||
/// Null values would be provided for keys whose elements are missing in Settings.
|
||||
/// Returns values for settings whose keys are equal to the ones provided in
|
||||
/// `keys` argument. Null values would be provided for keys whose elements
|
||||
/// are missing in Settings.
|
||||
mapbox::base::ValueObject get(const std::vector<std::string>& keys) const noexcept;
|
||||
|
||||
private:
|
||||
|
||||
@@ -42,7 +42,9 @@ struct PlacedSymbolData {
|
||||
|
||||
class Renderer {
|
||||
public:
|
||||
Renderer(gfx::RendererBackend&, float pixelRatio_, const std::optional<std::string>& localFontFamily = std::nullopt);
|
||||
Renderer(gfx::RendererBackend&,
|
||||
float pixelRatio_,
|
||||
const std::optional<std::string>& localFontFamily = std::nullopt);
|
||||
~Renderer();
|
||||
|
||||
void markContextLost();
|
||||
@@ -53,7 +55,8 @@ public:
|
||||
|
||||
/// Feature queries
|
||||
std::vector<Feature> queryRenderedFeatures(const ScreenLineString&, const RenderedQueryOptions& options = {}) const;
|
||||
std::vector<Feature> queryRenderedFeatures(const ScreenCoordinate& point, const RenderedQueryOptions& options = {}) const;
|
||||
std::vector<Feature> queryRenderedFeatures(const ScreenCoordinate& point,
|
||||
const RenderedQueryOptions& options = {}) const;
|
||||
std::vector<Feature> queryRenderedFeatures(const ScreenBox& box, const RenderedQueryOptions& options = {}) const;
|
||||
std::vector<Feature> querySourceFeatures(const std::string& sourceID, const SourceQueryOptions& options = {}) const;
|
||||
AnnotationIDs queryPointAnnotations(const ScreenBox& box) const;
|
||||
@@ -61,14 +64,17 @@ public:
|
||||
AnnotationIDs getAnnotationIDs(const std::vector<Feature>&) const;
|
||||
|
||||
/// Feature extension query
|
||||
FeatureExtensionValue queryFeatureExtensions(const std::string& sourceID,
|
||||
const Feature& feature,
|
||||
const std::string& extension,
|
||||
const std::string& extensionField,
|
||||
const std::optional<std::map<std::string, Value>>& args = std::nullopt) const;
|
||||
FeatureExtensionValue queryFeatureExtensions(
|
||||
const std::string& sourceID,
|
||||
const Feature& feature,
|
||||
const std::string& extension,
|
||||
const std::string& extensionField,
|
||||
const std::optional<std::map<std::string, Value>>& args = std::nullopt) const;
|
||||
|
||||
void setFeatureState(const std::string& sourceID, const std::optional<std::string>& sourceLayerID,
|
||||
const std::string& featureID, const FeatureState& state);
|
||||
void setFeatureState(const std::string& sourceID,
|
||||
const std::optional<std::string>& sourceLayerID,
|
||||
const std::string& featureID,
|
||||
const FeatureState& state);
|
||||
|
||||
void getFeatureState(FeatureState& state,
|
||||
const std::string& sourceID,
|
||||
@@ -84,16 +90,16 @@ public:
|
||||
void dumpDebugLogs();
|
||||
|
||||
/**
|
||||
* @brief In Tile map mode, enables or disables collecting of the placed symbols data,
|
||||
* which can be obtained with `getPlacedSymbolsData()`.
|
||||
* @brief In Tile map mode, enables or disables collecting of the placed
|
||||
* symbols data, which can be obtained with `getPlacedSymbolsData()`.
|
||||
*
|
||||
* The placed symbols data collecting is disabled by default.
|
||||
*/
|
||||
void collectPlacedSymbolData(bool enable);
|
||||
|
||||
/**
|
||||
* @brief If collecting of the placed symbols data is enabled, returns the reference
|
||||
* to the `PlacedSymbolData` vector holding the collected data.
|
||||
* @brief If collecting of the placed symbols data is enabled, returns the
|
||||
* reference to the `PlacedSymbolData` vector holding the collected data.
|
||||
*
|
||||
* Note: the returned vector gets re-populated at every `render()` call.
|
||||
*
|
||||
|
||||
@@ -14,7 +14,6 @@ class UpdateParameters;
|
||||
/// the original thread.
|
||||
class RendererFrontend {
|
||||
public:
|
||||
|
||||
virtual ~RendererFrontend() = default;
|
||||
|
||||
/// Must synchronously clean up the Renderer if set
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
virtual void onRemoveUnusedStyleImages(const std::vector<std::string>&) {}
|
||||
|
||||
// Entry point for custom shader registration
|
||||
virtual void onRegisterShaders(gfx::ShaderRegistry&) {};
|
||||
virtual void onRegisterShaders(gfx::ShaderRegistry&){};
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -8,12 +8,11 @@ namespace mbgl {
|
||||
class UpdateParameters;
|
||||
|
||||
/**
|
||||
* RendererState acts as a Memento object that is able to extract data out of UpdateParameters (an opaque object
|
||||
* from the public API perspective).
|
||||
* RendererState acts as a Memento object that is able to extract data out of
|
||||
* UpdateParameters (an opaque object from the public API perspective).
|
||||
*/
|
||||
class RendererState {
|
||||
public:
|
||||
|
||||
/// Obtains a CameraOptions out of a given UpdateParameters object.
|
||||
static CameraOptions getCameraOptions(const UpdateParameters&, const EdgeInsets& = {});
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::BackgroundProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::BackgroundProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
uniform mat4 u_matrix;
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::BackgroundPatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::BackgroundPatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_pattern_size_a;
|
||||
uniform vec2 u_pattern_size_b;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::CircleProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::CircleProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform bool u_scale_with_map;
|
||||
uniform bool u_pitch_with_map;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::ClippingMaskProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::ClippingMaskProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::CollisionBoxProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::CollisionBoxProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_anchor_pos;
|
||||
layout (location = 2) in vec2 a_extrude;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::CollisionCircleProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::CollisionCircleProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_anchor_pos;
|
||||
layout (location = 2) in vec2 a_extrude;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::DebugProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::DebugProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
out vec2 v_uv;
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::FillProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::FillExtrusionProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillExtrusionProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec3 u_lightcolor;
|
||||
uniform lowp vec3 u_lightpos;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::FillExtrusionPatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillExtrusionPatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_pixel_coord_upper;
|
||||
uniform vec2 u_pixel_coord_lower;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::FillOutlineProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillOutlineProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::FillOutlinePatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillOutlinePatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_world;
|
||||
uniform vec2 u_pixel_coord_upper;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::FillPatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillPatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_pixel_coord_upper;
|
||||
uniform vec2 u_pixel_coord_lower;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::HeatmapProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HeatmapProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform float u_extrude_scale;
|
||||
uniform float u_opacity;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::HeatmapTextureProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HeatmapTextureProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_world;
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::HillshadeProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HillshadeProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::HillshadePrepareProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HillshadePrepareProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_dimension;
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::LineProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LineProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0
|
||||
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
|
||||
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::LineGradientProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LineGradientProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(
|
||||
// the attribute conveying progress along a line is scaled to [0, 2^15)
|
||||
#define MAX_LINE_DISTANCE 32767.0
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::LinePatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LinePatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0
|
||||
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
|
||||
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::LineSDFProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LineSDFProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0
|
||||
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
|
||||
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::Prelude, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::Prelude, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(#ifdef GL_ES
|
||||
precision highp float;
|
||||
#else
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::RasterProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::RasterProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_tl_parent;
|
||||
uniform float u_scale_parent;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::SymbolIconProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::SymbolIconProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(const float PI = 3.141592653589793;
|
||||
|
||||
layout (location = 0) in vec4 a_pos_offset;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::SymbolSDFIconProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::SymbolSDFIconProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(const float PI = 3.141592653589793;
|
||||
|
||||
layout (location = 0) in vec4 a_pos_offset;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::SymbolSDFTextProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::SymbolSDFTextProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(const float PI = 3.141592653589793;
|
||||
|
||||
layout (location = 0) in vec4 a_pos_offset;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <> struct ShaderSource<BuiltIn::SymbolTextAndIconProgram, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::SymbolTextAndIconProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(const float PI = 3.141592653589793;
|
||||
|
||||
layout (location = 0) in vec4 a_pos_offset;
|
||||
|
||||
@@ -45,10 +45,12 @@ enum class BuiltIn {
|
||||
/// @tparam T One of the built-in shader types available in the BuiltIn enum
|
||||
/// @tparam The desired graphics API to request shader code for. One of
|
||||
/// gfx::Backend::Type enums.
|
||||
template <BuiltIn T, gfx::Backend::Type> struct ShaderSource;
|
||||
template <BuiltIn T, gfx::Backend::Type>
|
||||
struct ShaderSource;
|
||||
|
||||
/// @brief A specialization of the ShaderSource template for no shader code.
|
||||
template <> struct ShaderSource<BuiltIn::None, gfx::Backend::Type::OpenGL> {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::None, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = "";
|
||||
static constexpr const char* fragment = "";
|
||||
};
|
||||
|
||||
@@ -26,17 +26,17 @@ public:
|
||||
// Methods common to Ambient cache and Offline functionality
|
||||
|
||||
/**
|
||||
* Sets path of a database to be used by DatabaseFileSource and invokes provided
|
||||
* callback when a database path is set.
|
||||
* Sets path of a database to be used by DatabaseFileSource and invokes
|
||||
* provided callback when a database path is set.
|
||||
*/
|
||||
virtual void setDatabasePath(const std::string&, std::function<void()> callback);
|
||||
|
||||
/**
|
||||
* Delete existing database and re-initialize.
|
||||
*
|
||||
* When the operation is complete or encounters an error, the given callback will be
|
||||
* executed on the database thread; it is the responsibility of the SDK bindings
|
||||
* to re-execute a user-provided callback on the main thread.
|
||||
* When the operation is complete or encounters an error, the given callback
|
||||
* will be executed on the database thread; it is the responsibility of the
|
||||
* SDK bindings to re-execute a user-provided callback on the main thread.
|
||||
*/
|
||||
virtual void resetDatabase(std::function<void(std::exception_ptr)>);
|
||||
|
||||
@@ -46,16 +46,16 @@ public:
|
||||
* This operation has a performance impact as it will vacuum the database,
|
||||
* forcing it to move pages on the filesystem.
|
||||
*
|
||||
* When the operation is complete or encounters an error, the given callback will be
|
||||
* executed on the database thread; it is the responsibility of the SDK bindings
|
||||
* to re-execute a user-provided callback on the main thread.
|
||||
* When the operation is complete or encounters an error, the given callback
|
||||
* will be executed on the database thread; it is the responsibility of the
|
||||
* SDK bindings to re-execute a user-provided callback on the main thread.
|
||||
*/
|
||||
virtual void packDatabase(std::function<void(std::exception_ptr)> callback);
|
||||
|
||||
/**
|
||||
* Sets whether packing the database file occurs automatically after an offline
|
||||
* region is deleted (deleteOfflineRegion()) or the ambient cache is cleared
|
||||
* (clearAmbientCache()).
|
||||
* Sets whether packing the database file occurs automatically after an
|
||||
* offline region is deleted (deleteOfflineRegion()) or the ambient cache is
|
||||
* cleared (clearAmbientCache()).
|
||||
*
|
||||
* By default, packing is enabled. If disabled, disk space will not be freed
|
||||
* after resources are removed unless packDatabase() is explicitly called.
|
||||
@@ -129,21 +129,23 @@ public:
|
||||
/**
|
||||
* Retrieve all regions in the offline database.
|
||||
*
|
||||
* The query will be executed asynchronously and the results passed to the given
|
||||
* callback, which will be executed on the database thread; it is the responsibility
|
||||
* of the SDK bindings to re-execute a user-provided callback on the main thread.
|
||||
* The query will be executed asynchronously and the results passed to the
|
||||
* given callback, which will be executed on the database thread; it is the
|
||||
* responsibility of the SDK bindings to re-execute a user-provided callback
|
||||
* on the main thread.
|
||||
*/
|
||||
virtual void listOfflineRegions(std::function<void(expected<OfflineRegions, std::exception_ptr>)>);
|
||||
|
||||
/**
|
||||
* Create an offline region in the database.
|
||||
*
|
||||
* When the initial database queries have completed, the provided callback will be
|
||||
* executed on the database thread; it is the responsibility of the SDK bindings
|
||||
* to re-execute a user-provided callback on the main thread.
|
||||
* When the initial database queries have completed, the provided callback
|
||||
* will be executed on the database thread; it is the responsibility of the
|
||||
* SDK bindings to re-execute a user-provided callback on the main thread.
|
||||
*
|
||||
* Note that the resulting region will be in an inactive download state; to begin
|
||||
* downloading resources, call `setOfflineRegionDownloadState(OfflineRegionDownloadState::Active)`,
|
||||
* Note that the resulting region will be in an inactive download state; to
|
||||
* begin downloading resources, call
|
||||
* `setOfflineRegionDownloadState(OfflineRegionDownloadState::Active)`,
|
||||
* optionally registering an `OfflineRegionObserver` beforehand.
|
||||
*/
|
||||
virtual void createOfflineRegion(const OfflineRegionDefinition& definition,
|
||||
@@ -168,9 +170,9 @@ public:
|
||||
|
||||
/**
|
||||
* Retrieve the current status of the region. The query will be executed
|
||||
* asynchronously and the results passed to the given callback, which will be
|
||||
* executed on the database thread; it is the responsibility of the SDK bindings
|
||||
* to re-execute a user-provided callback on the main thread.
|
||||
* asynchronously and the results passed to the given callback, which will
|
||||
* be executed on the database thread; it is the responsibility of the SDK
|
||||
* bindings to re-execute a user-provided callback on the main thread.
|
||||
*/
|
||||
virtual void getOfflineRegionStatus(const OfflineRegion&,
|
||||
std::function<void(expected<OfflineRegionStatus, std::exception_ptr>)>) const;
|
||||
@@ -199,36 +201,38 @@ public:
|
||||
std::function<void(expected<OfflineRegions, std::exception_ptr>)>);
|
||||
|
||||
/**
|
||||
* Remove an offline region from the database and perform any resources evictions
|
||||
* necessary as a result.
|
||||
* Remove an offline region from the database and perform any resources
|
||||
* evictions necessary as a result.
|
||||
*
|
||||
* Eviction works by removing the least-recently requested resources not also required
|
||||
* by other regions, until the database shrinks below a certain size.
|
||||
* Eviction works by removing the least-recently requested resources not
|
||||
* also required by other regions, until the database shrinks below a
|
||||
* certain size.
|
||||
*
|
||||
* Note that this method takes ownership of the input, reflecting the fact that once
|
||||
* region deletion is initiated, it is not legal to perform further actions with the
|
||||
* region.
|
||||
* Note that this method takes ownership of the input, reflecting the fact
|
||||
* that once region deletion is initiated, it is not legal to perform
|
||||
* further actions with the region.
|
||||
*
|
||||
* Note that this operation can be potentially slow if packing the database occurs
|
||||
* automatically (see runPackDatabaseAutomatically() and packDatabase()).
|
||||
* Note that this operation can be potentially slow if packing the database
|
||||
* occurs automatically (see runPackDatabaseAutomatically() and
|
||||
* packDatabase()).
|
||||
*
|
||||
* When the operation is complete or encounters an error, the given callback will be
|
||||
* executed on the database thread; it is the responsibility of the SDK bindings
|
||||
* to re-execute a user-provided callback on the main thread.
|
||||
* When the operation is complete or encounters an error, the given callback
|
||||
* will be executed on the database thread; it is the responsibility of the
|
||||
* SDK bindings to re-execute a user-provided callback on the main thread.
|
||||
*/
|
||||
virtual void deleteOfflineRegion(const OfflineRegion&, std::function<void(std::exception_ptr)>);
|
||||
|
||||
/**
|
||||
* Invalidate all the tiles from an offline region forcing Mapbox GL to revalidate
|
||||
* the tiles with the server before using. This is more efficient than deleting the
|
||||
* offline region and downloading it again because if the data on the cache matches
|
||||
* the server, no new data gets transmitted.
|
||||
* Invalidate all the tiles from an offline region forcing Mapbox GL to
|
||||
* revalidate the tiles with the server before using. This is more efficient
|
||||
* than deleting the offline region and downloading it again because if the
|
||||
* data on the cache matches the server, no new data gets transmitted.
|
||||
*/
|
||||
virtual void invalidateOfflineRegion(const OfflineRegion&, std::function<void(std::exception_ptr)>);
|
||||
|
||||
/**
|
||||
* Changing or bypassing this limit without permission from Mapbox is prohibited
|
||||
* by the Mapbox Terms of Service.
|
||||
* Changing or bypassing this limit without permission from Mapbox is
|
||||
* prohibited by the Mapbox Terms of Service.
|
||||
*/
|
||||
virtual void setOfflineMapboxTileCountLimit(uint64_t) const;
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ public:
|
||||
FileSource& operator=(const FileSource&) = delete;
|
||||
virtual ~FileSource() = default;
|
||||
|
||||
using Callback = std::function<void (Response)>;
|
||||
using Callback = std::function<void(Response)>;
|
||||
|
||||
/// Request a resource. The callback will be called asynchronously, in the same
|
||||
/// thread as the request was made. This thread must have an active RunLoop. The
|
||||
/// request may be cancelled before completion by releasing the returned AsyncRequest.
|
||||
/// If the request is cancelled before the callback is executed, the callback will
|
||||
/// not be executed.
|
||||
/// Request a resource. The callback will be called asynchronously, in the
|
||||
/// same thread as the request was made. This thread must have an active
|
||||
/// RunLoop. The request may be cancelled before completion by releasing the
|
||||
/// returned AsyncRequest. If the request is cancelled before the callback
|
||||
/// is executed, the callback will not be executed.
|
||||
virtual std::unique_ptr<AsyncRequest> request(const Resource&, Callback) = 0;
|
||||
|
||||
/// Allows to forward response from one source to another.
|
||||
@@ -53,10 +53,11 @@ public:
|
||||
// NOLINTNEXTLINE(performance-unnecessary-value-param)
|
||||
virtual void forward(const Resource&, const Response&, std::function<void()>) {}
|
||||
|
||||
/// When a file source supports consulting a local cache only, it must return true.
|
||||
/// Cache-only requests are requests that aren't as urgent, but could be useful, e.g.
|
||||
/// to cover part of the map while loading. The FileSource should only do cheap actions to
|
||||
/// retrieve the data, e.g. load it from a cache, but not from the internet.
|
||||
/// When a file source supports consulting a local cache only, it must
|
||||
/// return true. Cache-only requests are requests that aren't as urgent, but
|
||||
/// could be useful, e.g. to cover part of the map while loading. The
|
||||
/// FileSource should only do cheap actions to retrieve the data, e.g. load
|
||||
/// it from a cache, but not from the internet.
|
||||
virtual bool supportsCacheOnlyRequests() const { return false; }
|
||||
|
||||
/// Checks whether a resource could be requested from this file source.
|
||||
@@ -112,8 +113,8 @@ constexpr const char* MAX_CONCURRENT_REQUESTS_KEY = "max-concurrent-requests";
|
||||
|
||||
// Properties that may be supported by database file sources:
|
||||
|
||||
/// Property to set database mode. When set, database opens in read-only mode; database opens in read-write-create mode
|
||||
/// otherwise. type: bool
|
||||
/// Property to set database mode. When set, database opens in read-only mode;
|
||||
/// database opens in read-write-create mode otherwise. type: bool
|
||||
constexpr const char* READ_ONLY_MODE_KEY = "read-only-mode";
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -28,17 +28,19 @@ public:
|
||||
static FileSourceManager* get() noexcept;
|
||||
|
||||
// Returns shared instance of a file source for (type, options) tuple.
|
||||
// Creates new instance via registered factory if needed. If new instance cannot be
|
||||
// created, nullptr would be returned.
|
||||
[[nodiscard]] std::shared_ptr<FileSource> getFileSource(FileSourceType, const ResourceOptions&, const ClientOptions& = ClientOptions()) noexcept;
|
||||
// Creates new instance via registered factory if needed. If new instance
|
||||
// cannot be created, nullptr would be returned.
|
||||
[[nodiscard]] std::shared_ptr<FileSource> getFileSource(FileSourceType,
|
||||
const ResourceOptions&,
|
||||
const ClientOptions& = ClientOptions()) noexcept;
|
||||
|
||||
// Registers file source factory for a provided FileSourceType type. If factory for the
|
||||
// same type was already registered, will unregister previously registered factory.
|
||||
// Provided factory must not be null.
|
||||
// Registers file source factory for a provided FileSourceType type. If
|
||||
// factory for the same type was already registered, will unregister
|
||||
// previously registered factory. Provided factory must not be null.
|
||||
virtual void registerFileSourceFactory(FileSourceType, FileSourceFactory&&) noexcept;
|
||||
|
||||
// Unregisters file source factory. If there are no registered factories for a FileSourceType
|
||||
// invocation has no effect.
|
||||
// Unregisters file source factory. If there are no registered factories for
|
||||
// a FileSourceType invocation has no effect.
|
||||
virtual FileSourceFactory unRegisterFileSourceFactory(FileSourceType) noexcept;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace mbgl {
|
||||
class TileID;
|
||||
|
||||
/*
|
||||
* An offline region defined by a style URL, geographic bounding box, zoom range, and
|
||||
* device pixel ratio.
|
||||
* An offline region defined by a style URL, geographic bounding box, zoom
|
||||
* range, and device pixel ratio.
|
||||
*
|
||||
* Both minZoom and maxZoom must be ≥ 0, and maxZoom must be ≥ minZoom.
|
||||
*
|
||||
@@ -52,7 +52,12 @@ public:
|
||||
*/
|
||||
class OfflineGeometryRegionDefinition {
|
||||
public:
|
||||
OfflineGeometryRegionDefinition(std::string styleURL, Geometry<double>, double minZoom, double maxZoom, float pixelRatio, bool includeIdeographs);
|
||||
OfflineGeometryRegionDefinition(std::string styleURL,
|
||||
Geometry<double>,
|
||||
double minZoom,
|
||||
double maxZoom,
|
||||
float pixelRatio,
|
||||
bool includeIdeographs);
|
||||
|
||||
/* Private */
|
||||
std::string styleURL;
|
||||
@@ -75,11 +80,12 @@ std::string encodeOfflineRegionDefinition(const OfflineRegionDefinition&);
|
||||
OfflineRegionDefinition decodeOfflineRegionDefinition(const std::string&);
|
||||
|
||||
/*
|
||||
* Arbitrary binary region metadata. The contents are opaque to the mbgl implementation;
|
||||
* it just stores and retrieves a BLOB. SDK bindings should leave the interpretation of
|
||||
* this data up to the application; they _should not_ enforce a higher-level data format.
|
||||
* In the future we want offline database to be portable across target platforms, and a
|
||||
* platform-specific metadata format would prevent that.
|
||||
* Arbitrary binary region metadata. The contents are opaque to the mbgl
|
||||
* implementation; it just stores and retrieves a BLOB. SDK bindings should
|
||||
* leave the interpretation of this data up to the application; they _should
|
||||
* not_ enforce a higher-level data format. In the future we want offline
|
||||
* database to be portable across target platforms, and a platform-specific
|
||||
* metadata format would prevent that.
|
||||
*/
|
||||
using OfflineRegionMetadata = std::vector<uint8_t>;
|
||||
|
||||
@@ -116,14 +122,14 @@ public:
|
||||
uint64_t completedResourceCount = 0;
|
||||
|
||||
/**
|
||||
* The cumulative size, in bytes, of all resources (inclusive of tiles) that have
|
||||
* been fully downloaded.
|
||||
* The cumulative size, in bytes, of all resources (inclusive of tiles) that
|
||||
* have been fully downloaded.
|
||||
*/
|
||||
uint64_t completedResourceSize = 0;
|
||||
|
||||
/**
|
||||
* The number of tiles that are known to be required for this region. This is a
|
||||
* subset of `completedResourceCount`.
|
||||
* The number of tiles that are known to be required for this region. This
|
||||
* is a subset of `completedResourceCount`.
|
||||
*/
|
||||
uint64_t completedTileCount = 0;
|
||||
|
||||
@@ -133,15 +139,15 @@ public:
|
||||
uint64_t requiredTileCount = 0;
|
||||
|
||||
/**
|
||||
* The cumulative size, in bytes, of all tiles that have been fully downloaded.
|
||||
* This is a subset of `completedResourceSize`.
|
||||
* The cumulative size, in bytes, of all tiles that have been fully
|
||||
* downloaded. This is a subset of `completedResourceSize`.
|
||||
*/
|
||||
uint64_t completedTileSize = 0;
|
||||
|
||||
/**
|
||||
* The number of resources that are known to be required for this region. See the
|
||||
* documentation for `requiredResourceCountIsPrecise` for an important caveat
|
||||
* about this number.
|
||||
* The number of resources that are known to be required for this region.
|
||||
* See the documentation for `requiredResourceCountIsPrecise` for an
|
||||
* important caveat about this number.
|
||||
*/
|
||||
uint64_t requiredResourceCount = 0;
|
||||
|
||||
@@ -156,9 +162,7 @@ public:
|
||||
*/
|
||||
bool requiredResourceCountIsPrecise = false;
|
||||
|
||||
bool complete() const {
|
||||
return completedResourceCount >= requiredResourceCount;
|
||||
}
|
||||
bool complete() const { return completedResourceCount >= requiredResourceCount; }
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -175,35 +179,36 @@ public:
|
||||
* of OfflineRegionStatus.
|
||||
*
|
||||
* Note that this method will be executed on the database thread; it is the
|
||||
* responsibility of the SDK bindings to wrap this object in an interface that
|
||||
* re-executes the user-provided implementation on the main thread.
|
||||
* responsibility of the SDK bindings to wrap this object in an interface
|
||||
* that re-executes the user-provided implementation on the main thread.
|
||||
*/
|
||||
virtual void statusChanged(OfflineRegionStatus) {}
|
||||
|
||||
/*
|
||||
* Implement this method to be notified of errors encountered while downloading
|
||||
* regional resources. Such errors may be recoverable; for example the implementation
|
||||
* will attempt to re-request failed resources based on an exponential backoff
|
||||
* algorithm, or when it detects that network access has been restored.
|
||||
* Implement this method to be notified of errors encountered while
|
||||
* downloading regional resources. Such errors may be recoverable; for
|
||||
* example the implementation will attempt to re-request failed resources
|
||||
* based on an exponential backoff algorithm, or when it detects that
|
||||
* network access has been restored.
|
||||
*
|
||||
* Note that this method will be executed on the database thread; it is the
|
||||
* responsibility of the SDK bindings to wrap this object in an interface that
|
||||
* re-executes the user-provided implementation on the main thread.
|
||||
* responsibility of the SDK bindings to wrap this object in an interface
|
||||
* that re-executes the user-provided implementation on the main thread.
|
||||
*/
|
||||
virtual void responseError(Response::Error) {} // NOLINT(performance-unnecessary-value-param)
|
||||
|
||||
/*
|
||||
* Implement this method to be notified when the limit on the number of Mapbox
|
||||
* tiles stored for offline regions has been reached.
|
||||
* Implement this method to be notified when the limit on the number of
|
||||
* Mapbox tiles stored for offline regions has been reached.
|
||||
*
|
||||
* Once the limit has been reached, the SDK will not download further offline
|
||||
* tiles from Mapbox APIs until existing tiles have been removed.
|
||||
* Once the limit has been reached, the SDK will not download further
|
||||
* offline tiles from Mapbox APIs until existing tiles have been removed.
|
||||
*
|
||||
* This limit does not apply to non-Mapbox tile sources.
|
||||
*
|
||||
* Note that this method will be executed on the database thread; it is the
|
||||
* responsibility of the SDK bindings to wrap this object in an interface that
|
||||
* re-executes the user-provided implementation on the main thread.
|
||||
* responsibility of the SDK bindings to wrap this object in an interface
|
||||
* that re-executes the user-provided implementation on the main thread.
|
||||
*/
|
||||
virtual void mapboxTileCountLimitExceeded(uint64_t /* limit */) {}
|
||||
};
|
||||
@@ -220,9 +225,7 @@ public:
|
||||
private:
|
||||
friend class OfflineDatabase;
|
||||
|
||||
OfflineRegion(int64_t id,
|
||||
OfflineRegionDefinition,
|
||||
OfflineRegionMetadata);
|
||||
OfflineRegion(int64_t id, OfflineRegionDefinition, OfflineRegionMetadata);
|
||||
|
||||
int64_t id;
|
||||
OfflineRegionDefinition definition;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user