1df161ab8a
Measure the time taken for animation and flush. Exclude UI and stats logic from the timing. Use stacked bars to visualize the breakdown of time within a frame. BUG=skia: Change-Id: I7ef84442a68147f02f65b6aa4452768fd3314de2 Reviewed-on: https://skia-review.googlesource.com/8227 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
85 lines
2.3 KiB
C++
85 lines
2.3 KiB
C++
/*
|
|
* Copyright 2016 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef Viewer_DEFINED
|
|
#define Viewer_DEFINED
|
|
|
|
#include "sk_app/Application.h"
|
|
#include "sk_app/CommandSet.h"
|
|
#include "sk_app/Window.h"
|
|
#include "gm.h"
|
|
#include "SkAnimTimer.h"
|
|
#include "SkTouchGesture.h"
|
|
#include "Slide.h"
|
|
|
|
class SkCanvas;
|
|
|
|
class Viewer : public sk_app::Application {
|
|
public:
|
|
Viewer(int argc, char** argv, void* platformData);
|
|
~Viewer() override;
|
|
|
|
void onPaint(SkCanvas* canvas);
|
|
void onIdle() override;
|
|
bool onTouch(intptr_t owner, sk_app::Window::InputState state, float x, float y);
|
|
void onUIStateChanged(const SkString& stateName, const SkString& stateValue);
|
|
|
|
private:
|
|
void initSlides();
|
|
void updateTitle();
|
|
void setColorMode(SkColorType, sk_sp<SkColorSpace>);
|
|
void setupCurrentSlide(int previousSlide);
|
|
|
|
void updateUIState();
|
|
|
|
void drawSlide(SkCanvas* canvs);
|
|
void drawStats(SkCanvas* canvas);
|
|
|
|
void changeZoomLevel(float delta);
|
|
SkMatrix computeMatrix();
|
|
|
|
sk_app::Window* fWindow;
|
|
|
|
static const int kMeasurementCount = 64; // should be power of 2 for fast mod
|
|
double fPaintTimes[kMeasurementCount];
|
|
double fFlushTimes[kMeasurementCount];
|
|
double fAnimateTimes[kMeasurementCount];
|
|
int fCurrentMeasurement;
|
|
|
|
SkAnimTimer fAnimTimer;
|
|
SkTArray<sk_sp<Slide>> fSlides;
|
|
int fCurrentSlide;
|
|
|
|
bool fDisplayStats;
|
|
bool fRefresh; // whether to continuously refresh for measuring render time
|
|
|
|
sk_app::Window::BackendType fBackendType;
|
|
|
|
// Color properties for slide rendering
|
|
SkColorType fColorType;
|
|
sk_sp<SkColorSpace> fColorSpace;
|
|
|
|
// transform data
|
|
SkScalar fZoomCenterX;
|
|
SkScalar fZoomCenterY;
|
|
SkScalar fZoomLevel;
|
|
SkScalar fZoomScale;
|
|
|
|
sk_app::CommandSet fCommands;
|
|
|
|
SkTouchGesture fGesture;
|
|
|
|
// identity unless the window initially scales the content to fit the screen.
|
|
SkMatrix fDefaultMatrix;
|
|
SkMatrix fDefaultMatrixInv;
|
|
|
|
Json::Value fAllSlideNames; // cache all slide names for fast updateUIState
|
|
};
|
|
|
|
|
|
#endif
|