From 7715e5130b506ede1ae59296203076d75bffd7e9 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Wed, 16 Dec 2015 14:22:17 -0800 Subject: [PATCH] Make terminology consistent with gl native --- js/render/draw_background.js | 2 +- js/render/draw_circle.js | 2 +- js/render/draw_fill.js | 6 +++--- js/render/draw_line.js | 2 +- js/render/draw_raster.js | 2 +- js/render/draw_symbol.js | 2 +- js/render/painter.js | 12 ++++++------ 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/js/render/draw_background.js b/js/render/draw_background.js index 635122d5187..d5cc4bc89d4 100644 --- a/js/render/draw_background.js +++ b/js/render/draw_background.js @@ -16,7 +16,7 @@ function drawBackground(painter, source, layer) { var imagePosA = image ? painter.spriteAtlas.getPosition(image.from, true) : null; var imagePosB = image ? painter.spriteAtlas.getPosition(image.to, true) : null; - painter.setSublayer(0); + painter.setDepthSublayer(0); if (imagePosA && imagePosB) { if (painter.isOpaquePass) return; diff --git a/js/render/draw_circle.js b/js/render/draw_circle.js index 326b0bffaea..7e104855868 100644 --- a/js/render/draw_circle.js +++ b/js/render/draw_circle.js @@ -10,7 +10,7 @@ function drawCircles(painter, source, layer, coords) { var shader = painter.circleShader; painter.gl.switchShader(shader); - painter.setSublayer(0); + painter.setDepthSublayer(0); painter.depthMask(false); // Allow circles to be drawn across boundaries, so that diff --git a/js/render/draw_fill.js b/js/render/draw_fill.js index e17ec09b366..ac3b6d56c2e 100644 --- a/js/render/draw_fill.js +++ b/js/render/draw_fill.js @@ -29,7 +29,7 @@ function draw(painter, source, layer, coords) { // If we defined a different color for the fill outline, we are // going to ignore the bits in 0x07 and just care about the global // clipping mask. - painter.setSublayer(2); + painter.setDepthSublayer(2); } else { // Otherwise, we only want to drawFill the antialiased parts that are @@ -37,7 +37,7 @@ function draw(painter, source, layer, coords) { // or stroke color is translucent. If we wouldn't clip to outside // the current shape, some pixels from the outline stroke overlapped // the (non-antialiased) fill. - painter.setSublayer(0); + painter.setDepthSublayer(0); } gl.uniform2f(painter.outlineShader.u_world, gl.drawingBufferWidth, gl.drawingBufferHeight); @@ -65,7 +65,7 @@ function drawFill(painter, source, layer, coord) { var translatedPosMatrix = painter.translatePosMatrix(posMatrix, tile, layer.paint['fill-translate'], layer.paint['fill-translate-anchor']); // Draw the stencil mask. - painter.setSublayer(1); + painter.setDepthSublayer(1); // We're only drawFilling to the first seven bits (== support a maximum of // 8 overlapping polygons in one place before we get rendering errors). diff --git a/js/render/draw_line.js b/js/render/draw_line.js index 79042b8db39..f4e87d9c30f 100644 --- a/js/render/draw_line.js +++ b/js/render/draw_line.js @@ -15,7 +15,7 @@ var mat2 = require('gl-matrix').mat2; */ module.exports = function drawLine(painter, source, layer, coords) { if (painter.isOpaquePass) return; - painter.setSublayer(0); + painter.setDepthSublayer(0); painter.depthMask(false); var hasData = false; diff --git a/js/render/draw_raster.js b/js/render/draw_raster.js index 6a48279b5ea..a125cba7b7b 100644 --- a/js/render/draw_raster.js +++ b/js/render/draw_raster.js @@ -13,7 +13,7 @@ function drawRaster(painter, source, layer, coords) { function drawRasterTile(painter, source, layer, coord) { if (painter.isOpaquePass) return; - painter.setSublayer(0); + painter.setDepthSublayer(0); var gl = painter.gl; diff --git a/js/render/draw_symbol.js b/js/render/draw_symbol.js index 1e604e72bfc..4b45a7bd3dc 100644 --- a/js/render/draw_symbol.js +++ b/js/render/draw_symbol.js @@ -24,7 +24,7 @@ function drawSymbols(painter, source, layer, coords) { gl.disable(gl.STENCIL_TEST); } - painter.setSublayer(0); + painter.setDepthSublayer(0); painter.depthMask(false); gl.disable(gl.DEPTH_TEST); diff --git a/js/render/painter.js b/js/render/painter.js index a2c9f5e73b8..d3015a3e809 100644 --- a/js/render/painter.js +++ b/js/render/painter.js @@ -25,8 +25,8 @@ function Painter(gl, transform) { // Within each layer there are 3 distinct z-planes that can be drawn to. // This is implemented using the WebGL depth buffer. - this.sublayerCount = 3; - this.sublayerDepthEpsilon = 1 / Math.pow(2, 16); + this.numSublayers = 3; + this.depthEpsilon = 1 / Math.pow(2, 16); } /* @@ -278,7 +278,7 @@ Painter.prototype.render = function(style, options) { this.clearColor(); this.clearDepth(); - this.sublayerDepthRangeSize = (style._order.length + 2) * this.sublayerCount * this.sublayerDepthEpsilon; + this.depthRange = (style._order.length + 2) * this.numSublayers * this.depthEpsilon; this.renderPass({isOpaquePass: true}); this.renderPass({isOpaquePass: false}); @@ -356,9 +356,9 @@ Painter.prototype.drawStencilBuffer = function() { gl.blendFunc(gl.ONE_MINUS_DST_ALPHA, gl.ONE); }; -Painter.prototype.setSublayer = function(n) { - var farDepth = 1 - ((1 + this.currentLayer) * this.sublayerCount + n) * this.sublayerDepthEpsilon; - var nearDepth = farDepth - 1 + this.sublayerDepthRangeSize; +Painter.prototype.setDepthSublayer = function(n) { + var farDepth = 1 - ((1 + this.currentLayer) * this.numSublayers + n) * this.depthEpsilon; + var nearDepth = farDepth - 1 + this.depthRange; this.gl.depthRange(nearDepth, farDepth); };