diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2015-11-05 19:27:38 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2015-11-06 13:36:00 +0200 |
commit | 179917ccb670d62125754a6b519aa3c89f16d25f (patch) | |
tree | 13cb1bead0186c47960bcae221cd96bfbab5fb63 | |
parent | 69564cc886f37cf3f97145d199bd0bbca8b16523 (diff) | |
download | qtlocation-mapboxgl-179917ccb670d62125754a6b519aa3c89f16d25f.tar.gz |
[core] Replace GL config save/restore with setDirty mechanism
-rw-r--r-- | src/mbgl/renderer/gl_config.hpp | 69 | ||||
-rw-r--r-- | src/mbgl/renderer/painter.cpp | 6 |
2 files changed, 25 insertions, 50 deletions
diff --git a/src/mbgl/renderer/gl_config.hpp b/src/mbgl/renderer/gl_config.hpp index df372d49ea..b110f071fd 100644 --- a/src/mbgl/renderer/gl_config.hpp +++ b/src/mbgl/renderer/gl_config.hpp @@ -14,27 +14,26 @@ template <typename T> class Value { public: inline void operator=(const typename T::Type& value) { - if (current != value) { + if (dirty || current != value) { + dirty = false; current = value; T::Set(current); } } inline void reset() { + dirty = true; current = T::Default; T::Set(current); } - inline void save() { - current = T::Get(); - } - - inline void restore() { - T::Set(current); + inline void setDirty() { + dirty = true; } private: typename T::Type current = T::Default; + bool dirty = false; }; struct ClearDepth { @@ -305,44 +304,24 @@ public: viewport.reset(); } - void restore() { - stencilFunc.restore(); - stencilMask.restore(); - stencilTest.restore(); - stencilOp.restore(); - depthRange.restore(); - depthMask.restore(); - depthTest.restore(); - depthFunc.restore(); - blend.restore(); - blendFunc.restore(); - colorMask.restore(); - clearDepth.restore(); - clearColor.restore(); - clearStencil.restore(); - program.restore(); - lineWidth.restore(); - viewport.restore(); - } - - void save() { - stencilFunc.save(); - stencilMask.save(); - stencilTest.save(); - stencilOp.save(); - depthRange.save(); - depthMask.save(); - depthTest.save(); - depthFunc.save(); - blend.save(); - blendFunc.save(); - colorMask.save(); - clearDepth.save(); - clearColor.save(); - clearStencil.save(); - program.save(); - lineWidth.save(); - viewport.save(); + void setDirty() { + stencilFunc.setDirty(); + stencilMask.setDirty(); + stencilTest.setDirty(); + stencilOp.setDirty(); + depthRange.setDirty(); + depthMask.setDirty(); + depthTest.setDirty(); + depthFunc.setDirty(); + blend.setDirty(); + blendFunc.setDirty(); + colorMask.setDirty(); + clearDepth.setDirty(); + clearColor.setDirty(); + clearStencil.setDirty(); + program.setDirty(); + lineWidth.setDirty(); + viewport.setDirty(); } Value<StencilFunc> stencilFunc; diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index 788e290f63..a0096eb528 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -128,10 +128,6 @@ void Painter::render(const Style& style, TransformState state_, const FrameData& state = state_; frame = frame_; - if (data.contextMode == GLContextMode::Shared) { - config.restore(); - } - glyphAtlas = style.glyphAtlas.get(); spriteAtlas = style.spriteAtlas.get(); lineAtlas = style.lineAtlas.get(); @@ -227,7 +223,7 @@ void Painter::render(const Style& style, TransformState state_, const FrameData& } if (data.contextMode == GLContextMode::Shared) { - config.save(); + config.setDirty(); } } |