-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7808. Merge branch 'on-demand-bing-maps'
- Loading branch information
Showing
9 changed files
with
233 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
define([ | ||
'../Core/defined', | ||
'../Core/defaultValue' | ||
], function( | ||
defined, | ||
defaultValue) { | ||
'use strict'; | ||
|
||
/** | ||
* A policy for discarding tile images that contain no data (and so aren't actually images). | ||
* | ||
* @alias DiscardEmptyTileImagePolicy | ||
* @constructor | ||
* | ||
* @see DiscardMissingTileImagePolicy | ||
*/ | ||
function DiscardEmptyTileImagePolicy(options) { | ||
} | ||
|
||
/** | ||
* Determines if the discard policy is ready to process images. | ||
* @returns {Boolean} True if the discard policy is ready to process images; otherwise, false. | ||
*/ | ||
DiscardEmptyTileImagePolicy.prototype.isReady = function() { | ||
return true; | ||
}; | ||
|
||
/** | ||
* Given a tile image, decide whether to discard that image. | ||
* | ||
* @param {Image} image An image to test. | ||
* @returns {Boolean} True if the image should be discarded; otherwise, false. | ||
*/ | ||
DiscardEmptyTileImagePolicy.prototype.shouldDiscardImage = function(image) { | ||
return DiscardEmptyTileImagePolicy.EMPTY_IMAGE === image; | ||
}; | ||
|
||
/** | ||
* Default value for representing an empty image. | ||
*/ | ||
DiscardEmptyTileImagePolicy.EMPTY_IMAGE = {}; | ||
|
||
return DiscardEmptyTileImagePolicy; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
defineSuite([ | ||
'Scene/DiscardEmptyTileImagePolicy', | ||
'Core/Resource', | ||
'Specs/pollToPromise', | ||
'ThirdParty/when' | ||
], function( | ||
DiscardEmptyTileImagePolicy, | ||
Resource, | ||
pollToPromise, | ||
when) { | ||
'use strict'; | ||
|
||
afterEach(function() { | ||
Resource._Implementations.createImage = Resource._DefaultImplementations.createImage; | ||
Resource._Implementations.loadWithXhr = Resource._DefaultImplementations.loadWithXhr; | ||
}); | ||
|
||
describe('shouldDiscardImage', function() { | ||
it('does not discard a non-empty image', function() { | ||
var promises = []; | ||
promises.push(Resource.fetchImage('Data/Images/Green4x4.png')); | ||
|
||
var policy = new DiscardEmptyTileImagePolicy(); | ||
|
||
promises.push(pollToPromise(function() { | ||
return policy.isReady(); | ||
})); | ||
|
||
return when.all(promises, function(results) { | ||
var greenImage = results[0]; | ||
|
||
expect(policy.shouldDiscardImage(greenImage)).toEqual(false); | ||
}); | ||
}); | ||
|
||
it('discards an empty image', function() { | ||
var promises = []; | ||
promises.push(when.resolve(DiscardEmptyTileImagePolicy.EMPTY_IMAGE)); | ||
|
||
var policy = new DiscardEmptyTileImagePolicy(); | ||
|
||
promises.push(pollToPromise(function() { | ||
return policy.isReady(); | ||
})); | ||
|
||
return when.all(promises, function(results) { | ||
var emptyImage = results[0]; | ||
|
||
expect(policy.shouldDiscardImage(emptyImage)).toEqual(true); | ||
}); | ||
}); | ||
|
||
}); | ||
}); |