diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-25 17:52:32 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-25 17:52:32 +0000 |
commit | 37799e1f910877e6e87f43584325463efa4d6329 (patch) | |
tree | 54f25c60f397e773027653c6dd6f99c6a726113b /gm/tilemodes.cpp | |
parent | ea348cb4352cfa09fb060854057dc89ae102a976 (diff) |
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
Diffstat (limited to 'gm/tilemodes.cpp')
-rw-r--r-- | gm/tilemodes.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/gm/tilemodes.cpp b/gm/tilemodes.cpp index a11ff4ebb9..be7f924f79 100644 --- a/gm/tilemodes.cpp +++ b/gm/tilemodes.cpp @@ -54,35 +54,46 @@ static const SkBitmap::Config gConfigs[] = { SkBitmap::kARGB_8888_Config, SkBitmap::kRGB_565_Config, }; -static const int gWidth = 32; -static const int gHeight = 32; class TilingGM : public skiagm::GM { SkBlurDrawLooper fLooper; public: - TilingGM() - : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), - 0x88000000) { + TilingGM(bool powerOfTwoSize) + : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), 0x88000000) + , fPowerOfTwoSize(powerOfTwoSize) { } SkBitmap fTexture[SK_ARRAY_COUNT(gConfigs)]; protected: + + enum { + kPOTSize = 32, + kNPOTSize = 21, + }; + SkString onShortName() { - return SkString("tilemodes"); + SkString name("tilemodes"); + if (!fPowerOfTwoSize) { + name.append("_npot"); + } + return name; } SkISize onISize() { return SkISize::Make(880, 560); } virtual void onOnceBeforeDraw() SK_OVERRIDE { + int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; 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 { - 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" }; @@ -145,9 +156,13 @@ protected: } private: + bool fPowerOfTwoSize; typedef skiagm::GM INHERITED; }; +static const int gWidth = 32; +static const int gHeight = 32; + static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) { SkBitmap bm; 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_grad, "gradient"); ) |