[core] add raster-resampling property (#12176)
* update style-code for raster-resampling * implement user-defined raster-resampling * invert filter condition * raster-resampling -> raster-resampling-mode for darwin language conventions
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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>;
|
||||
|
||||
|
||||
@@ -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&);
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
@@ -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
|
||||
> {};
|
||||
|
||||
|
||||
@@ -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" },
|
||||
|
||||
Reference in New Issue
Block a user