Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SkiaAllocator Class Reference
Inheritance diagram for SkiaAllocator:
SkRasterHandleAllocator

Public Member Functions

 SkiaAllocator ()
 
bool allocHandle (const SkImageInfo &info, Rec *rec) override
 
void updateHandle (Handle hndl, const SkMatrix &ctm, const SkIRect &clip) override
 
- Public Member Functions inherited from SkRasterHandleAllocator
virtual ~SkRasterHandleAllocator ()=default
 

Additional Inherited Members

- Public Types inherited from SkRasterHandleAllocator
typedef void * Handle
 
- Static Public Member Functions inherited from SkRasterHandleAllocator
static std::unique_ptr< SkCanvasMakeCanvas (std::unique_ptr< SkRasterHandleAllocator >, const SkImageInfo &, const Rec *rec=nullptr, const SkSurfaceProps *props=nullptr)
 
- Protected Member Functions inherited from SkRasterHandleAllocator
 SkRasterHandleAllocator ()=default
 
 SkRasterHandleAllocator (const SkRasterHandleAllocator &)=delete
 
SkRasterHandleAllocatoroperator= (const SkRasterHandleAllocator &)=delete
 

Detailed Description

Definition at line 59 of file rasterhandleallocator.cpp.

Constructor & Destructor Documentation

◆ SkiaAllocator()

SkiaAllocator::SkiaAllocator ( )
inline

Definition at line 61 of file rasterhandleallocator.cpp.

61{}

Member Function Documentation

◆ allocHandle()

bool SkiaAllocator::allocHandle ( const SkImageInfo ,
Rec  
)
inlineoverridevirtual

Given a requested info, allocate the corresponding pixels/rowbytes, and whatever handle is desired to give clients access to those pixels. The rec also contains a proc and context which will be called when this allocation goes out of scope.

e.g. when canvas->saveLayer() is called, the allocator will be called to allocate the pixels for the layer. When canvas->restore() is called, the fReleaseProc will be called.

Implements SkRasterHandleAllocator.

Definition at line 63 of file rasterhandleallocator.cpp.

63 {
65 if (!surface) {
66 return false;
67 }
68 SkCanvas* canvas = surface->getCanvas();
69 SkPixmap pixmap;
70 canvas->peekPixels(&pixmap);
71
72 rec->fReleaseProc = [](void* pixels, void* ctx){ SkSafeUnref((SkSurface*)ctx); };
73 rec->fReleaseCtx = surface.release();
74 rec->fPixels = pixmap.writable_addr();
75 rec->fRowBytes = pixmap.rowBytes();
76 rec->fHandle = canvas;
77 canvas->save(); // balanced each time updateHandle is called
78 return true;
79 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
static void SkSafeUnref(T *obj)
Definition SkRefCnt.h:149
bool peekPixels(SkPixmap *pixmap)
int save()
Definition SkCanvas.cpp:451
size_t rowBytes() const
Definition SkPixmap.h:145
void * writable_addr() const
Definition SkPixmap.h:483
VkSurfaceKHR surface
Definition main.cc:49
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)

◆ updateHandle()

void SkiaAllocator::updateHandle ( Handle  ,
const SkMatrix ,
const SkIRect  
)
inlineoverridevirtual

Clients access the handle for a given layer by calling SkCanvas::accessTopRasterHandle(). To allow the handle to reflect the current matrix/clip in the canvs, updateHandle() is is called. The subclass is responsible to update the handle as it sees fit.

Implements SkRasterHandleAllocator.

Definition at line 81 of file rasterhandleallocator.cpp.

81 {
82 SkCanvas* canvas = (SkCanvas*)hndl;
83 canvas->restore();
84 canvas->save();
85 canvas->clipRect(SkRect::Make(clip));
86 canvas->concat(ctm);
87 }
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void restore()
Definition SkCanvas.cpp:465
void concat(const SkMatrix &matrix)
static SkRect Make(const SkISize &size)
Definition SkRect.h:669

The documentation for this class was generated from the following file: