2012-08-01 17:53:29 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PictureBenchmark_DEFINED
|
|
|
|
#define PictureBenchmark_DEFINED
|
|
|
|
#include "SkTypes.h"
|
|
|
|
#include "SkRefCnt.h"
|
|
|
|
#include "PictureRenderer.h"
|
|
|
|
|
2012-08-20 15:03:47 +00:00
|
|
|
class BenchTimer;
|
2012-09-07 15:21:18 +00:00
|
|
|
class SkBenchLogger;
|
2012-08-01 17:53:29 +00:00
|
|
|
class SkPicture;
|
|
|
|
class SkString;
|
|
|
|
|
|
|
|
namespace sk_tools {
|
|
|
|
|
|
|
|
class PictureBenchmark : public SkRefCnt {
|
|
|
|
public:
|
2012-09-07 15:21:18 +00:00
|
|
|
PictureBenchmark()
|
|
|
|
: fRepeats(1)
|
|
|
|
, fLogger(NULL) {}
|
|
|
|
|
|
|
|
void run(SkPicture* pict);
|
2012-08-01 17:53:29 +00:00
|
|
|
|
|
|
|
void setRepeats(int repeats) {
|
|
|
|
fRepeats = repeats;
|
|
|
|
}
|
|
|
|
|
2012-08-20 15:04:04 +00:00
|
|
|
void setDeviceType(PictureRenderer::SkDeviceTypes deviceType) {
|
|
|
|
sk_tools::PictureRenderer* renderer = getRenderer();
|
2012-08-20 15:03:41 +00:00
|
|
|
|
|
|
|
if (renderer != NULL) {
|
2012-08-20 15:04:04 +00:00
|
|
|
renderer->setDeviceType(deviceType);
|
2012-08-20 15:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
void setLogger(SkBenchLogger* logger) { fLogger = logger; }
|
2012-08-07 17:11:33 +00:00
|
|
|
|
|
|
|
private:
|
2012-09-07 15:21:18 +00:00
|
|
|
int fRepeats;
|
|
|
|
SkBenchLogger* fLogger;
|
2012-08-20 15:03:41 +00:00
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
void logProgress(const char msg[]);
|
|
|
|
|
|
|
|
virtual sk_tools::PictureRenderer* getRenderer() = 0;
|
|
|
|
|
|
|
|
BenchTimer* setupTimer();
|
|
|
|
|
|
|
|
typedef SkRefCnt INHERITED;
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
// TODO: Use just one PictureBenchmark with different renderers.
|
|
|
|
|
2012-08-01 17:53:29 +00:00
|
|
|
class PipePictureBenchmark : public PictureBenchmark {
|
|
|
|
private:
|
2012-08-20 15:03:41 +00:00
|
|
|
PipePictureRenderer fRenderer;
|
|
|
|
|
|
|
|
virtual sk_tools::PictureRenderer* getRenderer() SK_OVERRIDE {
|
|
|
|
return &fRenderer;
|
|
|
|
}
|
2012-09-07 15:21:18 +00:00
|
|
|
|
|
|
|
typedef PictureBenchmark INHERITED;
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RecordPictureBenchmark : public PictureBenchmark {
|
2012-08-07 17:11:33 +00:00
|
|
|
private:
|
2012-09-07 15:21:18 +00:00
|
|
|
RecordPictureRenderer fRenderer;
|
|
|
|
|
|
|
|
virtual sk_tools::PictureRenderer* getRenderer() SK_OVERRIDE {
|
|
|
|
return &fRenderer;
|
|
|
|
}
|
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
typedef PictureBenchmark INHERITED;
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SimplePictureBenchmark : public PictureBenchmark {
|
|
|
|
private:
|
2012-08-20 15:03:41 +00:00
|
|
|
SimplePictureRenderer fRenderer;
|
|
|
|
|
|
|
|
virtual sk_tools::PictureRenderer* getRenderer() SK_OVERRIDE {
|
|
|
|
return &fRenderer;
|
|
|
|
}
|
2012-09-07 15:21:18 +00:00
|
|
|
|
|
|
|
typedef PictureBenchmark INHERITED;
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TiledPictureBenchmark : public PictureBenchmark {
|
|
|
|
public:
|
|
|
|
void setTileWidth(int width) {
|
2012-08-20 15:03:41 +00:00
|
|
|
fRenderer.setTileWidth(width);
|
2012-08-01 17:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int getTileWidth() const {
|
2012-08-20 15:03:41 +00:00
|
|
|
return fRenderer.getTileWidth();
|
2012-08-01 17:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setTileHeight(int height) {
|
2012-08-20 15:03:41 +00:00
|
|
|
fRenderer.setTileHeight(height);
|
2012-08-01 17:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int getTileHeight() const {
|
2012-08-20 15:03:41 +00:00
|
|
|
return fRenderer.getTileHeight();
|
2012-08-01 17:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setTileWidthPercentage(double percentage) {
|
2012-08-20 15:03:41 +00:00
|
|
|
fRenderer.setTileWidthPercentage(percentage);
|
2012-08-01 17:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double getTileWidthPercentage() const {
|
2012-08-20 15:03:41 +00:00
|
|
|
return fRenderer.getTileWidthPercentage();
|
2012-08-01 17:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setTileHeightPercentage(double percentage) {
|
2012-08-20 15:03:41 +00:00
|
|
|
fRenderer.setTileHeightPercentage(percentage);
|
2012-08-01 17:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double getTileHeightPercentage() const {
|
2012-08-20 15:03:41 +00:00
|
|
|
return fRenderer.getTileHeightPercentage();
|
2012-08-01 17:53:29 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 20:53:25 +00:00
|
|
|
void setTileMinPowerOf2Width(int width) {
|
|
|
|
fRenderer.setTileMinPowerOf2Width(width);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getTileMinPowerOf2Width() {
|
|
|
|
return fRenderer.getTileMinPowerOf2Width();
|
|
|
|
}
|
|
|
|
|
2012-08-31 16:15:22 +00:00
|
|
|
void setThreading(bool multi) {
|
|
|
|
fRenderer.setMultiThreaded(multi);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setUsePipe(bool usePipe) {
|
|
|
|
fRenderer.setUsePipe(usePipe);
|
|
|
|
}
|
|
|
|
|
2012-08-01 17:53:29 +00:00
|
|
|
private:
|
2012-08-20 15:03:41 +00:00
|
|
|
TiledPictureRenderer fRenderer;
|
|
|
|
|
|
|
|
virtual sk_tools::PictureRenderer* getRenderer() SK_OVERRIDE{
|
|
|
|
return &fRenderer;
|
|
|
|
}
|
2012-09-07 15:21:18 +00:00
|
|
|
|
|
|
|
typedef PictureBenchmark INHERITED;
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
class PlaybackCreationBenchmark : public PictureBenchmark {
|
2012-08-07 17:11:33 +00:00
|
|
|
private:
|
2012-09-07 15:21:18 +00:00
|
|
|
PlaybackCreationRenderer fRenderer;
|
|
|
|
|
|
|
|
virtual sk_tools::PictureRenderer* getRenderer() SK_OVERRIDE{
|
|
|
|
return &fRenderer;
|
|
|
|
}
|
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
typedef PictureBenchmark INHERITED;
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PictureBenchmark_DEFINED
|