| Index: gm/tilemodes_scaled.cpp
|
| diff --git a/gm/tilemodes.cpp b/gm/tilemodes_scaled.cpp
|
| similarity index 78%
|
| copy from gm/tilemodes.cpp
|
| copy to gm/tilemodes_scaled.cpp
|
| index 5a5fbbe5299a7327e4fd7e433169f1d6df2385ae..63a4ef70a8cfce17b32846b03cb806c656dab8cc 100644
|
| --- a/gm/tilemodes.cpp
|
| +++ b/gm/tilemodes_scaled.cpp
|
| @@ -43,11 +43,11 @@ static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
|
| canvas.drawPaint(paint);
|
| }
|
|
|
| -static void setup(SkPaint* paint, const SkBitmap& bm, bool filter,
|
| +static void setup(SkPaint* paint, const SkBitmap& bm, SkPaint::FilterLevel filter_level,
|
| SkShader::TileMode tmx, SkShader::TileMode tmy) {
|
| SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy);
|
| paint->setShader(shader)->unref();
|
| - paint->setFilterBitmap(filter);
|
| + paint->setFilterLevel(filter_level);
|
| }
|
|
|
| static const SkBitmap::Config gConfigs[] = {
|
| @@ -55,10 +55,12 @@ static const SkBitmap::Config gConfigs[] = {
|
| SkBitmap::kRGB_565_Config,
|
| };
|
|
|
| -class TilingGM : public skiagm::GM {
|
| +class ScaledTilingGM : public skiagm::GM {
|
| + SkBlurDrawLooper fLooper;
|
| public:
|
| - TilingGM(bool powerOfTwoSize)
|
| - : fPowerOfTwoSize(powerOfTwoSize) {
|
| + ScaledTilingGM(bool powerOfTwoSize)
|
| + : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), 0x88000000)
|
| + , fPowerOfTwoSize(powerOfTwoSize) {
|
| }
|
|
|
| SkBitmap fTexture[SK_ARRAY_COUNT(gConfigs)];
|
| @@ -66,19 +68,19 @@ public:
|
| protected:
|
|
|
| enum {
|
| - kPOTSize = 32,
|
| - kNPOTSize = 21,
|
| + kPOTSize = 4,
|
| + kNPOTSize = 3,
|
| };
|
|
|
| SkString onShortName() {
|
| - SkString name("tilemodes");
|
| + SkString name("scaled_tilemodes");
|
| if (!fPowerOfTwoSize) {
|
| name.append("_npot");
|
| }
|
| return name;
|
| }
|
|
|
| - SkISize onISize() { return SkISize::Make(880, 560); }
|
| + SkISize onISize() { return SkISize::Make(880, 760); }
|
|
|
| virtual void onOnceBeforeDraw() SK_OVERRIDE {
|
| int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
|
| @@ -88,21 +90,27 @@ protected:
|
| }
|
|
|
| virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
|
| +
|
| + float scale = 32.f/kPOTSize;
|
|
|
| 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" };
|
|
|
| - static const bool gFilters[] = { false, true };
|
| - static const char* gFilterNames[] = { "point", "bilinear" };
|
| + static const SkPaint::FilterLevel gFilterLevels[] =
|
| + { SkPaint::kNone_FilterLevel,
|
| + SkPaint::kLow_FilterLevel,
|
| + SkPaint::kMedium_FilterLevel,
|
| + SkPaint::kHigh_FilterLevel };
|
| + static const char* gFilterNames[] = { "None", "Low", "Medium", "High" };
|
|
|
| static const SkShader::TileMode gModes[] = { SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode };
|
| static const char* gModeNames[] = { "C", "R", "M" };
|
|
|
| SkScalar y = SkIntToScalar(24);
|
| - SkScalar x = SkIntToScalar(10);
|
| + SkScalar x = SkIntToScalar(10)/scale;
|
|
|
| for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
|
| for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
|
| @@ -110,20 +118,21 @@ protected:
|
| SkString str;
|
| p.setAntiAlias(true);
|
| p.setDither(true);
|
| + p.setLooper(&fLooper);
|
| str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]);
|
|
|
| p.setTextAlign(SkPaint::kCenter_Align);
|
| - canvas->drawText(str.c_str(), str.size(), x + r.width()/2, y, p);
|
| + canvas->drawText(str.c_str(), str.size(), scale*(x + r.width()/2), y, p);
|
|
|
| x += r.width() * 4 / 3;
|
| }
|
| }
|
|
|
| - y += SkIntToScalar(16);
|
| + y = SkIntToScalar(40) / scale;
|
|
|
| for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) {
|
| - for (size_t j = 0; j < SK_ARRAY_COUNT(gFilters); j++) {
|
| - x = SkIntToScalar(10);
|
| + for (size_t j = 0; j < SK_ARRAY_COUNT(gFilterLevels); j++) {
|
| + x = SkIntToScalar(10)/scale;
|
| for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
|
| for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
|
| SkPaint paint;
|
| @@ -133,10 +142,11 @@ protected:
|
| makebm(&fTexture[i], gConfigs[i], size, size);
|
| }
|
| #endif
|
| - setup(&paint, fTexture[i], gFilters[j], gModes[kx], gModes[ky]);
|
| + setup(&paint, fTexture[i], gFilterLevels[j], gModes[kx], gModes[ky]);
|
| paint.setDither(true);
|
|
|
| canvas->save();
|
| + canvas->scale(scale,scale);
|
| canvas->translate(x, y);
|
| canvas->drawRect(r, paint);
|
| canvas->restore();
|
| @@ -148,8 +158,9 @@ protected:
|
| SkPaint p;
|
| SkString str;
|
| p.setAntiAlias(true);
|
| + p.setLooper(&fLooper);
|
| str.printf("%s, %s", gConfigNames[i], gFilterNames[j]);
|
| - canvas->drawText(str.c_str(), str.size(), x, y + r.height() * 2 / 3, p);
|
| + canvas->drawText(str.c_str(), str.size(), scale*x, scale*(y + r.height() * 2 / 3), p);
|
| }
|
|
|
| y += r.height() * 4 / 3;
|
| @@ -192,12 +203,12 @@ static SkShader* make_grad(SkShader::TileMode tx, SkShader::TileMode ty) {
|
|
|
| typedef SkShader* (*ShaderProc)(SkShader::TileMode, SkShader::TileMode);
|
|
|
| -class Tiling2GM : public skiagm::GM {
|
| +class ScaledTiling2GM : public skiagm::GM {
|
| ShaderProc fProc;
|
| SkString fName;
|
| public:
|
| - Tiling2GM(ShaderProc proc, const char name[]) : fProc(proc) {
|
| - fName.printf("tilemode_%s", name);
|
| + ScaledTiling2GM(ShaderProc proc, const char name[]) : fProc(proc) {
|
| + fName.printf("scaled_tilemode_%s", name);
|
| }
|
|
|
| protected:
|
| @@ -265,7 +276,7 @@ private:
|
|
|
| //////////////////////////////////////////////////////////////////////////////
|
|
|
| -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"); )
|
| +DEF_GM( return new ScaledTilingGM(true); )
|
| +DEF_GM( return new ScaledTilingGM(false); )
|
| +DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); )
|
| +DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); )
|
|
|