summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2017-02-24 15:07:13 +0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2017-02-25 14:03:38 +0200
commit92e6e48699f5f94a80d69a94202f0f9c803fa2a7 (patch)
tree43d98fcea65b0b6fc9e8697310c9135810b40606
parent4c2e720b1522d2a45980ac8dcf34d2a3783cf426 (diff)
downloadqtlocation-mapboxgl-92e6e48699f5f94a80d69a94202f0f9c803fa2a7.tar.gz
[glfw] Make P pause/resume the network thread
Simple test of the DefaultFileSource pause/resume API.
-rw-r--r--platform/glfw/glfw_view.cpp8
-rw-r--r--platform/glfw/glfw_view.hpp5
-rw-r--r--platform/glfw/main.cpp12
3 files changed, 23 insertions, 2 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp
index 3c6ea1ded9..15a229d4ae 100644
--- a/platform/glfw/glfw_view.cpp
+++ b/platform/glfw/glfw_view.cpp
@@ -109,10 +109,11 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_)
printf("- Press `7` through `0` to add increasing numbers of shape annotations for testing\n");
printf("\n");
printf("- Press `Q` to remove annotations\n");
- printf("- Press `P` to add a random custom runtime imagery annotation\n");
+ printf("- Press `K` to add a random custom runtime imagery annotation\n");
printf("- Press `L` to add a random line annotation\n");
printf("- Press `W` to pop the last-added annotation off\n");
printf("\n");
+ printf("- Press `P` to pause tile requests\n");
printf("- `Control` + mouse drag to rotate\n");
printf("- `Shift` + mouse drag to tilt\n");
printf("\n");
@@ -200,10 +201,13 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action,
auto result = view->map->queryPointAnnotations({ {}, { double(view->getSize().width), double(view->getSize().height) } });
printf("visible point annotations: %lu\n", result.size());
} break;
+ case GLFW_KEY_P:
+ view->pauseResumeCallback();
+ break;
case GLFW_KEY_C:
view->clearAnnotations();
break;
- case GLFW_KEY_P:
+ case GLFW_KEY_K:
view->addRandomCustomPointAnnotations(1);
break;
case GLFW_KEY_L:
diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp
index 835a73b54e..a426e58a94 100644
--- a/platform/glfw/glfw_view.hpp
+++ b/platform/glfw/glfw_view.hpp
@@ -27,6 +27,10 @@ public:
// The expected action is to set a new style, different to the current one.
void setChangeStyleCallback(std::function<void()> callback);
+ void setPauseResumeCallback(std::function<void()> callback) {
+ pauseResumeCallback = callback;
+ };
+
void setShouldClose();
void setWindowTitle(const std::string&);
@@ -104,6 +108,7 @@ private:
double lastClick = -1;
std::function<void()> changeStyleCallback;
+ std::function<void()> pauseResumeCallback;
mbgl::util::RunLoop runLoop;
mbgl::util::Timer frameTick;
diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp
index 1f683b185f..fbfba0b7fb 100644
--- a/platform/glfw/main.cpp
+++ b/platform/glfw/main.cpp
@@ -153,6 +153,18 @@ int main(int argc, char *argv[]) {
mbgl::Log::Info(mbgl::Event::Setup, "Changed style to: %s", newStyle.name);
});
+ view->setPauseResumeCallback([&fileSource] () {
+ static bool isPaused = false;
+
+ if (isPaused) {
+ fileSource.resume();
+ } else {
+ fileSource.pause();
+ }
+
+ isPaused = !isPaused;
+ });
+
// Load style
if (style.empty()) {
const char *url = getenv("MAPBOX_STYLE_URL");