From 698059d9e2c3616e6586c77a9bf0694591f8117a Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 9 Apr 2018 16:07:00 -0400 Subject: [PATCH] Ensure that GL polygons are built once before their strokes. When we build a webgl polygon we attach two vgl actors, one for the polygon and one for the stroke (lines). Whichever actor gets attached first is drawn first. We always want to draw the fill before the stroke, but for efficiency it can be deferred an animation frame when there are updates. The first time this is rendered, don't allow such a delay. This change ensures that the fill actor is added before the stroke actor. --- src/gl/polygonFeature.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gl/polygonFeature.js b/src/gl/polygonFeature.js index 060f21809a..c3af384ae0 100644 --- a/src/gl/polygonFeature.js +++ b/src/gl/polygonFeature.js @@ -38,6 +38,7 @@ var gl_polygonFeature = function (arg) { m_geometry, s_init = this._init, s_update = this._update, + m_builtOnce, m_updateAnimFrameRef; function createVertexShader() { @@ -325,6 +326,7 @@ var gl_polygonFeature = function (arg) { if (!m_this.renderer().contextRenderer().hasActor(m_actor)) { m_this.renderer().contextRenderer().addActor(m_actor); + m_builtOnce = true; } m_this.buildTime().modified(); }; @@ -332,10 +334,12 @@ var gl_polygonFeature = function (arg) { /** * Update. * - * @override + * @param {object} [opts] Update options. + * @param {boolean} [opts.mayDelay] If truthy, wait until the next animation + * frame for the update. */ this._update = function (opts) { - if (opts && opts.mayDelay) { + if (opts && opts.mayDelay && m_builtOnce) { m_updateAnimFrameRef = m_this.layer().map().scheduleAnimationFrame(m_this._update); return; }