[core] separate Backend from View for headless rendering

This commit is contained in:
Konstantin Käfer
2016-10-06 13:23:50 +02:00
parent 45f4dc0166
commit 5cc390d694
54 changed files with 779 additions and 525 deletions

View File

@@ -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);