Merge branch 'master' into libuv010
This commit is contained in:
6
Makefile
6
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
|
||||
|
||||
10
common.gypi
10
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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
|
||||
#include <mbgl/geometry/buffer.hpp>
|
||||
#include <mbgl/geometry/vao.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
template <int count>
|
||||
struct ElementGroup {
|
||||
struct ElementGroup : public util::noncopyable {
|
||||
std::array<VertexArrayObject, count> 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<
|
||||
|
||||
@@ -3,14 +3,25 @@
|
||||
|
||||
#include <mbgl/shader/shader.hpp>
|
||||
#include <mbgl/platform/gl.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
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 <typename Shader, typename VertexBuffer>
|
||||
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 <typename Shader, typename Buffers>
|
||||
void bind(Shader& shader, Buffers& buffers, char *offset) {
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
std::string percentEncode(const std::string&);
|
||||
std::string percentDecode(const std::string&);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Submodule ios/mapbox-gl-cocoa updated: e1c709a8de...8a315662b3
@@ -3,7 +3,7 @@
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
cd build/Testing
|
||||
cd build/${BUILDTYPE:-Release}
|
||||
|
||||
for TEST in ./test_* ; do
|
||||
${TEST}
|
||||
|
||||
@@ -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
|
||||
#
|
||||
|
||||
@@ -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/
|
||||
|
||||
@@ -56,45 +56,38 @@ void Painter::renderSymbol(SymbolBucket &bucket, std::shared_ptr<StyleLayer> lay
|
||||
const timestamp currentTime = util::now();
|
||||
|
||||
std::deque<FrameSnapshot> &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;
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ void getSegmentGlyphs(std::back_insert_iterator<GlyphInstances> 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;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
|
||||
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<char>(std::strtoul(hex, nullptr, 16));
|
||||
}
|
||||
}
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
14
test/fixtures/fixture_request.cpp
vendored
14
test/fixtures/fixture_request.cpp
vendored
@@ -1,12 +1,15 @@
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/platform/request.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/util/url.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
|
||||
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<Request> req = std::make_shared<Request>(url, callback, loop);
|
||||
|
||||
int err;
|
||||
|
||||
@@ -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<std::string> {};
|
||||
|
||||
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<rapidjson::StringBuffer> 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);
|
||||
|
||||
Reference in New Issue
Block a user