The layout package switched from interfaces to functions for
composing layouts. The switch made sure that no garbage is
generated for transient layouts such as Align, Inset, Stack, Flex.
Unfortunately, that left the stateful widgets and layouts: as soon
as their layout methods are embedded in a transient layout, a
closure is generated that escapes to the heap.
To avoid garbage for both transient as well as stateful widgets,
replace the functional approach with explicit begin/end methods.
A begin method generally starts an op block and returns the adjusted
constraints. An end method takes computed dimensions, ends its op
block and returns adjusted dimensions.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The os and gl packages were separate in the past, which required
uintptr for cross-package CFTypeRefs. That's no longer needed.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Now that syscall/js.TypedArrayOf is going away in Go 1.13 (sse
https://golang.org/issue/31980), copying byte slices to JS before
use is necessary. To avoid garbage, re-use a single buffer for all
transfers.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
syscall/js.TypedArrayOf is going away in Go 1.13. Avoid it for
invalidateFramebuffer by using a buffer managed by JS.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The frame callback for macOS comes in from a different thread than
the UI thread. Serialize event handling to maintain the invariant
that only one event is processed at a time.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
With layout.Widget a function instead of an interface, the amount
of per-frame garbage can be drastically reduced.
The layout code ends up slightly more explicit.
As a side benefit, the awkward ordering indexing for Flex and Stack
fit nicely into their new explicit Layout methods.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
GL_EXT_disjoint_timer_query_webgl2 is the WebGL 2 counterpart to
the WebGL 1 GL_EXT_disjoint_timer_query extension.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Some devices don't support floating point FBOs even though they
support OpenGL ES 3. Check support by creating a FBO and fail early
if no support is found.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
I found a convincing use case: stopping asynchronous activities
while paused. A follow up change will rename the stages and add
an example.
This reverts commit f9840b0963.
I'm not convinced the API is right. For exmaple, an event that
notifies a program when to save its state is both smaller and
might be sufficient.
Signed-off-by: Elias Naur <mail@eliasnaur.com>