diff --git a/include/mbgl/geometry/glyph_atlas.hpp b/include/mbgl/geometry/glyph_atlas.hpp index 639c6cc51..7b3c223fe 100644 --- a/include/mbgl/geometry/glyph_atlas.hpp +++ b/include/mbgl/geometry/glyph_atlas.hpp @@ -28,8 +28,6 @@ private: const SDFGlyph& glyph); public: GlyphAtlas(uint16_t width, uint16_t height); - ~GlyphAtlas(); - Rect addGlyph(uint64_t tile_id, const std::string& face_name, const SDFGlyph& glyph); @@ -46,7 +44,7 @@ private: std::mutex mtx; BinPack bin; std::map> index; - char *const data = nullptr; + std::unique_ptr data; std::atomic dirty; uint32_t texture = 0; }; diff --git a/src/geometry/glyph_atlas.cpp b/src/geometry/glyph_atlas.cpp index 72c961fda..50bda5dc4 100644 --- a/src/geometry/glyph_atlas.cpp +++ b/src/geometry/glyph_atlas.cpp @@ -17,10 +17,6 @@ GlyphAtlas::GlyphAtlas(uint16_t width_, uint16_t height_) dirty(true) { } -GlyphAtlas::~GlyphAtlas() { - delete[] data; -} - Rect GlyphAtlas::addGlyph(uint64_t tile_id, const std::string& face_name, const SDFGlyph& glyph) { @@ -74,7 +70,7 @@ Rect GlyphAtlas::addGlyph_impl(uint64_t tile_id, const std::string& fa face.emplace(glyph.id, GlyphValue { rect, tile_id }); // Copy the bitmap - char *target = data; + char *target = data.get(); const char *source = glyph.bitmap.data(); for (uint32_t y = 0; y < buffered_height; y++) { uint32_t y1 = width * (rect.y + y) + rect.x; @@ -119,7 +115,7 @@ void GlyphAtlas::removeGlyphs(uint64_t tile_id) { const Rect& rect = value.rect; // Clear out the bitmap. - char *target = data; + char *target = data.get(); for (uint32_t y = 0; y < rect.h; y++) { uint32_t y1 = width * (rect.y + y) + rect.x; for (uint32_t x = 0; x < rect.w; x++) { @@ -157,7 +153,7 @@ void GlyphAtlas::bind() { if (dirty) { std::lock_guard lock(mtx); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data); + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data.get()); dirty = false; #if defined(DEBUG)