public void CopyTo(Rectangle srcRegion, Canvas.ResolvedContext destination) { Contract.Requires(destination != null); Surface2D dstSurface = (Surface2D)destination.Surface2D; int offsetX = Convert.ToInt32(destination.Region.X); int offsetY = Convert.ToInt32(destination.Region.Y); ResourceRegion sourceRegion = new ResourceRegion { Front = 0, Left = Convert.ToInt32(srcRegion.Left), Top = Convert.ToInt32(srcRegion.Top), Right = Convert.ToInt32(srcRegion.Right), Bottom = Convert.ToInt32(srcRegion.Bottom), Back = 1 }; try { destination.Surface2D.AcquireLock(); _Device3D.CopySubresourceRegion( _Texture, 0, sourceRegion, dstSurface.Texture2D, 0, offsetX, offsetY, 0); } finally { destination.Surface2D.ReleaseLock(); } }
// Method to marshal from native to managed struct internal unsafe void __MarshalFrom(ref __Native @ref) { this.SourceRegionPointer = @ref.SourceRegionPointer; this.DestinationRegionPointer = @ref.DestinationRegionPointer; this.FirstSourceMip = @ref.FirstSourceMip; this.FirstDestinationMip = @ref.FirstDestinationMip; this.MipCount = @ref.MipCount; this.FirstSourceElement = @ref.FirstSourceElement; this.FirstDestinationElement = @ref.FirstDestinationElement; this.ElementCount = @ref.ElementCount; this.Filter = @ref.Filter; this.MipFilter = @ref.MipFilter; this.SourceRegion = new ResourceRegion(); if (@ref.SourceRegionPointer != IntPtr.Zero) Utilities.Read<ResourceRegion>(@ref.SourceRegionPointer, ref this.SourceRegion); this.DestinationRegion = new ResourceRegion(); if (@ref.DestinationRegionPointer != IntPtr.Zero) Utilities.Read<ResourceRegion>(@ref.DestinationRegionPointer, ref this.DestinationRegion); }