internal FixedSpan(ReadOnlyPinnedSpan <T> span) { // TODO : is a branch needed for IsEmpty? ReferenceObject = span.ReferenceObject; Pointer = Unsafe.AsPointer(ref span.GetPinnableReferenceUnsafe()); Length = span.Length; }
internal ManagedTexture2D( ReadOnlyPinnedSpan <byte> .FixedSpan data, ManagedSpriteInstance instance, XTexture2D reference, Vector2I dimensions, SurfaceFormat format, string?name = null ) : base( graphicsDevice: reference.GraphicsDevice.IsDisposed ? DrawState.Device : reference.GraphicsDevice, width: dimensions.Width, height: dimensions.Height, mipmap: UseMips, format: format, type: PTexture2D.PlatformConstruct is null ? SurfaceType.Texture : SurfaceType.SwapChainRenderTarget, // this prevents the texture from being constructed immediately shared: UseShared, arraySize: 1 ) { if (PTexture2D.PlatformConstruct is not null && !GL.Texture2DExt.Construct(this, data, dimensions, UseMips, format, SurfaceType.Texture, UseShared)) { PTexture2D.PlatformConstruct(this, dimensions.X, dimensions.Y, UseMips, format, SurfaceType.Texture, UseShared); SetData(data.Array); } Name = name ?? $"{reference.NormalizedName()} [internal managed <{format}>]"; Reference = reference.MakeWeak(); SpriteInstance = instance; Dimensions = dimensions - instance.BlockPadding; reference.Disposing += OnParentDispose; Interlocked.Add(ref TotalAllocatedSize, (ulong)this.SizeBytes()); Interlocked.Increment(ref TotalManagedTextures); if (Configuration.Config.Garbage.ShouldCollectAccountOwnedTextures) { Garbage.MarkOwned(format, dimensions.Area); Marked = true; } }
public PinnedSpanDebugView(ReadOnlyPinnedSpan <T> .FixedSpan span) : this(span.AsSpan) { }
public PinnedSpanDebugView(ReadOnlyPinnedSpan <T> span) { _array = span.ToArray(); }