From 7f905d16be62b036aafe63b11ae25f7c48eb6041 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Fri, 7 Oct 2016 03:32:00 +0700 Subject: [PATCH] refactor public symbols from dll --- .../Sources/Editors/SwfAssetEditor.cs | 3 +- .../Sources/Editors/SwfClipAssetEditor.cs | 2 +- .../Sources/Editors/SwfClipAssetPreview.cs | 2 +- .../Editors/SwfClipControllerEditor.cs | 2 +- .../FTEditor/Sources/Editors/SwfClipEditor.cs | 2 +- .../Sources/Editors/SwfManagerEditor.cs | 9 +- .../Postprocessors/SwfAssetPostprocessor.cs | 11 ++- .../Postprocessors/SwfPostprocessor.cs | 7 +- FTSources/FTEditor/Sources/SwfAssetData.cs | 22 ++--- FTSources/FTEditor/Sources/SwfEditorUtils.cs | 57 ++++++++++++- .../FTEditor/Sources/SwfMaterialCache.cs | 2 +- .../FTEditor/Sources/SwfPropertyDrawers.cs | 12 +-- .../Sources/Internal/SwfAssocList.cs | 6 +- .../FTRuntime/Sources/Internal/SwfList.cs | 13 ++- .../FTRuntime/Sources/Internal/SwfUtils.cs | 83 +------------------ FTSources/FTRuntime/Sources/SwfManager.cs | 4 +- FTSources/FTSources.userprefs | 6 +- 17 files changed, 117 insertions(+), 126 deletions(-) diff --git a/FTSources/FTEditor/Sources/Editors/SwfAssetEditor.cs b/FTSources/FTEditor/Sources/Editors/SwfAssetEditor.cs index fca29db..d52280d 100644 --- a/FTSources/FTEditor/Sources/Editors/SwfAssetEditor.cs +++ b/FTSources/FTEditor/Sources/Editors/SwfAssetEditor.cs @@ -6,11 +6,10 @@ using System.Linq; using System.Collections.Generic; using FTRuntime; -using FTRuntime.Internal; namespace FTEditor.Editors { [CustomEditor(typeof(SwfAsset)), CanEditMultipleObjects] - public class SwfAssetEditor : Editor { + class SwfAssetEditor : Editor { List _assets = new List(); // diff --git a/FTSources/FTEditor/Sources/Editors/SwfClipAssetEditor.cs b/FTSources/FTEditor/Sources/Editors/SwfClipAssetEditor.cs index d72952d..78bac0f 100644 --- a/FTSources/FTEditor/Sources/Editors/SwfClipAssetEditor.cs +++ b/FTSources/FTEditor/Sources/Editors/SwfClipAssetEditor.cs @@ -9,7 +9,7 @@ using FTRuntime; namespace FTEditor.Editors { [CustomEditor(typeof(SwfClipAsset)), CanEditMultipleObjects] - public class SwfClipAssetEditor : Editor { + class SwfClipAssetEditor : Editor { List _clips = new List(); static string GetClipPath(SwfClipAsset clip) { diff --git a/FTSources/FTEditor/Sources/Editors/SwfClipAssetPreview.cs b/FTSources/FTEditor/Sources/Editors/SwfClipAssetPreview.cs index b82f8ba..a720851 100644 --- a/FTSources/FTEditor/Sources/Editors/SwfClipAssetPreview.cs +++ b/FTSources/FTEditor/Sources/Editors/SwfClipAssetPreview.cs @@ -7,7 +7,7 @@ using FTRuntime; namespace FTEditor.Editors { [CustomPreview(typeof(SwfClipAsset))] - public class SwfClipAssetPreview : ObjectPreview { + class SwfClipAssetPreview : ObjectPreview { int _sequence = 0; static MaterialPropertyBlock _matPropBlock = null; static PreviewRenderUtility _previewUtils = null; diff --git a/FTSources/FTEditor/Sources/Editors/SwfClipControllerEditor.cs b/FTSources/FTEditor/Sources/Editors/SwfClipControllerEditor.cs index ed63394..21d2300 100644 --- a/FTSources/FTEditor/Sources/Editors/SwfClipControllerEditor.cs +++ b/FTSources/FTEditor/Sources/Editors/SwfClipControllerEditor.cs @@ -8,7 +8,7 @@ using FTRuntime; namespace FTEditor.Editors { [CustomEditor(typeof(SwfClipController)), CanEditMultipleObjects] - public class SwfClipControllerEditor : Editor { + class SwfClipControllerEditor : Editor { List _controllers = new List(); void AllControllersForeach(System.Action act) { diff --git a/FTSources/FTEditor/Sources/Editors/SwfClipEditor.cs b/FTSources/FTEditor/Sources/Editors/SwfClipEditor.cs index 6d077d1..f96f618 100644 --- a/FTSources/FTEditor/Sources/Editors/SwfClipEditor.cs +++ b/FTSources/FTEditor/Sources/Editors/SwfClipEditor.cs @@ -8,7 +8,7 @@ using FTRuntime; namespace FTEditor.Editors { [CustomEditor(typeof(SwfClip)), CanEditMultipleObjects] - public class SwfClipEditor : Editor { + class SwfClipEditor : Editor { List _clips = new List(); Dictionary _previews = new Dictionary(); diff --git a/FTSources/FTEditor/Sources/Editors/SwfManagerEditor.cs b/FTSources/FTEditor/Sources/Editors/SwfManagerEditor.cs index 7f1b22b..184d2c8 100644 --- a/FTSources/FTEditor/Sources/Editors/SwfManagerEditor.cs +++ b/FTSources/FTEditor/Sources/Editors/SwfManagerEditor.cs @@ -4,14 +4,13 @@ using UnityEditor; using System.Collections.Generic; using FTRuntime; -using FTRuntime.Internal; namespace FTEditor.Editors { [CustomEditor(typeof(SwfManager))] - public class SwfManagerEditor : Editor { - SwfManager _manager = null; - SwfList _controllers = new SwfList(); - bool _groupsFoldout = true; + class SwfManagerEditor : Editor { + SwfManager _manager = null; + List _controllers = new List(); + bool _groupsFoldout = true; void DrawCounts() { SwfEditorUtils.DoWithEnabledGUI(false, () => { diff --git a/FTSources/FTEditor/Sources/Postprocessors/SwfAssetPostprocessor.cs b/FTSources/FTEditor/Sources/Postprocessors/SwfAssetPostprocessor.cs index 4440b3f..85873fe 100644 --- a/FTSources/FTEditor/Sources/Postprocessors/SwfAssetPostprocessor.cs +++ b/FTSources/FTEditor/Sources/Postprocessors/SwfAssetPostprocessor.cs @@ -7,10 +7,9 @@ using System.Linq; using System.Collections.Generic; using FTRuntime; -using FTRuntime.Internal; namespace FTEditor.Postprocessors { - public class SwfAssetPostprocessor : AssetPostprocessor { + class SwfAssetPostprocessor : AssetPostprocessor { static void OnPostprocessAllAssets( string[] imported_assets, string[] deleted_assets, @@ -359,18 +358,18 @@ namespace FTEditor.Postprocessors { baked_vertices.Add(matrix.MultiplyPoint3x4(v3)); var source_rect = bitmap.SourceRect; - baked_uvs.Add(SwfUtils.PackUV(source_rect.xMin, source_rect.yMin)); - baked_uvs.Add(SwfUtils.PackUV(source_rect.xMax, source_rect.yMax)); + baked_uvs.Add(SwfEditorUtils.PackUV(source_rect.xMin, source_rect.yMin)); + baked_uvs.Add(SwfEditorUtils.PackUV(source_rect.xMax, source_rect.yMax)); uint mul_pack0, mul_pack1; - SwfUtils.PackFColorToUInts( + SwfEditorUtils.PackFColorToUInts( inst.ColorTrans.mulColor.ToUVector4(), out mul_pack0, out mul_pack1); baked_mulcolors.Add(mul_pack0); baked_mulcolors.Add(mul_pack1); uint add_pack0, add_pack1; - SwfUtils.PackFColorToUInts( + SwfEditorUtils.PackFColorToUInts( inst.ColorTrans.addColor.ToUVector4(), out add_pack0, out add_pack1); baked_addcolors.Add(add_pack0); diff --git a/FTSources/FTEditor/Sources/Postprocessors/SwfPostprocessor.cs b/FTSources/FTEditor/Sources/Postprocessors/SwfPostprocessor.cs index a2d6097..dfe85f3 100644 --- a/FTSources/FTEditor/Sources/Postprocessors/SwfPostprocessor.cs +++ b/FTSources/FTEditor/Sources/Postprocessors/SwfPostprocessor.cs @@ -6,15 +6,14 @@ using System.IO; using System.Linq; using System.Collections.Generic; +using FTRuntime; + using FTSwfTools; using FTSwfTools.SwfTags; using FTSwfTools.SwfTypes; -using FTRuntime; -using FTRuntime.Internal; - namespace FTEditor.Postprocessors { - public class SwfPostprocessor : AssetPostprocessor { + class SwfPostprocessor : AssetPostprocessor { static void OnPostprocessAllAssets( string[] imported_assets, string[] deleted_assets, diff --git a/FTSources/FTEditor/Sources/SwfAssetData.cs b/FTSources/FTEditor/Sources/SwfAssetData.cs index 140b9a0..6181652 100644 --- a/FTSources/FTEditor/Sources/SwfAssetData.cs +++ b/FTSources/FTEditor/Sources/SwfAssetData.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; namespace FTEditor { [System.Serializable] - public struct SwfVec2Data { + struct SwfVec2Data { public float x; public float y; @@ -27,7 +27,7 @@ namespace FTEditor { } [System.Serializable] - public struct SwfVec4Data { + struct SwfVec4Data { public float x; public float y; public float z; @@ -54,7 +54,7 @@ namespace FTEditor { } [System.Serializable] - public struct SwfRectData { + struct SwfRectData { public float xMin; public float xMax; public float yMin; @@ -80,7 +80,7 @@ namespace FTEditor { } [System.Serializable] - public struct SwfMatrixData { + struct SwfMatrixData { public SwfVec2Data sc; public SwfVec2Data sk; public SwfVec2Data tr; @@ -114,7 +114,7 @@ namespace FTEditor { } [System.Serializable] - public struct SwfBlendModeData { + struct SwfBlendModeData { public enum Types : byte { Normal, Layer, @@ -150,7 +150,7 @@ namespace FTEditor { } [System.Serializable] - public struct SwfColorTransData { + struct SwfColorTransData { public SwfVec4Data mulColor; public SwfVec4Data addColor; @@ -188,7 +188,7 @@ namespace FTEditor { } [System.Serializable] - public class SwfInstanceData { + class SwfInstanceData { public enum Types { Mask, Group, @@ -204,19 +204,19 @@ namespace FTEditor { } [System.Serializable] - public class SwfFrameData { + class SwfFrameData { public string Name = string.Empty; public List Instances = new List(); } [System.Serializable] - public class SwfSymbolData { + class SwfSymbolData { public string Name = string.Empty; public List Frames = new List(); } [System.Serializable] - public class SwfBitmapData { + class SwfBitmapData { public ushort Id = 0; public byte[] ARGB32 = new byte[0]; public ushort Redirect = 0; @@ -226,7 +226,7 @@ namespace FTEditor { } [System.Serializable] - public class SwfAssetData { + class SwfAssetData { public float FrameRate = 0.0f; public List Symbols = new List(); public List Bitmaps = new List(); diff --git a/FTSources/FTEditor/Sources/SwfEditorUtils.cs b/FTSources/FTEditor/Sources/SwfEditorUtils.cs index 5a537fc..b4a3d54 100644 --- a/FTSources/FTEditor/Sources/SwfEditorUtils.cs +++ b/FTSources/FTEditor/Sources/SwfEditorUtils.cs @@ -9,10 +9,63 @@ using System.Runtime.Serialization.Formatters.Binary; using Ionic.Zlib; using FTRuntime; -using FTRuntime.Internal; namespace FTEditor { - public static class SwfEditorUtils { + static class SwfEditorUtils { + + // --------------------------------------------------------------------- + // + // Packing + // + // --------------------------------------------------------------------- + + const ushort UShortMax = ushort.MaxValue; + const float FColorPrecision = 1.0f / 512.0f; + + public static uint PackUV(float u, float v) { + var uu = (uint)(Mathf.Clamp01(u) * UShortMax); + var vv = (uint)(Mathf.Clamp01(v) * UShortMax); + return (uu << 16) + vv; + } + + public static ushort PackFloatColorToUShort(float v) { + return (ushort)Mathf.Clamp( + v * (1.0f / FColorPrecision), + short.MinValue, + short.MaxValue); + } + + public static uint PackUShortsToUInt(ushort x, ushort y) { + var xx = (uint)x; + var yy = (uint)y; + return (xx << 16) + yy; + } + + public static void PackFColorToUInts( + Color v, + out uint pack0, out uint pack1) + { + PackFColorToUInts(v.r, v.g, v.b, v.a, out pack0, out pack1); + } + + public static void PackFColorToUInts( + Vector4 v, + out uint pack0, out uint pack1) + { + PackFColorToUInts(v.x, v.y, v.z, v.w, out pack0, out pack1); + } + + public static void PackFColorToUInts( + float v0, float v1, float v2, float v3, + out uint pack0, out uint pack1) + { + pack0 = PackUShortsToUInt( + PackFloatColorToUShort(v0), + PackFloatColorToUShort(v1)); + pack1 = PackUShortsToUInt( + PackFloatColorToUShort(v2), + PackFloatColorToUShort(v3)); + } // --------------------------------------------------------------------- // diff --git a/FTSources/FTEditor/Sources/SwfMaterialCache.cs b/FTSources/FTEditor/Sources/SwfMaterialCache.cs index b4731d6..51e7509 100644 --- a/FTSources/FTEditor/Sources/SwfMaterialCache.cs +++ b/FTSources/FTEditor/Sources/SwfMaterialCache.cs @@ -8,7 +8,7 @@ using System.Collections.Generic; using FTRuntime; namespace FTEditor { - public class SwfMaterialCache { + class SwfMaterialCache { const string SwfSimpleShaderName = "SwfSimpleShader"; const string SwfMaskedShaderName = "SwfMaskedShader"; diff --git a/FTSources/FTEditor/Sources/SwfPropertyDrawers.cs b/FTSources/FTEditor/Sources/SwfPropertyDrawers.cs index 6936c3f..0086394 100644 --- a/FTSources/FTEditor/Sources/SwfPropertyDrawers.cs +++ b/FTSources/FTEditor/Sources/SwfPropertyDrawers.cs @@ -13,7 +13,7 @@ namespace FTEditor { // [CustomPropertyDrawer(typeof(SwfIntRangeAttribute))] - public class SwfIntRangeDrawer : PropertyDrawer { + class SwfIntRangeDrawer : PropertyDrawer { static void ValidateProperty(SerializedProperty property, int min, int max) { if ( !property.hasMultipleDifferentValues ) { if ( property.propertyType == SerializedPropertyType.Integer ) { @@ -39,7 +39,7 @@ namespace FTEditor { // [CustomPropertyDrawer(typeof(SwfFloatRangeAttribute))] - public class SwfFloatRangeDrawer : PropertyDrawer { + class SwfFloatRangeDrawer : PropertyDrawer { static void ValidateProperty(SerializedProperty property, float min, float max) { if ( !property.hasMultipleDifferentValues ) { if ( property.propertyType == SerializedPropertyType.Float ) { @@ -65,7 +65,7 @@ namespace FTEditor { // [CustomPropertyDrawer(typeof(SwfSortingLayerAttribute))] - public class SwfSortingLayerDrawer : PropertyDrawer { + class SwfSortingLayerDrawer : PropertyDrawer { const string DefaultLayerName = "Default"; @@ -155,7 +155,7 @@ namespace FTEditor { // [CustomPropertyDrawer(typeof(SwfPowerOfTwoIfAttribute))] - public class SwfPowerOfTwoIfDrawer : PropertyDrawer { + class SwfPowerOfTwoIfDrawer : PropertyDrawer { static SerializedProperty FindNextBoolProperty(SerializedProperty property, string next_prop) { var prop = property.Copy(); @@ -227,7 +227,7 @@ namespace FTEditor { // [CustomPropertyDrawer(typeof(SwfReadOnlyAttribute))] - public class SwfReadOnlyDrawer : PropertyDrawer { + class SwfReadOnlyDrawer : PropertyDrawer { public override void OnGUI( Rect position, SerializedProperty property, GUIContent label) { @@ -242,7 +242,7 @@ namespace FTEditor { // [CustomPropertyDrawer(typeof(SwfDisplayNameAttribute))] - public class SwfDisplayNameDrawer : PropertyDrawer { + class SwfDisplayNameDrawer : PropertyDrawer { public override void OnGUI( Rect position, SerializedProperty property, GUIContent label) { diff --git a/FTSources/FTRuntime/Sources/Internal/SwfAssocList.cs b/FTSources/FTRuntime/Sources/Internal/SwfAssocList.cs index a4cb7c2..ce77ff8 100644 --- a/FTSources/FTRuntime/Sources/Internal/SwfAssocList.cs +++ b/FTSources/FTRuntime/Sources/Internal/SwfAssocList.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; namespace FTRuntime.Internal { - public class SwfAssocList { + class SwfAssocList { SwfList _list; Dictionary _dict; IEqualityComparer _comp; @@ -63,6 +63,10 @@ namespace FTRuntime.Internal { _dict.Clear(); } + public void AssignTo(List list) { + _list.AssignTo(list); + } + public void AssignTo(SwfList list) { _list.AssignTo(list); } diff --git a/FTSources/FTRuntime/Sources/Internal/SwfList.cs b/FTSources/FTRuntime/Sources/Internal/SwfList.cs index 4023282..8448356 100644 --- a/FTSources/FTRuntime/Sources/Internal/SwfList.cs +++ b/FTSources/FTRuntime/Sources/Internal/SwfList.cs @@ -1,7 +1,8 @@ using System; +using System.Collections.Generic; namespace FTRuntime.Internal { - public class SwfList { + class SwfList { T[] _data; int _size; @@ -107,6 +108,16 @@ namespace FTRuntime.Internal { } } + public void AssignTo(List list) { + list.Clear(); + if ( list.Capacity < Count ) { + list.Capacity = Count * 2; + } + for ( int i = 0, e = Count; i < e; ++i ) { + list.Add(this[i]); + } + } + public void AssignTo(SwfList list) { if ( list._data.Length < _size ) { var new_data = new T[_size * 2]; diff --git a/FTSources/FTRuntime/Sources/Internal/SwfUtils.cs b/FTSources/FTRuntime/Sources/Internal/SwfUtils.cs index 35a6aea..4b1573c 100644 --- a/FTSources/FTRuntime/Sources/Internal/SwfUtils.cs +++ b/FTSources/FTRuntime/Sources/Internal/SwfUtils.cs @@ -2,92 +2,17 @@ using System.Collections.Generic; namespace FTRuntime.Internal { - public static class SwfUtils { + static class SwfUtils { - public const float UVPrecision = 1.0f / 16384.0f; - public const float FColorPrecision = 1.0f / 512.0f; - - const ushort UShortMax = ushort.MaxValue; - const float InvFColorPrecision = 1.0f / FColorPrecision; - - // - // - // - - public static uint PackUShortsToUInt(ushort x, ushort y) { - var xx = (uint)x; - var yy = (uint)y; - return (xx << 16) + yy; - } - - public static void UnpackUShortsFromUInt( - uint pack, - out ushort x, out ushort y) - { - x = (ushort)((pack >> 16) & 0xFFFF); - y = (ushort)((pack ) & 0xFFFF); - } - - // - // - // - - public static uint PackUV(float u, float v) { - var uu = (uint)(Mathf.Clamp01(u) * UShortMax); - var vv = (uint)(Mathf.Clamp01(v) * UShortMax); - return (uu << 16) + vv; - } + const ushort UShortMax = ushort.MaxValue; + const float FColorPrecision = 1.0f / 512.0f; + const float InvFColorPrecision = 1.0f / FColorPrecision; public static void UnpackUV(uint pack, out float u, out float v) { u = (float)((pack >> 16) & 0xFFFF) / UShortMax; v = (float)((pack ) & 0xFFFF) / UShortMax; } - // - // - // - - public static ushort PackFloatColorToUShort(float v) { - return (ushort)Mathf.Clamp( - v * (1.0f / FColorPrecision), - short.MinValue, - short.MaxValue); - } - - public static float UnpackFloatColorFromUShort(ushort pack) { - return (short)pack / InvFColorPrecision; - } - - // - // - // - - public static void PackFColorToUInts( - Color v, - out uint pack0, out uint pack1) - { - PackFColorToUInts(v.r, v.g, v.b, v.a, out pack0, out pack1); - } - - public static void PackFColorToUInts( - Vector4 v, - out uint pack0, out uint pack1) - { - PackFColorToUInts(v.x, v.y, v.z, v.w, out pack0, out pack1); - } - - public static void PackFColorToUInts( - float v0, float v1, float v2, float v3, - out uint pack0, out uint pack1) - { - pack0 = PackUShortsToUInt( - PackFloatColorToUShort(v0), - PackFloatColorToUShort(v1)); - pack1 = PackUShortsToUInt( - PackFloatColorToUShort(v2), - PackFloatColorToUShort(v3)); - } - public static void UnpackFColorFromUInts( uint pack0, uint pack1, out float c0, out float c1, out float c2, out float c3) diff --git a/FTSources/FTRuntime/Sources/SwfManager.cs b/FTSources/FTRuntime/Sources/SwfManager.cs index 49da09f..80b89f7 100644 --- a/FTSources/FTRuntime/Sources/SwfManager.cs +++ b/FTSources/FTRuntime/Sources/SwfManager.cs @@ -122,7 +122,7 @@ namespace FTRuntime { _clips.Remove(clip); } - public void GetAllClips(SwfList clips) { + public void GetAllClips(List clips) { _clips.AssignTo(clips); } @@ -134,7 +134,7 @@ namespace FTRuntime { _controllers.Remove(controller); } - public void GetAllControllers(SwfList controllers) { + public void GetAllControllers(List controllers) { _controllers.AssignTo(controllers); } diff --git a/FTSources/FTSources.userprefs b/FTSources/FTSources.userprefs index 3fb06bd..6012efa 100644 --- a/FTSources/FTSources.userprefs +++ b/FTSources/FTSources.userprefs @@ -1,7 +1,9 @@  - + - + + +