summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/layers
diff options
context:
space:
mode:
authorThomas Moenicke <thomas.moenicke@mapbox.com>2020-02-03 19:10:57 +0200
committerGitHub <noreply@github.com>2020-02-03 19:10:57 +0200
commitb64ed754442b894f3914a4191798fbd2f2bc8cd9 (patch)
tree59bb14829d7cdd5f2466dad4cffb74c4d1b80068 /src/mbgl/renderer/layers
parent2e10d3548a8b3aff1f28b9514594c3c14509f084 (diff)
downloadqtlocation-mapboxgl-b64ed754442b894f3914a4191798fbd2f2bc8cd9.tar.gz
[build] Adding a build flag to build without GL if needed (#16120)
* [build] Adding a build flag to build without GL if needed * [build] Moving custom layer to mbgl/gl
Diffstat (limited to 'src/mbgl/renderer/layers')
-rw-r--r--src/mbgl/renderer/layers/render_custom_layer.cpp104
-rw-r--r--src/mbgl/renderer/layers/render_custom_layer.hpp27
2 files changed, 0 insertions, 131 deletions
diff --git a/src/mbgl/renderer/layers/render_custom_layer.cpp b/src/mbgl/renderer/layers/render_custom_layer.cpp
deleted file mode 100644
index c53286a2a0..0000000000
--- a/src/mbgl/renderer/layers/render_custom_layer.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-#include <mbgl/renderer/layers/render_custom_layer.hpp>
-#include <mbgl/renderer/paint_parameters.hpp>
-#include <mbgl/gfx/renderer_backend.hpp>
-#include <mbgl/gfx/backend_scope.hpp>
-#include <mbgl/renderer/bucket.hpp>
-#include <mbgl/platform/gl_functions.hpp>
-#include <mbgl/style/layers/custom_layer_impl.hpp>
-#include <mbgl/map/transform_state.hpp>
-#include <mbgl/gl/context.hpp>
-#include <mbgl/gl/renderable_resource.hpp>
-#include <mbgl/util/mat4.hpp>
-
-namespace mbgl {
-
-using namespace style;
-
-namespace {
-
-inline const CustomLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
- assert(impl->getTypeInfo() == CustomLayer::Impl::staticTypeInfo());
- return static_cast<const CustomLayer::Impl&>(*impl);
-}
-
-} // namespace
-
-RenderCustomLayer::RenderCustomLayer(Immutable<style::CustomLayer::Impl> _impl)
- : RenderLayer(makeMutable<CustomLayerProperties>(std::move(_impl))),
- host(impl(baseImpl).host) {
- assert(gfx::BackendScope::exists());
- MBGL_CHECK_ERROR(host->initialize());
-}
-
-RenderCustomLayer::~RenderCustomLayer() {
- assert(gfx::BackendScope::exists());
- if (contextDestroyed) {
- host->contextLost();
- } else {
- MBGL_CHECK_ERROR(host->deinitialize());
- }
-}
-
-void RenderCustomLayer::evaluate(const PropertyEvaluationParameters&) {
- passes = RenderPass::Translucent;
- // It is fine to not update `evaluatedProperties`, as `baseImpl` should never be updated for this layer.
-}
-
-bool RenderCustomLayer::hasTransition() const {
- return false;
-}
-bool RenderCustomLayer::hasCrossfade() const {
- return false;
-}
-
-void RenderCustomLayer::markContextDestroyed() {
- contextDestroyed = true;
-}
-
-void RenderCustomLayer::prepare(const LayerPrepareParameters&) {
-}
-
-void RenderCustomLayer::render(PaintParameters& paintParameters) {
- if (host != impl(baseImpl).host) {
- //If the context changed, deinitialize the previous one before initializing the new one.
- if (host && !contextDestroyed) {
- MBGL_CHECK_ERROR(host->deinitialize());
- }
- host = impl(baseImpl).host;
- MBGL_CHECK_ERROR(host->initialize());
- }
-
- // TODO: remove cast
- auto& glContext = static_cast<gl::Context&>(paintParameters.context);
- const TransformState& state = paintParameters.state;
-
- // Reset GL state to a known state so the CustomLayer always has a clean slate.
- glContext.bindVertexArray = 0;
- glContext.setDepthMode(paintParameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly));
- glContext.setStencilMode(gfx::StencilMode::disabled());
- glContext.setColorMode(paintParameters.colorModeForRenderPass());
- glContext.setCullFaceMode(gfx::CullFaceMode::disabled());
-
- CustomLayerRenderParameters parameters;
-
- parameters.width = state.getSize().width;
- parameters.height = state.getSize().height;
- parameters.latitude = state.getLatLng().latitude();
- parameters.longitude = state.getLatLng().longitude();
- parameters.zoom = state.getZoom();
- parameters.bearing = -state.getBearing() * util::RAD2DEG;
- parameters.pitch = state.getPitch();
- parameters.fieldOfView = state.getFieldOfView();
- mat4 projMatrix;
- state.getProjMatrix(projMatrix);
- parameters.projectionMatrix = projMatrix;
-
- MBGL_CHECK_ERROR(host->render(parameters));
-
- // Reset the view back to our original one, just in case the CustomLayer changed
- // the viewport or Framebuffer.
- paintParameters.backend.getDefaultRenderable().getResource<gl::RenderableResource>().bind();
- glContext.setDirtyState();
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/renderer/layers/render_custom_layer.hpp b/src/mbgl/renderer/layers/render_custom_layer.hpp
deleted file mode 100644
index 698621eae6..0000000000
--- a/src/mbgl/renderer/layers/render_custom_layer.hpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include <mbgl/renderer/render_layer.hpp>
-#include <mbgl/style/layers/custom_layer_impl.hpp>
-
-namespace mbgl {
-
-class RenderCustomLayer final : public RenderLayer {
-public:
- explicit RenderCustomLayer(Immutable<style::CustomLayer::Impl>);
- ~RenderCustomLayer() override;
-
-private:
- void transition(const TransitionParameters&) override {}
- void evaluate(const PropertyEvaluationParameters&) override;
- bool hasTransition() const override;
- bool hasCrossfade() const override;
- void markContextDestroyed() override;
- void prepare(const LayerPrepareParameters&) override;
-
- void render(PaintParameters&) override;
-
- bool contextDestroyed = false;
- std::shared_ptr<style::CustomLayerHost> host;
-};
-
-} // namespace mbgl