Flutter Engine
The Flutter Engine
Functions
SkPixelRef.cpp File Reference
#include "include/core/SkPixelRef.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkDebug.h"
#include "src/core/SkBitmapCache.h"
#include "src/core/SkNextID.h"
#include "src/core/SkPixelRefPriv.h"
#include <atomic>
#include <utility>

Go to the source code of this file.

Functions

sk_sp< SkPixelRefSkMakePixelRefWithProc (int width, int height, size_t rowBytes, void *addr, void(*releaseProc)(void *addr, void *ctx), void *ctx)
 

Function Documentation

◆ SkMakePixelRefWithProc()

sk_sp< SkPixelRef > SkMakePixelRefWithProc ( int  w,
int  h,
size_t  rowBytes,
void *  addr,
void(*)(void *addr, void *ctx)  releaseProc,
void *  ctx 
)

Return a new SkMallocPixelRef with the provided pixel storage and rowBytes. On destruction, ReleaseProc will be called.

If ReleaseProc is NULL, the pixels will never be released. This can be useful if the pixels were stack allocated. However, such an SkMallocPixelRef must not live beyond its pixels (e.g. by copying an SkBitmap pointing to it, or drawing to an SkPicture).

Returns NULL on failure.

Definition at line 137 of file SkPixelRef.cpp.

138 {
139 SkASSERT(width >= 0 && height >= 0);
140 if (nullptr == releaseProc) {
141 return sk_make_sp<SkPixelRef>(width, height, addr, rowBytes);
142 }
143 struct PixelRef final : public SkPixelRef {
144 void (*fReleaseProc)(void*, void*);
145 void* fReleaseProcContext;
146 PixelRef(int w, int h, void* s, size_t r, void (*proc)(void*, void*), void* ctx)
147 : SkPixelRef(w, h, s, r), fReleaseProc(proc), fReleaseProcContext(ctx) {}
148 ~PixelRef() override { fReleaseProc(this->pixels(), fReleaseProcContext); }
149 };
150 return sk_sp<SkPixelRef>(new PixelRef(width, height, addr, rowBytes, releaseProc, ctx));
151}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static void releaseProc(const void *ptr, void *context)
void * pixels() const
Definition: SkPixelRef.h:36
struct MyStruct s
SkScalar w
SkScalar h
int32_t height
int32_t width