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-05-01 21:28:53 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "gm/gm.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkBitmap.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkColorPriv.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkPaint.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkShader.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkSize.h"
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "include/core/SkTileMode.h"
|
2011-07-18 21:19:31 +00:00
|
|
|
|
2019-07-18 16:36:54 +00:00
|
|
|
namespace {
|
|
|
|
class TinyBitmapGM : public skiagm::GM {
|
|
|
|
void onOnceBeforeDraw() override { this->setBGColor(0xFFDDDDDD); }
|
2011-07-18 21:19:31 +00:00
|
|
|
|
2019-07-18 16:36:54 +00:00
|
|
|
SkString onShortName() override { return SkString("tinybitmap"); }
|
2011-07-18 21:19:31 +00:00
|
|
|
|
2020-08-14 02:58:04 +00:00
|
|
|
SkISize onISize() override { return SkISize::Make(100, 100); }
|
2011-07-18 21:19:31 +00:00
|
|
|
|
2019-07-18 16:36:54 +00:00
|
|
|
void onDraw(SkCanvas* canvas) override {
|
|
|
|
SkBitmap bm;
|
|
|
|
bm.allocN32Pixels(1, 1);
|
|
|
|
*bm.getAddr32(0, 0) = SkPackARGB32(0x80, 0x80, 0, 0);
|
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);
|
|
|
|
}
|
|
|
|
};
|
2020-08-06 18:11:56 +00:00
|
|
|
} // namespace
|
2011-07-18 21:19:31 +00:00
|
|
|
|
2019-01-23 15:22:01 +00:00
|
|
|
DEF_GM( return new TinyBitmapGM; )
|