|
|
@ -1,4 +1,5 @@
|
|
|
|
import 'dart:ui';
|
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:collection/collection.dart' as collection;
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flame/components.dart';
|
|
|
|
import 'package:flame/components.dart';
|
|
|
|
import 'package:pinball_flame/src/canvas/canvas_wrapper.dart';
|
|
|
|
import 'package:pinball_flame/src/canvas/canvas_wrapper.dart';
|
|
|
@ -56,7 +57,14 @@ class _ZCanvas extends CanvasWrapper {
|
|
|
|
final List<ZIndex> _zBuffer = [];
|
|
|
|
final List<ZIndex> _zBuffer = [];
|
|
|
|
|
|
|
|
|
|
|
|
/// Postpones the rendering of [ZIndex] component and its children.
|
|
|
|
/// Postpones the rendering of [ZIndex] component and its children.
|
|
|
|
void buffer(ZIndex component) => _zBuffer.add(component);
|
|
|
|
void buffer(ZIndex component) {
|
|
|
|
|
|
|
|
final lowerBound = collection.lowerBound<ZIndex>(
|
|
|
|
|
|
|
|
_zBuffer,
|
|
|
|
|
|
|
|
component,
|
|
|
|
|
|
|
|
compare: (a, b) => a.zIndex.compareTo(b.zIndex),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
_zBuffer.insert(lowerBound, component);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Renders all [ZIndex] components and their children.
|
|
|
|
/// Renders all [ZIndex] components and their children.
|
|
|
|
///
|
|
|
|
///
|
|
|
@ -69,8 +77,7 @@ class _ZCanvas extends CanvasWrapper {
|
|
|
|
/// before the second one.
|
|
|
|
/// before the second one.
|
|
|
|
/// {@endtemplate}
|
|
|
|
/// {@endtemplate}
|
|
|
|
void render() => _zBuffer
|
|
|
|
void render() => _zBuffer
|
|
|
|
..sort((a, b) => a.zIndex.compareTo(b.zIndex))
|
|
|
|
..forEach(_render)
|
|
|
|
..whereType<Component>().forEach(_render)
|
|
|
|
|
|
|
|
..clear();
|
|
|
|
..clear();
|
|
|
|
|
|
|
|
|
|
|
|
void _render(Component component) => component.renderTree(canvas);
|
|
|
|
void _render(Component component) => component.renderTree(canvas);
|
|
|
|