skia2/gm/bicubicfilter.cpp
commit-bot@chromium.org a90c680386 Turn on quilt mode in DM.
- Rename TileGrid -> Quilt to avoid the name overload.
  - Tag all failing GMs with kSkipTiled_Flag.

You may be wondering, do any GMs pass?  Yes, some do!  And that trends towards all of them as we increase --quiltTile.

Two GMs only fail in --quilt mode in 565.  Otherwise all GMs which fail are skipped, and those which don't fail aren't. (The 8888 variants of those two GMs are skipped even though they pass.)

BUG=skia:2477
R=reed@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/256373002

git-svn-id: http://skia.googlecode.com/svn/trunk@14457 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-30 13:20:45 +00:00

87 lines
2.4 KiB
C++

/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkColor.h"
#include "SkBicubicImageFilter.h"
namespace skiagm {
class BicubicGM : public GM {
public:
BicubicGM() : fInitialized(false) {
this->setBGColor(0x00000000);
}
protected:
virtual uint32_t onGetFlags() const SK_OVERRIDE {
return kSkipTiled_Flag;
}
virtual SkString onShortName() {
return SkString("bicubicfilter");
}
void make_checkerboard(int width, int height) {
SkASSERT(width % 2 == 0);
SkASSERT(height % 2 == 0);
fCheckerboard.allocN32Pixels(width, height);
for (int y = 0; y < height; y += 2) {
SkPMColor* s = fCheckerboard.getAddr32(0, y);
for (int x = 0; x < width; x += 2) {
*s++ = 0xFFFFFFFF;
*s++ = 0xFF000000;
}
s = fCheckerboard.getAddr32(0, y + 1);
for (int x = 0; x < width; x += 2) {
*s++ = 0xFF000000;
*s++ = 0xFFFFFFFF;
}
}
}
virtual SkISize onISize() {
return make_isize(400, 300);
}
virtual void onDraw(SkCanvas* canvas) {
if (!fInitialized) {
make_checkerboard(4, 4);
fInitialized = true;
}
SkScalar sk32 = SkIntToScalar(32);
canvas->clear(0x00000000);
SkPaint bilinearPaint, bicubicPaint;
SkSize scale = SkSize::Make(sk32, sk32);
canvas->save();
canvas->scale(sk32, sk32);
bilinearPaint.setFilterLevel(SkPaint::kLow_FilterLevel);
canvas->drawBitmap(fCheckerboard, 0, 0, &bilinearPaint);
canvas->restore();
SkAutoTUnref<SkImageFilter> bicubic(SkBicubicImageFilter::CreateMitchell(scale));
bicubicPaint.setImageFilter(bicubic);
SkRect srcBounds;
fCheckerboard.getBounds(&srcBounds);
canvas->translate(SkIntToScalar(140), 0);
canvas->saveLayer(&srcBounds, &bicubicPaint);
canvas->drawBitmap(fCheckerboard, 0, 0);
canvas->restore();
}
private:
typedef GM INHERITED;
SkBitmap fCheckerboard;
bool fInitialized;
};
//////////////////////////////////////////////////////////////////////////////
static GM* MyFactory(void*) { return new BicubicGM; }
static GMRegistry reg(MyFactory);
}