Flutter Engine
The Flutter Engine
Functions
Surface_MakeRasterDirectReleaseProc.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (Surface_WrapPixels_WithReleaseProc, 256, 256, true, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Surface_WrapPixels_WithReleaseProc  ,
256  ,
256  ,
true  ,
 
)

Definition at line 4 of file Surface_MakeRasterDirectReleaseProc.cpp.

4 {
5 static void release_direct_surface_storage(void* pixels, void* context) {
6 if (pixels == context) {
7 SkDebugf("expected release context\n");
8 }
9 sk_free(pixels);
10 }
11
12 void draw(SkCanvas*) {
14 const size_t rowBytes = info.minRowBytes();
15 void* pixels = sk_malloc_throw(info.computeByteSize(rowBytes));
17 info, pixels, rowBytes, release_direct_surface_storage, pixels));
18 SkCanvas* canvas = surface->getCanvas();
19 canvas->clear(SK_ColorWHITE);
20 SkPMColor* colorPtr = (SkPMColor*)pixels;
21 SkPMColor pmWhite = colorPtr[0];
23 canvas->drawPoint(1, 1, paint);
24 for (int y = 0; y < info.height(); ++y) {
25 for (int x = 0; x < info.width(); ++x) {
26 SkDebugf("%c", *colorPtr++ == pmWhite ? '-' : 'x');
27 }
28 SkDebugf("\n");
29 }
30 }
31} // 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)
Definition: SurfaceTest.cpp:86
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawPoint(SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2695
void clear(SkColor color)
Definition: SkCanvas.h:1199
const Paint & paint
Definition: color_source.cc:38
VkSurfaceKHR surface
Definition: main.cc:49
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)