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(Bitmap_installPixels, 256, 256, true, 0) {
releaseProc(void * addr,void *)5 static void releaseProc(void* addr, void* ) {
6 SkDebugf("releaseProc called\n");
7 delete[] (uint32_t*) addr;
8 }
9
draw(SkCanvas * canvas)10 void draw(SkCanvas* canvas) {
11 SkBitmap bitmap;
12 void* pixels = new uint32_t[8 * 8];
13 SkImageInfo info = SkImageInfo::MakeN32(8, 8, kOpaque_SkAlphaType);
14 SkDebugf("before installPixels\n");
15 bool installed = bitmap.installPixels(info, pixels, 16, releaseProc, nullptr);
16 SkDebugf("install " "%s" "successful\n", installed ? "" : "not ");
17 }
18 } // END FIDDLE
19