1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC.
2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
4cb93a386Sopenharmony_ci// HASH=e9bd4f02b6cfb3ac864cb7fee7d7299c
5cb93a386Sopenharmony_ciREG_FIDDLE(ImageInfo_isOpaque, 256, 256, true, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    const int height = 2;
8cb93a386Sopenharmony_ci    const int width = 2;
9cb93a386Sopenharmony_ci    SkBitmap bitmap;
10cb93a386Sopenharmony_ci    SkImageInfo imageInfo = SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType);
11cb93a386Sopenharmony_ci    bitmap.setInfo(imageInfo);
12cb93a386Sopenharmony_ci    for (int index = 0; index < 2; ++index) {
13cb93a386Sopenharmony_ci        bitmap.allocPixels();
14cb93a386Sopenharmony_ci        bitmap.eraseColor(0x00000000);
15cb93a386Sopenharmony_ci        SkDebugf("isOpaque: %s\n", imageInfo.isOpaque() ? "true" : "false");
16cb93a386Sopenharmony_ci        bitmap.eraseColor(0xFFFFFFFF);
17cb93a386Sopenharmony_ci        SkDebugf("isOpaque: %s\n", imageInfo.isOpaque() ? "true" : "false");
18cb93a386Sopenharmony_ci        imageInfo = imageInfo.makeAlphaType(kOpaque_SkAlphaType);
19cb93a386Sopenharmony_ci        bitmap.setInfo(imageInfo);
20cb93a386Sopenharmony_ci    }
21cb93a386Sopenharmony_ci}
22cb93a386Sopenharmony_ci}  // END FIDDLE
23