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"
|
|
|
|
|
|
|
|
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:03:41 +00:00
|
|
|
void setUseBitmapDevice() {
|
|
|
|
sk_tools::PictureRenderer* renderer = getRenderer();
|
|
|
|
|
|
|
|
if (renderer != NULL) {
|
|
|
|
renderer->setUseBitmapDevice();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
void setUseGpuDevice() {
|
|
|
|
sk_tools::PictureRenderer* renderer = getRenderer();
|
|
|
|
|
|
|
|
if (renderer != NULL) {
|
|
|
|
renderer->setUseGpuDevice();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|