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

Commit

Permalink
Merge pull request #1419 from mapbox/strict-pause
Browse files Browse the repository at this point in the history
Ensure no GL commands are executed after pause
  • Loading branch information
jfirebaugh committed May 5, 2015
2 parents da8aaa2 + 00a1f44 commit 24a0d77
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
9 changes: 4 additions & 5 deletions android/cpp/native_map_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ void NativeMapView::createSurface(ANativeWindow *window_) {
void NativeMapView::destroySurface() {
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::destroySurface");

pause(true);
pause();

if (surface != EGL_NO_SURFACE) {
if (!eglDestroySurface(display, surface)) {
Expand Down Expand Up @@ -674,12 +674,11 @@ void loadExtensions() {
}
}

void NativeMapView::pause(bool waitForPause) {
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::pause %s",
(waitForPause) ? "true" : "false");
void NativeMapView::pause() {
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::pause");

if ((display != EGL_NO_DISPLAY) && (context != EGL_NO_CONTEXT)) {
map.pause(waitForPause);
map.pause();
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/mbgl/android/native_map_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NativeMapView : public mbgl::View, private mbgl::util::noncopyable {
void destroySurface();

void resume();
void pause(bool waitForPause = false);
void pause();

void enableFps(bool enable);
void updateFps();
Expand Down
2 changes: 1 addition & 1 deletion include/mbgl/map/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Map : private util::noncopyable {
~Map();

// Pauses the render thread. The render thread will stop running but will not be terminated and will not lose state until resumed.
void pause(bool waitForPause = false);
void pause();

// Resumes a paused render thread
void resume();
Expand Down
7 changes: 2 additions & 5 deletions src/mbgl/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ Map::~Map() {
resume();
}

void Map::pause(bool waitForPause) {
void Map::pause() {
assert(data->mode == MapMode::Continuous);

std::unique_lock<std::mutex> lockPause(data->mutexPause);
context->invoke(&MapContext::pause);

if (waitForPause) {
data->condPaused.wait(lockPause);
}
data->condPaused.wait(lockPause);
}

void Map::resume() {
Expand Down
2 changes: 2 additions & 0 deletions src/mbgl/map/map_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ MapContext::~MapContext() {
}

void MapContext::pause() {
MBGL_CHECK_ERROR(glFinish());

view.deactivate();

std::unique_lock<std::mutex> lockPause(data.mutexPause);
Expand Down

0 comments on commit 24a0d77

Please sign in to comment.