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 ¶
- type Options
- type Presenter
- type Renderer
- func (r *Renderer) Attach(h gpu.SurfaceHandle) (gpu.Surface, error)
- func (r *Renderer) Close() error
- func (r *Renderer) Render(s gpu.Surface, scene *ui.Scene, size ui.Size, dpr float32) error
- func (r *Renderer) RenderCapture(s gpu.Surface, scene *ui.Scene, size ui.Size, _ float32) (*image.RGBA, error)
- func (r *Renderer) Snapshot(scene *ui.Scene, size ui.Size) (*image.RGBA, error)
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 ¶
NewRenderer makes a renderer that presents through p. More than one options value panics with MultipleOptions.
Flutter: no counterpart
func (*Renderer) Attach ¶
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 ¶
Close stops the renderer; its surfaces are destroyed. It is safe to call twice.
Flutter: no counterpart
func (*Renderer) Render ¶
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