@@ -12,9 +12,9 @@ namespace SixLabors.ImageSharp.Benchmarks;
12
12
13
13
public class PorterDuffBulkVsPixel
14
14
{
15
- private Configuration Configuration => Configuration . Default ;
15
+ private static Configuration Configuration => Configuration . Default ;
16
16
17
- private void BulkVectorConvert < TPixel > (
17
+ private static void BulkVectorConvert < TPixel > (
18
18
Span < TPixel > destination ,
19
19
Span < TPixel > background ,
20
20
Span < TPixel > source ,
@@ -31,18 +31,18 @@ private void BulkVectorConvert<TPixel>(
31
31
Span < Vector4 > backgroundSpan = buffer . Slice ( destination . Length , destination . Length ) ;
32
32
Span < Vector4 > sourceSpan = buffer . Slice ( destination . Length * 2 , destination . Length ) ;
33
33
34
- PixelOperations < TPixel > . Instance . ToVector4 ( this . Configuration , background , backgroundSpan ) ;
35
- PixelOperations < TPixel > . Instance . ToVector4 ( this . Configuration , source , sourceSpan ) ;
34
+ PixelOperations < TPixel > . Instance . ToVector4 ( Configuration , background , backgroundSpan ) ;
35
+ PixelOperations < TPixel > . Instance . ToVector4 ( Configuration , source , sourceSpan ) ;
36
36
37
37
for ( int i = 0 ; i < destination . Length ; i ++ )
38
38
{
39
39
destinationSpan [ i ] = PorterDuffFunctions . NormalSrcOver ( backgroundSpan [ i ] , sourceSpan [ i ] , amount [ i ] ) ;
40
40
}
41
41
42
- PixelOperations < TPixel > . Instance . FromVector4Destructive ( this . Configuration , destinationSpan , destination ) ;
42
+ PixelOperations < TPixel > . Instance . FromVector4Destructive ( Configuration , destinationSpan , destination ) ;
43
43
}
44
44
45
- private void BulkPixelConvert < TPixel > (
45
+ private static void BulkPixelConvert < TPixel > (
46
46
Span < TPixel > destination ,
47
47
Span < TPixel > background ,
48
48
Span < TPixel > source ,
@@ -60,33 +60,33 @@ private void BulkPixelConvert<TPixel>(
60
60
}
61
61
62
62
[ Benchmark ( Description = "ImageSharp BulkVectorConvert" ) ]
63
- public Size BulkVectorConvert ( )
63
+ public static Size BulkVectorConvert ( )
64
64
{
65
- using var image = new Image < Rgba32 > ( 800 , 800 ) ;
65
+ using Image < Rgba32 > image = new ( 800 , 800 ) ;
66
66
using IMemoryOwner < float > amounts = Configuration . Default . MemoryAllocator . Allocate < float > ( image . Width ) ;
67
67
amounts . GetSpan ( ) . Fill ( 1 ) ;
68
68
69
69
Buffer2D < Rgba32 > pixels = image . GetRootFramePixelBuffer ( ) ;
70
70
for ( int y = 0 ; y < image . Height ; y ++ )
71
71
{
72
72
Span < Rgba32 > span = pixels . DangerousGetRowSpan ( y ) ;
73
- this . BulkVectorConvert ( span , span , span , amounts . GetSpan ( ) ) ;
73
+ BulkVectorConvert ( span , span , span , amounts . GetSpan ( ) ) ;
74
74
}
75
75
76
76
return new Size ( image . Width , image . Height ) ;
77
77
}
78
78
79
79
[ Benchmark ( Description = "ImageSharp BulkPixelConvert" ) ]
80
- public Size BulkPixelConvert ( )
80
+ public static Size BulkPixelConvert ( )
81
81
{
82
- using var image = new Image < Rgba32 > ( 800 , 800 ) ;
82
+ using Image < Rgba32 > image = new ( 800 , 800 ) ;
83
83
using IMemoryOwner < float > amounts = Configuration . Default . MemoryAllocator . Allocate < float > ( image . Width ) ;
84
84
amounts . GetSpan ( ) . Fill ( 1 ) ;
85
85
Buffer2D < Rgba32 > pixels = image . GetRootFramePixelBuffer ( ) ;
86
86
for ( int y = 0 ; y < image . Height ; y ++ )
87
87
{
88
88
Span < Rgba32 > span = pixels . DangerousGetRowSpan ( y ) ;
89
- this . BulkPixelConvert ( span , span , span , amounts . GetSpan ( ) ) ;
89
+ BulkPixelConvert ( span , span , span , amounts . GetSpan ( ) ) ;
90
90
}
91
91
92
92
return new Size ( image . Width , image . Height ) ;
0 commit comments