| Flutter macOS Embedder |

Instance Methods | List of all members
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 81 of file FlutterSurfaceManager.h.

## Method Documentation

## ◆ count

- (NSUInteger) count |  |  |

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

Definition at line 309 of file FlutterSurfaceManager.mm.

309 {
310 @synchronized(self) {
311 return _surfaces.count;
312 }
313 }

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 285 of file FlutterSurfaceManager.mm.

285 :(CGSize)size {
286 @synchronized(self) {
287 for (FlutterSurface* surface in _surfaces) {
288 if (CGSizeEqualToSize(surface.size, size)) {
289 // By default ARC doesn't retain enumeration iteration variables.
290 FlutterSurface* res = surface;
291 [_surfaces removeObject:surface];
292 return res;
293 }
294 }
295 return nil;
296 }
297 }

References FlutterSurface::size.

## ◆ replaceSurfaces:

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

Removes all cached surfaces replacing them with new ones.

Definition at line 299 of file FlutterSurfaceManager.mm.

299 :(nonnull NSArray<FlutterSurface*>*)surfaces {
300 @synchronized(self) {
301 [_surfaces removeAllObjects];
302 [_surfaces addObjectsFromArray:surfaces];
303 }
304
305 // performSelector:withObject:afterDelay needs to be performed on RunLoop thread
306 [self performSelectorOnMainThread:@selector(reschedule) withObject:nil waitUntilDone:NO];
307 }

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

- shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h
- shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm

FlutterSurface
Definition: FlutterSurface.h:16