1 module skia.SKPixelSerializer;
2 
3 import skia.SKObject;
4 import skia.SkiaApi;
5 import skia.SKData;
6 import skia.SKPixmap;
7 import skia.Definitions;
8 import skia.Exceptions;
9 
10 
11 class SKPixelSerializer : SKObject, ISKSkipObjectRegistration
12 {
13 	protected this ()
14 	{
15     	super (null, false);
16 	}
17 
18 	bool UseEncodedData (void* data, ulong length)
19 	{
20 		// if (!PlatformConfiguration.Is64Bit && length > uint.max)
21 		// 	throw new ArgumentOutOfRangeException (length.stringof, "The length exceeds the size of pointers.");
22 
23 		return OnUseEncodedData (data, cast(void*)length);
24 	}
25 
26 	SKData Encode (SKPixmap pixmap)
27 	{
28 		if (pixmap is null)
29 			throw new ArgumentNullException (pixmap.stringof);
30 
31 		return OnEncode (pixmap);
32 	}
33 
34 	protected abstract bool OnUseEncodedData (void* data, void* length);
35 
36 	protected abstract SKData OnEncode (SKPixmap pixmap);
37 
38 	// static SKPixelSerializer Create (Func<SKPixmap, SKData> onEncode)
39 	// {
40 	// 	return new SKSimplePixelSerializer (null, onEncode);
41 	// }
42 
43 	// static SKPixelSerializer Create (Func<void*, void*, bool> onUseEncodedData, Func<SKPixmap, SKData> onEncode)
44 	// {
45 	// 	return new SKSimplePixelSerializer (onUseEncodedData, onEncode);
46 	// }
47 }
48 
49 class SKSimplePixelSerializer : SKPixelSerializer
50 {
51 	// private const Func<void*, void*, bool> onUseEncodedData;
52 	// private const Func<SKPixmap, SKData> onEncode;
53 
54 	// this (Func<void*, void*, bool> onUseEncodedData, Func<SKPixmap, SKData> onEncode)
55 	// {
56 	// 	this.onUseEncodedData = onUseEncodedData;
57 	// 	this.onEncode = onEncode;
58 	// }
59 
60 	// protected override SKData OnEncode (SKPixmap pixmap)
61 	// {
62 	// 	return onEncode.Invoke (pixmap) ? onEncode.Invoke (pixmap) : null;
63 	// }
64 
65 	// protected override bool OnUseEncodedData (void* data, void* length)
66 	// {
67 	// 	return onUseEncodedData.Invoke (data, length) ? onUseEncodedData.Invoke (data, length) : false;
68 	// }
69 }
70 
71 class SKManagedPixelSerializer : SKPixelSerializer
72 {
73 	this ()
74 	{
75 	}
76 }