Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Rework map threading #879

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5fdd449
add target for static image rendering [skip ci]
kkaefer Feb 4, 2015
0d7c943
change default size of render executable [skip ci]
kkaefer Feb 5, 2015
d0c43e2
we're not using rapidjson, so don't include it here [skip ci]
kkaefer Feb 5, 2015
27e3998
don't complain about a missing style if we have a style URL instead […
kkaefer Feb 5, 2015
66094ef
make Map::resize() private [skip ci]
kkaefer Feb 5, 2015
3519bef
align threading in continuous rendering mode still image generation
kkaefer Feb 11, 2015
08c7615
update variant code
kkaefer Feb 11, 2015
479b113
add load-testing code that continually renders random map images
kkaefer Feb 11, 2015
19d5347
move readlock/writelock to uv.hpp and add movable lock/mutex
kkaefer Feb 11, 2015
c8610ee
lock the StyleBucket to avoid crashing
kkaefer Feb 11, 2015
591c6ce
add more locking around GlyphStore and FontStack
kkaefer Feb 11, 2015
f44a7d8
fix crash where painter was accessed before being constructed
kkaefer Feb 11, 2015
7cb4cac
make sure the HeadlessView always has a valid framebuffer
kkaefer Feb 11, 2015
2f7ef68
add isRendering() call
kkaefer Feb 12, 2015
bc22847
expose the Pixel type
kkaefer Feb 12, 2015
b23daff
assert that the shader program exists
kkaefer Feb 12, 2015
1168eb1
add missing include header
kkaefer Feb 12, 2015
da1a958
Fail early in case there is no display
kkaefer Feb 12, 2015
456a141
use a reinterpret_cast to return the correct type
kkaefer Feb 12, 2015
19d6f96
move gl context creation in headless to the Map render thread
kkaefer Feb 12, 2015
0a2432c
enable the context when deleting the HeadlessView
kkaefer Feb 13, 2015
1cadab2
throw when there's no style object
kkaefer Feb 13, 2015
b4e97ed
add atomic header and make constructor noexcept
kkaefer Feb 13, 2015
2d88526
use mutex instead of atomic
kkaefer Feb 13, 2015
2cb29f2
fix ambiguous name (gcc)
kkaefer Feb 13, 2015
b59ae9f
throw exception when shader compilation fails
kkaefer Feb 13, 2015
74c23ff
fix handling around unique_ptr releases
kkaefer Feb 13, 2015
70c8ebe
asyncUpdate can go away when the map is being terminated
kkaefer Feb 13, 2015
cd3eb6e
guard against concurrent OpenGL extension loading
kkaefer Feb 14, 2015
f1db1bb
PLATFORM is now HOST
kkaefer Feb 14, 2015
15e07eb
make rendering a critical section and wait until rendering is complet…
kkaefer Feb 14, 2015
ca0819a
Add Android support
Feb 18, 2015
79c13e2
move thread start to initialize() function and also call it from rend…
kkaefer Feb 18, 2015
bb8cedf
safe thread.join()
mikemorris Feb 20, 2015
3ad26aa
Handle double surfaceDestroyed callbacks
Feb 24, 2015
335cf4c
scope Requests to an Environment object for easier cancelation
kkaefer Mar 4, 2015
30a5f58
don't shadow variable
kkaefer Mar 4, 2015
021ad1f
fix test by writing to the correct output file
kkaefer Mar 4, 2015
a0b439a
pass StyleLayer objects as const ref instead of a shared pointer
kkaefer Mar 4, 2015
1a13331
prefix log output with MBGL
kkaefer Mar 6, 2015
c5b124f
Removed special cased zoom level for HiDPI
1ec5 Feb 25, 2015
c64f673
#931: fix end of acceptable glyph/unicode range
friedbunny Mar 5, 2015
21ccf43
tolerate missing sprites
kkaefer Mar 12, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Standard: Cpp11
IndentWidth: 4
AccessModifierOffset: -4
UseTab: Never
BinPackParameters: false
BinPackParameters: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortBlocksOnASingleLine: false
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,19 @@ android-deploy: $(ANDROID_ABIS)
cd android/java/MapboxGLAndroidSDK && chmod ugo+x deploy.sh && ./deploy.sh


##### CLI builds ###############################################################

render: Makefile/mbgl
$(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) mbgl-render

load-test: Makefile/mbgl
$(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) mbgl-load-test

##### Maintenace operations ####################################################

.PHONY: clear_xcode_cache
clear_xcode_cache:
ifeq ($(PLATFORM), osx)
ifeq ($(HOST), osx)
@CUSTOM_DD=`defaults read com.apple.dt.Xcode IDECustomDerivedDataLocation 2>/dev/null`; \
if [ $$CUSTOM_DD ]; then \
echo clearing files in $$CUSTOM_DD older than one day; \
Expand Down
80 changes: 4 additions & 76 deletions android/cpp/jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,42 +250,14 @@ void JNICALL nativeStart(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeStart");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->start();
nativeMapView->getMap().start();
}

void JNICALL nativeStop(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeStop");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->stop();
}

void JNICALL nativePause(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativePause");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->pause();
}

void JNICALL nativeResume(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeResume");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->resume();
}

void JNICALL nativeRun(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeRun");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->getMap().run();
}

void JNICALL nativeRerender(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeRerender");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->getMap().rerender();
nativeMapView->getMap().stop();
}

void JNICALL nativeUpdate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
Expand All @@ -295,39 +267,6 @@ void JNICALL nativeUpdate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
nativeMapView->getMap().update();
}

void JNICALL nativeTerminate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeTerminate");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->getMap().terminate();
}

jboolean JNICALL nativeNeedsSwap(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeNeedsSwap");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
return nativeMapView->getMap().needsSwap();
}

void JNICALL nativeSwapped(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSwapped");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->getMap().swapped();
}

void JNICALL nativeResize(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jint width, jint height,
jfloat ratio) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeResize");
assert(nativeMapViewPtr != 0);
assert(width >= 0);
assert(height >= 0);
assert(width <= UINT16_MAX);
assert(height <= UINT16_MAX);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->getMap().resize(width, height, ratio);
}

void JNICALL nativeResize(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jint width, jint height,
jfloat ratio, jint fbWidth, jint fbHeight) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeResize");
Expand All @@ -341,7 +280,7 @@ void JNICALL nativeResize(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jint
assert(fbWidth <= UINT16_MAX);
assert(fbHeight <= UINT16_MAX);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->getMap().resize(width, height, ratio, fbWidth, fbHeight);
nativeMapView->resize(width, height, ratio, fbWidth, fbHeight);
}

void JNICALL nativeRemoveClass(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jstring clazz) {
Expand Down Expand Up @@ -837,7 +776,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {

// NOTE: if you get java.lang.UnsatisfiedLinkError you likely forgot to set the size of the
// array correctly (too large)
std::array<JNINativeMethod, 62> methods = {{ // Can remove the extra brace in C++14
std::array<JNINativeMethod, 54> methods = {{ // Can remove the extra brace in C++14
{"nativeCreate", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J",
reinterpret_cast<void *>(&nativeCreate)},
{"nativeDestroy", "(J)V", reinterpret_cast<void *>(&nativeDestroy)},
Expand All @@ -850,18 +789,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
{"nativeDestroySurface", "(J)V", reinterpret_cast<void *>(&nativeDestroySurface)},
{"nativeStart", "(J)V", reinterpret_cast<void *>(&nativeStart)},
{"nativeStop", "(J)V", reinterpret_cast<void *>(&nativeStop)},
{"nativePause", "(J)V", reinterpret_cast<void *>(&nativePause)},
{"nativeResume", "(J)V", reinterpret_cast<void *>(&nativeResume)},
{"nativeRun", "(J)V", reinterpret_cast<void *>(&nativeRun)},
{"nativeRerender", "(J)V", reinterpret_cast<void *>(&nativeRerender)},
{"nativeUpdate", "(J)V", reinterpret_cast<void *>(&nativeUpdate)},
{"nativeTerminate", "(J)V", reinterpret_cast<void *>(&nativeTerminate)},
{"nativeNeedsSwap", "(J)Z", reinterpret_cast<void *>(&nativeNeedsSwap)},
{"nativeSwapped", "(J)V", reinterpret_cast<void *>(&nativeSwapped)},
{"nativeResize", "(JIIF)V",
reinterpret_cast<void *>(
static_cast<void JNICALL (*)(JNIEnv *, jobject, jlong, jint, jint, jfloat)>(
&nativeResize))},
{"nativeResize", "(JIIFII)V",
reinterpret_cast<void *>(static_cast<void JNICALL (
*)(JNIEnv *, jobject, jlong, jint, jint, jfloat, jint, jint)>(&nativeResize))},
Expand Down
Loading