mason-based android port

This commit is contained in:
Dane Springmeyer
2014-11-01 22:41:40 -04:00
parent 551ff954a5
commit d7b0a34bdd
8 changed files with 50 additions and 12 deletions

View File

@@ -69,6 +69,21 @@ build/ios/mapbox-gl-cocoa/app/mapboxgl-app.xcodeproj: ios/mapbox-gl-cocoa/app/ma
build/linux/mapboxgl-app.xcodeproj: linux/mapboxgl-app.gyp config.gypi
deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=linux --depth=. --generator-output=./build -f xcode
.PHONY: android
android:
export CXX=`MASON_PLATFORM=android ~/.mason/mason env CXX` && \
export CC=`MASON_PLATFORM=android ~/.mason/mason env CC` && \
export LD=`MASON_PLATFORM=android ~/.mason/mason env LD` && \
export AR=`MASON_PLATFORM=android ~/.mason/mason env AR` && \
export RANLIB=`MASON_PLATFORM=android ~/.mason/mason env RANLIB` && \
export LDFLAGS=`MASON_PLATFORM=android ~/.mason/mason env LDFLAGS` && \
export CFLAGS=`MASON_PLATFORM=android ~/.mason/mason env CFLAGS` && \
export CPPFLAGS=`MASON_PLATFORM=android ~/.mason/mason env CPPFLAGS` && \
export PATH=`MASON_PLATFORM=android ~/.mason/mason env PATH` && \
MASON_PLATFORM=android ./configure config-android.gypi && \
deps/run_gyp mapboxgl.gyp -Iconfig-android.gypi -Dplatform=android --depth=. --generator-output=./build/android -f make-android && \
$(MAKE) -C ./build/android BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl-core
##### Test cases ###############################################################
test: build/test/Makefile
@@ -131,7 +146,7 @@ clean: clear_xcode_cache
-find ./deps/gyp -name "*.pyc" -exec rm {} \;
-rm -rf ./build/
-rm -rf ./macosx/build/
-rm -rf ./config.gypi ./config-ios.gypi
-rm -rf ./config.gypi ./config-ios.gypi ./config-android.gypi
distclean: clean
-rm -rf ./mason_packages

6
configure vendored
View File

@@ -24,6 +24,12 @@ case ${MASON_PLATFORM} in
ZLIB_VERSION=system
BOOST_VERSION=system
;;
'android')
SQLITE_VERSION=3.8.6
LIBUV_VERSION=0.11.29
ZLIB_VERSION=system
BOOST_VERSION=system
;;
*)
GLFW_VERSION=a21f2377
SQLITE_VERSION=system

View File

@@ -23,6 +23,7 @@
'cflags_cc': [
'-Wno-unknown-pragmas', # We are using '#pragma mark', but it is only available on Darwin.
'-Wno-literal-suffix', # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61653
'-Wno-unknown-warning-option'
],
}],
],

View File

@@ -69,11 +69,20 @@ private:
class VertexArrayObject : public util::noncopyable {
public:
template <typename Shader, typename Buffers>
void bind(Shader& shader, Buffers& buffers, char *offset) {
for (auto &buffer : buffers) {
buffer.bind();
}
inline VertexArrayObject() {};
inline VertexArrayObject(VertexArrayObject &&) noexcept {};
template <typename Shader, typename VertexBuffer>
inline void bind(Shader& shader, VertexBuffer &vertexBuffer, char *offset) {
vertexBuffer.bind();
shader.bind(offset);
}
template <typename Shader, typename VertexBuffer, typename ElementsBuffer>
inline void bind(Shader& shader, VertexBuffer &vertexBuffer, ElementsBuffer &elementsBuffer, char *offset) {
vertexBuffer.bind();
elementsBuffer.bind();
shader.bind(offset);
}
};
@@ -82,4 +91,4 @@ public:
}
#endif
#endif

View File

@@ -35,6 +35,9 @@
#else
#error Unsupported Apple platform
#endif
#elif __ANDROID__
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>

View File

@@ -10,7 +10,7 @@ void Painter::preparePrerender(RasterBucket &bucket) {
glDisable(GL_STENCIL_TEST);
// Render the actual tile.
#if GL_EXT_discard_framebuffer
#if GL_EXT_discard_framebuffer && !__ANDROID__
const GLenum discards[] = {GL_COLOR_ATTACHMENT0};
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards);
#endif

View File

@@ -49,8 +49,12 @@ void PrerenderedTexture::bindFramebuffer() {
// Create depth/stencil buffer
glGenRenderbuffers(1, &fbo_depth_stencil);
glBindRenderbuffer(GL_RENDERBUFFER, fbo_depth_stencil);
#ifdef GL_ES_VERSION_2_0
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, properties.size, properties.size);
#else
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, properties.size, properties.size);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
#endif
glBindRenderbuffer(GL_RENDERBUFFER, 0);
}
if (fbo == 0) {
@@ -117,7 +121,7 @@ void PrerenderedTexture::blur(Painter& painter, uint16_t passes) {
for (int i = 0; i < passes; i++) {
// Render horizontal
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, secondary_texture, 0);
#if GL_EXT_discard_framebuffer
#if GL_EXT_discard_framebuffer && !__ANDROID__
const GLenum discards[] = { GL_COLOR_ATTACHMENT0 };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards);
#endif
@@ -132,7 +136,7 @@ void PrerenderedTexture::blur(Painter& painter, uint16_t passes) {
// Render vertical
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, original_texture, 0);
#if GL_EXT_discard_framebuffer
#if GL_EXT_discard_framebuffer && !__ANDROID__
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards);
#endif
glClear(GL_COLOR_BUFFER_BIT);

View File

@@ -9,7 +9,7 @@ int64_t Response::parseCacheControl(const char *value) {
uint64_t seconds = 0;
// TODO: cache-control may contain other information as well:
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
if (std::sscanf(value, "max-age=%lu", &seconds) == 1) {
if (std::sscanf(value, "max-age=%llu", &seconds) == 1) {
return std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::system_clock::now().time_since_epoch()).count() +
seconds;