summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-10-06 13:23:50 +0200
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2016-11-11 18:00:15 +0100
commit28b201acb57a8f9091821fb0a84400865e8d012d (patch)
treeab7bb107c75203d8635bd8d729fb539b3169a3ed /test
parentb481bcbe6aba6ce25512b519023a355d4ffd28a4 (diff)
downloadqtlocation-mapboxgl-28b201acb57a8f9091821fb0a84400865e8d012d.tar.gz
[core] separate Backend from View for headless rendering
Diffstat (limited to 'test')
-rw-r--r--test/api/annotations.test.cpp8
-rw-r--r--test/api/api_misuse.test.cpp16
-rw-r--r--test/api/custom_layer.test.cpp8
-rw-r--r--test/api/query.test.cpp8
-rw-r--r--test/api/render_missing.test.cpp8
-rw-r--r--test/api/repeated_render.test.cpp9
-rw-r--r--test/gl/object.test.cpp8
-rw-r--r--test/map/map.test.cpp62
-rw-r--r--test/util/memory.test.cpp21
-rw-r--r--test/util/offscreen_texture.test.cpp11
10 files changed, 93 insertions, 66 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp
index c1716a5228..53c0182ee9 100644
--- a/test/api/annotations.test.cpp
+++ b/test/api/annotations.test.cpp
@@ -5,7 +5,7 @@
#include <mbgl/annotation/annotation.hpp>
#include <mbgl/sprite/sprite_image.hpp>
#include <mbgl/map/map.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/platform/default/headless_backend.hpp>
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
@@ -23,11 +23,11 @@ std::shared_ptr<SpriteImage> namedMarker(const std::string &name) {
class AnnotationTest {
public:
util::RunLoop loop;
- std::shared_ptr<HeadlessDisplay> display { std::make_shared<HeadlessDisplay>() };
- HeadlessView view { display, 1 };
+ HeadlessBackend backend;
+ HeadlessView view;
StubFileSource fileSource;
ThreadPool threadPool { 4 };
- Map map { view, fileSource, threadPool, MapMode::Still };
+ Map map { backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still };
void checkRendering(const char * name) {
test::checkImage(std::string("test/fixtures/annotations/") + name,
diff --git a/test/api/api_misuse.test.cpp b/test/api/api_misuse.test.cpp
index 2016e278da..f11363fa3c 100644
--- a/test/api/api_misuse.test.cpp
+++ b/test/api/api_misuse.test.cpp
@@ -3,7 +3,8 @@
#include <mbgl/test/fixture_log_observer.hpp>
#include <mbgl/map/map.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/platform/default/headless_backend.hpp>
+#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/storage/online_file_source.hpp>
#include <mbgl/platform/default/thread_pool.hpp>
#include <mbgl/util/exception.hpp>
@@ -19,13 +20,14 @@ TEST(API, RenderWithoutCallback) {
util::RunLoop loop;
- auto display = std::make_shared<mbgl::HeadlessDisplay>();
- HeadlessView view(display, 1);
+ HeadlessBackend backend;
+ HeadlessView view;
view.resize(128, 512);
StubFileSource fileSource;
ThreadPool threadPool(4);
- std::unique_ptr<Map> map = std::make_unique<Map>(view, fileSource, threadPool, MapMode::Still);
+ std::unique_ptr<Map> map = std::make_unique<Map>(backend, view, view.getPixelRatio(),
+ fileSource, threadPool, MapMode::Still);
map->renderStill(nullptr);
// Force Map thread to join.
@@ -44,13 +46,13 @@ TEST(API, RenderWithoutCallback) {
TEST(API, RenderWithoutStyle) {
util::RunLoop loop;
- auto display = std::make_shared<mbgl::HeadlessDisplay>();
- HeadlessView view(display, 1);
+ HeadlessBackend backend;
+ HeadlessView view;
view.resize(128, 512);
StubFileSource fileSource;
ThreadPool threadPool(4);
- Map map(view, fileSource, threadPool, MapMode::Still);
+ Map map(backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still);
std::exception_ptr error;
map.renderStill([&](std::exception_ptr error_, PremultipliedImage&&) {
diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp
index 1342dfa50c..84ae780174 100644
--- a/test/api/custom_layer.test.cpp
+++ b/test/api/custom_layer.test.cpp
@@ -2,7 +2,7 @@
#include <mbgl/gl/gl.hpp>
#include <mbgl/map/map.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/platform/default/headless_backend.hpp>
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/platform/default/thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
@@ -85,8 +85,8 @@ public:
TEST(CustomLayer, Basic) {
util::RunLoop loop;
- auto display = std::make_shared<mbgl::HeadlessDisplay>();
- HeadlessView view(display, 1);
+ HeadlessBackend backend;
+ HeadlessView view;
#ifdef MBGL_ASSET_ZIP
// Regenerate with `cd test/fixtures/api/ && zip -r assets.zip assets/`
@@ -97,7 +97,7 @@ TEST(CustomLayer, Basic) {
ThreadPool threadPool(4);
- Map map(view, fileSource, threadPool, MapMode::Still);
+ Map map(backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still);
map.setStyleJSON(util::read_file("test/fixtures/api/water.json"));
map.setLatLngZoom({ 37.8, -122.5 }, 10);
map.addLayer(std::make_unique<CustomLayer>(
diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp
index da38dd0cb2..d989d222c5 100644
--- a/test/api/query.test.cpp
+++ b/test/api/query.test.cpp
@@ -1,5 +1,5 @@
#include <mbgl/map/map.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/platform/default/headless_backend.hpp>
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/platform/default/thread_pool.hpp>
#include <mbgl/sprite/sprite_image.hpp>
@@ -26,11 +26,11 @@ public:
}
util::RunLoop loop;
- std::shared_ptr<HeadlessDisplay> display { std::make_shared<HeadlessDisplay>() };
- HeadlessView view { display, 1 };
+ HeadlessBackend backend;
+ HeadlessView view;
StubFileSource fileSource;
ThreadPool threadPool { 4 };
- Map map { view, fileSource, threadPool, MapMode::Still };
+ Map map { backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still };
};
} // end namespace
diff --git a/test/api/render_missing.test.cpp b/test/api/render_missing.test.cpp
index d57a5a98bd..8123070282 100644
--- a/test/api/render_missing.test.cpp
+++ b/test/api/render_missing.test.cpp
@@ -2,7 +2,7 @@
#include <mbgl/test/fixture_log_observer.hpp>
#include <mbgl/map/map.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/platform/default/headless_backend.hpp>
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/platform/default/thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
@@ -25,8 +25,8 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) {
const auto style = util::read_file("test/fixtures/api/water_missing_tiles.json");
- auto display = std::make_shared<mbgl::HeadlessDisplay>();
- HeadlessView view(display, 1, 256, 512);
+ HeadlessBackend backend;
+ HeadlessView view(1, 256, 512);
#ifdef MBGL_ASSET_ZIP
// Regenerate with `cd test/fixtures/api/ && zip -r assets.zip assets/`
DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets.zip");
@@ -38,7 +38,7 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) {
Log::setObserver(std::make_unique<FixtureLogObserver>());
- Map map(view, fileSource, threadPool, MapMode::Still);
+ Map map(backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still);
std::string message;
diff --git a/test/api/repeated_render.test.cpp b/test/api/repeated_render.test.cpp
index 4229f9d7ad..5bc57198bd 100644
--- a/test/api/repeated_render.test.cpp
+++ b/test/api/repeated_render.test.cpp
@@ -2,7 +2,7 @@
#include <mbgl/test/fixture_log_observer.hpp>
#include <mbgl/map/map.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/platform/default/headless_backend.hpp>
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/platform/default/thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
@@ -19,9 +19,8 @@ TEST(API, RepeatedRender) {
const auto style = util::read_file("test/fixtures/api/water.json");
- auto display = std::make_shared<mbgl::HeadlessDisplay>();
- HeadlessView view(display, 1, 256, 512);
-
+ HeadlessBackend backend;
+ HeadlessView view(1, 256, 512);
#ifdef MBGL_ASSET_ZIP
// Regenerate with `cd test/fixtures/api/ && zip -r assets.zip assets/`
DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets.zip");
@@ -33,7 +32,7 @@ TEST(API, RepeatedRender) {
Log::setObserver(std::make_unique<FixtureLogObserver>());
- Map map(view, fileSource, threadPool, MapMode::Still);
+ Map map(backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still);
{
map.setStyleJSON(style);
diff --git a/test/gl/object.test.cpp b/test/gl/object.test.cpp
index 1a90cec83b..1f9d48cff7 100644
--- a/test/gl/object.test.cpp
+++ b/test/gl/object.test.cpp
@@ -1,6 +1,6 @@
#include <mbgl/test/util.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/platform/default/headless_backend.hpp>
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/gl/gl.hpp>
@@ -67,8 +67,8 @@ TEST(GLObject, Value) {
}
TEST(GLObject, Store) {
- mbgl::HeadlessView view(std::make_shared<mbgl::HeadlessDisplay>(), 1);
- view.activate();
+ mbgl::HeadlessBackend backend;
+ mbgl::HeadlessView view;
mbgl::gl::Context context;
EXPECT_TRUE(context.empty());
@@ -106,5 +106,5 @@ TEST(GLObject, Store) {
context.reset();
EXPECT_TRUE(context.empty());
- view.deactivate();
+ backend.deactivate();
}
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index c03a038dc0..a5d634e77a 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -4,7 +4,7 @@
#include <mbgl/test/fixture_log_observer.hpp>
#include <mbgl/map/map.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/platform/default/headless_backend.hpp>
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/platform/default/thread_pool.hpp>
#include <mbgl/sprite/sprite_image.hpp>
@@ -22,15 +22,16 @@ using namespace std::literals::string_literals;
struct MapTest {
util::RunLoop runLoop;
- std::shared_ptr<HeadlessDisplay> display { std::make_shared<mbgl::HeadlessDisplay>() };
- HeadlessView view { display, 1 };
+ HeadlessBackend backend;
+ HeadlessView view;
StubFileSource fileSource;
ThreadPool threadPool { 4 };
};
TEST(Map, LatLngBehavior) {
MapTest test;
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
@@ -64,7 +65,8 @@ TEST(Map, Offline) {
fileSource.put(Resource::glyphs(prefix + "{fontstack}/{range}.pbf", {{"Helvetica"}}, {0, 255}), expiredItem("glyph.pbf"));
NetworkStatus::Set(NetworkStatus::Status::Offline);
- Map map(test.view, fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleURL(prefix + "style.json");
test::checkImage("test/fixtures/map/offline",
@@ -81,14 +83,15 @@ TEST(Map, SetStyleInvalidJSON) {
Log::setObserver(std::make_unique<FixtureLogObserver>());
bool fail = false;
- test.view.setMapChangeCallback([&](MapChange change) {
+ test.backend.setMapChangeCallback([&](MapChange change) {
if (change == mbgl::MapChangeDidFailLoadingMap) {
fail = true;
}
});
{
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource,
+ test.threadPool, MapMode::Still);
map.setStyleJSON("invalid");
}
@@ -113,13 +116,14 @@ TEST(Map, SetStyleInvalidURL) {
return response;
};
- test.view.setMapChangeCallback([&](MapChange change) {
+ test.backend.setMapChangeCallback([&](MapChange change) {
if (change == mbgl::MapChangeDidFailLoadingMap) {
test.runLoop.stop();
}
});
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleURL("mapbox://bar");
test.runLoop.run();
@@ -128,7 +132,8 @@ TEST(Map, SetStyleInvalidURL) {
TEST(Map, DoubleStyleLoad) {
MapTest test;
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleJSON("");
map.setStyleJSON("");
}
@@ -139,7 +144,8 @@ TEST(Map, StyleFresh) {
MapTest test;
FakeFileSource fileSource;
- Map map(test.view, fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleURL("mapbox://styles/test");
EXPECT_EQ(1u, fileSource.requests.size());
@@ -159,7 +165,8 @@ TEST(Map, StyleExpired) {
MapTest test;
FakeFileSource fileSource;
- Map map(test.view, fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleURL("mapbox://styles/test");
EXPECT_EQ(1u, fileSource.requests.size());
@@ -186,7 +193,8 @@ TEST(Map, StyleExpiredWithAnnotations) {
MapTest test;
FakeFileSource fileSource;
- Map map(test.view, fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleURL("mapbox://styles/test");
EXPECT_EQ(1u, fileSource.requests.size());
@@ -210,7 +218,8 @@ TEST(Map, StyleEarlyMutation) {
MapTest test;
FakeFileSource fileSource;
- Map map(test.view, fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleURL("mapbox://styles/test");
map.addLayer(std::make_unique<style::BackgroundLayer>("bg"));
@@ -224,11 +233,12 @@ TEST(Map, StyleEarlyMutation) {
TEST(Map, StyleLoadedSignal) {
MapTest test;
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
-
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
+
// The map should emit a signal on style loaded
bool emitted = false;
- test.view.setMapChangeCallback([&](MapChange change) {
+ test.backend.setMapChangeCallback([&](MapChange change) {
if (change == mbgl::MapChangeDidFinishLoadingStyle) {
emitted = true;
}
@@ -245,7 +255,8 @@ TEST(Map, StyleLoadedSignal) {
TEST(Map, AddLayer) {
MapTest test;
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
auto layer = std::make_unique<BackgroundLayer>("background");
@@ -258,7 +269,8 @@ TEST(Map, AddLayer) {
TEST(Map, RemoveLayer) {
MapTest test;
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
auto layer = std::make_unique<BackgroundLayer>("background");
@@ -283,7 +295,8 @@ TEST(Map, DisabledSources) {
return {};
};
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
map.setZoom(1);
// This stylesheet has two raster layers, one that starts at zoom 1, the other at zoom 0.
@@ -333,7 +346,8 @@ TEST(Map, DisabledSources) {
TEST(Map, Classes) {
MapTest test;
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
EXPECT_FALSE(map.getTransitionOptions().duration);
@@ -367,7 +381,8 @@ TEST(Map, Classes) {
TEST(Map, AddImage) {
MapTest test;
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
auto decoded1 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
auto decoded2 = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
auto image1 = std::make_unique<SpriteImage>(std::move(decoded1), 1.0);
@@ -384,7 +399,8 @@ TEST(Map, AddImage) {
TEST(Map, RemoveImage) {
MapTest test;
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
auto image = std::make_unique<SpriteImage>(std::move(decoded), 1.0);
diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp
index e2ace99c41..2ab3a03799 100644
--- a/test/util/memory.test.cpp
+++ b/test/util/memory.test.cpp
@@ -2,7 +2,7 @@
#include <mbgl/test/util.hpp>
#include <mbgl/map/map.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/platform/default/headless_backend.hpp>
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/platform/default/thread_pool.hpp>
#include <mbgl/util/io.hpp>
@@ -56,8 +56,8 @@ public:
}
util::RunLoop runLoop;
- std::shared_ptr<HeadlessDisplay> display { std::make_shared<mbgl::HeadlessDisplay>() };
- HeadlessView view { display, 2 };
+ HeadlessBackend backend;
+ HeadlessView view{ 2 };
StubFileSource fileSource;
ThreadPool threadPool { 4 };
@@ -93,7 +93,8 @@ private:
TEST(Memory, Vector) {
MemoryTest test;
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
map.setZoom(16); // more map features
map.setStyleURL("mapbox://streets");
@@ -103,7 +104,8 @@ TEST(Memory, Vector) {
TEST(Memory, Raster) {
MemoryTest test;
- Map map(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource, test.threadPool,
+ MapMode::Still);
map.setStyleURL("mapbox://satellite");
test::render(map);
@@ -130,7 +132,8 @@ TEST(Memory, Footprint) {
// Warm up buffers and cache.
for (unsigned i = 0; i < 10; ++i) {
- Map map(test.view, test.fileSource,test.threadPool, MapMode::Still);
+ Map map(test.backend, test.view, test.view.getPixelRatio(), test.fileSource,
+ test.threadPool, MapMode::Still);
renderMap(&map, "mapbox://streets");
renderMap(&map, "mapbox://satellite");
};
@@ -144,7 +147,8 @@ TEST(Memory, Footprint) {
long vectorInitialRSS = getRSS();
for (unsigned i = 0; i < runs; ++i) {
- auto vector = std::make_unique<Map>(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ auto vector = std::make_unique<Map>(test.backend, test.view, test.view.getPixelRatio(),
+ test.fileSource, test.threadPool, MapMode::Still);
renderMap(vector.get(), "mapbox://streets");
maps.push_back(std::move(vector));
};
@@ -153,7 +157,8 @@ TEST(Memory, Footprint) {
long rasterInitialRSS = getRSS();
for (unsigned i = 0; i < runs; ++i) {
- auto raster = std::make_unique<Map>(test.view, test.fileSource, test.threadPool, MapMode::Still);
+ auto raster = std::make_unique<Map>(test.backend, test.view, test.view.getPixelRatio(),
+ test.fileSource, test.threadPool, MapMode::Still);
renderMap(raster.get(), "mapbox://satellite");
maps.push_back(std::move(raster));
};
diff --git a/test/util/offscreen_texture.test.cpp b/test/util/offscreen_texture.test.cpp
index 301fc2c250..e281a3d65b 100644
--- a/test/util/offscreen_texture.test.cpp
+++ b/test/util/offscreen_texture.test.cpp
@@ -1,15 +1,18 @@
#include <mbgl/test/util.hpp>
#include <mbgl/gl/context.hpp>
+#include <mbgl/platform/default/headless_backend.hpp>
#include <mbgl/platform/default/headless_view.hpp>
+#include <mbgl/gl/gl.hpp>
#include <mbgl/util/offscreen_texture.hpp>
using namespace mbgl;
TEST(OffscreenTexture, EmptyRed) {
+ HeadlessBackend backend;
HeadlessView view(1.0f, 512, 256);
- view.activate();
+ view.bind();
MBGL_CHECK_ERROR(glClearColor(1.0f, 0.0f, 0.0f, 1.0f));
MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT));
@@ -64,11 +67,11 @@ struct Buffer {
TEST(OffscreenTexture, RenderToTexture) {
+ HeadlessBackend backend;
HeadlessView view(1.0f, 512, 256);
- view.activate();
+ view.bind();
gl::Context context;
context.viewport.setDefaultValue(gl::value::Viewport::Get());
- context.bindFramebuffer.setDefaultValue(gl::value::BindFramebuffer::Get());
MBGL_CHECK_ERROR(glEnable(GL_BLEND));
MBGL_CHECK_ERROR(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
@@ -130,6 +133,8 @@ void main() {
// Now reset the FBO back to normal and retrieve the original (restored) framebuffer.
context.resetState();
+ context.bindFramebuffer.setDirty();
+ view.bind();
image = view.readStillImage();
test::checkImage("test/fixtures/offscreen_texture/render-to-fbo", image, 0, 0);