2014-08-01 14:46:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SKPBench_DEFINED
|
|
|
|
#define SKPBench_DEFINED
|
|
|
|
|
|
|
|
#include "Benchmark.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkPicture.h"
|
2015-08-05 20:57:49 +00:00
|
|
|
#include "SkTDArray.h"
|
|
|
|
|
|
|
|
class SkSurface;
|
2014-08-01 14:46:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Runs an SkPicture as a benchmark by repeatedly drawing it scaled inside a device clip.
|
|
|
|
*/
|
|
|
|
class SKPBench : public Benchmark {
|
|
|
|
public:
|
2014-11-21 14:19:36 +00:00
|
|
|
SKPBench(const char* name, const SkPicture*, const SkIRect& devClip, SkScalar scale,
|
2015-06-25 17:51:56 +00:00
|
|
|
bool useMultiPictureDraw, bool doLooping);
|
2015-03-26 01:17:31 +00:00
|
|
|
~SKPBench() override;
|
2014-08-01 14:46:52 +00:00
|
|
|
|
2015-06-25 17:51:56 +00:00
|
|
|
int calculateLoops(int defaultLoops) const override {
|
|
|
|
return fDoLooping ? defaultLoops : 1;
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:05:37 +00:00
|
|
|
void getGpuStats(SkCanvas*, SkTArray<SkString>* keys, SkTArray<double>* values) override;
|
|
|
|
|
2014-08-01 14:46:52 +00:00
|
|
|
protected:
|
2015-03-26 01:17:31 +00:00
|
|
|
const char* onGetName() override;
|
|
|
|
const char* onGetUniqueName() override;
|
|
|
|
void onPerCanvasPreDraw(SkCanvas*) override;
|
|
|
|
void onPerCanvasPostDraw(SkCanvas*) override;
|
|
|
|
bool isSuitableFor(Backend backend) override;
|
2015-10-01 16:43:39 +00:00
|
|
|
void onDraw(int loops, SkCanvas* canvas) override;
|
2015-03-26 01:17:31 +00:00
|
|
|
SkIPoint onGetSize() override;
|
2014-08-01 14:46:52 +00:00
|
|
|
|
2015-04-27 16:16:57 +00:00
|
|
|
virtual void drawMPDPicture();
|
|
|
|
virtual void drawPicture();
|
|
|
|
|
2016-11-04 17:02:54 +00:00
|
|
|
const SkPicture* picture() const { return fPic.get(); }
|
2018-07-12 17:30:47 +00:00
|
|
|
const SkTArray<sk_sp<SkSurface>, true>& surfaces() const { return fSurfaces; }
|
2015-04-27 16:16:57 +00:00
|
|
|
const SkTDArray<SkIRect>& tileRects() const { return fTileRects; }
|
|
|
|
|
2014-08-01 14:46:52 +00:00
|
|
|
private:
|
2016-11-04 17:02:54 +00:00
|
|
|
sk_sp<const SkPicture> fPic;
|
2014-08-01 14:46:52 +00:00
|
|
|
const SkIRect fClip;
|
|
|
|
const SkScalar fScale;
|
|
|
|
SkString fName;
|
2014-09-10 19:05:59 +00:00
|
|
|
SkString fUniqueName;
|
2014-08-01 14:46:52 +00:00
|
|
|
|
2014-11-21 14:19:36 +00:00
|
|
|
const bool fUseMultiPictureDraw;
|
2018-07-12 17:30:47 +00:00
|
|
|
SkTArray<sk_sp<SkSurface>, true> fSurfaces; // for MultiPictureDraw
|
2014-11-21 14:19:36 +00:00
|
|
|
SkTDArray<SkIRect> fTileRects; // for MultiPictureDraw
|
|
|
|
|
2015-06-25 17:51:56 +00:00
|
|
|
const bool fDoLooping;
|
|
|
|
|
2014-08-01 14:46:52 +00:00
|
|
|
typedef Benchmark INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|