From 3a5a0aa833f003aa7039775ba0f22adf13ea2128 Mon Sep 17 00:00:00 2001 From: Lauren Budorick Date: Wed, 6 Dec 2017 17:31:52 -0800 Subject: [PATCH] Address review comments --- src/render/draw_fill_extrusion.js | 17 +++++++---------- src/render/draw_hillshade.js | 1 - src/render/painter.js | 18 ------------------ src/source/raster_dem_tile_source.js | 4 ++-- src/style/style_layer.js | 4 +--- .../style_layer/fill_extrusion_style_layer.js | 2 ++ 6 files changed, 12 insertions(+), 34 deletions(-) diff --git a/src/render/draw_fill_extrusion.js b/src/render/draw_fill_extrusion.js index ff762720b44..f52c02244f7 100644 --- a/src/render/draw_fill_extrusion.js +++ b/src/render/draw_fill_extrusion.js @@ -22,15 +22,7 @@ function draw(painter: Painter, source: SourceCache, layer: FillExtrusionStyleLa } if (painter.renderPass === 'offscreen') { - const context = painter.context; - - setupFramebuffer(painter, layer); - - context.stencilTest.set(false); - context.depthTest.set(true); - - context.clear({ color: Color.transparent }); - context.depthMask.set(true); + drawToExtrusionFramebuffer(painter, layer); for (let i = 0; i < coords.length; i++) { drawExtrusion(painter, source, layer, coords[i]); @@ -40,7 +32,7 @@ function draw(painter: Painter, source: SourceCache, layer: FillExtrusionStyleLa } } -function setupFramebuffer(painter, layer) { +function drawToExtrusionFramebuffer(painter, layer) { const context = painter.context; const gl = context.gl; @@ -66,6 +58,11 @@ function setupFramebuffer(painter, layer) { painter.depthRboNeedsClear = false; } + context.stencilTest.set(false); + context.depthTest.set(true); + + context.clear({ color: Color.transparent }); + context.depthMask.set(true); } function drawExtrusionTexture(painter, layer) { diff --git a/src/render/draw_hillshade.js b/src/render/draw_hillshade.js index 2b2e562ee77..170fe45bdf4 100644 --- a/src/render/draw_hillshade.js +++ b/src/render/draw_hillshade.js @@ -128,7 +128,6 @@ function prepareHillshade(painter, tile) { context.activeTexture.set(gl.TEXTURE0); - if (!tile.fbo) tile.fbo = painter.getTileFramebuffer(tile.tileSize); let fbo = tile.fbo; if (!fbo) { diff --git a/src/render/painter.js b/src/render/painter.js index af29c8f5837..ea06cc2d1ae 100644 --- a/src/render/painter.js +++ b/src/render/painter.js @@ -40,7 +40,6 @@ import type LineAtlas from './line_atlas'; import type ImageManager from './image_manager'; import type GlyphManager from './glyph_manager'; import type VertexBuffer from '../gl/vertex_buffer'; -import type Framebuffer from '../gl/framebuffer'; export type RenderPass = 'offscreen' | 'opaque' | 'translucent'; @@ -62,7 +61,6 @@ class Painter { context: Context; transform: Transform; _tileTextures: { [number]: Array }; - _tileFramebuffers: { [number]: Array }; numSublayers: number; depthEpsilon: number; lineWidthRange: [number, number]; @@ -99,7 +97,6 @@ class Painter { this.context = new Context(gl); this.transform = transform; this._tileTextures = {}; - this._tileFramebuffers = {}; this.setup(); @@ -480,21 +477,6 @@ class Painter { return textures && textures.length > 0 ? textures.pop() : null; } - saveTileFramebuffer(fbo: Framebuffer) { - const framebuffers = this._tileFramebuffers[fbo.width]; - - if (!framebuffers) { - this._tileFramebuffers[fbo.width] = [fbo]; - } else { - framebuffers.push(fbo); - } - } - - getTileFramebuffer(size: number) { - const framebuffers = this._tileFramebuffers[size]; - return framebuffers && framebuffers.length > 0 ? framebuffers.pop() : null; - } - lineWidth(width: number) { this.context.lineWidth.set(util.clamp(width, this.lineWidthRange[0], this.lineWidthRange[1])); } diff --git a/src/source/raster_dem_tile_source.js b/src/source/raster_dem_tile_source.js index 7d31c3ab836..225e73faa4f 100644 --- a/src/source/raster_dem_tile_source.js +++ b/src/source/raster_dem_tile_source.js @@ -117,8 +117,8 @@ class RasterDEMTileSource extends RasterTileSource implements Source { unloadTile(tile: Tile) { if (tile.demTexture) this.map.painter.saveTileTexture(tile.demTexture); if (tile.fbo) { - this.map.painter.saveTileFramebuffer(tile.fbo); - tile.fbo = null; + tile.fbo.destroy(); + delete tile.fbo; } if (tile.dem) delete tile.dem; delete tile.neighboringTiles; diff --git a/src/style/style_layer.js b/src/style/style_layer.js index 40367d8a59d..fa794c325f2 100644 --- a/src/style/style_layer.js +++ b/src/style/style_layer.js @@ -15,7 +15,6 @@ const { import type {Bucket} from '../data/bucket'; import type Point from '@mapbox/point-geometry'; -import type Framebuffer from '../gl/framebuffer'; import type {FeatureFilter} from '../style-spec/feature_filter'; import type {TransitionParameters} from './properties'; import type EvaluationParameters from './evaluation_parameters'; @@ -42,7 +41,6 @@ class StyleLayer extends Evented { _transitioningPaint: Transitioning; +paint: mixed; - viewportFrame: ?Framebuffer; _featureFilter: FeatureFilter; +queryRadius: (bucket: Bucket) => number; @@ -201,7 +199,7 @@ class StyleLayer extends Evented { return false; } - resize() { // eslint-disable-line + resize() { // noop } } diff --git a/src/style/style_layer/fill_extrusion_style_layer.js b/src/style/style_layer/fill_extrusion_style_layer.js index 5d37f516ecc..b31c8ac5b64 100644 --- a/src/style/style_layer/fill_extrusion_style_layer.js +++ b/src/style/style_layer/fill_extrusion_style_layer.js @@ -15,11 +15,13 @@ const { import type {BucketParameters} from '../../data/bucket'; import type Point from '@mapbox/point-geometry'; import type {PaintProps} from './fill_extrusion_style_layer_properties'; +import type Framebuffer from '../../gl/framebuffer'; class FillExtrusionStyleLayer extends StyleLayer { _transitionablePaint: Transitionable; _transitioningPaint: Transitioning; paint: PossiblyEvaluated; + viewportFrame: ?Framebuffer; constructor(layer: LayerSpecification) { super(layer, properties);