@@ -15,7 +15,7 @@ import Units from '../../proj/Units.js';
|
||||
import ReplayType from '../../render/ReplayType.js';
|
||||
import {labelCache, rotateAtOffset} from '../../render/canvas.js';
|
||||
import CanvasReplayGroup from '../../render/canvas/ReplayGroup.js';
|
||||
import _ol_render_replay_ from '../../render/replay.js';
|
||||
import {ORDER} from '../../render/replay.js';
|
||||
import RendererType from '../Type.js';
|
||||
import CanvasTileLayerRenderer from '../canvas/TileLayer.js';
|
||||
import {getSquaredTolerance as getSquaredRenderTolerance, renderFeature} from '../vector.js';
|
||||
@@ -44,7 +44,7 @@ const IMAGE_REPLAYS = {
|
||||
const VECTOR_REPLAYS = {
|
||||
'image': [ReplayType.DEFAULT],
|
||||
'hybrid': [ReplayType.IMAGE, ReplayType.TEXT, ReplayType.DEFAULT],
|
||||
'vector': _ol_render_replay_.ORDER
|
||||
'vector': ORDER
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
invert as invertTransform,
|
||||
multiply as multiplyTransform
|
||||
} from '../../transform.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import {CLAMP_TO_EDGE} from '../../webgl.js';
|
||||
import {createTexture} from '../../webgl/Context.js';
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ WebGLImageLayerRenderer.prototype.createTexture_ = function(image) {
|
||||
const gl = this.mapRenderer.getGL();
|
||||
|
||||
return createTexture(
|
||||
gl, imageElement, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE);
|
||||
gl, imageElement, CLAMP_TO_EDGE, CLAMP_TO_EDGE);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ import {fragment, vertex} from '../webgl/defaultmapshader.js';
|
||||
import Locations from '../webgl/defaultmapshader/Locations.js';
|
||||
import {create as createTransform} from '../../transform.js';
|
||||
import {create, fromTransform} from '../../vec/mat4.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import {ARRAY_BUFFER, FRAMEBUFFER, FLOAT, TEXTURE_2D,
|
||||
TRIANGLE_STRIP, COLOR_ATTACHMENT0} from '../../webgl.js';
|
||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||
import {createEmptyTexture} from '../../webgl/Context.js';
|
||||
|
||||
@@ -120,16 +121,16 @@ WebGLLayerRenderer.prototype.bindFramebuffer = function(frameState, framebufferD
|
||||
gl, framebufferDimension, framebufferDimension);
|
||||
|
||||
const framebuffer = gl.createFramebuffer();
|
||||
gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, framebuffer);
|
||||
gl.framebufferTexture2D(_ol_webgl_.FRAMEBUFFER,
|
||||
_ol_webgl_.COLOR_ATTACHMENT0, _ol_webgl_.TEXTURE_2D, texture, 0);
|
||||
gl.bindFramebuffer(FRAMEBUFFER, framebuffer);
|
||||
gl.framebufferTexture2D(FRAMEBUFFER,
|
||||
COLOR_ATTACHMENT0, TEXTURE_2D, texture, 0);
|
||||
|
||||
this.texture = texture;
|
||||
this.framebuffer = framebuffer;
|
||||
this.framebufferDimension = framebufferDimension;
|
||||
|
||||
} else {
|
||||
gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, this.framebuffer);
|
||||
gl.bindFramebuffer(FRAMEBUFFER, this.framebuffer);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -144,7 +145,7 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
|
||||
|
||||
this.dispatchComposeEvent_(RenderEventType.PRECOMPOSE, context, frameState);
|
||||
|
||||
context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.arrayBuffer_);
|
||||
context.bindBuffer(ARRAY_BUFFER, this.arrayBuffer_);
|
||||
|
||||
const gl = context.getGL();
|
||||
|
||||
@@ -161,10 +162,10 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
|
||||
if (context.useProgram(program)) {
|
||||
gl.enableVertexAttribArray(locations.a_position);
|
||||
gl.vertexAttribPointer(
|
||||
locations.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0);
|
||||
locations.a_position, 2, FLOAT, false, 16, 0);
|
||||
gl.enableVertexAttribArray(locations.a_texCoord);
|
||||
gl.vertexAttribPointer(
|
||||
locations.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8);
|
||||
locations.a_texCoord, 2, FLOAT, false, 16, 8);
|
||||
gl.uniform1i(locations.u_texture, 0);
|
||||
}
|
||||
|
||||
@@ -173,8 +174,8 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
|
||||
gl.uniformMatrix4fv(locations.u_projectionMatrix, false,
|
||||
fromTransform(this.tmpMat4_, this.getProjectionMatrix()));
|
||||
gl.uniform1f(locations.u_opacity, layerState.opacity);
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, this.getTexture());
|
||||
gl.drawArrays(_ol_webgl_.TRIANGLE_STRIP, 0, 4);
|
||||
gl.bindTexture(TEXTURE_2D, this.getTexture());
|
||||
gl.drawArrays(TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
this.dispatchComposeEvent_(RenderEventType.POSTCOMPOSE, context, frameState);
|
||||
};
|
||||
|
||||
@@ -17,7 +17,10 @@ import RendererType from '../Type.js';
|
||||
import SourceState from '../../source/State.js';
|
||||
import LRUCache from '../../structs/LRUCache.js';
|
||||
import PriorityQueue from '../../structs/PriorityQueue.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import {BLEND, CLAMP_TO_EDGE, COLOR_BUFFER_BIT, CULL_FACE, DEPTH_TEST, FRAMEBUFFER,
|
||||
getContext, LINEAR, ONE, ONE_MINUS_SRC_ALPHA, RGBA, SCISSOR_TEST, SRC_ALPHA,
|
||||
STENCIL_TEST, TEXTURE0, TEXTURE_2D, TEXTURE_MAG_FILTER, TEXTURE_MIN_FILTER,
|
||||
TEXTURE_WRAP_S, TEXTURE_WRAP_T, UNSIGNED_BYTE} from '../../webgl.js';
|
||||
import WebGLContext from '../../webgl/Context.js';
|
||||
import ContextEventType from '../../webgl/ContextEventType.js';
|
||||
|
||||
@@ -79,7 +82,7 @@ const WebGLMapRenderer = function(container, map) {
|
||||
* @private
|
||||
* @type {WebGLRenderingContext}
|
||||
*/
|
||||
this.gl_ = _ol_webgl_.getContext(this.canvas_, {
|
||||
this.gl_ = getContext(this.canvas_, {
|
||||
antialias: true,
|
||||
depth: true,
|
||||
failIfMajorPerformanceCaveat: true,
|
||||
@@ -152,7 +155,7 @@ const WebGLMapRenderer = function(container, map) {
|
||||
const tileSize = /** @type {ol.Size} */ (element[3]);
|
||||
const tileGutter = /** @type {number} */ (element[4]);
|
||||
this.bindTileTexture(
|
||||
tile, tileSize, tileGutter, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR);
|
||||
tile, tileSize, tileGutter, LINEAR, LINEAR);
|
||||
}
|
||||
return false;
|
||||
}.bind(this);
|
||||
@@ -203,20 +206,20 @@ WebGLMapRenderer.prototype.bindTileTexture = function(tile, tileSize, tileGutter
|
||||
const tileKey = tile.getKey();
|
||||
if (this.textureCache_.containsKey(tileKey)) {
|
||||
const textureCacheEntry = this.textureCache_.get(tileKey);
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, textureCacheEntry.texture);
|
||||
gl.bindTexture(TEXTURE_2D, textureCacheEntry.texture);
|
||||
if (textureCacheEntry.magFilter != magFilter) {
|
||||
gl.texParameteri(
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter);
|
||||
TEXTURE_2D, TEXTURE_MAG_FILTER, magFilter);
|
||||
textureCacheEntry.magFilter = magFilter;
|
||||
}
|
||||
if (textureCacheEntry.minFilter != minFilter) {
|
||||
gl.texParameteri(
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter);
|
||||
TEXTURE_2D, TEXTURE_MIN_FILTER, minFilter);
|
||||
textureCacheEntry.minFilter = minFilter;
|
||||
}
|
||||
} else {
|
||||
const texture = gl.createTexture();
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, texture);
|
||||
gl.bindTexture(TEXTURE_2D, texture);
|
||||
if (tileGutter > 0) {
|
||||
const clipTileCanvas = this.clipTileContext_.canvas;
|
||||
const clipTileContext = this.clipTileContext_;
|
||||
@@ -231,22 +234,22 @@ WebGLMapRenderer.prototype.bindTileTexture = function(tile, tileSize, tileGutter
|
||||
}
|
||||
clipTileContext.drawImage(tile.getImage(), tileGutter, tileGutter,
|
||||
tileSize[0], tileSize[1], 0, 0, tileSize[0], tileSize[1]);
|
||||
gl.texImage2D(_ol_webgl_.TEXTURE_2D, 0,
|
||||
_ol_webgl_.RGBA, _ol_webgl_.RGBA,
|
||||
_ol_webgl_.UNSIGNED_BYTE, clipTileCanvas);
|
||||
gl.texImage2D(TEXTURE_2D, 0,
|
||||
RGBA, RGBA,
|
||||
UNSIGNED_BYTE, clipTileCanvas);
|
||||
} else {
|
||||
gl.texImage2D(_ol_webgl_.TEXTURE_2D, 0,
|
||||
_ol_webgl_.RGBA, _ol_webgl_.RGBA,
|
||||
_ol_webgl_.UNSIGNED_BYTE, tile.getImage());
|
||||
gl.texImage2D(TEXTURE_2D, 0,
|
||||
RGBA, RGBA,
|
||||
UNSIGNED_BYTE, tile.getImage());
|
||||
}
|
||||
gl.texParameteri(
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter);
|
||||
TEXTURE_2D, TEXTURE_MAG_FILTER, magFilter);
|
||||
gl.texParameteri(
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter);
|
||||
gl.texParameteri(_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_S,
|
||||
_ol_webgl_.CLAMP_TO_EDGE);
|
||||
gl.texParameteri(_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_T,
|
||||
_ol_webgl_.CLAMP_TO_EDGE);
|
||||
TEXTURE_2D, TEXTURE_MIN_FILTER, minFilter);
|
||||
gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S,
|
||||
CLAMP_TO_EDGE);
|
||||
gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T,
|
||||
CLAMP_TO_EDGE);
|
||||
this.textureCache_.set(tileKey, {
|
||||
texture: texture,
|
||||
magFilter: magFilter,
|
||||
@@ -394,14 +397,14 @@ WebGLMapRenderer.prototype.handleWebGLContextRestored = function() {
|
||||
*/
|
||||
WebGLMapRenderer.prototype.initializeGL_ = function() {
|
||||
const gl = this.gl_;
|
||||
gl.activeTexture(_ol_webgl_.TEXTURE0);
|
||||
gl.activeTexture(TEXTURE0);
|
||||
gl.blendFuncSeparate(
|
||||
_ol_webgl_.SRC_ALPHA, _ol_webgl_.ONE_MINUS_SRC_ALPHA,
|
||||
_ol_webgl_.ONE, _ol_webgl_.ONE_MINUS_SRC_ALPHA);
|
||||
gl.disable(_ol_webgl_.CULL_FACE);
|
||||
gl.disable(_ol_webgl_.DEPTH_TEST);
|
||||
gl.disable(_ol_webgl_.SCISSOR_TEST);
|
||||
gl.disable(_ol_webgl_.STENCIL_TEST);
|
||||
SRC_ALPHA, ONE_MINUS_SRC_ALPHA,
|
||||
ONE, ONE_MINUS_SRC_ALPHA);
|
||||
gl.disable(CULL_FACE);
|
||||
gl.disable(DEPTH_TEST);
|
||||
gl.disable(SCISSOR_TEST);
|
||||
gl.disable(STENCIL_TEST);
|
||||
};
|
||||
|
||||
|
||||
@@ -466,11 +469,11 @@ WebGLMapRenderer.prototype.renderFrame = function(frameState) {
|
||||
this.canvas_.height = height;
|
||||
}
|
||||
|
||||
gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, null);
|
||||
gl.bindFramebuffer(FRAMEBUFFER, null);
|
||||
|
||||
gl.clearColor(0, 0, 0, 0);
|
||||
gl.clear(_ol_webgl_.COLOR_BUFFER_BIT);
|
||||
gl.enable(_ol_webgl_.BLEND);
|
||||
gl.clear(COLOR_BUFFER_BIT);
|
||||
gl.enable(BLEND);
|
||||
gl.viewport(0, 0, this.canvas_.width, this.canvas_.height);
|
||||
|
||||
for (i = 0, ii = layerStatesToDraw.length; i < ii; ++i) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
translate as translateTransform,
|
||||
apply as applyTransform
|
||||
} from '../../transform.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import {COLOR_BUFFER_BIT, BLEND, ARRAY_BUFFER, FLOAT, LINEAR, TRIANGLE_STRIP} from '../../webgl.js';
|
||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||
|
||||
/**
|
||||
@@ -223,8 +223,8 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
||||
gl.viewport(0, 0, framebufferDimension, framebufferDimension);
|
||||
|
||||
gl.clearColor(0, 0, 0, 0);
|
||||
gl.clear(_ol_webgl_.COLOR_BUFFER_BIT);
|
||||
gl.disable(_ol_webgl_.BLEND);
|
||||
gl.clear(COLOR_BUFFER_BIT);
|
||||
gl.disable(BLEND);
|
||||
|
||||
const program = context.getProgram(this.fragmentShader_, this.vertexShader_);
|
||||
context.useProgram(program);
|
||||
@@ -232,13 +232,13 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
||||
this.locations_ = new Locations(gl, program);
|
||||
}
|
||||
|
||||
context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.renderArrayBuffer_);
|
||||
context.bindBuffer(ARRAY_BUFFER, this.renderArrayBuffer_);
|
||||
gl.enableVertexAttribArray(this.locations_.a_position);
|
||||
gl.vertexAttribPointer(
|
||||
this.locations_.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0);
|
||||
this.locations_.a_position, 2, FLOAT, false, 16, 0);
|
||||
gl.enableVertexAttribArray(this.locations_.a_texCoord);
|
||||
gl.vertexAttribPointer(
|
||||
this.locations_.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8);
|
||||
this.locations_.a_texCoord, 2, FLOAT, false, 16, 8);
|
||||
gl.uniform1i(this.locations_.u_texture, 0);
|
||||
|
||||
/**
|
||||
@@ -320,8 +320,8 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
||||
framebufferExtentDimension - 1;
|
||||
gl.uniform4fv(this.locations_.u_tileOffset, u_tileOffset);
|
||||
mapRenderer.bindTileTexture(tile, tilePixelSize,
|
||||
tileGutter * pixelRatio, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR);
|
||||
gl.drawArrays(_ol_webgl_.TRIANGLE_STRIP, 0, 4);
|
||||
tileGutter * pixelRatio, LINEAR, LINEAR);
|
||||
gl.drawArrays(TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user