• 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 #include "gm.h"
8 #include "sk_tool_utils.h"
9 #include "SkColorPriv.h"
10 #include "SkShader.h"
11 #include "SkCanvas.h"
12 #include "SkUTF.h"
13 
14 namespace skiagm {
15 
make_bitmap()16 static SkBitmap make_bitmap() {
17     SkBitmap bm;
18     bm.allocN32Pixels(1, 1);
19     *bm.getAddr32(0, 0) = SkPackARGB32(0x80, 0x80, 0, 0);
20     return bm;
21 }
22 
23 class TinyBitmapGM : public GM {
24 public:
TinyBitmapGM()25     TinyBitmapGM() {
26         this->setBGColor(0xFFDDDDDD);
27     }
28 
29 protected:
onShortName()30     SkString onShortName() {
31         return SkString("tinybitmap");
32     }
33 
onISize()34     virtual SkISize onISize() { return SkISize::Make(100, 100); }
35 
onDraw(SkCanvas * canvas)36     virtual void onDraw(SkCanvas* canvas) {
37         SkBitmap bm = make_bitmap();
38         SkPaint paint;
39         paint.setAlpha(0x80);
40         paint.setShader(SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode,
41                                                    SkShader::kMirror_TileMode));
42         canvas->drawPaint(paint);
43     }
44 
45 private:
46     typedef GM INHERITED;
47 };
48 
49 //////////////////////////////////////////////////////////////////////////////
50 
51 DEF_GM( return new TinyBitmapGM; )
52 
53 }
54