File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
src/ImageSharp/Formats/Webp/Lossless Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -8,21 +8,33 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless;
8
8
9
9
internal class Vp8LBackwardRefs : IDisposable
10
10
{
11
- private readonly IMemoryOwner < PixOrCopy > refs ;
11
+ private readonly IMemoryOwner < PixOrCopy > owner ;
12
+ private readonly MemoryHandle handle ;
12
13
private int count ;
13
14
14
15
public Vp8LBackwardRefs ( MemoryAllocator memoryAllocator , int pixels )
15
16
{
16
- this . refs = memoryAllocator . Allocate < PixOrCopy > ( pixels ) ;
17
+ this . owner = memoryAllocator . Allocate < PixOrCopy > ( pixels ) ;
18
+ this . handle = this . owner . Memory . Pin ( ) ;
17
19
this . count = 0 ;
18
20
}
19
21
20
- public void Add ( PixOrCopy pixOrCopy ) => this . refs . Memory . Span [ this . count ++ ] = pixOrCopy ;
22
+ public void Add ( PixOrCopy pixOrCopy )
23
+ {
24
+ unsafe
25
+ {
26
+ ( ( PixOrCopy * ) this . handle . Pointer ) [ this . count ++ ] = pixOrCopy ;
27
+ }
28
+ }
21
29
22
30
public void Clear ( ) => this . count = 0 ;
23
31
24
- public Span < PixOrCopy > . Enumerator GetEnumerator ( ) => this . refs . Slice ( 0 , this . count ) . GetEnumerator ( ) ;
32
+ public Span < PixOrCopy > . Enumerator GetEnumerator ( ) => this . owner . Slice ( 0 , this . count ) . GetEnumerator ( ) ;
25
33
26
34
/// <inheritdoc/>
27
- public void Dispose ( ) => this . refs . Dispose ( ) ;
35
+ public void Dispose ( )
36
+ {
37
+ this . handle . Dispose ( ) ;
38
+ this . owner . Dispose ( ) ;
39
+ }
28
40
}
You can’t perform that action at this time.
0 commit comments