Merge branch 'master' into libuv010
This commit is contained in:
@@ -12,7 +12,7 @@ class Geometry : private util::noncopyable {
|
||||
|
||||
public:
|
||||
inline explicit Geometry(pbf& data);
|
||||
|
||||
|
||||
enum command : uint8_t {
|
||||
end = 0,
|
||||
move_to = 1,
|
||||
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
// Triggers a lazy rerender: only performs a render when the map is not clean.
|
||||
void rerender();
|
||||
|
||||
void renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass, const Tile::ID* id = nullptr, const mat4* matrix = nullptr);
|
||||
|
||||
// Forces a map update: always triggers a rerender.
|
||||
void update();
|
||||
|
||||
@@ -123,6 +125,7 @@ public:
|
||||
inline std::shared_ptr<uv::loop> getLoop() { return loop; }
|
||||
inline timestamp getAnimationTime() const { return animationTime; }
|
||||
inline timestamp getTime() const { return animationTime; }
|
||||
void updateTiles();
|
||||
|
||||
private:
|
||||
// uv async callbacks
|
||||
@@ -137,7 +140,6 @@ private:
|
||||
void updateSources();
|
||||
void updateSources(const std::shared_ptr<StyleLayerGroup> &group);
|
||||
|
||||
void updateTiles();
|
||||
void updateRenderState();
|
||||
|
||||
size_t countLayers(const std::vector<LayerDescription>& layers);
|
||||
@@ -146,12 +148,10 @@ private:
|
||||
// the stylesheet.
|
||||
void prepare();
|
||||
|
||||
enum RenderPass { Opaque, Translucent };
|
||||
|
||||
// Unconditionally performs a render with the current map state.
|
||||
void render();
|
||||
void renderLayers(std::shared_ptr<StyleLayerGroup> group);
|
||||
void renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass);
|
||||
|
||||
private:
|
||||
bool async = false;
|
||||
|
||||
@@ -22,10 +22,11 @@ public:
|
||||
~RasterTileData();
|
||||
|
||||
virtual void parse();
|
||||
virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc);
|
||||
virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix);
|
||||
virtual bool hasData(std::shared_ptr<StyleLayer> layer_desc) const;
|
||||
|
||||
protected:
|
||||
StyleBucketRaster properties;
|
||||
RasterBucket bucket;
|
||||
};
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
void drawClippingMasks(Painter &painter);
|
||||
size_t getTileCount() const;
|
||||
void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc);
|
||||
void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix);
|
||||
void finishRender(Painter &painter);
|
||||
|
||||
std::forward_list<Tile::ID> getIDs() const;
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
virtual void beforeParse();
|
||||
virtual void parse() = 0;
|
||||
virtual void afterParse();
|
||||
virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc) = 0;
|
||||
virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix) = 0;
|
||||
virtual bool hasData(std::shared_ptr<StyleLayer> layer_desc) const = 0;
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
namespace mbgl {
|
||||
|
||||
class Bucket;
|
||||
class Texturepool;
|
||||
class FontStack;
|
||||
class GlyphAtlas;
|
||||
class GlyphStore;
|
||||
@@ -22,6 +23,7 @@ class Sprite;
|
||||
class Style;
|
||||
class StyleBucket;
|
||||
class StyleBucketFill;
|
||||
class StyleBucketRaster;
|
||||
class StyleBucketLine;
|
||||
class StyleBucketSymbol;
|
||||
class StyleLayerGroup;
|
||||
@@ -45,6 +47,7 @@ private:
|
||||
std::unique_ptr<Bucket> createBucket(std::shared_ptr<StyleBucket> bucket_desc);
|
||||
|
||||
std::unique_ptr<Bucket> createFillBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketFill &fill);
|
||||
std::unique_ptr<Bucket> createRasterBucket(const std::shared_ptr<Texturepool> &texturepool, const StyleBucketRaster &raster);
|
||||
std::unique_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketLine &line);
|
||||
std::unique_ptr<Bucket> createSymbolBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketSymbol &symbol);
|
||||
|
||||
@@ -60,6 +63,7 @@ private:
|
||||
std::shared_ptr<GlyphStore> glyphStore;
|
||||
std::shared_ptr<SpriteAtlas> spriteAtlas;
|
||||
std::shared_ptr<Sprite> sprite;
|
||||
std::shared_ptr<Texturepool> texturePool;
|
||||
|
||||
Collision collision;
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
virtual void beforeParse();
|
||||
virtual void parse();
|
||||
virtual void afterParse();
|
||||
virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc);
|
||||
virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix);
|
||||
virtual bool hasData(std::shared_ptr<StyleLayer> layer_desc) const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <memory>
|
||||
#include <mbgl/map/tile.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/renderer/prerendered_texture.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -14,11 +13,10 @@ class StyleLayer;
|
||||
|
||||
class Bucket : private util::noncopyable {
|
||||
public:
|
||||
virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id) = 0;
|
||||
virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) = 0;
|
||||
virtual bool hasData() const = 0;
|
||||
virtual ~Bucket() {}
|
||||
|
||||
std::unique_ptr<PrerenderedTexture> prerendered;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class DebugBucket : public Bucket {
|
||||
public:
|
||||
DebugBucket(DebugFontBuffer& fontBuffer);
|
||||
|
||||
virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id);
|
||||
virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
|
||||
virtual bool hasData() const;
|
||||
|
||||
void drawLines(PlainShader& shader);
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
const StyleBucketFill& properties);
|
||||
~FillBucket();
|
||||
|
||||
virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id);
|
||||
virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
|
||||
virtual bool hasData() const;
|
||||
|
||||
void addGeometry(pbf& data);
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
PointElementsBuffer& pointElementsBuffer,
|
||||
const StyleBucketLine& properties);
|
||||
|
||||
virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id);
|
||||
virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
|
||||
virtual bool hasData() const;
|
||||
|
||||
void addGeometry(pbf& data);
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
enum class RenderPass : bool { Opaque, Translucent };
|
||||
|
||||
class Transform;
|
||||
class Style;
|
||||
class Tile;
|
||||
@@ -40,8 +42,10 @@ class FillBucket;
|
||||
class LineBucket;
|
||||
class SymbolBucket;
|
||||
class RasterBucket;
|
||||
class PrerenderedTexture;
|
||||
|
||||
struct FillProperties;
|
||||
struct RasterProperties;
|
||||
struct CompositeProperties;
|
||||
|
||||
class LayerDescription;
|
||||
@@ -69,27 +73,28 @@ public:
|
||||
void changeMatrix();
|
||||
|
||||
// Renders a particular layer from a tile.
|
||||
void renderTileLayer(const Tile& tile, std::shared_ptr<StyleLayer> layer_desc);
|
||||
void renderTileLayer(const Tile& tile, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix);
|
||||
|
||||
// Renders debug information for a tile.
|
||||
void renderTileDebug(const Tile& tile);
|
||||
|
||||
// Renders the red debug frame around a tile, visualizing its perimeter.
|
||||
void renderDebugFrame();
|
||||
void renderDebugFrame(const mat4 &matrix);
|
||||
|
||||
void renderDebugText(DebugBucket& bucket);
|
||||
void renderDebugText(DebugBucket& bucket, const mat4 &matrix);
|
||||
void renderDebugText(const std::vector<std::string> &strings);
|
||||
void renderFill(FillBucket& bucket, const FillProperties& properties, const Tile::ID& id, const mat4 &mat);
|
||||
void renderFill(FillBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id);
|
||||
void renderLine(LineBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id);
|
||||
void renderSymbol(SymbolBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id);
|
||||
void renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id);
|
||||
void renderFill(FillBucket& bucket, const FillProperties& properties, const Tile::ID& id, const mat4 &matrix);
|
||||
void renderFill(FillBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
|
||||
void renderLine(LineBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
|
||||
void renderSymbol(SymbolBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
|
||||
void renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
|
||||
std::array<float, 3> spinWeights(float spin_value);
|
||||
|
||||
void preparePrerender(PrerenderedTexture &texture);
|
||||
void finishPrerender(PrerenderedTexture &texture);
|
||||
void preparePrerender(RasterBucket &bucket);
|
||||
|
||||
template <typename Properties>
|
||||
void renderPrerenderedTexture(PrerenderedTexture &texture, const Properties &properties);
|
||||
void renderPrerenderedTexture(RasterBucket &bucket, const mat4 &matrix, const RasterProperties& properties);
|
||||
|
||||
void createPrerendered(RasterBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id);
|
||||
|
||||
void resize();
|
||||
|
||||
@@ -117,7 +122,7 @@ public:
|
||||
bool needsAnimation() const;
|
||||
private:
|
||||
void setupShaders();
|
||||
const mat4 &translatedMatrix(const std::array<float, 2> &translation, const Tile::ID &id, TranslateAnchorType anchor = TranslateAnchorType::Map);
|
||||
const mat4 &translatedMatrix(const mat4& matrix, const std::array<float, 2> &translation, const Tile::ID &id, TranslateAnchorType anchor = TranslateAnchorType::Map);
|
||||
|
||||
void prepareTile(const Tile& tile);
|
||||
|
||||
@@ -127,7 +132,6 @@ public:
|
||||
void depthMask(bool value);
|
||||
|
||||
public:
|
||||
mat4 matrix;
|
||||
mat4 vtxMatrix;
|
||||
mat4 projMatrix;
|
||||
mat4 nativeMatrix;
|
||||
@@ -153,7 +157,7 @@ private:
|
||||
bool gl_depthMask = true;
|
||||
std::array<uint16_t, 2> gl_viewport = {{ 0, 0 }};
|
||||
float strata = 0;
|
||||
enum { Opaque, Translucent } pass = Opaque;
|
||||
RenderPass pass = RenderPass::Opaque;
|
||||
const float strata_epsilon = 1.0f / (1 << 16);
|
||||
|
||||
public:
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/platform/gl.hpp>
|
||||
#include <mbgl/style/rasterize_properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class StyleBucketRaster;
|
||||
class Painter;
|
||||
|
||||
class PrerenderedTexture : private util::noncopyable {
|
||||
public:
|
||||
PrerenderedTexture(const RasterizedProperties &properties);
|
||||
PrerenderedTexture(const StyleBucketRaster &properties);
|
||||
~PrerenderedTexture();
|
||||
|
||||
void bindTexture();
|
||||
@@ -23,12 +23,13 @@ public:
|
||||
void blur(Painter& painter, uint16_t passes);
|
||||
|
||||
public:
|
||||
const RasterizedProperties properties;
|
||||
const StyleBucketRaster &properties;
|
||||
|
||||
private:
|
||||
GLint previous_fbo = 0;
|
||||
GLuint fbo = 0;
|
||||
GLuint texture = 0;
|
||||
GLuint fbo_depth_stencil = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
#include <mbgl/util/raster.hpp>
|
||||
#include <mbgl/renderer/prerendered_texture.hpp>
|
||||
#include <mbgl/style/style_bucket.hpp>
|
||||
|
||||
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -12,17 +16,23 @@ class VertexArrayObject;
|
||||
|
||||
class RasterBucket : public Bucket {
|
||||
public:
|
||||
RasterBucket(const std::shared_ptr<Texturepool> &texturepool);
|
||||
RasterBucket(const std::shared_ptr<Texturepool> &texturepool, const StyleBucketRaster& properties);
|
||||
|
||||
virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id);
|
||||
virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
|
||||
virtual bool hasData() const;
|
||||
|
||||
bool setImage(const std::string &data);
|
||||
|
||||
const StyleBucketRaster &properties;
|
||||
PrerenderedTexture texture;
|
||||
|
||||
void drawRaster(RasterShader& shader, VertexBuffer &vertices, VertexArrayObject &array);
|
||||
|
||||
private:
|
||||
void drawRaster(RasterShader& shader, VertexBuffer &vertices, VertexArrayObject &array, GLuint texture);
|
||||
|
||||
Raster raster;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class SymbolBucket : public Bucket {
|
||||
public:
|
||||
SymbolBucket(const StyleBucketSymbol &properties, Collision &collision);
|
||||
|
||||
virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID &id);
|
||||
virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix);
|
||||
virtual bool hasData() const;
|
||||
virtual bool hasTextData() const;
|
||||
virtual bool hasIconData() const;
|
||||
|
||||
@@ -14,6 +14,10 @@ public:
|
||||
void setImage(int32_t image);
|
||||
void setOpacity(float opacity);
|
||||
void setBuffer(float buffer);
|
||||
void setBrightness(float brightness_low, float brightness_high);
|
||||
void setSaturation(float saturation_factor);
|
||||
void setContrast(float contrast_factor);
|
||||
void setSpin(std::array<float, 3> spin_weights);
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
@@ -26,6 +30,22 @@ private:
|
||||
|
||||
float buffer = 0;
|
||||
int32_t u_buffer = -1;
|
||||
|
||||
float brightness_low = 0;
|
||||
int32_t u_brightness_low = -1;
|
||||
|
||||
float brightness_high = 0;
|
||||
int32_t u_brightness_high = -1;
|
||||
|
||||
float saturation_factor = 0;
|
||||
int32_t u_saturation_factor = -1;
|
||||
|
||||
float contrast_factor = 1;
|
||||
int32_t u_contrast_factor = -1;
|
||||
|
||||
std::array<float, 3> spin_weights = {{}};
|
||||
int32_t u_spin_weights = -1;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ enum class PropertyKey {
|
||||
CompositeOpacity,
|
||||
|
||||
RasterOpacity,
|
||||
RasterSpin,
|
||||
RasterHueRotate,
|
||||
RasterBrightness, // for transitions only
|
||||
RasterBrightnessLow,
|
||||
RasterBrightnessHigh,
|
||||
RasterSaturation,
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#ifndef MBGL_STYLE_RASTERIZE_PROPERTIES
|
||||
#define MBGL_STYLE_RASTERIZE_PROPERTIES
|
||||
|
||||
#include <mbgl/style/function_properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
// The calculated properties for a layer in a tile.
|
||||
class RasterizedProperties {
|
||||
public:
|
||||
float buffer = 1.0f / 32.0f;
|
||||
uint16_t size = 256;
|
||||
uint8_t blur = 0;
|
||||
};
|
||||
|
||||
class RasterizeProperties {
|
||||
public:
|
||||
Function<bool> enabled = ConstantFunction<bool>(false);
|
||||
Function<float> buffer = ConstantFunction<float>(1.0f / 32.0f);
|
||||
Function<float> size = ConstantFunction<float>(256);
|
||||
Function<float> blur = ConstantFunction<float>(0);
|
||||
|
||||
inline bool isEnabled(const int8_t z) const {
|
||||
return util::apply_visitor(FunctionEvaluator<bool>(z), enabled);
|
||||
}
|
||||
|
||||
inline RasterizedProperties get(const int8_t z) const {
|
||||
RasterizedProperties properties;
|
||||
properties.buffer = util::apply_visitor(FunctionEvaluator<float>(z), buffer);
|
||||
properties.size = util::apply_visitor(FunctionEvaluator<float>(z), size);
|
||||
properties.blur = util::apply_visitor(FunctionEvaluator<float>(z), blur);
|
||||
return properties;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -82,6 +82,10 @@ public:
|
||||
|
||||
class StyleBucketRaster {
|
||||
public:
|
||||
bool prerendered = false;
|
||||
uint16_t size = 256;
|
||||
float blur = 0.0f;
|
||||
float buffer = 0.03125f;
|
||||
};
|
||||
|
||||
typedef util::variant<StyleBucketFill, StyleBucketLine, StyleBucketSymbol,
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <mbgl/style/class_dictionary.hpp>
|
||||
#include <mbgl/style/class_properties.hpp>
|
||||
#include <mbgl/style/style_properties.hpp>
|
||||
#include <mbgl/style/rasterize_properties.hpp>
|
||||
#include <mbgl/style/applied_class_properties.hpp>
|
||||
|
||||
#include <vector>
|
||||
@@ -20,8 +19,7 @@ class StyleLayerGroup;
|
||||
|
||||
class StyleLayer {
|
||||
public:
|
||||
StyleLayer(const std::string &id, std::map<ClassID, ClassProperties> &&styles,
|
||||
std::unique_ptr<const RasterizeProperties> &&rasterize);
|
||||
StyleLayer(const std::string &id, std::map<ClassID, ClassProperties> &&styles);
|
||||
|
||||
template <typename T> const T &getProperties() {
|
||||
if (properties.is<T>()) {
|
||||
@@ -80,11 +78,6 @@ public:
|
||||
// layer's type.
|
||||
StyleProperties properties;
|
||||
|
||||
// Rasterization properties are used for prerendering the tile to a bitmap,
|
||||
// which is then used as a raster image instead of rendering this layer
|
||||
// directly in every frame.
|
||||
const std::unique_ptr<const RasterizeProperties> rasterize;
|
||||
|
||||
// Child layer array (if this layer has child layers).
|
||||
std::shared_ptr<StyleLayerGroup> layers;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <mbgl/style/style_source.hpp>
|
||||
#include <mbgl/style/filter_expression.hpp>
|
||||
#include <mbgl/style/class_properties.hpp>
|
||||
#include <mbgl/style/rasterize_properties.hpp>
|
||||
#include <mbgl/style/style_bucket.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
@@ -52,7 +51,6 @@ private:
|
||||
void parseLayer(std::pair<JSVal, std::shared_ptr<StyleLayer>> &pair);
|
||||
void parseStyles(JSVal value, std::map<ClassID, ClassProperties> &styles);
|
||||
void parseStyle(JSVal, ClassProperties &properties);
|
||||
std::unique_ptr<RasterizeProperties> parseRasterize(JSVal value);
|
||||
void parseReference(JSVal value, std::shared_ptr<StyleLayer> &layer);
|
||||
void parseBucket(JSVal value, std::shared_ptr<StyleLayer> &layer);
|
||||
void parseRender(JSVal value, std::shared_ptr<StyleLayer> &layer);
|
||||
|
||||
@@ -89,7 +89,7 @@ struct CompositeProperties {
|
||||
struct RasterProperties {
|
||||
inline RasterProperties() {}
|
||||
float opacity = 1.0f;
|
||||
float spin = 0.0f;
|
||||
float hue_rotate = 0.0f;
|
||||
std::array<float, 2> brightness = {{ 0, 1 }};
|
||||
float saturation = 0.0f;
|
||||
float contrast = 0.0f;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <mbgl/util/transition.hpp>
|
||||
#include <mbgl/util/texturepool.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/renderer/prerendered_texture.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
@@ -25,6 +26,9 @@ public:
|
||||
// bind current texture
|
||||
void bind(bool linear = false);
|
||||
|
||||
// bind prerendered texture
|
||||
void bind(const GLuint texture);
|
||||
|
||||
// loaded status
|
||||
bool isLoaded() const;
|
||||
|
||||
|
||||
@@ -611,7 +611,7 @@ void Map::renderLayers(std::shared_ptr<StyleLayerGroup> group) {
|
||||
for (auto it = group->layers.rbegin(), end = group->layers.rend(); it != end; ++it, ++i) {
|
||||
painter.setOpaque();
|
||||
painter.setStrata(i * strata_thickness);
|
||||
renderLayer(*it, Opaque);
|
||||
renderLayer(*it, RenderPass::Opaque);
|
||||
}
|
||||
if (debug::renderTree) {
|
||||
std::cout << std::string(--indent * 4, ' ') << "}" << std::endl;
|
||||
@@ -627,17 +627,17 @@ void Map::renderLayers(std::shared_ptr<StyleLayerGroup> group) {
|
||||
for (auto it = group->layers.begin(), end = group->layers.end(); it != end; ++it, --i) {
|
||||
painter.setTranslucent();
|
||||
painter.setStrata(i * strata_thickness);
|
||||
renderLayer(*it, Translucent);
|
||||
renderLayer(*it, RenderPass::Translucent);
|
||||
}
|
||||
if (debug::renderTree) {
|
||||
std::cout << std::string(--indent * 4, ' ') << "}" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Map::renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass) {
|
||||
if (layer_desc->layers) {
|
||||
void Map::renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass, const Tile::ID* id, const mat4* matrix) {
|
||||
if (layer_desc->layers && layer_desc->type != StyleLayerType::Raster) {
|
||||
// This is a layer group. We render them during our translucent render pass.
|
||||
if (pass == Translucent) {
|
||||
if (pass == RenderPass::Translucent) {
|
||||
const CompositeProperties &properties = layer_desc->getProperties<CompositeProperties>();
|
||||
if (properties.isVisible()) {
|
||||
gl::group group(std::string("group: ") + layer_desc->id);
|
||||
@@ -698,15 +698,15 @@ void Map::renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass) {
|
||||
if (!layer_desc->getProperties<FillProperties>().isVisible()) return;
|
||||
break;
|
||||
case StyleLayerType::Line:
|
||||
if (pass == Opaque) return;
|
||||
if (pass == RenderPass::Opaque) return;
|
||||
if (!layer_desc->getProperties<LineProperties>().isVisible()) return;
|
||||
break;
|
||||
case StyleLayerType::Symbol:
|
||||
if (pass == Opaque) return;
|
||||
if (pass == RenderPass::Opaque) return;
|
||||
if (!layer_desc->getProperties<SymbolProperties>().isVisible()) return;
|
||||
break;
|
||||
case StyleLayerType::Raster:
|
||||
if (pass == Translucent) return;
|
||||
if (pass == RenderPass::Opaque) return;
|
||||
if (!layer_desc->getProperties<RasterProperties>().isVisible()) return;
|
||||
break;
|
||||
default:
|
||||
@@ -717,7 +717,10 @@ void Map::renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass) {
|
||||
std::cout << std::string(indent * 4, ' ') << "- " << layer_desc->id << " ("
|
||||
<< layer_desc->type << ")" << std::endl;
|
||||
}
|
||||
|
||||
style_source.source->render(painter, layer_desc);
|
||||
if (!id) {
|
||||
style_source.source->render(painter, layer_desc);
|
||||
} else {
|
||||
style_source.source->render(painter, layer_desc, *id, *matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ using namespace mbgl;
|
||||
|
||||
RasterTileData::RasterTileData(Tile::ID id, Map &map, const SourceInfo &source)
|
||||
: TileData(id, map, source),
|
||||
bucket(map.getTexturepool()) {
|
||||
bucket(map.getTexturepool(), properties) {
|
||||
}
|
||||
|
||||
RasterTileData::~RasterTileData() {
|
||||
@@ -25,8 +25,8 @@ void RasterTileData::parse() {
|
||||
}
|
||||
}
|
||||
|
||||
void RasterTileData::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc) {
|
||||
bucket.render(painter, layer_desc, id);
|
||||
void RasterTileData::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix) {
|
||||
bucket.render(painter, layer_desc, id, matrix);
|
||||
}
|
||||
|
||||
bool RasterTileData::hasData(std::shared_ptr<StyleLayer> /*layer_desc*/) const {
|
||||
|
||||
@@ -83,11 +83,18 @@ void Source::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc) {
|
||||
for (const std::pair<const Tile::ID, std::unique_ptr<Tile>> &pair : tiles) {
|
||||
Tile &tile = *pair.second;
|
||||
if (tile.data && tile.data->state == TileData::State::parsed) {
|
||||
painter.renderTileLayer(tile, layer_desc);
|
||||
painter.renderTileLayer(tile, layer_desc, tile.matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Source::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) {
|
||||
auto it = tiles.find(id);
|
||||
if (it != tiles.end() && it->second->data && it->second->data->state == TileData::State::parsed) {
|
||||
painter.renderTileLayer(*it->second, layer_desc, matrix);
|
||||
}
|
||||
}
|
||||
|
||||
void Source::finishRender(Painter &painter) {
|
||||
for (std::pair<const Tile::ID, std::unique_ptr<Tile>> &pair : tiles) {
|
||||
Tile &tile = *pair.second;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <mbgl/geometry/glyph_atlas.hpp>
|
||||
#include <mbgl/text/glyph_store.hpp>
|
||||
#include <mbgl/text/glyph.hpp>
|
||||
#include <mbgl/map/map.hpp>
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/utf.hpp>
|
||||
@@ -69,7 +70,8 @@ void TileParser::parseStyleLayers(std::shared_ptr<StyleLayerGroup> group) {
|
||||
} else if (layer_desc->layers) {
|
||||
// This is a layer group.
|
||||
parseStyleLayers(layer_desc->layers);
|
||||
} else if (layer_desc->bucket) {
|
||||
}
|
||||
if (layer_desc->bucket) {
|
||||
// This is a singular layer. Check if this bucket already exists. If not,
|
||||
// parse this bucket.
|
||||
auto bucket_it = tile.buckets.find(layer_desc->bucket->name);
|
||||
@@ -112,6 +114,8 @@ std::unique_ptr<Bucket> TileParser::createBucket(std::shared_ptr<StyleBucket> bu
|
||||
} else {
|
||||
fprintf(stderr, "[WARNING] unknown bucket render type for layer '%s' (source layer '%s')\n", bucket_desc->name.c_str(), bucket_desc->source_layer.c_str());
|
||||
}
|
||||
} else if (bucket_desc->render.is<StyleBucketRaster>() && bucket_desc->render.get<StyleBucketRaster>().prerendered == true) {
|
||||
return createRasterBucket(texturePool, bucket_desc->render.get<StyleBucketRaster>());
|
||||
} else {
|
||||
// The layer specified in the bucket does not exist. Do nothing.
|
||||
if (debug::tileParseWarnings) {
|
||||
@@ -147,6 +151,11 @@ std::unique_ptr<Bucket> TileParser::createFillBucket(const VectorTileLayer& laye
|
||||
return obsolete() ? nullptr : std::move(bucket);
|
||||
}
|
||||
|
||||
std::unique_ptr<Bucket> TileParser::createRasterBucket(const std::shared_ptr<Texturepool> &texturepool, const StyleBucketRaster &raster) {
|
||||
std::unique_ptr<RasterBucket> bucket = std::make_unique<RasterBucket>(texturepool, raster);
|
||||
return obsolete() ? nullptr : std::move(bucket);
|
||||
}
|
||||
|
||||
std::unique_ptr<Bucket> TileParser::createLineBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketLine &line) {
|
||||
std::unique_ptr<LineBucket> bucket = std::make_unique<LineBucket>(tile.lineVertexBuffer, tile.triangleElementsBuffer, tile.pointElementsBuffer, line);
|
||||
addBucketGeometries(bucket, layer, filter);
|
||||
|
||||
@@ -128,7 +128,7 @@ FilteredVectorTileLayer::iterator::iterator(const FilteredVectorTileLayer& paren
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// if (filterExpression.is<util::recursive_wrapper<PropertyFilter>>()) {
|
||||
|
||||
@@ -21,7 +21,7 @@ VectorTileData::~VectorTileData() {
|
||||
}
|
||||
|
||||
void VectorTileData::beforeParse() {
|
||||
|
||||
|
||||
parser = std::make_unique<TileParser>(data, *this, map.getStyle(), map.getGlyphAtlas(), map.getGlyphStore(), map.getSpriteAtlas(), map.getSprite());
|
||||
}
|
||||
|
||||
@@ -52,12 +52,12 @@ void VectorTileData::afterParse() {
|
||||
parser.reset();
|
||||
}
|
||||
|
||||
void VectorTileData::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc) {
|
||||
void VectorTileData::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix) {
|
||||
if (state == State::parsed && layer_desc->bucket) {
|
||||
auto databucket_it = buckets.find(layer_desc->bucket->name);
|
||||
if (databucket_it != buckets.end()) {
|
||||
assert(databucket_it->second);
|
||||
databucket_it->second->render(painter, layer_desc, id);
|
||||
databucket_it->second->render(painter, layer_desc, id, matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ DebugBucket::DebugBucket(DebugFontBuffer& fontBuffer)
|
||||
: fontBuffer(fontBuffer) {
|
||||
}
|
||||
|
||||
void DebugBucket::render(Painter& painter, std::shared_ptr<StyleLayer> /*layer_desc*/, const Tile::ID& /*id*/) {
|
||||
painter.renderDebugText(*this);
|
||||
void DebugBucket::render(Painter& painter, std::shared_ptr<StyleLayer> /*layer_desc*/, const Tile::ID& /*id*/, const mat4 &matrix) {
|
||||
painter.renderDebugText(*this, matrix);
|
||||
}
|
||||
|
||||
bool DebugBucket::hasData() const {
|
||||
|
||||
@@ -204,8 +204,8 @@ void FillBucket::tessellate() {
|
||||
lineGroup.vertex_length += total_vertex_count;
|
||||
}
|
||||
|
||||
void FillBucket::render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id) {
|
||||
painter.renderFill(*this, layer_desc, id);
|
||||
void FillBucket::render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) {
|
||||
painter.renderFill(*this, layer_desc, id, matrix);
|
||||
}
|
||||
|
||||
bool FillBucket::hasData() const {
|
||||
|
||||
@@ -341,8 +341,8 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
}
|
||||
}
|
||||
|
||||
void LineBucket::render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id) {
|
||||
painter.renderLine(*this, layer_desc, id);
|
||||
void LineBucket::render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) {
|
||||
painter.renderLine(*this, layer_desc, id, matrix);
|
||||
}
|
||||
|
||||
bool LineBucket::hasData() const {
|
||||
|
||||
@@ -144,16 +144,16 @@ void Painter::clear() {
|
||||
}
|
||||
|
||||
void Painter::setOpaque() {
|
||||
if (pass != Opaque) {
|
||||
pass = Opaque;
|
||||
if (pass != RenderPass::Opaque) {
|
||||
pass = RenderPass::Opaque;
|
||||
glDisable(GL_BLEND);
|
||||
depthMask(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Painter::setTranslucent() {
|
||||
if (pass != Translucent) {
|
||||
pass = Translucent;
|
||||
if (pass != RenderPass::Translucent) {
|
||||
pass = RenderPass::Translucent;
|
||||
glEnable(GL_BLEND);
|
||||
depthMask(false);
|
||||
}
|
||||
@@ -164,25 +164,23 @@ void Painter::setStrata(float value) {
|
||||
}
|
||||
|
||||
void Painter::prepareTile(const Tile& tile) {
|
||||
matrix = tile.matrix;
|
||||
|
||||
GLint id = (GLint)tile.clip.mask.to_ulong();
|
||||
GLuint mask = clipMask[tile.clip.length];
|
||||
glStencilFunc(GL_EQUAL, id, mask);
|
||||
}
|
||||
|
||||
void Painter::renderTileLayer(const Tile& tile, std::shared_ptr<StyleLayer> layer_desc) {
|
||||
void Painter::renderTileLayer(const Tile& tile, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix) {
|
||||
assert(tile.data);
|
||||
if (tile.data->hasData(layer_desc)) {
|
||||
if (tile.data->hasData(layer_desc) || layer_desc->type == StyleLayerType::Raster) {
|
||||
gl::group group(util::sprintf<32>("render %d/%d/%d\n", tile.id.z, tile.id.y, tile.id.z));
|
||||
prepareTile(tile);
|
||||
tile.data->render(*this, layer_desc);
|
||||
tile.data->render(*this, layer_desc, matrix);
|
||||
frameHistory.record(map.getAnimationTime(), map.getState().getNormalizedZoom());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const mat4 &Painter::translatedMatrix(const std::array<float, 2> &translation, const Tile::ID &id, TranslateAnchorType anchor) {
|
||||
const mat4 &Painter::translatedMatrix(const mat4& matrix, const std::array<float, 2> &translation, const Tile::ID &id, TranslateAnchorType anchor) {
|
||||
if (translation[0] == 0 && translation[1] == 0) {
|
||||
return matrix;
|
||||
} else {
|
||||
|
||||
@@ -10,12 +10,12 @@ void Painter::renderTileDebug(const Tile& tile) {
|
||||
assert(tile.data);
|
||||
if (debug) {
|
||||
prepareTile(tile);
|
||||
renderDebugText(tile.data->debugBucket);
|
||||
renderDebugFrame();
|
||||
renderDebugText(tile.data->debugBucket, tile.matrix);
|
||||
renderDebugFrame(tile.matrix);
|
||||
}
|
||||
}
|
||||
|
||||
void Painter::renderDebugText(DebugBucket& bucket) {
|
||||
void Painter::renderDebugText(DebugBucket& bucket, const mat4 &matrix) {
|
||||
gl::group group("debug text");
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
@@ -42,7 +42,7 @@ void Painter::renderDebugText(DebugBucket& bucket) {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void Painter::renderDebugFrame() {
|
||||
void Painter::renderDebugFrame(const mat4 &matrix) {
|
||||
gl::group group("debug frame");
|
||||
|
||||
// Disable depth test and don't count this towards the depth buffer,
|
||||
|
||||
@@ -38,7 +38,7 @@ void Painter::renderFill(FillBucket& bucket, const FillProperties& properties, c
|
||||
|
||||
// Because we're drawing top-to-bottom, and we update the stencil mask
|
||||
// below, we have to draw the outline first (!)
|
||||
if (outline && pass == Translucent) {
|
||||
if (outline && pass == RenderPass::Translucent) {
|
||||
useProgram(outlineShader->program);
|
||||
outlineShader->setMatrix(vtxMatrix);
|
||||
lineWidth(2.0f); // This is always fixed and does not depend on the pixelRatio!
|
||||
@@ -70,7 +70,7 @@ void Painter::renderFill(FillBucket& bucket, const FillProperties& properties, c
|
||||
// glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP);
|
||||
}
|
||||
|
||||
if ((fill_color[3] >= 1.0f) == (pass == Opaque)) {
|
||||
if ((fill_color[3] >= 1.0f) == (pass == RenderPass::Opaque)) {
|
||||
Sprite &sprite = *map.getSprite();
|
||||
if (properties.image.size() && sprite) {
|
||||
SpriteAtlas &spriteAtlas = *map.getSpriteAtlas();
|
||||
@@ -128,7 +128,7 @@ void Painter::renderFill(FillBucket& bucket, const FillProperties& properties, c
|
||||
|
||||
// Because we're drawing top-to-bottom, and we update the stencil mask
|
||||
// below, we have to draw the outline first (!)
|
||||
if (fringeline && pass == Translucent) {
|
||||
if (fringeline && pass == RenderPass::Translucent) {
|
||||
useProgram(outlineShader->program);
|
||||
outlineShader->setMatrix(vtxMatrix);
|
||||
lineWidth(2.0f); // This is always fixed and does not depend on the pixelRatio!
|
||||
@@ -146,59 +146,10 @@ void Painter::renderFill(FillBucket& bucket, const FillProperties& properties, c
|
||||
}
|
||||
}
|
||||
|
||||
void Painter::renderFill(FillBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id) {
|
||||
void Painter::renderFill(FillBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) {
|
||||
// Abort early.
|
||||
if (!bucket.hasData()) return;
|
||||
|
||||
const FillProperties &properties = layer_desc->getProperties<FillProperties>();
|
||||
|
||||
if (layer_desc->rasterize && layer_desc->rasterize->isEnabled(id.z)) {
|
||||
if (pass == Translucent) {
|
||||
const RasterizedProperties rasterize = layer_desc->rasterize->get(id.z);
|
||||
// Buffer value around the 0..4096 extent that will be drawn into the 256x256 pixel
|
||||
// texture. We later scale the texture so that the actual bounds will align with this
|
||||
// tile's bounds. The reason we do this is so that the
|
||||
if (!bucket.prerendered) {
|
||||
bucket.prerendered = std::make_unique<PrerenderedTexture>(rasterize);
|
||||
bucket.prerendered->bindFramebuffer();
|
||||
|
||||
preparePrerender(*bucket.prerendered);
|
||||
|
||||
const FillProperties modifiedProperties = [&]{
|
||||
FillProperties modifiedProperties = properties;
|
||||
modifiedProperties.opacity = 1;
|
||||
return modifiedProperties;
|
||||
}();
|
||||
|
||||
// When drawing the fill, we want to draw a buffer around too, so we
|
||||
// essentially downscale everyting, and then upscale it later when rendering.
|
||||
const int buffer = rasterize.buffer * 4096.0f;
|
||||
const mat4 vtxMatrix = [&]{
|
||||
mat4 vtxMatrix;
|
||||
matrix::ortho(vtxMatrix, -buffer, 4096 + buffer, -4096 - buffer, buffer, 0, 1);
|
||||
matrix::translate(vtxMatrix, vtxMatrix, 0, -4096, 0);
|
||||
return vtxMatrix;
|
||||
}();
|
||||
|
||||
setOpaque();
|
||||
renderFill(bucket, modifiedProperties, id, vtxMatrix);
|
||||
|
||||
setTranslucent();
|
||||
renderFill(bucket, modifiedProperties, id, vtxMatrix);
|
||||
|
||||
if (rasterize.blur > 0) {
|
||||
bucket.prerendered->blur(*this, rasterize.blur);
|
||||
}
|
||||
|
||||
// RESET STATE
|
||||
bucket.prerendered->unbindFramebuffer();
|
||||
finishPrerender(*bucket.prerendered);
|
||||
}
|
||||
|
||||
renderPrerenderedTexture(*bucket.prerendered, properties);
|
||||
}
|
||||
} else {
|
||||
const mat4 &vtxMatrix = translatedMatrix(properties.translate, id, properties.translateAnchor);
|
||||
renderFill(bucket, properties, id, vtxMatrix);
|
||||
}
|
||||
const mat4 &vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor);
|
||||
renderFill(bucket, properties, id, vtxMatrix);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
void Painter::renderLine(LineBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id) {
|
||||
void Painter::renderLine(LineBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) {
|
||||
// Abort early.
|
||||
if (pass == Opaque) return;
|
||||
if (pass == RenderPass::Opaque) return;
|
||||
if (!bucket.hasData()) return;
|
||||
|
||||
const LineProperties &properties = layer_desc->getProperties<LineProperties>();
|
||||
@@ -31,7 +31,7 @@ void Painter::renderLine(LineBucket& bucket, std::shared_ptr<StyleLayer> layer_d
|
||||
float dash_length = properties.dash_array[0];
|
||||
float dash_gap = properties.dash_array[1];
|
||||
|
||||
const mat4 &vtxMatrix = translatedMatrix(properties.translate, id, properties.translateAnchor);
|
||||
const mat4 &vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor);
|
||||
|
||||
glDepthRange(strata, 1.0f);
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include <mbgl/renderer/painter.hpp>
|
||||
#include <mbgl/style/style_properties.hpp>
|
||||
#include <mbgl/renderer/prerendered_texture.hpp>
|
||||
#include <mbgl/renderer/raster_bucket.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
void Painter::preparePrerender(PrerenderedTexture &texture) {
|
||||
void Painter::preparePrerender(RasterBucket &bucket) {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
|
||||
@@ -12,21 +14,14 @@ void Painter::preparePrerender(PrerenderedTexture &texture) {
|
||||
const GLenum discards[] = {GL_COLOR_ATTACHMENT0};
|
||||
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards);
|
||||
#endif
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glViewport(0, 0, texture.properties.size, texture.properties.size);
|
||||
glViewport(0, 0, bucket.properties.size, bucket.properties.size);
|
||||
}
|
||||
|
||||
void Painter::finishPrerender(PrerenderedTexture &/*texture*/) {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
|
||||
glViewport(0, 0, gl_viewport[0], gl_viewport[1]);
|
||||
}
|
||||
|
||||
template <typename Properties>
|
||||
void Painter::renderPrerenderedTexture(PrerenderedTexture &texture, const Properties &properties) {
|
||||
const int buffer = texture.properties.buffer * 4096.0f;
|
||||
void Painter::renderPrerenderedTexture(RasterBucket &bucket, const mat4 &matrix, const RasterProperties& properties) {
|
||||
const int buffer = bucket.properties.buffer * 4096.0f;
|
||||
|
||||
// draw the texture on a quad
|
||||
useProgram(rasterShader->program);
|
||||
@@ -39,9 +34,11 @@ void Painter::renderPrerenderedTexture(PrerenderedTexture &texture, const Proper
|
||||
rasterShader->setImage(0);
|
||||
rasterShader->setBuffer(buffer);
|
||||
rasterShader->setOpacity(properties.opacity);
|
||||
texture.bindTexture();
|
||||
rasterShader->setBrightness(properties.brightness[0], properties.brightness[1]);
|
||||
rasterShader->setSaturation(properties.saturation);
|
||||
rasterShader->setContrast(properties.contrast);
|
||||
rasterShader->setSpin(spinWeights(properties.hue_rotate));
|
||||
bucket.texture.bindTexture();
|
||||
coveringRasterArray.bind(*rasterShader, tileStencilBuffer, BUFFER_OFFSET(0));
|
||||
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index());
|
||||
}
|
||||
|
||||
template void Painter::renderPrerenderedTexture(PrerenderedTexture &, const FillProperties &);
|
||||
|
||||
@@ -1,25 +1,93 @@
|
||||
#include <mbgl/renderer/painter.hpp>
|
||||
#include <mbgl/platform/gl.hpp>
|
||||
#include <mbgl/renderer/raster_bucket.hpp>
|
||||
#include <mbgl/style/style_layer.hpp>
|
||||
#include <mbgl/style/style_layer_group.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/map/transform.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> /*layer_desc*/, const Tile::ID& /*id*/) {
|
||||
if (pass == Translucent) return;
|
||||
void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) {
|
||||
if (pass != RenderPass::Translucent) return;
|
||||
|
||||
// const RasterProperties &properties = layer_desc->getProperties<RasterProperties>();
|
||||
const RasterProperties &properties = layer_desc->getProperties<RasterProperties>();
|
||||
|
||||
depthMask(false);
|
||||
if (layer_desc->layers) {
|
||||
|
||||
useProgram(rasterShader->program);
|
||||
rasterShader->setMatrix(matrix);
|
||||
rasterShader->setBuffer(0);
|
||||
rasterShader->setOpacity(1);
|
||||
// rasterShader->setOpacity(properties.opacity * tile_data->raster->opacity);
|
||||
if (!bucket.texture.getTexture()) {
|
||||
|
||||
glDepthRange(strata + strata_epsilon, 1.0f);
|
||||
bucket.drawRaster(*rasterShader, tileStencilBuffer, coveringRasterArray);
|
||||
bucket.texture.bindFramebuffer();
|
||||
|
||||
preparePrerender(bucket);
|
||||
|
||||
const int buffer = bucket.properties.buffer * 4096.0f;
|
||||
|
||||
const mat4 preMatrix = [&]{
|
||||
mat4 vtxMatrix;
|
||||
matrix::ortho(vtxMatrix, -buffer, 4096 + buffer, -4096 - buffer, buffer, 0, 1);
|
||||
matrix::translate(vtxMatrix, vtxMatrix, 0, -4096, 0);
|
||||
return vtxMatrix;
|
||||
}();
|
||||
|
||||
// call updateTiles to get parsed data for sublayers
|
||||
map.updateTiles();
|
||||
|
||||
for (const std::shared_ptr<StyleLayer> &layer : layer_desc->layers->layers) {
|
||||
setOpaque();
|
||||
map.renderLayer(layer, RenderPass::Opaque, &id, &preMatrix);
|
||||
setTranslucent();
|
||||
map.renderLayer(layer, RenderPass::Translucent, &id, &preMatrix);
|
||||
}
|
||||
|
||||
if (bucket.properties.blur > 0) {
|
||||
bucket.texture.blur(*this, bucket.properties.blur);
|
||||
}
|
||||
|
||||
bucket.texture.unbindFramebuffer();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
|
||||
glViewport(0, 0, gl_viewport[0], gl_viewport[1]);
|
||||
|
||||
}
|
||||
|
||||
renderPrerenderedTexture(bucket, matrix, properties);
|
||||
|
||||
}
|
||||
|
||||
// Only draw non-prerendered raster here
|
||||
if (bucket.hasData()) {
|
||||
depthMask(false);
|
||||
|
||||
useProgram(rasterShader->program);
|
||||
rasterShader->setMatrix(matrix);
|
||||
rasterShader->setBuffer(0);
|
||||
rasterShader->setOpacity(properties.opacity);
|
||||
rasterShader->setBrightness(properties.brightness[0], properties.brightness[1]);
|
||||
rasterShader->setSaturation(properties.saturation);
|
||||
rasterShader->setContrast(properties.contrast);
|
||||
rasterShader->setSpin(spinWeights(properties.hue_rotate));
|
||||
|
||||
glDepthRange(strata + strata_epsilon, 1.0f);
|
||||
|
||||
bucket.drawRaster(*rasterShader, tileStencilBuffer, coveringRasterArray);
|
||||
|
||||
depthMask(true);
|
||||
}
|
||||
|
||||
depthMask(true);
|
||||
}
|
||||
|
||||
std::array<float, 3> Painter::spinWeights(float spin) {
|
||||
spin *= M_PI / 180;
|
||||
float s = std::sin(spin);
|
||||
float c = std::cos(spin);
|
||||
std::array<float, 3> spin_weights = {{
|
||||
(2 * c + 1) / 3,
|
||||
(-std::sqrt(3.0f) * s - c + 1) / 3,
|
||||
(std::sqrt(3.0f) * s - c + 1) / 3
|
||||
}};
|
||||
return spin_weights;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
namespace mbgl {
|
||||
|
||||
void Painter::renderSymbol(SymbolBucket &bucket, std::shared_ptr<StyleLayer> layer_desc,
|
||||
const Tile::ID &/*id*/) {
|
||||
const Tile::ID &/*id*/, const mat4 &matrix) {
|
||||
// Abort early.
|
||||
if (pass == Opaque) {
|
||||
if (pass == RenderPass::Opaque) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include <mbgl/renderer/prerendered_texture.hpp>
|
||||
|
||||
#include <mbgl/renderer/painter.hpp>
|
||||
#include <mbgl/style/style_bucket.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
PrerenderedTexture::PrerenderedTexture(const RasterizedProperties &properties)
|
||||
PrerenderedTexture::PrerenderedTexture(const StyleBucketRaster &properties)
|
||||
: properties(properties) {
|
||||
}
|
||||
|
||||
@@ -44,10 +45,24 @@ void PrerenderedTexture::bindFramebuffer() {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
if (fbo_depth_stencil == 0) {
|
||||
// Create depth/stencil buffer
|
||||
glGenRenderbuffers(1, &fbo_depth_stencil);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, fbo_depth_stencil);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, properties.size, properties.size);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
}
|
||||
|
||||
if (fbo == 0) {
|
||||
glGenFramebuffers(1, &fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
|
||||
#ifdef GL_ES_VERSION_2_0
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo_depth_stencil);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fbo_depth_stencil);
|
||||
#else
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fbo_depth_stencil);
|
||||
#endif
|
||||
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
RasterBucket::RasterBucket(const std::shared_ptr<Texturepool> &texturepool)
|
||||
: raster(texturepool) {
|
||||
RasterBucket::RasterBucket(const std::shared_ptr<Texturepool> &texturepool, const StyleBucketRaster& properties)
|
||||
: properties(properties),
|
||||
texture(properties),
|
||||
raster(texturepool) {
|
||||
}
|
||||
|
||||
void RasterBucket::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID &id) {
|
||||
painter.renderRaster(*this, layer_desc, id);
|
||||
void RasterBucket::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) {
|
||||
painter.renderRaster(*this, layer_desc, id, matrix);
|
||||
}
|
||||
|
||||
bool RasterBucket::setImage(const std::string &data) {
|
||||
@@ -22,6 +24,13 @@ void RasterBucket::drawRaster(RasterShader& shader, VertexBuffer &vertices, Vert
|
||||
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.index());
|
||||
}
|
||||
|
||||
void RasterBucket::drawRaster(RasterShader& shader, VertexBuffer &vertices, VertexArrayObject &array, GLuint texture) {
|
||||
raster.bind(texture);
|
||||
shader.setImage(0);
|
||||
array.bind(shader, vertices, BUFFER_OFFSET(0));
|
||||
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.index());
|
||||
}
|
||||
|
||||
bool RasterBucket::hasData() const {
|
||||
return raster.isLoaded();
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ SymbolBucket::SymbolBucket(const StyleBucketSymbol &properties, Collision &colli
|
||||
: properties(properties), collision(collision) {}
|
||||
|
||||
void SymbolBucket::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc,
|
||||
const Tile::ID &id) {
|
||||
painter.renderSymbol(*this, layer_desc, id);
|
||||
const Tile::ID &id, const mat4 &matrix) {
|
||||
painter.renderSymbol(*this, layer_desc, id, matrix);
|
||||
}
|
||||
|
||||
bool SymbolBucket::hasData() const { return hasTextData() || hasIconData(); }
|
||||
|
||||
@@ -3,6 +3,34 @@ uniform float u_opacity;
|
||||
|
||||
varying vec2 v_pos;
|
||||
|
||||
uniform float u_brightness_low;
|
||||
uniform float u_brightness_high;
|
||||
|
||||
uniform float u_saturation_factor;
|
||||
uniform float u_contrast_factor;
|
||||
uniform vec3 u_spin_weights;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D(u_image, v_pos) * u_opacity;
|
||||
|
||||
vec4 color = texture2D(u_image, v_pos) * u_opacity;
|
||||
vec3 rgb = color.rgb;
|
||||
|
||||
// spin
|
||||
rgb = vec3(
|
||||
dot(rgb, u_spin_weights.xyz),
|
||||
dot(rgb, u_spin_weights.zxy),
|
||||
dot(rgb, u_spin_weights.yzx));
|
||||
|
||||
// saturation
|
||||
float average = (color.r + color.g + color.b) / 3.0;
|
||||
rgb += (average - rgb) * u_saturation_factor;
|
||||
|
||||
// contrast
|
||||
rgb = (rgb - 0.5) * u_contrast_factor + 0.5;
|
||||
|
||||
// brightness
|
||||
vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low);
|
||||
vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);
|
||||
|
||||
gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb), color.a);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,11 @@ RasterShader::RasterShader()
|
||||
u_image = glGetUniformLocation(program, "u_image");
|
||||
u_opacity = glGetUniformLocation(program, "u_opacity");
|
||||
u_buffer = glGetUniformLocation(program, "u_buffer");
|
||||
u_brightness_low = glGetUniformLocation(program, "u_brightness_low");
|
||||
u_brightness_high = glGetUniformLocation(program, "u_brightness_high");
|
||||
u_saturation_factor = glGetUniformLocation(program, "u_saturation_factor");
|
||||
u_contrast_factor = glGetUniformLocation(program, "u_contrast_factor");
|
||||
u_spin_weights = glGetUniformLocation(program, "u_spin_weights");
|
||||
|
||||
// fprintf(stderr, "RasterShader:\n");
|
||||
// fprintf(stderr, " - u_matrix: %d\n", u_matrix);
|
||||
@@ -57,3 +62,45 @@ void RasterShader::setBuffer(float new_buffer) {
|
||||
buffer = new_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void RasterShader::setBrightness(float new_brightness_low, float new_brightness_high) {
|
||||
if (brightness_low != new_brightness_low) {
|
||||
glUniform1f(u_brightness_low, new_brightness_low);
|
||||
brightness_low = new_brightness_low;
|
||||
}
|
||||
if (brightness_high != new_brightness_high) {
|
||||
glUniform1f(u_brightness_high, new_brightness_high);
|
||||
brightness_high = new_brightness_high;
|
||||
}
|
||||
}
|
||||
|
||||
void RasterShader::setSaturation(float new_saturation_factor) {
|
||||
if (saturation_factor != new_saturation_factor) {
|
||||
if (new_saturation_factor > 0) {
|
||||
new_saturation_factor = 1 - 1 / (1.001 - new_saturation_factor);
|
||||
} else {
|
||||
new_saturation_factor = -new_saturation_factor;
|
||||
}
|
||||
glUniform1f(u_saturation_factor, new_saturation_factor);
|
||||
saturation_factor = new_saturation_factor;
|
||||
}
|
||||
}
|
||||
|
||||
void RasterShader::setContrast(float new_contrast_factor) {
|
||||
if (contrast_factor != new_contrast_factor) {
|
||||
if (new_contrast_factor > 0) {
|
||||
new_contrast_factor = 1 / (1 - new_contrast_factor);
|
||||
} else {
|
||||
new_contrast_factor = 1 + new_contrast_factor;
|
||||
}
|
||||
glUniform1f(u_contrast_factor, new_contrast_factor);
|
||||
contrast_factor = new_contrast_factor;
|
||||
}
|
||||
}
|
||||
|
||||
void RasterShader::setSpin(std::array<float, 3> new_spin_weights) {
|
||||
if (spin_weights != new_spin_weights) {
|
||||
glUniform3fv(u_spin_weights, 1, new_spin_weights.data());
|
||||
spin_weights = new_spin_weights;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
|
||||
{ PropertyKey::CompositeOpacity, defaultStyleProperties<CompositeProperties>().opacity },
|
||||
|
||||
{ PropertyKey::RasterOpacity, defaultStyleProperties<RasterProperties>().opacity },
|
||||
{ PropertyKey::RasterSpin, defaultStyleProperties<RasterProperties>().spin },
|
||||
{ PropertyKey::RasterHueRotate, defaultStyleProperties<RasterProperties>().hue_rotate },
|
||||
{ PropertyKey::RasterBrightnessLow, defaultStyleProperties<RasterProperties>().brightness[0] },
|
||||
{ PropertyKey::RasterBrightnessHigh, defaultStyleProperties<RasterProperties>().brightness[1] },
|
||||
{ PropertyKey::RasterSaturation, defaultStyleProperties<RasterProperties>().saturation },
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
StyleLayer::StyleLayer(const std::string &id, std::map<ClassID, ClassProperties> &&styles,
|
||||
std::unique_ptr<const RasterizeProperties> &&rasterize)
|
||||
: id(id), styles(std::move(styles)), rasterize(std::move(rasterize)) {}
|
||||
StyleLayer::StyleLayer(const std::string &id, std::map<ClassID, ClassProperties> &&styles)
|
||||
: id(id), styles(std::move(styles)) {}
|
||||
|
||||
bool StyleLayer::isBackground() const {
|
||||
return type == StyleLayerType::Background;
|
||||
@@ -229,7 +228,7 @@ void StyleLayer::applyStyleProperties<RasterProperties>(const float z, const tim
|
||||
properties.set<RasterProperties>();
|
||||
RasterProperties &raster = properties.get<RasterProperties>();
|
||||
applyStyleProperty(PropertyKey::RasterOpacity, raster.opacity, z, now);
|
||||
applyStyleProperty(PropertyKey::RasterSpin, raster.spin, z, now);
|
||||
applyStyleProperty(PropertyKey::RasterHueRotate, raster.hue_rotate, z, now);
|
||||
applyStyleProperty(PropertyKey::RasterBrightnessLow, raster.brightness[0], z, now);
|
||||
applyStyleProperty(PropertyKey::RasterBrightnessHigh, raster.brightness[1], z, now);
|
||||
applyStyleProperty(PropertyKey::RasterSaturation, raster.saturation, z, now);
|
||||
|
||||
@@ -344,7 +344,7 @@ bool StyleParser::parseOptionalProperty(const char *property_name, PropertyKey k
|
||||
template <typename T>
|
||||
bool StyleParser::parseOptionalProperty(const char *property_name, T &target, JSVal value) {
|
||||
if (!value.HasMember(property_name)) {
|
||||
return false;
|
||||
return false;
|
||||
} else {
|
||||
return setProperty<T>(replaceConstant(value[property_name]), property_name, target);
|
||||
}
|
||||
@@ -492,14 +492,8 @@ std::shared_ptr<StyleLayer> StyleParser::createLayer(JSVal value) {
|
||||
std::map<ClassID, ClassProperties> styles;
|
||||
parseStyles(value, styles);
|
||||
|
||||
// Parse Rasterization options, as they can't be inherited anyway.
|
||||
std::unique_ptr<const RasterizeProperties> rasterize;
|
||||
if (value.HasMember("rasterize")) {
|
||||
rasterize = parseRasterize(replaceConstant(value["rasterize"]));
|
||||
}
|
||||
|
||||
std::shared_ptr<StyleLayer> layer = std::make_shared<StyleLayer>(
|
||||
layer_id, std::move(styles), std::move(rasterize));
|
||||
layer_id, std::move(styles));
|
||||
|
||||
if (value.HasMember("layers")) {
|
||||
layer->layers = createLayers(value["layers"]);
|
||||
@@ -525,11 +519,6 @@ void StyleParser::parseLayer(std::pair<JSVal, std::shared_ptr<StyleLayer>> &pair
|
||||
JSVal value = pair.first;
|
||||
std::shared_ptr<StyleLayer> &layer = pair.second;
|
||||
|
||||
if (layer->bucket || layer->layers) {
|
||||
// Skip parsing this again. We already have a valid layer definition.
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.HasMember("type")) {
|
||||
JSVal type = value["type"];
|
||||
if (!type.IsString()) {
|
||||
@@ -539,6 +528,11 @@ void StyleParser::parseLayer(std::pair<JSVal, std::shared_ptr<StyleLayer>> &pair
|
||||
}
|
||||
}
|
||||
|
||||
if (layer->bucket || (layer->layers && layer->type != StyleLayerType::Raster)) {
|
||||
// Skip parsing this again. We already have a valid layer definition.
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure we have not previously attempted to parse this layer.
|
||||
if (std::find(stack.begin(), stack.end(), layer.get()) != stack.end()) {
|
||||
Log::Warning(Event::ParseStyle, "layer reference of '%s' is circular", layer->id.c_str());
|
||||
@@ -639,12 +633,10 @@ void StyleParser::parseStyle(JSVal value, ClassProperties &klass) {
|
||||
|
||||
parseOptionalProperty<Function<float>>("raster-opacity", Key::RasterOpacity, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-raster-opacity", Key::RasterOpacity, klass, value);
|
||||
parseOptionalProperty<Function<float>>("raster-spin", Key::RasterSpin, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-raster-spin", Key::RasterSpin, klass, value);
|
||||
parseOptionalProperty<Function<float>>("raster-brightness-low", Key::RasterBrightnessLow, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-raster-brightness-low", Key::RasterBrightnessLow, klass, value);
|
||||
parseOptionalProperty<Function<float>>("raster-brightness-high", Key::RasterBrightnessHigh, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-raster-brightness-high", Key::RasterBrightnessHigh, klass, value);
|
||||
parseOptionalProperty<Function<float>>("raster-hue-rotate", Key::RasterHueRotate, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-raster-hue-rotate", Key::RasterHueRotate, klass, value);
|
||||
parseOptionalProperty<Function<float>>("raster-brightness", { Key::RasterBrightnessLow, Key::RasterBrightnessHigh }, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-raster-brightness", Key::RasterBrightness, klass, value);
|
||||
parseOptionalProperty<Function<float>>("raster-saturation", Key::RasterSaturation, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-raster-saturation", Key::RasterSaturation, klass, value);
|
||||
parseOptionalProperty<Function<float>>("raster-contrast", Key::RasterContrast, klass, value);
|
||||
@@ -655,19 +647,6 @@ void StyleParser::parseStyle(JSVal value, ClassProperties &klass) {
|
||||
parseOptionalProperty<Function<Color>>("background-color", Key::BackgroundColor, klass, value);
|
||||
}
|
||||
|
||||
std::unique_ptr<RasterizeProperties> StyleParser::parseRasterize(JSVal value) {
|
||||
auto rasterize = std::make_unique<RasterizeProperties>();
|
||||
|
||||
if (value.IsObject()) {
|
||||
parseOptionalProperty("enabled", rasterize->enabled, value);
|
||||
parseOptionalProperty("buffer", rasterize->buffer, value);
|
||||
parseOptionalProperty("size", rasterize->size, value);
|
||||
parseOptionalProperty("blur", rasterize->blur, value);
|
||||
}
|
||||
|
||||
return rasterize;
|
||||
}
|
||||
|
||||
void StyleParser::parseReference(JSVal value, std::shared_ptr<StyleLayer> &layer) {
|
||||
if (!value.IsString()) {
|
||||
Log::Warning(Event::ParseStyle, "layer ref of '%s' must be a string", layer->id.c_str());
|
||||
@@ -925,6 +904,18 @@ void StyleParser::parseRender(JSVal value, std::shared_ptr<StyleLayer> &layer) {
|
||||
parseRenderProperty(value, render.text.ignore_placement, "text-ignore-placement");
|
||||
parseRenderProperty(value, render.text.optional, "text-optional");
|
||||
} break;
|
||||
|
||||
case StyleLayerType::Raster: {
|
||||
StyleBucketRaster &render = bucket.render.get<StyleBucketRaster>();
|
||||
|
||||
parseRenderProperty(value, render.size, "raster-size");
|
||||
parseRenderProperty(value, render.blur, "raster-blur");
|
||||
parseRenderProperty(value, render.buffer, "raster-buffer");
|
||||
if (layer->layers) {
|
||||
render.prerendered = true;
|
||||
}
|
||||
} break;
|
||||
|
||||
default:
|
||||
// There are no render properties for these layer types.
|
||||
break;
|
||||
|
||||
@@ -68,6 +68,28 @@ void Raster::bind(bool linear) {
|
||||
}
|
||||
}
|
||||
|
||||
// overload ::bind for prerendered raster textures
|
||||
void Raster::bind(const GLuint texture) {
|
||||
if (img && !textured) {
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->getData());
|
||||
img.reset();
|
||||
textured = true;
|
||||
} else if (textured) {
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
}
|
||||
|
||||
GLuint filter = GL_LINEAR;
|
||||
if (filter != this->filter) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||
this->filter = filter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Raster::beginFadeInTransition() {
|
||||
timestamp start = util::now();
|
||||
fade_transition = std::make_shared<util::ease_transition<double>>(opacity, 1.0, opacity, start, 250_milliseconds);
|
||||
|
||||
@@ -25,7 +25,7 @@ GLuint Texturepool::getTextureID() {
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
void Texturepool::removeTextureID(GLuint texture_id) {
|
||||
bool needs_clear = false;
|
||||
|
||||
|
||||
2220
styles/outdoors/style.json
Normal file
2220
styles/outdoors/style.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user