gdiwindow

package
v1.17.8 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 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 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

View Source
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

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.SurfaceKindWin32. 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) Invalidate

func (r *Renderer) Invalidate(s gpu.Surface)

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) MipmapStats

func (r *Renderer) MipmapStats() soft.CacheStats

MipmapStats returns what the renderer's cache of the mipmap chains of images holds and has done (soft.Cache.Stats): a picture scaled down in frame after frame is made smaller once.

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