diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-08-19 23:15:37 +0300 |
---|---|---|
committer | Mike Morris <mikemorris@users.noreply.github.com> | 2016-08-24 15:51:04 -0400 |
commit | 7b73d971fa7bd7f2633d6f9447a39cdf089740ba (patch) | |
tree | deae05ad4f54b54bac4e557aaa5e014f56097c89 | |
parent | 2523f33ac440be1a817e50d2d8bdc4d9c5b0a9d9 (diff) | |
download | qtlocation-mapboxgl-7b73d971fa7bd7f2633d6f9447a39cdf089740ba.tar.gz |
[node] stopwatch
-rw-r--r-- | platform/default/headless_view.cpp | 20 | ||||
-rw-r--r-- | src/mbgl/map/map.cpp | 2 |
2 files changed, 16 insertions, 6 deletions
diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index 28c300b41e..945de32037 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -1,5 +1,6 @@ -#include <mbgl/platform/default/headless_view.hpp> #include <mbgl/platform/default/headless_display.hpp> +#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/util/stopwatch.hpp> #include <cassert> #include <cstring> @@ -41,21 +42,28 @@ void HeadlessView::resize(const uint16_t width, const uint16_t height) { } PremultipliedImage HeadlessView::readStillImage() { + util::stopwatch stopwatch("readStillImage", Event::General); assert(active); const unsigned int w = dimensions[0] * pixelRatio; const unsigned int h = dimensions[1] * pixelRatio; PremultipliedImage image { w, h }; - MBGL_CHECK_ERROR(glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, image.data.get())); + { + util::stopwatch stopwatch2("glReadPixels", Event::General); + MBGL_CHECK_ERROR(glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, image.data.get())); + } const auto stride = image.stride(); auto tmp = std::make_unique<uint8_t[]>(stride); uint8_t* rgba = image.data.get(); - for (int i = 0, j = h - 1; i < j; i++, j--) { - std::memcpy(tmp.get(), rgba + i * stride, stride); - std::memcpy(rgba + i * stride, rgba + j * stride, stride); - std::memcpy(rgba + j * stride, tmp.get(), stride); + { + util::stopwatch stopwatch3("memcpy", Event::General); + for (int i = 0, j = h - 1; i < j; i++, j--) { + std::memcpy(tmp.get(), rgba + i * stride, stride); + std::memcpy(rgba + i * stride, rgba + j * stride, stride); + std::memcpy(rgba + j * stride, tmp.get(), stride); + } } return image; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 3a307735ab..eab4c77e2e 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -21,6 +21,7 @@ #include <mbgl/util/exception.hpp> #include <mbgl/util/async_task.hpp> #include <mbgl/util/mapbox.hpp> +#include <mbgl/util/stopwatch.hpp> #include <mbgl/util/tile_coordinate.hpp> namespace mbgl { @@ -241,6 +242,7 @@ void Map::Impl::update() { if (mode == MapMode::Continuous) { view.invalidate(); } else if (callback && style->isLoaded()) { + util::stopwatch stopwatch2("render", Event::General); view.activate(); render(); view.deactivate(); |