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 18namespace { 19class TinyBitmapGM : public skiagm::GM { 20 void onOnceBeforeDraw() override { this->setBGColor(0xFFDDDDDD); } 21 22 SkString onShortName() override { return SkString("tinybitmap"); } 23 24 SkISize onISize() override { return SkISize::Make(100, 100); } 25 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 SkSamplingOptions())); 34 canvas->drawPaint(paint); 35 } 36}; 37} // namespace 38 39DEF_GM( return new TinyBitmapGM; ) 40