Flutter macOS Embedder
FlutterBackBufferCache Class Reference

#import <FlutterSurfaceManager.h>

Inheritance diagram for FlutterBackBufferCache:

Instance Methods

(nullable FlutterSurface *) - removeSurfaceForSize:
 
(void) - replaceSurfaces:
 
(NSUInteger) - count
 

Detailed Description

Cache of back buffers to prevent unnecessary IOSurface allocations.

Definition at line 77 of file FlutterSurfaceManager.h.

Method Documentation

◆ count

- (NSUInteger) count

Returns number of surfaces currently in cache. Used for tests.

Definition at line 277 of file FlutterSurfaceManager.mm.

277  {
278  @synchronized(self) {
279  return _surfaces.count;
280  }
281 }

Referenced by flutter::testing::TEST().

◆ removeSurfaceForSize:

- (nullable FlutterSurface *) removeSurfaceForSize: (CGSize)  size

Removes surface with given size from cache (if available) and returns it.

Definition at line 253 of file FlutterSurfaceManager.mm.

253  :(CGSize)size {
254  @synchronized(self) {
255  for (FlutterSurface* surface in _surfaces) {
256  if (CGSizeEqualToSize(surface.size, size)) {
257  // By default ARC doesn't retain enumeration iteration variables.
258  FlutterSurface* res = surface;
259  [_surfaces removeObject:surface];
260  return res;
261  }
262  }
263  return nil;
264  }
265 }

References FlutterSurface::size.

◆ replaceSurfaces:

- (void) replaceSurfaces: (nonnull NSArray<FlutterSurface*>*)  surfaces

Removes all cached surfaces replacing them with new ones.

Definition at line 267 of file FlutterSurfaceManager.mm.

267  :(nonnull NSArray<FlutterSurface*>*)surfaces {
268  @synchronized(self) {
269  [_surfaces removeAllObjects];
270  [_surfaces addObjectsFromArray:surfaces];
271  }
272 
273  // performSelector:withObject:afterDelay needs to be performed on RunLoop thread
274  [self performSelectorOnMainThread:@selector(reschedule) withObject:nil waitUntilDone:NO];
275 }

The documentation for this class was generated from the following files:
FlutterSurface
Definition: FlutterSurface.h:13