skia2/gm/tiledscaledbitmap.cpp
bungeman 003571887d Revert of Remove uses of SkImageDecoder from gms (patchset #2 id:20001 of https://codereview.chromium.org/1791583002/ )
Reason for revert:
Suspected of causing assertion failures in unrelated tests on Windows.

Original issue's description:
> Remove uses of SkImageDecoder from gms
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1791583002
>
> Committed: https://skia.googlesource.com/skia/+/d427266a58af7e6ea6c12c9cd56ade3e179a0c04

TBR=scroggo@google.com,reed@google.com,msarett@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/1806383002
2016-03-17 10:38:36 -07:00

81 lines
1.9 KiB
C++

/*
* Copyright 2014 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 "Resources.h"
#include "SkBitmap.h"
#include "SkImageDecoder.h"
#include "SkPaint.h"
#include "SkShader.h"
#include "SkStream.h"
/***
*
* This GM reproduces Skia bug 2904, in which a tiled bitmap shader was failing to draw correctly
* when fractional image scaling was ignored by the high quality bitmap scaler.
*
***/
namespace skiagm {
class TiledScaledBitmapGM : public GM {
public:
TiledScaledBitmapGM() {
}
protected:
SkString onShortName() override {
return SkString("tiledscaledbitmap");
}
SkISize onISize() override {
return SkISize::Make(1016, 616);
}
static SkBitmap make_bm(int width, int height) {
SkBitmap bm;
bm.allocN32Pixels(width, height);
bm.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(bm);
SkPaint paint;
paint.setAntiAlias(true);
canvas.drawCircle(width/2.f, height/2.f, width/4.f, paint);
return bm;
}
void onOnceBeforeDraw() override {
fBitmap = make_bm(360, 288);
}
void onDraw(SkCanvas* canvas) override {
SkPaint paint;
paint.setAntiAlias(true);
paint.setFilterQuality(kHigh_SkFilterQuality);
SkMatrix mat;
mat.setScale(121.f/360.f, 93.f/288.f);
mat.postTranslate(-72, -72);
paint.setShader(SkShader::MakeBitmapShader(fBitmap, SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode, &mat));
canvas->drawRectCoords(8,8,1008, 608, paint);
}
private:
SkBitmap fBitmap;
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
DEF_GM(return new TiledScaledBitmapGM;)
}