private void Unregister(VectorImage vi, VectorImageRenderInfo renderInfo) { VectorImageManager.s_MarkerUnregister.Begin(); bool flag = renderInfo.gradientSettingsAlloc.size > 0u; if (flag) { this.m_GradientSettingsAtlas.Remove(renderInfo.gradientSettingsAlloc); } GradientRemap next; for (GradientRemap gradientRemap = renderInfo.firstGradientRemap; gradientRemap != null; gradientRemap = next) { next = gradientRemap.next; this.m_GradientRemapPool.Return(gradientRemap); } this.m_Registered.Remove(vi); this.m_RenderInfoPool.Return(renderInfo); VectorImageManager.s_MarkerUnregister.End(); }
void Unregister(VectorImage vi, VectorImageRenderInfo renderInfo) { s_MarkerUnregister.Begin(); if (renderInfo.gradientSettingsAlloc.size > 0) { m_GradientSettingsAtlas.Remove(renderInfo.gradientSettingsAlloc); } GradientRemap remap = renderInfo.firstGradientRemap; while (remap != null) { GradientRemap next = remap.next; m_GradientRemapPool.Return(remap); remap = next; } m_Registered.Remove(vi); m_RenderInfoPool.Return(renderInfo); s_MarkerUnregister.End(); }
VectorImageRenderInfo Register(VectorImage vi, VisualElement context) { s_MarkerRegister.Begin(); VectorImageRenderInfo renderInfo = m_RenderInfoPool.Get(); renderInfo.useCount = 1; m_Registered[vi] = renderInfo; if (vi.settings?.Length > 0) { // We first attempt to allocate into the gradient settings atlas since it supports deallocation. int gradientCount = vi.settings.Length; Alloc alloc = m_GradientSettingsAtlas.Add(gradientCount); if (alloc.size > 0) { // Then attempt to allocate in the texture atlas. // TODO: Once the atlas actually processes returns, we should call it at some point. if (m_Atlas.TryGetAtlas(context, vi.atlas, out TextureId atlasId, out RectInt uvs)) { // Remap. GradientRemap previous = null; for (int i = 0; i < gradientCount; ++i) { // Chain. GradientRemap current = m_GradientRemapPool.Get(); if (i > 0) { previous.next = current; } else { renderInfo.firstGradientRemap = current; } previous = current; // Remap the index. current.origIndex = i; current.destIndex = (int)alloc.start + i; // Remap the rect. GradientSettings gradient = vi.settings[i]; RectInt location = gradient.location; location.x += uvs.x; location.y += uvs.y; current.location = location; current.atlas = atlasId; } // Write into the previously allocated gradient settings now that we are sure to use it. m_GradientSettingsAtlas.Write(alloc, vi.settings, renderInfo.firstGradientRemap); } else { // If the texture atlas didn't fit, keep it as a standalone custom texture, only need to remap the setting indices GradientRemap previous = null; for (int i = 0; i < gradientCount; ++i) { GradientRemap current = m_GradientRemapPool.Get(); if (i > 0) { previous.next = current; } else { renderInfo.firstGradientRemap = current; } previous = current; current.origIndex = i; current.destIndex = (int)alloc.start + i; current.atlas = TextureId.invalid; } m_GradientSettingsAtlas.Write(alloc, vi.settings, null); } } else { if (!m_LoggedExhaustedSettingsAtlas) { Debug.LogError("Exhausted max gradient settings (" + m_GradientSettingsAtlas.length + ") for atlas: " + m_GradientSettingsAtlas.atlas?.name); m_LoggedExhaustedSettingsAtlas = true; } } }
private VectorImageRenderInfo Register(VectorImage vi) { VectorImageManager.s_MarkerRegister.Begin(); VectorImageRenderInfo vectorImageRenderInfo = this.m_RenderInfoPool.Get(); vectorImageRenderInfo.useCount = 1; this.m_Registered[vi] = vectorImageRenderInfo; GradientSettings[] expr_33 = vi.settings; bool flag = expr_33 != null && expr_33.Length != 0; if (flag) { int num = vi.settings.Length; Alloc alloc = this.m_GradientSettingsAtlas.Add(num); bool flag2 = alloc.size > 0u; if (flag2) { RectInt rectInt; bool flag3 = this.m_AtlasManager.TryGetLocation(vi.atlas, out rectInt); if (flag3) { GradientRemap gradientRemap = null; for (int i = 0; i < num; i++) { GradientRemap gradientRemap2 = this.m_GradientRemapPool.Get(); bool flag4 = i > 0; if (flag4) { gradientRemap.next = gradientRemap2; } else { vectorImageRenderInfo.firstGradientRemap = gradientRemap2; } gradientRemap = gradientRemap2; gradientRemap2.origIndex = i; gradientRemap2.destIndex = (int)(alloc.start + (uint)i); GradientSettings gradientSettings = vi.settings[i]; RectInt location = gradientSettings.location; location.x += rectInt.x; location.y += rectInt.y; gradientRemap2.location = location; gradientRemap2.isAtlassed = true; } this.m_GradientSettingsAtlas.Write(alloc, vi.settings, vectorImageRenderInfo.firstGradientRemap); } else { GradientRemap gradientRemap3 = null; for (int j = 0; j < num; j++) { GradientRemap gradientRemap4 = this.m_GradientRemapPool.Get(); bool flag5 = j > 0; if (flag5) { gradientRemap3.next = gradientRemap4; } else { vectorImageRenderInfo.firstGradientRemap = gradientRemap4; } gradientRemap3 = gradientRemap4; gradientRemap4.origIndex = j; gradientRemap4.destIndex = (int)(alloc.start + (uint)j); gradientRemap4.isAtlassed = false; } this.m_GradientSettingsAtlas.Write(alloc, vi.settings, null); } } else { bool flag6 = !this.m_LoggedExhaustedSettingsAtlas; if (flag6) { string arg_233_0 = "Exhausted max gradient settings ("; string arg_233_1 = this.m_GradientSettingsAtlas.length.ToString(); string arg_233_2 = ") for atlas: "; Texture2D expr_227 = this.m_GradientSettingsAtlas.atlas; Debug.LogError(arg_233_0 + arg_233_1 + arg_233_2 + ((expr_227 != null) ? expr_227.name : null)); this.m_LoggedExhaustedSettingsAtlas = true; } } } VectorImageManager.s_MarkerRegister.End(); return(vectorImageRenderInfo); }
VectorImageRenderInfo Register(VectorImage vi) { k_RegisterSampler.Begin(); VectorImageRenderInfo renderInfo = m_RenderInfoPool.Get(); renderInfo.useCount = 1; m_Registered[vi] = renderInfo; if (vi.settings?.Length > 0) { // We first attempt to allocate into the gradient settings atlas since it supports deallocation. int gradientCount = vi.settings.Length; Alloc alloc = m_GradientSettingsAtlas.Add(gradientCount); if (alloc.size > 0) { // Then attempt to allocate in the texture atlas. RectInt uvs; if (m_AtlasManager.TryGetLocation(vi.atlas, out uvs)) { // Remap. GradientRemap previous = null; for (int i = 0; i < gradientCount; ++i) { // Chain. GradientRemap current = m_GradientRemapPool.Get(); if (i > 0) { previous.next = current; } else { renderInfo.firstGradientRemap = current; } previous = current; // Remap the index. current.origIndex = i; current.destIndex = (int)alloc.start + i; // Remap the rect. GradientSettings gradient = vi.settings[i]; RectInt location = gradient.location; location.x += uvs.x; location.y += uvs.y; current.location = location; current.isAtlassed = true; } // Write into the previously allocated gradient settings now that we are sure to use it. m_GradientSettingsAtlas.Write(alloc, vi.settings, renderInfo.firstGradientRemap); } else { // If the texture atlas didn't fit, keep it as a standalone custom texture, only need to remap the setting indices GradientRemap previous = null; for (int i = 0; i < gradientCount; ++i) { GradientRemap current = m_GradientRemapPool.Get(); if (i > 0) { previous.next = current; } else { renderInfo.firstGradientRemap = current; } previous = current; current.origIndex = i; current.destIndex = (int)alloc.start + i; current.isAtlassed = false; } m_GradientSettingsAtlas.Write(alloc, vi.settings, null); } } else { if (!m_LoggedExhaustedSettingsAtlas) { Debug.LogError("Exhausted max gradient settings (" + m_GradientSettingsAtlas.length + ") for atlas: " + m_GradientSettingsAtlas.atlas?.name); m_LoggedExhaustedSettingsAtlas = true; } } } k_RegisterSampler.End(); return(renderInfo); }