Documentation
¶
Overview ¶
Package gdiwindow is the last-resort renderer of Windows (SPEC §25.5): the software renderer (package soft) draws the frame, and a Presenter puts the image into the window with GDI, StretchDIBits at 1:1 from a top-down 32-bit DIB, into the window's device context, one call for each damaged rectangle. It is to Windows what canvas2d is to the web and nativewindow to Android.
The presenter keeps the last frame, so a WM_PAINT after an exposure (the window was uncovered) paints it again with BeginPaint and no new frame is needed. The sequence of calls is plain Go over a windowAPI, which a test replaces with a fake; the calls to Windows are in the file that carries the windows tag.
Flutter: no counterpart (Flutter's Windows embedder has a software compositor that presents with StretchDIBits, shell/platform/windows/compositor_software.cc)
Index ¶
- Constants
- type Options
- type Presenter
- type Renderer
- func (r *Renderer) Attach(h gpu.SurfaceHandle) (gpu.Surface, error)
- func (r *Renderer) Close() error
- func (r *Renderer) Invalidate(s gpu.Surface)
- 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 ¶
const ( // TagGDIPresentFailed is the tag of the error for a frame that GDI does not copy into the // window; the metadata are "window", "x", "y", "width" and "height". TagGDIPresentFailed = "GDIPresentFailed" )
The tags of the errors that this file makes (rm4n0s/errors, R5).
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 Windows 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, at 1:1. damage says
// which part changed from the frame before, which is what the window already shows; when it is
// Full, or the size of the image changed, all of the image is shown. It must not keep img.
Present(h gpu.SurfaceHandle, img *image.RGBA, damage gpu.Damage) error
// Release forgets what the presenter knows about the window of the handle.
Release(h gpu.SurfaceHandle)
}
Presenter shows a finished frame in a window. The Windows build's Presenter blits it with GDI; 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/windows/compositor_software.cc CompositorSoftware
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.SurfaceKindWin32. 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) Invalidate ¶
Invalidate says that the window of the surface lost its content, so that the next frame is presented whole. A surface that is not this renderer's is ignored.
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