2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
10 #include "Resources.h"
18 * This GM reproduces Skia bug 2904, in which a tiled bitmap shader was failing to draw correctly
19 * when fractional image scaling was ignored by the high quality bitmap scaler.
25 class TiledScaledBitmapGM : public GM {
28 TiledScaledBitmapGM() {
32 SkString onShortName() override {
33 return SkString("tiledscaledbitmap");
36 SkISize onISize() override {
37 return SkISize::Make(1016, 616);
40 static SkBitmap make_bm(int width, int height) {
42 bm.allocN32Pixels(width, height);
43 bm.eraseColor(SK_ColorTRANSPARENT);
46 paint.setAntiAlias(true);
47 canvas.drawCircle(width/2.f, height/2.f, width/4.f, paint);
51 void onOnceBeforeDraw() override {
52 fBitmap = make_bm(360, 288);
55 void onDraw(SkCanvas* canvas) override {
58 paint.setAntiAlias(true);
59 paint.setFilterQuality(kHigh_SkFilterQuality);
62 mat.setScale(121.f/360.f, 93.f/288.f);
63 mat.postTranslate(-72, -72);
65 paint.setShader(SkShader::MakeBitmapShader(fBitmap, SkShader::kRepeat_TileMode,
66 SkShader::kRepeat_TileMode, &mat));
67 canvas->drawRect({ 8, 8, 1008, 608 }, paint);
76 //////////////////////////////////////////////////////////////////////////////
78 DEF_GM(return new TiledScaledBitmapGM;)