@@ -28,17 +28,19 @@ public IconCacheBase()
2828 _platformScalingFactor = ( float ) PlatformInfo . ScalingFactor ;
2929 }
3030
31- public Task < Image > IconFromSvg ( string svgName , double squareSize = 22d , string additionalCacheKey = "" , Color ? colorOverride = null ) => IconFromSvg ( svgName , new Size ( squareSize , squareSize ) , additionalCacheKey , colorOverride ) ;
31+ public Task < Image > IconFromSvg ( string svgName , double squareSize = 22d , string additionalCacheKey = "" , Color ? colorOverride = null , bool hardwareAcceleration = true ) =>
32+ IconFromSvg ( svgName , new Size ( squareSize , squareSize ) , additionalCacheKey , colorOverride , hardwareAcceleration ) ;
3233
33- public async Task < Image > IconFromSvg ( string svgName , Size size , string additionalCacheKey = "" , Color ? colorOverride = null ) =>
34+ public async Task < Image > IconFromSvg ( string svgName , Size size , string additionalCacheKey = "" , Color ? colorOverride = null , bool hardwareAcceleration = true ) =>
3435 new ( )
3536 {
36- Source = await ImageSourceFromSvg ( svgName , size , additionalCacheKey , colorOverride ) ,
37+ Source = await ImageSourceFromSvg ( svgName , size , additionalCacheKey , colorOverride , hardwareAcceleration ) ,
3738 } ;
3839
39- public Task < ImageSource > ImageSourceFromRawSvg ( string svgName , string svgValue , double squareSize = 22d , string additionalCacheKey = "" , Color ? colorOverride = null ) => ImageSourceFromRawSvg ( svgName , svgValue , new Size ( squareSize , squareSize ) , additionalCacheKey , colorOverride ) ;
40+ public Task < ImageSource > ImageSourceFromRawSvg ( string svgName , string svgValue , double squareSize = 22d , string additionalCacheKey = "" , Color ? colorOverride = null , bool hardwareAcceleration = true ) =>
41+ ImageSourceFromRawSvg ( svgName , svgValue , new Size ( squareSize , squareSize ) , additionalCacheKey , colorOverride , hardwareAcceleration ) ;
4042
41- public async Task < ImageSource > ImageSourceFromRawSvg ( string svgName , string svgValue , Size size , string additionalCacheKey = "" , Color ? colorOverride = null )
43+ public async Task < ImageSource > ImageSourceFromRawSvg ( string svgName , string svgValue , Size size , string additionalCacheKey = "" , Color ? colorOverride = null , bool hardwareAcceleration = true )
4244 {
4345 try
4446 {
@@ -48,15 +50,15 @@ public async Task<ImageSource> ImageSourceFromRawSvg(string svgName, string svgV
4850
4951 if ( _resolvedIcons . ContainsKey ( key ) )
5052 {
51- return GetPlatformImageSource ( _resolvedIcons [ key ] ) ;
53+ return GetPlatformImageSource ( _resolvedIcons [ key ] , hardwareAcceleration ) ;
5254 }
5355
5456 string ? diskCachedImage = GetImagePathFromDiskCache ( key ) ;
5557
5658 if ( ! string . IsNullOrEmpty ( diskCachedImage ) )
5759 {
5860 _resolvedIcons [ key ] = diskCachedImage ;
59- return GetPlatformImageSource ( diskCachedImage ) ;
61+ return GetPlatformImageSource ( diskCachedImage , hardwareAcceleration ) ;
6062 }
6163
6264 await GenerateImageFromRaw ( key , svgValue , size , colorOverride ) . ConfigureAwait ( false ) ;
@@ -65,18 +67,18 @@ public async Task<ImageSource> ImageSourceFromRawSvg(string svgName, string svgV
6567
6668 _resolvedIcons [ key ] = diskCachedImage ;
6769
68- return GetPlatformImageSource ( diskCachedImage ) ;
70+ return GetPlatformImageSource ( diskCachedImage , hardwareAcceleration ) ;
6971 }
7072 finally
7173 {
7274 _iconLock . Release ( ) ;
7375 }
7476 }
7577
76- public Task < ImageSource > ImageSourceFromSvg ( string svgName , double squareSize = 22d , string additionalCacheKey = "" , Color ? colorOverride = null ) =>
77- ImageSourceFromSvg ( svgName , new Size ( squareSize , squareSize ) , additionalCacheKey , colorOverride ) ;
78+ public Task < ImageSource > ImageSourceFromSvg ( string svgName , double squareSize = 22d , string additionalCacheKey = "" , Color ? colorOverride = null , bool hardwareAcceleration = true ) =>
79+ ImageSourceFromSvg ( svgName , new Size ( squareSize , squareSize ) , additionalCacheKey , colorOverride , hardwareAcceleration ) ;
7880
79- public async Task < ImageSource > ImageSourceFromSvg ( string svgName , Size size , string additionalCacheKey = "" , Color ? colorOverride = null )
81+ public async Task < ImageSource > ImageSourceFromSvg ( string svgName , Size size , string additionalCacheKey = "" , Color ? colorOverride = null , bool hardwareAcceleration = true )
8082 {
8183 try
8284 {
@@ -86,15 +88,15 @@ public async Task<ImageSource> ImageSourceFromSvg(string svgName, Size size, str
8688
8789 if ( _resolvedIcons . ContainsKey ( key ) )
8890 {
89- return GetPlatformImageSource ( _resolvedIcons [ key ] ) ;
91+ return GetPlatformImageSource ( _resolvedIcons [ key ] , hardwareAcceleration ) ;
9092 }
9193
9294 string ? diskCachedImage = GetImagePathFromDiskCache ( key ) ;
9395
9496 if ( ! string . IsNullOrEmpty ( diskCachedImage ) )
9597 {
9698 _resolvedIcons [ key ] = diskCachedImage ;
97- return GetPlatformImageSource ( diskCachedImage ) ;
99+ return GetPlatformImageSource ( diskCachedImage , hardwareAcceleration ) ;
98100 }
99101
100102 await GenerateImageFromEmbedded ( key , svgName , size , colorOverride ) . ConfigureAwait ( false ) ;
@@ -103,7 +105,7 @@ public async Task<ImageSource> ImageSourceFromSvg(string svgName, Size size, str
103105
104106 _resolvedIcons [ key ] = diskCachedImage ;
105107
106- return GetPlatformImageSource ( diskCachedImage ) ;
108+ return GetPlatformImageSource ( diskCachedImage , hardwareAcceleration ) ;
107109 }
108110 catch ( Exception ex )
109111 {
@@ -117,11 +119,11 @@ public async Task<ImageSource> ImageSourceFromSvg(string svgName, Size size, str
117119 }
118120 }
119121
120- private ImageSource GetPlatformImageSource ( string ? file = null )
122+ private ImageSource GetPlatformImageSource ( string ? file = null , bool hardwareAcceleration = true )
121123 {
122124 if ( DeviceInfo . Current . Platform == DevicePlatform . Android )
123125 {
124- return new NoCacheFileImageSource { File = file } ;
126+ return new NoCacheFileImageSource { File = file , HardwareAcceleration = hardwareAcceleration } ;
125127 }
126128
127129 return new FileImageSource { File = file } ;
0 commit comments