• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
7 
8 #include "gm/gm.h"
9 #include "include/core/SkBitmap.h"
10 #include "include/core/SkCanvas.h"
11 #include "include/core/SkColorPriv.h"
12 #include "include/core/SkPaint.h"
13 #include "include/core/SkShader.h"
14 #include "include/core/SkSize.h"
15 #include "include/core/SkString.h"
16 #include "include/core/SkTileMode.h"
17 
18 namespace {
19 class TinyBitmapGM : public skiagm::GM {
onOnceBeforeDraw()20     void onOnceBeforeDraw() override { this->setBGColor(0xFFDDDDDD); }
21 
onShortName()22     SkString onShortName() override { return SkString("tinybitmap"); }
23 
onISize()24     virtual SkISize onISize() override { return SkISize::Make(100, 100); }
25 
onDraw(SkCanvas * canvas)26     void onDraw(SkCanvas* canvas) override {
27         SkBitmap bm;
28         bm.allocN32Pixels(1, 1);
29         *bm.getAddr32(0, 0) = SkPackARGB32(0x80, 0x80, 0, 0);
30         SkPaint paint;
31         paint.setAlphaf(0.5f);
32         paint.setShader(bm.makeShader(SkTileMode::kRepeat, SkTileMode::kMirror));
33         canvas->drawPaint(paint);
34     }
35 };
36 }
37 
38 DEF_GM( return new TinyBitmapGM; )
39