impeller

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 9 Imported by: 1 module, 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.

README

impeller

Go Reference golangci-lint

This library provides cgo-free Go bindings for Impeller.

status

This library is experimental. It appears to broadly work (at least on linux), but it has not been extensively tested.

AI

No AI was used in the creation of this library.

development

upgrading Impeller
  • update the FLUTTER_SHA env var in internal/update.sh to the desired flutter repo git commit
  • run ./internal/update, to download and extract the artifacts
  • run go generate to regenerate the Go binding
  • once satisfied that all is good, commit
pre-commit hook

There are configuration files for linting and other checks. To use a git pre-commit hook for the checks

Documentation

Overview

Package impeller provides cgo-free bindings for Flutter's Impeller.

The documentation is generated from comments in the C header that defines the Impeller C API. It will not always quite match the generated Go API, and it may not always make sense in the context of Go.

Index

Constants

View Source
const FlutterSHA = "4e5a09292c1c64a38d604c7ec096537f50d69f93"

Variables

This section is empty.

Functions

func GetVersion

func GetVersion() uint32

Get the version of Impeller standalone API. This is the API that will be accepted for validity checks when provided to the context creation methods.

The current version of the API is denoted by the IMPELLER_VERSION macro. This version must be passed to APIs that create top-level objects like graphics contexts. Construction of the context may fail if the API version expected by the caller is not supported by the library.

Since there are no API stability guarantees today, passing a version that is different to the one returned by GetVersion will always fail.

see ContextCreateOpenGLESNew

Return: The version of the standalone API.

func GetVersionMajor

func GetVersionMajor() uint32

func GetVersionMinor

func GetVersionMinor() uint32

func GetVersionPatch

func GetVersionPatch() uint32

func GetVersionVariant

func GetVersionVariant() uint32

func Init

func Init() error

Types

type BlendMode

type BlendMode enum
const BlendModeClear BlendMode = 0
const BlendModeColor BlendMode = 27
const BlendModeColorBurn BlendMode = 19
const BlendModeColorDodge BlendMode = 18
const BlendModeDarken BlendMode = 16
const BlendModeDestination BlendMode = 2
const BlendModeDestinationATop BlendMode = 10
const BlendModeDestinationIn BlendMode = 6
const BlendModeDestinationOut BlendMode = 8
const BlendModeDestinationOver BlendMode = 4
const BlendModeDifference BlendMode = 22
const BlendModeExclusion BlendMode = 23
const BlendModeHardLight BlendMode = 20
const BlendModeHue BlendMode = 25
const BlendModeLighten BlendMode = 17
const BlendModeLuminosity BlendMode = 28
const BlendModeModulate BlendMode = 13
const BlendModeMultiply BlendMode = 24
const BlendModeOverlay BlendMode = 15
const BlendModePlus BlendMode = 12
const BlendModeSaturation BlendMode = 26
const BlendModeScreen BlendMode = 14
const BlendModeSoftLight BlendMode = 21
const BlendModeSource BlendMode = 1
const BlendModeSourceATop BlendMode = 9
const BlendModeSourceIn BlendMode = 5
const BlendModeSourceOut BlendMode = 7
const BlendModeSourceOver BlendMode = 3
const BlendModeXor BlendMode = 11

type BlurStyle

type BlurStyle enum
const BlurStyleInner BlurStyle = 3
const BlurStyleNormal BlurStyle = 0
const BlurStyleOuter BlurStyle = 2
const BlurStyleSolid BlurStyle = 1

type Bool

type Bool uint8

func (Bool) Bool

func (bool Bool) Bool() bool

func (*Bool) Set

func (bool *Bool) Set(value bool)

type Callback

type Callback uintptr

Callback is a callback invoked by Impeller that passes a user supplied baton back to the user. Impeller does not interpret the baton in any way. The way the baton is specified and the thread on which the callback is invoked depends on how the user supplies the callback to Impeller.

func NewCallback

func NewCallback(cb func(user_data unsafe.Pointer)) Callback

type ClipOperation

type ClipOperation enum
const ClipOperationDifference ClipOperation = 0
const ClipOperationIntersect ClipOperation = 1

type Color

type Color struct {
	Red        float32
	Green      float32
	Blue       float32
	Alpha      float32
	ColorSpace ColorSpace
	// contains filtered or unexported fields
}

type ColorFilter

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

Color filters are functions that take two colors and mix them to produce a single color. This color is then merged with the destination during blending.

func ColorFilterCreateBlendNew

func ColorFilterCreateBlendNew(color *Color, blend_mode BlendMode) ColorFilter

Create a color filter that performs blending of pixel values independently.

  • color - The color.
  • blend_mode - The blend mode.

Return: The color filter.

func ColorFilterCreateColorMatrixNew

func ColorFilterCreateColorMatrixNew(color_matrix *ColorMatrix) ColorFilter

Create a color filter that transforms pixel color values independently.

  • color_matrix - The color matrix.

Return: The color filter.

func (ColorFilter) Release

func (color_filter ColorFilter) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • color_filter - The color filter.

func (ColorFilter) Retain

func (color_filter ColorFilter) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • color_filter - The color filter.

type ColorMatrix

type ColorMatrix struct {
	M [20]float32
	// contains filtered or unexported fields
}

A 4x5 matrix using row-major storage used for transforming color values.

To transform color values, a 5x5 matrix is constructed with the 5th row being identity. Then the following transformation is performed:

| R' |   | m[0]  m[1]  m[2]  m[3]  m[4]  |   | R |
| G' |   | m[5]  m[6]  m[7]  m[8]  m[9]  |   | G |
| B' | = | m[10] m[11] m[12] m[13] m[14] | * | B |
| A' |   | m[15] m[16] m[17] m[18] m[19] |   | A |
| 1  |   | 0     0     0     0     1     |   | 1 |

The translation column (m[4], m[9], m[14], m[19]) must be specified in non-normalized 8-bit unsigned integer space (0 to 255). Values outside this range will produce undefined results.

The identity transformation is thus:

1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,

Some examples:

To invert all colors:

-1,  0,  0, 0, 255,
0, -1,  0, 0, 255,
0,  0, -1, 0, 255,
0,  0,  0, 1,   0,

To apply a sepia filter:

0.393, 0.769, 0.189, 0, 0,
0.349, 0.686, 0.168, 0, 0,
0.272, 0.534, 0.131, 0, 0,
0,     0,     0,     1, 0,

To apply a grayscale conversion filter:

0.2126, 0.7152, 0.0722, 0, 0,
0.2126, 0.7152, 0.0722, 0, 0,
0.2126, 0.7152, 0.0722, 0, 0,
0,      0,      0,      1, 0,

see ColorFilter

type ColorSource

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

Color sources are functions that generate colors for each texture element covered by a draw call. The colors for each element can be generated using a mathematical function (to produce gradients for example) or sampled from a texture.

func ColorSourceCreateConicalGradientNew

func ColorSourceCreateConicalGradientNew(start_center *Point, start_radius float32, end_center *Point, end_radius float32, stop_count uint32, colors *Color, stops *float32, tile_mode TileMode, transformation *Matrix) ColorSource

Create a color source that forms a conical gradient.

  • start_center - The start center.
  • start_radius - The start radius.
  • end_center - The end center.
  • end_radius - The end radius.
  • stop_count - The stop count.
  • colors - The colors.
  • stops - The stops.
  • tile_mode - The tile mode.
  • transformation - The transformation.

Return: The color source.

func ColorSourceCreateLinearGradientNew

func ColorSourceCreateLinearGradientNew(start_point *Point, end_point *Point, stop_count uint32, colors *Color, stops *float32, tile_mode TileMode, transformation *Matrix) ColorSource

Create a color source that forms a linear gradient.

  • start_point - The start point.
  • end_point - The end point.
  • stop_count - The stop count.
  • colors - The colors.
  • stops - The stops.
  • tile_mode - The tile mode.
  • transformation - The transformation.

Return: The color source.

func ColorSourceCreateRadialGradientNew

func ColorSourceCreateRadialGradientNew(center *Point, radius float32, stop_count uint32, colors *Color, stops *float32, tile_mode TileMode, transformation *Matrix) ColorSource

Create a color source that forms a radial gradient.

  • center - The center.
  • radius - The radius.
  • stop_count - The stop count.
  • colors - The colors.
  • stops - The stops.
  • tile_mode - The tile mode.
  • transformation - The transformation.

Return: The color source.

func ColorSourceCreateSweepGradientNew

func ColorSourceCreateSweepGradientNew(center *Point, start float32, end float32, stop_count uint32, colors *Color, stops *float32, tile_mode TileMode, transformation *Matrix) ColorSource

Create a color source that forms a sweep gradient.

  • center - The center.
  • start - The start.
  • end - The end.
  • stop_count - The stop count.
  • colors - The colors.
  • stops - The stops.
  • tile_mode - The tile mode.
  • transformation - The transformation.

Return: The color source.

func (ColorSource) Release

func (color_source ColorSource) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • color_source - The color source.

func (ColorSource) Retain

func (color_source ColorSource) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • color_source - The color source.

type ColorSpace

type ColorSpace enum
const ColorSpaceDisplayP3 ColorSpace = 2
const ColorSpaceExtendedSRGB ColorSpace = 1
const ColorSpaceSRGB ColorSpace = 0

type Context

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

An Impeller graphics context. Contexts are platform and client-rendering-API specific.

Contexts are thread-safe objects that are expensive to create. Most applications will only ever create a single context during their lifetimes. Once setup, Impeller is ready to render frames as performantly as possible.

During setup, context create the underlying graphics pipelines, allocators, worker threads, etc...

The general guidance is to create as few contexts as possible (typically just one) and share them as much as possible.

func ContextCreateMetalNew

func ContextCreateMetalNew(version uint32) Context

Create a Metal context using the system default Metal device.

  • version - The version specified in the IMPELLER_VERSION macro.

Return: The Metal context or NULL if one cannot be created.

func ContextCreateOpenGLESNew

func ContextCreateOpenGLESNew(version uint32, gl_proc_address_callback ProcAddressCallback, gl_proc_address_callback_user_data unsafe.Pointer) Context

Create an OpenGL(ES) Impeller context.

Warning: Unlike other context types, the OpenGL ES context can only be created, used, and collected on the calling thread. This restriction may be lifted in the future once reactor workers are exposed in the API. No other context types have threading restrictions. Till reactor workers can be used, using the context on a background thread will cause a stall of OpenGL operations.

  • version - The version of the Impeller standalone API. See GetVersion. If the specified here is not compatible with the version of the library, context creation will fail and NULL context returned from this call.
  • gl_proc_address_callback - The gl proc address callback. For instance, eglGetProcAddress.
  • gl_proc_address_callback_user_data - The gl proc address callback user data baton. This pointer is not interpreted by Impeller and will be returned as user data in the proc address callback. user data.

Return: The context or NULL if one cannot be created.

func ContextCreateVulkanNew

func ContextCreateVulkanNew(version uint32, settings *ContextVulkanSettings) Context

Create a Vulkan context using the provided Vulkan Settings.

  • version - The version specified in the IMPELLER_VERSION macro.
  • settings - The Vulkan settings.

Return: The Vulkan context or NULL if one cannot be created.

func (Context) ColorSourceCreateFragmentProgramNew

func (context Context) ColorSourceCreateFragmentProgramNew(fragment_program FragmentProgram, samplers *Texture, samplers_count uint64, data string) ColorSource

Create a color source whose pixels are shaded by a fragment program.

see https://docs.flutter.dev/ui/design/graphics/fragment-shaders

  • context - The context.
  • fragment_program - The fragment program.
  • samplers - The samplers.
  • samplers_count - The samplers count.
  • data - The data (copied).
  • data_bytes_length - The data bytes length.

Return: The color source.

func (Context) GetVulkanInfo

func (context Context) GetVulkanInfo() (ContextVulkanInfo, Bool)

Get internal Vulkan handles managed by the given Vulkan context. Ownership of the handles is still maintained by Impeller. This accessor is just available so embedders can create resources using the same device and instance as Impeller for interop.

Warning: If the context is not a Vulkan context, False is returned with the [out] argument unaffected.

  • context - The context
  • out_vulkan_info - The out vulkan information

Return: If the Vulkan info could be fetched from the context.

func (Context) ImageFilterCreateFragmentProgramNew

func (context Context) ImageFilterCreateFragmentProgramNew(fragment_program FragmentProgram, samplers *Texture, samplers_count uint64, data string) ImageFilter

Create an image filter where each pixel is shaded by a fragment program.

see https://docs.flutter.dev/ui/design/graphics/fragment-shaders

  • context - The context.
  • fragment_program - The fragment program.
  • samplers - The samplers.
  • samplers_count - The samplers count.
  • data - The data (copied).
  • data_bytes_length - The data bytes length.

Return: The image filter.

func (Context) Release

func (context Context) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • context - The context.

func (Context) Retain

func (context Context) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • context - The context.

func (Context) SurfaceCreateWrappedFBONew

func (context Context) SurfaceCreateWrappedFBONew(fbo uint64, format PixelFormat, size *ISize) Surface

Create a new surface by wrapping an existing framebuffer object. The framebuffer must be complete as determined by glCheckFramebufferStatus. The framebuffer is still owned by the caller and it must be collected once the surface is collected.

  • context - The context.
  • fbo - The framebuffer object handle.
  • format - The format of the framebuffer.
  • size - The size of the framebuffer is texels.

Return: The surface if once can be created, NULL otherwise.

func (Context) SurfaceCreateWrappedMetalDrawableNew

func (context Context) SurfaceCreateWrappedMetalDrawableNew(metal_drawable unsafe.Pointer) Surface

Create a surface by wrapping a Metal drawable. This is useful during WSI when the drawable is the backing store of the Metal layer being drawn to.

The Metal layer must be using the same device managed by the underlying context.

  • context - The context. The Metal device managed by this context must be the same used to create the drawable that is being wrapped.
  • metal_drawable - The drawable to wrap as a surface.

Return: The surface if one could be wrapped, NULL otherwise.

func (Context) TextureCreateWithContentsNew

func (context Context) TextureCreateWithContentsNew(descriptor *TextureDescriptor, contents *Mapping, contents_on_release_user_data unsafe.Pointer) Texture

Create a texture with decompressed bytes.

Impeller will do its best to perform the transfer of this data to GPU memory with a minimal number of copies. Towards this end, it may need to send this data to a different thread for preparation and transfer. To facilitate this transfer, it is recommended that the content mapping have a release callback attach to it. When there is a release callback, Impeller assumes that collection of the data can be deferred till texture upload is done and can happen on a background thread. When there is no release callback, Impeller may try to perform an eager copy of the data if it needs to perform data preparation and transfer on a background thread.

Whether an extra data copy actually occurs will always depend on the rendering backend in use. But it is best practice to provide a release callback and be resilient to the data being released in a deferred manner on a background thread.

Warning: Do **not** supply compressed image data directly (PNG, JPEG, etc...). This function only works with tightly packed decompressed data.

  • context - The context.
  • descriptor - The texture descriptor.
  • contents - The contents.
  • contents_on_release_user_data - The baton passes to the contents release callback if one exists.

Return: The texture if one can be created using the provided data, NULL otherwise.

func (Context) TextureCreateWithOpenGLTextureHandleNew

func (context Context) TextureCreateWithOpenGLTextureHandleNew(descriptor *TextureDescriptor, handle uint64) Texture

Create a texture with an externally created OpenGL texture handle.

Ownership of the handle is transferred over to Impeller after a successful call to this method. Impeller is responsible for calling glDeleteTextures on this handle. Do **not** collect this handle yourself as this will lead to a double-free.

The handle must be created in the same context as the one used by Impeller. If a different context is used, that context must be in the same sharegroup as Impellers OpenGL context and all synchronization of texture contents must already be complete.

If the context is not an OpenGL context, this call will always fail.

  • context - The context
  • descriptor - The descriptor
  • handle - The handle

Return: The texture if one could be created by adopting the supplied texture handle, NULL otherwise.

func (Context) VulkanSwapchainCreateNew

func (context Context) VulkanSwapchainCreateNew(vulkan_surface_khr unsafe.Pointer) VulkanSwapchain

Create a new Vulkan swapchain using a VkSurfaceKHR instance. Ownership of the surface is transferred over to Impeller. The Vulkan instance the surface is created from must the same as the context provided.

  • context - The context. Must be a Vulkan context whose instance is the same used to create the surface passed into the next argument.
  • vulkan_surface_khr - The vulkan surface.

Return: The vulkan swapchain.

type ContextVulkanInfo

type ContextVulkanInfo struct {
	VkInstance               *byte
	VkPhysicalDevice         *byte
	VkLogicalDevice          *byte
	GraphicsQueueFamilyIndex uint32
	GraphicsQueueIndex       uint32
	// contains filtered or unexported fields
}

type ContextVulkanSettings

type ContextVulkanSettings struct {
	UserData               *byte
	ProcAddressCallback    VulkanProcAddressCallback
	EnableVulkanValidation Bool
	// contains filtered or unexported fields
}

type DisplayList

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

Display lists represent encoded rendering intent. These objects are immutable, reusable, thread-safe, and context-agnostic.

While it is perfectly fine to create new display lists per frame, there may be opportunities for optimization when display lists are reused multiple times.

func (DisplayList) Release

func (display_list DisplayList) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • display_list - The display list.

func (DisplayList) Retain

func (display_list DisplayList) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • display_list - The display list.

type DisplayListBuilder

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

Display list builders allow for the incremental creation of display lists.

Display list builders are context-agnostic.

func DisplayListBuilderNew

func DisplayListBuilderNew(cull_rect *Rect) DisplayListBuilder

Create a new display list builder.

An optional cull rectangle may be specified. Impeller is allowed to treat the contents outside this rectangle as being undefined. This may aid performance optimizations.

  • cull_rect - The cull rectangle or NULL.

Return: The display list builder.

func (DisplayListBuilder) ClipOval

func (builder DisplayListBuilder) ClipOval(oval_bounds *Rect, op ClipOperation)

Reduces the clip region to the intersection of the current clip and the given oval taking into account the clip operation.

  • builder - The builder.
  • oval_bounds - The oval bounds.
  • op - The operation.

func (DisplayListBuilder) ClipPath

func (builder DisplayListBuilder) ClipPath(path Path, op ClipOperation)

Reduces the clip region to the intersection of the current clip and the given path taking into account the clip operation.

  • builder - The builder.
  • path - The path.
  • op - The operation.

func (DisplayListBuilder) ClipRect

func (builder DisplayListBuilder) ClipRect(rect *Rect, op ClipOperation)

Reduces the clip region to the intersection of the current clip and the given rectangle taking into account the clip operation.

  • builder - The builder.
  • rect - The rectangle.
  • op - The operation.

func (DisplayListBuilder) ClipRoundedRect

func (builder DisplayListBuilder) ClipRoundedRect(rect *Rect, radii *RoundingRadii, op ClipOperation)

Reduces the clip region to the intersection of the current clip and the given rounded rectangle taking into account the clip operation.

  • builder - The builder.
  • rect - The rectangle.
  • radii - The radii.
  • op - The operation.

func (DisplayListBuilder) CreateDisplayListNew

func (builder DisplayListBuilder) CreateDisplayListNew() DisplayList

Create a new display list using the rendering intent already encoded in the builder. The builder is reset after this call.

  • builder - The builder.

Return: The display list.

func (DisplayListBuilder) DrawDashedLine

func (builder DisplayListBuilder) DrawDashedLine(from *Point, to *Point, on_length float32, off_length float32, paint Paint)

Draws a dash line segment.

  • builder - The builder.
  • from - The starting point of the line.
  • to - The end point of the line.
  • on_length - On length.
  • off_length - Off length.
  • paint - The paint.

func (DisplayListBuilder) DrawDisplayList

func (builder DisplayListBuilder) DrawDisplayList(display_list DisplayList, opacity float32)

Flattens the contents of another display list into the one currently being built.

  • builder - The builder.
  • display_list - The display list.
  • opacity - The opacity.

func (DisplayListBuilder) DrawLine

func (builder DisplayListBuilder) DrawLine(from *Point, to *Point, paint Paint)

Draws a line segment.

  • builder - The builder.
  • from - The starting point of the line.
  • to - The end point of the line.
  • paint - The paint.

func (DisplayListBuilder) DrawOval

func (builder DisplayListBuilder) DrawOval(oval_bounds *Rect, paint Paint)

Draws an oval.

  • builder - The builder.
  • oval_bounds - The oval bounds.
  • paint - The paint.

func (DisplayListBuilder) DrawPaint

func (builder DisplayListBuilder) DrawPaint(paint Paint)

Fills the current clip with the specified paint.

  • builder - The builder.
  • paint - The paint.

func (DisplayListBuilder) DrawParagraph

func (builder DisplayListBuilder) DrawParagraph(paragraph Paragraph, point *Point)

Draw a paragraph at the specified point.

  • builder - The builder.
  • paragraph - The paragraph.
  • point - The point.

func (DisplayListBuilder) DrawPath

func (builder DisplayListBuilder) DrawPath(path Path, paint Paint)

Draws the specified shape.

  • builder - The builder.
  • path - The path.
  • paint - The paint.

func (DisplayListBuilder) DrawRect

func (builder DisplayListBuilder) DrawRect(rect *Rect, paint Paint)

Draws a rectangle.

  • builder - The builder.
  • rect - The rectangle.
  • paint - The paint.

func (DisplayListBuilder) DrawRoundedRect

func (builder DisplayListBuilder) DrawRoundedRect(rect *Rect, radii *RoundingRadii, paint Paint)

Draws a rounded rect.

  • builder - The builder.
  • rect - The rectangle.
  • radii - The radii.
  • paint - The paint.

func (DisplayListBuilder) DrawRoundedRectDifference

func (builder DisplayListBuilder) DrawRoundedRectDifference(outer_rect *Rect, outer_radii *RoundingRadii, inner_rect *Rect, inner_radii *RoundingRadii, paint Paint)

Draws a shape that is the different between the specified rectangles (each with configurable corner radii).

  • builder - The builder.
  • outer_rect - The outer rectangle.
  • outer_radii - The outer radii.
  • inner_rect - The inner rectangle.
  • inner_radii - The inner radii.
  • paint - The paint.

func (DisplayListBuilder) DrawShadow

func (builder DisplayListBuilder) DrawShadow(path Path, color *Color, elevation float32, occluder_is_transparent Bool, device_pixel_ratio float32)

Draw a shadow for a Path given a material elevation. If the occluding object is not opaque, additional hints (via the occluder_is_transparent argument) must be provided to render the shadow correctly.

  • builder - The builder.
  • path - The shadow path.
  • color - The shadow color.
  • elevation - The material elevation.
  • occluder_is_transparent - If the object casting the shadow is transparent.
  • device_pixel_ratio - The device pixel ratio.

func (DisplayListBuilder) DrawTexture

func (builder DisplayListBuilder) DrawTexture(texture Texture, point *Point, sampling TextureSampling, paint Paint)

Draw a texture at the specified point.

  • builder - The builder.
  • texture - The texture.
  • point - The point.
  • sampling - The sampling.
  • paint - The paint.

func (DisplayListBuilder) DrawTextureRect

func (builder DisplayListBuilder) DrawTextureRect(texture Texture, src_rect *Rect, dst_rect *Rect, sampling TextureSampling, paint Paint)

Draw a portion of texture at the specified location.

  • builder - The builder.
  • texture - The texture.
  • src_rect - The source rectangle.
  • dst_rect - The destination rectangle.
  • sampling - The sampling.
  • paint - The paint.

func (DisplayListBuilder) GetSaveCount

func (builder DisplayListBuilder) GetSaveCount() uint32

Get the current size of the save stack.

  • builder - The builder.

Return: The save stack size.

func (DisplayListBuilder) GetTransform

func (builder DisplayListBuilder) GetTransform() Matrix

Get the transformation currently built up on the top of the transformation stack.

  • builder - The builder.
  • out_transform - The transform.

func (DisplayListBuilder) Release

func (builder DisplayListBuilder) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • builder - The display list builder.

func (DisplayListBuilder) ResetTransform

func (builder DisplayListBuilder) ResetTransform()

Reset the transformation on top of the transformation stack to identity.

  • builder - The builder.

func (DisplayListBuilder) Restore

func (builder DisplayListBuilder) Restore()

Pops the last entry pushed onto the save stack using a call to DisplayListBuilder.Save or DisplayListBuilder.SaveLayer.

  • builder - The builder.

func (DisplayListBuilder) RestoreToCount

func (builder DisplayListBuilder) RestoreToCount(count uint32)

Effectively calls ImpellerDisplayListBuilderRestore till the size of the save stack becomes a specified count.

  • builder - The builder.
  • count - The count.

func (DisplayListBuilder) Retain

func (builder DisplayListBuilder) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • builder - The display list builder.

func (DisplayListBuilder) Rotate

func (builder DisplayListBuilder) Rotate(angle_degrees float32)

Apply a clockwise rotation to the transformation matrix currently on top of the save stack.

  • builder - The builder.
  • angle_degrees - The angle in degrees.

func (DisplayListBuilder) Save

func (builder DisplayListBuilder) Save()

Stashes the current transformation and clip state onto a save stack.

  • builder - The builder.

func (DisplayListBuilder) SaveLayer

func (builder DisplayListBuilder) SaveLayer(bounds *Rect, paint Paint, backdrop ImageFilter)

Stashes the current transformation and clip state onto a save stack and creates and creates an offscreen layer onto which subsequent rendering intent will be directed to.

On the balancing call to restore, the supplied paints filters and blend modes will be used to composite the offscreen contents back onto the display display list.

  • builder - The builder.
  • bounds - The bounds.
  • paint - The paint.
  • backdrop - The backdrop.

func (DisplayListBuilder) Scale

func (builder DisplayListBuilder) Scale(x_scale float32, y_scale float32)

Apply a scale to the transformation matrix currently on top of the save stack.

  • builder - The builder.
  • x_scale - The x scale.
  • y_scale - The y scale.

func (DisplayListBuilder) SetTransform

func (builder DisplayListBuilder) SetTransform(transform *Matrix)

Clear the transformation on top of the save stack and replace it with a new value.

  • builder - The builder.
  • transform - The new transform.

func (DisplayListBuilder) Transform

func (builder DisplayListBuilder) Transform(transform *Matrix)

Appends the the provided transformation to the transformation already on the save stack.

  • builder - The builder.
  • transform - The transform to append.

func (DisplayListBuilder) Translate

func (builder DisplayListBuilder) Translate(x_translation float32, y_translation float32)

Apply a translation to the transformation matrix currently on top of the save stack.

  • builder - The builder.
  • x_translation - The x translation.
  • y_translation - The y translation.

type DrawStyle

type DrawStyle enum
const DrawStyleFill DrawStyle = 0
const DrawStyleStroke DrawStyle = 1
const DrawStyleStrokeAndFill DrawStyle = 2

type FillType

type FillType enum
const FillTypeNonZero FillType = 0
const FillTypeOdd FillType = 1

type FontStyle

type FontStyle enum
const FontStyleItalic FontStyle = 1
const FontStyleNormal FontStyle = 0

type FontWeight

type FontWeight enum
const FontWeight100 FontWeight = 0
const FontWeight200 FontWeight = 1
const FontWeight300 FontWeight = 2
const FontWeight400 FontWeight = 3
const FontWeight500 FontWeight = 4
const FontWeight600 FontWeight = 5
const FontWeight700 FontWeight = 6
const FontWeight800 FontWeight = 7
const FontWeight900 FontWeight = 8

type FragmentProgram

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

A fragment shader is a small program that is authored in GLSL and compiled using impellerc that runs on each pixel covered by a polygon and allows the user to configure how it is shaded.

see https://docs.flutter.dev/ui/design/graphics/fragment-shaders

func FragmentProgramNew

func FragmentProgramNew(data *Mapping, data_release_user_data unsafe.Pointer) FragmentProgram

Create a new fragment program using data obtained by compiling a GLSL shader with impellerc.

Warning: The data provided must be compiled by impellerc. Providing raw GLSL strings will lead to a nullptr return. Impeller does not compile shaders at runtime.

  • data - The data compiled by impellerc.
  • data_release_user_data - A baton passed back to the caller on the invocation of the mappings release callback. This call can happen on any thread.

Return: The fragment program if one can be created, nullptr otherwise.

func (FragmentProgram) Release

func (fragment_program FragmentProgram) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • fragment_program - The fragment program.

func (FragmentProgram) Retain

func (fragment_program FragmentProgram) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • fragment_program - The fragment program.

type GlyphInfo

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

Describes the metrics of glyphs in a paragraph line.

func (GlyphInfo) GetGraphemeClusterBounds

func (glyph_info GlyphInfo) GetGraphemeClusterBounds() Rect

Fetch the bounds of the grapheme cluster for the glyph in the coordinate space of the paragraph.

  • glyph_info - The glyph information.
  • out_bounds - The grapheme cluster bounds.

func (GlyphInfo) GetGraphemeClusterCodeUnitRangeBegin

func (glyph_info GlyphInfo) GetGraphemeClusterCodeUnitRangeBegin() uint64

Fetch the start index in the buffer of UTF-16 code units used to represent the grapheme cluster for a glyph.

  • glyph_info - The glyph information.

Return: The UTF-16 code units start index.

func (GlyphInfo) GetGraphemeClusterCodeUnitRangeEnd

func (glyph_info GlyphInfo) GetGraphemeClusterCodeUnitRangeEnd() uint64

Fetch the end index in the buffer of UTF-16 code units used to represent the grapheme cluster for a glyph.

  • glyph_info - The glyph information.

Return: The UTF-16 code units end index.

func (GlyphInfo) GetTextDirection

func (glyph_info GlyphInfo) GetTextDirection() TextDirection
  • glyph_info - The glyph information.

Return: The direction of the run that contains the glyph.

func (GlyphInfo) IsEllipsis

func (glyph_info GlyphInfo) IsEllipsis() Bool
  • glyph_info - The glyph information.

Return: True if the glyph represents an ellipsis. False otherwise.

func (GlyphInfo) Release

func (glyph_info GlyphInfo) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • glyph_info - The glyph information.

func (GlyphInfo) Retain

func (glyph_info GlyphInfo) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • glyph_info - The glyph information.

type ISize

type ISize struct {
	Width  int64
	Height int64
	// contains filtered or unexported fields
}

type ImageFilter

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

Image filters are functions that are applied regions of a texture to produce a single color. Contrast this with color filters that operate independently on a per-pixel basis. The generated color is then merged with the destination during blending.

func ImageFilterCreateBlurNew

func ImageFilterCreateBlurNew(x_sigma float32, y_sigma float32, tile_mode TileMode) ImageFilter

Creates an image filter that applies a Gaussian blur.

The Gaussian blur applied may be an approximation for performance.

  • x_sigma - The x sigma.
  • y_sigma - The y sigma.
  • tile_mode - The tile mode.

Return: The image filter.

func ImageFilterCreateDilateNew

func ImageFilterCreateDilateNew(x_radius float32, y_radius float32) ImageFilter

Creates an image filter that enhances the per-channel pixel values to the maximum value in a circle around the pixel.

  • x_radius - The x radius.
  • y_radius - The y radius.

Return: The image filter.

func ImageFilterCreateErodeNew

func ImageFilterCreateErodeNew(x_radius float32, y_radius float32) ImageFilter

Creates an image filter that dampens the per-channel pixel values to the minimum value in a circle around the pixel.

  • x_radius - The x radius.
  • y_radius - The y radius.

Return: The image filter.

func ImageFilterCreateMatrixNew

func ImageFilterCreateMatrixNew(matrix *Matrix, sampling TextureSampling) ImageFilter

Creates an image filter that applies a transformation matrix to the underlying image.

  • matrix - The transformation matrix.
  • sampling - The image sampling mode.

Return: The image filter.

func (ImageFilter) CreateComposeNew

func (outer ImageFilter) CreateComposeNew(inner ImageFilter) ImageFilter

Creates a composed filter that when applied is identical to subsequently applying the inner and then the outer filters.

 destination = outer_filter(inner_filter(source))

- outer - The outer image filter.
- inner - The inner image filter.

Return: The combined image filter.

func (ImageFilter) Release

func (image_filter ImageFilter) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • image_filter - The image filter.

func (ImageFilter) Retain

func (image_filter ImageFilter) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • image_filter - The image filter.

type LineMetrics

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

Describes the metrics of lines in a fully laid out paragraph.

Regardless of how the string of text is specified to the paragraph builder, offsets into buffers that are returned by line metrics are always assumed to be into buffers of UTF-16 code units.

func (LineMetrics) GetAscent

func (metrics LineMetrics) GetAscent(line uint64) float64

The rise from the baseline as calculated from the font and style for this line.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: The ascent.

func (LineMetrics) GetBaseline

func (metrics LineMetrics) GetBaseline(line uint64) float64

The y coordinate of the baseline for this line from the top of the paragraph.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: The baseline.

func (LineMetrics) GetCodeUnitEndIndex

func (metrics LineMetrics) GetCodeUnitEndIndex(line uint64) uint64

Fetch the end index in the buffer of UTF-16 code units used to represent the paragraph line.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: The UTF-16 code units end index.

func (LineMetrics) GetCodeUnitEndIndexExcludingWhitespace

func (metrics LineMetrics) GetCodeUnitEndIndexExcludingWhitespace(line uint64) uint64

Fetch the end index (excluding whitespace) in the buffer of UTF-16 code units used to represent the paragraph line.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: The UTF-16 code units end index excluding whitespace.

func (LineMetrics) GetCodeUnitEndIndexIncludingNewline

func (metrics LineMetrics) GetCodeUnitEndIndexIncludingNewline(line uint64) uint64

Fetch the end index (including newlines) in the buffer of UTF-16 code units used to represent the paragraph line.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: The UTF-16 code units end index including newlines.

func (LineMetrics) GetCodeUnitStartIndex

func (metrics LineMetrics) GetCodeUnitStartIndex(line uint64) uint64

Fetch the start index in the buffer of UTF-16 code units used to represent the paragraph line.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: The UTF-16 code units start index.

func (LineMetrics) GetDescent

func (metrics LineMetrics) GetDescent(line uint64) float64

The drop from the baseline as calculated from the font and style for this line.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: The descent.

func (LineMetrics) GetHeight

func (metrics LineMetrics) GetHeight(line uint64) float64

Total height of the line from the top edge to the bottom edge.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: The height.

func (LineMetrics) GetLeft

func (metrics LineMetrics) GetLeft(line uint64) float64

The x coordinate of left edge of the line.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: The left edge coordinate.

func (LineMetrics) GetUnscaledAscent

func (metrics LineMetrics) GetUnscaledAscent(line uint64) float64

The rise from the baseline as calculated from the font and style for this line ignoring the height from the text style.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: The unscaled ascent.

func (LineMetrics) GetWidth

func (metrics LineMetrics) GetWidth(line uint64) float64

Width of the line from the left edge of the leftmost glyph to the right edge of the rightmost glyph.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: The width.

func (LineMetrics) IsHardbreak

func (metrics LineMetrics) IsHardbreak(line uint64) Bool

Used to determine if this line ends with an explicit line break (e.g. ' ') or is the end of the paragraph.

  • metrics - The metrics.
  • line - The line index (zero based).

Return: True if the line is a hard break.

func (LineMetrics) Release

func (line_metrics LineMetrics) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • line_metrics - The line metrics.

func (LineMetrics) Retain

func (line_metrics LineMetrics) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • line_metrics - The line metrics.

type Mapping

type Mapping struct {
	Data      *byte
	Length    uint64
	OnRelease Callback
	// contains filtered or unexported fields
}

type MaskFilter

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

Mask filters are functions that are applied over a shape after it has been drawn but before it has been blended into the final image.

func MaskFilterCreateBlurNew

func MaskFilterCreateBlurNew(style BlurStyle, sigma float32) MaskFilter

Create a mask filter that blurs contents in the masked shape.

  • style - The style.
  • sigma - The sigma.

Return: The mask filter.

func (MaskFilter) Release

func (mask_filter MaskFilter) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • mask_filter - The mask filter.

func (MaskFilter) Retain

func (mask_filter MaskFilter) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • mask_filter - The mask filter.

type Matrix

type Matrix struct {
	M [16]float32
	// contains filtered or unexported fields
}

A 4x4 transformation matrix using column-major storage.

| m[0] m[4] m[8]  m[12] |
| m[1] m[5] m[9]  m[13] |
| m[2] m[6] m[10] m[14] |
| m[3] m[7] m[11] m[15] |

type Paint

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

Paints control the behavior of draw calls encoded in a display list.

Like display lists, paints are context-agnostic.

func PaintNew

func PaintNew() Paint

Create a new paint with default values.

Return: The impeller paint.

func (Paint) Release

func (paint Paint) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • paint - The paint.

func (Paint) Retain

func (paint Paint) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • paint - The paint.

func (Paint) SetBlendMode

func (paint Paint) SetBlendMode(mode BlendMode)

Set the paint blend mode. The blend mode controls how the new paints contents are mixed with the values already drawn using previous draw calls.

  • paint - The paint.
  • mode - The mode.

func (Paint) SetColor

func (paint Paint) SetColor(color *Color)

Set the paint color.

  • paint - The paint.
  • color - The color.

func (Paint) SetColorFilter

func (paint Paint) SetColorFilter(color_filter ColorFilter)

Set the color filter of the paint.

Color filters are functions that take two colors and mix them to produce a single color. This color is then usually merged with the destination during blending.

  • paint - The paint.
  • color_filter - The color filter.

func (Paint) SetColorSource

func (paint Paint) SetColorSource(color_source ColorSource)

Set the color source of the paint.

Color sources are functions that generate colors for each texture element covered by a draw call.

  • paint - The paint.
  • color_source - The color source.

func (Paint) SetDrawStyle

func (paint Paint) SetDrawStyle(style DrawStyle)

Set the paint draw style. The style controls if the closed shapes are filled and/or stroked.

  • paint - The paint.
  • style - The style.

func (Paint) SetImageFilter

func (paint Paint) SetImageFilter(image_filter ImageFilter)

Set the image filter of a paint.

Image filters are functions that are applied to regions of a texture to produce a single color.

  • paint - The paint.
  • image_filter - The image filter.

func (Paint) SetMaskFilter

func (paint Paint) SetMaskFilter(mask_filter MaskFilter)

Set the mask filter of a paint.

  • paint - The paint.
  • mask_filter - The mask filter.

func (Paint) SetStrokeCap

func (paint Paint) SetStrokeCap(cap StrokeCap)

Sets how strokes rendered using this paint are capped.

  • paint - The paint.
  • cap - The stroke cap style.

func (Paint) SetStrokeJoin

func (paint Paint) SetStrokeJoin(join StrokeJoin)

Sets how strokes rendered using this paint are joined.

  • paint - The paint.
  • join - The join.

func (Paint) SetStrokeMiter

func (paint Paint) SetStrokeMiter(miter float32)

Set the miter limit of the strokes rendered using this paint.

  • paint - The paint.
  • miter - The miter limit.

func (Paint) SetStrokeWidth

func (paint Paint) SetStrokeWidth(width float32)

Set the width of the strokes rendered using this paint.

  • paint - The paint.
  • width - The width.

type Paragraph

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

An immutable, fully laid out paragraph.

func (Paragraph) CreateGlyphInfoAtCodeUnitIndexNew

func (paragraph Paragraph) CreateGlyphInfoAtCodeUnitIndexNew(code_unit_index uint64) GlyphInfo

Create a new instance of glyph info that can be queried for information about the glyph at the given UTF-16 code unit index. The instance must be freed using GlyphInfo.Release.

  • paragraph - The paragraph.
  • code_unit_index - The UTF-16 code unit index.

Return: The glyph information.

func (Paragraph) CreateGlyphInfoAtParagraphCoordinatesNew

func (paragraph Paragraph) CreateGlyphInfoAtParagraphCoordinatesNew(x float64, y float64) GlyphInfo

Create a new instance of glyph info that can be queried for information about the glyph closest to the specified coordinates relative to the origin of the paragraph. The instance must be freed using GlyphInfo.Release.

  • paragraph - The paragraph.
  • x - The x coordinate relative to paragraph origin.
  • y - The x coordinate relative to paragraph origin.

Return: The glyph information.

func (Paragraph) GetAlphabeticBaseline

func (paragraph Paragraph) GetAlphabeticBaseline() float32
  • paragraph - The paragraph.

Return: The distance from the top of the paragraph to the alphabetic baseline of the first line when using alphabetic fonts (A-Z, a-z, Greek, etc...).

func (Paragraph) GetHeight

func (paragraph Paragraph) GetHeight() float32
  • paragraph - The paragraph.

Return: The height of the laid out paragraph. This is **not** a tight bounding box and some glyphs may not reach the minimum location they are allowed to reach.

func (Paragraph) GetIdeographicBaseline

func (paragraph Paragraph) GetIdeographicBaseline() float32
  • paragraph - The paragraph.

Return: The distance from the top of the paragraph to the ideographic baseline of the first line when using ideographic fonts (Japanese, Korean, etc...).

func (Paragraph) GetLineCount

func (paragraph Paragraph) GetLineCount() uint32
  • paragraph - The paragraph.

Return: The number of lines visible in the paragraph after line breaking.

func (Paragraph) GetLineMetrics

func (paragraph Paragraph) GetLineMetrics() LineMetrics

Get the line metrics of this laid out paragraph. Calculating the line metrics is expensive. The first time line metrics are requested, they will be cached along with the paragraph (which is immutable).

  • paragraph - The paragraph.

Return: The line metrics.

func (Paragraph) GetLongestLineWidth

func (paragraph Paragraph) GetLongestLineWidth() float32
  • paragraph - The paragraph.

Return: The length of the longest line in the paragraph. This is the horizontal distance between the left edge of the leftmost glyph and the right edge of the rightmost glyph, in the longest line in the paragraph.

func (Paragraph) GetMaxIntrinsicWidth

func (paragraph Paragraph) GetMaxIntrinsicWidth() float32
  • paragraph - The paragraph.

Return: The width of the paragraph without line breaking.

func (Paragraph) GetMaxWidth

func (paragraph Paragraph) GetMaxWidth() float32

see Paragraph.GetMinIntrinsicWidth

  • paragraph - The paragraph.

Return: The width provided to the paragraph builder during the call to layout. This is the maximum width any line in the laid out paragraph can occupy. But, it is not necessarily the actual width of the paragraph after layout.

func (Paragraph) GetMinIntrinsicWidth

func (paragraph Paragraph) GetMinIntrinsicWidth() float32

see Paragraph.GetMaxWidth

  • paragraph - The paragraph.

Return: The actual width of the longest line in the paragraph after layout. This is expected to be less than or equal to Paragraph.GetMaxWidth.

func (Paragraph) GetWordBoundary

func (paragraph Paragraph) GetWordBoundary(code_unit_index uint64) Range

Get the range into the UTF-16 code unit buffer that represents the word at the specified caret location in the same buffer.

Word boundaries are defined more precisely in [Unicode Standard Annex #29](http://www.unicode.org/reports/tr29/#Word_Boundaries)

  • paragraph - The paragraph
  • code_unit_index - The code unit index
  • out_range - The range.

func (Paragraph) Release

func (paragraph Paragraph) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • paragraph - The paragraph.

func (Paragraph) Retain

func (paragraph Paragraph) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • paragraph - The paragraph.

type ParagraphBuilder

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

Paragraph builders allow for the creation of fully laid out paragraphs (which themselves are immutable).

To build a paragraph, users push/pop paragraph styles onto a stack then add UTF-8 encoded text. The properties on the top of paragraph style stack when the text is added are used to layout and shape that subset of the paragraph.

see ParagraphStyle

func (ParagraphBuilder) AddText

func (paragraph_builder ParagraphBuilder) AddText(data string)

Add UTF-8 encoded text to the paragraph. The text will be styled according to the paragraph style already on top of the paragraph style stack.

  • paragraph_builder - The paragraph builder.
  • data - The data.
  • length - The length.

func (ParagraphBuilder) BuildParagraphNew

func (paragraph_builder ParagraphBuilder) BuildParagraphNew(width float32) Paragraph

Layout and build a new paragraph using the specified width. The resulting paragraph is immutable. The paragraph builder must be discarded and a new one created to build more paragraphs.

  • paragraph_builder - The paragraph builder.
  • width - The paragraph width.

Return: The paragraph if one can be created, NULL otherwise.

func (ParagraphBuilder) PopStyle

func (paragraph_builder ParagraphBuilder) PopStyle()

Pop a previously pushed paragraph style from the paragraph style stack.

  • paragraph_builder - The paragraph builder.

func (ParagraphBuilder) PushStyle

func (paragraph_builder ParagraphBuilder) PushStyle(style ParagraphStyle)

Push a new paragraph style onto the paragraph style stack managed by the paragraph builder.

Not all paragraph styles can be combined. For instance, it does not make sense to mix text alignment for different text runs within a paragraph. In such cases, the preference of the the first paragraph style on the style stack will take hold.

If text is pushed onto the paragraph builder without a style previously pushed onto the stack, a default paragraph text style will be used. This may not always be desirable because some style element cannot be overridden. It is recommended that a default paragraph style always be pushed onto the stack before the addition of any text.

  • paragraph_builder - The paragraph builder.
  • style - The style.

func (ParagraphBuilder) Release

func (paragraph_builder ParagraphBuilder) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • paragraph_builder - The paragraph_builder.

func (ParagraphBuilder) Retain

func (paragraph_builder ParagraphBuilder) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • paragraph_builder - The paragraph builder.

type ParagraphStyle

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

Specified when building a paragraph, paragraph styles are managed in a stack with specify text properties to apply to text that is added to the paragraph builder.

func ParagraphStyleNew

func ParagraphStyleNew() ParagraphStyle

Create a new paragraph style.

Return: The paragraph style.

func (ParagraphStyle) Release

func (paragraph_style ParagraphStyle) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • paragraph_style - The paragraph style.

func (ParagraphStyle) Retain

func (paragraph_style ParagraphStyle) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • paragraph_style - The paragraph style.

func (ParagraphStyle) SetBackground

func (paragraph_style ParagraphStyle) SetBackground(paint Paint)

Set the paint used to render the background of the text glyphs.

  • paragraph_style - The paragraph style.
  • paint - The paint.

func (ParagraphStyle) SetEllipsis

func (paragraph_style ParagraphStyle) SetEllipsis(ellipsis string)

Set the UTF-8 string to use as the ellipsis. Pass nullptr to clear the setting to default.

  • paragraph_style - The paragraph style.
  • data - The ellipsis string UTF-8 data, or null.

func (ParagraphStyle) SetFontFamily

func (paragraph_style ParagraphStyle) SetFontFamily(family_name string)

Set the font family.

  • paragraph_style - The paragraph style.
  • family_name - The family name.

func (ParagraphStyle) SetFontSize

func (paragraph_style ParagraphStyle) SetFontSize(size float32)

Set the font size.

  • paragraph_style - The paragraph style.
  • size - The size.

func (ParagraphStyle) SetFontStyle

func (paragraph_style ParagraphStyle) SetFontStyle(style FontStyle)

Set whether the glyphs should be bolded or italicized.

  • paragraph_style - The paragraph style.
  • style - The style.

func (ParagraphStyle) SetFontWeight

func (paragraph_style ParagraphStyle) SetFontWeight(weight FontWeight)

Set the weight of the font to select when rendering glyphs.

  • paragraph_style - The paragraph style.
  • weight - The weight.

func (ParagraphStyle) SetForeground

func (paragraph_style ParagraphStyle) SetForeground(paint Paint)

Set the paint used to render the text glyph contents.

  • paragraph_style - The paragraph style.
  • paint - The paint.

func (ParagraphStyle) SetHeight

func (paragraph_style ParagraphStyle) SetHeight(height float32)

The height of the text as a multiple of text size.

When height is 0.0, the line height will be determined by the font's metrics directly, which may differ from the font size. Otherwise the line height of the text will be a multiple of font size, and be exactly fontSize * height logical pixels tall.

  • paragraph_style - The paragraph style.
  • height - The height.

func (ParagraphStyle) SetLocale

func (paragraph_style ParagraphStyle) SetLocale(locale string)

Set the paragraph locale.

  • paragraph_style - The paragraph style.
  • locale - The locale.

func (ParagraphStyle) SetMaxLines

func (paragraph_style ParagraphStyle) SetMaxLines(max_lines uint32)

Set the maximum line count within the paragraph.

  • paragraph_style - The paragraph style.
  • max_lines - The maximum lines.

func (ParagraphStyle) SetTextAlignment

func (paragraph_style ParagraphStyle) SetTextAlignment(align TextAlignment)

Set the alignment of text within the paragraph.

  • paragraph_style - The paragraph style.
  • align - The align.

func (ParagraphStyle) SetTextDecoration

func (paragraph_style ParagraphStyle) SetTextDecoration(decoration *TextDecoration)

Set one of more text decorations on the paragraph. Decorations can be underlines, overlines, strikethroughs, etc.. The style of decorations can be set as well (dashed, dotted, wavy, etc..)

  • ImpellerParagraphStyle - The paragraph style.
  • decoration - The text decoration.

func (ParagraphStyle) SetTextDirection

func (paragraph_style ParagraphStyle) SetTextDirection(direction TextDirection)

Set the directionality of the text within the paragraph.

  • paragraph_style - The paragraph style.
  • direction - The direction.

type Path

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

Represents a two-dimensional path that is immutable and graphics context agnostic.

Paths in Impeller consist of linear, cubic Bézier curve, and quadratic Bézier curve segments. All other shapes are approximations using these building blocks.

Paths are created using path builder that allow for the configuration of the path segments, how they are filled, and/or stroked.

func (Path) GetBounds

func (path Path) GetBounds() Rect

Get the bounds of the path.

The bounds are conservative. That is, they may be larger than the actual shape of the path and could include the control points and isolated calls to move the cursor.

  • path - The path
  • out_bounds - The conservative bounds of the path.

func (Path) Release

func (path Path) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • path - The path.

func (Path) Retain

func (path Path) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • path - The path.

type PathBuilder

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

Path builders allow for the incremental building up of paths.

func PathBuilderNew

func PathBuilderNew() PathBuilder

Create a new path builder. Paths themselves are immutable. A builder builds these immutable paths.

Return: The path builder.

func (PathBuilder) AddArc

func (builder PathBuilder) AddArc(oval_bounds *Rect, start_angle_degrees float32, end_angle_degrees float32)

Add an arc to the path.

  • builder - The builder.
  • oval_bounds - The oval bounds.
  • start_angle_degrees - The start angle in degrees.
  • end_angle_degrees - The end angle in degrees.

func (PathBuilder) AddOval

func (builder PathBuilder) AddOval(oval_bounds *Rect)

Add an oval to the path.

  • builder - The builder.
  • oval_bounds - The oval bounds.

func (PathBuilder) AddRect

func (builder PathBuilder) AddRect(rect *Rect)

Adds a rectangle to the path.

  • builder - The builder.
  • rect - The rectangle.

func (PathBuilder) AddRoundedRect

func (builder PathBuilder) AddRoundedRect(rect *Rect, rounding_radii *RoundingRadii)

Add a rounded rect with potentially non-uniform radii to the path.

  • builder - The builder.
  • rect - The rectangle.
  • rounding_radii - The rounding radii.

func (PathBuilder) Close

func (builder PathBuilder) Close()

Close the path.

  • builder - The builder.

func (PathBuilder) CopyPathNew

func (builder PathBuilder) CopyPathNew(fill FillType) Path

Create a new path by copying the existing built-up path. The existing path can continue being added to.

  • builder - The builder.
  • fill - The fill.

Return: The impeller path.

func (PathBuilder) CubicCurveTo

func (builder PathBuilder) CubicCurveTo(control_point_1 *Point, control_point_2 *Point, end_point *Point)

Add a cubic curve whose start point is current cursor location to the specified end point using the two specified control points.

The new location of the cursor after this call is the end point supplied.

  • builder - The builder
  • control_point_1 - The control point 1
  • control_point_2 - The control point 2
  • end_point - The end point

func (PathBuilder) LineTo

func (builder PathBuilder) LineTo(location *Point)

Add a line segment from the current cursor location to the given location. The cursor location is updated to be at the endpoint.

  • builder - The builder.
  • location - The location.

func (PathBuilder) MoveTo

func (builder PathBuilder) MoveTo(location *Point)

Move the cursor to the specified location.

  • builder - The builder.
  • location - The location.

func (PathBuilder) QuadraticCurveTo

func (builder PathBuilder) QuadraticCurveTo(control_point *Point, end_point *Point)

Add a quadratic curve from whose start point is the cursor to the specified end point using the a single control point.

The new location of the cursor after this call is the end point.

  • builder - The builder.
  • control_point - The control point.
  • end_point - The end point.

func (PathBuilder) Release

func (builder PathBuilder) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • builder - The builder.

func (PathBuilder) Retain

func (builder PathBuilder) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • builder - The builder.

func (PathBuilder) TakePathNew

func (builder PathBuilder) TakePathNew(fill FillType) Path

Create a new path using the existing built-up path. The existing path builder now contains an empty path.

  • builder - The builder.
  • fill - The fill.

Return: The impeller path.

type PixelFormat

type PixelFormat enum
const PixelFormatRGBA8888 PixelFormat = 0

type Point

type Point struct {
	X float32
	Y float32
	// contains filtered or unexported fields
}

type ProcAddressCallback

type ProcAddressCallback uintptr

ProcAddressCallback is a callback used by Impeller to allow the user to resolve function pointers. A user supplied baton that is uninterpreted by Impeller is passed back to the user in the callback. How the baton is specified to Impeller and the thread on which the callback is invoked depends on how the callback is specified to Impeller.

func NewProcAddressCallback

func NewProcAddressCallback(cb func(
	procName string,
	user_data unsafe.Pointer,
) unsafe.Pointer) ProcAddressCallback

type Range

type Range struct {
	Start uint64
	End   uint64
	// contains filtered or unexported fields
}

type Rect

type Rect struct {
	X      float32
	Y      float32
	Width  float32
	Height float32
	// contains filtered or unexported fields
}

type RoundingRadii

type RoundingRadii struct {
	TopLeft     Point
	BottomLeft  Point
	TopRight    Point
	BottomRight Point
	// contains filtered or unexported fields
}

type Size

type Size struct {
	Width  float32
	Height float32
	// contains filtered or unexported fields
}

type StrokeCap

type StrokeCap enum
const StrokeCapButt StrokeCap = 0
const StrokeCapRound StrokeCap = 1
const StrokeCapSquare StrokeCap = 2

type StrokeJoin

type StrokeJoin enum
const StrokeJoinBevel StrokeJoin = 2
const StrokeJoinMiter StrokeJoin = 0
const StrokeJoinRound StrokeJoin = 1

type Surface

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

A surface represents a render target for Impeller to direct the rendering intent specified the form of display lists to.

Render targets are how Impeller API users perform Window System Integration (WSI). Users wrap swapchain images as surfaces and draw display lists onto these surfaces to present content.

Creating surfaces is typically platform and client-rendering-API specific.

func (Surface) DrawDisplayList

func (surface Surface) DrawDisplayList(display_list DisplayList) Bool

Draw a display list onto the surface. The same display list can be drawn multiple times to different surfaces.

Warning: In the OpenGL backend, Impeller will not make an effort to preserve the OpenGL state that is current in the context. Embedders that perform additional OpenGL operations in the context should expect the reset state after control transitions back to them. Key state to watch out for would be the viewports, stencil rects, test toggles, resource (texture, framebuffer, buffer) bindings, etc...

  • surface - The surface to draw the display list to.
  • display_list - The display list to draw onto the surface.

Return: If the display list could be drawn onto the surface.

func (Surface) Present

func (surface Surface) Present() Bool

Present the surface to the underlying window system.

  • surface - The surface to present.

Return: True if the surface could be presented.

func (Surface) Release

func (surface Surface) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • surface - The surface.

func (Surface) Retain

func (surface Surface) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • surface - The surface.

type TextAlignment

type TextAlignment enum
const TextAlignmentCenter TextAlignment = 2
const TextAlignmentEnd TextAlignment = 5
const TextAlignmentJustify TextAlignment = 3
const TextAlignmentLeft TextAlignment = 0
const TextAlignmentRight TextAlignment = 1
const TextAlignmentStart TextAlignment = 4

type TextDecoration

type TextDecoration struct {

	/*
	   A mask of [TextDecorationType]s to enable.
	*/
	Types int32
	/*
	   The decoration color.
	*/
	Color Color
	/*
	   The decoration style.
	*/
	Style               TextDecorationStyle
	ThicknessMultiplier float32
	// contains filtered or unexported fields
}

type TextDecorationStyle

type TextDecorationStyle enum
const TextDecorationStyleDashed TextDecorationStyle = 3
const TextDecorationStyleDotted TextDecorationStyle = 2
const TextDecorationStyleDouble TextDecorationStyle = 1
const TextDecorationStyleSolid TextDecorationStyle = 0
const TextDecorationStyleWavy TextDecorationStyle = 4

type TextDecorationType

type TextDecorationType enum
const TextDecorationTypeLineThrough TextDecorationType = 4
const TextDecorationTypeNone TextDecorationType = 0
const TextDecorationTypeOverline TextDecorationType = 2
const TextDecorationTypeUnderline TextDecorationType = 1

type TextDirection

type TextDirection enum
const TextDirectionLTR TextDirection = 1
const TextDirectionRTL TextDirection = 0

type Texture

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

A reference to a texture whose data is resident on the GPU. These can be referenced in draw calls and paints.

Creating textures is extremely expensive. Creating a single one can typically comfortably blow the frame budget of an application. Textures should be created on background threads.

Warning: While textures themselves are thread safe, some context types (like OpenGL) may need extra configuration to be able to operate from multiple threads.

func (Texture) ColorSourceCreateImageNew

func (image Texture) ColorSourceCreateImageNew(horizontal_tile_mode TileMode, vertical_tile_mode TileMode, sampling TextureSampling, transformation *Matrix) ColorSource

Create a color source that samples from an image.

  • image - The image.
  • horizontal_tile_mode - The horizontal tile mode.
  • vertical_tile_mode - The vertical tile mode.
  • sampling - The sampling.
  • transformation - The transformation.

Return: The color source.

func (Texture) GetOpenGLHandle

func (texture Texture) GetOpenGLHandle() uint64

Get the OpenGL handle associated with this texture. If this is not an OpenGL texture, this method will always return 0.

OpenGL handles are lazily created, this method will return GL_NONE is no OpenGL handle is available. To ensure that this call eagerly creates an OpenGL texture, call this on a thread where Impeller knows there is an OpenGL context available.

  • texture - The texture.

Return: The OpenGL handle if one is available, GL_NONE otherwise.

func (Texture) Release

func (texture Texture) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • texture - The texture.

func (Texture) Retain

func (texture Texture) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • texture - The texture.

type TextureDescriptor

type TextureDescriptor struct {
	PixelFormat PixelFormat
	Size        ISize
	MipCount    uint32
	// contains filtered or unexported fields
}

type TextureSampling

type TextureSampling enum
const TextureSamplingLinear TextureSampling = 1
const TextureSamplingNearestNeighbor TextureSampling = 0

type TileMode

type TileMode enum
const TileModeClamp TileMode = 0
const TileModeDecal TileMode = 3
const TileModeMirror TileMode = 2
const TileModeRepeat TileMode = 1

type TypographyContext

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

Typography contexts allow for the layout and rendering of text.

These are typically expensive to create and applications will only ever need to create a single one of these during their lifetimes.

Unlike graphics context, typograhy contexts are not thread-safe. These must be created, used, and collected on a single thread.

func TypographyContextNew

func TypographyContextNew() TypographyContext

Create a new typography contents.

Return: The typography context.

func (TypographyContext) ParagraphBuilderNew

func (context TypographyContext) ParagraphBuilderNew() ParagraphBuilder

Create a new paragraph builder.

  • context - The context.

Return: The paragraph builder.

func (TypographyContext) RegisterFont

func (context TypographyContext) RegisterFont(contents *Mapping, contents_on_release_user_data unsafe.Pointer, family_name_alias string) Bool

Register a custom font.

The following font formats are supported: * OpenType font collections (.ttc extension) * TrueType fonts: (.ttf extension) * OpenType fonts: (.otf extension)

Warning: Web Open Font Formats (.woff and .woff2 extensions) are **not** supported.

The font data is specified as a mapping. It is possible for the release callback of the mapping to not be called even past the destruction of the typography context. Care must be taken to not collect the mapping till the release callback is invoked by Impeller.

The family alias name can be NULL. In such cases, the font family specified in paragraph styles must match the family that is specified in the font data.

If the family name alias is not NULL, that family name must be used in the paragraph style to reference glyphs from this font instead of the one encoded in the font itself.

Multiple fonts (with glyphs for different styles) can be specified with the same family.

see ParagraphStyle.SetFontFamily

  • context - The context.
  • contents - The contents.
  • contents_on_release_user_data - The user data baton to be passed to the contents release callback.
  • family_name_alias - The family name alias or NULL if the one specified in the font data is to be used.

Return: If the font could be successfully registered.

func (TypographyContext) Release

func (context TypographyContext) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • context - The typography context.

func (TypographyContext) Retain

func (context TypographyContext) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • context - The typography context.

type VulkanProcAddressCallback

type VulkanProcAddressCallback uintptr

VulkanProcAddressCallback is a callback used by Impeller to allow the user to resolve Vulkan function pointers. A user supplied baton that is uninterpreted by Impeller is passed back to the user in the callback.

func NewVulkanProcAddressCallback

func NewVulkanProcAddressCallback(cb func(
	vulkan_instance unsafe.Pointer,
	vulkan_proc_name string,
	user_data unsafe.Pointer,
)) VulkanProcAddressCallback

type VulkanSwapchain

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

The primary form of WSI when using a Vulkan context, these swapchains use the VK_KHR_surface Vulkan extension.

Creating a swapchain is extremely expensive. One must be created at application startup and re-used throughout the application lifecycle.

Swapchains are resilient to the underlying surfaces being resized. The swapchain images will be re-created as necessary on-demand.

func (VulkanSwapchain) AcquireNextSurfaceNew

func (swapchain VulkanSwapchain) AcquireNextSurfaceNew() Surface

A potentially blocking operation, acquires the next surface to render to. Since this may block, surface acquisition must be delayed for as long as possible to avoid an idle wait on the CPU.

  • swapchain - The swapchain.

Return: The surface if one could be obtained, NULL otherwise.

func (VulkanSwapchain) Release

func (swapchain VulkanSwapchain) Release()

Release a previously retained reference to the object. The object can be NULL in which case this method is a no-op.

  • swapchain - The swapchain.

func (VulkanSwapchain) Retain

func (swapchain VulkanSwapchain) Retain()

Retain a strong reference to the object. The object can be NULL in which case this method is a no-op.

  • swapchain - The swapchain.

Directories

Path Synopsis
example
customfont command
image command
simple command
text command
internal
generate/cmd command

Jump to

Keyboard shortcuts

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