forked from mono/SkiaSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSKShader.cs
461 lines (353 loc) · 21.9 KB
/
SKShader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#nullable disable
using System;
using System.IO;
namespace SkiaSharp
{
public unsafe class SKShader : SKObject, ISKReferenceCounted
{
internal SKShader (IntPtr handle, bool owns)
: base (handle, owns)
{
}
protected override void Dispose (bool disposing) =>
base.Dispose (disposing);
// WithColorFilter
public SKShader WithColorFilter (SKColorFilter filter)
{
if (filter == null)
throw new ArgumentNullException (nameof (filter));
return GetObject (SkiaApi.sk_shader_with_color_filter (Handle, filter.Handle));
}
// WithLocalMatrix
public SKShader WithLocalMatrix (SKMatrix localMatrix) =>
GetObject (SkiaApi.sk_shader_with_local_matrix (Handle, &localMatrix));
// CreateEmpty
public static SKShader CreateEmpty () =>
GetObject (SkiaApi.sk_shader_new_empty ());
// CreateColor
public static SKShader CreateColor (SKColor color) =>
GetObject (SkiaApi.sk_shader_new_color ((uint)color));
public static SKShader CreateColor (SKColorF color, SKColorSpace colorspace)
{
if (colorspace == null)
throw new ArgumentNullException (nameof (colorspace));
return GetObject (SkiaApi.sk_shader_new_color4f (&color, colorspace.Handle));
}
// CreateBitmap
public static SKShader CreateBitmap (SKBitmap src) =>
CreateBitmap (src, SKShaderTileMode.Clamp, SKShaderTileMode.Clamp);
public static SKShader CreateBitmap (SKBitmap src, SKShaderTileMode tmx, SKShaderTileMode tmy)
{
if (src == null)
throw new ArgumentNullException (nameof (src));
return src.ToShader (tmx, tmy);
}
public static SKShader CreateBitmap (SKBitmap src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix)
{
if (src == null)
throw new ArgumentNullException (nameof (src));
return src.ToShader (tmx, tmy, localMatrix);
}
// CreateImage
public static SKShader CreateImage (SKImage src) =>
src?.ToShader () ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy) =>
src?.ToShader (tmx, tmy) ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) =>
src?.ToShader (tmx, tmy, sampling) ?? throw new ArgumentNullException (nameof (src));
[Obsolete ("Use CreateImage(SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) instead.")]
public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterQuality quality) =>
src?.ToShader (tmx, tmy, quality.ToSamplingOptions()) ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix) =>
src?.ToShader (tmx, tmy, localMatrix) ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) =>
src?.ToShader (tmx, tmy, sampling, localMatrix) ?? throw new ArgumentNullException (nameof (src));
[Obsolete ("Use CreateImage(SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) instead.")]
public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterQuality quality, SKMatrix localMatrix) =>
src?.ToShader (tmx, tmy, quality.ToSamplingOptions(), localMatrix) ?? throw new ArgumentNullException (nameof (src));
// CreatePicture
public static SKShader CreatePicture (SKPicture src) =>
src?.ToShader () ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreatePicture (SKPicture src, SKShaderTileMode tmx, SKShaderTileMode tmy) =>
src?.ToShader (tmx, tmy) ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreatePicture (SKPicture src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterMode filterMode) =>
src?.ToShader (tmx, tmy, filterMode) ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreatePicture (SKPicture src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKRect tile) =>
src?.ToShader (tmx, tmy, tile) ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreatePicture (SKPicture src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterMode filterMode, SKRect tile) =>
src?.ToShader (tmx, tmy, filterMode, tile) ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreatePicture (SKPicture src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix, SKRect tile) =>
src?.ToShader (tmx, tmy, localMatrix, tile) ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreatePicture (SKPicture src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterMode filterMode, SKMatrix localMatrix, SKRect tile) =>
src?.ToShader (tmx, tmy, filterMode, localMatrix, tile) ?? throw new ArgumentNullException (nameof (src));
// CreateLinearGradient
public static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColor[] colors, SKShaderTileMode mode) =>
CreateLinearGradient (start, end, colors, null, mode);
public static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColor[] colors, float[] colorPos, SKShaderTileMode mode)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
var points = stackalloc SKPoint[] { start, end };
fixed (SKColor* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_linear_gradient (points, (uint*)c, cp, colors.Length, mode, null));
}
}
public static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColor[] colors, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
var points = stackalloc SKPoint[] { start, end };
fixed (SKColor* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_linear_gradient (points, (uint*)c, cp, colors.Length, mode, &localMatrix));
}
}
public static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode mode) =>
CreateLinearGradient (start, end, colors, colorspace, null, mode);
public static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
var points = stackalloc SKPoint[] { start, end };
fixed (SKColorF* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_linear_gradient_color4f (points, c, colorspace?.Handle ?? IntPtr.Zero, cp, colors.Length, mode, null));
}
}
public static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
var points = stackalloc SKPoint[] { start, end };
fixed (SKColorF* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_linear_gradient_color4f (points, c, colorspace?.Handle ?? IntPtr.Zero, cp, colors.Length, mode, &localMatrix));
}
}
// CreateRadialGradient
public static SKShader CreateRadialGradient (SKPoint center, float radius, SKColor[] colors, SKShaderTileMode mode) =>
CreateRadialGradient (center, radius, colors, null, mode);
public static SKShader CreateRadialGradient (SKPoint center, float radius, SKColor[] colors, float[] colorPos, SKShaderTileMode mode)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColor* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_radial_gradient (¢er, radius, (uint*)c, cp, colors.Length, mode, null));
}
}
public static SKShader CreateRadialGradient (SKPoint center, float radius, SKColor[] colors, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColor* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_radial_gradient (¢er, radius, (uint*)c, cp, colors.Length, mode, &localMatrix));
}
}
public static SKShader CreateRadialGradient (SKPoint center, float radius, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode mode) =>
CreateRadialGradient (center, radius, colors, colorspace, null, mode);
public static SKShader CreateRadialGradient (SKPoint center, float radius, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColorF* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_radial_gradient_color4f (¢er, radius, c, colorspace?.Handle ?? IntPtr.Zero, cp, colors.Length, mode, null));
}
}
public static SKShader CreateRadialGradient (SKPoint center, float radius, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColorF* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_radial_gradient_color4f (¢er, radius, c, colorspace?.Handle ?? IntPtr.Zero, cp, colors.Length, mode, &localMatrix));
}
}
// CreateSweepGradient
public static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors) =>
CreateSweepGradient (center, colors, null, SKShaderTileMode.Clamp, 0, 360);
public static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors, float[] colorPos) =>
CreateSweepGradient (center, colors, colorPos, SKShaderTileMode.Clamp, 0, 360);
public static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors, float[] colorPos, SKMatrix localMatrix) =>
CreateSweepGradient (center, colors, colorPos, SKShaderTileMode.Clamp, 0, 360, localMatrix);
public static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors, SKShaderTileMode tileMode, float startAngle, float endAngle) =>
CreateSweepGradient (center, colors, null, tileMode, startAngle, endAngle);
public static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors, float[] colorPos, SKShaderTileMode tileMode, float startAngle, float endAngle)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColor* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_sweep_gradient (¢er, (uint*)c, cp, colors.Length, tileMode, startAngle, endAngle, null));
}
}
public static SKShader CreateSweepGradient (SKPoint center, SKColor[] colors, float[] colorPos, SKShaderTileMode tileMode, float startAngle, float endAngle, SKMatrix localMatrix)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColor* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_sweep_gradient (¢er, (uint*)c, cp, colors.Length, tileMode, startAngle, endAngle, &localMatrix));
}
}
public static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace) =>
CreateSweepGradient (center, colors, colorspace, null, SKShaderTileMode.Clamp, 0, 360);
public static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos) =>
CreateSweepGradient (center, colors, colorspace, colorPos, SKShaderTileMode.Clamp, 0, 360);
public static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKMatrix localMatrix) =>
CreateSweepGradient (center, colors, colorspace, colorPos, SKShaderTileMode.Clamp, 0, 360, localMatrix);
public static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode tileMode, float startAngle, float endAngle) =>
CreateSweepGradient (center, colors, colorspace, null, tileMode, startAngle, endAngle);
public static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode tileMode, float startAngle, float endAngle)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColorF* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_sweep_gradient_color4f (¢er, c, colorspace?.Handle ?? IntPtr.Zero, cp, colors.Length, tileMode, startAngle, endAngle, null));
}
}
public static SKShader CreateSweepGradient (SKPoint center, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode tileMode, float startAngle, float endAngle, SKMatrix localMatrix)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColorF* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_sweep_gradient_color4f (¢er, c, colorspace?.Handle ?? IntPtr.Zero, cp, colors.Length, tileMode, startAngle, endAngle, &localMatrix));
}
}
// CreateTwoPointConicalGradient
public static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColor[] colors, SKShaderTileMode mode) =>
CreateTwoPointConicalGradient (start, startRadius, end, endRadius, colors, null, mode);
public static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColor[] colors, float[] colorPos, SKShaderTileMode mode)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColor* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_two_point_conical_gradient (&start, startRadius, &end, endRadius, (uint*)c, cp, colors.Length, mode, null));
}
}
public static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColor[] colors, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColor* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_two_point_conical_gradient (&start, startRadius, &end, endRadius, (uint*)c, cp, colors.Length, mode, &localMatrix));
}
}
public static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode mode) =>
CreateTwoPointConicalGradient (start, startRadius, end, endRadius, colors, colorspace, null, mode);
public static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColorF* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_two_point_conical_gradient_color4f (&start, startRadius, &end, endRadius, c, colorspace?.Handle ?? IntPtr.Zero, cp, colors.Length, mode, null));
}
}
public static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix)
{
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos != null && colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
fixed (SKColorF* c = colors)
fixed (float* cp = colorPos) {
return GetObject (SkiaApi.sk_shader_new_two_point_conical_gradient_color4f (&start, startRadius, &end, endRadius, c, colorspace?.Handle ?? IntPtr.Zero, cp, colors.Length, mode, &localMatrix));
}
}
// CreatePerlinNoiseFractalNoise
public static SKShader CreatePerlinNoiseFractalNoise (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed) =>
GetObject (SkiaApi.sk_shader_new_perlin_noise_fractal_noise (baseFrequencyX, baseFrequencyY, numOctaves, seed, null));
public static SKShader CreatePerlinNoiseFractalNoise (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, SKPointI tileSize) =>
CreatePerlinNoiseFractalNoise (baseFrequencyX, baseFrequencyY, numOctaves, seed, (SKSizeI)tileSize);
public static SKShader CreatePerlinNoiseFractalNoise (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, SKSizeI tileSize) =>
GetObject (SkiaApi.sk_shader_new_perlin_noise_fractal_noise (baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize));
// CreatePerlinNoiseTurbulence
public static SKShader CreatePerlinNoiseTurbulence (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed) =>
GetObject (SkiaApi.sk_shader_new_perlin_noise_turbulence (baseFrequencyX, baseFrequencyY, numOctaves, seed, null));
public static SKShader CreatePerlinNoiseTurbulence (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, SKPointI tileSize) =>
CreatePerlinNoiseTurbulence (baseFrequencyX, baseFrequencyY, numOctaves, seed, (SKSizeI)tileSize);
public static SKShader CreatePerlinNoiseTurbulence (float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, SKSizeI tileSize) =>
GetObject (SkiaApi.sk_shader_new_perlin_noise_turbulence (baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize));
// CreateCompose
public static SKShader CreateCompose (SKShader shaderA, SKShader shaderB) =>
CreateCompose (shaderA, shaderB, SKBlendMode.SrcOver);
public static SKShader CreateCompose (SKShader shaderA, SKShader shaderB, SKBlendMode mode)
{
if (shaderA == null)
throw new ArgumentNullException (nameof (shaderA));
if (shaderB == null)
throw new ArgumentNullException (nameof (shaderB));
return GetObject (SkiaApi.sk_shader_new_blend (mode, shaderA.Handle, shaderB.Handle));
}
// CreateBlend
public static SKShader CreateBlend (SKBlendMode mode, SKShader shaderA, SKShader shaderB)
{
_ = shaderA ?? throw new ArgumentNullException (nameof (shaderA));
_ = shaderB ?? throw new ArgumentNullException (nameof (shaderB));
return GetObject (SkiaApi.sk_shader_new_blend (mode, shaderA.Handle, shaderB.Handle));
}
public static SKShader CreateBlend (SKBlender blender, SKShader shaderA, SKShader shaderB)
{
_ = shaderA ?? throw new ArgumentNullException (nameof (shaderA));
_ = shaderB ?? throw new ArgumentNullException (nameof (shaderB));
_ = blender ?? throw new ArgumentNullException (nameof (blender));
return GetObject (SkiaApi.sk_shader_new_blender (blender.Handle, shaderA.Handle, shaderB.Handle));
}
// CreateColorFilter
public static SKShader CreateColorFilter (SKShader shader, SKColorFilter filter)
{
if (shader == null)
throw new ArgumentNullException (nameof (shader));
if (filter == null)
throw new ArgumentNullException (nameof (filter));
return shader.WithColorFilter (filter);
}
// CreateLocalMatrix
public static SKShader CreateLocalMatrix (SKShader shader, SKMatrix localMatrix)
{
if (shader == null)
throw new ArgumentNullException (nameof (shader));
return shader.WithLocalMatrix (localMatrix);
}
internal static SKShader GetObject (IntPtr handle) =>
GetOrAddObject (handle, (h, o) => new SKShader (h, o));
}
}