blob: b2773cc740d7df5e51c9ba0b8dc801a9fa81f7e0 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001/*
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 Wagner7fde8e12019-05-01 17:28:53 -04007
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -04009#include "include/core/SkBitmap.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkCanvas.h"
11#include "include/core/SkColorPriv.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040012#include "include/core/SkPaint.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "include/core/SkShader.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040014#include "include/core/SkSize.h"
15#include "include/core/SkString.h"
16#include "include/core/SkTileMode.h"
bsalomon@google.com1936f262011-07-18 21:19:31 +000017
Hal Canaryfa3305a2019-07-18 12:36:54 -040018namespace {
19class TinyBitmapGM : public skiagm::GM {
20 void onOnceBeforeDraw() override { this->setBGColor(0xFFDDDDDD); }
bsalomon@google.com1936f262011-07-18 21:19:31 +000021
Hal Canaryfa3305a2019-07-18 12:36:54 -040022 SkString onShortName() override { return SkString("tinybitmap"); }
bsalomon@google.com1936f262011-07-18 21:19:31 +000023
Hal Canaryfa3305a2019-07-18 12:36:54 -040024 virtual SkISize onISize() override { return SkISize::Make(100, 100); }
rmistry@google.comae933ce2012-08-23 18:19:56 +000025
Hal Canaryfa3305a2019-07-18 12:36:54 -040026 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.com1936f262011-07-18 21:19:31 +000030 SkPaint paint;
Mike Reed9407e242019-02-15 16:13:57 -050031 paint.setAlphaf(0.5f);
Mike Reed50acf8f2019-04-08 13:20:23 -040032 paint.setShader(bm.makeShader(SkTileMode::kRepeat, SkTileMode::kMirror));
bsalomon@google.com1936f262011-07-18 21:19:31 +000033 canvas->drawPaint(paint);
34 }
bsalomon@google.com1936f262011-07-18 21:19:31 +000035};
Hal Canaryfa3305a2019-07-18 12:36:54 -040036}
bsalomon@google.com1936f262011-07-18 21:19:31 +000037
Hal Canarye964c182019-01-23 10:22:01 -050038DEF_GM( return new TinyBitmapGM; )