diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-04-01 16:56:24 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-04-05 11:49:17 +0200 |
commit | 66c020034e8260e5e071481e68ab61cd264723ba (patch) | |
tree | b5263772d72175474d91ce2daa9dc037b99fab0d /test | |
parent | a782a6d15b80dd83105604f3f779f6c83ba222e5 (diff) | |
download | qtlocation-mapboxgl-66c020034e8260e5e071481e68ab61cd264723ba.tar.gz |
[core] refactor RendererBackend
Diffstat (limited to 'test')
-rw-r--r-- | test/gl/bucket.test.cpp | 20 | ||||
-rw-r--r-- | test/gl/context.test.cpp | 3 | ||||
-rw-r--r-- | test/gl/object.test.cpp | 4 | ||||
-rw-r--r-- | test/map/map.test.cpp | 2 | ||||
-rw-r--r-- | test/renderer/backend_scope.test.cpp | 19 | ||||
-rw-r--r-- | test/util/offscreen_texture.test.cpp | 16 |
6 files changed, 32 insertions, 32 deletions
diff --git a/test/gl/bucket.test.cpp b/test/gl/bucket.test.cpp index 48cdc1c0f5..277d988f9e 100644 --- a/test/gl/bucket.test.cpp +++ b/test/gl/bucket.test.cpp @@ -43,10 +43,10 @@ PropertyMap properties; } // namespace TEST(Buckets, CircleBucket) { - HeadlessBackend backend({ 512, 256 }); + gl::HeadlessBackend backend({ 512, 256 }); gfx::BackendScope scope { backend }; - gl::Context context; + gl::Context context{ backend }; CircleBucket bucket { { {0, 0, 0}, MapMode::Static, 1.0, nullptr }, {} }; ASSERT_FALSE(bucket.hasData()); ASSERT_FALSE(bucket.needsUpload()); @@ -62,11 +62,11 @@ TEST(Buckets, CircleBucket) { } TEST(Buckets, FillBucket) { - HeadlessBackend backend({ 512, 256 }); + gl::HeadlessBackend backend({ 512, 256 }); gfx::BackendScope scope { backend }; style::Properties<>::PossiblyEvaluated layout; - gl::Context context; + gl::Context context{ backend }; FillBucket bucket { layout, {}, 5.0f, 1}; ASSERT_FALSE(bucket.hasData()); ASSERT_FALSE(bucket.needsUpload()); @@ -81,11 +81,11 @@ TEST(Buckets, FillBucket) { } TEST(Buckets, LineBucket) { - HeadlessBackend backend({ 512, 256 }); + gl::HeadlessBackend backend({ 512, 256 }); gfx::BackendScope scope { backend }; style::LineLayoutProperties::PossiblyEvaluated layout; - gl::Context context; + gl::Context context{ backend }; LineBucket bucket { layout, {}, 10.0f, 1 }; ASSERT_FALSE(bucket.hasData()); ASSERT_FALSE(bucket.needsUpload()); @@ -105,7 +105,7 @@ TEST(Buckets, LineBucket) { } TEST(Buckets, SymbolBucket) { - HeadlessBackend backend({ 512, 256 }); + gl::HeadlessBackend backend({ 512, 256 }); gfx::BackendScope scope { backend }; style::SymbolLayoutProperties::PossiblyEvaluated layout; @@ -115,7 +115,7 @@ TEST(Buckets, SymbolBucket) { std::string bucketLeaderID = "test"; std::vector<SymbolInstance> symbolInstances; - gl::Context context; + gl::Context context{ backend }; SymbolBucket bucket { layout, {}, 16.0f, 1.0f, 0, sdfIcons, iconsNeedLinear, sortFeaturesByY, bucketLeaderID, std::move(symbolInstances), 1.0f }; ASSERT_FALSE(bucket.hasIconData()); ASSERT_FALSE(bucket.hasTextData()); @@ -139,10 +139,10 @@ TEST(Buckets, SymbolBucket) { } TEST(Buckets, RasterBucket) { - HeadlessBackend backend({ 512, 256 }); + gl::HeadlessBackend backend({ 512, 256 }); gfx::BackendScope scope { backend }; - gl::Context context; + gl::Context context{ backend }; PremultipliedImage rgba({ 1, 1 }); // RasterBucket::hasData() is always true. diff --git a/test/gl/context.test.cpp b/test/gl/context.test.cpp index 14f7cd3a13..4e41af55d1 100644 --- a/test/gl/context.test.cpp +++ b/test/gl/context.test.cpp @@ -8,6 +8,7 @@ #include <mbgl/gfx/backend_scope.hpp> #include <mbgl/gl/defines.hpp> #include <mbgl/gl/headless_frontend.hpp> +#include <mbgl/gl/renderable_resource.hpp> #include <mbgl/storage/resource_options.hpp> #include <mbgl/style/style.hpp> #include <mbgl/style/layers/custom_layer.hpp> @@ -104,8 +105,8 @@ TEST(GLContextMode, Shared) { { // Custom rendering outside of GL Native render loop. - frontend.getBackend()->bind(); gfx::BackendScope scope { *frontend.getBackend() }; + frontend.getBackend()->getDefaultRenderable().getResource<gl::RenderableResource>().bind(); Shader paintShader(vertexShaderSource, fragmentShaderSource); Buffer triangleBuffer({ 0, 0.5, 0.5, -0.5, -0.5, -0.5 }); diff --git a/test/gl/object.test.cpp b/test/gl/object.test.cpp index 5441c4c335..2e53b12a80 100644 --- a/test/gl/object.test.cpp +++ b/test/gl/object.test.cpp @@ -45,10 +45,10 @@ TEST(GLObject, Value) { } TEST(GLObject, Store) { - HeadlessBackend backend { { 256, 256 } }; + gl::HeadlessBackend backend { { 256, 256 } }; gfx::BackendScope scope { backend }; - gl::Context context; + gl::Context context{ backend }; EXPECT_TRUE(context.empty()); gl::UniqueTexture texture = context.createUniqueTexture(); diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 41275df7f0..a2d36b2ca2 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -614,8 +614,8 @@ TEST(Map, AddLayer) { TEST(Map, WithoutVAOExtension) { MapTest<DefaultFileSource> test { ":memory:", "test/fixtures/api/assets" }; - test.frontend.getBackend()->getContext().disableVAOExtension = true; gfx::BackendScope scope { *test.frontend.getBackend() }; + static_cast<gl::Context&>(test.frontend.getBackend()->getContext()).disableVAOExtension = true; test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); diff --git a/test/renderer/backend_scope.test.cpp b/test/renderer/backend_scope.test.cpp index e78c895ac8..f5c43a34a1 100644 --- a/test/renderer/backend_scope.test.cpp +++ b/test/renderer/backend_scope.test.cpp @@ -1,21 +1,14 @@ #include <mbgl/test/util.hpp> -#include <mbgl/renderer/renderer_backend.hpp> +#include <mbgl/gl/renderer_backend.hpp> #include <mbgl/gfx/backend_scope.hpp> #include <functional> using namespace mbgl; -class StubRendererBackend: public RendererBackend { +class StubRendererBackend: public gl::RendererBackend { public: - void bind() override { - } - - mbgl::Size getFramebufferSize() const override { - return mbgl::Size{}; - } - void activate() override { if (activateFunction) activateFunction(); } @@ -29,7 +22,13 @@ public: } gl::ProcAddress getExtensionFunctionPointer(const char*) override { - return {}; + abort(); + return nullptr; + } + + gfx::Renderable& getDefaultRenderable() override { + abort(); + return reinterpret_cast<gfx::Renderable&>(*this); } std::function<void ()> activateFunction; diff --git a/test/util/offscreen_texture.test.cpp b/test/util/offscreen_texture.test.cpp index 91bae66ce3..ef10984364 100644 --- a/test/util/offscreen_texture.test.cpp +++ b/test/util/offscreen_texture.test.cpp @@ -14,14 +14,14 @@ using namespace mbgl; using namespace mbgl::platform; TEST(OffscreenTexture, EmptyRed) { - HeadlessBackend backend({ 512, 256 }); + gl::HeadlessBackend backend({ 512, 256 }); gfx::BackendScope scope { backend }; - // Scissor test shouldn't leak after HeadlessBackend::bind(). + // Scissor test shouldn't leak after gl::HeadlessBackend::bind(). MBGL_CHECK_ERROR(glScissor(64, 64, 128, 128)); - backend.getContext().scissorTest.setCurrentValue(true); + static_cast<gl::Context&>(backend.getContext()).scissorTest.setCurrentValue(true); - backend.bind(); + backend.getDefaultRenderable().getResource<gl::RenderableResource>().bind(); MBGL_CHECK_ERROR(glClearColor(1.0f, 0.0f, 0.0f, 1.0f)); MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT)); @@ -76,9 +76,9 @@ struct Buffer { TEST(OffscreenTexture, RenderToTexture) { - HeadlessBackend backend({ 512, 256 }); - auto& context = backend.getContext(); + gl::HeadlessBackend backend({ 512, 256 }); gfx::BackendScope scope { backend }; + auto& context = static_cast<gl::Context&>(backend.getContext()); MBGL_CHECK_ERROR(glEnable(GL_BLEND)); MBGL_CHECK_ERROR(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); @@ -126,7 +126,7 @@ void main() { Buffer triangleBuffer({ 0, 0.5, 0.5, -0.5, -0.5, -0.5 }); Buffer viewportBuffer({ -1, -1, 1, -1, -1, 1, 1, 1 }); - backend.bind(); + backend.getDefaultRenderable().getResource<gl::RenderableResource>().bind(); // First, draw red to the bound FBO. context.clear(Color::red(), {}, {}); @@ -154,7 +154,7 @@ void main() { test::checkImage("test/fixtures/offscreen_texture/render-to-texture", image, 0, 0); // Now reset the FBO back to normal and retrieve the original (restored) framebuffer. - backend.bind(); + backend.getDefaultRenderable().getResource<gl::RenderableResource>().bind(); image = backend.readStillImage(); test::checkImage("test/fixtures/offscreen_texture/render-to-fbo", image, 0, 0); |