#include <FlutterSurfaceManager.h>
Cache of back buffers to prevent unnecessary IOSurface allocations.
Definition at line 81 of file FlutterSurfaceManager.h.
◆ ageForSurface:
Definition at line 277 of file FlutterSurfaceManager.mm.
293 NSNumber* age = [_surfaceAge objectForKey:surface];
294 return age != nil ? age.intValue : 0;
295}
◆ count
Returns number of surfaces currently in cache. Used for tests.
Definition at line 277 of file FlutterSurfaceManager.mm.
352 {
353 @synchronized(self) {
355 }
356}
NSMutableArray< FlutterSurface * > * _surfaces
◆ dealloc
Definition at line 277 of file FlutterSurfaceManager.mm.
369 {
370 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(onIdle) object:nil];
371}
◆ init
Definition at line 277 of file FlutterSurfaceManager.mm.
284 {
285 if (
self = [super
init]) {
286 self->_surfaces = [[NSMutableArray alloc] init];
287 self->_surfaceAge = [NSMapTable weakToStrongObjectsMapTable];
288 }
289 return self;
290}
◆ onIdle
◆ removeSurfaceForSize:
Removes surface with given size from cache (if available) and returns it.
Definition at line 277 of file FlutterSurfaceManager.mm.
301 :(CGSize)size {
302 @synchronized(self) {
303
304 if (
_surfaces.firstObject != nil && !CGSizeEqualToSize(
_surfaces.firstObject.size, size)) {
305 [_surfaces removeAllObjects];
306 }
307
309
310
311
312
315 (res == nil || [
self ageForSurface:res] > [
self ageForSurface:
surface])) {
317 }
318 }
319 if (res != nil) {
320 [_surfaces removeObject:res];
321 }
322 return res;
323 }
324}
◆ reschedule
Definition at line 277 of file FlutterSurfaceManager.mm.
364 {
365 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(onIdle) object:nil];
366 [self performSelector:@selector(onIdle) withObject:nil afterDelay:kIdleDelay];
367}
◆ returnSurfaces:
Removes all cached surfaces replacing them with new ones.
Definition at line 277 of file FlutterSurfaceManager.mm.
326 :(nonnull NSArray<FlutterSurface*>*)returnedSurfaces {
327 @synchronized(self) {
329 [self setAge:0 forSurface:surface];
330 }
332 [self setAge:[self ageForSurface:surface] + 1 forSurface:surface];
333 }
334
335 [_surfaces addObjectsFromArray:returnedSurfaces];
336
337
338
339
340
341
342 [_surfaces filterUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(FlutterSurface* surface,
343 NSDictionary* bindings) {
344 return [self ageForSurface:surface] < kSurfaceEvictionAge;
345 }]];
346 }
347
348
349 [self performSelectorOnMainThread:@selector(reschedule) withObject:nil waitUntilDone:NO];
350}
◆ setAge:forSurface:
Definition at line 277 of file FlutterSurfaceManager.mm.
299}
Type::kYUV Type::kRGBA() int(0.7 *637)
NSMapTable< FlutterSurface *, NSNumber * > * _surfaceAge
◆ _surfaceAge
◆ _surfaces
The documentation for this class was generated from the following files: