squashed stylequest merge
* uses OSM Bright style * adds dot shader * adds layer translation * adds dashed line support * adds style array parsing * improves background layer parsing * improves style constant parsing * fixes sprite JSON pixel ratio parsing
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <llmr/shader/point_shader.hpp>
|
||||
#include <llmr/shader/raster_shader.hpp>
|
||||
#include <llmr/shader/text_shader.hpp>
|
||||
#include <llmr/shader/dot_shader.hpp>
|
||||
|
||||
#include <llmr/map/transform_state.hpp>
|
||||
|
||||
@@ -62,6 +63,7 @@ private:
|
||||
void setupShaders();
|
||||
void renderLayers(const std::shared_ptr<TileData>& tile, const std::vector<LayerDescription>& layers);
|
||||
void renderLayer(const std::shared_ptr<TileData>& tile_data, const LayerDescription& layer_desc);
|
||||
void translateLayer(std::array<float, 2> translation, bool reverse = false);
|
||||
void renderDebug(const std::shared_ptr<TileData>& tile);
|
||||
|
||||
void useProgram(uint32_t program);
|
||||
@@ -97,6 +99,7 @@ private:
|
||||
std::unique_ptr<PointShader> pointShader;
|
||||
std::unique_ptr<RasterShader> rasterShader;
|
||||
std::unique_ptr<TextShader> textShader;
|
||||
std::unique_ptr<DotShader> dotShader;
|
||||
|
||||
// Set up the stencil quad we're using to generate the stencil mask.
|
||||
VertexBuffer tileStencilBuffer = {
|
||||
|
||||
@@ -19,6 +19,7 @@ class Style;
|
||||
class PointVertexBuffer;
|
||||
class BucketDescription;
|
||||
class PointShader;
|
||||
class DotShader;
|
||||
struct pbf;
|
||||
|
||||
class PointBucket : public Bucket {
|
||||
@@ -33,6 +34,7 @@ public:
|
||||
bool hasPoints() const;
|
||||
|
||||
void drawPoints(PointShader& shader);
|
||||
void drawPoints(DotShader& shader);
|
||||
|
||||
public:
|
||||
const BucketGeometryDescription geometry;
|
||||
|
||||
33
include/llmr/shader/dot_shader.hpp
Normal file
33
include/llmr/shader/dot_shader.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef LLMR_SHADER_SHADER_DOT
|
||||
#define LLMR_SHADER_SHADER_DOT
|
||||
|
||||
#include <llmr/shader/shader.hpp>
|
||||
|
||||
namespace llmr {
|
||||
|
||||
class DotShader : public Shader {
|
||||
public:
|
||||
DotShader();
|
||||
|
||||
void bind(char *offset);
|
||||
|
||||
void setColor(const std::array<float, 4>& color);
|
||||
void setSize(float size);
|
||||
void setBlur(float blur);
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
|
||||
std::array<float, 4> color = {{}};
|
||||
int32_t u_color = -1;
|
||||
|
||||
float size = 0;
|
||||
int32_t u_size = -1;
|
||||
|
||||
float blur = 0;
|
||||
int32_t u_blur = -1;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
int32_t a_extrude = -1;
|
||||
// int32_t a_linesofar = -1;
|
||||
int32_t a_linesofar = -1;
|
||||
|
||||
std::array<float, 16> exmatrix = {{}};
|
||||
int32_t u_exmatrix = -1;
|
||||
|
||||
@@ -56,38 +56,49 @@ struct FunctionProperty {
|
||||
|
||||
struct PointClass {
|
||||
FunctionProperty enabled = true;
|
||||
std::array<FunctionProperty, 2> translate = {{ 0, 0 }};
|
||||
FunctionProperty size;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
FunctionProperty opacity = 1;
|
||||
std::string image;
|
||||
FunctionProperty radius = 0;
|
||||
FunctionProperty blur = 0;
|
||||
};
|
||||
|
||||
struct PointProperties {
|
||||
bool enabled = true;
|
||||
std::array<float, 2> translate = {{ 0, 0 }};
|
||||
float size = 0;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
float opacity = 1.0;
|
||||
std::string image;
|
||||
float radius = 0;
|
||||
float blur = 0;
|
||||
};
|
||||
|
||||
struct LineClass {
|
||||
FunctionProperty enabled = true;
|
||||
std::array<FunctionProperty, 2> translate = {{ 0, 0 }};
|
||||
FunctionProperty width;
|
||||
FunctionProperty offset;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
std::array<FunctionProperty, 2> dash_array = {{ 1, -1 }};
|
||||
FunctionProperty opacity = 1;
|
||||
};
|
||||
|
||||
struct LineProperties {
|
||||
bool enabled = true;
|
||||
std::array<float, 2> translate = {{ 0, 0 }};
|
||||
float width = 0;
|
||||
float offset = 0;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
std::array<float, 2> dash_array = {{ 1, -1 }};
|
||||
float opacity = 1.0;
|
||||
};
|
||||
|
||||
struct FillClass {
|
||||
FunctionProperty enabled = true;
|
||||
std::array<FunctionProperty, 2> translate = {{ 0, 0 }};
|
||||
Winding winding = Winding::NonZero;
|
||||
FunctionProperty antialias = true;
|
||||
Color fill_color = {{ 0, 0, 0, 1 }};
|
||||
@@ -98,6 +109,7 @@ struct FillClass {
|
||||
|
||||
struct FillProperties {
|
||||
bool enabled = true;
|
||||
std::array<float, 2> translate = {{ 0, 0 }};
|
||||
Winding winding = Winding::NonZero;
|
||||
bool antialias = true;
|
||||
Color fill_color = {{ 0, 0, 0, 1 }};
|
||||
@@ -108,6 +120,7 @@ struct FillProperties {
|
||||
|
||||
struct TextClass {
|
||||
FunctionProperty enabled = true;
|
||||
std::array<FunctionProperty, 2> translate = {{ 0, 0 }};
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
Color halo = {{ 1, 1, 1, 0.75 }};
|
||||
FunctionProperty haloRadius = 0.25f;
|
||||
@@ -118,6 +131,7 @@ struct TextClass {
|
||||
|
||||
struct TextProperties {
|
||||
bool enabled = true;
|
||||
std::array<float, 2> translate = {{ 0, 0 }};
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
Color halo = {{ 1, 1, 1, 0.75 }};
|
||||
float haloRadius = 0.25f;
|
||||
@@ -138,11 +152,13 @@ struct BackgroundProperties {
|
||||
|
||||
struct RasterClass {
|
||||
FunctionProperty enabled = true;
|
||||
std::array<FunctionProperty, 2> translate = {{ 0, 0 }};
|
||||
FunctionProperty opacity = 1;
|
||||
};
|
||||
|
||||
struct RasterProperties {
|
||||
bool enabled = true;
|
||||
std::array<float, 2> translate = {{ 0, 0 }};
|
||||
float opacity = 1.0;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ public:
|
||||
void parseBuckets(JSVal value, std::map<std::string, BucketDescription>& buckets);
|
||||
void parseLayers(JSVal value, std::vector<LayerDescription>& layers);
|
||||
void parseConstants(JSVal value);
|
||||
void parseClasses(JSVal value, std::map<std::string, ClassDescription>& classes);
|
||||
void parseClasses(JSVal value, std::map<std::string, ClassDescription>& classes, std::map<std::string, BucketDescription>& buckets, std::vector<LayerDescription>& layers);
|
||||
|
||||
private:
|
||||
LayerDescription parseLayer(JSVal value);
|
||||
BucketDescription parseBucket(JSVal value);
|
||||
std::pair<std::string, ClassDescription> parseClassDescription(JSVal value);
|
||||
void parseClass(const std::string& name, JSVal value, ClassDescription& class_desc);
|
||||
std::pair<std::string, ClassDescription> parseClassDescription(JSVal value, std::map<std::string, BucketDescription>& buckets, std::vector<LayerDescription>& layers);
|
||||
void parseClass(const std::string& name, JSVal value, ClassDescription& class_desc, std::map<std::string, BucketDescription>& buckets, std::vector<LayerDescription>& layers);
|
||||
FillClass parseFillClass(JSVal value);
|
||||
LineClass parseLineClass(JSVal value);
|
||||
PointClass parsePointClass(JSVal value);
|
||||
@@ -29,6 +29,8 @@ private:
|
||||
|
||||
bool parseBoolean(JSVal value);
|
||||
std::string parseString(JSVal value);
|
||||
const JSVal& replaceConstant(const JSVal& value);
|
||||
std::vector<FunctionProperty> parseArray(JSVal value, uint16_t expected_count);
|
||||
Color parseColor(JSVal value);
|
||||
Value parseValue(JSVal value);
|
||||
FunctionProperty::fn parseFunctionType(JSVal type);
|
||||
|
||||
Reference in New Issue
Block a user