private void doCopy() { List <VisualElementModel> elementsToCopy = new List <VisualElementModel>(); if (WorkspaceSpaceEditorView.SelectedItems != null) { var filter = System.Linq.Enumerable.OfType <ComponentVisual>(WorkspaceSpaceEditorView.SelectedItems); var list = filter.Select(visual => visual.Model).OfType <VisualElementModel>().ToList <VisualElementModel>(); elementsToCopy = elementsToCopy.Concat(CopyOperation.SelectConnections(list)).ToList <VisualElementModel>(); //elementsToCopy = elementsToCopy.Concat(list).ToList<VisualElementModel>(); //Nils Kopal 28.08.2013: I removed this line because it lead to the following bug: // Copy an component: You had 2! components in the list // Paste the component - only one component appears on workspace // save + load the workspace // delete or move the "copied" component // a "ghost" component appears at the same place, the copy was // => workspace was corrupt } if (WorkspaceSpaceEditorView.SelectedText != null) { elementsToCopy.Add(WorkspaceSpaceEditorView.SelectedText.Model); } if (WorkspaceSpaceEditorView.SelectedImage != null) { elementsToCopy.Add(WorkspaceSpaceEditorView.SelectedImage.Model); } copy = new CopyOperation(new SerializationWrapper() { elements = elementsToCopy }); }
private void ExecuteDropCopy(object parameter) { var sourceFileSystem = new WindowsFileSystem(droppedFiles.First().FullName); var operation = new CopyOperation(droppedFiles, ActiveView.FullPath, sourceFileSystem, ActiveView.FileSystem); OperationsManager.ExecuteOperation(operation); }
public static Task CopyToAsync(this Stream source, Stream destination, int? bytesRemaining, CancellationToken cancel = default(CancellationToken)) { if (source == null) { throw new ArgumentNullException("source"); } if (destination == null) { throw new ArgumentNullException("destination"); } int bufferSize = 64 * 1024; if (bytesRemaining.HasValue) { bufferSize = Math.Min(bytesRemaining.Value, bufferSize); } CopyOperation copy = new CopyOperation() { source = source, destination = destination, bytesRemaining = bytesRemaining, buffer = new byte[bufferSize], cancel = cancel, complete = new TaskCompletionSource<object>() }; return copy.Start(); }
public static Task CopyToAsync(this Stream source, Stream destination, int?bytesRemaining, CancellationToken cancel = default(CancellationToken)) { if (source == null) { throw new ArgumentNullException("source"); } if (destination == null) { throw new ArgumentNullException("destination"); } int bufferSize = 64 * 1024; if (bytesRemaining.HasValue) { bufferSize = Math.Min(bytesRemaining.Value, bufferSize); } CopyOperation copy = new CopyOperation() { source = source, destination = destination, bytesRemaining = bytesRemaining, buffer = new byte[bufferSize], cancel = cancel, complete = new TaskCompletionSource <object>() }; return(copy.Start()); }
public override void Execute(object parameter) { var source = MainViewModel.ActiveDirectoryContainer.ActiveView; var dest = MainViewModel.InActiveDirectoryContainer.ActiveView; var operation = new CopyOperation(MainViewModel.GetSelectedItems(), dest.FullPath, source.FileSystem, dest.FileSystem); OperationManager.ExecuteOperation(operation); }
private void DropCopy(object sender, RoutedEventArgs e) { MenuItem item = (MenuItem)sender; IDirectoryViewItem[] files = (IDirectoryViewItem[])item.Tag; CopyOperation copy = new CopyOperation(files, DisplayPath, FileSystem, FileSystem); //Main.SupportOperation(copy); }
public static void Copy (TextEditorData data) { CopyOperation operation = new CopyOperation (); Clipboard clipboard = Clipboard.Get (CopyOperation.CLIPBOARD_ATOM); operation.CopyData (data); clipboard.SetWithData (CopyOperation.TargetEntries, operation.ClipboardGetFunc, operation.ClipboardClearFunc); }
private void TextureCopy(AMemory Memory, NsGpuPBEntry PBEntry) { CopyOperation Operation = (CopyOperation)ReadRegister(NvGpuEngine2dReg.CopyOperation); bool SrcLinear = ReadRegister(NvGpuEngine2dReg.SrcLinear) != 0; int SrcWidth = ReadRegister(NvGpuEngine2dReg.SrcWidth); int SrcHeight = ReadRegister(NvGpuEngine2dReg.SrcHeight); bool DstLinear = ReadRegister(NvGpuEngine2dReg.DstLinear) != 0; int DstWidth = ReadRegister(NvGpuEngine2dReg.DstWidth); int DstHeight = ReadRegister(NvGpuEngine2dReg.DstHeight); int DstPitch = ReadRegister(NvGpuEngine2dReg.DstPitch); int DstBlkDim = ReadRegister(NvGpuEngine2dReg.DstBlockDimensions); TextureSwizzle DstSwizzle = DstLinear ? TextureSwizzle.Pitch : TextureSwizzle.BlockLinear; int DstBlockHeight = 1 << ((DstBlkDim >> 4) & 0xf); long Tag = MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress); TryGetCpuAddr(NvGpuEngine2dReg.SrcAddress, out long SrcAddress); TryGetCpuAddr(NvGpuEngine2dReg.DstAddress, out long DstAddress); bool IsFbTexture = Gpu.Engine3d.IsFrameBufferPosition(Tag); if (IsFbTexture && DstLinear) { DstSwizzle = TextureSwizzle.BlockLinear; } Texture DstTexture = new Texture( DstAddress, DstWidth, DstHeight, DstBlockHeight, DstBlockHeight, DstSwizzle, GalTextureFormat.A8B8G8R8); if (IsFbTexture) { Gpu.Renderer.GetFrameBufferData(Tag, (byte[] Buffer) => { CopyTexture(Memory, DstTexture, Buffer); }); } else { long Size = SrcWidth * SrcHeight * 4; byte[] Buffer = AMemoryHelper.ReadBytes(Memory, SrcAddress, Size); CopyTexture(Memory, DstTexture, Buffer); } }
public override object ReadJson( JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JArray ja = JArray.Load(reader); var result = new List <IRollbackableOperation>(); foreach (var jsonObject in ja) { var unit = default(IRollbackableOperation); switch (jsonObject["Type"].Value <string>()) { case "AppendAllText": unit = new AppendAllTextOperation( jsonObject["path"].Value <string>(), jsonObject["contents"].Value <string>()); break; case "Copy": unit = new CopyOperation( jsonObject["sourceFileName"].Value <string>(), jsonObject["path"].Value <string>(), jsonObject["overwrite"].Value <bool>()); break; case "CreateFile": unit = new CreateFileOperation( jsonObject["path"].Value <string>()); break; case "Delete": unit = new DeleteFileOperation( jsonObject["path"].Value <string>()); break; case "Move": unit = new MoveOperation( jsonObject["sourceFileName"].Value <string>(), jsonObject["destFileName"].Value <string>()); break; case "WriteAllText": unit = new WriteAllTextOperation( jsonObject["path"].Value <string>(), jsonObject["contents"].Value <string>()); break; } serializer.Populate(jsonObject.CreateReader(), unit); result.Add(unit); } return(result); }
public static void Copy(TextEditorData data) { CopyOperation operation = new CopyOperation(); operation.CopyData(data); operation.SetData(1); operation.SetData(2); operation.SetData(3); operation.SetData(99); }
public static void Copy(TextEditorData data) { CopyOperation operation = new CopyOperation(); Clipboard clipboard = Clipboard.Get(CopyOperation.CLIPBOARD_ATOM); operation.CopyData(data); clipboard.SetWithData(CopyOperation.TargetEntries, operation.ClipboardGetFunc, operation.ClipboardClearFunc); }
public void CopyTo(string destDir, CopyOperation operation) { if (!isDir) { WindowsFileSystemApi.CopyFile((FileInfo)adapted, new FileInfo(Path.Combine(destDir, Name)), CopyFileOptions.None, operation.CopiedPieceOfFile); } else { CopyDirectory((DirectoryInfo)adapted, destDir, operation); } }
private void DisposeAndLogExceptions(CopyOperation copyOperation) { try { copyOperation.Dispose(); } catch (Exception e) { Logger.Log(e); } }
public static void Copy (TextEditorData data) { if (data.IsSomethingSelected || Path.DirectorySeparatorChar == '\\') { // Case 407636 CopyOperation operation = new CopyOperation (); Clipboard clipboard = Clipboard.Get (CopyOperation.CLIPBOARD_ATOM); operation.CopyData (data); clipboard.SetWithData ((Gtk.TargetEntry[])CopyOperation.targetList, operation.ClipboardGetFunc, operation.ClipboardClearFunc); } }
public static void Copy(TextEditorData data) { CopyOperation operation = new CopyOperation(); Clipboard.SetData(data); /* * Clipboard clipboard = Clipboard.GetData<object> (CopyOperation.CLIPBOARD_ATOM); * operation.CopyData (data); * Clipboard.SetData (); * clipboard (CopyOperation.TargetEntries, operation.ClipboardGetFunc, operation.ClipboardClearFunc);*/ }
public static void Copy(TextEditorData data) { if (data.IsSomethingSelected || Path.DirectorySeparatorChar == '\\') // Case 407636 { CopyOperation operation = new CopyOperation(); Clipboard clipboard = Clipboard.Get(CopyOperation.CLIPBOARD_ATOM); operation.CopyData(data); clipboard.SetWithData((Gtk.TargetEntry[])CopyOperation.targetList, operation.ClipboardGetFunc, operation.ClipboardClearFunc); } }
public GeoprocessingService(IAppContext context, IBroadcasterService broadcaster) { if (context == null) { throw new ArgumentNullException("context"); } if (broadcaster == null) { throw new ArgumentNullException("broadcaster"); } _context = context; _broadcaster = broadcaster; _copyOperation = new CopyOperation(context.Map, this); }
/// <summary> /// Copy directory /// </summary> /// <param name="dir">Directory to copy</param> /// <param name="destination">Destination directory</param> /// <param name="operation">CopyOperation to report changes</param> private void CopyDirectory(DirectoryInfo dir, string destination, CopyOperation operation) { string copyDir = Path.Combine(destination, dir.Name); Directory.CreateDirectory(copyDir); foreach (FileInfo file in dir.GetFiles()) { WindowsFileSystemApi.CopyFile(file, new FileInfo(Path.Combine(copyDir, file.Name)), CopyFileOptions.None, operation.CopiedPieceOfFile); } foreach (DirectoryInfo di in dir.GetDirectories()) { CopyDirectory(di, copyDir, operation); } }
public async Task TestCopyCancel() { _autoMocker .Setup <IFileService, Task <bool> >(m => m.CopyAsync(SourceName, DestinationName, It.IsAny <CancellationToken>(), false)) .Throws <TaskCanceledException>(); var operation = new CopyOperation( _autoMocker.Get <IDirectoryService>(), _autoMocker.Get <IFileService>(), _autoMocker.Get <IPathService>(), SourceName, DestinationName ); Task RunAsync() => operation.RunAsync(default);
public void ShouldCopyDataFromSourceToDestination() { //GIVEN var copyOperation = new CopyOperation(); var destination = Substitute.For <IDataDestination>(); var source = Substitute.For <IDataSource>(); var data = Any.Instance <Data>(); source.RetrieveData().Returns(data); //WHEN copyOperation.ApplyTo(source, destination); //THEN destination.Received(1).Save(data); //destination.Received().Save(data); }
public void ShouldThrowExceptionWhenSavingToDestinationThrowsException() { //GIVEN var copyOperation = new CopyOperation(); var destination = Substitute.For <IDataDestination>(); var source = Substitute.For <IDataSource>(); var data = Any.Instance <Data>(); var exception = Any.Exception(); source.RetrieveData().Returns(data); destination.When(d => d.Save(data)).Throw(exception); //WHEN - THEN var thrownException = Assert.Throws <Exception>( () => copyOperation.ApplyTo(source, destination)); Assert.AreEqual(exception, thrownException); }
public void ShouldThrowExceptionWhenReadingFromSourceThrowsException() { //GIVEN var copyOperation = new CopyOperation(); var destination = Substitute.For <IDataDestination>(); var source = Substitute.For <IDataSource>(); var exception = Any.Exception(); source.RetrieveData().Throws(exception); //WHEN - THEN var e = Assert.Throws <Exception>( () => copyOperation.ApplyTo(source, destination)); Assert.AreEqual(exception, e); //never verification destination.DidNotReceive().Save(Arg.Any <Data>()); }
public override void Execute(object parameter) { var active = MainViewModel.ActiveDirectoryContainer.ActiveView; //get data from clipboard var data = Clipboard.GetDataObject(); //files var paths = (string[])data.GetData(DataFormats.FileDrop, true); if (paths == null) { MessageBox.Show("Schowek jest pusty"); return; } //get flag indicating whether it is copy or cut var stream = (MemoryStream)data.GetData("Preferred DropEffect", true); bool copyFlag = stream.ReadByte() == 5 ? true : false; //change paths into IDirectoryViewItems var items = new IDirectoryViewItem[paths.Length]; for (int i = 0; i < paths.Length; i++) { items[i] = WindowsFile.CreateFromPath(paths[i]); } MultiFileOperation operation; if (copyFlag) { operation = new CopyOperation(items, active.FullPath, new WindowsFileSystem(), active.FileSystem); } else { operation = new MoveOperation(items, active.FullPath, new WindowsFileSystem(), active.FileSystem); } OperationManager.ExecuteOperation(operation); }
[Test] //order verification public void ShouldCopyDataFromSourceToDestinationMultipleTimes() { //GIVEN var copyOperation = new CopyOperation(); var destination = Substitute.For <IDataDestination>(); var source = Substitute.For <IDataSource>(); var data1 = Any.Instance <Data>(); var data2 = Any.Instance <Data>(); source.RetrieveData().Returns(data1, data2); //WHEN copyOperation.ApplyTo(source, destination); copyOperation.ApplyTo(source, destination); //THEN Received.InOrder(() => { destination.Save(data1); destination.Save(data2); }); }
public void Evaluate(int spreadMax) { FCopyOperations.Resize(spreadMax, i => new CopyOperation(FromFilenameIn[i], ToFilenameIn[i]), DisposeAndLogExceptions); ProgressOut.SliceCount = spreadMax; for (int i = 0; i < spreadMax; i++) { var copyOperation = FCopyOperations[i]; var from = FromFilenameIn[i]; var to = ToFilenameIn[i]; if (from != copyOperation.From || to != copyOperation.To || copyOperation.IsCompleted) { DisposeAndLogExceptions(copyOperation); copyOperation = new CopyOperation(from, to); ProgressOut[i] = 0; } var doCopy = DoCopyIn[i]; if (doCopy && !copyOperation.IsRunning) { copyOperation.Run(new Progress <float>(p => ProgressOut[i] = p)); } FCopyOperations[i] = copyOperation; } }
private void TextureCopy(NvGpuVmm Vmm) { CopyOperation Operation = (CopyOperation)ReadRegister(NvGpuEngine2dReg.CopyOperation); int DstFormat = ReadRegister(NvGpuEngine2dReg.DstFormat); bool DstLinear = ReadRegister(NvGpuEngine2dReg.DstLinear) != 0; int DstWidth = ReadRegister(NvGpuEngine2dReg.DstWidth); int DstHeight = ReadRegister(NvGpuEngine2dReg.DstHeight); int DstPitch = ReadRegister(NvGpuEngine2dReg.DstPitch); int DstBlkDim = ReadRegister(NvGpuEngine2dReg.DstBlockDimensions); int SrcFormat = ReadRegister(NvGpuEngine2dReg.SrcFormat); bool SrcLinear = ReadRegister(NvGpuEngine2dReg.SrcLinear) != 0; int SrcWidth = ReadRegister(NvGpuEngine2dReg.SrcWidth); int SrcHeight = ReadRegister(NvGpuEngine2dReg.SrcHeight); int SrcPitch = ReadRegister(NvGpuEngine2dReg.SrcPitch); int SrcBlkDim = ReadRegister(NvGpuEngine2dReg.SrcBlockDimensions); int DstBlitX = ReadRegister(NvGpuEngine2dReg.BlitDstX); int DstBlitY = ReadRegister(NvGpuEngine2dReg.BlitDstY); int DstBlitW = ReadRegister(NvGpuEngine2dReg.BlitDstW); int DstBlitH = ReadRegister(NvGpuEngine2dReg.BlitDstH); long BlitDuDx = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitDuDxFract); long BlitDvDy = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitDvDyFract); long SrcBlitX = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitSrcXFract); long SrcBlitY = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitSrcYFract); GalImageFormat SrcImgFormat = ImageUtils.ConvertSurface((GalSurfaceFormat)SrcFormat); GalImageFormat DstImgFormat = ImageUtils.ConvertSurface((GalSurfaceFormat)DstFormat); GalMemoryLayout SrcLayout = GetLayout(SrcLinear); GalMemoryLayout DstLayout = GetLayout(DstLinear); int SrcBlockHeight = 1 << ((SrcBlkDim >> 4) & 0xf); int DstBlockHeight = 1 << ((DstBlkDim >> 4) & 0xf); long SrcAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress); long DstAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.DstAddress); long SrcKey = Vmm.GetPhysicalAddress(SrcAddress); long DstKey = Vmm.GetPhysicalAddress(DstAddress); GalImage SrcTexture = new GalImage( SrcWidth, SrcHeight, 1, SrcBlockHeight, SrcLayout, SrcImgFormat); GalImage DstTexture = new GalImage( DstWidth, DstHeight, 1, DstBlockHeight, DstLayout, DstImgFormat); SrcTexture.Pitch = SrcPitch; DstTexture.Pitch = DstPitch; Gpu.ResourceManager.SendTexture(Vmm, SrcKey, SrcTexture); Gpu.ResourceManager.SendTexture(Vmm, DstKey, DstTexture); int SrcBlitX1 = (int)(SrcBlitX >> 32); int SrcBlitY1 = (int)(SrcBlitY >> 32); int SrcBlitX2 = (int)(SrcBlitX + DstBlitW * BlitDuDx >> 32); int SrcBlitY2 = (int)(SrcBlitY + DstBlitH * BlitDvDy >> 32); Gpu.Renderer.RenderTarget.Copy( SrcKey, DstKey, SrcBlitX1, SrcBlitY1, SrcBlitX2, SrcBlitY2, DstBlitX, DstBlitY, DstBlitX + DstBlitW, DstBlitY + DstBlitH); //Do a guest side copy aswell. This is necessary when //the texture is modified by the guest, however it doesn't //work when resources that the gpu can write to are copied, //like framebuffers. ImageUtils.CopyTexture( Vmm, SrcTexture, DstTexture, SrcAddress, DstAddress, SrcBlitX1, SrcBlitY1, DstBlitX, DstBlitY, DstBlitW, DstBlitH); Vmm.IsRegionModified(DstKey, ImageUtils.GetSize(DstTexture), NvGpuBufferType.Texture); }
protected abstract void Copy(CopyOperation operation);
private void TextureCopy(NvGpuVmm Vmm, NvGpuPBEntry PBEntry) { CopyOperation Operation = (CopyOperation)ReadRegister(NvGpuEngine2dReg.CopyOperation); bool SrcLinear = ReadRegister(NvGpuEngine2dReg.SrcLinear) != 0; int SrcWidth = ReadRegister(NvGpuEngine2dReg.SrcWidth); int SrcHeight = ReadRegister(NvGpuEngine2dReg.SrcHeight); int SrcPitch = ReadRegister(NvGpuEngine2dReg.SrcPitch); int SrcBlkDim = ReadRegister(NvGpuEngine2dReg.SrcBlockDimensions); bool DstLinear = ReadRegister(NvGpuEngine2dReg.DstLinear) != 0; int DstWidth = ReadRegister(NvGpuEngine2dReg.DstWidth); int DstHeight = ReadRegister(NvGpuEngine2dReg.DstHeight); int DstPitch = ReadRegister(NvGpuEngine2dReg.DstPitch); int DstBlkDim = ReadRegister(NvGpuEngine2dReg.DstBlockDimensions); TextureSwizzle SrcSwizzle = SrcLinear ? TextureSwizzle.Pitch : TextureSwizzle.BlockLinear; TextureSwizzle DstSwizzle = DstLinear ? TextureSwizzle.Pitch : TextureSwizzle.BlockLinear; int SrcBlockHeight = 1 << ((SrcBlkDim >> 4) & 0xf); int DstBlockHeight = 1 << ((DstBlkDim >> 4) & 0xf); long SrcAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress); long DstAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.DstAddress); long SrcKey = Vmm.GetPhysicalAddress(SrcAddress); long DstKey = Vmm.GetPhysicalAddress(DstAddress); bool IsSrcFb = Gpu.Engine3d.IsFrameBufferPosition(SrcKey); bool IsDstFb = Gpu.Engine3d.IsFrameBufferPosition(DstKey); TextureInfo SrcTexture() { return(new TextureInfo( SrcAddress, SrcWidth, SrcHeight, SrcPitch, SrcBlockHeight, 1, SrcSwizzle, GalTextureFormat.A8B8G8R8)); } TextureInfo DstTexture() { return(new TextureInfo( DstAddress, DstWidth, DstHeight, DstPitch, DstBlockHeight, 1, DstSwizzle, GalTextureFormat.A8B8G8R8)); } //TODO: fb -> fb copies, tex -> fb copies, formats other than RGBA8, //make it throw for unimpl stuff (like the copy mode)... if (IsSrcFb && IsDstFb) { //Frame Buffer -> Frame Buffer copy. Gpu.Renderer.FrameBuffer.Copy( SrcKey, DstKey, 0, 0, SrcWidth, SrcHeight, 0, 0, DstWidth, DstHeight); } if (IsSrcFb) { //Frame Buffer -> Texture copy. Gpu.Renderer.FrameBuffer.GetBufferData(SrcKey, (byte[] Buffer) => { TextureInfo Src = SrcTexture(); TextureInfo Dst = DstTexture(); if (Src.Width != Dst.Width || Src.Height != Dst.Height) { throw new NotImplementedException("Texture resizing is not supported"); } TextureWriter.Write(Vmm, Dst, Buffer); }); } else if (IsDstFb) { //Texture -> Frame Buffer copy. const GalTextureFormat Format = GalTextureFormat.A8B8G8R8; byte[] Buffer = TextureReader.Read(Vmm, SrcTexture()); Gpu.Renderer.FrameBuffer.SetBufferData( DstKey, DstWidth, DstHeight, Format, Buffer); } else { //Texture -> Texture copy. TextureInfo Src = SrcTexture(); TextureInfo Dst = DstTexture(); if (Src.Width != Dst.Width || Src.Height != Dst.Height) { throw new NotImplementedException("Texture resizing is not supported"); } TextureWriter.Write(Vmm, Dst, TextureReader.Read(Vmm, Src)); } }
private void TextureCopy(NvGpuVmm Vmm, NvGpuPBEntry PBEntry) { CopyOperation Operation = (CopyOperation)ReadRegister(NvGpuEngine2dReg.CopyOperation); bool SrcLinear = ReadRegister(NvGpuEngine2dReg.SrcLinear) != 0; int SrcWidth = ReadRegister(NvGpuEngine2dReg.SrcWidth); int SrcHeight = ReadRegister(NvGpuEngine2dReg.SrcHeight); bool DstLinear = ReadRegister(NvGpuEngine2dReg.DstLinear) != 0; int DstWidth = ReadRegister(NvGpuEngine2dReg.DstWidth); int DstHeight = ReadRegister(NvGpuEngine2dReg.DstHeight); int DstPitch = ReadRegister(NvGpuEngine2dReg.DstPitch); int DstBlkDim = ReadRegister(NvGpuEngine2dReg.DstBlockDimensions); TextureSwizzle DstSwizzle = DstLinear ? TextureSwizzle.Pitch : TextureSwizzle.BlockLinear; int DstBlockHeight = 1 << ((DstBlkDim >> 4) & 0xf); long Key = Vmm.GetPhysicalAddress(MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress)); long SrcAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress); long DstAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.DstAddress); bool IsFbTexture = Gpu.Engine3d.IsFrameBufferPosition(Key); if (IsFbTexture && DstLinear) { DstSwizzle = TextureSwizzle.BlockLinear; } TextureInfo DstTexture = new TextureInfo( DstAddress, DstWidth, DstHeight, DstBlockHeight, DstBlockHeight, DstSwizzle, GalTextureFormat.A8B8G8R8); if (IsFbTexture) { //TODO: Change this when the correct frame buffer resolution is used. //Currently, the frame buffer size is hardcoded to 1280x720. SrcWidth = 1280; SrcHeight = 720; Gpu.Renderer.FrameBuffer.GetBufferData(Key, (byte[] Buffer) => { CopyTexture( Vmm, DstTexture, Buffer, SrcWidth, SrcHeight); }); } else { long Size = SrcWidth * SrcHeight * 4; byte[] Buffer = Vmm.ReadBytes(SrcAddress, Size); CopyTexture( Vmm, DstTexture, Buffer, SrcWidth, SrcHeight); } }
private void TextureCopy(NvGpuVmm Vmm, NvGpuPBEntry PBEntry) { CopyOperation Operation = (CopyOperation)ReadRegister(NvGpuEngine2dReg.CopyOperation); int SrcFormat = ReadRegister(NvGpuEngine2dReg.SrcFormat); bool SrcLinear = ReadRegister(NvGpuEngine2dReg.SrcLinear) != 0; int SrcWidth = ReadRegister(NvGpuEngine2dReg.SrcWidth); int SrcHeight = ReadRegister(NvGpuEngine2dReg.SrcHeight); int SrcPitch = ReadRegister(NvGpuEngine2dReg.SrcPitch); int SrcBlkDim = ReadRegister(NvGpuEngine2dReg.SrcBlockDimensions); int DstFormat = ReadRegister(NvGpuEngine2dReg.DstFormat); bool DstLinear = ReadRegister(NvGpuEngine2dReg.DstLinear) != 0; int DstWidth = ReadRegister(NvGpuEngine2dReg.DstWidth); int DstHeight = ReadRegister(NvGpuEngine2dReg.DstHeight); int DstPitch = ReadRegister(NvGpuEngine2dReg.DstPitch); int DstBlkDim = ReadRegister(NvGpuEngine2dReg.DstBlockDimensions); GalImageFormat SrcImgFormat = ImageUtils.ConvertSurface((GalSurfaceFormat)SrcFormat); GalImageFormat DstImgFormat = ImageUtils.ConvertSurface((GalSurfaceFormat)DstFormat); GalMemoryLayout SrcLayout = GetLayout(SrcLinear); GalMemoryLayout DstLayout = GetLayout(DstLinear); int SrcBlockHeight = 1 << ((SrcBlkDim >> 4) & 0xf); int DstBlockHeight = 1 << ((DstBlkDim >> 4) & 0xf); long SrcAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress); long DstAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.DstAddress); long SrcKey = Vmm.GetPhysicalAddress(SrcAddress); long DstKey = Vmm.GetPhysicalAddress(DstAddress); GalImage SrcTexture = new GalImage( SrcWidth, SrcHeight, 1, SrcBlockHeight, SrcLayout, SrcImgFormat); GalImage DstTexture = new GalImage( DstWidth, DstHeight, 1, DstBlockHeight, DstLayout, DstImgFormat); Gpu.ResourceManager.SendTexture(Vmm, SrcKey, SrcTexture); Gpu.ResourceManager.SendTexture(Vmm, DstKey, DstTexture); Gpu.Renderer.RenderTarget.Copy( SrcKey, DstKey, 0, 0, SrcWidth, SrcHeight, 0, 0, DstWidth, DstHeight); }
private void TextureCopy(NvGpuVmm vmm) { CopyOperation operation = (CopyOperation)ReadRegister(NvGpuEngine2dReg.CopyOperation); int dstFormat = ReadRegister(NvGpuEngine2dReg.DstFormat); bool dstLinear = ReadRegister(NvGpuEngine2dReg.DstLinear) != 0; int dstWidth = ReadRegister(NvGpuEngine2dReg.DstWidth); int dstHeight = ReadRegister(NvGpuEngine2dReg.DstHeight); int dstDepth = ReadRegister(NvGpuEngine2dReg.DstDepth); int dstLayer = ReadRegister(NvGpuEngine2dReg.DstLayer); int dstPitch = ReadRegister(NvGpuEngine2dReg.DstPitch); int dstBlkDim = ReadRegister(NvGpuEngine2dReg.DstBlockDimensions); int srcFormat = ReadRegister(NvGpuEngine2dReg.SrcFormat); bool srcLinear = ReadRegister(NvGpuEngine2dReg.SrcLinear) != 0; int srcWidth = ReadRegister(NvGpuEngine2dReg.SrcWidth); int srcHeight = ReadRegister(NvGpuEngine2dReg.SrcHeight); int srcDepth = ReadRegister(NvGpuEngine2dReg.SrcDepth); int srcLayer = ReadRegister(NvGpuEngine2dReg.SrcLayer); int srcPitch = ReadRegister(NvGpuEngine2dReg.SrcPitch); int srcBlkDim = ReadRegister(NvGpuEngine2dReg.SrcBlockDimensions); int dstBlitX = ReadRegister(NvGpuEngine2dReg.BlitDstX); int dstBlitY = ReadRegister(NvGpuEngine2dReg.BlitDstY); int dstBlitW = ReadRegister(NvGpuEngine2dReg.BlitDstW); int dstBlitH = ReadRegister(NvGpuEngine2dReg.BlitDstH); long blitDuDx = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitDuDxFract); long blitDvDy = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitDvDyFract); long srcBlitX = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitSrcXFract); long srcBlitY = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitSrcYFract); GalImageFormat srcImgFormat = ImageUtils.ConvertSurface((GalSurfaceFormat)srcFormat); GalImageFormat dstImgFormat = ImageUtils.ConvertSurface((GalSurfaceFormat)dstFormat); GalMemoryLayout srcLayout = GetLayout(srcLinear); GalMemoryLayout dstLayout = GetLayout(dstLinear); int srcBlockHeight = 1 << ((srcBlkDim >> 4) & 0xf); int dstBlockHeight = 1 << ((dstBlkDim >> 4) & 0xf); long srcAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress); long dstAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.DstAddress); long srcKey = vmm.GetPhysicalAddress(srcAddress); long dstKey = vmm.GetPhysicalAddress(dstAddress); bool isSrcLayered = false; bool isDstLayered = false; GalTextureTarget srcTarget = GalTextureTarget.TwoD; if (srcDepth != 0) { srcTarget = GalTextureTarget.TwoDArray; srcDepth++; isSrcLayered = true; } else { srcDepth = 1; } GalTextureTarget dstTarget = GalTextureTarget.TwoD; if (dstDepth != 0) { dstTarget = GalTextureTarget.TwoDArray; dstDepth++; isDstLayered = true; } else { dstDepth = 1; } GalImage srcTexture = new GalImage( srcWidth, srcHeight, 1, srcDepth, 1, srcBlockHeight, 1, srcLayout, srcImgFormat, srcTarget); GalImage dstTexture = new GalImage( dstWidth, dstHeight, 1, dstDepth, 1, dstBlockHeight, 1, dstLayout, dstImgFormat, dstTarget); srcTexture.Pitch = srcPitch; dstTexture.Pitch = dstPitch; long GetLayerOffset(GalImage image, int layer) { int targetMipLevel = image.MaxMipmapLevel <= 1 ? 1 : image.MaxMipmapLevel - 1; return(ImageUtils.GetLayerOffset(image, targetMipLevel) * layer); } int srcLayerIndex = -1; if (isSrcLayered && _gpu.ResourceManager.TryGetTextureLayer(srcKey, out srcLayerIndex) && srcLayerIndex != 0) { srcKey = srcKey - GetLayerOffset(srcTexture, srcLayerIndex); } int dstLayerIndex = -1; if (isDstLayered && _gpu.ResourceManager.TryGetTextureLayer(dstKey, out dstLayerIndex) && dstLayerIndex != 0) { dstKey = dstKey - GetLayerOffset(dstTexture, dstLayerIndex); } _gpu.ResourceManager.SendTexture(vmm, srcKey, srcTexture); _gpu.ResourceManager.SendTexture(vmm, dstKey, dstTexture); if (isSrcLayered && srcLayerIndex == -1) { for (int layer = 0; layer < srcTexture.LayerCount; layer++) { _gpu.ResourceManager.SetTextureArrayLayer(srcKey + GetLayerOffset(srcTexture, layer), layer); } srcLayerIndex = 0; } if (isDstLayered && dstLayerIndex == -1) { for (int layer = 0; layer < dstTexture.LayerCount; layer++) { _gpu.ResourceManager.SetTextureArrayLayer(dstKey + GetLayerOffset(dstTexture, layer), layer); } dstLayerIndex = 0; } int srcBlitX1 = (int)(srcBlitX >> 32); int srcBlitY1 = (int)(srcBlitY >> 32); int srcBlitX2 = (int)(srcBlitX + dstBlitW * blitDuDx >> 32); int srcBlitY2 = (int)(srcBlitY + dstBlitH * blitDvDy >> 32); _gpu.Renderer.RenderTarget.Copy( srcTexture, dstTexture, srcKey, dstKey, srcLayerIndex, dstLayerIndex, srcBlitX1, srcBlitY1, srcBlitX2, srcBlitY2, dstBlitX, dstBlitY, dstBlitX + dstBlitW, dstBlitY + dstBlitH); //Do a guest side copy aswell. This is necessary when //the texture is modified by the guest, however it doesn't //work when resources that the gpu can write to are copied, //like framebuffers. // FIXME: SUPPORT MULTILAYER CORRECTLY HERE (this will cause weird stuffs on the first layer) ImageUtils.CopyTexture( vmm, srcTexture, dstTexture, srcAddress, dstAddress, srcBlitX1, srcBlitY1, dstBlitX, dstBlitY, dstBlitW, dstBlitH); vmm.IsRegionModified(dstKey, ImageUtils.GetSize(dstTexture), NvGpuBufferType.Texture); }
protected abstract void Copy(CopyOperation operation, TDoc target);
public void CopyTo(string destDir, CopyOperation operation) { throw new NotImplementedException(); }