/// <summary>Sets up the current batch as a 'globally isolated' batch. This acts like a hybrid between isolated /// and shared.</summary> /// <param name="property">The displayable property which wants the batch.</param> /// <param name="fontTexture">The font texture to use with this batch.</param> public void SetupBatchGI(DisplayableProperty property, TextureAtlas graphics, TextureAtlas font) { if (!property.Isolated) { // Ordinary non-isolated batch: SetupBatch(property, graphics, font); return; } if (property.GotBatchAlready) { // Re-use existing batch? if (font != null) { if (CurrentBatch.FontAtlas == null) { // Didn't have one assigned before. Assign now: CurrentBatch.SetFontAtlas(font); } else if (font != CurrentBatch.FontAtlas) { // Font atlas changed. Can't share. CurrentBatch = null; } } if (graphics != null) { if (CurrentBatch.GraphicsAtlas == null) { // Didn't have one assigned before. Assign now: CurrentBatch.SetGraphicsAtlas(graphics); } else if (graphics != CurrentBatch.GraphicsAtlas) { // Atlas changed. Can't share. CurrentBatch = null; } } if (CurrentBatch != null) { // Yep - reuse it. return; } } // First timer or new one required - create: CurrentBatch = UIBatchPool.Get(this); if (CurrentBatch == null) { CurrentBatch = new UIBatch(this); } property.GotBatchAlready = true; // And push it to the active stack: AddBatch(CurrentBatch); // Use the global material, but set it as isolated // (note that we don't want to set CurrentBatch.IsolatedProperty as it may get unintentionally spammed): CurrentBatch.NotIsolated(graphics, font); CurrentBatch.Isolated = true; // Finally, prepare it for layout: CurrentBatch.PrepareForLayout(); }
/// <summary>Sets up the current batch based on the isolation settings requested by a property.</summary> /// <param name="property">The displayable property which wants the batch.</param> /// <param name="fontTexture">The font texture to use with this batch.</param> public void SetupBatch(DisplayableProperty property, TextureAtlas graphics, TextureAtlas font) { if (property.Isolated) { if (property.GotBatchAlready) { // The property already got a batch on this layout - it doesn't need another. return; } // Isolated properties always get a new batch every time. CurrentBatch = UIBatchPool.Get(this); if (CurrentBatch == null) { CurrentBatch = new UIBatch(this); } property.GotBatchAlready = true; // And push it to the active stack: AddBatch(CurrentBatch); // Make sure it knows it's isolated: CurrentBatch.IsIsolated(property); } else { if (CurrentBatch != null && !CurrentBatch.Isolated) { // Re-use existing batch? if (font != null) { if (CurrentBatch.FontAtlas == null) { // Didn't have one assigned before. Assign now: CurrentBatch.SetFontAtlas(font); } else if (font != CurrentBatch.FontAtlas) { // Font atlas changed. Can't share. CurrentBatch = null; } } if (graphics != null) { if (CurrentBatch.GraphicsAtlas == null) { // Didn't have one assigned before. Assign now: CurrentBatch.SetGraphicsAtlas(graphics); } else if (graphics != CurrentBatch.GraphicsAtlas) { // Atlas changed. Can't share. CurrentBatch = null; } } if (CurrentBatch != null) { // Yep - reuse it. return; } } // Pull a batch from the pool and set it to currentbatch. May need to generate a new one. CurrentBatch = UIBatchPool.Get(this); if (CurrentBatch == null) { CurrentBatch = new UIBatch(this); } // And push it to the active stack: AddBatch(CurrentBatch); // Make sure it knows it's not isolated: CurrentBatch.NotIsolated(graphics, font); } // Finally, prepare it for layout: CurrentBatch.PrepareForLayout(); }
public DisplayablePropertyGroup(RenderableData data, DisplayableProperty a, DisplayableProperty b) : base(data) { // Add the first two: Contents.Add(a); Contents.Add(b); }