2016-04-06 13:08:59 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
#include "Viewer.h"
|
2016-04-06 13:08:59 +00:00
|
|
|
|
2016-04-08 14:24:09 +00:00
|
|
|
#include "GMSlide.h"
|
|
|
|
#include "SKPSlide.h"
|
|
|
|
|
2016-04-06 13:08:59 +00:00
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkCommonFlags.h"
|
2016-04-08 14:24:09 +00:00
|
|
|
#include "SkOSFile.h"
|
|
|
|
#include "SkRandom.h"
|
|
|
|
#include "SkStream.h"
|
2016-04-06 13:08:59 +00:00
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
using namespace sk_app;
|
|
|
|
|
2016-04-06 13:08:59 +00:00
|
|
|
Application* Application::Create(int argc, char** argv, void* platformData) {
|
2016-05-04 20:49:13 +00:00
|
|
|
return new Viewer(argc, argv, platformData);
|
2016-04-06 13:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void on_paint_handler(SkCanvas* canvas, void* userData) {
|
2016-05-04 20:49:13 +00:00
|
|
|
Viewer* vv = reinterpret_cast<Viewer*>(userData);
|
2016-04-06 13:08:59 +00:00
|
|
|
|
|
|
|
return vv->onPaint(canvas);
|
|
|
|
}
|
|
|
|
|
2016-05-17 19:44:20 +00:00
|
|
|
static bool on_touch_handler(int owner, Window::InputState state, float x, float y, void* userData)
|
|
|
|
{
|
|
|
|
Viewer* viewer = reinterpret_cast<Viewer*>(userData);
|
|
|
|
|
|
|
|
return viewer->onTouch(owner, state, x, y);
|
|
|
|
}
|
|
|
|
|
2016-05-27 13:47:08 +00:00
|
|
|
DEFINE_bool2(fullscreen, f, false, "Run fullscreen.");
|
2016-04-08 14:24:09 +00:00
|
|
|
DEFINE_string(key, "", "Space-separated key/value pairs to add to JSON identifying this builder.");
|
|
|
|
DEFINE_string2(match, m, nullptr,
|
|
|
|
"[~][^]substring[$] [...] of bench name to run.\n"
|
|
|
|
"Multiple matches may be separated by spaces.\n"
|
|
|
|
"~ causes a matching bench to always be skipped\n"
|
|
|
|
"^ requires the start of the bench to match\n"
|
|
|
|
"$ requires the end of the bench to match\n"
|
|
|
|
"^ and $ requires an exact match\n"
|
|
|
|
"If a bench does not match any list entry,\n"
|
|
|
|
"it is skipped unless some list entry starts with ~");
|
|
|
|
DEFINE_string(skps, "skps", "Directory to read skps from.");
|
2016-05-27 13:47:08 +00:00
|
|
|
DEFINE_bool(vulkan, true, "Run with Vulkan.");
|
2016-04-08 14:24:09 +00:00
|
|
|
|
2016-05-20 13:01:06 +00:00
|
|
|
const char *kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = {
|
|
|
|
" [OpenGL]",
|
|
|
|
" [Vulkan]"
|
|
|
|
};
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
Viewer::Viewer(int argc, char** argv, void* platformData)
|
2016-04-08 19:51:45 +00:00
|
|
|
: fCurrentMeasurement(0)
|
|
|
|
, fDisplayStats(false)
|
2016-05-20 13:01:06 +00:00
|
|
|
, fBackendType(sk_app::Window::kVulkan_BackendType)
|
2016-04-11 15:30:40 +00:00
|
|
|
, fZoomCenterX(0.0f)
|
|
|
|
, fZoomCenterY(0.0f)
|
|
|
|
, fZoomLevel(0.0f)
|
|
|
|
, fZoomScale(SK_Scalar1)
|
2016-04-08 19:51:45 +00:00
|
|
|
{
|
2016-04-07 18:09:51 +00:00
|
|
|
memset(fMeasurements, 0, sizeof(fMeasurements));
|
2016-04-06 13:08:59 +00:00
|
|
|
|
2016-04-08 14:24:09 +00:00
|
|
|
SkDebugf("Command line arguments: ");
|
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
SkDebugf("%s ", argv[i]);
|
|
|
|
}
|
|
|
|
SkDebugf("\n");
|
|
|
|
|
|
|
|
SkCommandLineFlags::Parse(argc, argv);
|
|
|
|
|
2016-05-27 13:47:08 +00:00
|
|
|
fBackendType = FLAGS_vulkan ? sk_app::Window::kVulkan_BackendType
|
|
|
|
: sk_app::Window::kNativeGL_BackendType;
|
|
|
|
|
2016-04-06 13:08:59 +00:00
|
|
|
fWindow = Window::CreateNativeWindow(platformData);
|
2016-05-20 13:01:06 +00:00
|
|
|
fWindow->attach(fBackendType, DisplayParams());
|
2016-04-06 13:08:59 +00:00
|
|
|
|
|
|
|
// register callbacks
|
2016-05-10 13:50:49 +00:00
|
|
|
fCommands.attach(fWindow);
|
2016-04-06 13:08:59 +00:00
|
|
|
fWindow->registerPaintFunc(on_paint_handler, this);
|
2016-05-17 19:44:20 +00:00
|
|
|
fWindow->registerTouchFunc(on_touch_handler, this);
|
2016-04-06 13:08:59 +00:00
|
|
|
|
2016-05-10 13:50:49 +00:00
|
|
|
// add key-bindings
|
|
|
|
fCommands.addCommand('s', "Overlays", "Toggle stats display", [this]() {
|
|
|
|
this->fDisplayStats = !this->fDisplayStats;
|
|
|
|
fWindow->inval();
|
|
|
|
});
|
|
|
|
fCommands.addCommand('c', "Modes", "Toggle sRGB color mode", [this]() {
|
|
|
|
DisplayParams params = fWindow->getDisplayParams();
|
|
|
|
params.fProfileType = (kLinear_SkColorProfileType == params.fProfileType)
|
|
|
|
? kSRGB_SkColorProfileType : kLinear_SkColorProfileType;
|
|
|
|
fWindow->setDisplayParams(params);
|
|
|
|
this->updateTitle();
|
|
|
|
fWindow->inval();
|
|
|
|
});
|
|
|
|
fCommands.addCommand(Window::Key::kRight, "Right", "Navigation", "Next slide", [this]() {
|
|
|
|
int previousSlide = fCurrentSlide;
|
|
|
|
fCurrentSlide++;
|
|
|
|
if (fCurrentSlide >= fSlides.count()) {
|
|
|
|
fCurrentSlide = 0;
|
|
|
|
}
|
|
|
|
this->setupCurrentSlide(previousSlide);
|
|
|
|
});
|
|
|
|
fCommands.addCommand(Window::Key::kLeft, "Left", "Navigation", "Previous slide", [this]() {
|
|
|
|
int previousSlide = fCurrentSlide;
|
|
|
|
fCurrentSlide--;
|
|
|
|
if (fCurrentSlide < 0) {
|
|
|
|
fCurrentSlide = fSlides.count() - 1;
|
|
|
|
}
|
|
|
|
this->setupCurrentSlide(previousSlide);
|
|
|
|
});
|
|
|
|
fCommands.addCommand(Window::Key::kUp, "Up", "Transform", "Zoom in", [this]() {
|
|
|
|
this->changeZoomLevel(1.f / 32.f);
|
|
|
|
fWindow->inval();
|
|
|
|
});
|
|
|
|
fCommands.addCommand(Window::Key::kDown, "Down", "Transform", "Zoom out", [this]() {
|
|
|
|
this->changeZoomLevel(-1.f / 32.f);
|
|
|
|
fWindow->inval();
|
|
|
|
});
|
2016-05-27 13:47:08 +00:00
|
|
|
#if 0 // this doesn't seem to work on any platform right now
|
2016-05-20 13:01:06 +00:00
|
|
|
#ifndef SK_BUILD_FOR_ANDROID
|
|
|
|
fCommands.addCommand('d', "Modes", "Change rendering backend", [this]() {
|
|
|
|
fWindow->detach();
|
|
|
|
|
|
|
|
if (sk_app::Window::kVulkan_BackendType == fBackendType) {
|
|
|
|
fBackendType = sk_app::Window::kNativeGL_BackendType;
|
|
|
|
}
|
2016-05-27 13:47:08 +00:00
|
|
|
// TODO: get Vulkan -> OpenGL working on Windows without swapchain creation failure
|
2016-05-20 13:01:06 +00:00
|
|
|
//else if (sk_app::Window::kNativeGL_BackendType == fBackendType) {
|
|
|
|
// fBackendType = sk_app::Window::kVulkan_BackendType;
|
|
|
|
//}
|
|
|
|
|
|
|
|
fWindow->attach(fBackendType, DisplayParams());
|
|
|
|
this->updateTitle();
|
2016-05-27 13:47:08 +00:00
|
|
|
fWindow->inval();
|
2016-05-20 13:01:06 +00:00
|
|
|
});
|
2016-05-27 13:47:08 +00:00
|
|
|
#endif
|
2016-05-20 13:01:06 +00:00
|
|
|
#endif
|
2016-05-10 13:50:49 +00:00
|
|
|
|
2016-04-08 14:24:09 +00:00
|
|
|
// set up slides
|
|
|
|
this->initSlides();
|
|
|
|
|
2016-04-21 14:59:44 +00:00
|
|
|
fAnimTimer.run();
|
|
|
|
|
2016-04-08 14:24:09 +00:00
|
|
|
// set up first frame
|
|
|
|
fCurrentSlide = 0;
|
2016-04-08 19:51:45 +00:00
|
|
|
setupCurrentSlide(-1);
|
2016-04-08 14:24:09 +00:00
|
|
|
|
2016-04-08 19:51:45 +00:00
|
|
|
fWindow->show();
|
2016-04-08 14:24:09 +00:00
|
|
|
}
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
void Viewer::initSlides() {
|
2016-04-08 14:24:09 +00:00
|
|
|
const skiagm::GMRegistry* gms(skiagm::GMRegistry::Head());
|
|
|
|
while (gms) {
|
|
|
|
SkAutoTDelete<skiagm::GM> gm(gms->factory()(nullptr));
|
|
|
|
|
|
|
|
if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, gm->getName())) {
|
|
|
|
sk_sp<Slide> slide(new GMSlide(gm.release()));
|
|
|
|
fSlides.push_back(slide);
|
|
|
|
}
|
|
|
|
|
|
|
|
gms = gms->next();
|
|
|
|
}
|
|
|
|
|
|
|
|
// reverse array
|
|
|
|
for (int i = 0; i < fSlides.count()/2; ++i) {
|
|
|
|
sk_sp<Slide> temp = fSlides[i];
|
|
|
|
fSlides[i] = fSlides[fSlides.count() - i - 1];
|
|
|
|
fSlides[fSlides.count() - i - 1] = temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SKPs
|
|
|
|
for (int i = 0; i < FLAGS_skps.count(); i++) {
|
|
|
|
if (SkStrEndsWith(FLAGS_skps[i], ".skp")) {
|
2016-04-08 19:51:45 +00:00
|
|
|
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, FLAGS_skps[i])) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-04-08 14:24:09 +00:00
|
|
|
SkString path(FLAGS_skps[i]);
|
2016-04-08 19:51:45 +00:00
|
|
|
sk_sp<SKPSlide> slide(new SKPSlide(SkOSPath::Basename(path.c_str()), path));
|
2016-04-08 14:24:09 +00:00
|
|
|
if (slide) {
|
|
|
|
fSlides.push_back(slide);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SkOSFile::Iter it(FLAGS_skps[i], ".skp");
|
2016-04-08 19:51:45 +00:00
|
|
|
SkString skpName;
|
|
|
|
while (it.next(&skpName)) {
|
|
|
|
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, skpName.c_str())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkString path = SkOSPath::Join(FLAGS_skps[i], skpName.c_str());
|
|
|
|
sk_sp<SKPSlide> slide(new SKPSlide(skpName, path));
|
2016-04-08 14:24:09 +00:00
|
|
|
if (slide) {
|
|
|
|
fSlides.push_back(slide);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
Viewer::~Viewer() {
|
2016-04-06 13:08:59 +00:00
|
|
|
fWindow->detach();
|
|
|
|
delete fWindow;
|
|
|
|
}
|
|
|
|
|
2016-05-06 20:28:57 +00:00
|
|
|
void Viewer::updateTitle() {
|
2016-05-04 20:49:13 +00:00
|
|
|
SkString title("Viewer: ");
|
2016-04-08 19:51:45 +00:00
|
|
|
title.append(fSlides[fCurrentSlide]->getName());
|
2016-05-06 20:28:57 +00:00
|
|
|
if (kSRGB_SkColorProfileType == fWindow->getDisplayParams().fProfileType) {
|
|
|
|
title.append(" sRGB");
|
|
|
|
}
|
2016-05-20 13:01:06 +00:00
|
|
|
title.append(kBackendTypeStrings[fBackendType]);
|
2016-05-06 20:28:57 +00:00
|
|
|
fWindow->setTitle(title.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Viewer::setupCurrentSlide(int previousSlide) {
|
2016-05-20 14:32:19 +00:00
|
|
|
fGesture.reset();
|
|
|
|
fDefaultMatrix.reset();
|
|
|
|
fDefaultMatrixInv.reset();
|
|
|
|
|
|
|
|
if (fWindow->supportsContentRect() && fWindow->scaleContentToFit()) {
|
|
|
|
const SkRect contentRect = fWindow->getContentRect();
|
|
|
|
const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions();
|
|
|
|
const SkRect slideBounds = SkRect::MakeIWH(slideSize.width(), slideSize.height());
|
|
|
|
if (contentRect.width() > 0 && contentRect.height() > 0) {
|
|
|
|
fDefaultMatrix.setRectToRect(slideBounds, contentRect, SkMatrix::kStart_ScaleToFit);
|
2016-05-20 18:41:01 +00:00
|
|
|
SkAssertResult(fDefaultMatrix.invert(&fDefaultMatrixInv));
|
2016-05-20 14:32:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fWindow->supportsContentRect()) {
|
|
|
|
const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions();
|
|
|
|
SkRect windowRect = fWindow->getContentRect();
|
|
|
|
fDefaultMatrixInv.mapRect(&windowRect);
|
|
|
|
fGesture.setTransLimit(SkRect::MakeWH(slideSize.width(), slideSize.height()), windowRect);
|
|
|
|
}
|
|
|
|
|
2016-05-06 20:28:57 +00:00
|
|
|
this->updateTitle();
|
2016-04-08 19:51:45 +00:00
|
|
|
fSlides[fCurrentSlide]->load();
|
|
|
|
if (previousSlide >= 0) {
|
|
|
|
fSlides[previousSlide]->unload();
|
|
|
|
}
|
|
|
|
fWindow->inval();
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_ZOOM_LEVEL 8
|
|
|
|
#define MIN_ZOOM_LEVEL -8
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
void Viewer::changeZoomLevel(float delta) {
|
2016-04-08 19:51:45 +00:00
|
|
|
fZoomLevel += delta;
|
|
|
|
if (fZoomLevel > 0) {
|
|
|
|
fZoomLevel = SkMinScalar(fZoomLevel, MAX_ZOOM_LEVEL);
|
|
|
|
fZoomScale = fZoomLevel + SK_Scalar1;
|
|
|
|
} else if (fZoomLevel < 0) {
|
|
|
|
fZoomLevel = SkMaxScalar(fZoomLevel, MIN_ZOOM_LEVEL);
|
|
|
|
fZoomScale = SK_Scalar1 / (SK_Scalar1 - fZoomLevel);
|
|
|
|
} else {
|
|
|
|
fZoomScale = SK_Scalar1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-17 19:44:20 +00:00
|
|
|
SkMatrix Viewer::computeMatrix() {
|
2016-04-08 19:51:45 +00:00
|
|
|
SkMatrix m;
|
|
|
|
m.reset();
|
|
|
|
|
|
|
|
if (fZoomLevel) {
|
|
|
|
SkPoint center;
|
|
|
|
//m = this->getLocalMatrix();//.invert(&m);
|
|
|
|
m.mapXY(fZoomCenterX, fZoomCenterY, ¢er);
|
|
|
|
SkScalar cx = center.fX;
|
|
|
|
SkScalar cy = center.fY;
|
|
|
|
|
|
|
|
m.setTranslate(-cx, -cy);
|
|
|
|
m.postScale(fZoomScale, fZoomScale);
|
|
|
|
m.postTranslate(cx, cy);
|
|
|
|
}
|
|
|
|
|
2016-05-17 19:44:20 +00:00
|
|
|
m.preConcat(fGesture.localM());
|
|
|
|
m.preConcat(fGesture.globalM());
|
2016-04-08 19:51:45 +00:00
|
|
|
|
2016-05-17 19:44:20 +00:00
|
|
|
return m;
|
2016-04-08 19:51:45 +00:00
|
|
|
}
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
void Viewer::onPaint(SkCanvas* canvas) {
|
2016-04-08 19:51:45 +00:00
|
|
|
int count = canvas->save();
|
2016-04-21 14:59:44 +00:00
|
|
|
|
|
|
|
if (fWindow->supportsContentRect()) {
|
|
|
|
SkRect contentRect = fWindow->getContentRect();
|
|
|
|
canvas->clipRect(contentRect);
|
|
|
|
canvas->translate(contentRect.fLeft, contentRect.fTop);
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->clear(SK_ColorWHITE);
|
2016-05-20 14:32:19 +00:00
|
|
|
canvas->concat(fDefaultMatrix);
|
2016-05-17 19:44:20 +00:00
|
|
|
canvas->concat(computeMatrix());
|
2016-04-08 19:51:45 +00:00
|
|
|
|
2016-04-08 14:24:09 +00:00
|
|
|
fSlides[fCurrentSlide]->draw(canvas);
|
2016-04-08 19:51:45 +00:00
|
|
|
canvas->restoreToCount(count);
|
2016-04-07 18:09:51 +00:00
|
|
|
|
2016-04-08 19:51:45 +00:00
|
|
|
if (fDisplayStats) {
|
|
|
|
drawStats(canvas);
|
|
|
|
}
|
2016-05-10 13:50:49 +00:00
|
|
|
fCommands.drawHelp(canvas);
|
2016-04-07 18:09:51 +00:00
|
|
|
}
|
|
|
|
|
2016-05-17 19:44:20 +00:00
|
|
|
bool Viewer::onTouch(int owner, Window::InputState state, float x, float y) {
|
|
|
|
void* castedOwner = reinterpret_cast<void*>(owner);
|
2016-05-20 14:32:19 +00:00
|
|
|
SkPoint touchPoint = fDefaultMatrixInv.mapXY(x, y);
|
2016-05-17 19:44:20 +00:00
|
|
|
switch (state) {
|
|
|
|
case Window::kUp_InputState: {
|
|
|
|
fGesture.touchEnd(castedOwner);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Window::kDown_InputState: {
|
2016-05-20 14:32:19 +00:00
|
|
|
fGesture.touchBegin(castedOwner, touchPoint.fX, touchPoint.fY);
|
2016-05-17 19:44:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Window::kMove_InputState: {
|
2016-05-20 14:32:19 +00:00
|
|
|
fGesture.touchMoved(castedOwner, touchPoint.fX, touchPoint.fY);
|
2016-05-17 19:44:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fWindow->inval();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
void Viewer::drawStats(SkCanvas* canvas) {
|
2016-04-07 18:09:51 +00:00
|
|
|
static const float kPixelPerMS = 2.0f;
|
|
|
|
static const int kDisplayWidth = 130;
|
|
|
|
static const int kDisplayHeight = 100;
|
|
|
|
static const int kDisplayPadding = 10;
|
|
|
|
static const int kGraphPadding = 3;
|
|
|
|
static const SkScalar kBaseMS = 1000.f / 60.f; // ms/frame to hit 60 fps
|
|
|
|
|
|
|
|
SkISize canvasSize = canvas->getDeviceSize();
|
|
|
|
SkRect rect = SkRect::MakeXYWH(SkIntToScalar(canvasSize.fWidth-kDisplayWidth-kDisplayPadding),
|
|
|
|
SkIntToScalar(kDisplayPadding),
|
|
|
|
SkIntToScalar(kDisplayWidth), SkIntToScalar(kDisplayHeight));
|
|
|
|
SkPaint paint;
|
|
|
|
canvas->save();
|
|
|
|
|
2016-04-21 14:59:44 +00:00
|
|
|
if (fWindow->supportsContentRect()) {
|
|
|
|
SkRect contentRect = fWindow->getContentRect();
|
|
|
|
canvas->clipRect(contentRect);
|
|
|
|
canvas->translate(contentRect.fLeft, contentRect.fTop);
|
|
|
|
}
|
|
|
|
|
2016-04-07 18:09:51 +00:00
|
|
|
canvas->clipRect(rect);
|
|
|
|
paint.setColor(SK_ColorBLACK);
|
|
|
|
canvas->drawRect(rect, paint);
|
|
|
|
// draw the 16ms line
|
|
|
|
paint.setColor(SK_ColorLTGRAY);
|
|
|
|
canvas->drawLine(rect.fLeft, rect.fBottom - kBaseMS*kPixelPerMS,
|
|
|
|
rect.fRight, rect.fBottom - kBaseMS*kPixelPerMS, paint);
|
|
|
|
paint.setColor(SK_ColorRED);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
canvas->drawRect(rect, paint);
|
|
|
|
|
|
|
|
int x = SkScalarTruncToInt(rect.fLeft) + kGraphPadding;
|
|
|
|
const int xStep = 2;
|
|
|
|
const int startY = SkScalarTruncToInt(rect.fBottom);
|
|
|
|
int i = fCurrentMeasurement;
|
|
|
|
do {
|
|
|
|
int endY = startY - (int)(fMeasurements[i] * kPixelPerMS + 0.5); // round to nearest value
|
|
|
|
canvas->drawLine(SkIntToScalar(x), SkIntToScalar(startY),
|
|
|
|
SkIntToScalar(x), SkIntToScalar(endY), paint);
|
|
|
|
i++;
|
|
|
|
i &= (kMeasurementCount - 1); // fast mod
|
|
|
|
x += xStep;
|
|
|
|
} while (i != fCurrentMeasurement);
|
2016-04-06 13:08:59 +00:00
|
|
|
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
void Viewer::onIdle(double ms) {
|
2016-04-07 18:09:51 +00:00
|
|
|
// Record measurements
|
|
|
|
fMeasurements[fCurrentMeasurement++] = ms;
|
|
|
|
fCurrentMeasurement &= (kMeasurementCount - 1); // fast mod
|
|
|
|
SkASSERT(fCurrentMeasurement < kMeasurementCount);
|
|
|
|
|
2016-04-08 19:51:45 +00:00
|
|
|
fAnimTimer.updateTime();
|
2016-04-26 15:01:33 +00:00
|
|
|
if (fSlides[fCurrentSlide]->animate(fAnimTimer) || fDisplayStats) {
|
2016-04-08 19:51:45 +00:00
|
|
|
fWindow->inval();
|
|
|
|
}
|
2016-04-06 13:08:59 +00:00
|
|
|
}
|