diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-09-27 13:00:27 +0200 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-27 11:03:29 -0700 |
commit | ce42d22984d19fa020e6fba77e2585c0fd9dacf4 (patch) | |
tree | 76e1a33a58bfb023987de1cc7aca59e649624db3 /src/mbgl/renderer | |
parent | 21386b31465302d63cae5d93680442555c8560f1 (diff) | |
download | qtlocation-mapboxgl-ce42d22984d19fa020e6fba77e2585c0fd9dacf4.tar.gz |
[core] rename gl::Config to gl::Context
Diffstat (limited to 'src/mbgl/renderer')
25 files changed, 250 insertions, 250 deletions
diff --git a/src/mbgl/renderer/bucket.hpp b/src/mbgl/renderer/bucket.hpp index 0efcd2845e..957bfade49 100644 --- a/src/mbgl/renderer/bucket.hpp +++ b/src/mbgl/renderer/bucket.hpp @@ -17,7 +17,7 @@ class RenderTile; namespace gl { class ObjectStore; -class Config; +class Context; } // namespace gl namespace style { @@ -30,7 +30,7 @@ public: // As long as this bucket has a Prepare render pass, this function is getting called. Typically, // this only happens once when the bucket is being rendered for the first time. - virtual void upload(gl::ObjectStore&, gl::Config&) = 0; + virtual void upload(gl::ObjectStore&, gl::Context&) = 0; // Every time this bucket is getting rendered, this function is called. This happens either // once or twice (for Opaque and Transparent render passes). diff --git a/src/mbgl/renderer/circle_bucket.cpp b/src/mbgl/renderer/circle_bucket.cpp index d330c98d65..f33c893b04 100644 --- a/src/mbgl/renderer/circle_bucket.cpp +++ b/src/mbgl/renderer/circle_bucket.cpp @@ -16,9 +16,9 @@ CircleBucket::~CircleBucket() { // Do not remove. header file only contains forward definitions to unique pointers. } -void CircleBucket::upload(gl::ObjectStore& store, gl::Config& config) { - vertexBuffer_.upload(store, config); - elementsBuffer_.upload(store, config); +void CircleBucket::upload(gl::ObjectStore& store, gl::Context& context) { + vertexBuffer_.upload(store, context); + elementsBuffer_.upload(store, context); uploaded = true; } @@ -82,7 +82,7 @@ void CircleBucket::addGeometry(const GeometryCollection& geometryCollection) { } } -void CircleBucket::drawCircles(CircleShader& shader, gl::ObjectStore& store, gl::Config& config) { +void CircleBucket::drawCircles(CircleShader& shader, gl::ObjectStore& store, gl::Context& context) { GLbyte* vertexIndex = BUFFER_OFFSET(0); GLbyte* elementsIndex = BUFFER_OFFSET(0); @@ -91,7 +91,7 @@ void CircleBucket::drawCircles(CircleShader& shader, gl::ObjectStore& store, gl: if (!group->elements_length) continue; - group->array[0].bind(shader, vertexBuffer_, elementsBuffer_, vertexIndex, store, config); + group->array[0].bind(shader, vertexBuffer_, elementsBuffer_, vertexIndex, store, context); MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT, elementsIndex)); diff --git a/src/mbgl/renderer/circle_bucket.hpp b/src/mbgl/renderer/circle_bucket.hpp index 13ade90bdf..045ddfab72 100644 --- a/src/mbgl/renderer/circle_bucket.hpp +++ b/src/mbgl/renderer/circle_bucket.hpp @@ -18,14 +18,14 @@ public: CircleBucket(const MapMode); ~CircleBucket() override; - void upload(gl::ObjectStore&, gl::Config&) override; + void upload(gl::ObjectStore&, gl::Context&) override; void render(Painter&, PaintParameters&, const style::Layer&, const RenderTile&) override; bool hasData() const override; bool needsClipping() const override; void addGeometry(const GeometryCollection&); - void drawCircles(CircleShader&, gl::ObjectStore&, gl::Config&); + void drawCircles(CircleShader&, gl::ObjectStore&, gl::Context&); private: CircleVertexBuffer vertexBuffer_; diff --git a/src/mbgl/renderer/debug_bucket.cpp b/src/mbgl/renderer/debug_bucket.cpp index 6e7f08e6ad..69e060c1bd 100644 --- a/src/mbgl/renderer/debug_bucket.cpp +++ b/src/mbgl/renderer/debug_bucket.cpp @@ -38,16 +38,16 @@ DebugBucket::DebugBucket(const OverscaledTileID& id, } } -void DebugBucket::drawLines(PlainShader& shader, gl::ObjectStore& store, gl::Config& config) { +void DebugBucket::drawLines(PlainShader& shader, gl::ObjectStore& store, gl::Context& context) { if (!fontBuffer.empty()) { - array.bind(shader, fontBuffer, BUFFER_OFFSET_0, store, config); + array.bind(shader, fontBuffer, BUFFER_OFFSET_0, store, context); MBGL_CHECK_ERROR(glDrawArrays(GL_LINES, 0, (GLsizei)(fontBuffer.index()))); } } -void DebugBucket::drawPoints(PlainShader& shader, gl::ObjectStore& store, gl::Config& config) { +void DebugBucket::drawPoints(PlainShader& shader, gl::ObjectStore& store, gl::Context& context) { if (!fontBuffer.empty()) { - array.bind(shader, fontBuffer, BUFFER_OFFSET_0, store, config); + array.bind(shader, fontBuffer, BUFFER_OFFSET_0, store, context); MBGL_CHECK_ERROR(glDrawArrays(GL_POINTS, 0, (GLsizei)(fontBuffer.index()))); } } diff --git a/src/mbgl/renderer/debug_bucket.hpp b/src/mbgl/renderer/debug_bucket.hpp index 1c8f44c4f1..413714178e 100644 --- a/src/mbgl/renderer/debug_bucket.hpp +++ b/src/mbgl/renderer/debug_bucket.hpp @@ -12,7 +12,7 @@ class PlainShader; namespace gl { class ObjectStore; -class Config; +class Context; } // namespace gl class DebugBucket : private util::noncopyable { @@ -24,8 +24,8 @@ public: optional<Timestamp> expires, MapDebugOptions); - void drawLines(PlainShader&, gl::ObjectStore&, gl::Config&); - void drawPoints(PlainShader&, gl::ObjectStore&, gl::Config&); + void drawLines(PlainShader&, gl::ObjectStore&, gl::Context&); + void drawPoints(PlainShader&, gl::ObjectStore&, gl::Context&); const bool renderable; const bool complete; diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp index 706f063ca0..868ab6afe4 100644 --- a/src/mbgl/renderer/fill_bucket.cpp +++ b/src/mbgl/renderer/fill_bucket.cpp @@ -95,10 +95,10 @@ void FillBucket::addGeometry(const GeometryCollection& geometry) { } } -void FillBucket::upload(gl::ObjectStore& store, gl::Config& config) { - vertexBuffer.upload(store, config); - triangleElementsBuffer.upload(store, config); - lineElementsBuffer.upload(store, config); +void FillBucket::upload(gl::ObjectStore& store, gl::Context& context) { + vertexBuffer.upload(store, context); + triangleElementsBuffer.upload(store, context); + lineElementsBuffer.upload(store, context); // From now on, we're going to render during the opaque and translucent pass. uploaded = true; @@ -121,14 +121,14 @@ bool FillBucket::needsClipping() const { void FillBucket::drawElements(PlainShader& shader, gl::ObjectStore& store, - gl::Config& config, + gl::Context& context, PaintMode paintMode) { GLbyte* vertex_index = BUFFER_OFFSET(0); GLbyte* elements_index = BUFFER_OFFSET(0); for (auto& group : triangleGroups) { assert(group); group->array[paintMode == PaintMode::Overdraw ? 1 : 0].bind( - shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, config); + shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, context); MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT, elements_index)); vertex_index += group->vertex_length * vertexBuffer.itemSize; @@ -138,14 +138,14 @@ void FillBucket::drawElements(PlainShader& shader, void FillBucket::drawElements(PatternShader& shader, gl::ObjectStore& store, - gl::Config& config, + gl::Context& context, PaintMode paintMode) { GLbyte* vertex_index = BUFFER_OFFSET(0); GLbyte* elements_index = BUFFER_OFFSET(0); for (auto& group : triangleGroups) { assert(group); group->array[paintMode == PaintMode::Overdraw ? 3 : 2].bind( - shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, config); + shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, context); MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT, elements_index)); vertex_index += group->vertex_length * vertexBuffer.itemSize; @@ -155,14 +155,14 @@ void FillBucket::drawElements(PatternShader& shader, void FillBucket::drawVertices(OutlineShader& shader, gl::ObjectStore& store, - gl::Config& config, + gl::Context& context, PaintMode paintMode) { GLbyte* vertex_index = BUFFER_OFFSET(0); GLbyte* elements_index = BUFFER_OFFSET(0); for (auto& group : lineGroups) { assert(group); group->array[paintMode == PaintMode::Overdraw ? 1 : 0].bind( - shader, vertexBuffer, lineElementsBuffer, vertex_index, store, config); + shader, vertexBuffer, lineElementsBuffer, vertex_index, store, context); MBGL_CHECK_ERROR(glDrawElements(GL_LINES, group->elements_length * 2, GL_UNSIGNED_SHORT, elements_index)); vertex_index += group->vertex_length * vertexBuffer.itemSize; @@ -172,14 +172,14 @@ void FillBucket::drawVertices(OutlineShader& shader, void FillBucket::drawVertices(OutlinePatternShader& shader, gl::ObjectStore& store, - gl::Config& config, + gl::Context& context, PaintMode paintMode) { GLbyte* vertex_index = BUFFER_OFFSET(0); GLbyte* elements_index = BUFFER_OFFSET(0); for (auto& group : lineGroups) { assert(group); group->array[paintMode == PaintMode::Overdraw ? 3 : 2].bind( - shader, vertexBuffer, lineElementsBuffer, vertex_index, store, config); + shader, vertexBuffer, lineElementsBuffer, vertex_index, store, context); MBGL_CHECK_ERROR(glDrawElements(GL_LINES, group->elements_length * 2, GL_UNSIGNED_SHORT, elements_index)); vertex_index += group->vertex_length * vertexBuffer.itemSize; diff --git a/src/mbgl/renderer/fill_bucket.hpp b/src/mbgl/renderer/fill_bucket.hpp index fd28cd83ce..b8c18545f7 100644 --- a/src/mbgl/renderer/fill_bucket.hpp +++ b/src/mbgl/renderer/fill_bucket.hpp @@ -20,17 +20,17 @@ public: FillBucket(); ~FillBucket() override; - void upload(gl::ObjectStore&, gl::Config&) override; + void upload(gl::ObjectStore&, gl::Context&) override; void render(Painter&, PaintParameters&, const style::Layer&, const RenderTile&) override; bool hasData() const override; bool needsClipping() const override; void addGeometry(const GeometryCollection&); - void drawElements(PlainShader&, gl::ObjectStore&, gl::Config&, PaintMode); - void drawElements(PatternShader&, gl::ObjectStore&, gl::Config&, PaintMode); - void drawVertices(OutlineShader&, gl::ObjectStore&, gl::Config&, PaintMode); - void drawVertices(OutlinePatternShader&, gl::ObjectStore&, gl::Config&, PaintMode); + void drawElements(PlainShader&, gl::ObjectStore&, gl::Context&, PaintMode); + void drawElements(PatternShader&, gl::ObjectStore&, gl::Context&, PaintMode); + void drawVertices(OutlineShader&, gl::ObjectStore&, gl::Context&, PaintMode); + void drawVertices(OutlinePatternShader&, gl::ObjectStore&, gl::Context&, PaintMode); private: FillVertexBuffer vertexBuffer; diff --git a/src/mbgl/renderer/frame_history.cpp b/src/mbgl/renderer/frame_history.cpp index fc9d9b6616..066d999b9a 100644 --- a/src/mbgl/renderer/frame_history.cpp +++ b/src/mbgl/renderer/frame_history.cpp @@ -1,6 +1,6 @@ #include <mbgl/renderer/frame_history.hpp> #include <mbgl/math/minmax.hpp> -#include <mbgl/gl/gl_config.hpp> +#include <mbgl/gl/context.hpp> namespace mbgl { @@ -58,11 +58,11 @@ bool FrameHistory::needsAnimation(const Duration& duration) const { return (time - previousTime) < duration; } -void FrameHistory::upload(gl::ObjectStore& store, gl::Config& config, uint32_t unit) { +void FrameHistory::upload(gl::ObjectStore& store, gl::Context& context, uint32_t unit) { if (changed) { const bool first = !texture; - bind(store, config, unit); + bind(store, context, unit); if (first) { MBGL_CHECK_ERROR(glTexImage2D( @@ -95,11 +95,11 @@ void FrameHistory::upload(gl::ObjectStore& store, gl::Config& config, uint32_t u } } -void FrameHistory::bind(gl::ObjectStore& store, gl::Config& config, uint32_t unit) { +void FrameHistory::bind(gl::ObjectStore& store, gl::Context& context, uint32_t unit) { if (!texture) { texture = store.createTexture(); - config.activeTexture = unit; - config.texture[unit] = *texture; + context.activeTexture = unit; + context.texture[unit] = *texture; #ifndef GL_ES_VERSION_2_0 MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0)); #endif @@ -107,9 +107,9 @@ void FrameHistory::bind(gl::ObjectStore& store, gl::Config& config, uint32_t uni MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); - } else if (config.texture[unit] != *texture) { - config.activeTexture = unit; - config.texture[unit] = *texture; + } else if (context.texture[unit] != *texture) { + context.activeTexture = unit; + context.texture[unit] = *texture; } } diff --git a/src/mbgl/renderer/frame_history.hpp b/src/mbgl/renderer/frame_history.hpp index ec43e2beb5..88c4ebe301 100644 --- a/src/mbgl/renderer/frame_history.hpp +++ b/src/mbgl/renderer/frame_history.hpp @@ -10,7 +10,7 @@ namespace mbgl { namespace gl { -class Config; +class Context; } // namespace gl class FrameHistory { @@ -19,8 +19,8 @@ public: void record(const TimePoint&, float zoom, const Duration&); bool needsAnimation(const Duration&) const; - void bind(gl::ObjectStore&, gl::Config&, uint32_t); - void upload(gl::ObjectStore&, gl::Config&, uint32_t); + void bind(gl::ObjectStore&, gl::Context&, uint32_t); + void upload(gl::ObjectStore&, gl::Context&, uint32_t); private: const int width = 256; diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp index 700d334f79..56e07afe53 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -437,9 +437,9 @@ void LineBucket::addPieSliceVertex(const GeometryCoordinate& currentVertex, } } -void LineBucket::upload(gl::ObjectStore& store, gl::Config& config) { - vertexBuffer.upload(store, config); - triangleElementsBuffer.upload(store, config); +void LineBucket::upload(gl::ObjectStore& store, gl::Context& context) { + vertexBuffer.upload(store, context); + triangleElementsBuffer.upload(store, context); // From now on, we're only going to render during the translucent pass. uploaded = true; @@ -462,7 +462,7 @@ bool LineBucket::needsClipping() const { void LineBucket::drawLines(LineShader& shader, gl::ObjectStore& store, - gl::Config& config, + gl::Context& context, PaintMode paintMode) { GLbyte* vertex_index = BUFFER_OFFSET(0); GLbyte* elements_index = BUFFER_OFFSET(0); @@ -472,7 +472,7 @@ void LineBucket::drawLines(LineShader& shader, continue; } group->array[paintMode == PaintMode::Overdraw ? 1 : 0].bind( - shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, config); + shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, context); MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT, elements_index)); vertex_index += group->vertex_length * vertexBuffer.itemSize; @@ -482,7 +482,7 @@ void LineBucket::drawLines(LineShader& shader, void LineBucket::drawLineSDF(LineSDFShader& shader, gl::ObjectStore& store, - gl::Config& config, + gl::Context& context, PaintMode paintMode) { GLbyte* vertex_index = BUFFER_OFFSET(0); GLbyte* elements_index = BUFFER_OFFSET(0); @@ -492,7 +492,7 @@ void LineBucket::drawLineSDF(LineSDFShader& shader, continue; } group->array[paintMode == PaintMode::Overdraw ? 3 : 2].bind( - shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, config); + shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, context); MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT, elements_index)); vertex_index += group->vertex_length * vertexBuffer.itemSize; @@ -502,7 +502,7 @@ void LineBucket::drawLineSDF(LineSDFShader& shader, void LineBucket::drawLinePatterns(LinepatternShader& shader, gl::ObjectStore& store, - gl::Config& config, + gl::Context& context, PaintMode paintMode) { GLbyte* vertex_index = BUFFER_OFFSET(0); GLbyte* elements_index = BUFFER_OFFSET(0); @@ -512,7 +512,7 @@ void LineBucket::drawLinePatterns(LinepatternShader& shader, continue; } group->array[paintMode == PaintMode::Overdraw ? 5 : 4].bind( - shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, config); + shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, context); MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT, elements_index)); vertex_index += group->vertex_length * vertexBuffer.itemSize; diff --git a/src/mbgl/renderer/line_bucket.hpp b/src/mbgl/renderer/line_bucket.hpp index 32dd157c65..578aa764d3 100644 --- a/src/mbgl/renderer/line_bucket.hpp +++ b/src/mbgl/renderer/line_bucket.hpp @@ -24,7 +24,7 @@ public: LineBucket(uint32_t overscaling); ~LineBucket() override; - void upload(gl::ObjectStore&, gl::Config&) override; + void upload(gl::ObjectStore&, gl::Context&) override; void render(Painter&, PaintParameters&, const style::Layer&, const RenderTile&) override; bool hasData() const override; bool needsClipping() const override; @@ -32,9 +32,9 @@ public: void addGeometry(const GeometryCollection&); void addGeometry(const GeometryCoordinates& line); - void drawLines(LineShader&, gl::ObjectStore&, gl::Config&, PaintMode); - void drawLineSDF(LineSDFShader&, gl::ObjectStore&, gl::Config&, PaintMode); - void drawLinePatterns(LinepatternShader&, gl::ObjectStore&, gl::Config&, PaintMode); + void drawLines(LineShader&, gl::ObjectStore&, gl::Context&, PaintMode); + void drawLineSDF(LineSDFShader&, gl::ObjectStore&, gl::Context&, PaintMode); + void drawLinePatterns(LinepatternShader&, gl::ObjectStore&, gl::Context&, PaintMode); private: struct TriangleElement { diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index 2b3189cc55..2a974f7d27 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -48,8 +48,8 @@ Painter::Painter(const TransformState& state_, #endif // Reset GL values - config.setDirtyState(); - config.resetState(); + context.setDirtyState(); + context.resetState(); } Painter::~Painter() = default; @@ -61,12 +61,12 @@ bool Painter::needsAnimation() const { void Painter::setClipping(const ClipID& clip) { const GLint ref = (GLint)clip.reference.to_ulong(); const GLuint mask = (GLuint)clip.mask.to_ulong(); - config.stencilFunc = { GL_EQUAL, ref, mask }; + context.stencilFunc = { GL_EQUAL, ref, mask }; } void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& annotationSpriteAtlas) { if (frame.framebufferSize != frame_.framebufferSize) { - config.viewport.setDefaultValue( + context.viewport.setDefaultValue( { { 0, 0, frame_.framebufferSize[0], frame_.framebufferSize[1] } }); } frame = frame_; @@ -104,18 +104,18 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a { MBGL_DEBUG_GROUP("upload"); - tileStencilBuffer.upload(store, config); - rasterBoundsBuffer.upload(store, config); - tileBorderBuffer.upload(store, config); - spriteAtlas->upload(store, config, 0); - lineAtlas->upload(store, config, 0); - glyphAtlas->upload(store, config, 0); - frameHistory.upload(store, config, 0); - annotationSpriteAtlas.upload(store, config, 0); + tileStencilBuffer.upload(store, context); + rasterBoundsBuffer.upload(store, context); + tileBorderBuffer.upload(store, context); + spriteAtlas->upload(store, context, 0); + lineAtlas->upload(store, context, 0); + glyphAtlas->upload(store, context, 0); + frameHistory.upload(store, context, 0); + annotationSpriteAtlas.upload(store, context, 0); for (const auto& item : order) { if (item.bucket && item.bucket->needsUpload()) { - item.bucket->upload(store, config); + item.bucket->upload(store, context); } } } @@ -125,26 +125,26 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a // tiles whatsoever. { MBGL_DEBUG_GROUP("clear"); - config.bindFramebuffer.reset(); - config.viewport.reset(); - config.stencilFunc.reset(); - config.stencilTest = GL_TRUE; - config.stencilMask = 0xFF; - config.depthTest = GL_FALSE; - config.depthMask = GL_TRUE; - config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; + context.bindFramebuffer.reset(); + context.viewport.reset(); + context.stencilFunc.reset(); + context.stencilTest = GL_TRUE; + context.stencilMask = 0xFF; + context.depthTest = GL_FALSE; + context.depthMask = GL_TRUE; + context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; if (paintMode() == PaintMode::Overdraw) { - config.blend = GL_TRUE; - config.blendFunc = { GL_CONSTANT_COLOR, GL_ONE }; + context.blend = GL_TRUE; + context.blendFunc = { GL_CONSTANT_COLOR, GL_ONE }; const float overdraw = 1.0f / 8.0f; - config.blendColor = { overdraw, overdraw, overdraw, 0.0f }; - config.clearColor = Color::black(); + context.blendColor = { overdraw, overdraw, overdraw, 0.0f }; + context.clearColor = Color::black(); } else { - config.clearColor = background; + context.clearColor = background; } - config.clearStencil = 0; - config.clearDepth = 1; + context.clearStencil = 0; + context.clearDepth = 1; MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); } @@ -216,16 +216,16 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a { MBGL_DEBUG_GROUP("cleanup"); - config.activeTexture = 1; - config.texture[1] = 0; - config.activeTexture = 0; - config.texture[0] = 0; + context.activeTexture = 1; + context.texture[1] = 0; + context.activeTexture = 0; + context.texture[0] = 0; - config.vertexArrayObject = 0; + context.vertexArrayObject = 0; } if (frame.contextMode == GLContextMode::Shared) { - config.setDirtyState(); + context.setDirtyState(); } } @@ -253,32 +253,32 @@ void Painter::renderPass(PaintParameters& parameters, continue; if (paintMode() == PaintMode::Overdraw) { - config.blend = GL_TRUE; + context.blend = GL_TRUE; } else if (pass == RenderPass::Translucent) { - config.blendFunc.reset(); - config.blend = GL_TRUE; + context.blendFunc.reset(); + context.blend = GL_TRUE; } else { - config.blend = GL_FALSE; + context.blend = GL_FALSE; } - config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; - config.stencilMask = 0x0; + context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; + context.stencilMask = 0x0; if (layer.is<BackgroundLayer>()) { MBGL_DEBUG_GROUP("background"); renderBackground(parameters, *layer.as<BackgroundLayer>()); } else if (layer.is<CustomLayer>()) { MBGL_DEBUG_GROUP(layer.baseImpl->id + " - custom"); - config.vertexArrayObject = 0; - config.depthFunc.reset(); - config.depthTest = GL_TRUE; - config.depthMask = GL_FALSE; - config.stencilTest = GL_FALSE; + context.vertexArrayObject = 0; + context.depthFunc.reset(); + context.depthTest = GL_TRUE; + context.depthMask = GL_FALSE; + context.stencilTest = GL_FALSE; setDepthSublayer(0); layer.as<CustomLayer>()->impl->render(state); - config.setDirtyState(); - config.bindFramebuffer.reset(); - config.viewport.reset(); + context.setDirtyState(); + context.bindFramebuffer.reset(); + context.viewport.reset(); } else { MBGL_DEBUG_GROUP(layer.baseImpl->id + " - " + util::toString(item.tile->id)); if (item.bucket->needsClipping()) { @@ -296,7 +296,7 @@ void Painter::renderPass(PaintParameters& parameters, void Painter::setDepthSublayer(int n) { float nearDepth = ((1 + currentLayer) * numSublayers + n) * depthEpsilon; float farDepth = nearDepth + depthRangeSize; - config.depthRange = { nearDepth, farDepth }; + context.depthRange = { nearDepth, farDepth }; } } // namespace mbgl diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp index 022d3adef8..31c840372f 100644 --- a/src/mbgl/renderer/painter.hpp +++ b/src/mbgl/renderer/painter.hpp @@ -11,7 +11,7 @@ #include <mbgl/geometry/vao.hpp> #include <mbgl/geometry/static_vertex_buffer.hpp> -#include <mbgl/gl/gl_config.hpp> +#include <mbgl/gl/context.hpp> #include <mbgl/gl/gl.hpp> #include <mbgl/style/style.hpp> @@ -125,7 +125,7 @@ private: float scaleDivisor, std::array<float, 2> texsize, SDFShader& sdfShader, - void (SymbolBucket::*drawSDF)(SDFShader&, gl::ObjectStore&, gl::Config&, PaintMode), + void (SymbolBucket::*drawSDF)(SDFShader&, gl::ObjectStore&, gl::Context&, PaintMode), // Layout style::AlignmentType rotationAlignment, @@ -172,7 +172,7 @@ private: int indent = 0; - gl::Config config; + gl::Context context; RenderPass pass = RenderPass::Opaque; diff --git a/src/mbgl/renderer/painter_background.cpp b/src/mbgl/renderer/painter_background.cpp index 942f993f55..b19a7563eb 100644 --- a/src/mbgl/renderer/painter_background.cpp +++ b/src/mbgl/renderer/painter_background.cpp @@ -35,7 +35,7 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye if (!imagePosA || !imagePosB) return; - config.program = patternShader.getID(); + context.program = patternShader.getID(); patternShader.u_matrix = identityMatrix; patternShader.u_pattern_tl_a = imagePosA->tl; patternShader.u_pattern_br_a = imagePosA->br; @@ -44,21 +44,21 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye patternShader.u_mix = properties.backgroundPattern.value.t; patternShader.u_opacity = properties.backgroundOpacity; - spriteAtlas->bind(true, store, config, 0); - arrayBackgroundPattern.bind(patternShader, tileStencilBuffer, BUFFER_OFFSET(0), store, config); + spriteAtlas->bind(true, store, context, 0); + arrayBackgroundPattern.bind(patternShader, tileStencilBuffer, BUFFER_OFFSET(0), store, context); } else { - config.program = plainShader.getID(); + context.program = plainShader.getID(); plainShader.u_color = properties.backgroundColor; plainShader.u_opacity = properties.backgroundOpacity; - arrayBackground.bind(plainShader, tileStencilBuffer, BUFFER_OFFSET(0), store, config); + arrayBackground.bind(plainShader, tileStencilBuffer, BUFFER_OFFSET(0), store, context); } - config.stencilTest = GL_FALSE; - config.depthFunc.reset(); - config.depthTest = GL_TRUE; - config.depthMask = GL_FALSE; + context.stencilTest = GL_FALSE; + context.depthFunc.reset(); + context.depthTest = GL_TRUE; + context.depthMask = GL_FALSE; setDepthSublayer(0); for (const auto& tileID : util::tileCover(state, state.getIntegerZoom())) { diff --git a/src/mbgl/renderer/painter_circle.cpp b/src/mbgl/renderer/painter_circle.cpp index 991ba2d4bc..14eb957dfd 100644 --- a/src/mbgl/renderer/painter_circle.cpp +++ b/src/mbgl/renderer/painter_circle.cpp @@ -19,16 +19,16 @@ void Painter::renderCircle(PaintParameters& parameters, // Abort early. if (pass == RenderPass::Opaque) return; - config.stencilTest = frame.mapMode == MapMode::Still ? GL_TRUE : GL_FALSE; - config.depthFunc.reset(); - config.depthTest = GL_TRUE; - config.depthMask = GL_FALSE; + context.stencilTest = frame.mapMode == MapMode::Still ? GL_TRUE : GL_FALSE; + context.depthFunc.reset(); + context.depthTest = GL_TRUE; + context.depthMask = GL_FALSE; setDepthSublayer(0); const CirclePaintProperties& properties = layer.impl->paint; auto& circleShader = parameters.shaders.circle; - config.program = circleShader.getID(); + context.program = circleShader.getID(); circleShader.u_matrix = tile.translatedMatrix(properties.circleTranslate, properties.circleTranslateAnchor, @@ -51,7 +51,7 @@ void Painter::renderCircle(PaintParameters& parameters, circleShader.u_blur = properties.circleBlur; circleShader.u_opacity = properties.circleOpacity; - bucket.drawCircles(circleShader, store, config); + bucket.drawCircles(circleShader, store, context); } } // namespace mbgl diff --git a/src/mbgl/renderer/painter_clipping.cpp b/src/mbgl/renderer/painter_clipping.cpp index bbef57399a..14808310e4 100644 --- a/src/mbgl/renderer/painter_clipping.cpp +++ b/src/mbgl/renderer/painter_clipping.cpp @@ -18,15 +18,15 @@ void Painter::drawClippingMasks(PaintParameters& parameters, const std::map<Unwr mat4 matrix; const GLuint mask = 0b11111111; - config.program = plainShader.getID(); - config.stencilOp.reset(); - config.stencilTest = GL_TRUE; - config.depthTest = GL_FALSE; - config.depthMask = GL_FALSE; - config.colorMask = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; - config.stencilMask = mask; + context.program = plainShader.getID(); + context.stencilOp.reset(); + context.stencilTest = GL_TRUE; + context.depthTest = GL_FALSE; + context.depthMask = GL_FALSE; + context.colorMask = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; + context.stencilMask = mask; - arrayCoveringPlain.bind(plainShader, tileStencilBuffer, BUFFER_OFFSET_0, store, config); + arrayCoveringPlain.bind(plainShader, tileStencilBuffer, BUFFER_OFFSET_0, store, context); for (const auto& stencil : stencils) { const auto& id = stencil.first; @@ -38,7 +38,7 @@ void Painter::drawClippingMasks(PaintParameters& parameters, const std::map<Unwr plainShader.u_matrix = matrix; const GLint ref = (GLint)(clip.reference.to_ulong()); - config.stencilFunc = { GL_ALWAYS, ref, mask }; + context.stencilFunc = { GL_ALWAYS, ref, mask }; MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index())); } } diff --git a/src/mbgl/renderer/painter_debug.cpp b/src/mbgl/renderer/painter_debug.cpp index adecc20518..7aeb5cc6e1 100644 --- a/src/mbgl/renderer/painter_debug.cpp +++ b/src/mbgl/renderer/painter_debug.cpp @@ -26,7 +26,7 @@ void Painter::renderTileDebug(const RenderTile& tile) { void Painter::renderDebugText(Tile& tile, const mat4 &matrix) { MBGL_DEBUG_GROUP("debug text"); - config.depthTest = GL_FALSE; + context.depthTest = GL_FALSE; if (!tile.debugBucket || tile.debugBucket->renderable != tile.isRenderable() || tile.debugBucket->complete != tile.isComplete() || @@ -39,28 +39,28 @@ void Painter::renderDebugText(Tile& tile, const mat4 &matrix) { } auto& plainShader = shaders->plain; - config.program = plainShader.getID(); + context.program = plainShader.getID(); plainShader.u_matrix = matrix; plainShader.u_opacity = 1.0f; // Draw white outline plainShader.u_color = Color::white(); - config.lineWidth = 4.0f * frame.pixelRatio; - tile.debugBucket->drawLines(plainShader, store, config); + context.lineWidth = 4.0f * frame.pixelRatio; + tile.debugBucket->drawLines(plainShader, store, context); #ifndef GL_ES_VERSION_2_0 // Draw line "end caps" MBGL_CHECK_ERROR(glPointSize(2)); - tile.debugBucket->drawPoints(plainShader, store, config); + tile.debugBucket->drawPoints(plainShader, store, context); #endif // Draw black text. plainShader.u_color = Color::black(); - config.lineWidth = 2.0f * frame.pixelRatio; - tile.debugBucket->drawLines(plainShader, store, config); + context.lineWidth = 2.0f * frame.pixelRatio; + tile.debugBucket->drawLines(plainShader, store, context); - config.depthFunc.reset(); - config.depthTest = GL_TRUE; + context.depthFunc.reset(); + context.depthTest = GL_TRUE; } void Painter::renderDebugFrame(const mat4 &matrix) { @@ -69,32 +69,32 @@ void Painter::renderDebugFrame(const mat4 &matrix) { // Disable depth test and don't count this towards the depth buffer, // but *don't* disable stencil test, as we want to clip the red tile border // to the tile viewport. - config.depthTest = GL_FALSE; - config.stencilOp.reset(); - config.stencilTest = GL_TRUE; + context.depthTest = GL_FALSE; + context.stencilOp.reset(); + context.stencilTest = GL_TRUE; auto& plainShader = shaders->plain; - config.program = plainShader.getID(); + context.program = plainShader.getID(); plainShader.u_matrix = matrix; plainShader.u_opacity = 1.0f; // draw tile outline - tileBorderArray.bind(plainShader, tileBorderBuffer, BUFFER_OFFSET_0, store, config); + tileBorderArray.bind(plainShader, tileBorderBuffer, BUFFER_OFFSET_0, store, context); plainShader.u_color = { 1.0f, 0.0f, 0.0f, 1.0f }; - config.lineWidth = 4.0f * frame.pixelRatio; + context.lineWidth = 4.0f * frame.pixelRatio; MBGL_CHECK_ERROR(glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)tileBorderBuffer.index())); } #ifndef NDEBUG void Painter::renderClipMasks() { - config.stencilTest = GL_FALSE; - config.depthTest = GL_FALSE; - config.program = 0; - config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; + context.stencilTest = GL_FALSE; + context.depthTest = GL_FALSE; + context.program = 0; + context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; #ifndef GL_ES_VERSION_2_0 - config.pixelZoom = { 1, 1 }; - config.rasterPos = {{ -1, -1, 0, 0 }}; + context.pixelZoom = { 1, 1 }; + context.rasterPos = {{ -1, -1, 0, 0 }}; // Read the stencil buffer const auto& fbSize = frame.framebufferSize; @@ -125,14 +125,14 @@ void Painter::renderClipMasks() { #ifndef NDEBUG void Painter::renderDepthBuffer() { - config.stencilTest = GL_FALSE; - config.depthTest = GL_FALSE; - config.program = 0; - config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; + context.stencilTest = GL_FALSE; + context.depthTest = GL_FALSE; + context.program = 0; + context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; #ifndef GL_ES_VERSION_2_0 - config.pixelZoom = { 1, 1 }; - config.rasterPos = {{ -1, -1, 0, 0 }}; + context.pixelZoom = { 1, 1 }; + context.rasterPos = {{ -1, -1, 0, 0 }}; // Read the stencil buffer const auto& fbSize = frame.framebufferSize; diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp index a948cf1651..c6f36dd209 100644 --- a/src/mbgl/renderer/painter_fill.cpp +++ b/src/mbgl/renderer/painter_fill.cpp @@ -33,12 +33,12 @@ void Painter::renderFill(PaintParameters& parameters, bool outline = properties.fillAntialias && !pattern && isOutlineColorDefined; bool fringeline = properties.fillAntialias && !pattern && !isOutlineColorDefined; - config.stencilOp.reset(); - config.stencilTest = GL_TRUE; - config.depthFunc.reset(); - config.depthTest = GL_TRUE; - config.depthMask = GL_TRUE; - config.lineWidth = 2.0f; // This is always fixed and does not depend on the pixelRatio! + context.stencilOp.reset(); + context.stencilTest = GL_TRUE; + context.depthFunc.reset(); + context.depthTest = GL_TRUE; + context.depthMask = GL_TRUE; + context.lineWidth = 2.0f; // This is always fixed and does not depend on the pixelRatio! auto& outlineShader = parameters.shaders.outline; auto& patternShader = parameters.shaders.pattern; @@ -48,7 +48,7 @@ void Painter::renderFill(PaintParameters& parameters, // Because we're drawing top-to-bottom, and we update the stencil mask // befrom, we have to draw the outline first (!) if (outline && pass == RenderPass::Translucent) { - config.program = outlineShader.getID(); + context.program = outlineShader.getID(); outlineShader.u_matrix = vertexMatrix; outlineShader.u_outline_color = strokeColor; @@ -69,7 +69,7 @@ void Painter::renderFill(PaintParameters& parameters, // the (non-antialiased) fill. setDepthSublayer(0); // OK } - bucket.drawVertices(outlineShader, store, config, paintMode()); + bucket.drawVertices(outlineShader, store, context, paintMode()); } if (pattern) { @@ -80,7 +80,7 @@ void Painter::renderFill(PaintParameters& parameters, // Image fill. if (pass == RenderPass::Translucent && imagePosA && imagePosB) { - config.program = patternShader.getID(); + context.program = patternShader.getID(); patternShader.u_matrix = vertexMatrix; patternShader.u_pattern_tl_a = imagePosA->tl; patternShader.u_pattern_br_a = imagePosA->br; @@ -101,14 +101,14 @@ void Painter::renderFill(PaintParameters& parameters, patternShader.u_pixel_coord_upper = {{ float(pixelX >> 16), float(pixelY >> 16) }}; patternShader.u_pixel_coord_lower = {{ float(pixelX & 0xFFFF), float(pixelY & 0xFFFF) }}; - spriteAtlas->bind(true, store, config, 0); + spriteAtlas->bind(true, store, context, 0); // Draw the actual triangles into the color & stencil buffer. setDepthSublayer(0); - bucket.drawElements(patternShader, store, config, paintMode()); + bucket.drawElements(patternShader, store, context, paintMode()); if (properties.fillAntialias && !isOutlineColorDefined) { - config.program = outlinePatternShader.getID(); + context.program = outlinePatternShader.getID(); outlinePatternShader.u_matrix = vertexMatrix; outlinePatternShader.u_pattern_tl_a = imagePosA->tl; @@ -129,10 +129,10 @@ void Painter::renderFill(PaintParameters& parameters, // Draw the entire line outlinePatternShader.u_world = worldSize; - spriteAtlas->bind(true, store, config, 0); + spriteAtlas->bind(true, store, context, 0); setDepthSublayer(2); - bucket.drawVertices(outlinePatternShader, store, config, paintMode()); + bucket.drawVertices(outlinePatternShader, store, context, paintMode()); } } } else { @@ -142,21 +142,21 @@ void Painter::renderFill(PaintParameters& parameters, // fragments or when it's translucent and we're drawing translucent // fragments // Draw filling rectangle. - config.program = plainShader.getID(); + context.program = plainShader.getID(); plainShader.u_matrix = vertexMatrix; plainShader.u_color = fillColor; plainShader.u_opacity = opacity; // Draw the actual triangles into the color & stencil buffer. setDepthSublayer(1); - bucket.drawElements(plainShader, store, config, paintMode()); + bucket.drawElements(plainShader, store, context, paintMode()); } } // Because we're drawing top-to-bottom, and we update the stencil mask // below, we have to draw the outline first (!) if (fringeline && pass == RenderPass::Translucent) { - config.program = outlineShader.getID(); + context.program = outlineShader.getID(); outlineShader.u_matrix = vertexMatrix; outlineShader.u_outline_color = fillColor; @@ -166,7 +166,7 @@ void Painter::renderFill(PaintParameters& parameters, outlineShader.u_world = worldSize; setDepthSublayer(2); - bucket.drawVertices(outlineShader, store, config, paintMode()); + bucket.drawVertices(outlineShader, store, context, paintMode()); } } diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp index b93ef6d73d..97e64027da 100644 --- a/src/mbgl/renderer/painter_line.cpp +++ b/src/mbgl/renderer/painter_line.cpp @@ -20,11 +20,11 @@ void Painter::renderLine(PaintParameters& parameters, // Abort early. if (pass == RenderPass::Opaque) return; - config.stencilOp.reset(); - config.stencilTest = GL_TRUE; - config.depthFunc.reset(); - config.depthTest = GL_TRUE; - config.depthMask = GL_FALSE; + context.stencilOp.reset(); + context.stencilTest = GL_TRUE; + context.depthFunc.reset(); + context.depthTest = GL_TRUE; + context.depthMask = GL_FALSE; const auto& properties = layer.impl->paint; const auto& layout = bucket.layout; @@ -61,7 +61,7 @@ void Painter::renderLine(PaintParameters& parameters, auto& lineShader = parameters.shaders.line; if (!properties.lineDasharray.value.from.empty()) { - config.program = linesdfShader.getID(); + context.program = linesdfShader.getID(); linesdfShader.u_matrix = vtxMatrix; linesdfShader.u_linewidth = properties.lineWidth / 2; @@ -96,9 +96,9 @@ void Painter::renderLine(PaintParameters& parameters, linesdfShader.u_antialiasingmatrix = antialiasingMatrix; linesdfShader.u_image = 0; - lineAtlas->bind(store, config, 0); + lineAtlas->bind(store, context, 0); - bucket.drawLineSDF(linesdfShader, store, config, paintMode()); + bucket.drawLineSDF(linesdfShader, store, context, paintMode()); } else if (!properties.linePattern.value.from.empty()) { optional<SpriteAtlasPosition> imagePosA = spriteAtlas->getPosition( @@ -109,7 +109,7 @@ void Painter::renderLine(PaintParameters& parameters, if (!imagePosA || !imagePosB) return; - config.program = linepatternShader.getID(); + context.program = linepatternShader.getID(); linepatternShader.u_matrix = vtxMatrix; linepatternShader.u_linewidth = properties.lineWidth / 2; @@ -139,12 +139,12 @@ void Painter::renderLine(PaintParameters& parameters, linepatternShader.u_antialiasingmatrix = antialiasingMatrix; linepatternShader.u_image = 0; - spriteAtlas->bind(true, store, config, 0); + spriteAtlas->bind(true, store, context, 0); - bucket.drawLinePatterns(linepatternShader, store, config, paintMode()); + bucket.drawLinePatterns(linepatternShader, store, context, paintMode()); } else { - config.program = lineShader.getID(); + context.program = lineShader.getID(); lineShader.u_matrix = vtxMatrix; lineShader.u_linewidth = properties.lineWidth / 2; @@ -159,7 +159,7 @@ void Painter::renderLine(PaintParameters& parameters, lineShader.u_color = color; lineShader.u_opacity = opacity; - bucket.drawLines(lineShader, store, config, paintMode()); + bucket.drawLines(lineShader, store, context, paintMode()); } } diff --git a/src/mbgl/renderer/painter_raster.cpp b/src/mbgl/renderer/painter_raster.cpp index 8f6a1ac27b..16808f80a6 100644 --- a/src/mbgl/renderer/painter_raster.cpp +++ b/src/mbgl/renderer/painter_raster.cpp @@ -23,7 +23,7 @@ void Painter::renderRaster(PaintParameters& parameters, auto& rasterShader = parameters.shaders.raster; auto& rasterVAO = parameters.shaders.coveringRasterArray; - config.program = rasterShader.getID(); + context.program = rasterShader.getID(); rasterShader.u_matrix = tile.matrix; rasterShader.u_buffer_scale = 1.0f; rasterShader.u_opacity0 = properties.rasterOpacity; @@ -35,19 +35,19 @@ void Painter::renderRaster(PaintParameters& parameters, rasterShader.u_contrast_factor = contrastFactor(properties.rasterContrast); rasterShader.u_spin_weights = spinWeights(properties.rasterHueRotate); - config.stencilTest = GL_FALSE; + context.stencilTest = GL_FALSE; rasterShader.u_image0 = 0; // GL_TEXTURE0 rasterShader.u_image1 = 1; // GL_TEXTURE1 rasterShader.u_tl_parent = {{ 0.0f, 0.0f }}; rasterShader.u_scale_parent = 1.0f; - config.depthFunc.reset(); - config.depthTest = GL_TRUE; - config.depthMask = GL_FALSE; + context.depthFunc.reset(); + context.depthTest = GL_TRUE; + context.depthMask = GL_FALSE; setDepthSublayer(0); - bucket.drawRaster(rasterShader, rasterBoundsBuffer, rasterVAO, config, store); + bucket.drawRaster(rasterShader, rasterBoundsBuffer, rasterVAO, context, store); } } diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp index 2dded27c6c..635c81fbf7 100644 --- a/src/mbgl/renderer/painter_symbol.cpp +++ b/src/mbgl/renderer/painter_symbol.cpp @@ -20,7 +20,7 @@ void Painter::renderSDF(SymbolBucket& bucket, float sdfFontSize, std::array<float, 2> texsize, SDFShader& sdfShader, - void (SymbolBucket::*drawSDF)(SDFShader&, gl::ObjectStore&, gl::Config&, PaintMode), + void (SymbolBucket::*drawSDF)(SDFShader&, gl::ObjectStore&, gl::Context&, PaintMode), // Layout AlignmentType rotationAlignment, @@ -60,7 +60,7 @@ void Painter::renderSDF(SymbolBucket& bucket, }}; } - config.program = sdfShader.getID(); + context.program = sdfShader.getID(); sdfShader.u_matrix = vtxMatrix; sdfShader.u_extrude_scale = extrudeScale; sdfShader.u_texsize = texsize; @@ -76,7 +76,7 @@ void Painter::renderSDF(SymbolBucket& bucket, sdfShader.u_zoom = (state.getZoom() - zoomAdjust) * 10; // current zoom level - frameHistory.bind(store, config, 1); + frameHistory.bind(store, context, 1); sdfShader.u_fadetexture = 1; // The default gamma value has to be adjust for the current pixelratio so that we're not @@ -94,7 +94,7 @@ void Painter::renderSDF(SymbolBucket& bucket, sdfShader.u_color = haloColor; sdfShader.u_opacity = opacity; sdfShader.u_buffer = (haloOffset - haloWidth / fontScale) / sdfPx; - (bucket.*drawSDF)(sdfShader, store, config, paintMode()); + (bucket.*drawSDF)(sdfShader, store, context, paintMode()); } // Then, we draw the text/icon over the halo @@ -103,7 +103,7 @@ void Painter::renderSDF(SymbolBucket& bucket, sdfShader.u_color = color; sdfShader.u_opacity = opacity; sdfShader.u_buffer = (256.0f - 64.0f) / 256.0f; - (bucket.*drawSDF)(sdfShader, store, config, paintMode()); + (bucket.*drawSDF)(sdfShader, store, context, paintMode()); } } @@ -119,7 +119,7 @@ void Painter::renderSymbol(PaintParameters& parameters, const auto& paint = layer.impl->paint; const auto& layout = bucket.layout; - config.depthMask = GL_FALSE; + context.depthMask = GL_FALSE; // TODO remove the `true ||` when #1673 is implemented const bool drawAcrossEdges = (frame.mapMode == MapMode::Continuous) && (true || !(layout.textAllowOverlap || layout.iconAllowOverlap || @@ -131,20 +131,20 @@ void Painter::renderSymbol(PaintParameters& parameters, // layers are sorted in the y direction, and to draw the correct ordering near // tile edges the icons are included in both tiles and clipped when drawing. if (drawAcrossEdges) { - config.stencilTest = GL_FALSE; + context.stencilTest = GL_FALSE; } else { - config.stencilOp.reset(); - config.stencilTest = GL_TRUE; + context.stencilOp.reset(); + context.stencilTest = GL_TRUE; } setDepthSublayer(0); if (bucket.hasIconData()) { if (layout.iconRotationAlignment == AlignmentType::Map) { - config.depthFunc.reset(); - config.depthTest = GL_TRUE; + context.depthFunc.reset(); + context.depthTest = GL_TRUE; } else { - config.depthTest = GL_FALSE; + context.depthTest = GL_FALSE; } bool sdf = bucket.sdfIcons; @@ -160,7 +160,7 @@ void Painter::renderSymbol(PaintParameters& parameters, SpriteAtlas* activeSpriteAtlas = layer.impl->spriteAtlas; const bool iconScaled = fontScale != 1 || frame.pixelRatio != activeSpriteAtlas->getPixelRatio() || bucket.iconsNeedLinear; const bool iconTransformed = layout.iconRotationAlignment == AlignmentType::Map || angleOffset != 0 || state.getPitch() != 0; - activeSpriteAtlas->bind(sdf || state.isChanging() || iconScaled || iconTransformed, store, config, 0); + activeSpriteAtlas->bind(sdf || state.isChanging() || iconScaled || iconTransformed, store, context, 0); if (sdf) { renderSDF(bucket, @@ -201,7 +201,7 @@ void Painter::renderSymbol(PaintParameters& parameters, auto& iconShader = parameters.shaders.icon; - config.program = iconShader.getID(); + context.program = iconShader.getID(); iconShader.u_matrix = vtxMatrix; iconShader.u_extrude_scale = extrudeScale; iconShader.u_texsize = {{ float(activeSpriteAtlas->getWidth()) / 4.0f, float(activeSpriteAtlas->getHeight()) / 4.0f }}; @@ -213,22 +213,22 @@ void Painter::renderSymbol(PaintParameters& parameters, iconShader.u_zoom = (state.getZoom() - zoomAdjust) * 10; // current zoom level iconShader.u_opacity = paint.iconOpacity; - frameHistory.bind(store, config, 1); + frameHistory.bind(store, context, 1); iconShader.u_fadetexture = 1; - bucket.drawIcons(iconShader, store, config, paintMode()); + bucket.drawIcons(iconShader, store, context, paintMode()); } } if (bucket.hasTextData()) { if (layout.textPitchAlignment == AlignmentType::Map) { - config.depthFunc.reset(); - config.depthTest = GL_TRUE; + context.depthFunc.reset(); + context.depthTest = GL_TRUE; } else { - config.depthTest = GL_FALSE; + context.depthTest = GL_FALSE; } - glyphAtlas->bind(store, config, 0); + glyphAtlas->bind(store, context, 0); renderSDF(bucket, tile, @@ -250,19 +250,19 @@ void Painter::renderSymbol(PaintParameters& parameters, } if (bucket.hasCollisionBoxData()) { - config.stencilOp.reset(); - config.stencilTest = GL_TRUE; + context.stencilOp.reset(); + context.stencilTest = GL_TRUE; auto& collisionBoxShader = shaders->collisionBox; - config.program = collisionBoxShader.getID(); + context.program = collisionBoxShader.getID(); collisionBoxShader.u_matrix = tile.matrix; // TODO: This was the overscaled z instead of the canonical z. collisionBoxShader.u_scale = std::pow(2, state.getZoom() - tile.id.canonical.z); collisionBoxShader.u_zoom = state.getZoom() * 10; collisionBoxShader.u_maxzoom = (tile.id.canonical.z + 1) * 10; - config.lineWidth = 1.0f; + context.lineWidth = 1.0f; - bucket.drawCollisionBoxes(collisionBoxShader, store, config); + bucket.drawCollisionBoxes(collisionBoxShader, store, context); } } diff --git a/src/mbgl/renderer/raster_bucket.cpp b/src/mbgl/renderer/raster_bucket.cpp index d167f1605b..32db44f16b 100644 --- a/src/mbgl/renderer/raster_bucket.cpp +++ b/src/mbgl/renderer/raster_bucket.cpp @@ -7,9 +7,9 @@ namespace mbgl { using namespace style; -void RasterBucket::upload(gl::ObjectStore& store, gl::Config& config) { +void RasterBucket::upload(gl::ObjectStore& store, gl::Context& context) { if (hasData()) { - raster.upload(store, config, 0); + raster.upload(store, context, 0); uploaded = true; } } @@ -28,11 +28,11 @@ void RasterBucket::setImage(PremultipliedImage image) { void RasterBucket::drawRaster(RasterShader& shader, StaticRasterVertexBuffer& vertices, VertexArrayObject& array, - gl::Config& config, + gl::Context& context, gl::ObjectStore& store) { - raster.bind(store, config, 0, Raster::Scaling::Linear); - raster.bind(store, config, 1, Raster::Scaling::Linear); - array.bind(shader, vertices, BUFFER_OFFSET_0, store, config); + raster.bind(store, context, 0, Raster::Scaling::Linear); + raster.bind(store, context, 1, Raster::Scaling::Linear); + array.bind(shader, vertices, BUFFER_OFFSET_0, store, context); MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)vertices.index())); } diff --git a/src/mbgl/renderer/raster_bucket.hpp b/src/mbgl/renderer/raster_bucket.hpp index e212b9ecea..68dc3f0ad5 100644 --- a/src/mbgl/renderer/raster_bucket.hpp +++ b/src/mbgl/renderer/raster_bucket.hpp @@ -2,7 +2,7 @@ #include <mbgl/renderer/bucket.hpp> #include <mbgl/util/raster.hpp> -#include <mbgl/gl/gl_config.hpp> +#include <mbgl/gl/context.hpp> namespace mbgl { @@ -12,14 +12,14 @@ class VertexArrayObject; class RasterBucket : public Bucket { public: - void upload(gl::ObjectStore&, gl::Config&) override; + void upload(gl::ObjectStore&, gl::Context&) override; void render(Painter&, PaintParameters&, const style::Layer&, const RenderTile&) override; bool hasData() const override; bool needsClipping() const override; void setImage(PremultipliedImage); - void drawRaster(RasterShader&, StaticRasterVertexBuffer&, VertexArrayObject&, gl::Config&, gl::ObjectStore&); + void drawRaster(RasterShader&, StaticRasterVertexBuffer&, VertexArrayObject&, gl::Context&, gl::ObjectStore&); Raster raster; }; diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index f7fd34cd84..a692281fa6 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -19,14 +19,14 @@ SymbolBucket::SymbolBucket(const MapMode mode_, iconsNeedLinear(iconsNeedLinear_) { } -void SymbolBucket::upload(gl::ObjectStore& store, gl::Config& config) { +void SymbolBucket::upload(gl::ObjectStore& store, gl::Context& context) { if (hasTextData()) { - text.vertices.upload(store, config); - text.triangles.upload(store, config); + text.vertices.upload(store, context); + text.triangles.upload(store, context); } if (hasIconData()) { - icon.vertices.upload(store, config); - icon.triangles.upload(store, config); + icon.vertices.upload(store, context); + icon.triangles.upload(store, context); } uploaded = true; @@ -62,14 +62,14 @@ bool SymbolBucket::needsClipping() const { void SymbolBucket::drawGlyphs(SDFShader& shader, gl::ObjectStore& store, - gl::Config& config, + gl::Context& context, PaintMode paintMode) { GLbyte* vertex_index = BUFFER_OFFSET_0; GLbyte* elements_index = BUFFER_OFFSET_0; for (auto& group : text.groups) { assert(group); group->array[paintMode == PaintMode::Overdraw ? 1 : 0].bind( - shader, text.vertices, text.triangles, vertex_index, store, config); + shader, text.vertices, text.triangles, vertex_index, store, context); MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT, elements_index)); vertex_index += group->vertex_length * text.vertices.itemSize; @@ -79,14 +79,14 @@ void SymbolBucket::drawGlyphs(SDFShader& shader, void SymbolBucket::drawIcons(SDFShader& shader, gl::ObjectStore& store, - gl::Config& config, + gl::Context& context, PaintMode paintMode) { GLbyte* vertex_index = BUFFER_OFFSET_0; GLbyte* elements_index = BUFFER_OFFSET_0; for (auto& group : icon.groups) { assert(group); group->array[paintMode == PaintMode::Overdraw ? 1 : 0].bind( - shader, icon.vertices, icon.triangles, vertex_index, store, config); + shader, icon.vertices, icon.triangles, vertex_index, store, context); MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT, elements_index)); vertex_index += group->vertex_length * icon.vertices.itemSize; @@ -96,14 +96,14 @@ void SymbolBucket::drawIcons(SDFShader& shader, void SymbolBucket::drawIcons(IconShader& shader, gl::ObjectStore& store, - gl::Config& config, + gl::Context& context, PaintMode paintMode) { GLbyte* vertex_index = BUFFER_OFFSET_0; GLbyte* elements_index = BUFFER_OFFSET_0; for (auto& group : icon.groups) { assert(group); group->array[paintMode == PaintMode::Overdraw ? 3 : 2].bind( - shader, icon.vertices, icon.triangles, vertex_index, store, config); + shader, icon.vertices, icon.triangles, vertex_index, store, context); MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT, elements_index)); vertex_index += group->vertex_length * icon.vertices.itemSize; @@ -113,10 +113,10 @@ void SymbolBucket::drawIcons(IconShader& shader, void SymbolBucket::drawCollisionBoxes(CollisionBoxShader& shader, gl::ObjectStore& store, - gl::Config& config) { + gl::Context& context) { GLbyte* vertex_index = BUFFER_OFFSET_0; for (auto& group : collisionBox.groups) { - group->array[0].bind(shader, collisionBox.vertices, vertex_index, store, config); + group->array[0].bind(shader, collisionBox.vertices, vertex_index, store, context); MBGL_CHECK_ERROR(glDrawArrays(GL_LINES, 0, group->vertex_length)); } } diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp index 5384979ebe..a915df5424 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -25,7 +25,7 @@ public: bool sdfIcons, bool iconsNeedLinear); - void upload(gl::ObjectStore&, gl::Config&) override; + void upload(gl::ObjectStore&, gl::Context&) override; void render(Painter&, PaintParameters&, const style::Layer&, const RenderTile&) override; bool hasData() const override; bool hasTextData() const; @@ -33,10 +33,10 @@ public: bool hasCollisionBoxData() const; bool needsClipping() const override; - void drawGlyphs(SDFShader&, gl::ObjectStore&, gl::Config&, PaintMode); - void drawIcons(SDFShader&, gl::ObjectStore&, gl::Config&, PaintMode); - void drawIcons(IconShader&, gl::ObjectStore&, gl::Config&, PaintMode); - void drawCollisionBoxes(CollisionBoxShader&, gl::ObjectStore&, gl::Config&); + void drawGlyphs(SDFShader&, gl::ObjectStore&, gl::Context&, PaintMode); + void drawIcons(SDFShader&, gl::ObjectStore&, gl::Context&, PaintMode); + void drawIcons(IconShader&, gl::ObjectStore&, gl::Context&, PaintMode); + void drawCollisionBoxes(CollisionBoxShader&, gl::ObjectStore&, gl::Context&); const MapMode mode; const style::SymbolLayoutProperties layout; |