Flutter Engine
The Flutter Engine
tinybitmap.cpp
Go to the documentation of this file.
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"
14#include "include/core/SkSize.h"
17
18namespace {
19class TinyBitmapGM : public skiagm::GM {
20 void onOnceBeforeDraw() override { this->setBGColor(0xFFDDDDDD); }
21
22 SkString getName() const override { return SkString("tinybitmap"); }
23
24 SkISize getISize() 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);
31 paint.setAlphaf(0.5f);
34 canvas->drawPaint(paint);
35 }
36};
37} // namespace
38
39DEF_GM( return new TinyBitmapGM; )
static SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColorPriv.h:106
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkBitmap.cpp:669
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:232
uint32_t * getAddr32(int x, int y) const
Definition: SkBitmap.h:1260
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668
Definition: gm.h:110
virtual SkISize getISize()=0
virtual void onOnceBeforeDraw()
Definition: gm.cpp:167
void setBGColor(SkColor)
Definition: gm.cpp:159
virtual SkString getName() const =0
virtual DrawResult onDraw(SkCanvas *, SkString *errorMsg)
Definition: gm.cpp:139
const Paint & paint
Definition: color_source.cc:38
#define DEF_GM(CODE)
Definition: gm.h:40
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20