static void UpdateOrAllocate(ref MeshHandle data, int vertexCount, int indexCount, UIRenderDevice device, out NativeSlice <Vertex> verts, out NativeSlice <UInt16> indices, out UInt16 indexOffset, ref ChainBuilderStats stats) { if (data != null) { // Try to fit within the existing allocation, optionally we can change the condition // to be an exact match of size to guarantee continuity in draw ranges if (data.allocVerts.size >= vertexCount && data.allocIndices.size >= indexCount) { device.Update(data, (uint)vertexCount, (uint)indexCount, out verts, out indices, out indexOffset); stats.updatedMeshAllocations++; } else { // Won't fit in the existing allocated region, free the current one device.Free(data); data = device.Allocate((uint)vertexCount, (uint)indexCount, out verts, out indices, out indexOffset); stats.newMeshAllocations++; } } else { data = device.Allocate((uint)vertexCount, (uint)indexCount, out verts, out indices, out indexOffset); stats.newMeshAllocations++; } }
static unsafe void PrepareNudgeVertices(VisualElement ve, UIRenderDevice device, MeshHandle mesh, out IntPtr src, out IntPtr dst, out int count) { int vertCount = (int)mesh.allocVerts.size; NativeSlice <Vertex> oldVerts = mesh.allocPage.vertices.cpuData.Slice((int)mesh.allocVerts.start, vertCount); NativeSlice <Vertex> newVerts; device.Update(mesh, (uint)vertCount, out newVerts); src = (IntPtr)oldVerts.GetUnsafePtr(); dst = (IntPtr)newVerts.GetUnsafePtr(); count = vertCount; }
public void Begin(VisualElement ve, UIRenderDevice device) { Debug.Assert(ve.renderChainData.usesLegacyText && ve.renderChainData.textEntries.Count > 0); this.m_CurrentElement = ve; this.m_TextEntryIndex = 0; Alloc allocVerts = ve.renderChainData.data.allocVerts; NativeSlice <Vertex> slice = ve.renderChainData.data.allocPage.vertices.cpuData.Slice((int)allocVerts.start, (int)allocVerts.size); device.Update(ve.renderChainData.data, ve.renderChainData.data.allocVerts.size, out this.m_MeshDataVerts); RenderChainTextEntry renderChainTextEntry = ve.renderChainData.textEntries[0]; bool flag = ve.renderChainData.textEntries.Count > 1 || renderChainTextEntry.vertexCount != this.m_MeshDataVerts.Length; if (flag) { this.m_MeshDataVerts.CopyFrom(slice); } int firstVertex = renderChainTextEntry.firstVertex; this.m_XFormClipPages = slice[firstVertex].xformClipPages; this.m_IDsFlags = slice[firstVertex].idsFlags; this.m_OpacityPagesSettingsIndex = slice[firstVertex].opacityPageSVGSettingIndex; }