pass style into painter

This commit is contained in:
Konstantin Käfer
2014-01-23 16:36:04 +01:00
parent 9ba8d5b7a6
commit 2a6e4597e2
5 changed files with 12 additions and 11 deletions

View File

@@ -60,8 +60,8 @@ private:
private:
Settings& settings;
Transform transform;
Painter painter;
Style style;
Painter painter;
int32_t min_zoom;
int32_t max_zoom;

View File

@@ -11,13 +11,14 @@ namespace llmr {
class Settings;
class Transform;
class Style;
class FillBucket;
struct FillProperties;
class Painter {
public:
Painter(Transform& transform, Settings& settings);
Painter(Transform& transform, Settings& settings, Style& style);
// Make noncopyable
Painter(const Painter&) = delete;
@@ -49,6 +50,7 @@ public:
private:
Transform& transform;
Settings& settings;
Style& style;
float matrix[16];
Shader *currentShader;

View File

@@ -2,6 +2,7 @@
#define LLMR_STYLE_STYLE
#include <array>
#include <map>
#include "../util/pbf.hpp"
namespace llmr {
@@ -43,8 +44,9 @@ public:
void reset();
void load(pbf data);
// StrokeStyle strokeStyle(const std::string& layer_name) const;
// FillProperties fillStyle(const std::string& layer_name) const;
public:
std::map<std::string, FillProperties> computedFills;
std::map<std::string, StrokeProperties> computedStrokes;
};
}

View File

@@ -13,8 +13,8 @@ using namespace llmr;
Map::Map(Settings& settings)
: settings(settings),
transform(),
painter(transform, settings),
style(),
painter(transform, settings, style),
min_zoom(0),
max_zoom(14) {
}

View File

@@ -39,9 +39,10 @@ GLshort tile_border_vertices[] = {
0, 0
};
Painter::Painter(Transform& transform, Settings& settings)
Painter::Painter(Transform& transform, Settings& settings, Style& style)
: transform(transform),
settings(settings),
style(style),
currentShader(NULL),
fillShader(NULL),
lineShader(NULL),
@@ -180,11 +181,7 @@ void Painter::render(const Tile::Ptr& tile) {
}
void Painter::renderFill(FillBucket& bucket, const std::string& layer_name) {
// TODO: obtain the correct style information for this layer
FillProperties properties;
properties.fill_color = {{ 0, 0, 1, 0.5 }};
properties.stroke_color = properties.fill_color;
const FillProperties& properties = style.computedFills[layer_name];
// Draw the stencil mask.
{