Not using requestAnimationFrame
Using the Timeline tab of the Chrome Developer Tools, no significant difference of Paint events can be observed when requestAnimationFrame is used. So I agree with @elemoine that there is no need to introduce asynchronous behavior here.
This commit is contained in:
@@ -379,17 +379,9 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
|||||||
onImageLoad: function() {
|
onImageLoad: function() {
|
||||||
var img = this.imgDiv;
|
var img = this.imgDiv;
|
||||||
OpenLayers.Event.stopObservingElement(img);
|
OpenLayers.Event.stopObservingElement(img);
|
||||||
|
img.style.visibility = 'inherit';
|
||||||
OpenLayers.Animation.requestFrame(OpenLayers.Function.bind(function() {
|
img.style.opacity = this.layer.opacity;
|
||||||
// make sure we are not destroyed and not being reused for a
|
this.events.triggerEvent("loadend");
|
||||||
// different image
|
|
||||||
if (this.imgDiv === img) {
|
|
||||||
img.style.visibility = 'inherit';
|
|
||||||
img.style.opacity = this.layer.opacity;
|
|
||||||
this.events.triggerEvent("loadend");
|
|
||||||
}
|
|
||||||
}, this));
|
|
||||||
|
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
this.canvasContext = null;
|
this.canvasContext = null;
|
||||||
|
|
||||||
|
|||||||
@@ -770,9 +770,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_setOpacity(t) {
|
function test_setOpacity(t) {
|
||||||
var origRequestFrame = OpenLayers.Animation.requestFrame;
|
|
||||||
OpenLayers.Animation.requestFrame = function(fn) { fn(); };
|
|
||||||
|
|
||||||
t.plan(5);
|
t.plan(5);
|
||||||
|
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
@@ -801,8 +798,6 @@
|
|||||||
t.eq(parseFloat(tile.imgDiv.style.opacity), 0.2, "tile opacity is correc");
|
t.eq(parseFloat(tile.imgDiv.style.opacity), 0.2, "tile opacity is correc");
|
||||||
|
|
||||||
map.destroy();
|
map.destroy();
|
||||||
|
|
||||||
OpenLayers.Animation.requestFrame = origRequestFrame
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_getServerResolution(t) {
|
function test_getServerResolution(t) {
|
||||||
@@ -1313,9 +1308,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_delayed_back_buffer_removal(t) {
|
function test_delayed_back_buffer_removal(t) {
|
||||||
var origRequestFrame = OpenLayers.Animation.requestFrame;
|
|
||||||
OpenLayers.Animation.requestFrame = function(fn) { fn(); };
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Test that the delaying of the back buffer removal behaves
|
// Test that the delaying of the back buffer removal behaves
|
||||||
// as expected.
|
// as expected.
|
||||||
@@ -1359,8 +1351,6 @@
|
|||||||
// tear down
|
// tear down
|
||||||
|
|
||||||
map.destroy();
|
map.destroy();
|
||||||
|
|
||||||
OpenLayers.Animation.requestFrame = origRequestFrame;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_getGridData(t) {
|
function test_getGridData(t) {
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// turn off tile queue, so we can check img urls in tests
|
// turn off tile queue, so we can check img urls in tests
|
||||||
delete OpenLayers.Layer.Grid.prototype.queueTileDraw;
|
delete OpenLayers.Layer.Grid.prototype.queueTileDraw;
|
||||||
// turn off animation, so we don't need to test asynchronously
|
|
||||||
OpenLayers.Animation.requestFrame = function(fn) { fn(); };
|
|
||||||
|
|
||||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||||
var tile;
|
var tile;
|
||||||
|
|||||||
Reference in New Issue
Block a user