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