From 4b08987e5348c9f29c0da6970a9e647ab6bc7473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sun, 11 Feb 2018 18:14:55 +0100 Subject: [PATCH] Remove private statics from webgl related modules --- src/ol/render/webgl/TextureReplay.js | 4 ++-- src/ol/renderer/webgl/ImageLayer.js | 4 ++-- src/ol/webgl/Context.js | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ol/render/webgl/TextureReplay.js b/src/ol/render/webgl/TextureReplay.js index daa40fbe0c..d1ff6080be 100644 --- a/src/ol/render/webgl/TextureReplay.js +++ b/src/ol/render/webgl/TextureReplay.js @@ -8,7 +8,7 @@ import {fragment, vertex} from '../webgl/texturereplay/defaultshader.js'; import Locations from '../webgl/texturereplay/defaultshader/Locations.js'; import WebGLReplay from '../webgl/Replay.js'; import _ol_webgl_ from '../../webgl.js'; -import WebGLContext from '../../webgl/Context.js'; +import {createTexture} from '../../webgl/Context.js'; /** * @constructor @@ -257,7 +257,7 @@ WebGLTextureReplay.prototype.createTextures = function(textures, images, texture if (uid in texturePerImage) { texture = texturePerImage[uid]; } else { - texture = WebGLContext.createTexture( + texture = createTexture( gl, image, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE); texturePerImage[uid] = texture; } diff --git a/src/ol/renderer/webgl/ImageLayer.js b/src/ol/renderer/webgl/ImageLayer.js index 21d342a6ad..ad7c40df41 100644 --- a/src/ol/renderer/webgl/ImageLayer.js +++ b/src/ol/renderer/webgl/ImageLayer.js @@ -12,7 +12,7 @@ import RendererType from '../Type.js'; import WebGLLayerRenderer from '../webgl/Layer.js'; import _ol_transform_ from '../../transform.js'; import _ol_webgl_ from '../../webgl.js'; -import WebGLContext from '../../webgl/Context.js'; +import {createTexture} from '../../webgl/Context.js'; /** * @constructor @@ -88,7 +88,7 @@ WebGLImageLayerRenderer.prototype.createTexture_ = function(image) { const imageElement = image.getImage(); const gl = this.mapRenderer.getGL(); - return WebGLContext.createTexture( + return createTexture( gl, imageElement, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE); }; diff --git a/src/ol/webgl/Context.js b/src/ol/webgl/Context.js index 018d4cf7a1..3f71073f46 100644 --- a/src/ol/webgl/Context.js +++ b/src/ol/webgl/Context.js @@ -314,9 +314,8 @@ WebGLContext.prototype.useProgram = function(program) { * @param {number=} opt_wrapS wrapS. * @param {number=} opt_wrapT wrapT. * @return {WebGLTexture} The texture. - * @private */ -WebGLContext.createTexture_ = function(gl, opt_wrapS, opt_wrapT) { +function createTextureInternal(gl, opt_wrapS, opt_wrapT) { const texture = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); @@ -332,7 +331,7 @@ WebGLContext.createTexture_ = function(gl, opt_wrapS, opt_wrapT) { } return texture; -}; +} /** @@ -343,15 +342,15 @@ WebGLContext.createTexture_ = function(gl, opt_wrapS, opt_wrapT) { * @param {number=} opt_wrapT wrapT. * @return {WebGLTexture} The texture. */ -WebGLContext.createEmptyTexture = function( +export function createEmptyTexture( gl, width, height, opt_wrapS, opt_wrapT) { - const texture = WebGLContext.createTexture_(gl, opt_wrapS, opt_wrapT); + const texture = createTextureInternal(gl, opt_wrapS, opt_wrapT); gl.texImage2D( gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); return texture; -}; +} /** @@ -361,11 +360,12 @@ WebGLContext.createEmptyTexture = function( * @param {number=} opt_wrapT wrapT. * @return {WebGLTexture} The texture. */ -WebGLContext.createTexture = function(gl, image, opt_wrapS, opt_wrapT) { - const texture = WebGLContext.createTexture_(gl, opt_wrapS, opt_wrapT); +export function createTexture(gl, image, opt_wrapS, opt_wrapT) { + const texture = createTextureInternal(gl, opt_wrapS, opt_wrapT); gl.texImage2D( gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); return texture; -}; +} + export default WebGLContext;