epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 9 | #include "include/core/SkBitmap.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/core/SkCanvas.h" |
| 11 | #include "include/core/SkColorPriv.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 12 | #include "include/core/SkPaint.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "include/core/SkShader.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 14 | #include "include/core/SkSize.h" |
| 15 | #include "include/core/SkString.h" |
| 16 | #include "include/core/SkTileMode.h" |
bsalomon@google.com | 1936f26 | 2011-07-18 21:19:31 +0000 | [diff] [blame] | 17 | |
Hal Canary | fa3305a | 2019-07-18 12:36:54 -0400 | [diff] [blame] | 18 | namespace { |
| 19 | class TinyBitmapGM : public skiagm::GM { |
| 20 | void onOnceBeforeDraw() override { this->setBGColor(0xFFDDDDDD); } |
bsalomon@google.com | 1936f26 | 2011-07-18 21:19:31 +0000 | [diff] [blame] | 21 | |
Hal Canary | fa3305a | 2019-07-18 12:36:54 -0400 | [diff] [blame] | 22 | SkString onShortName() override { return SkString("tinybitmap"); } |
bsalomon@google.com | 1936f26 | 2011-07-18 21:19:31 +0000 | [diff] [blame] | 23 | |
Hal Canary | fa3305a | 2019-07-18 12:36:54 -0400 | [diff] [blame] | 24 | virtual SkISize onISize() override { return SkISize::Make(100, 100); } |
rmistry@google.com | ae933ce | 2012-08-23 18:19:56 +0000 | [diff] [blame] | 25 | |
Hal Canary | fa3305a | 2019-07-18 12:36:54 -0400 | [diff] [blame] | 26 | void onDraw(SkCanvas* canvas) override { |
| 27 | SkBitmap bm; |
| 28 | bm.allocN32Pixels(1, 1); |
| 29 | *bm.getAddr32(0, 0) = SkPackARGB32(0x80, 0x80, 0, 0); |
bsalomon@google.com | 1936f26 | 2011-07-18 21:19:31 +0000 | [diff] [blame] | 30 | SkPaint paint; |
Mike Reed | 9407e24 | 2019-02-15 16:13:57 -0500 | [diff] [blame] | 31 | paint.setAlphaf(0.5f); |
Mike Reed | 50acf8f | 2019-04-08 13:20:23 -0400 | [diff] [blame] | 32 | paint.setShader(bm.makeShader(SkTileMode::kRepeat, SkTileMode::kMirror)); |
bsalomon@google.com | 1936f26 | 2011-07-18 21:19:31 +0000 | [diff] [blame] | 33 | canvas->drawPaint(paint); |
| 34 | } |
bsalomon@google.com | 1936f26 | 2011-07-18 21:19:31 +0000 | [diff] [blame] | 35 | }; |
Hal Canary | fa3305a | 2019-07-18 12:36:54 -0400 | [diff] [blame] | 36 | } |
bsalomon@google.com | 1936f26 | 2011-07-18 21:19:31 +0000 | [diff] [blame] | 37 | |
Hal Canary | e964c18 | 2019-01-23 10:22:01 -0500 | [diff] [blame] | 38 | DEF_GM( return new TinyBitmapGM; ) |