feat(转换能力): 无损提速离线转换
build.yaml / build (push) Successful in 50s

This commit is contained in:
xiaoqidun committed 2026-10-15 15:48:36 +08:00
1 parent 7f6282fd94
commit 43d0713488
2 files changed
+15

No files matched your search

+9
View File
@@ -250,6 +250,9 @@ func CompositeGroupRegion(ctx context.Context, pixels, initial, result []Composi
} }
components, parentComponents := space.Components(), parent.Components() components, parentComponents := space.Components(), parent.Components()
var target pdfgo.ColorantPixel var target pdfgo.ColorantPixel
var previous, previousInitial, previousResult, composed CompositePixel
var previousAlpha float64
ready := false
for y := region.Min.Y; y < region.Max.Y; y++ { for y := region.Min.Y; y < region.Max.Y; y++ {
if err := ctx.Err(); err != nil { if err := ctx.Err(); err != nil {
return err return err
@@ -265,6 +268,11 @@ func CompositeGroupRegion(ctx context.Context, pixels, initial, result []Composi
alpha *= mask[i] alpha *= mask[i]
} }
pixel := &result[i] pixel := &result[i]
if ready && pixels[i] == previous && initial[i] == previousInitial && *pixel == previousResult && alpha == previousAlpha {
pixels[i] = composed
continue
}
previous, previousInitial, previousResult, previousAlpha = pixels[i], initial[i], *pixel, alpha
target.Values = pixels[i].Values[:parentComponents] target.Values = pixels[i].Values[:parentComponents]
target.Alpha = pixels[i].Alpha target.Alpha = pixels[i].Alpha
target.Shape = pixels[i].Shape target.Shape = pixels[i].Shape
@@ -277,6 +285,7 @@ func CompositeGroupRegion(ctx context.Context, pixels, initial, result []Composi
return err return err
} }
pixels[i].Alpha, pixels[i].Effect, pixels[i].Shape = target.Alpha, target.Effect, target.Shape pixels[i].Alpha, pixels[i].Effect, pixels[i].Shape = target.Alpha, target.Effect, target.Shape
composed, ready = pixels[i], true
} }
} }
return nil return nil
+6
View File
@@ -132,6 +132,7 @@ type outputContext struct {
cancel context.CancelFunc cancel context.CancelFunc
checkpoint func() error checkpoint func() error
checked time.Time checked time.Time
pending uint8
} }
// Write 将数据块交给浏览器保存 // Write 将数据块交给浏览器保存
@@ -5490,6 +5491,11 @@ func (c *outputContext) Err() error {
if err := c.Context.Err(); err != nil { if err := c.Context.Err(); err != nil {
return err return err
} }
if c.pending != 0 {
c.pending--
return nil
}
c.pending = 15
if time.Since(c.checked) >= 50*time.Millisecond { if time.Since(c.checked) >= 50*time.Millisecond {
c.checked = time.Now() c.checked = time.Now()
if err := c.checkpoint(); err != nil { if err := c.checkpoint(); err != nil {