Skip to content

Commit 186b090

Browse files
mathislogesopyer
authored andcommitted
Windows port
1 parent 2888511 commit 186b090

30 files changed

+415
-175
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Created by http://www.gitignore.io
22

3+
### OSX ###
4+
.vscode
5+
.vs
6+
37
### OSX ###
48
.DS_Store
59
.AppleDouble

CMakeLists.txt

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
cmake_minimum_required(VERSION 3.2)
1+
cmake_minimum_required(VERSION 3.15)
22

3-
project(tangram)
3+
project(tangram VERSION 1.0.0)
44

55
# Options
66
option(TANGRAM_USE_JSCORE "Use system libraries for JavaScriptCore and enable it on iOS and macOS" OFF)
@@ -18,11 +18,6 @@ option(TANGRAM_DEV_MODE "For developers only: Don't omit the frame pointer" OFF)
1818

1919
message(STATUS "Build type configuration: ${CMAKE_BUILD_TYPE}")
2020

21-
# Check that submodules are present.
22-
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/core/deps/harfbuzz-icu-freetype/harfbuzz/README")
23-
message(SEND_ERROR "Missing submodules - Please run:\n 'git submodule update --init'")
24-
return()
25-
endif()
2621

2722
if(CMAKE_BUILD_TYPE MATCHES Debug)
2823
add_definitions(-DDEBUG)

core/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
project(tangram-core)
22

33
# Build core library dependencies.
4+
find_package(yaml-cpp CONFIG REQUIRED)
45
add_subdirectory(deps)
56

67
add_library(tangram-core
@@ -231,7 +232,6 @@ target_link_libraries(tangram-core
231232
alfons
232233
double-conversion
233234
miniz
234-
z
235235
)
236236

237237
# Add JavaScript implementation.
@@ -260,6 +260,7 @@ if(UNIX AND NOT APPLE)
260260
target_link_libraries(tangram-core PRIVATE dl)
261261
endif()
262262

263+
target_compile_definitions(tangram-core PUBLIC _USE_MATH_DEFINES)
263264
if(TANGRAM_WARN_ON_RULE_CONFLICT)
264265
target_compile_definitions(tangram-core
265266
PRIVATE

core/deps/CMakeLists.txt

+11-15
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ add_library(glm INTERFACE)
1111
target_include_directories(glm INTERFACE glm)
1212
target_compile_definitions(glm INTERFACE GLM_FORCE_CTOR_INIT)
1313

14-
## yaml-cpp ##
15-
##############
16-
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "")
17-
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "")
18-
set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "")
19-
set(YAML_CPP_INSTALL OFF CACHE BOOL "")
20-
add_subdirectory(yaml-cpp)
14+
### yaml-cpp ##
15+
###############
16+
#set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "")
17+
#set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "")
18+
#set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "")
19+
#set(YAML_CPP_INSTALL OFF CACHE BOOL "")
20+
#add_subdirectory(yaml-cpp)
2121

22-
target_include_directories(yaml-cpp PUBLIC yaml-cpp/include)
22+
#target_include_directories(yaml-cpp PUBLIC yaml-cpp/include)
2323

2424
## css-color-parser-cpp ##
2525
##########################
@@ -48,14 +48,10 @@ target_include_directories(miniz
4848
if(NOT TANGRAM_USE_SYSTEM_FONT_LIBS)
4949
## Harfbuzz - ICU-Common - Freetype2 ##
5050
#######################################
51-
set(HARFBUZZ_BUILD_ICU ON CACHE BOOL "Enable building of ICU")
52-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/harfbuzz-icu-freetype)
53-
54-
message(STATUS "harfbuzz" ${HARFBUZZ_LIBRARIES})
55-
51+
#find_package(ICU REQUIRED COMPONENTS common)
52+
find_package(harfbuzz CONFIG REQUIRED)
5653
set(ALFONS_DEPS_LIBRARIES
57-
${ALFONS_DEPS_LIBRARIES}
58-
harfbuzz ${HARFBUZZ_LIBRARIES}
54+
harfbuzz::harfbuzz
5955
CACHE INTERNAL "alfons-libs" FORCE)
6056
endif()
6157

core/deps/pbf/pbf.hpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@
2626
#endif
2727

2828
namespace protobuf {
29-
29+
#if defined(__GNUC__)
3030
#define FORCEINLINE inline __attribute__((always_inline))
3131
#define NOINLINE __attribute__((noinline))
32+
#else
33+
#define FORCEINLINE inline
34+
#define NOINLINE
35+
#endif
3236
#define PBF_INLINE FORCEINLINE
3337

3438
class message {

core/include/tangram/log.h

+4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ static constexpr const char * past_last_slash(const char * const str) {
2727
return past_last_slash(str, str);
2828
}
2929

30+
#ifdef TANGRAM_WINDOWS
31+
#define __FILENAME__ __FILE__
32+
#else
3033
#define __FILENAME__ ({constexpr const char * const sf__ {past_last_slash(__FILE__)}; sf__;})
34+
#endif
3135

3236
#define TANGRAM_MAX_BUFFER_LOG_SIZE 99999
3337

core/include/tangram/tile/tileID.h

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <cassert>
44
#include <cstdint>
55
#include <string>
6+
#include <algorithm>
67

78
/* An immutable identifier for a map tile
89
*

core/include/tangram/util/variant.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@ using Value = variant<none_type, double, std::string>;
5555

5656
class Value : public detail::Value {
5757
using Base = detail::Value;
58-
using Base::Base;
58+
59+
public:
60+
Value(): Base() {}
61+
62+
template<typename T>
63+
Value(const T& val): Base(val) {}
64+
65+
template<typename T>
66+
Value(T&& val): Base(val) {}
5967
};
6068

6169
const static Value NOT_A_VALUE(none_type{});

core/src/data/rasterSource.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ std::shared_ptr<Texture> RasterSource::cacheTexture(const TileID& _tileId, std::
208208
}
209209

210210
texture = std::shared_ptr<Texture>(_texture.release(),
211-
[c = std::weak_ptr<Cache>(m_textures), id](auto t) {
211+
[c = std::weak_ptr<Cache>(m_textures), id](auto* t) {
212212
if (auto cache = c.lock()) {
213213
cache->erase(id);
214214
LOGD("%d - remove %s", cache->size(), id.toString().c_str());

core/src/debug/textDisplay.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void TextDisplay::draw(RenderState& rs, const std::string& _text, int _posx, int
8989
std::vector<glm::vec2> vertices;
9090
int nquads;
9191

92-
nquads = stb_easy_font_print(_posx, _posy, _text.c_str(), NULL, m_vertexBuffer, VERTEX_BUFFER_SIZE);
92+
nquads = stb_easy_font_print(_posx, _posy, const_cast<char*>(_text.c_str()), NULL, m_vertexBuffer, VERTEX_BUFFER_SIZE);
9393

9494
float* data = reinterpret_cast<float*>(m_vertexBuffer);
9595

core/src/gl/framebuffer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void FrameBuffer::init(RenderState& _rs) {
147147
}
148148

149149
GLenum status = GL::checkFramebufferStatus(GL_FRAMEBUFFER);
150-
GL_CHECK();
150+
GL_CHECK("");
151151

152152
if (status != GL_FRAMEBUFFER_COMPLETE) {
153153
LOGE("Framebuffer status is incomplete:");

core/src/scene/filters.cpp

+26-26
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,33 @@ void Filter::print(int _indent) const {
3232

3333
switch (data.which()) {
3434

35-
case Data::type<OperatorAny>::value: {
35+
case Data::which<OperatorAny>(): {
3636
logMsg("%*s any\n", _indent, "");
3737
for (const auto& filt : data.get<OperatorAny>().operands) {
3838
filt.print(_indent + 2);
3939
}
4040
break;
4141
}
42-
case Data::type<OperatorAll>::value: {
42+
case Data::which<OperatorAll>(): {
4343
logMsg("%*s all\n", _indent, "");
4444
for (const auto& filt : data.get<OperatorAll>().operands) {
4545
filt.print(_indent + 2);
4646
}
4747
break;
4848
}
49-
case Data::type<OperatorNone>::value: {
49+
case Data::which<OperatorNone>(): {
5050
logMsg("%*s none\n", _indent, "");
5151
for (const auto& filt : data.get<OperatorNone>().operands) {
5252
filt.print(_indent + 2);
5353
}
5454
break;
5555
}
56-
case Data::type<Existence>::value: {
56+
case Data::which<Existence>(): {
5757
auto& f = data.get<Existence>();
5858
logMsg("%*s existence - key:%s\n", _indent, "", f.key.c_str());
5959
break;
6060
}
61-
case Data::type<EqualitySet>::value: {
61+
case Data::which<EqualitySet>(): {
6262
auto& f = data.get<EqualitySet>();
6363
if (f.values[0].is<std::string>()) {
6464
logMsg("%*s equality set - keyword:%d key:%s val:%s\n", _indent, "",
@@ -74,7 +74,7 @@ void Filter::print(int _indent) const {
7474
}
7575
break;
7676
}
77-
case Data::type<Equality>::value: {
77+
case Data::which<Equality>(): {
7878
auto& f = data.get<Equality>();
7979
if (f.value.is<std::string>()) {
8080
logMsg("%*s equality - keyword:%d key:%s val:%s\n", _indent, "",
@@ -90,14 +90,14 @@ void Filter::print(int _indent) const {
9090
}
9191
break;
9292
}
93-
case Data::type<Range>::value: {
93+
case Data::which<Range>(): {
9494
auto& f = data.get<Range>();
9595
logMsg("%*s range - keyword:%d key:%s min:%f max:%f\n", _indent, "",
9696
f.keyword != FilterKeyword::undefined,
9797
f.key.c_str(), f.min, f.max);
9898
return;
9999
}
100-
case Data::type<Function>::value: {
100+
case Data::which<Function>(): {
101101
logMsg("%*s function\n", _indent, "");
102102
break;
103103
}
@@ -113,33 +113,33 @@ int Filter::filterCost() const {
113113
int sum = 100;
114114

115115
switch (data.which()) {
116-
case Data::type<OperatorAny>::value:
116+
case Data::which<OperatorAny>():
117117
for (auto& f : operands()) { sum += f.filterCost(); }
118118
return sum;
119119

120-
case Data::type<OperatorAll>::value:
120+
case Data::which<OperatorAll>():
121121
for (auto& f : operands()) { sum += f.filterCost(); }
122122
return sum;
123123

124-
case Data::type<OperatorNone>::value:
124+
case Data::which<OperatorNone>():
125125
for (auto& f : operands()) { sum += f.filterCost(); }
126126
return sum;
127127

128-
case Data::type<Existence>::value:
128+
case Data::which<Existence>():
129129
// Equality and Range are more specific for increasing
130130
// the chance to fail early check them before Existence
131131
return 20;
132132

133-
case Data::type<EqualitySet>::value:
133+
case Data::which<EqualitySet>():
134134
return data.get<EqualitySet>().keyword == FilterKeyword::undefined ? 10 : 1;
135135

136-
case Data::type<Equality>::value:
136+
case Data::which<Equality>():
137137
return data.get<Equality>().keyword == FilterKeyword::undefined ? 10 : 1;
138138

139-
case Data::type<Filter::Range>::value:
139+
case Data::which<Filter::Range>():
140140
return data.get<Range>().keyword == FilterKeyword::undefined ? 10 : 1;
141141

142-
case Data::type<Function>::value:
142+
case Data::which<Function>():
143143
// Most expensive filter should be checked last
144144
return 1000;
145145
}
@@ -151,16 +151,16 @@ const std::string& Filter::key() const {
151151

152152
switch (data.which()) {
153153

154-
case Data::type<Existence>::value:
154+
case Data::which<Existence>():
155155
return data.get<Existence>().key;
156156

157-
case Data::type<EqualitySet>::value:
157+
case Data::which<EqualitySet>():
158158
return data.get<EqualitySet>().key;
159159

160-
case Data::type<Equality>::value:
160+
case Data::which<Equality>():
161161
return data.get<Equality>().key;
162162

163-
case Data::type<Filter::Range>::value:
163+
case Data::which<Filter::Range>():
164164
return data.get<Range>().key;
165165

166166
default:
@@ -173,13 +173,13 @@ const std::vector<Filter>& Filter::operands() const {
173173
static const std::vector<Filter> empty;
174174

175175
switch (data.which()) {
176-
case Data::type<OperatorAny>::value:
176+
case Data::which<OperatorAny>():
177177
return data.get<OperatorAny>().operands;
178178

179-
case Data::type<OperatorAll>::value:
179+
case Data::which<OperatorAll>():
180180
return data.get<OperatorAll>().operands;
181181

182-
case Data::type<OperatorNone>::value:
182+
case Data::which<OperatorNone>():
183183
return data.get<OperatorNone>().operands;
184184

185185
default:
@@ -191,13 +191,13 @@ const std::vector<Filter>& Filter::operands() const {
191191
bool Filter::isOperator() const {
192192

193193
switch (data.which()) {
194-
case Data::type<OperatorAny>::value:
194+
case Data::which<OperatorAny>():
195195
return true;
196196

197-
case Data::type<OperatorAll>::value:
197+
case Data::which<OperatorAll>():
198198
return true;
199199

200-
case Data::type<OperatorNone>::value:
200+
case Data::which<OperatorNone>():
201201
return true;
202202

203203
default:

core/src/scene/importer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void Importer::addSceneYaml(const Url& sceneUrl, const char* sceneYaml, size_t l
188188
auto& sceneNode = m_sceneNodes[sceneUrl];
189189

190190
try {
191-
sceneNode.yaml = YAML::Load(sceneYaml, length);
191+
sceneNode.yaml = YAML::Load(sceneYaml);
192192
} catch (const YAML::ParserException& e) {
193193
LOGE("Parsing scene config '%s'", e.what());
194194
return;

core/src/scene/sceneLayer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ SceneLayer::SceneLayer(std::string name, Filter filter,
1919
// Sort sublayers for precedence in matching operations. If multiple values for a parameter are assigned to the same
2020
// draw group at the same layer depth, then the value that comes *first* in the layer list will be the final value.
2121
std::sort(m_sublayers.begin(), m_sublayers.end(),
22-
[](const SceneLayer& a, const SceneLayer& b) {
22+
[](const auto& a, const auto& b) {
2323
if (a.exclusive() != b.exclusive()) {
2424
// Exclusive layers always precede non-exclusive layers.
2525
return a.exclusive();

0 commit comments

Comments
 (0)