-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use drawables for location indicator layer (#2836)
Co-authored-by: Bart Louwers <[email protected]>
- Loading branch information
1 parent
37bc023
commit 156872f
Showing
22 changed files
with
847 additions
and
76 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
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
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,20 @@ | ||
#pragma once | ||
|
||
#include <mbgl/shaders/layer_ubo.hpp> | ||
|
||
namespace mbgl { | ||
namespace shaders { | ||
|
||
struct alignas(16) CommonUBO { | ||
std::array<float, 4 * 4> matrix; | ||
Color color; | ||
}; | ||
static_assert(sizeof(CommonUBO) % 16 == 0); | ||
|
||
enum { | ||
idCommonUBO = globalUBOCount, | ||
commonUBOCount | ||
}; | ||
|
||
} // namespace shaders | ||
} // 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
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
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 |
---|---|---|
|
@@ -48,4 +48,4 @@ task unzip(dependsOn: download, type: Copy) { | |
|
||
android.sourceSets.vulkan.jniLibs { | ||
srcDir(tasks.unzip) | ||
} | ||
} |
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
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
59 changes: 59 additions & 0 deletions
59
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,59 @@ | ||
#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 |
Oops, something went wrong.