diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-08-19 23:15:37 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-08-19 23:15:43 +0300 |
commit | a2d8f50a0a2b4ed2bb06b02ff4429fe4cd33b40f (patch) | |
tree | c520eca0e625cf53b286f6455e68cad8fc280981 | |
parent | 0df60c46517648b18e65d860f5a9356ba751ca11 (diff) | |
download | qtlocation-mapboxgl-a2d8f50a0a2b4ed2bb06b02ff4429fe4cd33b40f.tar.gz |
stopwatchupstream/tmpsantos-glReadPixels
-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 13ea78a709..40c46e017f 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 15f7779f83..2457e33031 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 { @@ -239,6 +240,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(); |