blitznative

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT, MIT Imports: 7 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 blitznative 绑定 Blitz C ABI,管理原生 Context、RGBA 内存和线程本地错误。

Context 将原生图像复制到 Go 内存。绑定精简自 xo/blitz v0.5.0,许可见同目录 LICENSE。

Index

Constants

View Source
const InvalidArgument = int(C.BLITZ_ERR_INVALID_ARG)

InvalidArgument 对应原生桥接的输入错误状态码。

Variables

View Source
var ErrClosed = errors.New("blitz: context is closed")

ErrClosed 表示原生 Context 已释放。

Functions

This section is empty.

Types

type Context

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

Context 拥有原生指针,锁保证渲染结束前不会被 Close 释放。

func New

func New(workerThreads uint32) (*Context, error)

New 创建原生 Context;workerThreads 为零时使用桥接的默认线程设置。

func (*Context) Close

func (c *Context) Close()

Close 释放原生 Context,重复调用保持已关闭状态。

func (*Context) RenderHTML

func (c *Context) RenderHTML(markup, baseURL string, opts Options) (*image.RGBA, error)

RenderHTML 渲染 HTML,将原生 RGBA 复制到 Go 内存后释放原生图像。

type Error

type Error struct {
	Operation string
	Code      int
	Message   string
}

Error 保留原生调用名称、状态码与线程本地错误消息。

func (*Error) Error

func (e *Error) Error() string

Error 返回包含原生状态码的完整调用错误。

type Options

type Options struct {
	Width, Height              uint32
	Scale                      float32
	MaxHeight                  uint32
	BackgroundRGBA             uint32
	NetworkTimeoutMilliseconds uint32 // 子资源获取期限,单位为毫秒。
	FitContentHeight           bool
	Selector                   string
}

Options 映射 C ABI 渲染参数,尺寸以 CSS 像素表示,Scale 为像素缩放。

func DefaultOptions

func DefaultOptions() Options

DefaultOptions 读取当前 C ABI 定义的默认渲染参数。

Jump to

Keyboard shortcuts

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