Add NPOT version of tilemodes GM

R=reed@google.com

Author: bsalomon@google.com

Review URL: https://chromiumcodereview.appspot.com/20204006

git-svn-id: http://skia.googlecode.com/svn/trunk@10364 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2013-07-25 17:52:32 +00:00
parent ea348cb435
commit 37799e1f91

View File

@ -54,35 +54,46 @@ static const SkBitmap::Config gConfigs[] = {
SkBitmap::kARGB_8888_Config, SkBitmap::kARGB_8888_Config,
SkBitmap::kRGB_565_Config, SkBitmap::kRGB_565_Config,
}; };
static const int gWidth = 32;
static const int gHeight = 32;
class TilingGM : public skiagm::GM { class TilingGM : public skiagm::GM {
SkBlurDrawLooper fLooper; SkBlurDrawLooper fLooper;
public: public:
TilingGM() TilingGM(bool powerOfTwoSize)
: fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), 0x88000000)
0x88000000) { , fPowerOfTwoSize(powerOfTwoSize) {
} }
SkBitmap fTexture[SK_ARRAY_COUNT(gConfigs)]; SkBitmap fTexture[SK_ARRAY_COUNT(gConfigs)];
protected: protected:
enum {
kPOTSize = 32,
kNPOTSize = 21,
};
SkString onShortName() { SkString onShortName() {
return SkString("tilemodes"); SkString name("tilemodes");
if (!fPowerOfTwoSize) {
name.append("_npot");
}
return name;
} }
SkISize onISize() { return SkISize::Make(880, 560); } SkISize onISize() { return SkISize::Make(880, 560); }
virtual void onOnceBeforeDraw() SK_OVERRIDE { virtual void onOnceBeforeDraw() SK_OVERRIDE {
int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) {
makebm(&fTexture[i], gConfigs[i], gWidth, gHeight); makebm(&fTexture[i], gConfigs[i], size, size);
} }
} }
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkRect r = { 0, 0, SkIntToScalar(gWidth*2), SkIntToScalar(gHeight*2) }; int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) };
static const char* gConfigNames[] = { "8888", "565", "4444" }; static const char* gConfigNames[] = { "8888", "565", "4444" };
@ -145,9 +156,13 @@ protected:
} }
private: private:
bool fPowerOfTwoSize;
typedef skiagm::GM INHERITED; typedef skiagm::GM INHERITED;
}; };
static const int gWidth = 32;
static const int gHeight = 32;
static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) { static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) {
SkBitmap bm; SkBitmap bm;
makebm(&bm, SkBitmap::kARGB_8888_Config, gWidth, gHeight); makebm(&bm, SkBitmap::kARGB_8888_Config, gWidth, gHeight);
@ -248,6 +263,7 @@ private:
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
DEF_GM( return new TilingGM; ) DEF_GM( return new TilingGM(true); )
DEF_GM( return new TilingGM(false); )
DEF_GM( return new Tiling2GM(make_bm, "bitmap"); ) DEF_GM( return new Tiling2GM(make_bm, "bitmap"); )
DEF_GM( return new Tiling2GM(make_grad, "gradient"); ) DEF_GM( return new Tiling2GM(make_grad, "gradient"); )