From c111250fcccaf5e57154852606ee740f0db242c1 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 25 May 2016 23:56:52 +0300 Subject: [core] s/operator bool/created()/ in {GL,TexturePool}Holder Prevents confusing usage of GL holder objects. --- src/mbgl/geometry/buffer.hpp | 6 +++--- src/mbgl/geometry/glyph_atlas.cpp | 4 ++-- src/mbgl/geometry/line_atlas.cpp | 2 +- src/mbgl/geometry/vao.cpp | 4 +++- src/mbgl/geometry/vao.hpp | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/mbgl/geometry') diff --git a/src/mbgl/geometry/buffer.hpp b/src/mbgl/geometry/buffer.hpp index e8e2788f51..80fde61702 100644 --- a/src/mbgl/geometry/buffer.hpp +++ b/src/mbgl/geometry/buffer.hpp @@ -36,7 +36,7 @@ public: // Transfers this buffer to the GPU and binds the buffer to the GL context. void bind(gl::GLObjectStore& glObjectStore) { - if (buffer) { + if (buffer.created()) { MBGL_CHECK_ERROR(glBindBuffer(bufferType, getID())); } else { buffer.create(glObjectStore); @@ -65,7 +65,7 @@ public: // Uploads the buffer to the GPU to be available when we need it. inline void upload(gl::GLObjectStore& glObjectStore) { - if (!buffer) { + if (!buffer.created()) { bind(glObjectStore); } } @@ -73,7 +73,7 @@ public: protected: // increase the buffer size by at least /required/ bytes. inline void *addElement() { - if (buffer) { + if (buffer.created()) { throw std::runtime_error("Can't add elements after buffer was bound to GPU"); } if (length < pos + itemSize) { diff --git a/src/mbgl/geometry/glyph_atlas.cpp b/src/mbgl/geometry/glyph_atlas.cpp index fd43fb8c18..1b0f4bc7e4 100644 --- a/src/mbgl/geometry/glyph_atlas.cpp +++ b/src/mbgl/geometry/glyph_atlas.cpp @@ -144,7 +144,7 @@ void GlyphAtlas::removeGlyphs(uintptr_t tileUID) { void GlyphAtlas::upload(gl::GLObjectStore& glObjectStore) { if (dirty) { - const bool first = !texture; + const bool first = !texture.created(); bind(glObjectStore); std::lock_guard lock(mtx); @@ -184,7 +184,7 @@ void GlyphAtlas::upload(gl::GLObjectStore& glObjectStore) { } void GlyphAtlas::bind(gl::GLObjectStore& glObjectStore) { - if (!texture) { + if (!texture.created()) { texture.create(glObjectStore); MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture.getID())); #ifndef GL_ES_VERSION_2_0 diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp index 1213b8d778..614e3280c7 100644 --- a/src/mbgl/geometry/line_atlas.cpp +++ b/src/mbgl/geometry/line_atlas.cpp @@ -129,7 +129,7 @@ void LineAtlas::upload(gl::GLObjectStore& glObjectStore) { void LineAtlas::bind(gl::GLObjectStore& glObjectStore) { bool first = false; - if (!texture) { + if (!texture.created()) { texture.create(glObjectStore); MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture.getID())); MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); diff --git a/src/mbgl/geometry/vao.cpp b/src/mbgl/geometry/vao.cpp index 8239604264..c438fbd2e6 100644 --- a/src/mbgl/geometry/vao.cpp +++ b/src/mbgl/geometry/vao.cpp @@ -26,7 +26,9 @@ void VertexArrayObject::bindVertexArrayObject(gl::GLObjectStore& glObjectStore) return; } - if (!vao) vao.create(glObjectStore); + if (!vao.created()) { + vao.create(glObjectStore); + } MBGL_CHECK_ERROR(gl::BindVertexArray(vao.getID())); } diff --git a/src/mbgl/geometry/vao.hpp b/src/mbgl/geometry/vao.hpp index 8e9e417c1c..8bc3750590 100644 --- a/src/mbgl/geometry/vao.hpp +++ b/src/mbgl/geometry/vao.hpp @@ -24,7 +24,7 @@ public: if (bound_shader == 0) { vertexBuffer.bind(glObjectStore); shader.bind(offset); - if (vao) { + if (vao.created()) { storeBinding(shader, vertexBuffer.getID(), 0, offset); } } else { @@ -39,7 +39,7 @@ public: vertexBuffer.bind(glObjectStore); elementsBuffer.bind(glObjectStore); shader.bind(offset); - if (vao) { + if (vao.created()) { storeBinding(shader, vertexBuffer.getID(), elementsBuffer.getID(), offset); } } else { -- cgit v1.2.1