public void SetBackBuffer(D3DResourceType backBufferType, IntPtr backBuffer, bool enableSoftwareFallback) { SecurityHelper.DemandUnmanagedCode(); WritePreamble(); if (_lockCount == 0) { throw new InvalidOperationException(SR.Get(SRID.Image_MustBeLocked)); } // In case the user passed in something like "(D3DResourceType)-1" if (backBufferType != D3DResourceType.IDirect3DSurface9) { throw new ArgumentOutOfRangeException("backBufferType"); } // Early-out if the current back buffer equals the new one. If the front buffer // is not available and software fallback is not enabled, _pUserSurfaceUnsafe // will be null and this check will fail. We don't want a null backBuffer to // early-out when the front buffer isn't available. if (backBuffer != IntPtr.Zero && backBuffer == _pUserSurfaceUnsafe) { return; } SafeMILHandle newBitmap = null; uint newPixelWidth = 0; uint newPixelHeight = 0; // Create a new CInteropDeviceBitmap. Note that a null backBuffer will result // in a null _pInteropDeviceBitmap at the end if (backBuffer != IntPtr.Zero) { HRESULT.Check(UnsafeNativeMethods.InteropDeviceBitmap.Create( backBuffer, _dpiX, _dpiY, ++_version, _availableCallback, enableSoftwareFallback, out newBitmap, out newPixelWidth, out newPixelHeight )); } // // We need to completely disassociate with the old interop bitmap if it // exists because it won't be deleted until the composition thread is done // with it or until the garbage collector runs. // if (_pInteropDeviceBitmap != null) { // 1. Tell the old bitmap to stop sending front buffer messages because // our new back buffer may be on a different adapter. Plus, tell the // bitmap to release the back buffer in case the user wants to delete // it immediately. UnsafeNativeMethods.InteropDeviceBitmap.Detach(_pInteropDeviceBitmap); // 2. If we were waiting for a present, unhook from commit UnsubscribeFromCommittingBatch(); // 3. We are no longer dirty _isDirty = false; // Note: We don't need to do anything to the event because we're under // the protection of Lock } // If anything about the new surface were unacceptible, we would have recieved // a bad HRESULT from Create() so everything must be good _pInteropDeviceBitmap = newBitmap; _pUserSurfaceUnsafe = backBuffer; _pixelWidth = newPixelWidth; _pixelHeight = newPixelHeight; _isSoftwareFallbackEnabled = enableSoftwareFallback; // AddDirtyRect is usually what triggers Changed, but AddDirtyRect isn't allowed with // no back buffer so we mark for Changed here if (_pInteropDeviceBitmap == null) { _isChangePending = true; } RegisterForAsyncUpdateResource(); _waitingForUpdateResourceBecauseBitmapChanged = true; // WritePostscript will happen at Unlock }
public void SetBackBuffer(D3DResourceType backBufferType, IntPtr backBuffer) { }
/// <summary> /// Sets a back buffer source for this D3DImage. See the 2nd overload for details. /// </summary> public void SetBackBuffer(D3DResourceType backBufferType, IntPtr backBuffer) { SetBackBuffer(backBufferType, backBuffer, false); }