Conditionally render tiles to a separate tile canvas
Because clip geometries are anti-aliased in most browsers, there will be tiny gaps between tiles. If tiles are rendered to a tile canvas which is then drawn to the map canvas upon composition, these gaps can be avoided. For rotated views, it is stil necessary to clip the tile, but in this case a 1-pixel buffer is used. This change also brings a huge performance improvement for panning, because the fully rendered tiles can be reused. Because of the added cost of using drawImage in addition to replaying the tile replay group, we fall back to directly drawing to the map canvas when the tile canvas would be too large, or during interaction/animation when resolution or rotation change.
This commit is contained in:
@@ -4,6 +4,7 @@ goog.require('ol.Tile');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileLoadFunctionType');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.proj.Projection');
|
||||
|
||||
|
||||
@@ -33,6 +34,12 @@ ol.VectorTile =
|
||||
|
||||
goog.base(this, tileCoord, state);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
this.context_ = ol.dom.createCanvasContext2D();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.format.Feature}
|
||||
@@ -84,6 +91,14 @@ ol.VectorTile =
|
||||
goog.inherits(ol.VectorTile, ol.Tile);
|
||||
|
||||
|
||||
/**
|
||||
* @return {CanvasRenderingContext2D}
|
||||
*/
|
||||
ol.VectorTile.prototype.getContext = function() {
|
||||
return this.context_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user