static Optional <int> GetSurfaceId(SurfaceCacheItem item) { if (item == null) { return(Optional.None()); } return(item.Surface.GetSurfaceId()); }
void Swap(SurfaceCacheItem newFrontSurface) { if (GetSurfaceId(newFrontSurface) != GetSurfaceId(_backSurface)) { // If new surface hasn't been cached, then pin the old one for deletion if (_backSurface != null) { PinSurfaceItemForWipe(_backSurface); } } _backSurface = _frontSurface; _frontSurface = newFrontSurface; _surfaceSwapped.OnNext(Unit.Default); }
void PinSurfaceItemForWipe(SurfaceCacheItem item) { item.ThrowIfNull("item"); _surfacesToBeWiped.Enqueue(item); }