Merge pull request #280 from mapbox/quiet-release

Quiet release mode
This commit is contained in:
Konstantin Käfer
2014-05-30 11:19:05 +02:00
14 changed files with 63 additions and 12 deletions

View File

@@ -137,6 +137,8 @@ void GlyphAtlas::bind() {
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data);
dirty = false;
#if defined(DEBUG)
// platform::show_debug_image("Glyph Atlas", data, width, height);
#endif
}
};

View File

@@ -270,8 +270,9 @@ void SpriteAtlas::bind(bool linear) {
data // const GLvoid * data
);
#if defined(DEBUG)
// platform::show_color_debug_image("Sprite Atlas", data, width, height, width * pixelRatio, height * pixelRatio);
#endif
dirty = false;
}
};

View File

@@ -479,8 +479,9 @@ void Map::prepare() {
}
void Map::render() {
#if defined(DEBUG)
std::vector<std::string> debug;
#endif
painter.clear();
painter.resetFramebuffer();
@@ -493,6 +494,7 @@ void Map::render() {
painter.drawClippingMasks(sources);
#if defined(DEBUG)
// Generate debug information
size_t source_id = 0;
for (const auto &pair : sources) {
@@ -501,7 +503,7 @@ void Map::render() {
debug.emplace_back(util::sprintf<100>("source %d: %d\n", source_id, count));
source_id++;
}
#endif
// Actually render the layers
if (debug::renderTree) { std::cout << "{" << std::endl; indent++; }
renderLayers(style.layers);
@@ -520,7 +522,9 @@ void Map::render() {
painter.renderMatte();
#if defined(DEBUG)
painter.renderDebugText(debug);
#endif
// Schedule another rerender when we definitely need a next frame.
if (transform.needsTransition()) {
@@ -573,12 +577,14 @@ void Map::renderLayers(const std::vector<LayerDescription>& layers) {
template <typename Styles>
typename Styles::const_iterator find_style(const Styles &styles, const LayerDescription &layer_desc) {
auto it = styles.find(layer_desc.name);
#if defined(DEBUG)
if (it == styles.end()) {
if (debug::renderWarnings) {
fprintf(stderr, "[WARNING] can't find class named '%s' in style\n",
layer_desc.name.c_str());
}
}
#endif
return it;
}

View File

@@ -42,7 +42,9 @@ void TileData::request() {
// Schedule tile parsing in another thread
tile->reparse();
} else {
#if defined(DEBUG)
fprintf(stderr, "[%s] tile loading failed: %d, %s\n", tile->url.c_str(), res->code, res->error_message.c_str());
#endif
}
}, map.getLoop());
}

View File

@@ -24,7 +24,9 @@ void VectorTileData::parse() {
// is going to be discarded afterwards.
TileParser parser(data, *this, map.getStyle(), map.getGlyphAtlas(), map.getGlyphStore(), map.getSpriteAtlas());
} catch (const std::exception& ex) {
#if defined(DEBUG)
fprintf(stderr, "[%p] exception [%d/%d/%d]... failed: %s\n", this, id.z, id.x, id.y, ex.what());
#endif
cancel();
return;
}

View File

@@ -182,18 +182,24 @@ void FillBucket::tessellate() {
if (a != TESS_UNDEF && b != TESS_UNDEF && c != TESS_UNDEF) {
triangleElementsBuffer.add(triangleIndex + a, triangleIndex + b, triangleIndex + c);
} else {
#if defined(DEBUG)
// TODO: We're missing a vertex that was not part of the line.
fprintf(stderr, "undefined element buffer\n");
#endif
}
} else {
#if defined(DEBUG)
fprintf(stderr, "undefined element buffer\n");
#endif
}
}
triangleGroup.vertex_length += total_vertex_count;
triangleGroup.elements_length += triangle_count;
} else {
#if defined(DEBUG)
fprintf(stderr, "tessellation failed\n");
#endif
}
// We're adding the total vertex count *after* we added additional vertices

View File

@@ -1,13 +1,13 @@
#include <llmr/renderer/painter.hpp>
#include <llmr/map/map.hpp>
#include <llmr/util/std.hpp>
#include <llmr/util/string.hpp>
#include <llmr/util/timer.hpp>
#include <llmr/util/time.hpp>
#include <llmr/util/clip_ids.hpp>
#include <llmr/util/constants.hpp>
#if defined(DEBUG)
#include <llmr/util/timer.hpp>
#endif
#include <cassert>
#include <algorithm>
@@ -29,8 +29,9 @@ bool Painter::needsAnimation() const {
}
void Painter::setup() {
#if defined(DEBUG)
util::timer timer("painter setup");
#endif
setupShaders();
assert(iconShader);

View File

@@ -1,6 +1,7 @@
#include <llmr/renderer/painter.hpp>
#include <llmr/renderer/text_bucket.hpp>
#include <llmr/map/map.hpp>
#include <cmath>
using namespace llmr;
@@ -66,8 +67,7 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons
history[0].z = history[1].z;
}
size_t frameLen = history.size();
assert("there should never be less than three frames in the history" && frameLen >= 3);
assert("there should never be less than three frames in the history" && (history.size() >= 3));
// Find the range of zoom levels we want to fade between
float startingZ = history.front().z;
@@ -81,7 +81,9 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons
timeDiff = lastFrame.timestamp - history[1].timestamp;
float fadedist = zoomDiff / (timeDiff / duration);
if (isnan(fadedist)) fprintf(stderr, "fadedist should never be NaN\n");
#if defined(DEBUG)
if (std::isnan(fadedist)) fprintf(stderr, "fadedist should never be NaN\n");
#endif
// At end of a zoom when the zoom stops changing continue pretending to zoom at that speed
// bump is how much farther it would have been if it had continued zooming at the same rate

View File

@@ -12,7 +12,9 @@ GaussianShader::GaussianShader()
shaders[GAUSSIAN_SHADER].fragment
) {
if (!valid) {
#if defined(DEBUG)
fprintf(stderr, "invalid raster shader\n");
#endif
return;
}

View File

@@ -12,7 +12,9 @@ RasterShader::RasterShader()
shaders[RASTER_SHADER].fragment
) {
if (!valid) {
#if defined(DEBUG)
fprintf(stderr, "invalid raster shader\n");
#endif
return;
}

View File

@@ -1,7 +1,8 @@
#include <llmr/shader/shader.hpp>
#include <llmr/platform/gl.hpp>
#if defined(DEBUG)
#include <llmr/util/timer.hpp>
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
@@ -11,18 +12,23 @@ using namespace llmr;
Shader::Shader(const GLchar *vertSource, const GLchar *fragSource)
: valid(false),
program(0) {
#if defined(DEBUG)
util::timer timer("shader compilation");
#endif
GLuint vertShader;
if (!compileShader(&vertShader, GL_VERTEX_SHADER, vertSource)) {
#if defined(DEBUG)
fprintf(stderr, "Vertex shader failed to compile: %s\n", vertSource);
#endif
return;
}
GLuint fragShader;
if (!compileShader(&fragShader, GL_FRAGMENT_SHADER, fragSource)) {
#if defined(DEBUG)
fprintf(stderr, "Fragment shader failed to compile: %s\n", fragSource);
#endif
return;
}
@@ -80,7 +86,9 @@ Shader::Shader(const GLchar *vertSource, const GLchar *fragSource)
glGetProgramiv(program, GL_VALIDATE_STATUS, &status);
if (status == 0) {
#if defined(DEBUG)
fprintf(stderr, "Program failed to validate\n");
#endif
glDeleteShader(vertShader);
vertShader = 0;
glDeleteShader(fragShader);

View File

@@ -54,7 +54,9 @@ void Sprite::complete(std::shared_ptr<Sprite> &sprite) {
if (sprite->raster && sprite->pos.size()) {
sprite->loaded = true;
sprite->map.update();
#if defined(DEBUG)
fprintf(stderr, "sprite loaded\n");
#endif
}
}

View File

@@ -52,7 +52,9 @@ GlyphPBF::GlyphPBF(const std::string &fontStack, GlyphRange glyphRange)
// TODO: Find more reliable URL normalization function
std::replace(url.begin(), url.end(), ' ', '+');
#if defined(DEBUG)
fprintf(stderr, "%s\n", url.c_str());
#endif
platform::request_http(url, [&](platform::Response *res) {
if (res->code != 200) {

View File

@@ -2,6 +2,7 @@
const float llmr::util::tileSize = 512.0f;
#if defined(DEBUG)
const bool llmr::debug::tileParseWarnings = false;
const bool llmr::debug::styleParseWarnings = false;
const bool llmr::debug::spriteWarnings = false;
@@ -12,3 +13,15 @@ const bool llmr::debug::missingFontStackWarning = true;
const bool llmr::debug::missingFontFaceWarning = true;
const bool llmr::debug::glyphWarning = true;
const bool llmr::debug::shapingWarning = true;
#else
const bool llmr::debug::tileParseWarnings = false;
const bool llmr::debug::styleParseWarnings = false;
const bool llmr::debug::spriteWarnings = false;
const bool llmr::debug::renderWarnings = false;
const bool llmr::debug::renderTree = false;
const bool llmr::debug::labelTextMissingWarning = false;
const bool llmr::debug::missingFontStackWarning = false;
const bool llmr::debug::missingFontFaceWarning = false;
const bool llmr::debug::glyphWarning = false;
const bool llmr::debug::shapingWarning = false;
#endif