[core] move gl::Context to Backend and refactor View
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include <mbgl/sprite/sprite_image.hpp>
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/platform/default/headless_backend.hpp>
|
||||
#include <mbgl/platform/default/headless_view.hpp>
|
||||
#include <mbgl/platform/default/offscreen_view.hpp>
|
||||
#include <mbgl/util/io.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
@@ -24,14 +24,14 @@ class AnnotationTest {
|
||||
public:
|
||||
util::RunLoop loop;
|
||||
HeadlessBackend backend;
|
||||
HeadlessView view;
|
||||
OffscreenView view{ backend.getContext() };
|
||||
StubFileSource fileSource;
|
||||
ThreadPool threadPool { 4 };
|
||||
Map map { backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still };
|
||||
Map map { backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still };
|
||||
|
||||
void checkRendering(const char * name) {
|
||||
test::checkImage(std::string("test/fixtures/annotations/") + name,
|
||||
test::render(map), 0.0002, 0.1);
|
||||
test::render(map, view), 0.0002, 0.1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -162,7 +162,7 @@ TEST(Annotations, AddMultiple) {
|
||||
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
|
||||
test.map.addAnnotation(SymbolAnnotation { Point<double> { -10, 0 }, "default_marker" });
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
test.map.addAnnotation(SymbolAnnotation { Point<double> { 10, 0 }, "default_marker" });
|
||||
test.checkRendering("add_multiple");
|
||||
@@ -172,7 +172,7 @@ TEST(Annotations, NonImmediateAdd) {
|
||||
AnnotationTest test;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
|
||||
FillAnnotation annotation { polygon };
|
||||
@@ -190,7 +190,7 @@ TEST(Annotations, UpdateSymbolAnnotationGeometry) {
|
||||
test.map.addAnnotationIcon("flipped_marker", namedMarker("flipped_marker.png"));
|
||||
AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
test.map.updateAnnotation(point, SymbolAnnotation { Point<double> { -10, 0 }, "default_marker" });
|
||||
test.checkRendering("update_point");
|
||||
@@ -204,7 +204,7 @@ TEST(Annotations, UpdateSymbolAnnotationIcon) {
|
||||
test.map.addAnnotationIcon("flipped_marker", namedMarker("flipped_marker.png"));
|
||||
AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
test.map.updateAnnotation(point, SymbolAnnotation { Point<double> { 0, 0 }, "flipped_marker" });
|
||||
test.checkRendering("update_icon");
|
||||
@@ -220,7 +220,7 @@ TEST(Annotations, UpdateLineAnnotationGeometry) {
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
AnnotationID line = test.map.addAnnotation(annotation);
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
annotation.geometry = LineString<double> {{ { 0, 0 }, { -45, -45 } }};
|
||||
test.map.updateAnnotation(line, annotation);
|
||||
@@ -237,7 +237,7 @@ TEST(Annotations, UpdateLineAnnotationStyle) {
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
AnnotationID line = test.map.addAnnotation(annotation);
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
annotation.color = { { 0, 255, 0, 1 } };
|
||||
annotation.width = { 2 };
|
||||
@@ -254,7 +254,7 @@ TEST(Annotations, UpdateFillAnnotationGeometry) {
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
AnnotationID fill = test.map.addAnnotation(annotation);
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
annotation.geometry = Polygon<double> {{ {{ { 0, 0 }, { 0, 45 }, { 45, 0 } }} }};
|
||||
test.map.updateAnnotation(fill, annotation);
|
||||
@@ -271,7 +271,7 @@ TEST(Annotations, UpdateFillAnnotationStyle) {
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
AnnotationID fill = test.map.addAnnotation(annotation);
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
annotation.color = { { 0, 255, 0, 1 } };
|
||||
test.map.updateAnnotation(fill, annotation);
|
||||
@@ -285,7 +285,7 @@ TEST(Annotations, RemovePoint) {
|
||||
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
|
||||
AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
test.map.removeAnnotation(point);
|
||||
test.checkRendering("remove_point");
|
||||
@@ -302,7 +302,7 @@ TEST(Annotations, RemoveShape) {
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
AnnotationID shape = test.map.addAnnotation(annotation);
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
test.map.removeAnnotation(shape);
|
||||
test.checkRendering("remove_shape");
|
||||
@@ -314,7 +314,7 @@ TEST(Annotations, ImmediateRemoveShape) {
|
||||
test.map.removeAnnotation(test.map.addAnnotation(LineAnnotation { LineString<double>() }));
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
}
|
||||
|
||||
TEST(Annotations, SwitchStyle) {
|
||||
@@ -324,7 +324,7 @@ TEST(Annotations, SwitchStyle) {
|
||||
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
|
||||
test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.checkRendering("switch_style");
|
||||
@@ -338,7 +338,7 @@ TEST(Annotations, QueryRenderedFeatures) {
|
||||
test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
|
||||
test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 50 }, "default_marker" });
|
||||
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
auto features = test.map.queryRenderedFeatures(test.map.pixelForLatLng({ 0, 0 }));
|
||||
EXPECT_EQ(features.size(), 1u);
|
||||
@@ -370,7 +370,7 @@ TEST(Annotations, QueryFractionalZoomLevels) {
|
||||
test.map.setLatLngZoom({ 5, 5 }, 0);
|
||||
for (uint16_t zoomSteps = 10; zoomSteps <= 20; ++zoomSteps) {
|
||||
test.map.setZoom(zoomSteps / 10.0);
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
auto features = test.map.queryRenderedFeatures(box);
|
||||
|
||||
// Filter out repeated features.
|
||||
@@ -402,7 +402,7 @@ TEST(Annotations, VisibleFeatures) {
|
||||
|
||||
// Change bearing *after* adding annotations causes them to be reordered.
|
||||
test.map.setBearing(45);
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
|
||||
auto features = test.map.queryRenderedFeatures(box);
|
||||
auto sortID = [](const Feature& lhs, const Feature& rhs) { return lhs.id < rhs.id; };
|
||||
@@ -413,7 +413,7 @@ TEST(Annotations, VisibleFeatures) {
|
||||
|
||||
test.map.setBearing(0);
|
||||
test.map.setZoom(4);
|
||||
test::render(test.map);
|
||||
test::render(test.map, test.view);
|
||||
features = test.map.queryRenderedFeatures(box);
|
||||
std::sort(features.begin(), features.end(), sortID);
|
||||
features.erase(std::unique(features.begin(), features.end(), sameID), features.end());
|
||||
|
||||
Reference in New Issue
Block a user