rename point => icon
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
#ifndef LLMR_GEOMETRY_POINT_BUFFER
|
||||
#define LLMR_GEOMETRY_POINT_BUFFER
|
||||
#ifndef LLMR_GEOMETRY_ICON_BUFFER
|
||||
#define LLMR_GEOMETRY_ICON_BUFFER
|
||||
|
||||
#include "buffer.hpp"
|
||||
|
||||
namespace llmr {
|
||||
|
||||
class PointVertexBuffer : public Buffer<
|
||||
class IconVertexBuffer : public Buffer<
|
||||
4 // 2 coordinates per vertex (== 4 bytes)
|
||||
> {
|
||||
public:
|
||||
@@ -24,7 +24,7 @@ private:
|
||||
std::unique_ptr<Bucket> createBucket(const BucketDescription& bucket_desc);
|
||||
std::unique_ptr<Bucket> createFillBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc);
|
||||
std::unique_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc);
|
||||
std::unique_ptr<Bucket> createPointBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc);
|
||||
std::unique_ptr<Bucket> createIconBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc);
|
||||
std::unique_ptr<Bucket> createTextBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc);
|
||||
template <class Bucket> void addBucketFeatures(Bucket& bucket, const VectorTileLayer& layer, const BucketDescription& bucket_desc);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <llmr/geometry/elements_buffer.hpp>
|
||||
#include <llmr/geometry/fill_buffer.hpp>
|
||||
#include <llmr/geometry/line_buffer.hpp>
|
||||
#include <llmr/geometry/point_buffer.hpp>
|
||||
#include <llmr/geometry/icon_buffer.hpp>
|
||||
#include <llmr/geometry/text_buffer.hpp>
|
||||
|
||||
#include <map>
|
||||
@@ -33,7 +33,7 @@ protected:
|
||||
// Holds the actual geometries in this tile.
|
||||
FillVertexBuffer fillVertexBuffer;
|
||||
LineVertexBuffer lineVertexBuffer;
|
||||
PointVertexBuffer pointVertexBuffer;
|
||||
IconVertexBuffer iconVertexBuffer;
|
||||
TextVertexBuffer textVertexBuffer;
|
||||
|
||||
TriangleElementsBuffer triangleElementsBuffer;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#ifndef LLMR_RENDERER_POINTBUCKET
|
||||
#define LLMR_RENDERER_POINTBUCKET
|
||||
#ifndef LLMR_RENDERER_ICONBUCKET
|
||||
#define LLMR_RENDERER_ICONBUCKET
|
||||
|
||||
#include <llmr/renderer/bucket.hpp>
|
||||
#include <llmr/style/bucket_description.hpp>
|
||||
#include <llmr/geometry/elements_buffer.hpp>
|
||||
#include <llmr/geometry/point_buffer.hpp>
|
||||
#include <llmr/geometry/icon_buffer.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
@@ -16,15 +16,15 @@
|
||||
namespace llmr {
|
||||
|
||||
class Style;
|
||||
class PointVertexBuffer;
|
||||
class IconVertexBuffer;
|
||||
class BucketDescription;
|
||||
class PointShader;
|
||||
class IconShader;
|
||||
class DotShader;
|
||||
struct pbf;
|
||||
|
||||
class PointBucket : public Bucket {
|
||||
class IconBucket : public Bucket {
|
||||
public:
|
||||
PointBucket(PointVertexBuffer& vertexBuffer,
|
||||
IconBucket(IconVertexBuffer& vertexBuffer,
|
||||
const BucketDescription& bucket_desc);
|
||||
|
||||
virtual void render(Painter& painter, const std::string& layer_name, const Tile::ID& id);
|
||||
@@ -32,15 +32,15 @@ public:
|
||||
|
||||
void addGeometry(pbf& data);
|
||||
|
||||
void drawPoints(PointShader& shader);
|
||||
void drawPoints(DotShader& shader);
|
||||
void drawIcons(IconShader& shader);
|
||||
void drawIcons(DotShader& shader);
|
||||
|
||||
public:
|
||||
const BucketGeometryDescription geometry;
|
||||
|
||||
private:
|
||||
|
||||
PointVertexBuffer& vertexBuffer;
|
||||
IconVertexBuffer& vertexBuffer;
|
||||
VertexArrayObject array;
|
||||
|
||||
const size_t vertex_start;
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <llmr/shader/pattern_shader.hpp>
|
||||
#include <llmr/shader/line_shader.hpp>
|
||||
#include <llmr/shader/linejoin_shader.hpp>
|
||||
#include <llmr/shader/point_shader.hpp>
|
||||
#include <llmr/shader/icon_shader.hpp>
|
||||
#include <llmr/shader/raster_shader.hpp>
|
||||
#include <llmr/shader/text_shader.hpp>
|
||||
#include <llmr/shader/dot_shader.hpp>
|
||||
@@ -30,7 +30,7 @@ class GlyphAtlas;
|
||||
|
||||
class FillBucket;
|
||||
class LineBucket;
|
||||
class PointBucket;
|
||||
class IconBucket;
|
||||
class TextBucket;
|
||||
class RasterBucket;
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
void renderDebugText(const std::vector<std::string> &strings);
|
||||
void renderFill(FillBucket& bucket, const std::string& layer_name, const Tile::ID& id);
|
||||
void renderLine(LineBucket& bucket, const std::string& layer_name, const Tile::ID& id);
|
||||
void renderPoint(PointBucket& bucket, const std::string& layer_name, const Tile::ID& id);
|
||||
void renderIcon(IconBucket& bucket, const std::string& layer_name, const Tile::ID& id);
|
||||
void renderText(TextBucket& bucket, const std::string& layer_name, const Tile::ID& id);
|
||||
void renderRaster(RasterBucket& bucket, const std::string& layer_name, const Tile::ID& id);
|
||||
|
||||
@@ -123,7 +123,7 @@ private:
|
||||
std::unique_ptr<LineShader> lineShader;
|
||||
std::unique_ptr<LinejoinShader> linejoinShader;
|
||||
std::unique_ptr<PatternShader> patternShader;
|
||||
std::unique_ptr<PointShader> pointShader;
|
||||
std::unique_ptr<IconShader> iconShader;
|
||||
std::unique_ptr<RasterShader> rasterShader;
|
||||
std::unique_ptr<TextShader> textShader;
|
||||
std::unique_ptr<DotShader> dotShader;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef LLMR_SHADER_SHADER_POINT
|
||||
#define LLMR_SHADER_SHADER_POINT
|
||||
#ifndef LLMR_SHADER_SHADER_ICON
|
||||
#define LLMR_SHADER_SHADER_ICON
|
||||
|
||||
#include <llmr/shader/shader.hpp>
|
||||
|
||||
namespace llmr {
|
||||
|
||||
class PointShader : public Shader {
|
||||
class IconShader : public Shader {
|
||||
public:
|
||||
PointShader();
|
||||
IconShader();
|
||||
|
||||
void bind(char *offset);
|
||||
|
||||
@@ -13,7 +13,7 @@ enum class BucketType {
|
||||
None = 0,
|
||||
Fill = 1,
|
||||
Line = 2,
|
||||
Point = 3,
|
||||
Icon = 3,
|
||||
Text = 4,
|
||||
Raster = 5
|
||||
};
|
||||
@@ -41,7 +41,7 @@ enum class TextPathType {
|
||||
inline BucketType bucketType(const std::string& type) {
|
||||
if (type == "fill") return BucketType::Fill;
|
||||
else if (type == "line") return BucketType::Line;
|
||||
else if (type == "point") return BucketType::Point;
|
||||
else if (type == "point") return BucketType::Icon;
|
||||
else if (type == "text") return BucketType::Text;
|
||||
else if (type == "raster") return BucketType::Raster;
|
||||
else return BucketType::None;
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
BackgroundClass background;
|
||||
std::map<std::string, FillClass> fill;
|
||||
std::map<std::string, LineClass> line;
|
||||
std::map<std::string, PointClass> point;
|
||||
std::map<std::string, IconClass> icon;
|
||||
std::map<std::string, TextClass> text;
|
||||
std::map<std::string, RasterClass> raster;
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ struct FunctionProperty {
|
||||
template <typename T> inline T evaluate(float z) const { return function(z, values); }
|
||||
};
|
||||
|
||||
struct PointClass {
|
||||
struct IconClass {
|
||||
FunctionProperty enabled = true;
|
||||
std::array<FunctionProperty, 2> translate = {{ 0, 0 }};
|
||||
TranslateAnchor translateAnchor = TranslateAnchor::Map;
|
||||
@@ -72,7 +72,7 @@ struct PointClass {
|
||||
FunctionProperty blur = 0;
|
||||
};
|
||||
|
||||
struct PointProperties {
|
||||
struct IconProperties {
|
||||
bool enabled = true;
|
||||
std::array<float, 2> translate = {{ 0, 0 }};
|
||||
TranslateAnchor translateAnchor = TranslateAnchor::Map;
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
BackgroundProperties background;
|
||||
std::map<std::string, FillProperties> fills;
|
||||
std::map<std::string, LineProperties> lines;
|
||||
std::map<std::string, PointProperties> points;
|
||||
std::map<std::string, IconProperties> icons;
|
||||
std::map<std::string, TextProperties> texts;
|
||||
std::map<std::string, RasterProperties> rasters;
|
||||
} computed;
|
||||
|
||||
@@ -22,7 +22,7 @@ private:
|
||||
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);
|
||||
IconClass parseIconClass(JSVal value);
|
||||
TextClass parseTextClass(JSVal value);
|
||||
BackgroundClass parseBackgroundClass(JSVal value);
|
||||
RasterClass parseRasterClass(JSVal value);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include <llmr/geometry/point_buffer.hpp>
|
||||
#include <llmr/geometry/icon_buffer.hpp>
|
||||
#include <llmr/platform/gl.hpp>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
void PointVertexBuffer::add(vertex_type x, vertex_type y) {
|
||||
void IconVertexBuffer::add(vertex_type x, vertex_type y) {
|
||||
vertex_type *vertices = static_cast<vertex_type *>(addElement());
|
||||
vertices[0] = x;
|
||||
vertices[1] = y;
|
||||
@@ -518,9 +518,9 @@ void Map::renderLayer(const LayerDescription& layer_desc, RenderPass pass) {
|
||||
if (pass == Opaque) return;
|
||||
if (is_invisible(style.computed.lines, layer_desc)) return;
|
||||
break;
|
||||
case BucketType::Point:
|
||||
case BucketType::Icon:
|
||||
if (pass == Opaque) return;
|
||||
if (is_invisible(style.computed.points, layer_desc)) return;
|
||||
if (is_invisible(style.computed.icons, layer_desc)) return;
|
||||
break;
|
||||
case BucketType::Text:
|
||||
if (pass == Opaque) return;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <llmr/style/style.hpp>
|
||||
#include <llmr/renderer/fill_bucket.hpp>
|
||||
#include <llmr/renderer/line_bucket.hpp>
|
||||
#include <llmr/renderer/point_bucket.hpp>
|
||||
#include <llmr/renderer/icon_bucket.hpp>
|
||||
#include <llmr/renderer/text_bucket.hpp>
|
||||
#include <llmr/renderer/raster_bucket.hpp>
|
||||
#include <llmr/util/raster.hpp>
|
||||
@@ -91,8 +91,8 @@ std::unique_ptr<Bucket> TileParser::createBucket(const BucketDescription& bucket
|
||||
return createFillBucket(layer, bucket_desc);
|
||||
} else if (bucket_desc.type == BucketType::Line) {
|
||||
return createLineBucket(layer, bucket_desc);
|
||||
} else if (bucket_desc.type == BucketType::Point) {
|
||||
return createPointBucket(layer, bucket_desc);
|
||||
} else if (bucket_desc.type == BucketType::Icon) {
|
||||
return createIconBucket(layer, bucket_desc);
|
||||
} else if (bucket_desc.type == BucketType::Text) {
|
||||
return createTextBucket(layer, bucket_desc);
|
||||
} else {
|
||||
@@ -134,9 +134,9 @@ std::unique_ptr<Bucket> TileParser::createLineBucket(const VectorTileLayer& laye
|
||||
return obsolete() ? nullptr : std::move(bucket);
|
||||
}
|
||||
|
||||
std::unique_ptr<Bucket> TileParser::createPointBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc) {
|
||||
std::unique_ptr<PointBucket> bucket = std::make_unique<PointBucket>(
|
||||
tile.pointVertexBuffer, bucket_desc);
|
||||
std::unique_ptr<Bucket> TileParser::createIconBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc) {
|
||||
std::unique_ptr<IconBucket> bucket = std::make_unique<IconBucket>(
|
||||
tile.iconVertexBuffer, bucket_desc);
|
||||
addBucketFeatures(bucket, layer, bucket_desc);
|
||||
return obsolete() ? nullptr : std::move(bucket);
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ void FilteredVectorTileLayer::iterator::operator++() {
|
||||
}
|
||||
} else if (feature_pbf.tag == 3) { // geometry type
|
||||
switch (feature_pbf.varint()) {
|
||||
case 1 /* Point */: type = BucketType::Point; break;
|
||||
case 1 /* Point */: type = BucketType::Icon; break;
|
||||
case 2 /* LineString */: type = BucketType::Line; break;
|
||||
case 3 /* Polygon */: type = BucketType::Fill; break;
|
||||
default: type = BucketType::None; break;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <llmr/renderer/point_bucket.hpp>
|
||||
#include <llmr/geometry/point_buffer.hpp>
|
||||
#include <llmr/renderer/icon_bucket.hpp>
|
||||
#include <llmr/geometry/icon_buffer.hpp>
|
||||
#include <llmr/geometry/elements_buffer.hpp>
|
||||
#include <llmr/geometry/geometry.hpp>
|
||||
|
||||
@@ -15,14 +15,14 @@ struct geometry_too_long_exception : std::exception {};
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
PointBucket::PointBucket(PointVertexBuffer& vertexBuffer,
|
||||
IconBucket::IconBucket(IconVertexBuffer& vertexBuffer,
|
||||
const BucketDescription& bucket_desc)
|
||||
: geometry(bucket_desc.geometry),
|
||||
vertexBuffer(vertexBuffer),
|
||||
vertex_start(vertexBuffer.index()) {
|
||||
}
|
||||
|
||||
void PointBucket::addGeometry(pbf& geom) {
|
||||
void IconBucket::addGeometry(pbf& geom) {
|
||||
Geometry::command cmd;
|
||||
Geometry geometry(geom);
|
||||
int32_t x, y;
|
||||
@@ -30,28 +30,28 @@ void PointBucket::addGeometry(pbf& geom) {
|
||||
if (cmd == Geometry::move_to) {
|
||||
vertexBuffer.add(x, y);
|
||||
} else {
|
||||
fprintf(stderr, "other command than move_to in point geometry\n");
|
||||
fprintf(stderr, "other command than move_to in icon geometry\n");
|
||||
}
|
||||
}
|
||||
|
||||
vertex_end = vertexBuffer.index();
|
||||
}
|
||||
|
||||
void PointBucket::render(Painter& painter, const std::string& layer_name, const Tile::ID& id) {
|
||||
painter.renderPoint(*this, layer_name, id);
|
||||
void IconBucket::render(Painter& painter, const std::string& layer_name, const Tile::ID& id) {
|
||||
painter.renderIcon(*this, layer_name, id);
|
||||
}
|
||||
|
||||
bool PointBucket::hasData() const {
|
||||
bool IconBucket::hasData() const {
|
||||
return vertex_end > 0;
|
||||
}
|
||||
|
||||
void PointBucket::drawPoints(PointShader& shader) {
|
||||
void IconBucket::drawIcons(IconShader& shader) {
|
||||
char *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize);
|
||||
array.bind(shader, vertexBuffer, vertex_index);
|
||||
glDrawArrays(GL_POINTS, 0, (GLsizei)(vertex_end - vertex_start));
|
||||
}
|
||||
|
||||
void PointBucket::drawPoints(DotShader& shader) {
|
||||
void IconBucket::drawIcons(DotShader& shader) {
|
||||
char *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize);
|
||||
array.bind(shader, vertexBuffer, vertex_index);
|
||||
glDrawArrays(GL_POINTS, 0, (GLsizei)(vertex_end - vertex_start));
|
||||
@@ -63,7 +63,7 @@ void Painter::setupShaders() {
|
||||
lineShader = std::make_unique<LineShader>();
|
||||
linejoinShader = std::make_unique<LinejoinShader>();
|
||||
patternShader = std::make_unique<PatternShader>();
|
||||
pointShader = std::make_unique<PointShader>();
|
||||
iconShader = std::make_unique<IconShader>();
|
||||
rasterShader = std::make_unique<RasterShader>();
|
||||
textShader = std::make_unique<TextShader>();
|
||||
dotShader = std::make_unique<DotShader>();
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#include <llmr/renderer/painter.hpp>
|
||||
#include <llmr/renderer/point_bucket.hpp>
|
||||
#include <llmr/renderer/icon_bucket.hpp>
|
||||
#include <llmr/map/map.hpp>
|
||||
#include <llmr/style/sprite.hpp>
|
||||
#include <llmr/util/math.hpp>
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
void Painter::renderPoint(PointBucket& bucket, const std::string& layer_name, const Tile::ID& id) {
|
||||
void Painter::renderIcon(IconBucket& bucket, const std::string& layer_name, const Tile::ID& id) {
|
||||
// Abort early.
|
||||
if (!bucket.hasData()) return;
|
||||
if (pass == Opaque) return;
|
||||
|
||||
auto point_properties = map.getStyle().computed.points;
|
||||
auto point_properties_it = point_properties.find(layer_name);
|
||||
if (point_properties_it == point_properties.end()) return;
|
||||
auto icon_properties = map.getStyle().computed.icons;
|
||||
auto icon_properties_it = icon_properties.find(layer_name);
|
||||
if (icon_properties_it == icon_properties.end()) return;
|
||||
|
||||
const PointProperties& properties = point_properties_it->second;
|
||||
const IconProperties& properties = icon_properties_it->second;
|
||||
if (!properties.enabled) return;
|
||||
|
||||
Color color = properties.color;
|
||||
@@ -43,41 +43,41 @@ void Painter::renderPoint(PointBucket& bucket, const std::string& layer_name, co
|
||||
dotShader->setMatrix(vtxMatrix);
|
||||
dotShader->setColor(color);
|
||||
|
||||
const float pointSize = (properties.radius ? properties.radius * 2 : 8) * map.getState().getPixelRatio();
|
||||
dotShader->setSize(pointSize);
|
||||
const float iconSize = (properties.radius ? properties.radius * 2 : 8) * map.getState().getPixelRatio();
|
||||
dotShader->setSize(iconSize);
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
glPointSize(pointSize);
|
||||
glPointSize(iconSize);
|
||||
glEnable(GL_POINT_SPRITE);
|
||||
#endif
|
||||
dotShader->setBlur((properties.blur ? properties.blur : 1.5) / pointSize);
|
||||
dotShader->setBlur((properties.blur ? properties.blur : 1.5) / iconSize);
|
||||
|
||||
glDepthRange(strata, 1.0f);
|
||||
bucket.drawPoints(*dotShader);
|
||||
bucket.drawIcons(*dotShader);
|
||||
} else {
|
||||
useProgram(pointShader->program);
|
||||
pointShader->setMatrix(vtxMatrix);
|
||||
pointShader->setColor(color);
|
||||
pointShader->setImage(0);
|
||||
pointShader->setPosition({{
|
||||
useProgram(iconShader->program);
|
||||
iconShader->setMatrix(vtxMatrix);
|
||||
iconShader->setColor(color);
|
||||
iconShader->setImage(0);
|
||||
iconShader->setPosition({{
|
||||
0.5f * (imagePos.tl.x + imagePos.br.x),
|
||||
0.5f * (imagePos.tl.y + imagePos.br.y),
|
||||
}});
|
||||
|
||||
pointShader->setDimension({{
|
||||
iconShader->setDimension({{
|
||||
static_cast<float>(sprite->raster.width),
|
||||
static_cast<float>(sprite->raster.height)
|
||||
}});
|
||||
|
||||
sprite->raster.bind(map.getState().isChanging());
|
||||
|
||||
const float pointSize = util::max(imagePos.size.x, imagePos.size.y) + 2;
|
||||
pointShader->setSize(pointSize);
|
||||
const float iconSize = util::max(imagePos.size.x, imagePos.size.y) + 2;
|
||||
iconShader->setSize(iconSize);
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
glPointSize(pointSize);
|
||||
glPointSize(iconSize);
|
||||
glEnable(GL_POINT_SPRITE);
|
||||
#endif
|
||||
|
||||
glDepthRange(strata, 1.0f);
|
||||
bucket.drawPoints(*pointShader);
|
||||
bucket.drawIcons(*iconShader);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <llmr/shader/point_shader.hpp>
|
||||
#include <llmr/shader/icon_shader.hpp>
|
||||
#include <llmr/shader/shaders.hpp>
|
||||
#include <llmr/platform/gl.hpp>
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
PointShader::PointShader()
|
||||
IconShader::IconShader()
|
||||
: Shader(
|
||||
shaders[POINT_SHADER].vertex,
|
||||
shaders[POINT_SHADER].fragment
|
||||
shaders[ICON_SHADER].vertex,
|
||||
shaders[ICON_SHADER].fragment
|
||||
) {
|
||||
if (!valid) {
|
||||
fprintf(stderr, "invalid point shader\n");
|
||||
fprintf(stderr, "invalid icon shader\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ PointShader::PointShader()
|
||||
u_pos = glGetUniformLocation(program, "u_pos");
|
||||
u_dimension = glGetUniformLocation(program, "u_dimension");
|
||||
|
||||
// fprintf(stderr, "PointShader:\n");
|
||||
// fprintf(stderr, "IconShader:\n");
|
||||
// fprintf(stderr, " - u_matrix: %d\n", u_matrix);
|
||||
// fprintf(stderr, " - u_color: %d\n", u_color);
|
||||
// fprintf(stderr, " - u_size: %d\n", u_size);
|
||||
@@ -33,40 +33,40 @@ PointShader::PointShader()
|
||||
// fprintf(stderr, " - u_image: %d\n", u_image);
|
||||
}
|
||||
|
||||
void PointShader::bind(char *offset) {
|
||||
void IconShader::bind(char *offset) {
|
||||
glEnableVertexAttribArray(a_pos);
|
||||
glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset);
|
||||
}
|
||||
|
||||
void PointShader::setImage(int32_t new_image) {
|
||||
void IconShader::setImage(int32_t new_image) {
|
||||
if (image != new_image) {
|
||||
glUniform1i(u_image, new_image);
|
||||
image = new_image;
|
||||
}
|
||||
}
|
||||
|
||||
void PointShader::setColor(const std::array<float, 4>& new_color) {
|
||||
void IconShader::setColor(const std::array<float, 4>& new_color) {
|
||||
if (color != new_color) {
|
||||
glUniform4fv(u_color, 1, new_color.data());
|
||||
color = new_color;
|
||||
}
|
||||
}
|
||||
|
||||
void PointShader::setSize(float new_size) {
|
||||
void IconShader::setSize(float new_size) {
|
||||
if (size != new_size) {
|
||||
glUniform1f(u_size, new_size);
|
||||
size = new_size;
|
||||
}
|
||||
}
|
||||
|
||||
void PointShader::setPosition(const std::array<float, 2>& new_pos) {
|
||||
void IconShader::setPosition(const std::array<float, 2>& new_pos) {
|
||||
if (pos != new_pos) {
|
||||
glUniform2fv(u_pos, 1, new_pos.data());
|
||||
pos = new_pos;
|
||||
}
|
||||
}
|
||||
|
||||
void PointShader::setDimension(const std::array<float, 2>& new_dimension) {
|
||||
void IconShader::setDimension(const std::array<float, 2>& new_dimension) {
|
||||
if (dimension != new_dimension) {
|
||||
glUniform2fv(u_dimension, 1, new_dimension.data());
|
||||
dimension = new_dimension;
|
||||
@@ -10,6 +10,10 @@ const shader_source llmr::shaders[SHADER_COUNT] = {
|
||||
"#version 120\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform float u_size;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n}\n\n",
|
||||
"#version 120\nuniform vec4 u_color;\nuniform float u_blur;\nvoid main ()\n{\n vec2 x_1;\n x_1 = (gl_PointCoord - 0.5);\n float tmpvar_2;\n tmpvar_2 = clamp (((\n sqrt(dot (x_1, x_1))\n - 0.5) / (\n (0.5 - u_blur)\n - 0.5)), 0.0, 1.0);\n gl_FragColor = (u_color * (tmpvar_2 * (tmpvar_2 * \n (3.0 - (2.0 * tmpvar_2))\n )));\n}\n\n",
|
||||
},
|
||||
{
|
||||
"#version 120\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform float u_size;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n}\n\n",
|
||||
"#version 120\nuniform sampler2D u_image;\nuniform vec2 u_pos;\nuniform vec2 u_dimension;\nuniform vec4 u_color;\nuniform float u_size;\nvoid main ()\n{\n gl_FragColor = (texture2D (u_image, (u_pos + (\n ((gl_PointCoord - 0.5) * u_size)\n / u_dimension))) * u_color);\n}\n\n",
|
||||
},
|
||||
{
|
||||
"#version 120\nattribute vec2 a_pos;\nattribute vec2 a_extrude;\nattribute float a_linesofar;\nuniform mat4 u_matrix;\nuniform mat4 u_exmatrix;\nuniform float u_ratio;\nuniform vec2 u_linewidth;\nvarying vec2 v_normal;\nvarying float v_linesofar;\nvoid main ()\n{\n vec2 normal_1;\n vec2 tmpvar_2;\n tmpvar_2 = (vec2(mod (a_pos, 2.0)));\n normal_1.x = tmpvar_2.x;\n normal_1.y = sign((tmpvar_2.y - 0.5));\n v_normal = normal_1;\n vec4 tmpvar_3;\n tmpvar_3.zw = vec2(0.0, 0.0);\n tmpvar_3.xy = ((u_linewidth.x * a_extrude) * 0.015873);\n vec4 tmpvar_4;\n tmpvar_4.zw = vec2(0.0, 1.0);\n tmpvar_4.xy = floor((a_pos * 0.5));\n gl_Position = ((u_matrix * tmpvar_4) + (u_exmatrix * tmpvar_3));\n v_linesofar = (a_linesofar * u_ratio);\n}\n\n",
|
||||
"#version 120\nuniform vec2 u_linewidth;\nuniform vec4 u_color;\nuniform vec2 u_dasharray;\nvarying vec2 v_normal;\nvarying float v_linesofar;\nvoid main ()\n{\n float tmpvar_1;\n tmpvar_1 = (sqrt(dot (v_normal, v_normal)) * u_linewidth.x);\n float tmpvar_2;\n tmpvar_2 = (float(mod (v_linesofar, (u_dasharray.x + u_dasharray.y))));\n gl_FragColor = (u_color * (clamp (\n min ((tmpvar_1 - (u_linewidth.y - 1.0)), (u_linewidth.x - tmpvar_1))\n , 0.0, 1.0) * max (\n float((-(u_dasharray.y) >= 0.0))\n , \n clamp (min (tmpvar_2, (u_dasharray.x - tmpvar_2)), 0.0, 1.0)\n )));\n}\n\n",
|
||||
@@ -30,10 +34,6 @@ const shader_source llmr::shaders[SHADER_COUNT] = {
|
||||
"#version 120\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n}\n\n",
|
||||
"#version 120\nuniform vec4 u_color;\nvoid main ()\n{\n gl_FragColor = u_color;\n}\n\n",
|
||||
},
|
||||
{
|
||||
"#version 120\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform float u_size;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n}\n\n",
|
||||
"#version 120\nuniform sampler2D u_image;\nuniform vec2 u_pos;\nuniform vec2 u_dimension;\nuniform vec4 u_color;\nuniform float u_size;\nvoid main ()\n{\n gl_FragColor = (texture2D (u_image, (u_pos + (\n ((gl_PointCoord - 0.5) * u_size)\n / u_dimension))) * u_color);\n}\n\n",
|
||||
},
|
||||
{
|
||||
"#version 120\nuniform mat4 u_matrix;\nattribute vec2 a_pos;\nvarying vec2 v_pos;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n v_pos = (a_pos / 4096.0);\n}\n\n",
|
||||
"#version 120\nuniform sampler2D u_image;\nuniform float u_opacity;\nvarying vec2 v_pos;\nvoid main ()\n{\n gl_FragColor = (texture2D (u_image, v_pos) * u_opacity);\n}\n\n",
|
||||
|
||||
@@ -10,6 +10,10 @@ const shader_source llmr::shaders[SHADER_COUNT] = {
|
||||
"precision highp float;\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform float u_size;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n}\n\n",
|
||||
"precision highp float;\nuniform vec4 u_color;\nuniform float u_blur;\nvoid main ()\n{\n mediump vec2 x_1;\n x_1 = (gl_PointCoord - 0.5);\n mediump float tmpvar_2;\n tmpvar_2 = clamp (((\n sqrt(dot (x_1, x_1))\n - 0.5) / (\n (0.5 - u_blur)\n - 0.5)), 0.0, 1.0);\n gl_FragColor = (u_color * (tmpvar_2 * (tmpvar_2 * \n (3.0 - (2.0 * tmpvar_2))\n )));\n}\n\n",
|
||||
},
|
||||
{
|
||||
"precision highp float;\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform float u_size;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n}\n\n",
|
||||
"precision highp float;\nuniform sampler2D u_image;\nuniform vec2 u_pos;\nuniform vec2 u_dimension;\nuniform vec4 u_color;\nuniform float u_size;\nvoid main ()\n{\n mediump vec2 tmpvar_1;\n tmpvar_1 = (u_pos + ((\n (gl_PointCoord - 0.5)\n * u_size) / u_dimension));\n lowp vec4 tmpvar_2;\n tmpvar_2 = (texture2D (u_image, tmpvar_1) * u_color);\n gl_FragColor = tmpvar_2;\n}\n\n",
|
||||
},
|
||||
{
|
||||
"precision highp float;\nattribute vec2 a_pos;\nattribute vec2 a_extrude;\nattribute float a_linesofar;\nuniform mat4 u_matrix;\nuniform mat4 u_exmatrix;\nuniform float u_ratio;\nuniform vec2 u_linewidth;\nvarying vec2 v_normal;\nvarying float v_linesofar;\nvoid main ()\n{\n vec2 normal_1;\n vec2 tmpvar_2;\n tmpvar_2 = (vec2(mod (a_pos, 2.0)));\n normal_1.x = tmpvar_2.x;\n normal_1.y = sign((tmpvar_2.y - 0.5));\n v_normal = normal_1;\n vec4 tmpvar_3;\n tmpvar_3.zw = vec2(0.0, 0.0);\n tmpvar_3.xy = ((u_linewidth.x * a_extrude) * 0.015873);\n vec4 tmpvar_4;\n tmpvar_4.zw = vec2(0.0, 1.0);\n tmpvar_4.xy = floor((a_pos * 0.5));\n gl_Position = ((u_matrix * tmpvar_4) + (u_exmatrix * tmpvar_3));\n v_linesofar = (a_linesofar * u_ratio);\n}\n\n",
|
||||
"precision highp float;\nuniform vec2 u_linewidth;\nuniform vec4 u_color;\nuniform vec2 u_dasharray;\nvarying vec2 v_normal;\nvarying float v_linesofar;\nvoid main ()\n{\n float tmpvar_1;\n tmpvar_1 = (sqrt(dot (v_normal, v_normal)) * u_linewidth.x);\n float tmpvar_2;\n tmpvar_2 = (float(mod (v_linesofar, (u_dasharray.x + u_dasharray.y))));\n gl_FragColor = (u_color * (clamp (\n min ((tmpvar_1 - (u_linewidth.y - 1.0)), (u_linewidth.x - tmpvar_1))\n , 0.0, 1.0) * max (\n float((-(u_dasharray.y) >= 0.0))\n , \n clamp (min (tmpvar_2, (u_dasharray.x - tmpvar_2)), 0.0, 1.0)\n )));\n}\n\n",
|
||||
@@ -30,10 +34,6 @@ const shader_source llmr::shaders[SHADER_COUNT] = {
|
||||
"precision highp float;\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n}\n\n",
|
||||
"precision highp float;\nuniform vec4 u_color;\nvoid main ()\n{\n gl_FragColor = u_color;\n}\n\n",
|
||||
},
|
||||
{
|
||||
"precision highp float;\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform float u_size;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n}\n\n",
|
||||
"precision highp float;\nuniform sampler2D u_image;\nuniform vec2 u_pos;\nuniform vec2 u_dimension;\nuniform vec4 u_color;\nuniform float u_size;\nvoid main ()\n{\n mediump vec2 tmpvar_1;\n tmpvar_1 = (u_pos + ((\n (gl_PointCoord - 0.5)\n * u_size) / u_dimension));\n lowp vec4 tmpvar_2;\n tmpvar_2 = (texture2D (u_image, tmpvar_1) * u_color);\n gl_FragColor = tmpvar_2;\n}\n\n",
|
||||
},
|
||||
{
|
||||
"precision highp float;\nuniform mat4 u_matrix;\nattribute vec2 a_pos;\nvarying vec2 v_pos;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n v_pos = (a_pos / 4096.0);\n}\n\n",
|
||||
"precision highp float;\nuniform sampler2D u_image;\nuniform float u_opacity;\nvarying vec2 v_pos;\nvoid main ()\n{\n lowp vec4 tmpvar_1;\n tmpvar_1 = (texture2D (u_image, v_pos) * u_opacity);\n gl_FragColor = tmpvar_1;\n}\n\n",
|
||||
|
||||
@@ -14,7 +14,7 @@ Style::Style() {
|
||||
void Style::reset() {
|
||||
computed.fills.clear();
|
||||
computed.lines.clear();
|
||||
computed.points.clear();
|
||||
computed.icons.clear();
|
||||
}
|
||||
|
||||
void Style::cascade(float z) {
|
||||
@@ -69,24 +69,24 @@ void Style::cascade(float z) {
|
||||
stroke.opacity = layer.opacity.evaluate<float>(z);
|
||||
}
|
||||
|
||||
// Cascade point classes
|
||||
for (const auto& point_pair : sheetClass.point) {
|
||||
const std::string& layer_name = point_pair.first;
|
||||
const llmr::PointClass& layer = point_pair.second;
|
||||
// Cascade icon classes
|
||||
for (const auto& icon_pair : sheetClass.icon) {
|
||||
const std::string& layer_name = icon_pair.first;
|
||||
const llmr::IconClass& layer = icon_pair.second;
|
||||
|
||||
// TODO: This should be restricted to point styles that have actual
|
||||
// TODO: This should be restricted to icon styles that have actual
|
||||
// values so as to not override with default values.
|
||||
llmr::PointProperties& point = computed.points[layer_name];
|
||||
point.enabled = layer.enabled.evaluate<bool>(z);
|
||||
point.translate = {{ layer.translate[0].evaluate<float>(z),
|
||||
llmr::IconProperties& icon = computed.icons[layer_name];
|
||||
icon.enabled = layer.enabled.evaluate<bool>(z);
|
||||
icon.translate = {{ layer.translate[0].evaluate<float>(z),
|
||||
layer.translate[1].evaluate<float>(z) }};
|
||||
point.translateAnchor = layer.translateAnchor;
|
||||
point.color = layer.color;
|
||||
point.size = layer.size.evaluate<float>(z);
|
||||
point.opacity = layer.opacity.evaluate<float>(z);
|
||||
point.image = layer.image;
|
||||
point.radius = layer.radius.evaluate<float>(z);
|
||||
point.blur = layer.blur.evaluate<float>(z);
|
||||
icon.translateAnchor = layer.translateAnchor;
|
||||
icon.color = layer.color;
|
||||
icon.size = layer.size.evaluate<float>(z);
|
||||
icon.opacity = layer.opacity.evaluate<float>(z);
|
||||
icon.image = layer.image;
|
||||
icon.radius = layer.radius.evaluate<float>(z);
|
||||
icon.blur = layer.blur.evaluate<float>(z);
|
||||
}
|
||||
|
||||
// Cascade text classes
|
||||
|
||||
@@ -269,8 +269,8 @@ void StyleParser::parseClass(const std::string& name, JSVal value, ClassDescript
|
||||
class_desc.fill.insert({ name, std::forward<FillClass>(parseFillClass(value)) });
|
||||
} else if (type == BucketType::Line) {
|
||||
class_desc.line.insert({ name, std::forward<LineClass>(parseLineClass(value)) });
|
||||
} else if (type == BucketType::Point) {
|
||||
class_desc.point.insert({ name, std::forward<PointClass>(parsePointClass(value)) });
|
||||
} else if (type == BucketType::Icon) {
|
||||
class_desc.icon.insert({ name, std::forward<IconClass>(parseIconClass(value)) });
|
||||
} else if (type == BucketType::Text) {
|
||||
class_desc.text.insert({ name, std::forward<TextClass>(parseTextClass(value)) });
|
||||
} else if (type == BucketType::Raster) {
|
||||
@@ -512,8 +512,8 @@ LineClass StyleParser::parseLineClass(JSVal value) {
|
||||
return klass;
|
||||
}
|
||||
|
||||
PointClass StyleParser::parsePointClass(JSVal value) {
|
||||
PointClass klass;
|
||||
IconClass StyleParser::parseIconClass(JSVal value) {
|
||||
IconClass klass;
|
||||
|
||||
if (value.HasMember("enabled")) {
|
||||
klass.enabled = parseFunction(value["enabled"]);
|
||||
|
||||
Reference in New Issue
Block a user