diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-05-04 19:21:08 +0300 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-05-08 19:39:55 +0300 |
commit | 6fd40867d67eb3758c0eb8eca184ed9d7b9da5b0 (patch) | |
tree | 36fede4f7dfeb01a6835f53a185dad47f3153481 /src/mbgl/style/style.cpp | |
parent | feae5e22ee4910a1508f2120c8131b2f8531bae8 (diff) | |
download | qtlocation-mapboxgl-6fd40867d67eb3758c0eb8eca184ed9d7b9da5b0.tar.gz |
[core] delegate light changes to render light
Diffstat (limited to 'src/mbgl/style/style.cpp')
-rw-r--r-- | src/mbgl/style/style.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 080911b746..4b694917c3 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -59,10 +59,11 @@ Style::Style(Scheduler& scheduler_, FileSource& fileSource_, float pixelRatio) spriteAtlas(std::make_unique<SpriteAtlas>(Size{ 1024, 1024 }, pixelRatio)), lineAtlas(std::make_unique<LineAtlas>(Size{ 256, 512 })), light(std::make_unique<Light>()), - renderLight(std::make_unique<RenderLight>(*light)), + renderLight(std::make_unique<RenderLight>(light->impl)), observer(&nullObserver) { glyphAtlas->setObserver(this); spriteAtlas->setObserver(this); + light->impl->setObserver(this); } Style::~Style() { @@ -78,6 +79,7 @@ Style::~Style() { glyphAtlas->setObserver(nullptr); spriteAtlas->setObserver(nullptr); + light->impl->setObserver(nullptr); } bool Style::addClass(const std::string& className) { @@ -313,7 +315,13 @@ void Style::removeRenderLayer(const std::string& id) { void Style::setLight(std::unique_ptr<Light> light_) { light = std::move(light_); - renderLight = std::make_unique<RenderLight>(*light); + light->impl->setObserver(this); + + // Copy renderlight to preserve the initialised + // transitioning light properties + renderLight = renderLight->copy(light->impl); + + onLightChanged(*light); } Light* Style::getLight() const { @@ -761,6 +769,10 @@ void Style::onLayerLayoutPropertyChanged(Layer& layer, const char * property) { : Update::Repaint); } +void Style::onLightChanged(const Light&) { + observer->onUpdate(Update::Classes | Update::RecalculateStyle); +} + void Style::dumpDebugLogs() const { for (const auto& source : sources) { source->baseImpl->dumpDebugLogs(); |