gralloc

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: CC0-1.0 Imports: 7 Imported by: 0

Documentation

Overview

Package gralloc provides gralloc buffer allocation via the Android IAllocator HAL service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	Handle common.NativeHandle
	Stride int32
	Width  uint32
	Height uint32
	Format int32
	Usage  uint64

	// MmapData holds a persistent mmap of the dmabuf, set by Mmap().
	// Keeping it mapped avoids mmap/munmap syscalls per frame read.
	MmapData []byte
}

Buffer holds a gralloc-allocated buffer with its NativeHandle.

func Allocate

func Allocate(
	ctx context.Context,
	sm *servicemanager.ServiceManager,
	width int32,
	height int32,
	format gfxCommon.PixelFormat,
	usage gfxCommon.BufferUsage,
) (*Buffer, error)

Allocate allocates a gralloc buffer using the IAllocator HAL service. The returned Buffer contains a dmabuf FD that can be mmap'd for CPU read access.

func (*Buffer) Mmap

func (b *Buffer) Mmap() error

Mmap creates a persistent read-only mmap of this buffer's dmabuf FD. The MmapData field can then be read directly. Call Munmap to release.

func (*Buffer) Munmap

func (b *Buffer) Munmap()

Munmap releases the persistent mmap created by Mmap.

Jump to

Keyboard shortcuts

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