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
|
|
|
#ifndef Viewer_DEFINED
|
|
|
|
#define Viewer_DEFINED
|
2016-04-06 13:08:59 +00:00
|
|
|
|
2016-05-05 19:32:03 +00:00
|
|
|
#include "sk_app/Application.h"
|
2016-05-10 13:50:49 +00:00
|
|
|
#include "sk_app/CommandSet.h"
|
2016-05-05 19:32:03 +00:00
|
|
|
#include "sk_app/Window.h"
|
2016-04-06 13:08:59 +00:00
|
|
|
#include "gm.h"
|
2016-04-08 19:51:45 +00:00
|
|
|
#include "SkAnimTimer.h"
|
2016-04-08 14:24:09 +00:00
|
|
|
#include "Slide.h"
|
2016-04-06 13:08:59 +00:00
|
|
|
|
|
|
|
class SkCanvas;
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
class Viewer : public sk_app::Application {
|
2016-04-06 13:08:59 +00:00
|
|
|
public:
|
2016-05-04 20:49:13 +00:00
|
|
|
Viewer(int argc, char** argv, void* platformData);
|
|
|
|
~Viewer() override;
|
2016-04-06 13:08:59 +00:00
|
|
|
|
|
|
|
void onPaint(SkCanvas* canvas);
|
2016-04-07 18:09:51 +00:00
|
|
|
void onIdle(double ms) override;
|
2016-04-06 13:08:59 +00:00
|
|
|
|
|
|
|
private:
|
2016-04-08 14:24:09 +00:00
|
|
|
void initSlides();
|
2016-05-06 20:28:57 +00:00
|
|
|
void updateTitle();
|
2016-04-08 19:51:45 +00:00
|
|
|
void setupCurrentSlide(int previousSlide);
|
2016-04-08 14:24:09 +00:00
|
|
|
|
2016-04-07 18:09:51 +00:00
|
|
|
void drawStats(SkCanvas* canvas);
|
|
|
|
|
2016-04-08 19:51:45 +00:00
|
|
|
void changeZoomLevel(float delta);
|
|
|
|
void updateMatrix();
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
sk_app::Window* fWindow;
|
2016-04-06 13:08:59 +00:00
|
|
|
|
2016-04-07 18:09:51 +00:00
|
|
|
static const int kMeasurementCount = 64; // should be power of 2 for fast mod
|
|
|
|
double fMeasurements[kMeasurementCount];
|
|
|
|
int fCurrentMeasurement;
|
|
|
|
|
2016-04-08 19:51:45 +00:00
|
|
|
SkAnimTimer fAnimTimer;
|
2016-04-08 14:24:09 +00:00
|
|
|
SkTArray<sk_sp<Slide>> fSlides;
|
|
|
|
int fCurrentSlide;
|
2016-04-08 19:51:45 +00:00
|
|
|
|
|
|
|
bool fDisplayStats;
|
|
|
|
|
2016-05-17 19:15:48 +00:00
|
|
|
sk_app::Window::BackendType fBackendType;
|
|
|
|
|
2016-04-08 19:51:45 +00:00
|
|
|
// transform data
|
|
|
|
SkMatrix fLocalMatrix;
|
|
|
|
SkScalar fZoomCenterX;
|
|
|
|
SkScalar fZoomCenterY;
|
|
|
|
SkScalar fZoomLevel;
|
|
|
|
SkScalar fZoomScale;
|
|
|
|
|
2016-05-10 13:50:49 +00:00
|
|
|
sk_app::CommandSet fCommands;
|
2016-04-06 13:08:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|