summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauren Budorick <lauren@mapbox.com>2014-08-11 12:02:46 -0700
committerLauren Budorick <lauren@mapbox.com>2014-08-11 12:13:24 -0700
commit41165452bcf16e90f6e4265123021e56cfb021f6 (patch)
tree6c7f19cebe19c931141f0e1b99f37a472436f6ed
parent1ad2f26b9d753940e26d0ac3be96392feb73ae9e (diff)
downloadqtlocation-mapboxgl-41165452bcf16e90f6e4265123021e56cfb021f6.tar.gz
some cleaning up, raster spin->hue-rotate rename
-rw-r--r--include/mbgl/renderer/painter.hpp4
-rw-r--r--include/mbgl/style/property_key.hpp2
-rw-r--r--include/mbgl/style/style_properties.hpp2
-rw-r--r--src/map/tile_parser.cpp5
-rw-r--r--src/renderer/painter_prerender.cpp12
-rw-r--r--src/renderer/painter_raster.cpp52
-rw-r--r--src/style/property_fallback.cpp2
-rw-r--r--src/style/style_layer.cpp2
-rw-r--r--src/style/style_parser.cpp4
9 files changed, 26 insertions, 59 deletions
diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp
index d4810cf69b..80948c49b1 100644
--- a/include/mbgl/renderer/painter.hpp
+++ b/include/mbgl/renderer/painter.hpp
@@ -43,6 +43,7 @@ class RasterBucket;
class PrerenderedTexture;
struct FillProperties;
+struct RasterProperties;
struct CompositeProperties;
class LayerDescription;
@@ -87,9 +88,8 @@ public:
void renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
void preparePrerender(RasterBucket &bucket);
- void finishPrerender(RasterBucket &bucket);
- void renderPrerenderedTexture(RasterBucket &bucket, const mat4 &matrix);
+ void renderPrerenderedTexture(RasterBucket &bucket, const mat4 &matrix, const RasterProperties& properties);
void createPrerendered(RasterBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id);
diff --git a/include/mbgl/style/property_key.hpp b/include/mbgl/style/property_key.hpp
index 68dc709597..7d24981765 100644
--- a/include/mbgl/style/property_key.hpp
+++ b/include/mbgl/style/property_key.hpp
@@ -54,7 +54,7 @@ enum class PropertyKey {
CompositeOpacity,
RasterOpacity,
- RasterSpin,
+ RasterHueRotate,
RasterBrightnessLow,
RasterBrightnessHigh,
RasterSaturation,
diff --git a/include/mbgl/style/style_properties.hpp b/include/mbgl/style/style_properties.hpp
index 35ea97781b..f12ab430e3 100644
--- a/include/mbgl/style/style_properties.hpp
+++ b/include/mbgl/style/style_properties.hpp
@@ -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;
diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp
index 35ad66d69d..7c3b720f62 100644
--- a/src/map/tile_parser.cpp
+++ b/src/map/tile_parser.cpp
@@ -45,7 +45,6 @@ TileParser::TileParser(const std::string &data, VectorTileData &tile,
spriteAtlas(spriteAtlas),
sprite(sprite),
collision(tile.id.z, 4096, tile.source.tile_size, tile.depth) {
-// placement(tile.id.z, tile.id.z >= tile.source.max_zoom ? tile.source.max_zoom - tile.id.z : 1) { // TODO : i'm guessing remove this in the rebase?
}
void TileParser::parse() {
@@ -84,7 +83,6 @@ void TileParser::parseStyleLayers(std::shared_ptr<StyleLayerGroup> group) {
// contain any data that falls into this bucket.
tile.buckets[layer_desc->bucket->name] = std::move(bucket);
}
- // TODO? here, no bucket is being created for prerender raster layers (though buckets are being created for its sublayers)...
}
} else {
fprintf(stderr, "[WARNING] layer '%s' does not have child layers or buckets\n", layer_desc->id.c_str());
@@ -116,8 +114,7 @@ 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>()) {
- // Assume this is a prerendered raster layer -- TODO more thorough checking here??
+ } 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.
diff --git a/src/renderer/painter_prerender.cpp b/src/renderer/painter_prerender.cpp
index 42033271b1..429f3cc80d 100644
--- a/src/renderer/painter_prerender.cpp
+++ b/src/renderer/painter_prerender.cpp
@@ -20,14 +20,7 @@ void Painter::preparePrerender(RasterBucket &bucket) {
glViewport(0, 0, bucket.properties.size, bucket.properties.size);
}
-void Painter::finishPrerender(RasterBucket &bucket) {
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_STENCIL_TEST);
-
- glViewport(0, 0, gl_viewport[0], gl_viewport[1]);
-}
-
-void Painter::renderPrerenderedTexture(RasterBucket &bucket, const mat4 &matrix) {
+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
@@ -40,8 +33,7 @@ void Painter::renderPrerenderedTexture(RasterBucket &bucket, const mat4 &matrix)
glActiveTexture(GL_TEXTURE0);
rasterShader->setImage(0);
rasterShader->setBuffer(buffer);
- rasterShader->setOpacity(1);
-// rasterShader->setOpacity(bucket.properties.opacity); // TODO find a place to pass opacity and change this back
+ rasterShader->setOpacity(properties.opacity);
bucket.texture.bindTexture();
coveringRasterArray.bind(*rasterShader, tileStencilBuffer, BUFFER_OFFSET(0));
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index());
diff --git a/src/renderer/painter_raster.cpp b/src/renderer/painter_raster.cpp
index 723d4b5e4d..b5f09a3e19 100644
--- a/src/renderer/painter_raster.cpp
+++ b/src/renderer/painter_raster.cpp
@@ -22,16 +22,8 @@ void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> lay
preparePrerender(bucket);
-// const RasterProperties modifiedProperties = [&]{
-// RasterProperties modifiedProperties = properties;
-// modifiedProperties.opacity = 1; // figure out why this was here
-// return modifiedProperties;
-// }();
-
const int buffer = bucket.properties.buffer * 4096.0f;
- const mat4 oldMatrix = vtxMatrix;
-
const mat4 preMatrix = [&]{
mat4 vtxMatrix;
matrix::ortho(vtxMatrix, -buffer, 4096 + buffer, -4096 - buffer, buffer, 0, 1);
@@ -39,20 +31,8 @@ void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> lay
return vtxMatrix;
}();
-// *id.matrix = vtxMatrix;
-
-
-
-
-// glUniformMatrix4fv(matrix, 1, GL_FALSE, preMatrix.data());
-
// call updateTiles to get parsed data for sublayers
map.updateTiles();
-
-// map.state.matrixFor(matrix, id);
-// matrix::ortho(matrix, -buffer, 4096 + buffer, -4096 - buffer, buffer, 0, 1);
-// matrix::translate(matrix, matrix, 0, -4096, 0);
-
int i = 0;
for (auto it = layer_desc->layers->layers.begin(), end = layer_desc->layers->layers.end(); it != end; ++it, --i) {
@@ -62,39 +42,37 @@ void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> lay
map.renderLayer(*it, Map::RenderPass::Translucent, &id, &preMatrix);
}
-// TODO make a separate renderLayer overload that takes a prerendered + tileID
-
if (bucket.properties.blur > 0) {
bucket.texture.blur(*this, bucket.properties.blur);
}
bucket.texture.unbindFramebuffer();
- finishPrerender(bucket);
-// Tile(id).matrix = oldMatrix;
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_STENCIL_TEST);
+
+ glViewport(0, 0, gl_viewport[0], gl_viewport[1]);
}
- renderPrerenderedTexture(bucket, matrix);
+ renderPrerenderedTexture(bucket, matrix, properties);
}
- depthMask(false);
+ // Only draw non-prerendered raster here
+ if (bucket.hasData()) {
+ depthMask(false);
- useProgram(rasterShader->program);
- rasterShader->setMatrix(matrix);
- rasterShader->setBuffer(0);
- rasterShader->setOpacity(1);
-// rasterShader->setOpacity(properties.opacity * tile_data->raster->opacity); // TODO fix
+ useProgram(rasterShader->program);
+ rasterShader->setMatrix(matrix);
+ rasterShader->setBuffer(0);
+ rasterShader->setOpacity(properties.opacity);
- glDepthRange(strata + strata_epsilon, 1.0f);
+ glDepthRange(strata + strata_epsilon, 1.0f);
- if (!bucket.hasData()) {
-// bucket.drawRaster(*rasterShader, tileStencilBuffer, coveringRasterArray, bucket.texture.getTexture());
- } else {
bucket.drawRaster(*rasterShader, tileStencilBuffer, coveringRasterArray);
- }
- depthMask(true);
+ depthMask(true);
+ }
}
diff --git a/src/style/property_fallback.cpp b/src/style/property_fallback.cpp
index 4401c8105a..4028980cbe 100644
--- a/src/style/property_fallback.cpp
+++ b/src/style/property_fallback.cpp
@@ -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 },
diff --git a/src/style/style_layer.cpp b/src/style/style_layer.cpp
index 8ec04d6695..520c183780 100644
--- a/src/style/style_layer.cpp
+++ b/src/style/style_layer.cpp
@@ -228,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);
diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp
index 17c8fdf25a..33a1573c0b 100644
--- a/src/style/style_parser.cpp
+++ b/src/style/style_parser.cpp
@@ -639,8 +639,8 @@ void StyleParser::parseStyle(JSVal value, ClassProperties &klass) {
// TODO edit these?:
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-hue-rotate", Key::RasterHueRotate, klass, value);
+ parseOptionalProperty<PropertyTransition>("transition-raster-hue-rotate", Key::RasterHueRotate, 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);