Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren Budorick committed Dec 7, 2017
1 parent 6280f13 commit 3a5a0aa
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 34 deletions.
17 changes: 7 additions & 10 deletions src/render/draw_fill_extrusion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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;

Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/render/draw_hillshade.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 0 additions & 18 deletions src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -62,7 +61,6 @@ class Painter {
context: Context;
transform: Transform;
_tileTextures: { [number]: Array<Texture> };
_tileFramebuffers: { [number]: Array<Framebuffer> };
numSublayers: number;
depthEpsilon: number;
lineWidthRange: [number, number];
Expand Down Expand Up @@ -99,7 +97,6 @@ class Painter {
this.context = new Context(gl);
this.transform = transform;
this._tileTextures = {};
this._tileFramebuffers = {};

this.setup();

Expand Down Expand Up @@ -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]));
}
Expand Down
4 changes: 2 additions & 2 deletions src/source/raster_dem_tile_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/style/style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -42,7 +41,6 @@ class StyleLayer extends Evented {
_transitioningPaint: Transitioning<any>;
+paint: mixed;

viewportFrame: ?Framebuffer;
_featureFilter: FeatureFilter;

+queryRadius: (bucket: Bucket) => number;
Expand Down Expand Up @@ -201,7 +199,7 @@ class StyleLayer extends Evented {
return false;
}

resize() { // eslint-disable-line
resize() {
// noop
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/style/style_layer/fill_extrusion_style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<PaintProps>;
_transitioningPaint: Transitioning<PaintProps>;
paint: PossiblyEvaluated<PaintProps>;
viewportFrame: ?Framebuffer;

constructor(layer: LayerSpecification) {
super(layer, properties);
Expand Down

0 comments on commit 3a5a0aa

Please sign in to comment.