Пример #1
0
        internal void ClearPropertyMap()
        {
            // when clearing the property map we want to retain the styles that we have inherited from elsewhere
            // to do this, we need to read in the inherited values, store them, clear the map, then write the values back
            LightList <StyleProperty> inherited = LightList <StyleProperty> .Get();

            inherited.EnsureCapacity(StyleUtil.InheritedProperties.Count);
            StyleProperty[] inheritedArray = inherited.Array;
            for (int i = 0; i < StyleUtil.InheritedProperties.Count; i++)
            {
                int key = BitUtil.SetHighLowBits(1, (int)StyleUtil.InheritedProperties[i]);
                if (propertyMap.TryGetValue(key, out StyleProperty inheritedValue))
                {
                    inherited.AddUnchecked(inheritedValue);
                }
            }

            propertyMap.Clear();
            // re-apply values
            for (int i = 0; i < inherited.Count; i++)
            {
                int key = BitUtil.SetHighLowBits(1, (int)inheritedArray[i].propertyId);
                propertyMap.Add(key, inheritedArray[i]);
            }

            LightList <StyleProperty> .Release(ref inherited);
        }
Пример #2
0
 public void EnsureCapacity(int vertexCount, int triangleCount)
 {
     positionList.EnsureCapacity(vertexCount);
     normalList.EnsureCapacity(vertexCount);
     colorList.EnsureCapacity(vertexCount);
     texCoord0List.EnsureCapacity(vertexCount);
     texCoord1List.EnsureCapacity(vertexCount);
     texCoord2List.EnsureCapacity(vertexCount);
     triangleList.EnsureCapacity(triangleCount);
 }
Пример #3
0
        private void ResetSharedStyles(LightList <UIStyleGroupContainer> updatedStyles)
        {
            int count = updatedStyles.Count;

            UIStyleGroupContainer[] updatedStyleArray = updatedStyles.array;

            for (int i = 0; i < styleGroupContainers.size; i++)
            {
                if (!updatedStyles.Contains(styleGroupContainers.array[i]))
                {
                    for (int j = 0; j < styleGroupContainers.array[i].groups.Length; j++)
                    {
                        RunCommands(styleGroupContainers.array[i].groups[j].normal.runCommands, false);
                    }
                }
            }

            availableStyles.Clear();
            styleGroupContainers.Clear();
            isInheritedMap = 0;
            propertyMap.Clear();

            styleGroupContainers.EnsureCapacity(updatedStyles.size);

            containedStates    = 0;
            hasAttributeStyles = false;

            LightList <StylePropertyId> toUpdate = LightList <StylePropertyId> .Get();

            if (instanceStyle != null)
            {
                CreateStyleEntry(toUpdate, instanceStyle, instanceStyle.normal, StyleType.Instance, StyleState.Normal, 0);
                CreateStyleEntry(toUpdate, instanceStyle, instanceStyle.hover, StyleType.Instance, StyleState.Hover, 0);
                CreateStyleEntry(toUpdate, instanceStyle, instanceStyle.focused, StyleType.Instance, StyleState.Focused, 0);
                CreateStyleEntry(toUpdate, instanceStyle, instanceStyle.active, StyleType.Instance, StyleState.Active, 0);
            }

            for (int i = 0; i < count; i++)
            {
                CreateStyleGroups(updatedStyleArray[i], toUpdate);
                styleGroupContainers.array[i] = updatedStyleArray[i];
            }

            styleGroupContainers.size = count;

            SortStyles();

            UpdatePropertyMap(toUpdate);

            LightList <StylePropertyId> .Release(ref toUpdate);
        }
Пример #4
0
        private static LightList <Type> ResolveGenericTypes(TypeLookup typeLookup, IReadOnlyList <string> namespaces = null, Type scopeType = null)
        {
            int count = typeLookup.generics.size;

            LightList <Type> results = LightList <Type> .Get();

            results.EnsureCapacity(count);

            Type[] array        = results.array;
            Type[] generics     = null;
            Type[] concreteArgs = null;
            if (scopeType != null)
            {
                if (scopeType.IsGenericType)
                {
                    generics     = scopeType.GetGenericTypeDefinition().GetGenericArguments();
                    concreteArgs = scopeType.GetGenericArguments();
                }
            }

            for (int i = 0; i < count; i++)
            {
                if (generics != null)
                {
                    for (int j = 0; j < generics.Length; j++)
                    {
                        if (typeLookup.generics[i].typeName == generics[j].Name)
                        {
                            array[i] = concreteArgs[i];
                            break;
                        }
                    }
                }

                array[i] = array[i] ?? ResolveType(typeLookup.generics[i], namespaces);

                if (array[i] == null)
                {
                    throw new TypeResolutionException($"Failed to find a type from string {typeLookup.generics[i]}");
                }
            }

            results.Count = typeLookup.generics.size;
            return(results);
        }
Пример #5
0
        public void ClearStore()
        {
            if (onRecordRemoved == null)
            {
                recordStore.Clear();
                return;
            }

            LightList <T> records = LightList <T> .Get();

            records.EnsureCapacity(recordStore.Count);
            recordStore.GetAllRecords(records);
            T[] recordsArray = records.Array;
            recordStore.Clear();
            for (int i = 0; i < records.Count; i++)
            {
                onRecordRemoved.Invoke(recordsArray[i]);
            }

            LightList <T> .Release(ref records);
        }