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-08-01 17:53:29 +00:00
|
|
|
class SkPicture;
|
|
|
|
class SkString;
|
|
|
|
|
|
|
|
namespace sk_tools {
|
|
|
|
|
|
|
|
class PictureBenchmark : public SkRefCnt {
|
|
|
|
public:
|
|
|
|
virtual void run(SkPicture* pict) = 0;
|
|
|
|
|
|
|
|
void setRepeats(int repeats) {
|
|
|
|
fRepeats = repeats;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getRepeats() const {
|
|
|
|
return fRepeats;
|
|
|
|
}
|
|
|
|
|
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-08-20 15:03:47 +00:00
|
|
|
BenchTimer* setupTimer();
|
|
|
|
|
2012-08-01 17:53:29 +00:00
|
|
|
protected:
|
|
|
|
int fRepeats;
|
2012-08-07 17:11:33 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
typedef SkRefCnt INHERITED;
|
2012-08-20 15:03:41 +00:00
|
|
|
|
|
|
|
virtual sk_tools::PictureRenderer* getRenderer() {
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PipePictureBenchmark : public PictureBenchmark {
|
|
|
|
public:
|
2012-08-07 17:11:33 +00:00
|
|
|
virtual void run(SkPicture* pict) SK_OVERRIDE;
|
2012-08-01 17:53:29 +00:00
|
|
|
private:
|
2012-08-20 15:03:41 +00:00
|
|
|
PipePictureRenderer fRenderer;
|
2012-08-07 17:11:33 +00:00
|
|
|
typedef PictureBenchmark INHERITED;
|
2012-08-20 15:03:41 +00:00
|
|
|
|
|
|
|
virtual sk_tools::PictureRenderer* getRenderer() SK_OVERRIDE {
|
|
|
|
return &fRenderer;
|
|
|
|
}
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RecordPictureBenchmark : public PictureBenchmark {
|
|
|
|
public:
|
2012-08-07 17:11:33 +00:00
|
|
|
virtual void run(SkPicture* pict) SK_OVERRIDE;
|
|
|
|
private:
|
|
|
|
typedef PictureBenchmark INHERITED;
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SimplePictureBenchmark : public PictureBenchmark {
|
|
|
|
public:
|
2012-08-07 17:11:33 +00:00
|
|
|
virtual void run(SkPicture* pict) SK_OVERRIDE;
|
2012-08-01 17:53:29 +00:00
|
|
|
private:
|
2012-08-20 15:03:41 +00:00
|
|
|
SimplePictureRenderer fRenderer;
|
2012-08-07 17:11:33 +00:00
|
|
|
typedef PictureBenchmark INHERITED;
|
2012-08-20 15:03:41 +00:00
|
|
|
|
|
|
|
virtual sk_tools::PictureRenderer* getRenderer() SK_OVERRIDE {
|
|
|
|
return &fRenderer;
|
|
|
|
}
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TiledPictureBenchmark : public PictureBenchmark {
|
|
|
|
public:
|
2012-08-07 17:11:33 +00:00
|
|
|
virtual void run(SkPicture* pict) SK_OVERRIDE;
|
2012-08-01 17:53:29 +00:00
|
|
|
|
|
|
|
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;
|
2012-08-07 17:11:33 +00:00
|
|
|
typedef PictureBenchmark INHERITED;
|
2012-08-20 15:03:41 +00:00
|
|
|
|
|
|
|
virtual sk_tools::PictureRenderer* getRenderer() SK_OVERRIDE{
|
|
|
|
return &fRenderer;
|
|
|
|
}
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class UnflattenPictureBenchmark : public PictureBenchmark {
|
|
|
|
public:
|
2012-08-07 17:11:33 +00:00
|
|
|
virtual void run(SkPicture* pict) SK_OVERRIDE;
|
|
|
|
private:
|
|
|
|
typedef PictureBenchmark INHERITED;
|
2012-08-01 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PictureBenchmark_DEFINED
|