diff options
author | Brian Osman <brianosman@google.com> | 2018-07-24 18:01:53 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-30 15:00:25 +0000 |
commit | b63f6005c1a72758a976984b1b00de4b1e66418b (patch) | |
tree | 0741e36b287f01eda554144004fed52dd2894753 | |
parent | 069b2cf19f1feedefa17e92e7418670f3a54ea09 (diff) |
Add 'u' to zoom stats display on high DPI devices
Still need to connect this to ImGui, but this is already useful
Bug: skia:
Change-Id: I925c7a9d6236cb2d865d45d6a68a5709bf2e3df7
Reviewed-on: https://skia-review.googlesource.com/143158
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
-rw-r--r-- | tools/viewer/StatsLayer.cpp | 5 | ||||
-rw-r--r-- | tools/viewer/StatsLayer.h | 3 | ||||
-rw-r--r-- | tools/viewer/Viewer.cpp | 6 | ||||
-rw-r--r-- | tools/viewer/Viewer.h | 1 |
4 files changed, 13 insertions, 2 deletions
diff --git a/tools/viewer/StatsLayer.cpp b/tools/viewer/StatsLayer.cpp index 50faf9cdd4..6573dfd0dd 100644 --- a/tools/viewer/StatsLayer.cpp +++ b/tools/viewer/StatsLayer.cpp @@ -14,7 +14,8 @@ StatsLayer::StatsLayer() : fCurrentMeasurement(0) , fCumulativeMeasurementTime(0) - , fCumulativeMeasurementCount(0) {} + , fCumulativeMeasurementCount(0) + , fDisplayScale(1.0f) {} void StatsLayer::resetMeasurements() { for (int i = 0; i < fTimers.count(); ++i) { @@ -64,7 +65,7 @@ void StatsLayer::onPaint(SkCanvas* canvas) { // Scale up the stats overlay on Android devices static constexpr SkScalar kScale = 1.5; #else - static constexpr SkScalar kScale = 1; + SkScalar kScale = fDisplayScale; #endif // Now draw everything diff --git a/tools/viewer/StatsLayer.h b/tools/viewer/StatsLayer.h index a99bd43a99..b888517e2c 100644 --- a/tools/viewer/StatsLayer.h +++ b/tools/viewer/StatsLayer.h @@ -26,6 +26,8 @@ public: void onPaint(SkCanvas* canvas) override; + void setDisplayScale(float scale) { fDisplayScale = scale; } + private: static const int kMeasurementCount = 1 << 6; // should be power of 2 for fast mod struct TimerData { @@ -38,6 +40,7 @@ private: int fCurrentMeasurement; double fCumulativeMeasurementTime; int fCumulativeMeasurementCount; + float fDisplayScale; }; #endif diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index 8f1d7bbbc8..b5a9084645 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -183,6 +183,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData) , fZoomWindowFixed(false) , fZoomWindowLocation{0.0f, 0.0f} , fLastImage(nullptr) + , fZoomUI(false) , fBackendType(sk_app::Window::kNativeGL_BackendType) , fColorMode(ColorMode::kLegacy) , fColorSpacePrimaries(gSrgbPrimaries) @@ -480,6 +481,11 @@ Viewer::Viewer(int argc, char** argv, void* platformData) this->updateTitle(); fWindow->inval(); }); + fCommands.addCommand('u', "GUI", "Zoom UI", [this]() { + fZoomUI = !fZoomUI; + fStatsLayer.setDisplayScale(fZoomUI ? 2.0f : 1.0f); + fWindow->inval(); + }); // set up slides this->initSlides(); diff --git a/tools/viewer/Viewer.h b/tools/viewer/Viewer.h index f1ecaf4445..6d03b3b27e 100644 --- a/tools/viewer/Viewer.h +++ b/tools/viewer/Viewer.h @@ -131,6 +131,7 @@ private: bool fZoomWindowFixed; SkPoint fZoomWindowLocation; sk_sp<SkImage> fLastImage; + bool fZoomUI; sk_app::Window::BackendType fBackendType; |