HeadlessView class final
A view that draws a World offscreen and reads the pixels back: for
tests and tools, not for showing on screen (package:fynkel_flutter's
FynkelView does that).
- Inheritance
- Available extensions
Constructors
- HeadlessView(World world, {required int width, required int height})
-
A view of
worlddrawingwidth×heightpixel frames, with its own render worker. Throws an ArgumentError for a size of 0, and a FynkelException when there's no GPU or the worker won't start. Dispose of it when done.
Properties
- address → int
-
The native view, for the platform plugins' calls. A plugin must stop
using it before dispose.
no setterinherited
- camera ↔ Camera?
-
The camera the view draws from: its own, or the world's main one
(World.camera) when null. Read at each frame. While its object
isn't a live, shown object of the world (not added yet, destroyed,
inactive), the view draws black, not the main camera's picture.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → int
-
The height the frames from the next frame on are drawn at, in
pixels.
no setterinherited
- isDisposed → bool
-
Whether dispose was called; then frame, resize, stats and
the rest of its calls throw a StateError.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stats → ViewStats
-
What the view did since it was made, and the GPU memory it holds
now. Subtract an earlier one for the counts in between.
no setterinherited
- width → int
-
The width the frames from the next frame on are drawn at, in pixels.
no setterinherited
Methods
-
dispose(
) → void -
Stops the render worker (after the frame it's drawing) and frees the
view. Calling it again does nothing.
override
-
expectFrame(
String path, {bool? bless, String failures = 'build/fynkel_failures'}) → void -
Available on HeadlessView, provided by the HeadlessViewTesting extension
Draws the world as it is now and checks the picture against the PNG atpath, as expectImage does:view.expectFrame('test/frames/start.png'). -
frame(
) → int -
Copies the world and hands it to the render worker, without waiting
for the GPU. Returns the frame's number (1, 2, …).
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
png(
{Duration timeout = const Duration(seconds: 10)}) → Uint8List -
Draws the world as it is now and gives the picture as a PNG file's
bytes, to look at what a test sees:
File('shot.png').writeAsBytesSync(view.png()). -
read(
int number, {Duration timeout = const Duration(seconds: 10)}) → ({int number, Uint8List rgba}) -
Waits up to
timeoutfor framenumber(or a later one) to finish and returns its number and pixels: RGBA8 in sRGB, rows top to bottom, at the size the frame was drawn. -
releaseImages(
) → void -
Lets go of the images the view draws through (its shadow maps and the
pictures its effects work on), for when memory is short and the view
isn't drawing. The render thread does it soon after, with no frame
needed. The next frame makes them again, for the same picture, so
doing this while drawing only costs a slow frame.
inherited
-
resize(
int width, int height) → void -
Draws the frames from the next frame on at
width×heightpixels. Frames already on their way finish at the old size and are never shown.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited