1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 #include "tools/fiddle/examples.h"
4 REG_FIDDLE(Pixmap_isOpaque, 256, 256, true, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 std::vector<uint32_t> pixels;
7 const int height = 2;
8 const int width = 2;
9 pixels.resize(height * width * 4);
10 SkPixmap pixmap(SkImageInfo::Make(width, height, kN32_SkColorType,
11 kPremul_SkAlphaType), (const void*) &pixels.front(), width * 4);
12 for (int index = 0; index < 2; ++index) {
13 pixmap.erase(0x00000000);
14 SkDebugf("isOpaque: %s\n", pixmap.isOpaque() ? "true" : "false");
15 pixmap.erase(0xFFFFFFFF);
16 SkDebugf("isOpaque: %s\n", pixmap.isOpaque() ? "true" : "false");
17 pixmap.reset(pixmap.info().makeAlphaType(kOpaque_SkAlphaType),
18 (const void*) &pixels.front(), width * 4);
19 }
20 }
21 } // END FIDDLE
22