summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMolly Lloyd <molly@mapbox.com>2018-06-21 10:44:02 -0700
committerMolly Lloyd <molly@mapbox.com>2018-06-21 10:44:13 -0700
commit03f110a37cbdb4acebe319637c5dcf17631a366d (patch)
treedc7beb16f7d3f814071eca0752b0549d401f369e
parentd7d7b785b8ee8c979314f05eefbc68689e9242eb (diff)
downloadqtlocation-mapboxgl-upstream/raster-resampling.tar.gz
raster-resampling -> raster-resampling-mode for darwin language conventionsupstream/raster-resampling
-rw-r--r--platform/darwin/scripts/style-spec-cocoa-conventions-v8.json3
-rw-r--r--platform/darwin/src/MGLRasterStyleLayer.h28
-rw-r--r--platform/darwin/src/MGLRasterStyleLayer.mm33
-rw-r--r--platform/darwin/test/MGLRasterStyleLayerTests.mm36
-rw-r--r--platform/ios/docs/guides/For Style Authors.md1
-rw-r--r--platform/macos/docs/guides/For Style Authors.md1
6 files changed, 59 insertions, 43 deletions
diff --git a/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json b/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json
index 830b6d69f9..dfc7d76a3c 100644
--- a/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json
+++ b/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json
@@ -37,7 +37,8 @@
"paint_raster": {
"raster-brightness-min": "minimum-raster-brightness",
"raster-brightness-max": "maximum-raster-brightness",
- "raster-hue-rotate": "raster-hue-rotation"
+ "raster-hue-rotate": "raster-hue-rotation",
+ "raster-resampling": "raster-resampling-mode"
},
"paint_line": {
"line-dasharray": "line-dash-pattern",
diff --git a/platform/darwin/src/MGLRasterStyleLayer.h b/platform/darwin/src/MGLRasterStyleLayer.h
index e351295289..a74d4f7f26 100644
--- a/platform/darwin/src/MGLRasterStyleLayer.h
+++ b/platform/darwin/src/MGLRasterStyleLayer.h
@@ -10,21 +10,21 @@ NS_ASSUME_NONNULL_BEGIN
The resampling/interpolation method to use for overscaling, also known as
texture magnification filter
- Values of this type are used in the `MGLRasterStyleLayer.rasterResampling`
+ Values of this type are used in the `MGLRasterStyleLayer.rasterResamplingMode`
property.
*/
-typedef NS_ENUM(NSUInteger, MGLRasterResampling) {
+typedef NS_ENUM(NSUInteger, MGLRasterResamplingMode) {
/**
(Bi)linear filtering interpolates point values using the weighted average
of the four closest original source points creating a smooth but blurry
look when overscaled
*/
- MGLRasterResamplingLinear,
+ MGLRasterResamplingModeLinear,
/**
Nearest neighbor filtering interpolates point values using the nearest
original source point creating a sharp but pointated look when overscaled
*/
- MGLRasterResamplingNearest,
+ MGLRasterResamplingModeNearest,
};
/**
@@ -260,9 +260,13 @@ MGL_EXPORT
The default value of this property is an expression that evaluates to `linear`.
Set this property to `nil` to reset it to the default value.
+ This attribute corresponds to the <a
+ href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-raster-resampling"><code>raster-resampling</code></a>
+ layout property in the Mapbox Style Specification.
+
You can set this property to an expression containing any of the following:
- * Constant `MGLRasterResampling` values
+ * Constant `MGLRasterResamplingMode` values
* Any of the following constant string values:
* `linear`: (Bi)linear filtering interpolates pixel values using the weighted
average of the four closest original source pixels creating a smooth but blurry
@@ -279,7 +283,9 @@ MGL_EXPORT
`$zoomLevel` variable or applying interpolation or step functions to feature
attributes.
*/
-@property (nonatomic, null_resettable) NSExpression *rasterResampling;
+@property (nonatomic, null_resettable) NSExpression *rasterResamplingMode;
+
+@property (nonatomic, null_resettable) NSExpression *rasterResampling __attribute__((unavailable("Use rasterResamplingMode instead.")));
/**
Increase or reduce the saturation of the image.
@@ -318,17 +324,17 @@ MGL_EXPORT
#pragma mark Working with Raster Style Layer Attribute Values
/**
- Creates a new value object containing the given `MGLRasterResampling` enumeration.
+ Creates a new value object containing the given `MGLRasterResamplingMode` enumeration.
- @param rasterResampling The value for the new object.
+ @param rasterResamplingMode The value for the new object.
@return A new value object that contains the enumeration value.
*/
-+ (instancetype)valueWithMGLRasterResampling:(MGLRasterResampling)rasterResampling;
++ (instancetype)valueWithMGLRasterResamplingMode:(MGLRasterResamplingMode)rasterResamplingMode;
/**
- The `MGLRasterResampling` enumeration representation of the value.
+ The `MGLRasterResamplingMode` enumeration representation of the value.
*/
-@property (readonly) MGLRasterResampling MGLRasterResamplingValue;
+@property (readonly) MGLRasterResamplingMode MGLRasterResamplingModeValue;
@end
diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm
index e150e24863..96ed5ab513 100644
--- a/platform/darwin/src/MGLRasterStyleLayer.mm
+++ b/platform/darwin/src/MGLRasterStyleLayer.mm
@@ -13,9 +13,9 @@
namespace mbgl {
- MBGL_DEFINE_ENUM(MGLRasterResampling, {
- { MGLRasterResamplingLinear, "linear" },
- { MGLRasterResamplingNearest, "nearest" },
+ MBGL_DEFINE_ENUM(MGLRasterResamplingMode, {
+ { MGLRasterResamplingModeLinear, "linear" },
+ { MGLRasterResamplingModeNearest, "nearest" },
});
}
@@ -261,21 +261,28 @@ namespace mbgl {
return transition;
}
-- (void)setRasterResampling:(NSExpression *)rasterResampling {
+- (void)setRasterResamplingMode:(NSExpression *)rasterResamplingMode {
MGLAssertStyleLayerIsValid();
- auto mbglValue = MGLStyleValueTransformer<mbgl::style::RasterResamplingType, NSValue *, mbgl::style::RasterResamplingType, MGLRasterResampling>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::RasterResamplingType>>(rasterResampling);
+ auto mbglValue = MGLStyleValueTransformer<mbgl::style::RasterResamplingType, NSValue *, mbgl::style::RasterResamplingType, MGLRasterResamplingMode>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::RasterResamplingType>>(rasterResamplingMode);
self.rawLayer->setRasterResampling(mbglValue);
}
-- (NSExpression *)rasterResampling {
+- (NSExpression *)rasterResamplingMode {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getRasterResampling();
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefaultRasterResampling();
}
- return MGLStyleValueTransformer<mbgl::style::RasterResamplingType, NSValue *, mbgl::style::RasterResamplingType, MGLRasterResampling>().toExpression(propertyValue);
+ return MGLStyleValueTransformer<mbgl::style::RasterResamplingType, NSValue *, mbgl::style::RasterResamplingType, MGLRasterResamplingMode>().toExpression(propertyValue);
+}
+
+- (void)setRasterResampling:(NSExpression *)rasterResampling {
+}
+
+- (NSExpression *)rasterResampling {
+ return self.rasterResamplingMode;
}
- (void)setRasterSaturation:(NSExpression *)rasterSaturation {
@@ -317,14 +324,14 @@ namespace mbgl {
@implementation NSValue (MGLRasterStyleLayerAdditions)
-+ (NSValue *)valueWithMGLRasterResampling:(MGLRasterResampling)rasterResampling {
- return [NSValue value:&rasterResampling withObjCType:@encode(MGLRasterResampling)];
++ (NSValue *)valueWithMGLRasterResamplingMode:(MGLRasterResamplingMode)rasterResamplingMode {
+ return [NSValue value:&rasterResamplingMode withObjCType:@encode(MGLRasterResamplingMode)];
}
-- (MGLRasterResampling)MGLRasterResamplingValue {
- MGLRasterResampling rasterResampling;
- [self getValue:&rasterResampling];
- return rasterResampling;
+- (MGLRasterResamplingMode)MGLRasterResamplingModeValue {
+ MGLRasterResamplingMode rasterResamplingMode;
+ [self getValue:&rasterResamplingMode];
+ return rasterResamplingMode;
}
@end
diff --git a/platform/darwin/test/MGLRasterStyleLayerTests.mm b/platform/darwin/test/MGLRasterStyleLayerTests.mm
index f71cc24d07..cc5c1b6984 100644
--- a/platform/darwin/test/MGLRasterStyleLayerTests.mm
+++ b/platform/darwin/test/MGLRasterStyleLayerTests.mm
@@ -310,19 +310,19 @@
{
XCTAssertTrue(rawLayer->getRasterResampling().isUndefined(),
@"raster-resampling should be unset initially.");
- NSExpression *defaultExpression = layer.rasterResampling;
+ NSExpression *defaultExpression = layer.rasterResamplingMode;
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'nearest'"];
- layer.rasterResampling = constantExpression;
+ layer.rasterResamplingMode = constantExpression;
mbgl::style::PropertyValue<mbgl::style::RasterResamplingType> propertyValue = { mbgl::style::RasterResamplingType::Nearest };
XCTAssertEqual(rawLayer->getRasterResampling(), propertyValue,
- @"Setting rasterResampling to a constant value expression should update raster-resampling.");
- XCTAssertEqualObjects(layer.rasterResampling, constantExpression,
- @"rasterResampling should round-trip constant value expressions.");
+ @"Setting rasterResamplingMode to a constant value expression should update raster-resampling.");
+ XCTAssertEqualObjects(layer.rasterResamplingMode, constantExpression,
+ @"rasterResamplingMode should round-trip constant value expressions.");
constantExpression = [NSExpression expressionWithFormat:@"'nearest'"];
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.rasterResampling = functionExpression;
+ layer.rasterResamplingMode = functionExpression;
mbgl::style::IntervalStops<mbgl::style::RasterResamplingType> intervalStops = {{
{ -INFINITY, mbgl::style::RasterResamplingType::Nearest },
@@ -331,22 +331,22 @@
propertyValue = mbgl::style::CameraFunction<mbgl::style::RasterResamplingType> { intervalStops };
XCTAssertEqual(rawLayer->getRasterResampling(), propertyValue,
- @"Setting rasterResampling to a camera expression should update raster-resampling.");
- XCTAssertEqualObjects(layer.rasterResampling, functionExpression,
- @"rasterResampling should round-trip camera expressions.");
+ @"Setting rasterResamplingMode to a camera expression should update raster-resampling.");
+ XCTAssertEqualObjects(layer.rasterResamplingMode, functionExpression,
+ @"rasterResamplingMode should round-trip camera expressions.");
- layer.rasterResampling = nil;
+ layer.rasterResamplingMode = nil;
XCTAssertTrue(rawLayer->getRasterResampling().isUndefined(),
- @"Unsetting rasterResampling should return raster-resampling to the default value.");
- XCTAssertEqualObjects(layer.rasterResampling, defaultExpression,
- @"rasterResampling should return the default value after being unset.");
+ @"Unsetting rasterResamplingMode should return raster-resampling to the default value.");
+ XCTAssertEqualObjects(layer.rasterResamplingMode, defaultExpression,
+ @"rasterResamplingMode should return the default value after being unset.");
functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.rasterResampling = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
+ XCTAssertThrowsSpecificNamed(layer.rasterResamplingMode = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.rasterResampling = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
+ XCTAssertThrowsSpecificNamed(layer.rasterResamplingMode = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
}
// raster-saturation
@@ -409,13 +409,13 @@
[self testPropertyName:@"raster-fade-duration" isBoolean:NO];
[self testPropertyName:@"raster-hue-rotation" isBoolean:NO];
[self testPropertyName:@"raster-opacity" isBoolean:NO];
- [self testPropertyName:@"raster-resampling" isBoolean:NO];
+ [self testPropertyName:@"raster-resampling-mode" isBoolean:NO];
[self testPropertyName:@"raster-saturation" isBoolean:NO];
}
- (void)testValueAdditions {
- XCTAssertEqual([NSValue valueWithMGLRasterResampling:MGLRasterResamplingLinear].MGLRasterResamplingValue, MGLRasterResamplingLinear);
- XCTAssertEqual([NSValue valueWithMGLRasterResampling:MGLRasterResamplingNearest].MGLRasterResamplingValue, MGLRasterResamplingNearest);
+ XCTAssertEqual([NSValue valueWithMGLRasterResamplingMode:MGLRasterResamplingModeLinear].MGLRasterResamplingModeValue, MGLRasterResamplingModeLinear);
+ XCTAssertEqual([NSValue valueWithMGLRasterResamplingMode:MGLRasterResamplingModeNearest].MGLRasterResamplingModeValue, MGLRasterResamplingModeNearest);
}
@end
diff --git a/platform/ios/docs/guides/For Style Authors.md b/platform/ios/docs/guides/For Style Authors.md
index d4fb17eb6a..e3e2eca603 100644
--- a/platform/ios/docs/guides/For Style Authors.md
+++ b/platform/ios/docs/guides/For Style Authors.md
@@ -243,6 +243,7 @@ In style JSON | In Objective-C | In Swift
`raster-brightness-max` | `MGLRasterStyleLayer.maximumRasterBrightness` | `MGLRasterStyleLayer.maximumRasterBrightness`
`raster-brightness-min` | `MGLRasterStyleLayer.minimumRasterBrightness` | `MGLRasterStyleLayer.minimumRasterBrightness`
`raster-hue-rotate` | `MGLRasterStyleLayer.rasterHueRotation` | `MGLRasterStyleLayer.rasterHueRotation`
+`raster-resampling` | `MGLRasterStyleLayer.rasterResamplingMode` | `MGLRasterStyleLayer.rasterResamplingMode`
### Symbol style layers
diff --git a/platform/macos/docs/guides/For Style Authors.md b/platform/macos/docs/guides/For Style Authors.md
index 08385a66d9..e2d63a6506 100644
--- a/platform/macos/docs/guides/For Style Authors.md
+++ b/platform/macos/docs/guides/For Style Authors.md
@@ -230,6 +230,7 @@ In style JSON | In Objective-C | In Swift
`raster-brightness-max` | `MGLRasterStyleLayer.maximumRasterBrightness` | `MGLRasterStyleLayer.maximumRasterBrightness`
`raster-brightness-min` | `MGLRasterStyleLayer.minimumRasterBrightness` | `MGLRasterStyleLayer.minimumRasterBrightness`
`raster-hue-rotate` | `MGLRasterStyleLayer.rasterHueRotation` | `MGLRasterStyleLayer.rasterHueRotation`
+`raster-resampling` | `MGLRasterStyleLayer.rasterResamplingMode` | `MGLRasterStyleLayer.rasterResamplingMode`
### Symbol style layers