summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-04-02 16:34:32 +0200
committerKonstantin Käfer <mail@kkaefer.com>2019-04-05 11:49:17 +0200
commit5cc3d7a73328d6df9c16d27d6aca5b49ba085351 (patch)
tree0e8b9d6938846bf12ea63b1568c96852501a68cc /src
parent4053776c27cde354acc36c27120c54427087721b (diff)
downloadqtlocation-mapboxgl-5cc3d7a73328d6df9c16d27d6aca5b49ba085351.tar.gz
[core] move GLContextMode to RendererBackend
Diffstat (limited to 'src')
-rw-r--r--src/core-files.json1
-rw-r--r--src/mbgl/gfx/renderer_backend.cpp4
-rw-r--r--src/mbgl/gl/renderer_backend.cpp4
-rw-r--r--src/mbgl/renderer/paint_parameters.cpp2
-rw-r--r--src/mbgl/renderer/paint_parameters.hpp3
-rw-r--r--src/mbgl/renderer/renderer.cpp8
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp12
-rw-r--r--src/mbgl/renderer/renderer_impl.hpp9
8 files changed, 19 insertions, 24 deletions
diff --git a/src/core-files.json b/src/core-files.json
index 23ccc6d631..08a6aa4aac 100644
--- a/src/core-files.json
+++ b/src/core-files.json
@@ -352,7 +352,6 @@
"mbgl/math/minmax.hpp": "include/mbgl/math/minmax.hpp",
"mbgl/math/wrap.hpp": "include/mbgl/math/wrap.hpp",
"mbgl/platform/gl_functions.hpp": "include/mbgl/platform/gl_functions.hpp",
- "mbgl/renderer/mode.hpp": "include/mbgl/renderer/mode.hpp",
"mbgl/renderer/query.hpp": "include/mbgl/renderer/query.hpp",
"mbgl/renderer/renderer.hpp": "include/mbgl/renderer/renderer.hpp",
"mbgl/renderer/renderer_frontend.hpp": "include/mbgl/renderer/renderer_frontend.hpp",
diff --git a/src/mbgl/gfx/renderer_backend.cpp b/src/mbgl/gfx/renderer_backend.cpp
index f0336f8b60..e6fe0c0b24 100644
--- a/src/mbgl/gfx/renderer_backend.cpp
+++ b/src/mbgl/gfx/renderer_backend.cpp
@@ -5,8 +5,8 @@
namespace mbgl {
namespace gfx {
-RendererBackend::RendererBackend() = default;
-
+RendererBackend::RendererBackend(const ContextMode contextMode_) : contextMode(contextMode_) {
+}
RendererBackend::~RendererBackend() = default;
gfx::Context& RendererBackend::getContext() {
diff --git a/src/mbgl/gl/renderer_backend.cpp b/src/mbgl/gl/renderer_backend.cpp
index ed3f38193f..9da6ceb589 100644
--- a/src/mbgl/gl/renderer_backend.cpp
+++ b/src/mbgl/gl/renderer_backend.cpp
@@ -8,7 +8,9 @@
namespace mbgl {
namespace gl {
-RendererBackend::RendererBackend() = default;
+RendererBackend::RendererBackend(const gfx::ContextMode contextMode_)
+ : gfx::RendererBackend(contextMode_) {
+}
std::unique_ptr<gfx::Context> RendererBackend::createContext() {
auto result = std::make_unique<gl::Context>(*this);
diff --git a/src/mbgl/renderer/paint_parameters.cpp b/src/mbgl/renderer/paint_parameters.cpp
index c162beaf61..51e85dd91b 100644
--- a/src/mbgl/renderer/paint_parameters.cpp
+++ b/src/mbgl/renderer/paint_parameters.cpp
@@ -8,7 +8,6 @@ namespace mbgl {
PaintParameters::PaintParameters(gfx::Context& context_,
float pixelRatio_,
- GLContextMode contextMode_,
gfx::RendererBackend& backend_,
const UpdateParameters& updateParameters,
const EvaluatedLight& evaluatedLight_,
@@ -26,7 +25,6 @@ PaintParameters::PaintParameters(gfx::Context& context_,
lineAtlas(lineAtlas_),
mapMode(updateParameters.mode),
debugOptions(updateParameters.debugOptions),
- contextMode(contextMode_),
timePoint(updateParameters.timePoint),
pixelRatio(pixelRatio_),
variableOffsets(variableOffsets_),
diff --git a/src/mbgl/renderer/paint_parameters.hpp b/src/mbgl/renderer/paint_parameters.hpp
index 1329a14404..7b0f941d23 100644
--- a/src/mbgl/renderer/paint_parameters.hpp
+++ b/src/mbgl/renderer/paint_parameters.hpp
@@ -2,7 +2,6 @@
#include <mbgl/renderer/render_pass.hpp>
#include <mbgl/renderer/render_light.hpp>
-#include <mbgl/renderer/mode.hpp>
#include <mbgl/map/mode.hpp>
#include <mbgl/gfx/depth_mode.hpp>
#include <mbgl/gfx/stencil_mode.hpp>
@@ -33,7 +32,6 @@ class PaintParameters {
public:
PaintParameters(gfx::Context&,
float pixelRatio,
- GLContextMode,
gfx::RendererBackend&,
const UpdateParameters&,
const EvaluatedLight&,
@@ -57,7 +55,6 @@ public:
RenderPass pass = RenderPass::Opaque;
MapMode mapMode;
MapDebugOptions debugOptions;
- GLContextMode contextMode;
TimePoint timePoint;
float pixelRatio;
diff --git a/src/mbgl/renderer/renderer.cpp b/src/mbgl/renderer/renderer.cpp
index b70d25dd86..1c6d937237 100644
--- a/src/mbgl/renderer/renderer.cpp
+++ b/src/mbgl/renderer/renderer.cpp
@@ -10,11 +10,13 @@ namespace mbgl {
Renderer::Renderer(gfx::RendererBackend& backend,
float pixelRatio_,
Scheduler& scheduler_,
- GLContextMode contextMode_,
const optional<std::string> programCacheDir_,
const optional<std::string> localFontFamily_)
- : impl(std::make_unique<Impl>(backend, pixelRatio_, scheduler_,
- contextMode_, std::move(programCacheDir_), std::move(localFontFamily_))) {
+ : impl(std::make_unique<Impl>(backend,
+ pixelRatio_,
+ scheduler_,
+ std::move(programCacheDir_),
+ std::move(localFontFamily_))) {
}
Renderer::~Renderer() {
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index 2f97e4fc33..9352fae471 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -40,13 +40,11 @@ static RendererObserver& nullObserver() {
Renderer::Impl::Impl(gfx::RendererBackend& backend_,
float pixelRatio_,
Scheduler& scheduler_,
- GLContextMode contextMode_,
const optional<std::string> programCacheDir_,
const optional<std::string> localFontFamily_)
: backend(backend_)
, scheduler(scheduler_)
, observer(&nullObserver())
- , contextMode(contextMode_)
, pixelRatio(pixelRatio_)
, programCacheDir(std::move(programCacheDir_))
, localFontFamily(std::move(localFontFamily_))
@@ -267,9 +265,8 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
}
// Handle layers without source.
- if (layerNeedsRendering && sourceImpl.get() == sourceImpls->at(0).get()) {
- if (contextMode == GLContextMode::Unique
- && layerImpl.get() == layerImpls->at(0).get()) {
+ if (layerNeedsRendering && sourceImpl.get() == sourceImpls->at(0).get()) {
+ if (!backend.contextIsShared() && layerImpl.get() == layerImpls->at(0).get()) {
const auto& solidBackground = layer->getSolidBackground();
if (solidBackground) {
backgroundColor = *solidBackground;
@@ -358,7 +355,6 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
PaintParameters parameters {
backend.getContext(),
pixelRatio,
- contextMode,
backend,
updateParameters,
renderLight.getEvaluated(),
@@ -373,7 +369,7 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
// TODO: remove cast
gl::Context& glContext = static_cast<gl::Context&>(parameters.context);
- if (parameters.contextMode == GLContextMode::Shared) {
+ if (backend.contextIsShared()) {
glContext.setDirtyState();
}
@@ -428,7 +424,7 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
parameters.backend.getDefaultRenderable().getResource<gl::RenderableResource>().bind();
if (parameters.debugOptions & MapDebugOptions::Overdraw) {
glContext.clear(Color::black(), ClearDepth::Default, ClearStencil::Default);
- } else if (parameters.contextMode == GLContextMode::Shared) {
+ } else if (backend.contextIsShared()) {
glContext.clear({}, ClearDepth::Default, ClearStencil::Default);
} else {
glContext.clear(backgroundColor, ClearDepth::Default, ClearStencil::Default);
diff --git a/src/mbgl/renderer/renderer_impl.hpp b/src/mbgl/renderer/renderer_impl.hpp
index c8ee939e7a..dc692fb8ce 100644
--- a/src/mbgl/renderer/renderer_impl.hpp
+++ b/src/mbgl/renderer/renderer_impl.hpp
@@ -1,6 +1,5 @@
#pragma once
-#include <mbgl/renderer/mode.hpp>
#include <mbgl/renderer/renderer.hpp>
#include <mbgl/renderer/render_source_observer.hpp>
#include <mbgl/renderer/render_light.hpp>
@@ -41,8 +40,11 @@ class Renderer::Impl : public GlyphManagerObserver,
public ImageManagerObserver,
public RenderSourceObserver{
public:
- Impl(gfx::RendererBackend&, float pixelRatio_, Scheduler&, GLContextMode,
- const optional<std::string> programCacheDir, const optional<std::string> localFontFamily_);
+ Impl(gfx::RendererBackend&,
+ float pixelRatio_,
+ Scheduler&,
+ const optional<std::string> programCacheDir,
+ const optional<std::string> localFontFamily_);
~Impl() final;
void markContextLost() {
@@ -103,7 +105,6 @@ private:
RendererObserver* observer;
- const GLContextMode contextMode;
const float pixelRatio;
const optional<std::string> programCacheDir;
const optional<std::string> localFontFamily;