From 1ce0ca0b7a38218e53601b0b1e9d72a3ff55e52e Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Fri, 16 Jan 2015 13:37:13 -0500 Subject: [PATCH] add warning when line atlas is overflowed --- src/mbgl/geometry/line_atlas.cpp | 6 ++++-- src/mbgl/geometry/line_atlas.hpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp index 7485ef31a..5cfb67021 100644 --- a/src/mbgl/geometry/line_atlas.cpp +++ b/src/mbgl/geometry/line_atlas.cpp @@ -33,7 +33,6 @@ LinePatternPos LineAtlas::getDashPosition(const std::vector &dasharray, b std::string key = sskey.str(); if (positions.find(key) == positions.end()) { - //fprintf(stderr, "add %s\n", key.c_str()); positions[key] = addDash(dasharray, round); } @@ -46,7 +45,10 @@ LinePatternPos LineAtlas::addDash(const std::vector &dasharray, bool roun int dashheight = 2 * n + 1; const uint8_t offset = 128; - // TODO check if enough space + if (nextRow + dashheight > height) { + fprintf(stderr, "[WARNING] line atlas bitmap overflow\n"); + return LinePatternPos(); + } float length = 0; for (const float &part : dasharray) { diff --git a/src/mbgl/geometry/line_atlas.hpp b/src/mbgl/geometry/line_atlas.hpp index 329c907b1..191dc0c4d 100644 --- a/src/mbgl/geometry/line_atlas.hpp +++ b/src/mbgl/geometry/line_atlas.hpp @@ -32,7 +32,7 @@ private: char *const data = nullptr; std::atomic dirty; uint32_t texture = 0; - uint32_t nextRow = 0; + int nextRow = 0; std::map positions; };