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=275356b65d18c8868f4434137350cddc 5cb93a386Sopenharmony_ciREG_FIDDLE(Image_MakeFromRaster, 256, 256, true, 0) { 6cb93a386Sopenharmony_cistatic void releaseProc(const void* pixels, SkImage::ReleaseContext context) { 7cb93a386Sopenharmony_ci int* countPtr = static_cast<int*>(context); 8cb93a386Sopenharmony_ci *countPtr += 1; 9cb93a386Sopenharmony_ci} 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 12cb93a386Sopenharmony_ci SkColor color = 0; 13cb93a386Sopenharmony_ci SkPixmap pixmap(SkImageInfo::MakeN32(1, 1, kPremul_SkAlphaType), &color, 4); 14cb93a386Sopenharmony_ci int releaseCount = 0; 15cb93a386Sopenharmony_ci sk_sp<SkImage> image(SkImage::MakeFromRaster(pixmap, releaseProc, &releaseCount)); 16cb93a386Sopenharmony_ci SkDebugf("before reset: %d\n", releaseCount); 17cb93a386Sopenharmony_ci image.reset(); 18cb93a386Sopenharmony_ci SkDebugf("after reset: %d\n", releaseCount); 19cb93a386Sopenharmony_ci} 20cb93a386Sopenharmony_ci} // END FIDDLE 21