-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31b2207
commit 4744604
Showing
5 changed files
with
121 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/mbgl/renderer/layers/location_indicator_layer_tweaker.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <mbgl/renderer/layers/location_indicator_layer_tweaker.hpp> | ||
|
||
#include <mbgl/renderer/layer_group.hpp> | ||
#include <mbgl/renderer/paint_parameters.hpp> | ||
#include <mbgl/renderer/layers/render_location_indicator_layer.hpp> | ||
#include <mbgl/style/layers/location_indicator_layer_properties.hpp> | ||
|
||
namespace mbgl { | ||
|
||
void LocationIndicatorLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters& params) { | ||
|
||
if (layerGroup.empty()) { | ||
return; | ||
} | ||
|
||
const auto& props = static_cast<const style::LocationIndicatorLayerProperties&>(*evaluatedProperties); | ||
|
||
const shaders::CommonUBO quadUBO = {/* .matrix */ util::cast<float>(projectionPuck), | ||
/* .color */ Color::black()}; | ||
|
||
visitLayerGroupDrawables(layerGroup, [&](gfx::Drawable& drawable) { | ||
auto& drawableUniforms = drawable.mutableUniformBuffers(); | ||
|
||
if (!drawable.getEnabled()) { | ||
return; | ||
} | ||
|
||
switch (static_cast<RenderLocationIndicatorLayer::LocationIndicatorComponentType>(drawable.getType())) { | ||
case RenderLocationIndicatorLayer::LocationIndicatorComponentType::Circle: { | ||
shaders::CommonUBO circleUBO = {/* .matrix */ util::cast<float>(projectionCircle), | ||
/* .color */ props.evaluated.get<style::AccuracyRadiusColor>()}; | ||
|
||
drawableUniforms.createOrUpdate(shaders::idCommonUBO, &circleUBO, params.context); | ||
break; | ||
} | ||
|
||
case RenderLocationIndicatorLayer::LocationIndicatorComponentType::CircleOutline: { | ||
shaders::CommonUBO circleUBO = {/* .matrix */ util::cast<float>(projectionCircle), | ||
/* .color */ props.evaluated.get<style::AccuracyRadiusBorderColor>()}; | ||
|
||
drawableUniforms.createOrUpdate(shaders::idCommonUBO, &circleUBO, params.context); | ||
break; | ||
} | ||
|
||
case RenderLocationIndicatorLayer::LocationIndicatorComponentType::PuckShadow: | ||
[[fallthrough]]; | ||
case RenderLocationIndicatorLayer::LocationIndicatorComponentType::Puck: | ||
[[fallthrough]]; | ||
case RenderLocationIndicatorLayer::LocationIndicatorComponentType::PuckHat: | ||
drawableUniforms.createOrUpdate(shaders::idCommonUBO, &quadUBO, params.context); | ||
break; | ||
|
||
default: | ||
assert(false); | ||
break; | ||
} | ||
}); | ||
} | ||
|
||
} // namespace mbgl |
33 changes: 33 additions & 0 deletions
33
src/mbgl/renderer/layers/location_indicator_layer_tweaker.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include <mbgl/renderer/layer_tweaker.hpp> | ||
#include <mbgl/gfx/uniform_buffer.hpp> | ||
|
||
#include <string> | ||
|
||
namespace mbgl { | ||
|
||
/** | ||
Location indicator layer specific tweaker | ||
*/ | ||
class LocationIndicatorLayerTweaker : public LayerTweaker { | ||
public: | ||
LocationIndicatorLayerTweaker(std::string id_, | ||
Immutable<style::LayerProperties> properties, | ||
const mbgl::mat4& projectionCircle_, | ||
const mbgl::mat4& projectionPuck_) | ||
: LayerTweaker(std::move(id_), properties), | ||
projectionCircle(projectionCircle_), | ||
projectionPuck(projectionPuck_) {} | ||
|
||
public: | ||
~LocationIndicatorLayerTweaker() override = default; | ||
|
||
void execute(LayerGroupBase&, const PaintParameters& params) override; | ||
|
||
private: | ||
const mbgl::mat4& projectionCircle; | ||
const mbgl::mat4& projectionPuck; | ||
}; | ||
|
||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters