From 28d2921c14ea5e4ea5a62ce30451948b01116955 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Fri, 6 Oct 2017 17:30:41 +0200 Subject: [PATCH 01/26] Added properties ImageryLayer.minificationFilter and .magnificationFilter --- CHANGES.md | 9 +++++ Source/Scene/ImageryLayer.js | 67 +++++++++++++++++++++++++++++---- Specs/Scene/ImageryLayerSpec.js | 23 +++++++++++ 3 files changed, 92 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 432dff7bc1a0..a064ecbeb424 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,14 @@ Change Log ========== + +### 1.39 - 2017-11-?? + +* Added two new properties to `ImageryLayer` that allow for adjusting the texture sampler used for up- and down-sampling + of image tiles, namely `minificationFilter` and `magnificationFilter` with possible values `LINEAR` + (the default) and `NEAREST` defined in `TextureMinificationFilter` and `TextureMagnificationFilter`. + [#5846](https://github.com/AnalyticalGraphicsInc/cesium/issues/5846) + + ### 1.38 - 2017-10-02 * Breaking changes diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index c03383ec04c1..1834642aeea2 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -136,6 +136,14 @@ define([ * the gamma value to use for the tile. The function is executed for every * frame and for every tile, so it must be fast. * @param {ImagerySplitDirection|Function} [options.splitDirection=ImagerySplitDirection.NONE] The {@link ImagerySplitDirection} split to apply to this layer. + * @param {TextureMinificationFilter} [options.minificationFilter=TextureMinificationFilter.LINEAR] The + * texture minification filter to apply to this layer. Possible values + * are TextureMinificationFilter.LINEAR and + * TextureMinificationFilter.NEAREST. + * @param {TextureMagnificationFilter} [options.magnificationFilter=TextureMagnificationFilter.LINEAR] The + * texture minification filter to apply to this layer. Possible values + * are TextureMagnificationFilter.LINEAR and + * TextureMagnificationFilter.NEAREST. * @param {Boolean} [options.show=true] True if the layer is shown; otherwise, false. * @param {Number} [options.maximumAnisotropy=maximum supported] The maximum anisotropy level to use * for texture filtering. If this parameter is not specified, the maximum anisotropy supported @@ -211,6 +219,22 @@ define([ */ this.splitDirection = defaultValue(options.splitDirection, defaultValue(imageryProvider.defaultSplit, ImageryLayer.DEFAULT_SPLIT)); + /** + * The {@link TextureMinificationFilter} to apply to this layer. + * + * @type {TextureMinificationFilter} + * @default {@link ImageryLayer.DEFAULT_MINIFICATION_FILTER} + */ + this.minificationFilter = defaultValue(options.minificationFilter, defaultValue(imageryProvider.defaultMinificationFilter, ImageryLayer.DEFAULT_MINIFICATION_FILTER)); + + /** + * The {@link TextureMagnificationFilter} to apply to this layer. + * + * @type {TextureMagnificationFilter} + * @default {@link ImageryLayer.DEFAULT_MAGNIFICATION_FILTER} + */ + this.magnificationFilter = defaultValue(options.magnificationFilter, defaultValue(imageryProvider.defaultMagnificationFilter, ImageryLayer.DEFAULT_MAGNIFICATION_FILTER)); + /** * Determines if this layer is shown. * @@ -309,13 +333,29 @@ define([ ImageryLayer.DEFAULT_GAMMA = 1.0; /** - * This value is used as the default spliat for the imagery layer if one is not provided during construction + * This value is used as the default split for the imagery layer if one is not provided during construction * or by the imagery provider. * @type {ImagerySplitDirection} * @default ImagerySplitDirection.NONE */ ImageryLayer.DEFAULT_SPLIT = ImagerySplitDirection.NONE; + /** + * This value is used as the default texture magnification filter for the imagery layer if one is not provided + * during construction or by the imagery provider. + * @type {TextureMagnificationFilter} + * @default TextureMagnificationFilter.LINEAR + */ + ImageryLayer.DEFAULT_MAGNIFICATION_FILTER = TextureMagnificationFilter.LINEAR; + + /** + * This value is used as the default texture minification filter for the imagery layer if one is not provided + * during construction or by the imagery provider. + * @type {TextureMinificationFilter} + * @default TextureMinificationFilter.LINEAR + */ + ImageryLayer.DEFAULT_MINIFICATION_FILTER = TextureMinificationFilter.LINEAR; + /** * Gets a value indicating whether this layer is the base layer in the * {@link ImageryLayerCollection}. The base layer is the one that underlies all @@ -764,6 +804,11 @@ define([ } } + var sampler = new Sampler({ + minificationFilter : this.minificationFilter, + magnificationFilter : this.magnificationFilter + }); + // Imagery does not need to be discarded, so upload it to WebGL. var texture; if (defined(image.internalFormat)) { @@ -774,13 +819,15 @@ define([ height : image.height, source : { arrayBufferView : image.bufferView - } + }, + sampler: sampler }); } else { texture = new Texture({ context : context, source : image, - pixelFormat : imageryProvider.hasAlphaChannel ? PixelFormat.RGBA : PixelFormat.RGB + pixelFormat : imageryProvider.hasAlphaChannel ? PixelFormat.RGBA : PixelFormat.RGB, + sampler: sampler }); } @@ -799,11 +846,17 @@ define([ var mipmapSampler = context.cache.imageryLayer_mipmapSampler; if (!defined(mipmapSampler)) { var maximumSupportedAnisotropy = ContextLimits.maximumTextureFilterAnisotropy; + var minificationFilter = imageryLayer.minificationFilter; + if (imageryLayer.minificationFilter === TextureMinificationFilter.NEAREST) { + minificationFilter = TextureMinificationFilter.NEAREST_MIPMAP_NEAREST; + } else if (imageryLayer.minificationFilter === TextureMinificationFilter.LINEAR) { + minificationFilter = TextureMinificationFilter.LINEAR_MIPMAP_LINEAR; + } mipmapSampler = context.cache.imageryLayer_mipmapSampler = new Sampler({ wrapS : TextureWrap.CLAMP_TO_EDGE, wrapT : TextureWrap.CLAMP_TO_EDGE, - minificationFilter : TextureMinificationFilter.LINEAR_MIPMAP_LINEAR, - magnificationFilter : TextureMagnificationFilter.LINEAR, + minificationFilter : minificationFilter, + magnificationFilter : imageryLayer.magnificationFilter, maximumAnisotropy : Math.min(maximumSupportedAnisotropy, defaultValue(imageryLayer._maximumAnisotropy, maximumSupportedAnisotropy)) }); } @@ -815,8 +868,8 @@ define([ nonMipmapSampler = context.cache.imageryLayer_nonMipmapSampler = new Sampler({ wrapS : TextureWrap.CLAMP_TO_EDGE, wrapT : TextureWrap.CLAMP_TO_EDGE, - minificationFilter : TextureMinificationFilter.LINEAR, - magnificationFilter : TextureMagnificationFilter.LINEAR + minificationFilter : imageryLayer.minificationFilter, + magnificationFilter : imageryLayer.magnificationFilter }); } texture.sampler = nonMipmapSampler; diff --git a/Specs/Scene/ImageryLayerSpec.js b/Specs/Scene/ImageryLayerSpec.js index fbb3211d453e..fbcc38c51af9 100644 --- a/Specs/Scene/ImageryLayerSpec.js +++ b/Specs/Scene/ImageryLayerSpec.js @@ -7,6 +7,8 @@ defineSuite([ 'Core/Rectangle', 'Core/RequestScheduler', 'Renderer/ComputeEngine', + 'Renderer/TextureMagnificationFilter', + 'Renderer/TextureMinificationFilter', 'Scene/ArcGisMapServerImageryProvider', 'Scene/BingMapsImageryProvider', 'Scene/createTileMapServiceImageryProvider', @@ -30,6 +32,8 @@ defineSuite([ Rectangle, RequestScheduler, ComputeEngine, + TextureMagnificationFilter, + TextureMinificationFilter, ArcGisMapServerImageryProvider, BingMapsImageryProvider, createTileMapServiceImageryProvider, @@ -367,6 +371,25 @@ defineSuite([ expect(layer.isDestroyed()).toEqual(true); }); + it('texture filter properties work as expected', function() { + var provider = new SingleTileImageryProvider({ + url : 'Data/Images/Red16x16.png' + }); + + var layer = new ImageryLayer(provider, {}); + expect(layer.magnificationFilter).toEqual(TextureMagnificationFilter.LINEAR); + expect(layer.minificationFilter).toEqual(TextureMinificationFilter.LINEAR); + layer.destroy(); + + layer = new ImageryLayer(provider, { + magnificationFilter: TextureMagnificationFilter.NEAREST, + minificationFilter: TextureMinificationFilter.NEAREST + }); + expect(layer.magnificationFilter).toEqual(TextureMagnificationFilter.NEAREST); + expect(layer.minificationFilter).toEqual(TextureMinificationFilter.NEAREST); + layer.destroy(); + }); + it('returns HTTP status code information in TileProviderError', function() { // Web browsers unfortunately provide very little information about what went wrong when an Image fails // to load. But when an imagery provider is configured to use a TileDiscardPolicy, Cesium downloads the image From 4aff9c229892e875737b292c552c3748a50c29ca Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Mon, 9 Oct 2017 16:44:41 +0200 Subject: [PATCH 02/26] Renamed local var as mipmapMinificationFilter --- Source/Scene/ImageryLayer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index 1834642aeea2..73838deff408 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -846,16 +846,16 @@ define([ var mipmapSampler = context.cache.imageryLayer_mipmapSampler; if (!defined(mipmapSampler)) { var maximumSupportedAnisotropy = ContextLimits.maximumTextureFilterAnisotropy; - var minificationFilter = imageryLayer.minificationFilter; + var mipmapMinificationFilter = imageryLayer.minificationFilter; if (imageryLayer.minificationFilter === TextureMinificationFilter.NEAREST) { - minificationFilter = TextureMinificationFilter.NEAREST_MIPMAP_NEAREST; + mipmapMinificationFilter = TextureMinificationFilter.NEAREST_MIPMAP_NEAREST; } else if (imageryLayer.minificationFilter === TextureMinificationFilter.LINEAR) { - minificationFilter = TextureMinificationFilter.LINEAR_MIPMAP_LINEAR; + mipmapMinificationFilter = TextureMinificationFilter.LINEAR_MIPMAP_LINEAR; } mipmapSampler = context.cache.imageryLayer_mipmapSampler = new Sampler({ wrapS : TextureWrap.CLAMP_TO_EDGE, wrapT : TextureWrap.CLAMP_TO_EDGE, - minificationFilter : minificationFilter, + minificationFilter : mipmapMinificationFilter, magnificationFilter : imageryLayer.magnificationFilter, maximumAnisotropy : Math.min(maximumSupportedAnisotropy, defaultValue(imageryLayer._maximumAnisotropy, maximumSupportedAnisotropy)) }); From c1e0e5451a1c30a03ef7ee3b8b86bf52bb4beec8 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Mon, 9 Oct 2017 17:18:29 +0200 Subject: [PATCH 03/26] Added some more API doc --- Source/Scene/ImageryLayer.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index 73838deff408..70f5861b6b27 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -221,6 +221,8 @@ define([ /** * The {@link TextureMinificationFilter} to apply to this layer. + * Possible values are {@link TextureMinificationFilter.LINEAR} (the default) + * and {@link TextureMinificationFilter.NEAREST}. * * @type {TextureMinificationFilter} * @default {@link ImageryLayer.DEFAULT_MINIFICATION_FILTER} @@ -229,6 +231,8 @@ define([ /** * The {@link TextureMagnificationFilter} to apply to this layer. + * Possible values are {@link TextureMagnificationFilter.LINEAR} (the default) + * and {@link TextureMagnificationFilter.NEAREST}. * * @type {TextureMagnificationFilter} * @default {@link ImageryLayer.DEFAULT_MAGNIFICATION_FILTER} From daa095f229e7304a4d1a1fd534c206ffbad9f28c Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Tue, 10 Oct 2017 10:52:56 +0200 Subject: [PATCH 04/26] Made TextureMagnification/MinificationFilter public and added API-docs. --- Source/Renderer/TextureMagnificationFilter.js | 20 +++++++++++- Source/Renderer/TextureMinificationFilter.js | 32 ++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/Source/Renderer/TextureMagnificationFilter.js b/Source/Renderer/TextureMagnificationFilter.js index ba87c508d991..5911e0ce82f6 100644 --- a/Source/Renderer/TextureMagnificationFilter.js +++ b/Source/Renderer/TextureMagnificationFilter.js @@ -7,12 +7,30 @@ define([ 'use strict'; /** - * @private + * Enumerates all possible filters used when magnifying WebGL textures, which takes places when zooming + * into imagery. Provides the possible values for the {@link ImageryLayer#magnificationFilter} property. + * + * @alias TextureMagnificationFilter + * + * @see TextureMinificationFilter + * @see ImageryLayer#magnificationFilter */ var TextureMagnificationFilter = { + /** + * Nearest neighbor sampling of image pixels to texture. + */ NEAREST : WebGLConstants.NEAREST, + /** + * Bi-linear interpolation of image pixels to texture. + */ LINEAR : WebGLConstants.LINEAR, + /** + * Validates the given textureMinificationFilter with respect to the possible enum values. + * + * @param textureMagnificationFilter + * @returns {boolean} true if textureMagnificationFilter is valid. + */ validate : function(textureMagnificationFilter) { return ((textureMagnificationFilter === TextureMagnificationFilter.NEAREST) || (textureMagnificationFilter === TextureMagnificationFilter.LINEAR)); diff --git a/Source/Renderer/TextureMinificationFilter.js b/Source/Renderer/TextureMinificationFilter.js index 270d5d9ecc39..56888e0d0c68 100644 --- a/Source/Renderer/TextureMinificationFilter.js +++ b/Source/Renderer/TextureMinificationFilter.js @@ -7,16 +7,46 @@ define([ 'use strict'; /** - * @private + * Enumerates all possible filters used when minifying WebGL textures, which takes places when zooming + * out of imagery. Provides the possible values for the {@link ImageryLayer#minificationFilter} property. + * + * @alias TextureMinificationFilter + * + * @see TextureMagnificationFilter + * @see ImageryLayer#minificationFilter */ var TextureMinificationFilter = { + /** + * Nearest neighbor sampling of image pixels to texture. + */ NEAREST : WebGLConstants.NEAREST, + /** + * Bi-linear interpolation of image pixels to texture. + */ LINEAR : WebGLConstants.LINEAR, + /** + * WebGL NEAREST_MIPMAP_NEAREST interpolation of image pixels to texture. + */ NEAREST_MIPMAP_NEAREST : WebGLConstants.NEAREST_MIPMAP_NEAREST, + /** + * WebGL LINEAR_MIPMAP_NEAREST interpolation of image pixels to texture. + */ LINEAR_MIPMAP_NEAREST : WebGLConstants.LINEAR_MIPMAP_NEAREST, + /** + * WebGL NEAREST_MIPMAP_LINEAR interpolation of image pixels to texture. + */ NEAREST_MIPMAP_LINEAR : WebGLConstants.NEAREST_MIPMAP_LINEAR, + /** + * WebGL LINEAR_MIPMAP_LINEAR interpolation of image pixels to texture. + */ LINEAR_MIPMAP_LINEAR : WebGLConstants.LINEAR_MIPMAP_LINEAR, + /** + * Validates the given textureMinificationFilter with respect to the possible enum values. + * + * @param textureMinificationFilter + * @returns {boolean} true if textureMinificationFilter is valid. + */ validate : function(textureMinificationFilter) { return ((textureMinificationFilter === TextureMinificationFilter.NEAREST) || (textureMinificationFilter === TextureMinificationFilter.LINEAR) || From cb90b622baeefd698d49c0a01f95f6da2de085ed Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Tue, 10 Oct 2017 11:12:12 +0200 Subject: [PATCH 05/26] Update wrt public TextureMagnification/MinificationFilter enums --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index a064ecbeb424..f955ba6f31d8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Change Log of image tiles, namely `minificationFilter` and `magnificationFilter` with possible values `LINEAR` (the default) and `NEAREST` defined in `TextureMinificationFilter` and `TextureMagnificationFilter`. [#5846](https://github.com/AnalyticalGraphicsInc/cesium/issues/5846) + Hence, the enums `TextureMagnificationFilter` and `TextureMinificationFilter` have been made public. ### 1.38 - 2017-10-02 From b5fe6092294b2c36e7a7bb206ae2bb137184cee8 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Wed, 11 Oct 2017 17:58:04 -0700 Subject: [PATCH 06/26] avoid line breaks --- CHANGES.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f955ba6f31d8..0a1134bb0a9a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,11 +3,8 @@ Change Log ### 1.39 - 2017-11-?? -* Added two new properties to `ImageryLayer` that allow for adjusting the texture sampler used for up- and down-sampling - of image tiles, namely `minificationFilter` and `magnificationFilter` with possible values `LINEAR` - (the default) and `NEAREST` defined in `TextureMinificationFilter` and `TextureMagnificationFilter`. - [#5846](https://github.com/AnalyticalGraphicsInc/cesium/issues/5846) - Hence, the enums `TextureMagnificationFilter` and `TextureMinificationFilter` have been made public. +* Added two new properties to `ImageryLayer` that allow for adjusting the texture sampler used for up- and down-sampling of image tiles, namely `minificationFilter` and `magnificationFilter` with possible values `LINEAR` (the default) and `NEAREST` defined in `TextureMinificationFilter` and `TextureMagnificationFilter`. [#5846](https://github.com/AnalyticalGraphicsInc/cesium/issues/5846) +* The enums `TextureMinificationFilter` and `TextureMagnificationFilter` have been made public to support the new texture filter properties mentioned above. ### 1.38 - 2017-10-02 From 2dd4fd3c425c4bb064940f8a1330c68cf6be8070 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Wed, 11 Oct 2017 18:00:04 -0700 Subject: [PATCH 07/26] Use @exports so enum doc appears as its own section in the documentation --- Source/Renderer/TextureMagnificationFilter.js | 2 +- Source/Renderer/TextureMinificationFilter.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Renderer/TextureMagnificationFilter.js b/Source/Renderer/TextureMagnificationFilter.js index 5911e0ce82f6..e96a0a7251af 100644 --- a/Source/Renderer/TextureMagnificationFilter.js +++ b/Source/Renderer/TextureMagnificationFilter.js @@ -10,7 +10,7 @@ define([ * Enumerates all possible filters used when magnifying WebGL textures, which takes places when zooming * into imagery. Provides the possible values for the {@link ImageryLayer#magnificationFilter} property. * - * @alias TextureMagnificationFilter + * @exports TextureMagnificationFilter * * @see TextureMinificationFilter * @see ImageryLayer#magnificationFilter diff --git a/Source/Renderer/TextureMinificationFilter.js b/Source/Renderer/TextureMinificationFilter.js index 56888e0d0c68..30e55dbc4320 100644 --- a/Source/Renderer/TextureMinificationFilter.js +++ b/Source/Renderer/TextureMinificationFilter.js @@ -10,7 +10,7 @@ define([ * Enumerates all possible filters used when minifying WebGL textures, which takes places when zooming * out of imagery. Provides the possible values for the {@link ImageryLayer#minificationFilter} property. * - * @alias TextureMinificationFilter + * @exports TextureMinificationFilter * * @see TextureMagnificationFilter * @see ImageryLayer#minificationFilter From b9b8ab79938d07811115dfb2cb5c95e83d95a016 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Wed, 11 Oct 2017 18:02:01 -0700 Subject: [PATCH 08/26] added @type {Number} and @constant to enum values --- Source/Renderer/TextureMagnificationFilter.js | 6 ++++++ Source/Renderer/TextureMinificationFilter.js | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Source/Renderer/TextureMagnificationFilter.js b/Source/Renderer/TextureMagnificationFilter.js index e96a0a7251af..91a6c5bac67e 100644 --- a/Source/Renderer/TextureMagnificationFilter.js +++ b/Source/Renderer/TextureMagnificationFilter.js @@ -18,10 +18,16 @@ define([ var TextureMagnificationFilter = { /** * Nearest neighbor sampling of image pixels to texture. + * + * @type {Number} + * @constant */ NEAREST : WebGLConstants.NEAREST, /** * Bi-linear interpolation of image pixels to texture. + * + * @type {Number} + * @constant */ LINEAR : WebGLConstants.LINEAR, diff --git a/Source/Renderer/TextureMinificationFilter.js b/Source/Renderer/TextureMinificationFilter.js index 30e55dbc4320..e14c9d47b1f4 100644 --- a/Source/Renderer/TextureMinificationFilter.js +++ b/Source/Renderer/TextureMinificationFilter.js @@ -18,26 +18,44 @@ define([ var TextureMinificationFilter = { /** * Nearest neighbor sampling of image pixels to texture. + * + * @type {Number} + * @constant */ NEAREST : WebGLConstants.NEAREST, /** * Bi-linear interpolation of image pixels to texture. + * + * @type {Number} + * @constant */ LINEAR : WebGLConstants.LINEAR, /** * WebGL NEAREST_MIPMAP_NEAREST interpolation of image pixels to texture. + * + * @type {Number} + * @constant */ NEAREST_MIPMAP_NEAREST : WebGLConstants.NEAREST_MIPMAP_NEAREST, /** * WebGL LINEAR_MIPMAP_NEAREST interpolation of image pixels to texture. + * + * @type {Number} + * @constant */ LINEAR_MIPMAP_NEAREST : WebGLConstants.LINEAR_MIPMAP_NEAREST, /** * WebGL NEAREST_MIPMAP_LINEAR interpolation of image pixels to texture. + * + * @type {Number} + * @constant */ NEAREST_MIPMAP_LINEAR : WebGLConstants.NEAREST_MIPMAP_LINEAR, /** * WebGL LINEAR_MIPMAP_LINEAR interpolation of image pixels to texture. + * + * @type {Number} + * @constant */ LINEAR_MIPMAP_LINEAR : WebGLConstants.LINEAR_MIPMAP_LINEAR, From 722cd71d6b38520587da1dc92001b1e2bac78149 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Wed, 11 Oct 2017 18:03:09 -0700 Subject: [PATCH 09/26] use upper case Boolean --- Source/Renderer/TextureMagnificationFilter.js | 2 +- Source/Renderer/TextureMinificationFilter.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Renderer/TextureMagnificationFilter.js b/Source/Renderer/TextureMagnificationFilter.js index 91a6c5bac67e..2fd64b300d4a 100644 --- a/Source/Renderer/TextureMagnificationFilter.js +++ b/Source/Renderer/TextureMagnificationFilter.js @@ -35,7 +35,7 @@ define([ * Validates the given textureMinificationFilter with respect to the possible enum values. * * @param textureMagnificationFilter - * @returns {boolean} true if textureMagnificationFilter is valid. + * @returns {Boolean} true if textureMagnificationFilter is valid. */ validate : function(textureMagnificationFilter) { return ((textureMagnificationFilter === TextureMagnificationFilter.NEAREST) || diff --git a/Source/Renderer/TextureMinificationFilter.js b/Source/Renderer/TextureMinificationFilter.js index e14c9d47b1f4..df08f2d960ed 100644 --- a/Source/Renderer/TextureMinificationFilter.js +++ b/Source/Renderer/TextureMinificationFilter.js @@ -63,7 +63,7 @@ define([ * Validates the given textureMinificationFilter with respect to the possible enum values. * * @param textureMinificationFilter - * @returns {boolean} true if textureMinificationFilter is valid. + * @returns {Boolean} true if textureMinificationFilter is valid. */ validate : function(textureMinificationFilter) { return ((textureMinificationFilter === TextureMinificationFilter.NEAREST) || From d5ccbb839245eaf2d87eb4cc222c7ac2b784ab1e Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Wed, 11 Oct 2017 18:04:07 -0700 Subject: [PATCH 10/26] made validate() methods @private --- Source/Renderer/TextureMagnificationFilter.js | 2 ++ Source/Renderer/TextureMinificationFilter.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Source/Renderer/TextureMagnificationFilter.js b/Source/Renderer/TextureMagnificationFilter.js index 2fd64b300d4a..edb9f3bf354d 100644 --- a/Source/Renderer/TextureMagnificationFilter.js +++ b/Source/Renderer/TextureMagnificationFilter.js @@ -34,6 +34,8 @@ define([ /** * Validates the given textureMinificationFilter with respect to the possible enum values. * + * @private + * * @param textureMagnificationFilter * @returns {Boolean} true if textureMagnificationFilter is valid. */ diff --git a/Source/Renderer/TextureMinificationFilter.js b/Source/Renderer/TextureMinificationFilter.js index df08f2d960ed..0f31ea0ee810 100644 --- a/Source/Renderer/TextureMinificationFilter.js +++ b/Source/Renderer/TextureMinificationFilter.js @@ -62,6 +62,8 @@ define([ /** * Validates the given textureMinificationFilter with respect to the possible enum values. * + * @private + * * @param textureMinificationFilter * @returns {Boolean} true if textureMinificationFilter is valid. */ From 8d27fe19ba02ddd74b15bb5e8fee2126e6e39570 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Wed, 11 Oct 2017 18:11:32 -0700 Subject: [PATCH 11/26] added defaultMinificationFilter and defaultMagnificationFilter to ImageryProvider --- Source/Scene/ImageryProvider.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Source/Scene/ImageryProvider.js b/Source/Scene/ImageryProvider.js index 3cfdc11e9ace..efb784ee01fb 100644 --- a/Source/Scene/ImageryProvider.js +++ b/Source/Scene/ImageryProvider.js @@ -93,6 +93,22 @@ define([ */ this.defaultGamma = undefined; + /** + * The default texture minification filter to apply to this provider. + * + * @type {TextureMinificationFilter} + * @default undefined + */ + this.defaultMinificationFilter = undefined; + + /** + * The default texture magnification filter to apply to this provider. + * + * @type {TextureMagnificationFilter} + * @default undefined + */ + this.defaultMagnificationFilter = undefined; + DeveloperError.throwInstantiationError(); } From 3ec59b0ca4d1d9616179d143a7125f983a68ffc8 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Wed, 11 Oct 2017 18:16:03 -0700 Subject: [PATCH 12/26] Updated api docs minification/magnificationFilter props --- Source/Scene/ImageryLayer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index 70f5861b6b27..27b32ae5634a 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -224,6 +224,9 @@ define([ * Possible values are {@link TextureMinificationFilter.LINEAR} (the default) * and {@link TextureMinificationFilter.NEAREST}. * + * To take effect, this property must be set immediately after adding the imagery layer. + * Once a texture is loaded it won't be possible to change the texture filter used. + * * @type {TextureMinificationFilter} * @default {@link ImageryLayer.DEFAULT_MINIFICATION_FILTER} */ @@ -234,6 +237,9 @@ define([ * Possible values are {@link TextureMagnificationFilter.LINEAR} (the default) * and {@link TextureMagnificationFilter.NEAREST}. * + * To take effect, this property must be set immediately after adding the imagery layer. + * Once a texture is loaded it won't be possible to change the texture filter used. + * * @type {TextureMagnificationFilter} * @default {@link ImageryLayer.DEFAULT_MAGNIFICATION_FILTER} */ From e5b9b618dba05351c9b176467f4172dfc466e398 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Wed, 11 Oct 2017 18:17:47 -0700 Subject: [PATCH 13/26] fixed order of constants --- Source/Scene/ImageryLayer.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index 27b32ae5634a..080979cc675e 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -350,14 +350,6 @@ define([ */ ImageryLayer.DEFAULT_SPLIT = ImagerySplitDirection.NONE; - /** - * This value is used as the default texture magnification filter for the imagery layer if one is not provided - * during construction or by the imagery provider. - * @type {TextureMagnificationFilter} - * @default TextureMagnificationFilter.LINEAR - */ - ImageryLayer.DEFAULT_MAGNIFICATION_FILTER = TextureMagnificationFilter.LINEAR; - /** * This value is used as the default texture minification filter for the imagery layer if one is not provided * during construction or by the imagery provider. @@ -366,6 +358,14 @@ define([ */ ImageryLayer.DEFAULT_MINIFICATION_FILTER = TextureMinificationFilter.LINEAR; + /** + * This value is used as the default texture magnification filter for the imagery layer if one is not provided + * during construction or by the imagery provider. + * @type {TextureMagnificationFilter} + * @default TextureMagnificationFilter.LINEAR + */ + ImageryLayer.DEFAULT_MAGNIFICATION_FILTER = TextureMagnificationFilter.LINEAR; + /** * Gets a value indicating whether this layer is the base layer in the * {@link ImageryLayerCollection}. The base layer is the one that underlies all From 47f66bab213324cba85e17f99f2242ebd0ed7e0f Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Wed, 11 Oct 2017 18:18:40 -0700 Subject: [PATCH 14/26] fixed coding style --- Source/Scene/ImageryLayer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index 080979cc675e..8d0b666e1541 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -830,14 +830,14 @@ define([ source : { arrayBufferView : image.bufferView }, - sampler: sampler + sampler : sampler }); } else { texture = new Texture({ context : context, source : image, pixelFormat : imageryProvider.hasAlphaChannel ? PixelFormat.RGBA : PixelFormat.RGB, - sampler: sampler + sampler : sampler }); } From 88d3458d0428928ece5a225dea81391ddadf0dc2 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Wed, 11 Oct 2017 18:41:26 -0700 Subject: [PATCH 15/26] added new test for default texture filters of ImageryProvider --- Specs/Scene/ImageryLayerSpec.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Specs/Scene/ImageryLayerSpec.js b/Specs/Scene/ImageryLayerSpec.js index fbcc38c51af9..efb9c181ba1a 100644 --- a/Specs/Scene/ImageryLayerSpec.js +++ b/Specs/Scene/ImageryLayerSpec.js @@ -371,22 +371,38 @@ defineSuite([ expect(layer.isDestroyed()).toEqual(true); }); - it('texture filter properties work as expected', function() { + it('allows setting texture filter properties', function() { var provider = new SingleTileImageryProvider({ url : 'Data/Images/Red16x16.png' }); - var layer = new ImageryLayer(provider, {}); - expect(layer.magnificationFilter).toEqual(TextureMagnificationFilter.LINEAR); + // expect default LINEAR + var layer = new ImageryLayer(provider); expect(layer.minificationFilter).toEqual(TextureMinificationFilter.LINEAR); + expect(layer.magnificationFilter).toEqual(TextureMagnificationFilter.LINEAR); layer.destroy(); + // change to NEAREST layer = new ImageryLayer(provider, { - magnificationFilter: TextureMagnificationFilter.NEAREST, - minificationFilter: TextureMinificationFilter.NEAREST + minificationFilter: TextureMinificationFilter.NEAREST, + magnificationFilter: TextureMagnificationFilter.NEAREST }); + expect(layer.minificationFilter).toEqual(TextureMinificationFilter.NEAREST); expect(layer.magnificationFilter).toEqual(TextureMagnificationFilter.NEAREST); + layer.destroy(); + }); + + it('uses default texture filter properties of ImageryProvider', function() { + var provider = new SingleTileImageryProvider({ + url : 'Data/Images/Red16x16.png' + }); + + provider.defaultMinificationFilter = TextureMinificationFilter.NEAREST; + provider.defaultMagnificationFilter = TextureMinificationFilter.NEAREST; + + var layer = new ImageryLayer(provider); expect(layer.minificationFilter).toEqual(TextureMinificationFilter.NEAREST); + expect(layer.magnificationFilter).toEqual(TextureMagnificationFilter.NEAREST); layer.destroy(); }); From eb5ec0c73c4e608ded594e56516ab6dc1dc98f94 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Thu, 12 Oct 2017 18:39:34 +0200 Subject: [PATCH 16/26] fix: turned context.cache.imageryLayer_Sampler into context.cache.imageryLayerSamplers so that we can holds samplers with different configurations --- Source/Scene/ImageryLayer.js | 50 +++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index 8d0b666e1541..7f2cc4cf2f04 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -850,36 +850,56 @@ define([ imagery.state = ImageryState.TEXTURE_LOADED; }; + function getSamplerKey(minificationFilter, magnificationFilter, maximumAnisotropy) { + return minificationFilter + ':' + magnificationFilter + ':' + maximumAnisotropy; + } + function finalizeReprojectTexture(imageryLayer, context, imagery, texture) { // Use mipmaps if this texture has power-of-two dimensions. if (!PixelFormat.isCompressedFormat(texture.pixelFormat) && CesiumMath.isPowerOfTwo(texture.width) && CesiumMath.isPowerOfTwo(texture.height)) { - var mipmapSampler = context.cache.imageryLayer_mipmapSampler; + var mipmapMinificationFilter = imageryLayer.minificationFilter; + if (mipmapMinificationFilter === TextureMinificationFilter.NEAREST) { + mipmapMinificationFilter = TextureMinificationFilter.NEAREST_MIPMAP_NEAREST; + } else if (mipmapMinificationFilter === TextureMinificationFilter.LINEAR) { + mipmapMinificationFilter = TextureMinificationFilter.LINEAR_MIPMAP_LINEAR; + } + var mipmapMagnificationFilter = imageryLayer.magnificationFilter; + var maximumSupportedAnisotropy = ContextLimits.maximumTextureFilterAnisotropy; + var maximumAnisotropy = Math.min(maximumSupportedAnisotropy, defaultValue(imageryLayer._maximumAnisotropy, maximumSupportedAnisotropy)); + var mipmapSamplerKey = getSamplerKey(mipmapMinificationFilter, mipmapMagnificationFilter, maximumAnisotropy); + var mipmapSamplers = context.cache.imageryLayerMipmapSamplers; + var mipmapSampler = mipmapSamplers && mipmapSamplers[mipmapSamplerKey]; if (!defined(mipmapSampler)) { - var maximumSupportedAnisotropy = ContextLimits.maximumTextureFilterAnisotropy; - var mipmapMinificationFilter = imageryLayer.minificationFilter; - if (imageryLayer.minificationFilter === TextureMinificationFilter.NEAREST) { - mipmapMinificationFilter = TextureMinificationFilter.NEAREST_MIPMAP_NEAREST; - } else if (imageryLayer.minificationFilter === TextureMinificationFilter.LINEAR) { - mipmapMinificationFilter = TextureMinificationFilter.LINEAR_MIPMAP_LINEAR; + if (!defined(mipmapSamplers)) { + mipmapSamplers = context.cache.imageryLayerMipmapSamplers = {}; } - mipmapSampler = context.cache.imageryLayer_mipmapSampler = new Sampler({ + mipmapSampler = mipmapSamplers[mipmapSamplerKey] = new Sampler({ wrapS : TextureWrap.CLAMP_TO_EDGE, wrapT : TextureWrap.CLAMP_TO_EDGE, minificationFilter : mipmapMinificationFilter, - magnificationFilter : imageryLayer.magnificationFilter, - maximumAnisotropy : Math.min(maximumSupportedAnisotropy, defaultValue(imageryLayer._maximumAnisotropy, maximumSupportedAnisotropy)) + magnificationFilter : mipmapMagnificationFilter, + maximumAnisotropy : maximumAnisotropy }); } - texture.generateMipmap(MipmapHint.NICEST); + //texture.generateMipmap(MipmapHint.NICEST); + //texture.generateMipmap(); texture.sampler = mipmapSampler; + texture.generateMipmap(MipmapHint.FASTEST); } else { - var nonMipmapSampler = context.cache.imageryLayer_nonMipmapSampler; + var minificationFilter = imageryLayer.minificationFilter; + var magnificationFilter = imageryLayer.magnificationFilter; + var nonMipmapSamplerKey = getSamplerKey(minificationFilter, magnificationFilter, 0); + var nonMipmapSamplers = context.cache.imageryLayerNonMipmapSamplers; + var nonMipmapSampler = nonMipmapSamplers && nonMipmapSamplers[nonMipmapSamplerKey]; if (!defined(nonMipmapSampler)) { - nonMipmapSampler = context.cache.imageryLayer_nonMipmapSampler = new Sampler({ + if (!defined(nonMipmapSamplers)) { + nonMipmapSamplers = context.cache.imageryLayerNonMipmapSamplers = {}; + } + nonMipmapSampler = nonMipmapSamplers[nonMipmapSamplerKey] = new Sampler({ wrapS : TextureWrap.CLAMP_TO_EDGE, wrapT : TextureWrap.CLAMP_TO_EDGE, - minificationFilter : imageryLayer.minificationFilter, - magnificationFilter : imageryLayer.magnificationFilter + minificationFilter : minificationFilter, + magnificationFilter : magnificationFilter }); } texture.sampler = nonMipmapSampler; From 924dc1cd3c6814ee1d600462b79e85f3a106c43e Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Thu, 12 Oct 2017 19:09:03 +0200 Subject: [PATCH 17/26] reverted experimental change --- Source/Scene/ImageryLayer.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index 7f2cc4cf2f04..5ec28357a9fd 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -881,10 +881,8 @@ define([ maximumAnisotropy : maximumAnisotropy }); } - //texture.generateMipmap(MipmapHint.NICEST); - //texture.generateMipmap(); + texture.generateMipmap(MipmapHint.NICEST); texture.sampler = mipmapSampler; - texture.generateMipmap(MipmapHint.FASTEST); } else { var minificationFilter = imageryLayer.minificationFilter; var magnificationFilter = imageryLayer.magnificationFilter; From 3d5bfaa650df738e20b268cb3e3b43c7e2103173 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Fri, 13 Oct 2017 12:33:26 +0200 Subject: [PATCH 18/26] create mipmap textures only for linear mini/magni filters --- Source/Scene/ImageryLayer.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index 5ec28357a9fd..37a8ea4a6fd0 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -855,18 +855,19 @@ define([ } function finalizeReprojectTexture(imageryLayer, context, imagery, texture) { - // Use mipmaps if this texture has power-of-two dimensions. - if (!PixelFormat.isCompressedFormat(texture.pixelFormat) && CesiumMath.isPowerOfTwo(texture.width) && CesiumMath.isPowerOfTwo(texture.height)) { - var mipmapMinificationFilter = imageryLayer.minificationFilter; - if (mipmapMinificationFilter === TextureMinificationFilter.NEAREST) { - mipmapMinificationFilter = TextureMinificationFilter.NEAREST_MIPMAP_NEAREST; - } else if (mipmapMinificationFilter === TextureMinificationFilter.LINEAR) { - mipmapMinificationFilter = TextureMinificationFilter.LINEAR_MIPMAP_LINEAR; + var minificationFilter = imageryLayer.minificationFilter; + var magnificationFilter = imageryLayer.magnificationFilter; + var usesLinearTextureFilter = minificationFilter === TextureMinificationFilter.LINEAR && magnificationFilter === TextureMinificationFilter.LINEAR; + // Use mipmaps if this texture uses linear filters and has power-of-two dimensions. + if (usesLinearTextureFilter && !PixelFormat.isCompressedFormat(texture.pixelFormat) && CesiumMath.isPowerOfTwo(texture.width) && CesiumMath.isPowerOfTwo(texture.height)) { + if (minificationFilter === TextureMinificationFilter.NEAREST) { + minificationFilter = TextureMinificationFilter.NEAREST_MIPMAP_NEAREST; + } else if (minificationFilter === TextureMinificationFilter.LINEAR) { + minificationFilter = TextureMinificationFilter.LINEAR_MIPMAP_LINEAR; } - var mipmapMagnificationFilter = imageryLayer.magnificationFilter; var maximumSupportedAnisotropy = ContextLimits.maximumTextureFilterAnisotropy; var maximumAnisotropy = Math.min(maximumSupportedAnisotropy, defaultValue(imageryLayer._maximumAnisotropy, maximumSupportedAnisotropy)); - var mipmapSamplerKey = getSamplerKey(mipmapMinificationFilter, mipmapMagnificationFilter, maximumAnisotropy); + var mipmapSamplerKey = getSamplerKey(minificationFilter, magnificationFilter, maximumAnisotropy); var mipmapSamplers = context.cache.imageryLayerMipmapSamplers; var mipmapSampler = mipmapSamplers && mipmapSamplers[mipmapSamplerKey]; if (!defined(mipmapSampler)) { @@ -876,16 +877,14 @@ define([ mipmapSampler = mipmapSamplers[mipmapSamplerKey] = new Sampler({ wrapS : TextureWrap.CLAMP_TO_EDGE, wrapT : TextureWrap.CLAMP_TO_EDGE, - minificationFilter : mipmapMinificationFilter, - magnificationFilter : mipmapMagnificationFilter, + minificationFilter : minificationFilter, + magnificationFilter : magnificationFilter, maximumAnisotropy : maximumAnisotropy }); } texture.generateMipmap(MipmapHint.NICEST); texture.sampler = mipmapSampler; } else { - var minificationFilter = imageryLayer.minificationFilter; - var magnificationFilter = imageryLayer.magnificationFilter; var nonMipmapSamplerKey = getSamplerKey(minificationFilter, magnificationFilter, 0); var nonMipmapSamplers = context.cache.imageryLayerNonMipmapSamplers; var nonMipmapSampler = nonMipmapSamplers && nonMipmapSamplers[nonMipmapSamplerKey]; From 151f8fe3e502d728829b27b0984bdec5da4f95aa Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Fri, 13 Oct 2017 13:16:43 +0200 Subject: [PATCH 19/26] added texture filter example to Sandcastle --- .../Imagery Layers Texture Filters.html | 110 ++++++++++++++++++ .../Imagery Layers Texture Filters.jpg | Bin 0 -> 8135 bytes 2 files changed, 110 insertions(+) create mode 100644 Apps/Sandcastle/gallery/Imagery Layers Texture Filters.html create mode 100644 Apps/Sandcastle/gallery/Imagery Layers Texture Filters.jpg diff --git a/Apps/Sandcastle/gallery/Imagery Layers Texture Filters.html b/Apps/Sandcastle/gallery/Imagery Layers Texture Filters.html new file mode 100644 index 000000000000..c82ceb588ff8 --- /dev/null +++ b/Apps/Sandcastle/gallery/Imagery Layers Texture Filters.html @@ -0,0 +1,110 @@ + + + + + + + + + Cesium Demo + + + + + + + + +
+
+
+

Loading...

+
+ + + + + diff --git a/Apps/Sandcastle/gallery/Imagery Layers Texture Filters.jpg b/Apps/Sandcastle/gallery/Imagery Layers Texture Filters.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1b2318fe46a0922a6409696b5fc1dea7ddec4410 GIT binary patch literal 8135 zcmbVwcT`i|)9yh)iU^|eA~mlxDT1_61QHPe0Ra&RN>vaL0@6g95CsA03Q`P0q<13H zyYya!kRTmGkxr-qLh{Am{nmHax_{k!Cufqq&fc>#&peZvvqKrD%mJ5lwRE%q8X6kl zDfIz0|3AX(9v)M^wbdzRUtGy|1;L25d~=fbN?K5QU;*D1ME~a zpz2?FO4YwM|M_%(=JfKF)JywU|H?~AOUWovziATC0M60S{Js8LXz6MH%6U3ET6%`_ z3=Dsjk?8^xBO@~-0|WC#X66elRAFFZWxL42`gi!ml><74zqn}5`B0UXosRyx%=ydeMhwq9 zt_aA!W4wCzQ$|?}lc3zA9S&R1U(Ejq$#{s-9q#x()3(9%%J zqh$x6!0LjF>7?@En9R%0>_`y~;)6wpOc#y7-I2=9wZRY4YR>(-Ue$fE2vn0tB|QE9;Etb3*yE`d4p!WBXc72f-0 zngs|A5guK*HjZB=t@*6qNBKAFv@D1Rh@SQz`&Zxx_XWuPacAhkuXUEf{)#Kc#-m%f zEQ3nDt?omQ4HMLZ2)jSCX&Q%&6kvk1cF=WFh_*6WH>ujF8I7}b3vZ^W1VvB)wu8pI zozM@rbM}YO4d&@lS1-RHUm^GZ;56z$a8<|aaL=V>9eq!P-OY69WrZK!B074Unvm>v zC_wnZ&s?78J-2vFXp(*KSp$d9|BMPH&|`V*DVe{2sXQ z!PkMh$HJmo#Hq6-Reo6|j$O|_uh(l})6>a--EBltIIc~)?{e@fZ0c!IWs`q`ui4L& zs5iC*pU{JgL1c2*Ph@T-Uq2S^M&Fsm5tR++KTZ^UP`;G%uJt=ZMrl247*F&gBpr4- zf%T0wkTX1~7Akn2{^%a5J8nsM?uyFzRv^_GhXUl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ep29TiL`I!Z}Gh!@9T*W8u!^8>w*d z_Q>ISmz!FgwYGlSLyz>Y8dGgOv&1PtyR|Gv73!4Rv%t20@%D|d3Hk^lTdjysZ(Bop z7q4KF?J)8FfdP1i_87g#V?xw6)w|*nUG`?U^KoY>Av2*orm!pT`v#+ER=U-|Rik(+ z;gElwaZFww3kBSIK05ezc2Y5iiQVGQYj&N|?y_>D5g64A`PTX#9>V(&yZcXqb325N z-_Oy6o@Tw3mfP&n&=Ux%&;|cjBE|{{oMXOx^$h literal 0 HcmV?d00001 From dbf8d3a4db928e8a13ba676835ae0d07f0af516a Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Fri, 13 Oct 2017 13:34:36 +0200 Subject: [PATCH 20/26] fixed a harmless typo --- Source/Scene/ImageryLayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index 37a8ea4a6fd0..5580f4c8f0ab 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -857,7 +857,7 @@ define([ function finalizeReprojectTexture(imageryLayer, context, imagery, texture) { var minificationFilter = imageryLayer.minificationFilter; var magnificationFilter = imageryLayer.magnificationFilter; - var usesLinearTextureFilter = minificationFilter === TextureMinificationFilter.LINEAR && magnificationFilter === TextureMinificationFilter.LINEAR; + var usesLinearTextureFilter = minificationFilter === TextureMinificationFilter.LINEAR && magnificationFilter === TextureMagnificationFilter.LINEAR; // Use mipmaps if this texture uses linear filters and has power-of-two dimensions. if (usesLinearTextureFilter && !PixelFormat.isCompressedFormat(texture.pixelFormat) && CesiumMath.isPowerOfTwo(texture.width) && CesiumMath.isPowerOfTwo(texture.height)) { if (minificationFilter === TextureMinificationFilter.NEAREST) { From 3d632cd64ed89f6bf9968ca157056a744629d196 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Thu, 19 Oct 2017 11:36:46 +0200 Subject: [PATCH 21/26] be more explicit about checking if something is undefined --- Source/Scene/ImageryLayer.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index 5580f4c8f0ab..97995ac670d7 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -858,22 +858,21 @@ define([ var minificationFilter = imageryLayer.minificationFilter; var magnificationFilter = imageryLayer.magnificationFilter; var usesLinearTextureFilter = minificationFilter === TextureMinificationFilter.LINEAR && magnificationFilter === TextureMagnificationFilter.LINEAR; - // Use mipmaps if this texture uses linear filters and has power-of-two dimensions. + // Use mipmaps if this texture has power-of-two dimensions. + // In addition, we only use mipmaps if the texture filters are both LINEAR, because a NEAREST filter + // in Cesium v1.39 had no effect on mipmaps (see discussion on PR #5890). if (usesLinearTextureFilter && !PixelFormat.isCompressedFormat(texture.pixelFormat) && CesiumMath.isPowerOfTwo(texture.width) && CesiumMath.isPowerOfTwo(texture.height)) { - if (minificationFilter === TextureMinificationFilter.NEAREST) { - minificationFilter = TextureMinificationFilter.NEAREST_MIPMAP_NEAREST; - } else if (minificationFilter === TextureMinificationFilter.LINEAR) { - minificationFilter = TextureMinificationFilter.LINEAR_MIPMAP_LINEAR; - } + minificationFilter = TextureMinificationFilter.LINEAR_MIPMAP_LINEAR; var maximumSupportedAnisotropy = ContextLimits.maximumTextureFilterAnisotropy; var maximumAnisotropy = Math.min(maximumSupportedAnisotropy, defaultValue(imageryLayer._maximumAnisotropy, maximumSupportedAnisotropy)); var mipmapSamplerKey = getSamplerKey(minificationFilter, magnificationFilter, maximumAnisotropy); var mipmapSamplers = context.cache.imageryLayerMipmapSamplers; - var mipmapSampler = mipmapSamplers && mipmapSamplers[mipmapSamplerKey]; + if (!defined(mipmapSamplers)) { + mipmapSamplers = {}; + context.cache.imageryLayerMipmapSamplers = mipmapSamplers; + } + var mipmapSampler = mipmapSamplers[mipmapSamplerKey]; if (!defined(mipmapSampler)) { - if (!defined(mipmapSamplers)) { - mipmapSamplers = context.cache.imageryLayerMipmapSamplers = {}; - } mipmapSampler = mipmapSamplers[mipmapSamplerKey] = new Sampler({ wrapS : TextureWrap.CLAMP_TO_EDGE, wrapT : TextureWrap.CLAMP_TO_EDGE, @@ -887,11 +886,12 @@ define([ } else { var nonMipmapSamplerKey = getSamplerKey(minificationFilter, magnificationFilter, 0); var nonMipmapSamplers = context.cache.imageryLayerNonMipmapSamplers; - var nonMipmapSampler = nonMipmapSamplers && nonMipmapSamplers[nonMipmapSamplerKey]; + if (!defined(nonMipmapSamplers)) { + nonMipmapSamplers = {}; + context.cache.imageryLayerNonMipmapSamplers = nonMipmapSamplers; + } + var nonMipmapSampler = nonMipmapSamplers[nonMipmapSamplerKey]; if (!defined(nonMipmapSampler)) { - if (!defined(nonMipmapSamplers)) { - nonMipmapSamplers = context.cache.imageryLayerNonMipmapSamplers = {}; - } nonMipmapSampler = nonMipmapSamplers[nonMipmapSamplerKey] = new Sampler({ wrapS : TextureWrap.CLAMP_TO_EDGE, wrapT : TextureWrap.CLAMP_TO_EDGE, From c826ec9f690ef398c30be92d6ef02e50ee6162b4 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Thu, 19 Oct 2017 11:48:26 +0200 Subject: [PATCH 22/26] merged upstream --- CHANGES.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 01f7ddc2b2cb..a48e252a6803 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,6 @@ Change Log ### 1.39 - 2017-11-01 * Added function that inserts missing namespace declarations into KML files. [#5860](https://github.com/AnalyticalGraphicsInc/cesium/pull/5860) - * Added support for the layer.json `parentUrl` property in `CesiumTerrainProvider` to allow for compositing of tilesets. * Fixed a bug that caused KML ground overlays to appear distorted when rotation was applied. [#5914](https://github.com/AnalyticalGraphicsInc/cesium/issues/5914) * Added two new properties to `ImageryLayer` that allow for adjusting the texture sampler used for up- and down-sampling of image tiles, namely `minificationFilter` and `magnificationFilter` with possible values `LINEAR` (the default) and `NEAREST` defined in `TextureMinificationFilter` and `TextureMagnificationFilter`. [#5846](https://github.com/AnalyticalGraphicsInc/cesium/issues/5846) From 356f677f0fd978c7824006a6e31cdab945677db5 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Thu, 19 Oct 2017 13:17:58 -0400 Subject: [PATCH 23/26] Tweak comment wording --- Source/Scene/ImageryLayer.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index 97995ac670d7..839da40ee183 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -859,8 +859,7 @@ define([ var magnificationFilter = imageryLayer.magnificationFilter; var usesLinearTextureFilter = minificationFilter === TextureMinificationFilter.LINEAR && magnificationFilter === TextureMagnificationFilter.LINEAR; // Use mipmaps if this texture has power-of-two dimensions. - // In addition, we only use mipmaps if the texture filters are both LINEAR, because a NEAREST filter - // in Cesium v1.39 had no effect on mipmaps (see discussion on PR #5890). + // In addition, mipmaps are only generated if the texture filters are both LINEAR. if (usesLinearTextureFilter && !PixelFormat.isCompressedFormat(texture.pixelFormat) && CesiumMath.isPowerOfTwo(texture.width) && CesiumMath.isPowerOfTwo(texture.height)) { minificationFilter = TextureMinificationFilter.LINEAR_MIPMAP_LINEAR; var maximumSupportedAnisotropy = ContextLimits.maximumTextureFilterAnisotropy; From d5cf4537741df19b6a390b0173e4e17d94d468ca Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Mon, 23 Oct 2017 16:04:46 +0200 Subject: [PATCH 24/26] added assertions for imagery.texture.sampler --- Specs/Scene/ImageryLayerSpec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Specs/Scene/ImageryLayerSpec.js b/Specs/Scene/ImageryLayerSpec.js index efb9c181ba1a..22fe1c728999 100644 --- a/Specs/Scene/ImageryLayerSpec.js +++ b/Specs/Scene/ImageryLayerSpec.js @@ -191,6 +191,9 @@ defineSuite([ return imagery.state === ImageryState.READY; }).then(function() { expect(imagery.texture).toBeDefined(); + expect(imagery.texture.sampler).toBeDefined(); + expect(imagery.texture.sampler.minificationFilter).toEqual(TextureMinificationFilter.LINEAR_MIPMAP_LINEAR); + expect(imagery.texture.sampler.magnificationFilter).toEqual(TextureMinificationFilter.LINEAR); expect(textureBeforeReprojection).not.toEqual(imagery.texture); imagery.releaseReference(); }); @@ -273,6 +276,9 @@ defineSuite([ return imagery.state === ImageryState.READY; }).then(function() { expect(imagery.texture).toBeDefined(); + expect(imagery.texture.sampler).toBeDefined(); + expect(imagery.texture.sampler.minificationFilter).toEqual(TextureMinificationFilter.LINEAR_MIPMAP_LINEAR); + expect(imagery.texture.sampler.magnificationFilter).toEqual(TextureMinificationFilter.LINEAR); expect(textureBeforeReprojection).not.toEqual(imagery.texture); imagery.releaseReference(); }); @@ -319,6 +325,9 @@ defineSuite([ return imagery.state === ImageryState.READY; }).then(function() { expect(imagery.texture).toBeDefined(); + expect(imagery.texture.sampler).toBeDefined(); + expect(imagery.texture.sampler.minificationFilter).toEqual(TextureMinificationFilter.LINEAR_MIPMAP_LINEAR); + expect(imagery.texture.sampler.magnificationFilter).toEqual(TextureMinificationFilter.LINEAR); expect(imagery.texture).toBe(imagery.textureWebMercator); imagery.releaseReference(); }); From a621f1396964aab8c31edf52a610e85d0f4cfd4d Mon Sep 17 00:00:00 2001 From: hpinkos Date: Mon, 23 Oct 2017 11:11:38 -0400 Subject: [PATCH 25/26] fix freezeRenderState test --- Specs/Renderer/RenderStateSpec.js | 9 +++++++-- Specs/customizeJasmine.js | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Specs/Renderer/RenderStateSpec.js b/Specs/Renderer/RenderStateSpec.js index 2a80493f342f..163ac9796fa0 100644 --- a/Specs/Renderer/RenderStateSpec.js +++ b/Specs/Renderer/RenderStateSpec.js @@ -1,14 +1,16 @@ defineSuite([ + 'Renderer/RenderState', + 'Core/defined', 'Core/WebGLConstants', 'Core/WindingOrder', 'Renderer/ContextLimits', - 'Renderer/RenderState', 'Specs/createContext' ], function( + RenderState, + defined, WebGLConstants, WindingOrder, ContextLimits, - RenderState, createContext) { 'use strict'; @@ -408,6 +410,9 @@ defineSuite([ }); it('freezes render states', function(){ + if (window.release) { + return; + } var rs = RenderState.fromCache(); expect(function() { rs.depthRange = {}; diff --git a/Specs/customizeJasmine.js b/Specs/customizeJasmine.js index 21dbdce268f3..5ba92c14c77a 100644 --- a/Specs/customizeJasmine.js +++ b/Specs/customizeJasmine.js @@ -140,6 +140,10 @@ define([ window.webglStub = true; } + if (release) { + window.release = true; + } + //env.catchExceptions(true); env.beforeEach(function () { From c635584938252c7148025af10cfc0cc2ba426fdd Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Mon, 23 Oct 2017 13:39:40 -0400 Subject: [PATCH 26/26] Fix release tests Cleans up #5466 which had some incomplete tests causing release builds to fail. Also simplified the tests to check frozen state instead of relying on exception handling. Also removed some uneeded `/*global defineSuite*/` statements I found while in the code --- Specs/DataSources/KmlTourFlyToSpec.js | 1 - Specs/DataSources/KmlTourSpec.js | 1 - Specs/Renderer/RenderStateSpec.js | 17 +------ Specs/Renderer/freezeRenderStateSpec.js | 60 ++++--------------------- Specs/Scene/TimeDynamicImagerySpec.js | 1 - Specs/customizeJasmine.js | 6 +-- Specs/spec-main.js | 3 ++ 7 files changed, 15 insertions(+), 74 deletions(-) diff --git a/Specs/DataSources/KmlTourFlyToSpec.js b/Specs/DataSources/KmlTourFlyToSpec.js index 71ee413aeb8e..49d61154f1ca 100644 --- a/Specs/DataSources/KmlTourFlyToSpec.js +++ b/Specs/DataSources/KmlTourFlyToSpec.js @@ -1,4 +1,3 @@ -/*global defineSuite*/ defineSuite([ 'DataSources/KmlTourFlyTo', 'DataSources/KmlCamera', diff --git a/Specs/DataSources/KmlTourSpec.js b/Specs/DataSources/KmlTourSpec.js index aca9c72fc898..98014337bb5a 100644 --- a/Specs/DataSources/KmlTourSpec.js +++ b/Specs/DataSources/KmlTourSpec.js @@ -1,4 +1,3 @@ -/*global defineSuite*/ defineSuite([ 'DataSources/KmlTour', 'DataSources/KmlTourFlyTo', diff --git a/Specs/Renderer/RenderStateSpec.js b/Specs/Renderer/RenderStateSpec.js index 163ac9796fa0..a65c20d60914 100644 --- a/Specs/Renderer/RenderStateSpec.js +++ b/Specs/Renderer/RenderStateSpec.js @@ -409,22 +409,9 @@ defineSuite([ expect(cache[fullKey]).not.toBeDefined(); }); - it('freezes render states', function(){ - if (window.release) { - return; - } + it('freezes render states', function() { var rs = RenderState.fromCache(); - expect(function() { - rs.depthRange = {}; - }).toThrow(); - - expect(function() { - rs.frontFace = WindingOrder.COUNTER_CLOCKWISE; - }).toThrow(); - - expect(function() { - rs._applyFunctions.push(function(){}); - }).not.toThrow(); + expect(Object.isFrozen(rs)).toBe(!window.specsUsingRelease); }); it('fails to create (frontFace)', function() { diff --git a/Specs/Renderer/freezeRenderStateSpec.js b/Specs/Renderer/freezeRenderStateSpec.js index b702657356b0..c12030f324c9 100644 --- a/Specs/Renderer/freezeRenderStateSpec.js +++ b/Specs/Renderer/freezeRenderStateSpec.js @@ -1,67 +1,23 @@ -/*global defineSuite*/ defineSuite([ 'Renderer/freezeRenderState' ], function( freezeRenderState) { 'use strict'; - it('works for literals', function() { + it('works as expected', function() { var fresh = { a: 1, - b: 'b', - c: 2.2, - u: undefined, - n: null - }; - - var frozen = freezeRenderState(fresh); - - expect(function() { - frozen.a = 2; - }).toThrow(); - - expect(function() { - frozen.b = 'c'; - }).toThrow(); - - expect(function() { - frozen.c = 2; - }).toThrow(); - - }); - - it('works for deep objects', function() { - var fresh = { - a: 2, - o: { - b: 2, + b: { c: 'c' - } - }; - - var frozen = freezeRenderState(fresh); - - expect(function() { - frozen.o.b = 3; - frozen.o.c = 'dddd'; - }).toThrow(); - }); - - it('ignores _applyFunctions', function() { - var fresh = { - a: 1, + }, _applyFunctions: [function() { }] }; var frozen = freezeRenderState(fresh); - - expect(function() { - frozen.a = 0; - }).toThrow(); - - expect(function() { - frozen._applyFunctions.push(function() { }); - }).not.toThrow(); + expect(Object.isFrozen(frozen)).toBe(true); + expect(Object.isFrozen(frozen.a)).toBe(true); + expect(Object.isFrozen(frozen.b)).toBe(true); + expect(Object.isFrozen(frozen.c)).toBe(true); + expect(Object.isFrozen(frozen._applyFunctions)).toBe(false); }); - }); diff --git a/Specs/Scene/TimeDynamicImagerySpec.js b/Specs/Scene/TimeDynamicImagerySpec.js index 4e26c96f545a..c0af7ab448b8 100644 --- a/Specs/Scene/TimeDynamicImagerySpec.js +++ b/Specs/Scene/TimeDynamicImagerySpec.js @@ -1,4 +1,3 @@ -/*global defineSuite*/ defineSuite([ 'Scene/TimeDynamicImagery', 'Core/Clock', diff --git a/Specs/customizeJasmine.js b/Specs/customizeJasmine.js index 5ba92c14c77a..4528777b094d 100644 --- a/Specs/customizeJasmine.js +++ b/Specs/customizeJasmine.js @@ -42,6 +42,8 @@ define([ }); } + window.specsUsingRelease = release; + window.fdefineSuite = function(deps, name, suite, categories) { defineSuite(deps, name, suite, categories, true); }; @@ -140,10 +142,6 @@ define([ window.webglStub = true; } - if (release) { - window.release = true; - } - //env.catchExceptions(true); env.beforeEach(function () { diff --git a/Specs/spec-main.js b/Specs/spec-main.js index 9ba3c174eeea..78342be219ad 100644 --- a/Specs/spec-main.js +++ b/Specs/spec-main.js @@ -21,6 +21,7 @@ } var built = getQueryParameter('built'); + var release = getQueryParameter('release'); var toRequire = ['Cesium']; @@ -73,6 +74,8 @@ */ window.jasmine = jasmineRequire.core(jasmineRequire); + window.specsUsingRelease = release; + window.defineSuite = function(deps, name, suite, categories) { /*global define,describe*/ if (typeof suite === 'object' || typeof suite === 'string') {