mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 17:27:08 +08:00
1 parent
7f6282fd94
commit
43d0713488
2 files changed
+15
No files matched your search
@@ -250,6 +250,9 @@ func CompositeGroupRegion(ctx context.Context, pixels, initial, result []Composi
|
||||
}
|
||||
components, parentComponents := space.Components(), parent.Components()
|
||||
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++ {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
@@ -265,6 +268,11 @@ func CompositeGroupRegion(ctx context.Context, pixels, initial, result []Composi
|
||||
alpha *= mask[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.Alpha = pixels[i].Alpha
|
||||
target.Shape = pixels[i].Shape
|
||||
@@ -277,6 +285,7 @@ func CompositeGroupRegion(ctx context.Context, pixels, initial, result []Composi
|
||||
return err
|
||||
}
|
||||
pixels[i].Alpha, pixels[i].Effect, pixels[i].Shape = target.Alpha, target.Effect, target.Shape
|
||||
composed, ready = pixels[i], true
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -132,6 +132,7 @@ type outputContext struct {
|
||||
cancel context.CancelFunc
|
||||
checkpoint func() error
|
||||
checked time.Time
|
||||
pending uint8
|
||||
}
|
||||
|
||||
// Write 将数据块交给浏览器保存
|
||||
@@ -5490,6 +5491,11 @@ func (c *outputContext) Err() error {
|
||||
if err := c.Context.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
if c.pending != 0 {
|
||||
c.pending--
|
||||
return nil
|
||||
}
|
||||
c.pending = 15
|
||||
if time.Since(c.checked) >= 50*time.Millisecond {
|
||||
c.checked = time.Now()
|
||||
if err := c.checkpoint(); err != nil {
|
||||
|
||||
Reference in new issue
Block a user