Documentation
¶
Overview ¶
Package renderstate 管理单次绘制的资源预算、诊断聚合与报告快照。 每份 Budget 由一次同步遍历持有;缓存中的预算仅用于读取已完成的用量。
Index ¶
- Constants
- type Budget
- func (b *Budget) AddUsage(usage *Budget)
- func (b *Budget) AllowComposite(resourceID models.StID) bool
- func (b *Budget) AllowOffscreenPixels(width, height, dpi float64) bool
- func (b *Budget) AllowPatternTiles(count int) bool
- func (b *Budget) CanReuse(usage *Budget) bool
- func (b *Budget) CompositeCount(resource models.StID) int
- func (b *Budget) Diagnose(code, message string, resource models.StID)
- func (b *Budget) HasUsage() bool
- func (b *Budget) ReportLimit(flag Limit, reason string, attrs ...any)
- func (b *Budget) Reset()
- func (b *Budget) Usage() Stats
- type Diagnostic
- type Limit
- type Report
- type ReportBuilder
- type Stats
Constants ¶
View Source
const ( // MaxCompositeExpansions 限制一次遍历的复合图元展开总数。 MaxCompositeExpansions = 10000 // MaxCompositeResourceExpansions 限制同一复合资源的重复展开。 MaxCompositeResourceExpansions = 256 // MaxPatternTiles 限制一次遍历的底纹图块总数。 MaxPatternTiles = 100000 // MaxOffscreenPixels 限制一次遍历累计分配的离屏像素。 MaxOffscreenPixels = 200000000 )
View Source
const MaxDiagnostics = 128
MaxDiagnostics 限制一份报告保留的诊断条目数,超出后只累计 Dropped。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Budget ¶
type Budget struct {
Report *ReportBuilder
ObjectID, ResourceID models.StID
// contains filtered or unexported fields
}
Budget 保存本次遍历的额度及诊断位置。Report 为 nil 时不收集报告。 ObjectID 和 ResourceID 由调用方在进入、退出图元时保存和恢复。
func (*Budget) AllowComposite ¶
AllowComposite 在展开前累计复合图元用量,超限时保留已消费额度。
func (*Budget) AllowOffscreenPixels ¶
AllowOffscreenPixels 在分配前按毫米尺寸和 DPI 累计离屏像素。
func (*Budget) AllowPatternTiles ¶
AllowPatternTiles 在绘制前累计图块数。
func (*Budget) CompositeCount ¶
CompositeCount 返回指定复合资源已展开的次数。
func (*Budget) ReportLimit ¶
ReportLimit 对每种拒绝原因仅输出一次 Debug 日志,报告仍按诊断事件累计次数。
type Diagnostic ¶
type Diagnostic struct {
Code string
Message string
ObjectID models.StID
ResourceID models.StID
Count int
}
Diagnostic 是一次绘制中的可恢复问题;同一原因、对象和资源会合并计数。
type Limit ¶
type Limit uint8
Limit 标识日志去重所用的预算拒绝原因。
const (
// LimitPatternTiles 也用于平铺计划在分配前发现索引或数量超限的情况。
LimitPatternTiles Limit
)
type Report ¶
type Report struct {
PageID models.StID
Stats Stats
Diagnostics []Diagnostic
// Dropped 是超过条目上限后未保存的诊断事件数。
Dropped int
}
Report 是单次绘制的独立快照,不记录到共享文档或全局日志处理器。
type ReportBuilder ¶
type ReportBuilder struct {
Report
// contains filtered or unexported fields
}
ReportBuilder 聚合单次绘制的诊断,零值可用。
func (*ReportBuilder) Snapshot ¶
func (r *ReportBuilder) Snapshot() Report
Snapshot 返回独立的报告副本,调用方修改诊断切片不会污染聚合器。
Click to show internal directories.
Click to hide internal directories.