nativewindow

package
v1.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package nativewindow is the last-resort renderer of Android (SPEC §24.4): the software renderer (package soft) draws the frame, and it is copied into the CPU buffers of the window's ANativeWindow (setBuffersGeometry, lock, unlockAndPost, loaded from libandroid.so through purego). It is to Android what canvas2d is to the web, and it also draws the first frames before the GPU renderers exist.

Flutter: no counterpart (Flutter's Android embedding has the Skia software surface, shell/platform/android/android_surface_software.cc)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Background is what shows where the scene draws nothing. A window of Android is opaque
	// here, so only the color's red, green and blue count; the zero value is black.
	Background ui.Color
}

Options are the optional parameters of NewRenderer.

Flutter: no counterpart

type Presenter

type Presenter interface {
	// Present shows img, an opaque image, in the window that the handle names, setting the
	// window's buffer size to the image's if it differs. It must not keep img.
	Present(h gpu.SurfaceHandle, img *image.RGBA) error
	// Release forgets what the presenter knows about the window of the handle.
	Release(h gpu.SurfaceHandle)
}

Presenter shows a finished frame in the window of a surface. The Android build's Presenter copies it into the window's buffer; tests give one that records the frames.

Flutter: no counterpart

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer is a gpu.Renderer that draws with soft and presents through a Presenter.

Flutter: shell/platform/android/android_surface_software.cc AndroidSurfaceSoftware

func NewRenderer

func NewRenderer(p Presenter, opts ...Options) *Renderer

NewRenderer makes a renderer that presents through p. More than one options value panics with MultipleOptions.

Flutter: no counterpart

func (*Renderer) Attach

func (r *Renderer) Attach(h gpu.SurfaceHandle) (gpu.Surface, error)

Attach starts drawing into the window that the handle names, which must be of kind gpu.SurfaceKindAndroid. It fails with SurfaceKindUnsupported for another kind and with RendererClosed after Close.

Flutter: no counterpart

func (*Renderer) Close

func (r *Renderer) Close() error

Close stops the renderer; its surfaces are destroyed. It is safe to call twice.

Flutter: no counterpart

func (*Renderer) Render

func (r *Renderer) Render(s gpu.Surface, scene *ui.Scene, size ui.Size, dpr float32) error

Render draws the scene into the surface at the size in device pixels and presents it. A nil scene draws the background only. The scene's coordinates are already in device pixels, so dpr is not used.

Flutter: no counterpart

func (*Renderer) RenderCapture

func (r *Renderer) RenderCapture(s gpu.Surface, scene *ui.Scene, size ui.Size, _ float32) (*image.RGBA, error)

RenderCapture is Render that also returns the frame it presented, top row first. The image belongs to the caller.

Flutter: no counterpart

func (*Renderer) Snapshot

func (r *Renderer) Snapshot(scene *ui.Scene, size ui.Size) (*image.RGBA, error)

Snapshot draws the scene into a new image of the size, without a window.

Flutter: no counterpart

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL