public void DrawVectorImage(MeshGenerationContextUtils.RectangleParams rectParams) { VectorImage vectorImage = rectParams.vectorImage; Debug.Assert(vectorImage != null); VertexFlags vertexFlags = (vectorImage.atlas != null) ? VertexFlags.IsSVGGradients : VertexFlags.IsSolid; int settingIndexOffset = 0; bool flag = vectorImage.atlas != null && this.m_VectorImageManager != null; if (flag) { GradientRemap gradientRemap = this.m_VectorImageManager.AddUser(vectorImage); vertexFlags = (gradientRemap.isAtlassed ? VertexFlags.IsSVGGradients : VertexFlags.IsCustomSVGGradients); settingIndexOffset = gradientRemap.destIndex; } int count = this.m_Entries.Count; MeshGenerationContext.MeshFlags flags = MeshGenerationContext.MeshFlags.None; bool flag2 = vertexFlags == VertexFlags.IsSVGGradients; if (flag2) { flags = MeshGenerationContext.MeshFlags.IsSVGGradients; } else { bool flag3 = vertexFlags == VertexFlags.IsCustomSVGGradients; if (flag3) { flags = MeshGenerationContext.MeshFlags.IsCustomSVGGradients; } } MeshBuilder.AllocMeshData meshAlloc = new MeshBuilder.AllocMeshData { alloc = this.m_AllocThroughDrawMeshDelegate, texture = ((vertexFlags == VertexFlags.IsCustomSVGGradients) ? vectorImage.atlas : null), flags = flags }; int num; int num2; MeshBuilder.MakeVectorGraphics(rectParams, settingIndexOffset, meshAlloc, out num, out num2); Debug.Assert(count <= this.m_Entries.Count + 1); bool flag4 = count != this.m_Entries.Count; if (flag4) { this.m_SVGBackgroundEntryIndex = this.m_Entries.Count - 1; bool flag5 = num != 0 && num2 != 0; if (flag5) { UIRStylePainter.Entry entry = this.m_Entries[this.m_SVGBackgroundEntryIndex]; entry.vertices = entry.vertices.Slice(0, num); entry.indices = entry.indices.Slice(0, num2); this.m_Entries[this.m_SVGBackgroundEntryIndex] = entry; } } }
public MeshWriteData DrawMesh(int vertexCount, int indexCount, Texture texture, Material material, MeshGenerationContext.MeshFlags flags) { var mwd = GetPooledMeshWriteData(); if (vertexCount == 0 || indexCount == 0) { mwd.Reset(new NativeSlice <Vertex>(), new NativeSlice <ushort>()); return(mwd); } m_CurrentEntry = new Entry() { vertices = m_VertsPool.Alloc((uint)vertexCount), indices = m_IndicesPool.Alloc((uint)indexCount), material = material, uvIsDisplacement = (flags & MeshGenerationContext.MeshFlags.UVisDisplacement) == MeshGenerationContext.MeshFlags.UVisDisplacement, clipRectID = m_ClipRectID, isStencilClipped = m_StencilClip, addFlags = VertexFlags.IsSolid }; Debug.Assert(m_CurrentEntry.vertices.Length == vertexCount); Debug.Assert(m_CurrentEntry.indices.Length == indexCount); Rect uvRegion = new Rect(0, 0, 1, 1); if (texture != null) { // Attempt to override with an atlas. if (!((flags & MeshGenerationContext.MeshFlags.SkipDynamicAtlas) == MeshGenerationContext.MeshFlags.SkipDynamicAtlas) && m_Atlas != null && m_Atlas.TryGetAtlas(currentElement, texture as Texture2D, out TextureId atlas, out RectInt atlasRect)) { m_CurrentEntry.addFlags = VertexFlags.IsDynamic; uvRegion = new Rect(atlasRect.x, atlasRect.y, atlasRect.width, atlasRect.height); m_CurrentEntry.texture = atlas; m_Owner.AppendTexture(currentElement, texture, atlas, true); } else { TextureId id = TextureRegistry.instance.Acquire(texture); m_CurrentEntry.addFlags = VertexFlags.IsTextured; m_CurrentEntry.texture = id; m_Owner.AppendTexture(currentElement, texture, id, false); } }
public MeshWriteData AddGradientsEntry(int vertexCount, int indexCount, TextureId texture, Material material, MeshGenerationContext.MeshFlags flags) { var mwd = GetPooledMeshWriteData(); if (vertexCount == 0 || indexCount == 0) { mwd.Reset(new NativeSlice <Vertex>(), new NativeSlice <ushort>()); return(mwd); } m_CurrentEntry = new Entry() { vertices = m_VertsPool.Alloc((uint)vertexCount), indices = m_IndicesPool.Alloc((uint)indexCount), material = material, texture = texture, clipRectID = m_ClipRectID, isStencilClipped = m_StencilClip, addFlags = VertexFlags.IsSvgGradients }; Debug.Assert(m_CurrentEntry.vertices.Length == vertexCount); Debug.Assert(m_CurrentEntry.indices.Length == indexCount); mwd.Reset(m_CurrentEntry.vertices, m_CurrentEntry.indices, new Rect(0, 0, 1, 1)); m_Entries.Add(m_CurrentEntry); totalVertices += m_CurrentEntry.vertices.Length; totalIndices += m_CurrentEntry.indices.Length; m_CurrentEntry = new Entry(); return(mwd); }
internal MeshWriteData Allocate(int vertexCount, int indexCount, Texture texture, Material material, MeshGenerationContext.MeshFlags flags) { return(this.painter.DrawMesh(vertexCount, indexCount, texture, material, flags)); }
public MeshWriteData DrawMesh(int vertexCount, int indexCount, Texture texture, Material material, MeshGenerationContext.MeshFlags flags) { MeshWriteData pooledMeshWriteData = this.GetPooledMeshWriteData(); bool flag = vertexCount == 0 || indexCount == 0; MeshWriteData result; if (flag) { pooledMeshWriteData.Reset(default(NativeSlice <Vertex>), default(NativeSlice <ushort>)); result = pooledMeshWriteData; } else { this.m_CurrentEntry = new UIRStylePainter.Entry { vertices = this.m_VertsPool.Alloc((uint)vertexCount), indices = this.m_IndicesPool.Alloc((uint)indexCount), material = material, uvIsDisplacement = (flags == MeshGenerationContext.MeshFlags.UVisDisplacement), clipRectID = this.m_ClipRectID, isStencilClipped = this.m_StencilClip, addFlags = VertexFlags.IsSolid }; Debug.Assert(this.m_CurrentEntry.vertices.Length == vertexCount); Debug.Assert(this.m_CurrentEntry.indices.Length == indexCount); Rect uvRegion = new Rect(0f, 0f, 1f, 1f); bool flag2 = flags == MeshGenerationContext.MeshFlags.IsSVGGradients; bool flag3 = flags == MeshGenerationContext.MeshFlags.IsCustomSVGGradients; bool flag4 = flag2 | flag3; if (flag4) { this.m_CurrentEntry.addFlags = (flag2 ? VertexFlags.IsSVGGradients : VertexFlags.IsCustomSVGGradients); bool flag5 = flag3; if (flag5) { this.m_CurrentEntry.custom = texture; } this.currentElement.renderChainData.usesAtlas = true; } else { bool flag6 = texture != null; if (flag6) { RectInt rectInt; bool flag7 = this.m_AtlasManager != null && this.m_AtlasManager.TryGetLocation(texture as Texture2D, out rectInt); if (flag7) { this.m_CurrentEntry.addFlags = ((texture.filterMode == FilterMode.Point) ? VertexFlags.IsAtlasTexturedPoint : VertexFlags.IsAtlasTexturedBilinear); this.currentElement.renderChainData.usesAtlas = true; uvRegion = new Rect((float)rectInt.x, (float)rectInt.y, (float)rectInt.width, (float)rectInt.height); } else { this.m_CurrentEntry.addFlags = VertexFlags.IsCustomTextured; this.m_CurrentEntry.custom = texture; } } } pooledMeshWriteData.Reset(this.m_CurrentEntry.vertices, this.m_CurrentEntry.indices, uvRegion); this.m_Entries.Add(this.m_CurrentEntry); this.totalVertices += this.m_CurrentEntry.vertices.Length; this.totalIndices += this.m_CurrentEntry.indices.Length; this.m_CurrentEntry = default(UIRStylePainter.Entry); result = pooledMeshWriteData; } return(result); }
public MeshWriteData DrawMesh(int vertexCount, int indexCount, Texture texture, Material material, MeshGenerationContext.MeshFlags flags) { bool flag = this.m_DudVerts.Length < vertexCount; if (flag) { bool isCreated = this.m_DudVerts.IsCreated; if (isCreated) { this.m_DudVerts.Dispose(); } this.m_DudVerts = new NativeArray <Vertex>(vertexCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); } bool flag2 = this.m_DudIndices.Length < indexCount; if (flag2) { bool isCreated2 = this.m_DudIndices.IsCreated; if (isCreated2) { this.m_DudIndices.Dispose(); } this.m_DudIndices = new NativeArray <ushort>(indexCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); } return(new MeshWriteData { m_Vertices = this.m_DudVerts.Slice(0, vertexCount), m_Indices = this.m_DudIndices.Slice(0, indexCount) }); }