Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Surface_MakeRasterDirectReleaseProc.cpp
Go to the documentation of this file.
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.
4// HASH=8e6530b26ab4096a9a91cfaadda1c568
5REG_FIDDLE(Surface_WrapPixels_WithReleaseProc, 256, 256, true, 0) {
6 static void release_direct_surface_storage(void* pixels, void* context) {
7 if (pixels == context) {
8 SkDebugf("expected release context\n");
9 }
10 sk_free(pixels);
11 }
12
13 void draw(SkCanvas*) {
15 const size_t rowBytes = info.minRowBytes();
16 void* pixels = sk_malloc_throw(info.computeByteSize(rowBytes));
18 info, pixels, rowBytes, release_direct_surface_storage, pixels));
19 SkCanvas* canvas = surface->getCanvas();
20 canvas->clear(SK_ColorWHITE);
21 SkPMColor* colorPtr = (SkPMColor*)pixels;
22 SkPMColor pmWhite = colorPtr[0];
24 canvas->drawPoint(1, 1, paint);
25 for (int y = 0; y < info.height(); ++y) {
26 for (int x = 0; x < info.width(); ++x) {
27 SkDebugf("%c", *colorPtr++ == pmWhite ? '-' : 'x');
28 }
29 SkDebugf("\n");
30 }
31 }
32} // END FIDDLE
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
uint32_t SkPMColor
Definition SkColor.h:205
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
Definition SkMalloc.h:67
static void release_direct_surface_storage(void *pixels, void *context)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void drawPoint(SkScalar x, SkScalar y, const SkPaint &paint)
void clear(SkColor color)
Definition SkCanvas.h:1199
const Paint & paint
VkSurfaceKHR surface
Definition main.cc:49
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
double y
double x
SK_API sk_sp< SkSurface > WrapPixels(const SkImageInfo &imageInfo, void *pixels, size_t rowBytes, const SkSurfaceProps *surfaceProps=nullptr)
static SkImageInfo MakeN32Premul(int width, int height)