first commit
This commit is contained in:
commit
9d9618897c
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"visualstudiotoolsforunity.vstuc"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Attach to Unity",
|
||||
"type": "vstuc",
|
||||
"request": "attach"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"files.exclude": {
|
||||
"**/.DS_Store": true,
|
||||
"**/.git": true,
|
||||
"**/.gitmodules": true,
|
||||
"**/*.booproj": true,
|
||||
"**/*.pidb": true,
|
||||
"**/*.suo": true,
|
||||
"**/*.user": true,
|
||||
"**/*.userprefs": true,
|
||||
"**/*.unityproj": true,
|
||||
"**/*.dll": true,
|
||||
"**/*.exe": true,
|
||||
"**/*.pdf": true,
|
||||
"**/*.mid": true,
|
||||
"**/*.midi": true,
|
||||
"**/*.wav": true,
|
||||
"**/*.gif": true,
|
||||
"**/*.ico": true,
|
||||
"**/*.jpg": true,
|
||||
"**/*.jpeg": true,
|
||||
"**/*.png": true,
|
||||
"**/*.psd": true,
|
||||
"**/*.tga": true,
|
||||
"**/*.tif": true,
|
||||
"**/*.tiff": true,
|
||||
"**/*.3ds": true,
|
||||
"**/*.3DS": true,
|
||||
"**/*.fbx": true,
|
||||
"**/*.FBX": true,
|
||||
"**/*.lxo": true,
|
||||
"**/*.LXO": true,
|
||||
"**/*.ma": true,
|
||||
"**/*.MA": true,
|
||||
"**/*.obj": true,
|
||||
"**/*.OBJ": true,
|
||||
"**/*.asset": true,
|
||||
"**/*.cubemap": true,
|
||||
"**/*.flare": true,
|
||||
"**/*.mat": true,
|
||||
"**/*.meta": true,
|
||||
"**/*.prefab": true,
|
||||
"**/*.unity": true,
|
||||
"build/": true,
|
||||
"Build/": true,
|
||||
"Library/": true,
|
||||
"library/": true,
|
||||
"obj/": true,
|
||||
"Obj/": true,
|
||||
"ProjectSettings/": true,
|
||||
"temp/": true,
|
||||
"Temp/": true
|
||||
},
|
||||
"dotnet.defaultSolution": "Singularity.sln"
|
||||
}
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0c055359223212d47810305d09089b25
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 59ccde1777a77f54a9434d727f494595
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace WebP
|
||||
{
|
||||
public enum Error
|
||||
{
|
||||
Success = 0,
|
||||
|
||||
InvalidHeader = 20,
|
||||
DecodingError = 30,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 559496677f3b38d44997ac5ce4705341
|
||||
timeCreated: 1505182658
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3e14b4cbe919f504aa2c05ca63fc3785
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 896477494e0c7d5429a0a520d53854d6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,68 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
|
||||
namespace WebP.Experiment.Animation
|
||||
{
|
||||
/// <summary>
|
||||
/// Entry of all the loading logic.
|
||||
/// </summary>
|
||||
public class WebP
|
||||
{
|
||||
|
||||
#if USE_FAIRYGUI
|
||||
/// <summary>
|
||||
/// Async loading webp files, and return WebPRender for render.
|
||||
/// This function return NTextures which would work with fairygui: https://en.fairygui.com/
|
||||
/// </summary>
|
||||
/// <param name="url">Remote urls to download or project related absolute path(based on platform)</param>
|
||||
/// <returns>WebPRederer to provide NTexture for rendering</returns>
|
||||
public static async Task<WebPRendererWrapper<NTexture>> LoadNTexturesAsync(string url)
|
||||
{
|
||||
var bytes = await WebPLoader.Load(url);
|
||||
if (bytes == null || bytes.Length <= 0) return null;
|
||||
|
||||
var sw = new Stopwatch();
|
||||
var textures = await WebPDecoderWrapper.Decode(bytes);
|
||||
var nTextures = textures.ConvertAll(ret =>
|
||||
{
|
||||
var (texture, timestamp) = ret;
|
||||
|
||||
return (new NTexture(texture), timestamp);
|
||||
});
|
||||
var renderer = new WebPRendererWrapper<NTexture>(nTextures);
|
||||
Debug.Log($"[WebP] Decode webp into textures in: {sw.ElapsedMilliseconds}");
|
||||
sw.Stop();
|
||||
return renderer;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Async loading webp files, and return WebPRender for render.
|
||||
/// </summary>
|
||||
/// <param name="url">Remote urls to download or project related absolute path(based on platform)</param>
|
||||
/// <returns>WebPRederer to provide Texture for rendering</returns>
|
||||
public static async Task<WebPRendererWrapper<Texture2D>> LoadTexturesAsync(string url)
|
||||
{
|
||||
byte[] bytes = await WebPLoader.Load(url);
|
||||
if (bytes == null || bytes.Length <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<(Texture2D, int)> textures = await WebPDecoderWrapper.Decode(bytes);
|
||||
WebPRendererWrapper<Texture2D> renderer = new WebPRendererWrapper<Texture2D>(textures);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
public static async Task<WebPRendererWrapper<Texture2D>> LoadTexturesAsync(byte[] bytes)
|
||||
{
|
||||
Assert.IsNotNull(bytes);
|
||||
|
||||
List<(Texture2D, int)> textures = await WebPDecoderWrapper.Decode(bytes);
|
||||
WebPRendererWrapper<Texture2D> renderer = new WebPRendererWrapper<Texture2D>(textures);
|
||||
return renderer;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a0a60e3c934562a4cb7d9b7eeb4f2f40
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,113 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Unity.Jobs;
|
||||
using UnityEngine;
|
||||
using unity.libwebp.Interop;
|
||||
using unity.libwebp;
|
||||
|
||||
namespace WebP.Experiment.Animation
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// WebP decoding process which optimized by using threads.
|
||||
/// </summary>
|
||||
public static class WebPDecodeJob
|
||||
{
|
||||
|
||||
public static Task<List<(byte[], int)>> StartJob(IntPtr decoder, int count)
|
||||
{
|
||||
Debug.Log($"[WebPDecodeJob] Starting multi-threading webp decode");
|
||||
var managedBytes = new ConcurrentDictionary<int, (byte[], int)>();
|
||||
var task = new WebPDecodeTask(decoder, managedBytes);
|
||||
var taskRef = GCHandle.Alloc(task);
|
||||
var job = new WebPDecoderJob { Task = taskRef };
|
||||
var handler = job.Schedule(count, 1);
|
||||
var handled = false;
|
||||
|
||||
while (!handled)
|
||||
{
|
||||
handled = handler.IsCompleted;
|
||||
}
|
||||
|
||||
handler.Complete();
|
||||
taskRef.Free();
|
||||
|
||||
if (managedBytes.Count <= 0 || managedBytes.Values.Count <= 0) return Task.FromResult(new List<(byte[], int)>());
|
||||
|
||||
var sorted = managedBytes.OrderBy(kvp => kvp.Key).ToList().ConvertAll(kvp => kvp.Value);
|
||||
return Task.FromResult(sorted);
|
||||
}
|
||||
}
|
||||
|
||||
internal interface IWebPDecodeTask
|
||||
{
|
||||
void Excute(int index);
|
||||
}
|
||||
|
||||
internal unsafe class WebPDecodeTask : IWebPDecodeTask
|
||||
{
|
||||
// have to use Concurrent structures to prevent concurrent race exceptions
|
||||
private ConcurrentDictionary<int, (byte[], int)> _managedBytes;
|
||||
private WebPAnimDecoder* _decoder;
|
||||
|
||||
public WebPDecodeTask(IntPtr decoder, ConcurrentDictionary<int, (byte[], int)> managedBytes)
|
||||
{
|
||||
_managedBytes = managedBytes;
|
||||
_decoder = (WebPAnimDecoder * )decoder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The actual decode process which make the magic happen
|
||||
/// </summary>
|
||||
public unsafe void Excute(int index)
|
||||
{
|
||||
// get the demuxer (which contains almost all the information about the WebP file)
|
||||
var demuxer = NativeLibwebpdemux.WebPAnimDecoderGetDemuxer(_decoder);
|
||||
WebPIterator iter = new WebPIterator();
|
||||
// use the demuxer and WebPIterator to extract one frame from the WebP data
|
||||
var success = NativeLibwebpdemux.WebPDemuxGetFrame(demuxer, index + 1, &iter);
|
||||
if (success == 0)
|
||||
{
|
||||
Debug.LogError($"[WebPDecodeTask] Decode frame data {index} failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// use native memory marshal to minimize the momory consumption from native memory to csharp managed memory
|
||||
var size = (int)iter.fragment.size;
|
||||
var bytes = new byte[size];
|
||||
Marshal.Copy((IntPtr)iter.fragment.bytes, bytes, 0, size);
|
||||
|
||||
// parse the memory data (structured bitmap data) to texture bytes, which can be used to parse into Texture
|
||||
var loadedBytes = Texture2DExt.LoadRGBAFromWebP(bytes, ref iter.width, ref iter.height, false, out var error, null);
|
||||
if (error != Error.Success)
|
||||
{
|
||||
Debug.LogError($"[WebPDecodeTask] Decode texture bytes {index} failed");
|
||||
return;
|
||||
}
|
||||
// sequential added to the concurrent dictionary
|
||||
// if not using concurrent dict, exceptions may happen
|
||||
_managedBytes?.TryAdd(index, (loadedBytes, iter.duration));
|
||||
// release the iterator pointer
|
||||
NativeLibwebpdemux.WebPDemuxReleaseIterator(&iter);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convinience for task usage
|
||||
/// </summary>
|
||||
internal struct WebPDecoderJob : IJobParallelFor
|
||||
{
|
||||
|
||||
public GCHandle Task;
|
||||
|
||||
public void Execute(int index)
|
||||
{
|
||||
var task = (IWebPDecodeTask)Task.Target;
|
||||
task?.Excute(index);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7f824b957755c274cb58313b2df1aedb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,129 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using unity.libwebp;
|
||||
using unity.libwebp.Interop;
|
||||
using UnityEngine;
|
||||
|
||||
namespace WebP.Experiment.Animation
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The decod logic before and after decoding.
|
||||
/// </summary>
|
||||
public static class WebPDecoderWrapper
|
||||
{
|
||||
|
||||
public static async Task<List<(Texture2D, int)>> Decode(byte[] bytes)
|
||||
{
|
||||
// create the decoder
|
||||
if (!CreateDecoder(bytes, out var decoder, out var info)) return null;
|
||||
|
||||
Debug.Log($"[WebPDecoderWrapper] Loaded animation: {info.frame_count}, {info.canvas_width}/{info.canvas_height}");
|
||||
// decode every frame of the WebP file with threads
|
||||
var decodedBytes = await WebPDecodeJob.StartJob(decoder, (int)info.frame_count);
|
||||
|
||||
Debug.Log($"[WebPDecoderWrapper] Raw bytes decode complete");
|
||||
|
||||
var textures = CreateTexturesFromBytes(decodedBytes, (int)info.canvas_width, (int)info.canvas_height);
|
||||
|
||||
// release the decoder
|
||||
ReleaseDecode(decoder);
|
||||
|
||||
return textures;
|
||||
}
|
||||
|
||||
private static unsafe void ReleaseDecode(IntPtr decoder)
|
||||
{
|
||||
NativeLibwebpdemux.WebPAnimDecoderReset((WebPAnimDecoder*)decoder);
|
||||
NativeLibwebpdemux.WebPAnimDecoderDelete((WebPAnimDecoder*)decoder);
|
||||
}
|
||||
|
||||
private static List<(Texture2D, int)> CreateTexturesFromBytes(List<(byte[], int)> decodedBytes, int width, int height)
|
||||
{
|
||||
|
||||
var textures = new List<(Texture2D, int)>();
|
||||
// turn bytes into texture
|
||||
for (var i = 0; i < decodedBytes.Count; i++)
|
||||
{
|
||||
var (rawBytes, timestamp) = decodedBytes[i];
|
||||
|
||||
if (ConvertBytesToTexture(rawBytes, width, height, out var texture))
|
||||
{
|
||||
textures.Add((texture, timestamp));
|
||||
}
|
||||
else
|
||||
{
|
||||
textures.Add(i == 0
|
||||
? (new Texture2D(width, height), timestamp)
|
||||
: (textures[i - 1].Item1, timestamp));
|
||||
}
|
||||
}
|
||||
|
||||
return textures;
|
||||
}
|
||||
|
||||
private static bool ConvertBytesToTexture(byte[] bytes, int width, int height, out Texture2D texture)
|
||||
{
|
||||
if (bytes == null || bytes.Length <= 0)
|
||||
{
|
||||
texture = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
texture = new Texture2D(width, height, TextureFormat.RGBA32, mipChain: false, linear: false);
|
||||
try
|
||||
{
|
||||
texture.LoadRawTextureData(bytes);
|
||||
texture.Apply(false, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log($"[WebPDecoderWrapper] Bytes to texture error: {e.Message}");
|
||||
texture = null;
|
||||
}
|
||||
|
||||
return texture != null;
|
||||
}
|
||||
|
||||
public static unsafe bool CreateDecoder(byte[] bytes, out IntPtr decoder, out WebPAnimInfo info)
|
||||
{
|
||||
decoder = IntPtr.Zero;
|
||||
info = new WebPAnimInfo();
|
||||
if (bytes == null || bytes.Length <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
fixed (byte* p = bytes)
|
||||
{
|
||||
WebPData webpData = new WebPData
|
||||
{
|
||||
bytes = p,
|
||||
size = (UIntPtr) bytes.Length
|
||||
};
|
||||
WebPAnimDecoderOptions options = new WebPAnimDecoderOptions
|
||||
{
|
||||
//flip = 1,
|
||||
use_threads = 1,
|
||||
color_mode = WEBP_CSP_MODE.MODE_RGBA
|
||||
};
|
||||
|
||||
WebPAnimDecoder* decoderP = NativeLibwebpdemux.WebPAnimDecoderNew(&webpData, &options);
|
||||
|
||||
WebPAnimInfo webpAnimInfo = new WebPAnimInfo();
|
||||
var success = NativeLibwebpdemux.WebPAnimDecoderGetInfo(decoderP, &webpAnimInfo);
|
||||
info = webpAnimInfo;
|
||||
decoder = (IntPtr)decoderP;
|
||||
if (success == 0)
|
||||
{
|
||||
Debug.LogError($"[WebPDecoderWrapper] Get file info failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 61a7ccaa33c6d3a4e9aa2a3b955c4562
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace WebP.Experiment.Animation
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// WebP loader for loading assets, should be override to suit your own needs.
|
||||
/// </summary>
|
||||
public class WebPLoader
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The actual function to load file from remote location or project related absolute path
|
||||
/// </summary>
|
||||
public static async Task<byte[]> Load(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
Debug.LogError("[WebP] Loading path can not be empty");
|
||||
return null;
|
||||
}
|
||||
Debug.Log($"[WebP] Try loading WebP file: {url}");
|
||||
|
||||
byte[] bytes = null;
|
||||
|
||||
if (url.Contains("//") || url.Contains("///"))
|
||||
{
|
||||
var www = await LoadAsync(url);
|
||||
bytes = www.downloadHandler.data;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
bytes = File.ReadAllBytes(url);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[WebP] load error: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Example for async UnityWebRequest
|
||||
///
|
||||
/// This function won't work, just example!!!
|
||||
/// You should implement your own loading logic here!
|
||||
/// </summary>
|
||||
private static async Task<UnityWebRequest> LoadAsync(string path)
|
||||
{
|
||||
var www = new UnityWebRequest(path);
|
||||
var op = www.SendWebRequest();
|
||||
while (!op.isDone)
|
||||
{
|
||||
await Task.Delay(1000 / 60);
|
||||
}
|
||||
return www;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 15c9adad6b8522d4390f77e92eb8c775
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,144 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WebP.Experiment.Animation
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// WebP render logic based on parsed WebP animation list.
|
||||
/// </summary>
|
||||
public class WebPRendererWrapper<T>
|
||||
{
|
||||
|
||||
public Action<T> OnRender;
|
||||
|
||||
private List<(T, int)> _animation;
|
||||
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
private bool _playing;
|
||||
private bool _stopped;
|
||||
private int _frame;
|
||||
private int _loop;
|
||||
|
||||
public WebPRendererWrapper(List<(T, int)> animation)
|
||||
{
|
||||
_animation = animation;
|
||||
Reset();
|
||||
Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// total frames
|
||||
/// </summary>
|
||||
public int totalFrame
|
||||
{
|
||||
get => this._animation.Count;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// current frame
|
||||
/// </summary>
|
||||
public int frame
|
||||
{
|
||||
get => _frame;
|
||||
set
|
||||
{
|
||||
if (_frame == value) return;
|
||||
|
||||
_frame = value;
|
||||
Stop();
|
||||
Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// loop times, defaults to -1, which means infinite loops
|
||||
/// </summary>
|
||||
public int loop
|
||||
{
|
||||
get => _loop;
|
||||
set => _loop = value;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (_playing) return;
|
||||
_playing = true;
|
||||
_stopped = false;
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
RenderAnimation();
|
||||
}
|
||||
|
||||
private async void RenderAnimation()
|
||||
{
|
||||
if (_animation == null || _animation.Count == 0) return;
|
||||
|
||||
for (; _animation != null && _frame < _animation.Count; ++_frame)
|
||||
{
|
||||
// if stopped, breaks
|
||||
if (_stopped) break;
|
||||
|
||||
// actual render
|
||||
var (texture, timestamp) = _animation[_frame];
|
||||
OnRender?.Invoke(texture);
|
||||
|
||||
// allows for canceling play at any time, by catch exceptions between loops
|
||||
try
|
||||
{
|
||||
await Task.Delay(timestamp, _cancellationTokenSource.Token);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// if not last frame, go on; otherwise keep looping
|
||||
if (_animation == null || _animation.Count <= 0 || _frame != _animation.Count - 1) continue;
|
||||
|
||||
// dec loop times
|
||||
if (_loop > 0)
|
||||
_loop--;
|
||||
|
||||
// if loop time equals 0, stop
|
||||
if (_loop == 0) break;
|
||||
|
||||
// restart from the first frame
|
||||
_frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_stopped = true;
|
||||
_playing = false;
|
||||
_cancellationTokenSource?.Cancel();
|
||||
_cancellationTokenSource?.Dispose();
|
||||
_cancellationTokenSource = null;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_frame = 0;
|
||||
_loop = -1;
|
||||
_playing = false;
|
||||
_stopped = false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Reset();
|
||||
_animation = null;
|
||||
OnRender = null;
|
||||
// just in case
|
||||
if (_cancellationTokenSource == null) return;
|
||||
_cancellationTokenSource.Cancel();
|
||||
_cancellationTokenSource.Dispose();
|
||||
_cancellationTokenSource = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 19f03e7a9a7fa824d875454a4b4eaac6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,25 @@
|
|||
using unity.libwebp;
|
||||
|
||||
namespace WebP
|
||||
{
|
||||
public class Info
|
||||
{
|
||||
public static string GetDecoderVersion()
|
||||
{
|
||||
uint v = (uint)NativeLibwebp.WebPGetDecoderVersion();
|
||||
uint revision = v % 256;
|
||||
uint minor = (v >> 8) % 256;
|
||||
uint major = (v >> 16) % 256;
|
||||
return $"{major}.{minor}.{revision}";
|
||||
}
|
||||
|
||||
public static string GetEncoderVersion()
|
||||
{
|
||||
uint v = (uint)NativeLibwebp.WebPGetEncoderVersion();
|
||||
uint revision = v % 256;
|
||||
uint minor = (v >> 8) % 256;
|
||||
uint major = (v >> 16) % 256;
|
||||
return $"{major}.{minor}.{revision}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 146264ffc305bc34a9c469e5b044073c
|
||||
timeCreated: 1505182658
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2e43116f1b7d4ea42a20c61a5544f9c8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,7 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public unsafe delegate void BlendRowFunc([NativeTypeName("uint32_t *const")] uint* param0, [NativeTypeName("const uint32_t *const")] uint* param1, int param2);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8f6e76db847742a458d2d4a359ee3079
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct Chunk
|
||||
{
|
||||
public ChunkData data_;
|
||||
|
||||
[NativeTypeName("struct Chunk *")]
|
||||
public Chunk* next_;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 97dfdd15493701f4699cbe55ade09c8d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public partial struct ChunkData
|
||||
{
|
||||
[NativeTypeName("size_t")]
|
||||
public UIntPtr offset_;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public UIntPtr size_;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0515915b50047964dbcfa5b86d1a99af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct ChunkParser
|
||||
{
|
||||
[NativeTypeName("uint8_t [4]")]
|
||||
public fixed byte id[4];
|
||||
|
||||
[NativeTypeName("ParseStatus (*)(WebPDemuxer *const)")]
|
||||
public IntPtr parse;
|
||||
|
||||
[NativeTypeName("int (*)(const WebPDemuxer *const)")]
|
||||
public IntPtr valid;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d74efcb1e265ff041a3a560caa32f3a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct Frame
|
||||
{
|
||||
public int x_offset_;
|
||||
|
||||
public int y_offset_;
|
||||
|
||||
public int width_;
|
||||
|
||||
public int height_;
|
||||
|
||||
public int has_alpha_;
|
||||
|
||||
public int duration_;
|
||||
|
||||
public WebPMuxAnimDispose dispose_method_;
|
||||
|
||||
public WebPMuxAnimBlend blend_method_;
|
||||
|
||||
public int frame_num_;
|
||||
|
||||
public int complete_;
|
||||
|
||||
[NativeTypeName("ChunkData [2]")]
|
||||
public _img_components__e__FixedBuffer img_components_;
|
||||
|
||||
[NativeTypeName("struct Frame *")]
|
||||
public Frame* next_;
|
||||
|
||||
public partial struct _img_components__e__FixedBuffer
|
||||
{
|
||||
public ChunkData e0;
|
||||
public ChunkData e1;
|
||||
|
||||
public unsafe ref ChunkData this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
fixed (ChunkData* pThis = &e0)
|
||||
{
|
||||
return ref pThis[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 47e018d4f6496a3489966d57c5c5fe1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct MemBuffer
|
||||
{
|
||||
[NativeTypeName("size_t")]
|
||||
public UIntPtr start_;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public UIntPtr end_;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public UIntPtr riff_end_;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public UIntPtr buf_size_;
|
||||
|
||||
[NativeTypeName("const uint8_t *")]
|
||||
public byte* buf_;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae7ee9b9ba60c2240aa1b84e92153592
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum ParseStatus
|
||||
{
|
||||
PARSE_OK,
|
||||
PARSE_NEED_MORE_DATA,
|
||||
PARSE_ERROR,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 828ecd97a3177ca459a03d36e161053f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,14 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum VP8StatusCode
|
||||
{
|
||||
VP8_STATUS_OK = 0,
|
||||
VP8_STATUS_OUT_OF_MEMORY,
|
||||
VP8_STATUS_INVALID_PARAM,
|
||||
VP8_STATUS_BITSTREAM_ERROR,
|
||||
VP8_STATUS_UNSUPPORTED_FEATURE,
|
||||
VP8_STATUS_SUSPENDED,
|
||||
VP8_STATUS_USER_ABORT,
|
||||
VP8_STATUS_NOT_ENOUGH_DATA,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1e270d4a80e27dd46a69afaa08e3adcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,20 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum WEBP_CSP_MODE
|
||||
{
|
||||
MODE_RGB = 0,
|
||||
MODE_RGBA = 1,
|
||||
MODE_BGR = 2,
|
||||
MODE_BGRA = 3,
|
||||
MODE_ARGB = 4,
|
||||
MODE_RGBA_4444 = 5,
|
||||
MODE_RGB_565 = 6,
|
||||
MODE_rgbA = 7,
|
||||
MODE_bgrA = 8,
|
||||
MODE_Argb = 9,
|
||||
MODE_rgbA_4444 = 10,
|
||||
MODE_YUV = 11,
|
||||
MODE_YUVA = 12,
|
||||
MODE_LAST = 13,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b3cc6ce330e6fbd47997233fbb206820
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public partial struct WebPAnimDecoder
|
||||
{
|
||||
}
|
||||
|
||||
public unsafe partial struct WebPAnimDecoder
|
||||
{
|
||||
public WebPDemuxer* demux_;
|
||||
|
||||
public WebPDecoderConfig config_;
|
||||
|
||||
[NativeTypeName("BlendRowFunc")]
|
||||
public IntPtr blend_func_;
|
||||
|
||||
public WebPAnimInfo info_;
|
||||
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* curr_frame_;
|
||||
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* prev_frame_disposed_;
|
||||
|
||||
public int prev_frame_timestamp_;
|
||||
|
||||
public WebPIterator prev_iter_;
|
||||
|
||||
public int prev_frame_was_keyframe_;
|
||||
|
||||
public int next_frame_;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fec152b85fac8694e94c53e683d79b2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,12 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPAnimDecoderOptions
|
||||
{
|
||||
public WEBP_CSP_MODE color_mode;
|
||||
|
||||
public int use_threads;
|
||||
|
||||
[NativeTypeName("uint32_t [7]")]
|
||||
public fixed uint padding[7];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 63ec7f869458fc6499be82aa2f275c10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,23 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPAnimInfo
|
||||
{
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint canvas_width;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint canvas_height;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint loop_count;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint bgcolor;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint frame_count;
|
||||
|
||||
[NativeTypeName("uint32_t [4]")]
|
||||
public fixed uint pad[4];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2a267d8466b4da746ba0eea6b6bbc87b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,52 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPAuxStats
|
||||
{
|
||||
public int coded_size;
|
||||
|
||||
[NativeTypeName("float [5]")]
|
||||
public fixed float PSNR[5];
|
||||
|
||||
[NativeTypeName("int [3]")]
|
||||
public fixed int block_count[3];
|
||||
|
||||
[NativeTypeName("int [2]")]
|
||||
public fixed int header_bytes[2];
|
||||
|
||||
[NativeTypeName("int [3][4]")]
|
||||
public fixed int residual_bytes[3 * 4];
|
||||
|
||||
[NativeTypeName("int [4]")]
|
||||
public fixed int segment_size[4];
|
||||
|
||||
[NativeTypeName("int [4]")]
|
||||
public fixed int segment_quant[4];
|
||||
|
||||
[NativeTypeName("int [4]")]
|
||||
public fixed int segment_level[4];
|
||||
|
||||
public int alpha_data_size;
|
||||
|
||||
public int layer_data_size;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint lossless_features;
|
||||
|
||||
public int histogram_bits;
|
||||
|
||||
public int transform_bits;
|
||||
|
||||
public int cache_bits;
|
||||
|
||||
public int palette_size;
|
||||
|
||||
public int lossless_size;
|
||||
|
||||
public int lossless_hdr_size;
|
||||
|
||||
public int lossless_data_size;
|
||||
|
||||
[NativeTypeName("uint32_t [2]")]
|
||||
public fixed uint pad[2];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 070f1cd734bc93146b35f02ffcaa84ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPBitstreamFeatures
|
||||
{
|
||||
public int width;
|
||||
|
||||
public int height;
|
||||
|
||||
public int has_alpha;
|
||||
|
||||
public int has_animation;
|
||||
|
||||
public int format;
|
||||
|
||||
[NativeTypeName("uint32_t [5]")]
|
||||
public fixed uint pad[5];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3b46adc128a497349a9a09c81c6ad742
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPChunkIterator
|
||||
{
|
||||
public int chunk_num;
|
||||
|
||||
public int num_chunks;
|
||||
|
||||
public WebPData chunk;
|
||||
|
||||
[NativeTypeName("uint32_t [6]")]
|
||||
public fixed uint pad[6];
|
||||
|
||||
public void* private_;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ccb2c7256646e124daeeb0bdae4524da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,63 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public partial struct WebPConfig
|
||||
{
|
||||
public int lossless;
|
||||
|
||||
public float quality;
|
||||
|
||||
public int method;
|
||||
|
||||
public WebPImageHint image_hint;
|
||||
|
||||
public int target_size;
|
||||
|
||||
public float target_PSNR;
|
||||
|
||||
public int segments;
|
||||
|
||||
public int sns_strength;
|
||||
|
||||
public int filter_strength;
|
||||
|
||||
public int filter_sharpness;
|
||||
|
||||
public int filter_type;
|
||||
|
||||
public int autofilter;
|
||||
|
||||
public int alpha_compression;
|
||||
|
||||
public int alpha_filtering;
|
||||
|
||||
public int alpha_quality;
|
||||
|
||||
public int pass;
|
||||
|
||||
public int show_compressed;
|
||||
|
||||
public int preprocessing;
|
||||
|
||||
public int partitions;
|
||||
|
||||
public int partition_limit;
|
||||
|
||||
public int emulate_jpeg_size;
|
||||
|
||||
public int thread_level;
|
||||
|
||||
public int low_memory;
|
||||
|
||||
public int near_lossless;
|
||||
|
||||
public int exact;
|
||||
|
||||
public int use_delta_palette;
|
||||
|
||||
public int use_sharp_yuv;
|
||||
|
||||
public int qmin;
|
||||
|
||||
public int qmax;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 501a2e1c0fd24fc46b9e32e6eaf222f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPData
|
||||
{
|
||||
[NativeTypeName("const uint8_t *")]
|
||||
public byte* bytes;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public UIntPtr size;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2f99f0679e9572d479d5bf54e7e8cc30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPDecBuffer
|
||||
{
|
||||
public WEBP_CSP_MODE colorspace;
|
||||
|
||||
public int width;
|
||||
|
||||
public int height;
|
||||
|
||||
public int is_external_memory;
|
||||
|
||||
[NativeTypeName("union (anonymous union at libwebp/src/webp/decode.h:207:3)")]
|
||||
public _u_e__Union u;
|
||||
|
||||
[NativeTypeName("uint32_t [4]")]
|
||||
public fixed uint pad[4];
|
||||
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* private_memory;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public partial struct _u_e__Union
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public WebPRGBABuffer RGBA;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public WebPYUVABuffer YUVA;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8d1a6d84d44884549aa301e0c7e29adb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public partial struct WebPDecoderConfig
|
||||
{
|
||||
public WebPBitstreamFeatures input;
|
||||
|
||||
public WebPDecBuffer output;
|
||||
|
||||
public WebPDecoderOptions options;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cb5d567d3e17c804cade62882ad230f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,36 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPDecoderOptions
|
||||
{
|
||||
public int bypass_filtering;
|
||||
|
||||
public int no_fancy_upsampling;
|
||||
|
||||
public int use_cropping;
|
||||
|
||||
public int crop_left;
|
||||
|
||||
public int crop_top;
|
||||
|
||||
public int crop_width;
|
||||
|
||||
public int crop_height;
|
||||
|
||||
public int use_scaling;
|
||||
|
||||
public int scaled_width;
|
||||
|
||||
public int scaled_height;
|
||||
|
||||
public int use_threads;
|
||||
|
||||
public int dithering_strength;
|
||||
|
||||
public int flip;
|
||||
|
||||
public int alpha_dithering_strength;
|
||||
|
||||
[NativeTypeName("uint32_t [5]")]
|
||||
public fixed uint pad[5];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 20002e256eef2a64ab91c4ed89ee3636
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum WebPDemuxState
|
||||
{
|
||||
WEBP_DEMUX_PARSE_ERROR = -1,
|
||||
WEBP_DEMUX_PARSING_HEADER = 0,
|
||||
WEBP_DEMUX_PARSED_HEADER = 1,
|
||||
WEBP_DEMUX_DONE = 2,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 70e9a801219b79448bb3725425e42815
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public partial struct WebPDemuxer
|
||||
{
|
||||
}
|
||||
|
||||
public unsafe partial struct WebPDemuxer
|
||||
{
|
||||
public MemBuffer mem_;
|
||||
|
||||
public WebPDemuxState state_;
|
||||
|
||||
public int is_ext_format_;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint feature_flags_;
|
||||
|
||||
public int canvas_width_;
|
||||
|
||||
public int canvas_height_;
|
||||
|
||||
public int loop_count_;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint bgcolor_;
|
||||
|
||||
public int num_frames_;
|
||||
|
||||
public Frame* frames_;
|
||||
|
||||
public Frame** frames_tail_;
|
||||
|
||||
public Chunk* chunks_;
|
||||
|
||||
public Chunk** chunks_tail_;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0a30e26c2d8c95a429cc83e37f9a3f9c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum WebPEncCSP
|
||||
{
|
||||
WEBP_YUV420 = 0,
|
||||
WEBP_YUV420A = 4,
|
||||
WEBP_CSP_UV_MASK = 3,
|
||||
WEBP_CSP_ALPHA_BIT = 4,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 993663533cd3e0143a4a66d5f6f2758e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum WebPEncodingError
|
||||
{
|
||||
VP8_ENC_OK = 0,
|
||||
VP8_ENC_ERROR_OUT_OF_MEMORY,
|
||||
VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY,
|
||||
VP8_ENC_ERROR_NULL_PARAMETER,
|
||||
VP8_ENC_ERROR_INVALID_CONFIGURATION,
|
||||
VP8_ENC_ERROR_BAD_DIMENSION,
|
||||
VP8_ENC_ERROR_PARTITION0_OVERFLOW,
|
||||
VP8_ENC_ERROR_PARTITION_OVERFLOW,
|
||||
VP8_ENC_ERROR_BAD_WRITE,
|
||||
VP8_ENC_ERROR_FILE_TOO_BIG,
|
||||
VP8_ENC_ERROR_USER_ABORT,
|
||||
VP8_ENC_ERROR_LAST,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5b6a5a70cb1c52e4e8f7f641bff506ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,12 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum WebPFeatureFlags
|
||||
{
|
||||
ANIMATION_FLAG = 0x00000002,
|
||||
XMP_FLAG = 0x00000004,
|
||||
EXIF_FLAG = 0x00000008,
|
||||
ALPHA_FLAG = 0x00000010,
|
||||
ICCP_FLAG = 0x00000020,
|
||||
ALL_VALID_FLAGS = 0x0000003e,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7d32dfc72c29c8f42b78bf1cbfd867f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,12 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum WebPFormatFeature
|
||||
{
|
||||
WEBP_FF_FORMAT_FLAGS,
|
||||
WEBP_FF_CANVAS_WIDTH,
|
||||
WEBP_FF_CANVAS_HEIGHT,
|
||||
WEBP_FF_LOOP_COUNT,
|
||||
WEBP_FF_BACKGROUND_COLOR,
|
||||
WEBP_FF_FRAME_COUNT,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7111c7810d2e47e4596b94a55c3e3890
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,6 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public partial struct WebPIDecoder
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cd7cebb6ccd9bd347958718e9369571a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,11 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum WebPImageHint
|
||||
{
|
||||
WEBP_HINT_DEFAULT = 0,
|
||||
WEBP_HINT_PICTURE,
|
||||
WEBP_HINT_PHOTO,
|
||||
WEBP_HINT_GRAPH,
|
||||
WEBP_HINT_LAST,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8570865947ea012409c935e75d7b4b4f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPIterator
|
||||
{
|
||||
public int frame_num;
|
||||
|
||||
public int num_frames;
|
||||
|
||||
public int x_offset;
|
||||
|
||||
public int y_offset;
|
||||
|
||||
public int width;
|
||||
|
||||
public int height;
|
||||
|
||||
public int duration;
|
||||
|
||||
public WebPMuxAnimDispose dispose_method;
|
||||
|
||||
public int complete;
|
||||
|
||||
public WebPData fragment;
|
||||
|
||||
public int has_alpha;
|
||||
|
||||
public WebPMuxAnimBlend blend_method;
|
||||
|
||||
[NativeTypeName("uint32_t [2]")]
|
||||
public fixed uint pad[2];
|
||||
|
||||
public void* private_;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2f96ddfb8eb4ad046bf2361e4943617f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPMemoryWriter
|
||||
{
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* mem;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public UIntPtr size;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public UIntPtr max_size;
|
||||
|
||||
[NativeTypeName("uint32_t [1]")]
|
||||
public fixed uint pad[1];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 48b317af6bd5deb4ea85acad3663468b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum WebPMuxAnimBlend
|
||||
{
|
||||
WEBP_MUX_BLEND,
|
||||
WEBP_MUX_NO_BLEND,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 01537c56253a28b4aa6e6a04455009ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum WebPMuxAnimDispose
|
||||
{
|
||||
WEBP_MUX_DISPOSE_NONE,
|
||||
WEBP_MUX_DISPOSE_BACKGROUND,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 730c8be2a4da71a478c9031474c602d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,105 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPPicture
|
||||
{
|
||||
public int use_argb;
|
||||
|
||||
public WebPEncCSP colorspace;
|
||||
|
||||
public int width;
|
||||
|
||||
public int height;
|
||||
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* y;
|
||||
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* u;
|
||||
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* v;
|
||||
|
||||
public int y_stride;
|
||||
|
||||
public int uv_stride;
|
||||
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* a;
|
||||
|
||||
public int a_stride;
|
||||
|
||||
[NativeTypeName("uint32_t [2]")]
|
||||
public fixed uint pad1[2];
|
||||
|
||||
[NativeTypeName("uint32_t *")]
|
||||
public uint* argb;
|
||||
|
||||
public int argb_stride;
|
||||
|
||||
[NativeTypeName("uint32_t [3]")]
|
||||
public fixed uint pad2[3];
|
||||
|
||||
[NativeTypeName("WebPWriterFunction")]
|
||||
public IntPtr writer;
|
||||
|
||||
public void* custom_ptr;
|
||||
|
||||
public int extra_info_type;
|
||||
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* extra_info;
|
||||
|
||||
public WebPAuxStats* stats;
|
||||
|
||||
public WebPEncodingError error_code;
|
||||
|
||||
[NativeTypeName("WebPProgressHook")]
|
||||
public IntPtr progress_hook;
|
||||
|
||||
public void* user_data;
|
||||
|
||||
[NativeTypeName("uint32_t [3]")]
|
||||
public fixed uint pad3[3];
|
||||
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* pad4;
|
||||
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* pad5;
|
||||
|
||||
[NativeTypeName("uint32_t [8]")]
|
||||
public fixed uint pad6[8];
|
||||
|
||||
public void* memory_;
|
||||
|
||||
public void* memory_argb_;
|
||||
|
||||
[NativeTypeName("void *[2]")]
|
||||
public _pad7_e__FixedBuffer pad7;
|
||||
|
||||
public unsafe partial struct _pad7_e__FixedBuffer
|
||||
{
|
||||
public void* e0;
|
||||
public void* e1;
|
||||
|
||||
// NOTE(pyoung): Comment out to avoid compile error
|
||||
// - ref: https://github.com/netpyoung/unity.webp/issues/44#issuecomment-1134680004
|
||||
//public ref void* this[int index]
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// fixed (void** pThis = &e0)
|
||||
// {
|
||||
// return ref pThis[index];
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
public partial struct WebPPicture
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9f12ee7845309f24e8f3c42681889780
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,12 @@
|
|||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public enum WebPPreset
|
||||
{
|
||||
WEBP_PRESET_DEFAULT = 0,
|
||||
WEBP_PRESET_PICTURE,
|
||||
WEBP_PRESET_PHOTO,
|
||||
WEBP_PRESET_DRAWING,
|
||||
WEBP_PRESET_ICON,
|
||||
WEBP_PRESET_TEXT,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 04b56f47bd9544d48a0daf63deb7f758
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,7 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public unsafe delegate int WebPProgressHook(int percent, [NativeTypeName("const WebPPicture *")] WebPPicture* picture);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 356d7ce072be1604182ec06fb625ac65
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace unity.libwebp.Interop
|
||||
{
|
||||
public unsafe partial struct WebPRGBABuffer
|
||||
{
|
||||
[NativeTypeName("uint8_t *")]
|
||||
public byte* rgba;
|
||||
|
||||
public int stride;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public UIntPtr size;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ef7358733d99ce645b5e619a10207ded
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user