diff --git a/Makefile b/Makefile index fe44e914d..c8d11b407 100644 --- a/Makefile +++ b/Makefile @@ -25,11 +25,11 @@ build/test/Makefile: src common config.gypi test/test.gyp deps/run_gyp test/test.gyp --depth=. -Goutput_dir=.. --generator-output=./build/test -f make test: build/test/Makefile - $(MAKE) -C build/test BUILDTYPE=Testing V=$(V) test + $(MAKE) -C build/test BUILDTYPE=$(BUILDTYPE) V=$(V) test test_%: build/test/Makefile - $(MAKE) -C build/test BUILDTYPE=Testing V=$(V) $* - (cd build/Testing && exec ./test_$*) + $(MAKE) -C build/test BUILDTYPE=$(BUILDTYPE) V=$(V) $* + (cd build/$(BUILDTYPE) && exec ./test_$*) # build Mac OS X project for Xcode xtest: config.gypi clear_xcode_cache node diff --git a/common.gypi b/common.gypi index 513d8688f..5d02a71c1 100644 --- a/common.gypi +++ b/common.gypi @@ -34,16 +34,6 @@ 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' } }, - 'Testing': { - 'cflags_cc': [ '-O3' ], - 'defines': [ 'NDEBUG', 'TESTING' ], - 'xcode_settings': { - 'GCC_OPTIMIZATION_LEVEL': '3', - 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO', - 'DEAD_CODE_STRIPPING': 'YES', - 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' - } - } } } } diff --git a/include/mbgl/geometry/elements_buffer.hpp b/include/mbgl/geometry/elements_buffer.hpp index 1282beb23..56080e29f 100644 --- a/include/mbgl/geometry/elements_buffer.hpp +++ b/include/mbgl/geometry/elements_buffer.hpp @@ -3,13 +3,14 @@ #include #include +#include #include namespace mbgl { template -struct ElementGroup { +struct ElementGroup : public util::noncopyable { std::array array; uint32_t vertex_length; uint32_t elements_length; @@ -19,6 +20,11 @@ struct ElementGroup { : vertex_length(vertex_length), elements_length(elements_length) { } + + ElementGroup(ElementGroup &&rhs) noexcept + : array(std::move(rhs.array)), + vertex_length(rhs.vertex_length), + elements_length(rhs.elements_length) {}; }; class TriangleElementsBuffer : public Buffer< diff --git a/include/mbgl/geometry/vao.hpp b/include/mbgl/geometry/vao.hpp index 87408ddba..bb1f571ff 100644 --- a/include/mbgl/geometry/vao.hpp +++ b/include/mbgl/geometry/vao.hpp @@ -3,14 +3,25 @@ #include #include +#include #include namespace mbgl { #if GL_ARB_vertex_array_object -class VertexArrayObject { +class VertexArrayObject : public util::noncopyable { public: + inline VertexArrayObject() {}; + + inline VertexArrayObject(VertexArrayObject &&rhs) noexcept + : vao(rhs.vao), + bound_shader(rhs.bound_shader), + bound_shader_name(rhs.bound_shader_name), + bound_vertex_buffer(rhs.bound_vertex_buffer), + bound_elements_buffer(rhs.bound_elements_buffer), + bound_offset(rhs.bound_offset) {}; + template inline void bind(Shader& shader, VertexBuffer &vertexBuffer, char *offset) { bindVertexArrayObject(); @@ -56,7 +67,7 @@ private: #else -class VertexArrayObject { +class VertexArrayObject : public util::noncopyable { public: template void bind(Shader& shader, Buffers& buffers, char *offset) { diff --git a/include/mbgl/platform/event.hpp b/include/mbgl/platform/event.hpp index 01a23aa25..1676f40d2 100644 --- a/include/mbgl/platform/event.hpp +++ b/include/mbgl/platform/event.hpp @@ -10,7 +10,6 @@ namespace mbgl { enum class EventSeverity : uint8_t { Debug, Info, - Test, Warning, Error, }; @@ -18,7 +17,6 @@ enum class EventSeverity : uint8_t { MBGL_DEFINE_ENUM_CLASS(EventSeverityClass, EventSeverity, { { EventSeverity::Debug, "DEBUG" }, { EventSeverity::Info, "INFO" }, - { EventSeverity::Test, "TEST" }, { EventSeverity::Warning, "WARNING" }, { EventSeverity::Error, "ERROR" }, { EventSeverity(-1), "UNKNOWN" }, @@ -61,9 +59,6 @@ constexpr EventSeverity disabledEventSeverities[] = { #if !DEBUG EventSeverity::Debug, #endif -#if !TESTING - EventSeverity::Test, -#endif }; diff --git a/include/mbgl/renderer/fill_bucket.hpp b/include/mbgl/renderer/fill_bucket.hpp index e8d6bf99e..15868e409 100644 --- a/include/mbgl/renderer/fill_bucket.hpp +++ b/include/mbgl/renderer/fill_bucket.hpp @@ -36,6 +36,7 @@ class FillBucket : public Bucket { typedef ElementGroup<2> triangle_group_type; typedef ElementGroup<1> line_group_type; + public: FillBucket(FillVertexBuffer& vertexBuffer, TriangleElementsBuffer& triangleElementsBuffer, diff --git a/include/mbgl/renderer/line_bucket.hpp b/include/mbgl/renderer/line_bucket.hpp index a33dde34e..c7e375a0a 100644 --- a/include/mbgl/renderer/line_bucket.hpp +++ b/include/mbgl/renderer/line_bucket.hpp @@ -22,6 +22,7 @@ struct pbf; class LineBucket : public Bucket { typedef ElementGroup<1> triangle_group_type; typedef ElementGroup<1> point_group_type; + public: LineBucket(LineVertexBuffer& vertexBuffer, TriangleElementsBuffer& triangleElementsBuffer, @@ -43,7 +44,6 @@ public: const StyleBucketLine &properties; private: - LineVertexBuffer& vertexBuffer; TriangleElementsBuffer& triangleElementsBuffer; PointElementsBuffer& pointElementsBuffer; diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp index eb5f42789..fcbafc52d 100644 --- a/include/mbgl/renderer/painter.hpp +++ b/include/mbgl/renderer/painter.hpp @@ -184,12 +184,9 @@ public: }; VertexArrayObject coveringPlainArray; - VertexArrayObject coveringPatternArray; VertexArrayObject coveringRasterArray; VertexArrayObject coveringGaussianArray; - VertexArrayObject matteArray; - // Set up the tile boundary lines we're using to draw the tile outlines. StaticVertexBuffer tileBorderBuffer = { { 0, 0 }, diff --git a/include/mbgl/util/url.hpp b/include/mbgl/util/url.hpp index 14d9dd316..a7e5291ec 100644 --- a/include/mbgl/util/url.hpp +++ b/include/mbgl/util/url.hpp @@ -7,6 +7,7 @@ namespace mbgl { namespace util { std::string percentEncode(const std::string&); +std::string percentDecode(const std::string&); } } diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index e1c709a8d..8a315662b 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit e1c709a8de0b69aa6bfbcd9ea4faf981b6e799b2 +Subproject commit 8a315662b365566cb37b3c9f13da6d6730d0abdb diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 716594824..dd9ee3f26 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -3,7 +3,7 @@ set -e set -o pipefail -cd build/Testing +cd build/${BUILDTYPE:-Release} for TEST in ./test_* ; do ${TEST} diff --git a/scripts/travis_script.sh b/scripts/travis_script.sh index f8325e41c..f1cad6b9d 100755 --- a/scripts/travis_script.sh +++ b/scripts/travis_script.sh @@ -10,7 +10,11 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then make linux -j4 BUILDTYPE=${BUILDTYPE} make test -j4 BUILDTYPE=${BUILDTYPE} ./scripts/run_tests.sh - (cd ./node_modules/mapbox-gl-test-suite/ && (./bin/compare_images.js || true; [[ $TRAVIS_PULL_REQUEST = "false" ]] && ./bin/deploy_results.sh)) + (cd ./node_modules/mapbox-gl-test-suite/ && (./bin/compare_images.js || true)) + + if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then + (cd ./node_modules/mapbox-gl-test-suite/ && ./bin/deploy_results.sh) + fi elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then # diff --git a/setup-libraries.sh b/setup-libraries.sh index cbc89a102..3db28a0d2 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -118,7 +118,7 @@ export LIBUV_VERSION=0.10.28 ./scripts/make_universal.sh -if [[ $TRAVIS_PULL_REQUEST = "false" ]]; then +if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then tar -zcf out/build-cpp11-libcpp-universal_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libcpp-universal aws s3 cp --acl public-read out/build-cpp11-libcpp-universal_${MP_HASH}_${DIR_HASH}.tar.gz s3://${AWS_S3_BUCKET}/dependencies/ fi @@ -150,7 +150,7 @@ export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libboost_regex.a ] ; then ./scripts/build_boost.sh --with-regex ; fi -if [[ $TRAVIS_PULL_REQUEST = "false" ]]; then +if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then if ! tar --compare -zf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ; then tar -zcf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz out/build-cpp11-libstdcpp-gcc-x86_64-linux aws s3 cp --acl public-read out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz s3://${AWS_S3_BUCKET}/dependencies/ diff --git a/src/renderer/painter_symbol.cpp b/src/renderer/painter_symbol.cpp index 66961b318..c2d62bec7 100644 --- a/src/renderer/painter_symbol.cpp +++ b/src/renderer/painter_symbol.cpp @@ -56,45 +56,38 @@ void Painter::renderSymbol(SymbolBucket &bucket, std::shared_ptr lay const timestamp currentTime = util::now(); std::deque &history = frameHistory.history; + if (history.size() >= 2) { + // Remove frames until only one is outside the duration, or until there are only three + while (history.size() > 3 && history[1].t + duration < currentTime) { + history.pop_front(); + } - // Remove frames until only one is outside the duration, or until there are only three - while (history.size() > 3 && history[1].t + duration < currentTime) { - history.pop_front(); + if (history[1].t + duration < currentTime) { + history[0].z = history[1].z; + } + + // Find the range of zoom levels we want to fade between + float startingZ = history.front().z; + const FrameSnapshot lastFrame = history.back(); + float endingZ = lastFrame.z; + float lowZ = std::fmin(startingZ, endingZ); + float highZ = std::fmax(startingZ, endingZ); + + // Calculate the speed of zooming, and how far it would zoom in terms of zoom levels in one + // duration + float zoomDiff = endingZ - history[1].z, timeDiff = lastFrame.t - history[1].t; + float fadedist = zoomDiff / (timeDiff / duration); + + // 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 + float bump = (currentTime - lastFrame.t) / duration * fadedist; + + textShader->setFadeDist(fadedist * 10); + textShader->setMinFadeZoom(std::floor(lowZ * 10)); + textShader->setMaxFadeZoom(std::floor(highZ * 10)); + textShader->setFadeZoom((map.getState().getNormalizedZoom() + bump) * 10); } - if (history[1].t + duration < currentTime) { - history[0].z = history[1].z; - } - - 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; - const FrameSnapshot lastFrame = history.back(); - float endingZ = lastFrame.z; - float lowZ = std::fmin(startingZ, endingZ); - float highZ = std::fmax(startingZ, endingZ); - - // Calculate the speed of zooming, and how far it would zoom in terms of zoom levels in one - // duration - float zoomDiff = endingZ - history[1].z, timeDiff = lastFrame.t - history[1].t; - float fadedist = zoomDiff / (timeDiff / duration); - -#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 - float bump = (currentTime - lastFrame.t) / duration * fadedist; - - textShader->setFadeDist(fadedist * 10); - textShader->setMinFadeZoom(std::floor(lowZ * 10)); - textShader->setMaxFadeZoom(std::floor(highZ * 10)); - textShader->setFadeZoom((map.getState().getNormalizedZoom() + bump) * 10); - // This defines the gamma around the SDF cutoff value. const float sdfGamma = 1.0f / 10.0f; diff --git a/src/text/placement.cpp b/src/text/placement.cpp index 26cc9f70f..0c95e3a80 100644 --- a/src/text/placement.cpp +++ b/src/text/placement.cpp @@ -80,7 +80,7 @@ void getSegmentGlyphs(std::back_insert_iterator glyphs, Anchor & // skip duplicate nodes while (newAnchor == end) { segment += direction; - if ((int)line.size() <= segment) { + if ((int)line.size() <= segment || segment < 0) { anchor.scale = scale; return; } diff --git a/src/util/url.cpp b/src/util/url.cpp index b1a721d86..e9b967210 100644 --- a/src/util/url.cpp +++ b/src/util/url.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include namespace mbgl { namespace util { @@ -25,5 +27,25 @@ std::string percentEncode(const std::string& input) { return encoded.str(); } +std::string percentDecode(const std::string& input) { + std::string decoded; + + auto it = input.begin(); + const auto end = input.end(); + char hex[3] = "00"; + + while (it != end) { + auto cur = std::find(it, end, '%'); + decoded.append(it, cur); + it = cur; + if (cur != end) { + it += input.copy(hex, 2, cur - input.begin() + 1) + 1; + decoded += static_cast(std::strtoul(hex, nullptr, 16)); + } + } + + return decoded; +} + } } diff --git a/test/fixtures/fixture_request.cpp b/test/fixtures/fixture_request.cpp index 1a7ed2ccc..7e351ecfa 100644 --- a/test/fixtures/fixture_request.cpp +++ b/test/fixtures/fixture_request.cpp @@ -1,12 +1,15 @@ #include #include #include +#include #include const std::string base_directory = []{ std::string fn = __FILE__; fn.erase(fn.find_last_of("/")); - return fn; + fn.erase(fn.find_last_of("/")); + fn.erase(fn.find_last_of("/")); + return fn + "/node_modules/mapbox-gl-test-suite/"; }(); @@ -23,14 +26,11 @@ platform::request_http(const std::string &url, l = uv_default_loop(); } - std::string clean_url = base_directory + "/" + url; - auto pos = clean_url.find("://"); - if (pos != std::string::npos) { - clean_url.replace(pos, 3, "/"); + std::string clean_url = util::percentDecode(url); + if (clean_url.find("local://") == 0) { + clean_url = base_directory + clean_url.substr(8); } - std::replace(clean_url.begin(), clean_url.end(), '+', ' '); - std::shared_ptr req = std::make_shared(url, callback, loop); int err; diff --git a/test/headless.cpp b/test/headless.cpp index a2f58e98d..2453f1bb3 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -18,17 +18,12 @@ const std::string base_directory = []{ std::string fn = __FILE__; fn.erase(fn.find_last_of("/")); - return fn + "/../node_modules/mapbox-gl-test-suite/"; + fn.erase(fn.find_last_of("/")); + return fn + "/node_modules/mapbox-gl-test-suite/"; }(); class HeadlessTest : public ::testing::TestWithParam {}; -void ResolveLocalURL(rapidjson::Value& value, rapidjson::Document& doc) { - std::string str { value.GetString(), value.GetStringLength() }; - str.replace(0, 8, base_directory); // local:// - value.SetString(str.c_str(), str.length(), doc.GetAllocator()); -} - TEST_P(HeadlessTest, render) { using namespace mbgl; @@ -43,12 +38,6 @@ TEST_P(HeadlessTest, render) { ASSERT_EQ(false, styleDoc.HasParseError()); ASSERT_EQ(true, styleDoc.IsObject()); - if (styleDoc.HasMember("sprite")) { - ResolveLocalURL(styleDoc["sprite"], styleDoc); - } - - ResolveLocalURL(styleDoc["sources"]["mapbox"]["tiles"][rapidjson::SizeType(0)], styleDoc); - rapidjson::StringBuffer buffer; rapidjson::Writer writer(buffer); styleDoc.Accept(writer); @@ -91,7 +80,7 @@ TEST_P(HeadlessTest, render) { } } - map.setStyleJSON(style); + map.setStyleJSON(style, base_directory); map.setAppliedClasses(classes); view.resize(width, height);