diff options
author | Molly Lloyd <mollymerp@users.noreply.github.com> | 2018-06-21 14:37:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-21 14:37:17 -0700 |
commit | e1af62e87dfd77d1c38802f082c4981dab1beeab (patch) | |
tree | 8371dccdcf8545fd50b2edddbdd3a622bb00b27a /src | |
parent | eb70b8984901d8113f3a29d26cc355d5b3ed46fd (diff) | |
download | qtlocation-mapboxgl-e1af62e87dfd77d1c38802f082c4981dab1beeab.tar.gz |
[core] add raster-resampling property (#12176)upstream/rclee
* update style-code for raster-resampling
* implement user-defined raster-resampling
* invert filter condition
* raster-resampling -> raster-resampling-mode for darwin language conventions
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/renderer/layers/render_raster_layer.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/style/conversion/make_property_setters.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/expression/value.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/layers/raster_layer.cpp | 27 | ||||
-rw-r--r-- | src/mbgl/style/layers/raster_layer_properties.hpp | 5 | ||||
-rw-r--r-- | src/mbgl/style/types.cpp | 5 |
6 files changed, 49 insertions, 4 deletions
diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp index f202ed4ebb..f31f53481f 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.cpp +++ b/src/mbgl/renderer/layers/render_raster_layer.cpp @@ -123,13 +123,15 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source ); }; + const gl::TextureFilter filter = evaluated.get<RasterResampling>() == RasterResamplingType::Nearest ? gl::TextureFilter::Nearest : gl::TextureFilter::Linear; + if (RenderImageSource* imageSource = source->as<RenderImageSource>()) { if (imageSource->isEnabled() && imageSource->isLoaded() && !imageSource->bucket->needsUpload()) { RasterBucket& bucket = *imageSource->bucket; assert(bucket.texture); - parameters.context.bindTexture(*bucket.texture, 0, gl::TextureFilter::Linear); - parameters.context.bindTexture(*bucket.texture, 1, gl::TextureFilter::Linear); + parameters.context.bindTexture(*bucket.texture, 0, filter); + parameters.context.bindTexture(*bucket.texture, 1, filter); for (auto matrix_ : imageSource->matrices) { draw(matrix_, @@ -147,8 +149,8 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source continue; assert(bucket.texture); - parameters.context.bindTexture(*bucket.texture, 0, gl::TextureFilter::Linear); - parameters.context.bindTexture(*bucket.texture, 1, gl::TextureFilter::Linear); + parameters.context.bindTexture(*bucket.texture, 0, filter); + parameters.context.bindTexture(*bucket.texture, 1, filter); if (bucket.vertexBuffer && bucket.indexBuffer && !bucket.segments.empty()) { // Draw only the parts of the tile that aren't drawn by another tile in the layer. diff --git a/src/mbgl/style/conversion/make_property_setters.hpp b/src/mbgl/style/conversion/make_property_setters.hpp index 25c8fdb1ca..40461fc1e7 100644 --- a/src/mbgl/style/conversion/make_property_setters.hpp +++ b/src/mbgl/style/conversion/make_property_setters.hpp @@ -206,6 +206,8 @@ inline auto makePaintPropertySetters() { result["raster-saturation-transition"] = &setTransition<RasterLayer, &RasterLayer::setRasterSaturationTransition>; result["raster-contrast"] = &setProperty<RasterLayer, PropertyValue<float>, &RasterLayer::setRasterContrast>; result["raster-contrast-transition"] = &setTransition<RasterLayer, &RasterLayer::setRasterContrastTransition>; + result["raster-resampling"] = &setProperty<RasterLayer, PropertyValue<RasterResamplingType>, &RasterLayer::setRasterResampling>; + result["raster-resampling-transition"] = &setTransition<RasterLayer, &RasterLayer::setRasterResamplingTransition>; result["raster-fade-duration"] = &setProperty<RasterLayer, PropertyValue<float>, &RasterLayer::setRasterFadeDuration>; result["raster-fade-duration-transition"] = &setTransition<RasterLayer, &RasterLayer::setRasterFadeDurationTransition>; diff --git a/src/mbgl/style/expression/value.cpp b/src/mbgl/style/expression/value.cpp index 1b3257c755..7c329e8f1f 100644 --- a/src/mbgl/style/expression/value.cpp +++ b/src/mbgl/style/expression/value.cpp @@ -337,6 +337,10 @@ template type::Type valueTypeToExpressionType<TranslateAnchorType>(); template optional<TranslateAnchorType> fromExpressionValue<TranslateAnchorType>(const Value&); template Value toExpressionValue(const TranslateAnchorType&); +template type::Type valueTypeToExpressionType<RasterResamplingType>(); +template optional<RasterResamplingType> fromExpressionValue<RasterResamplingType>(const Value&); +template Value toExpressionValue(const RasterResamplingType&); + template type::Type valueTypeToExpressionType<HillshadeIlluminationAnchorType>(); template optional<HillshadeIlluminationAnchorType> fromExpressionValue<HillshadeIlluminationAnchorType>(const Value&); template Value toExpressionValue(const HillshadeIlluminationAnchorType&); diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp index 36b2e3e027..e5b03df0f6 100644 --- a/src/mbgl/style/layers/raster_layer.cpp +++ b/src/mbgl/style/layers/raster_layer.cpp @@ -236,6 +236,33 @@ TransitionOptions RasterLayer::getRasterContrastTransition() const { return impl().paint.template get<RasterContrast>().options; } +PropertyValue<RasterResamplingType> RasterLayer::getDefaultRasterResampling() { + return { RasterResamplingType::Linear }; +} + +PropertyValue<RasterResamplingType> RasterLayer::getRasterResampling() const { + return impl().paint.template get<RasterResampling>().value; +} + +void RasterLayer::setRasterResampling(PropertyValue<RasterResamplingType> value) { + if (value == getRasterResampling()) + return; + auto impl_ = mutableImpl(); + impl_->paint.template get<RasterResampling>().value = value; + baseImpl = std::move(impl_); + observer->onLayerChanged(*this); +} + +void RasterLayer::setRasterResamplingTransition(const TransitionOptions& options) { + auto impl_ = mutableImpl(); + impl_->paint.template get<RasterResampling>().options = options; + baseImpl = std::move(impl_); +} + +TransitionOptions RasterLayer::getRasterResamplingTransition() const { + return impl().paint.template get<RasterResampling>().options; +} + PropertyValue<float> RasterLayer::getDefaultRasterFadeDuration() { return { 300 }; } diff --git a/src/mbgl/style/layers/raster_layer_properties.hpp b/src/mbgl/style/layers/raster_layer_properties.hpp index 12df09f32c..08818c9fb3 100644 --- a/src/mbgl/style/layers/raster_layer_properties.hpp +++ b/src/mbgl/style/layers/raster_layer_properties.hpp @@ -36,6 +36,10 @@ struct RasterContrast : PaintProperty<float> { static float defaultValue() { return 0; } }; +struct RasterResampling : PaintProperty<RasterResamplingType> { + static RasterResamplingType defaultValue() { return RasterResamplingType::Linear; } +}; + struct RasterFadeDuration : PaintProperty<float> { static float defaultValue() { return 300; } }; @@ -47,6 +51,7 @@ class RasterPaintProperties : public Properties< RasterBrightnessMax, RasterSaturation, RasterContrast, + RasterResampling, RasterFadeDuration > {}; diff --git a/src/mbgl/style/types.cpp b/src/mbgl/style/types.cpp index bdfa20a047..bcaa9e87c7 100644 --- a/src/mbgl/style/types.cpp +++ b/src/mbgl/style/types.cpp @@ -25,6 +25,11 @@ MBGL_DEFINE_ENUM(TranslateAnchorType, { { TranslateAnchorType::Viewport, "viewport" }, }); +MBGL_DEFINE_ENUM(RasterResamplingType, { + { RasterResamplingType::Linear, "linear" }, + { RasterResamplingType::Nearest, "nearest" }, +}); + MBGL_DEFINE_ENUM(HillshadeIlluminationAnchorType, { { HillshadeIlluminationAnchorType::Map, "map" }, { HillshadeIlluminationAnchorType::Viewport, "viewport" }, |