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>
This commit is contained in:
Brian Osman 2018-07-24 18:01:53 -04:00 committed by Skia Commit-Bot
parent 069b2cf19f
commit b63f6005c1
4 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -131,6 +131,7 @@ private:
bool fZoomWindowFixed;
SkPoint fZoomWindowLocation;
sk_sp<SkImage> fLastImage;
bool fZoomUI;
sk_app::Window::BackendType fBackendType;