2 * Copyright 2011 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "sk_tool_utils.h"
9 #include "SkColorPriv.h"
16 static SkBitmap make_bitmap() {
17 const SkPMColor c[] = { SkPackARGB32(0x80, 0x80, 0, 0) };
20 bm.allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType,
22 SkColorTable::Make(c, SK_ARRAY_COUNT(c)));
24 *bm.getAddr8(0, 0) = 0;
28 class TinyBitmapGM : public GM {
31 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
35 SkString onShortName() {
36 return SkString("tinybitmap");
39 virtual SkISize onISize() { return SkISize::Make(100, 100); }
41 virtual void onDraw(SkCanvas* canvas) {
42 SkBitmap bm = make_bitmap();
45 paint.setShader(SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode,
46 SkShader::kMirror_TileMode));
47 canvas->drawPaint(paint);
54 //////////////////////////////////////////////////////////////////////////////
56 static GM* MyFactory(void*) { return new TinyBitmapGM; }
57 static GMRegistry reg(MyFactory);