Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: gm/tilemodes.cpp

Issue 20204006: Add NPOT version of tilemodes GM (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/tilemodes.cpp
diff --git a/gm/tilemodes.cpp b/gm/tilemodes.cpp
index a11ff4ebb9c3e013cda4be2ae7c956cab3527f86..be7f924f7903a913e0217816f9e6e190e4a440e7 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"); )
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698