2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2019-03-20 16:12:10 +00:00
|
|
|
#include "SkCanvas.h"
|
2011-07-18 21:19:31 +00:00
|
|
|
#include "SkColorPriv.h"
|
|
|
|
#include "SkShader.h"
|
2018-08-21 15:45:46 +00:00
|
|
|
#include "SkUTF.h"
|
2019-03-20 16:12:10 +00:00
|
|
|
#include "ToolUtils.h"
|
|
|
|
#include "gm.h"
|
2011-07-18 21:19:31 +00:00
|
|
|
|
|
|
|
namespace skiagm {
|
|
|
|
|
|
|
|
static SkBitmap make_bitmap() {
|
2013-10-10 14:44:56 +00:00
|
|
|
SkBitmap bm;
|
2017-07-12 19:10:28 +00:00
|
|
|
bm.allocN32Pixels(1, 1);
|
|
|
|
*bm.getAddr32(0, 0) = SkPackARGB32(0x80, 0x80, 0, 0);
|
2011-07-18 21:19:31 +00:00
|
|
|
return bm;
|
|
|
|
}
|
|
|
|
|
|
|
|
class TinyBitmapGM : public GM {
|
|
|
|
public:
|
|
|
|
TinyBitmapGM() {
|
2018-08-16 14:17:03 +00:00
|
|
|
this->setBGColor(0xFFDDDDDD);
|
2011-07-18 21:19:31 +00:00
|
|
|
}
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2011-07-18 21:19:31 +00:00
|
|
|
protected:
|
|
|
|
SkString onShortName() {
|
|
|
|
return SkString("tinybitmap");
|
|
|
|
}
|
|
|
|
|
2014-06-10 06:59:03 +00:00
|
|
|
virtual SkISize onISize() { return SkISize::Make(100, 100); }
|
2011-07-18 21:19:31 +00:00
|
|
|
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
2012-11-27 15:15:58 +00:00
|
|
|
SkBitmap bm = make_bitmap();
|
2011-07-18 21:19:31 +00:00
|
|
|
SkPaint paint;
|
2019-02-15 21:13:57 +00:00
|
|
|
paint.setAlphaf(0.5f);
|
2019-04-08 17:20:23 +00:00
|
|
|
paint.setShader(bm.makeShader(SkTileMode::kRepeat, SkTileMode::kMirror));
|
2011-07-18 21:19:31 +00:00
|
|
|
canvas->drawPaint(paint);
|
|
|
|
}
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2011-07-18 21:19:31 +00:00
|
|
|
private:
|
|
|
|
typedef GM INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-01-23 15:22:01 +00:00
|
|
|
DEF_GM( return new TinyBitmapGM; )
|
2011-07-18 21:19:31 +00:00
|
|
|
|
|
|
|
}
|