Ejemplo n.º 1
0
        /// <summary>
        /// Initializes the various Direct3D objects we'll be using.
        /// </summary>
        public bool Initialize(bool startThread)
        {
            try
            {
                StartThread = startThread;

                ReleaseD3D();
                HwndSource hwnd = new HwndSource(0, 0, 0, 0, 0, "test", IntPtr.Zero);

                pp                    = new PresentParameters();
                pp.SwapEffect         = SwapEffect.Discard;
                pp.DeviceWindowHandle = hwnd.Handle;
                pp.Windowed           = true;
                pp.BackBufferWidth    = (int)ActualWidth;
                pp.BackBufferHeight   = (int)ActualHeight;
                pp.BackBufferFormat   = Format.X8R8G8B8;



                if (useDeviceEx)
                {
                    deviceEx = new DeviceEx((Direct3DEx)Direct3D, 0,
                                            DeviceType.Hardware,
                                            hwnd.Handle,
                                            CreateFlags.HardwareVertexProcessing,
                                            pp);
                }
                else
                {
                    device = new Device(Direct3D, 0,
                                        DeviceType.Hardware,
                                        hwnd.Handle,
                                        CreateFlags.HardwareVertexProcessing,
                                        pp);
                }

                // call the users one
                OnDeviceCreated(EventArgs.Empty);
                OnDeviceReset(EventArgs.Empty);

                // only if startThread is true
                if (StartThread)
                {
                    CompositionTarget.Rendering            += OnRendering;
                    d3dimage.IsFrontBufferAvailableChanged += new DependencyPropertyChangedEventHandler(OnIsFrontBufferAvailableChanged);
                }
                d3dimage.Lock();
                d3dimage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, Device.GetBackBuffer(0, 0).ComPointer);
                d3dimage.Unlock();

                CustomInitialize();

                return(true);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public RenderTarget GetOrCreateRenderTarget()
        {
            EnsureDirectX();
            var scale = _impl.GetScaling();
            var size  = new IntSize(_impl.ActualWidth * scale.X, _impl.ActualHeight * scale.Y);
            var dpi   = scale * 96;

            if (_backBuffer != null && _backBuffer.Size == size)
            {
                return(_backBuffer.Target);
            }

            if (_image == null || _oldDpi.X != dpi.X || _oldDpi.Y != dpi.Y)
            {
                _image = new D3DImage(dpi.X, dpi.Y);
            }
            _impl.ImageSource = _image;

            RemoveAndDispose(ref _backBuffer);
            if (size == default(IntSize))
            {
                _image.Lock();
                _image.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
                _image.Unlock();
                return(null);
            }
            _backBuffer = new SwapBuffer(size, dpi);

            return(_backBuffer.Target);
        }
Ejemplo n.º 3
0
        void Initialize()
        {
            ReleaseD3D();

            HwndSource hwnd = new HwndSource(0, 0, 0, 0, 0, "test", IntPtr.Zero);

            pp                    = new PresentParameters();
            pp.SwapEffect         = SwapEffect.Discard;
            pp.DeviceWindowHandle = hwnd.Handle;
            pp.Windowed           = true;
            pp.BackBufferWidth    = (int)ActualWidth;
            pp.BackBufferHeight   = (int)ActualHeight;
            pp.BackBufferFormat   = Format.X8R8G8B8;
            //pp.Multisample = MultisampleType.EightSamples;


            device = new DeviceEx(Direct3D, 0,
                                  DeviceType.Hardware,
                                  hwnd.Handle,
                                  CreateFlags.HardwareVertexProcessing,
                                  pp);

            System.Windows.Media.CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
            d3dimage.IsFrontBufferAvailableChanged           += new DependencyPropertyChangedEventHandler(d3dimage_IsFrontBufferAvailableChanged);

            d3dimage.Lock();
            d3dimage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, device.GetBackBuffer(0, 0).ComPointer);
            d3dimage.Unlock();
        }
Ejemplo n.º 4
0
 private void SetSharedSurfaceToD3DImage()
 {
     _image.Lock();
     _image.SetBackBuffer(D3DResourceType.IDirect3DSurface9, _d3d_surface);
     _image.AddDirtyRect(new Int32Rect(0, 0, _image.PixelWidth, _image.PixelHeight));
     _image.Unlock();
 }
Ejemplo n.º 5
0
        public void UpdateSurface(D3DImage previewSurface, string bsChannelID, string bsEventName, string bsEventParam, object pEventObject)
        {
            if (bsEventName == "wpf_nextframe")
            {
                IntPtr pSurfaceIUnk = Marshal.GetIUnknownForObject(pEventObject);
                if (pSurfaceIUnk != SavedSurfaceIUnk)
                {
                    if (SavedSurfaceIUnk != IntPtr.Zero)
                    {
                        Marshal.Release(SavedSurfaceIUnk);
                    }

                    SavedSurfaceIUnk = pSurfaceIUnk;
                    Marshal.AddRef(SavedSurfaceIUnk);

                    previewSurface.Lock();
                    previewSurface.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
                    previewSurface.SetBackBuffer(D3DResourceType.IDirect3DSurface9, SavedSurfaceIUnk);
                    previewSurface.Unlock();
                }

                if (pSurfaceIUnk != IntPtr.Zero)
                {
                    Marshal.Release(pSurfaceIUnk);
                }

                previewSurface.Lock();
                previewSurface.AddDirtyRect(new Int32Rect(0, 0, previewSurface.PixelWidth, previewSurface.PixelHeight));
                previewSurface.Unlock();
            }

            Marshal.ReleaseComObject(pEventObject);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Marks the surface of element as invalid and requests its presentation on screen.
        /// </summary>
        internal void InvalidateRendering()
        {
            DisposedGuard();

            image.Lock();
            image.AddDirtyRect(new Int32Rect(0, 0, image.PixelWidth, image.PixelHeight));
            image.Unlock();
        }
 void onPacket(long timestamp, IntPtr data, int len)
 {
     Dispatcher.Invoke(delegate() {
         img.Lock();
         img.AddDirtyRect(new Int32Rect(0, 0, img.PixelWidth, img.PixelHeight));
         img.Unlock();
     });
 }
Ejemplo n.º 8
0
        internal void NewSurface(IntPtr surfacePtr)
        {
            _surface = surfacePtr;

            DispatchToUI(() =>
            {
                _d3dImage.Lock();
                _d3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, surfacePtr);
                _d3dImage.Unlock();
            });
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Marks the surface of element as invalid and requests its presentation on screen.
        /// </summary>
        internal void InvalidateRendering()
        {
            if (!isLoaded || texture == null)
            {
                return;
            }

            image.Lock();
            image.AddDirtyRect(new Int32Rect(0, 0, image.PixelWidth, image.PixelHeight));
            image.Unlock();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// If we didn't do this, D3DImage would keep an reference to the backbuffer that causes the device reset below to fail.
        /// </summary>
        private void RemoveBackBufferReference()
        {
            if (_renderTarget != null)
            {
                _renderTarget.Dispose();
                _renderTarget = null;
            }

            _d3dImage.Lock();
            _d3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
            _d3dImage.Unlock();
        }
Ejemplo n.º 11
0
        private void M_objPreview_OnEventSafe(string bsChannelID, string bsEventName, string bsEventParam, object pEventObject)
        {
            // specific name for event is "wpf_nextframe"
            if (bsEventName == "wpf_nextframe")
            {
                // it is necessary to keep a pointer in memory cause in case of format or source changes the pointer can be changed too
                IntPtr pSurfaceIUnk = Marshal.GetIUnknownForObject(pEventObject);
                if (pSurfaceIUnk != IntPtr.Zero)
                {
                    if (pSurfaceIUnk != pSavedSurfaceIUnk)
                    {
                        // Release prev object
                        if (pSavedSurfaceIUnk != IntPtr.Zero)
                        {
                            Marshal.Release(pSavedSurfaceIUnk);
                            pSavedSurfaceIUnk = IntPtr.Zero;
                        }

                        // here we change back buffer of the surface (only in case of the pointer is changed)
                        pSavedSurfaceIUnk = pSurfaceIUnk;
                        Marshal.AddRef(pSavedSurfaceIUnk);

                        // Lock and Unlock are required for update of the surface
                        previewSource.Lock();
                        previewSource.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
                        previewSource.SetBackBuffer(D3DResourceType.IDirect3DSurface9, pSavedSurfaceIUnk);
                        previewSource.Unlock();
                        // use this 3D surface as source for preview control
                        preview.Source = previewSource;
                        //GC.Collect();
                    }

                    Marshal.Release(pSurfaceIUnk);
                }


                Marshal.ReleaseComObject(pEventObject);

                // update of preview rectangle
                previewSource.Lock();
                try
                {
                    previewSource.AddDirtyRect(new Int32Rect(0, 0, previewSource.PixelWidth, previewSource.PixelHeight));
                }
                catch (Exception)
                {
                    previewSource.SetBackBuffer(D3DResourceType.IDirect3DSurface9, pSavedSurfaceIUnk);
                }
                previewSource.Unlock();
            }
        }
Ejemplo n.º 12
0
        private void _d3d_render_IsFrontBufferAvailableChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (_d3d_render == null)
            {
                return;
            }

            if (!_d3d_render.IsFrontBufferAvailable)
            {
                _d3d_render.Lock();
                _d3d_render.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
                _d3d_render.Unlock();
            }
        }
Ejemplo n.º 13
0
        private void BeginRenderingScene()
        {
            RenderSurface = Rush.RushGetBackBuffer();
            if (RenderImage.IsFrontBufferAvailable && RenderSurface != IntPtr.Zero)
            {
                // set the back buffer using the new scene pointer
                RenderImage.Lock();
                RenderImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, RenderSurface);
                RenderImage.Unlock();

                // leverage the Rendering event of WPF's composition target to
                // update the custom D3D scene
                CompositionTarget.Rendering += OnRendering;
            }
        }
        /// <summary> Initializes Direct3D-OCCT rendering. </summary>
        private void UpdateScene()
        {
            if (!myIsFailed && myD3DImage.IsFrontBufferAvailable && myColorSurf != IntPtr.Zero)
            {
                myD3DImage.Lock();
                {
                    // Update the scene (via a call into our custom library)
                    Viewer.View.RedrawView();

                    // Invalidate the updated region of the D3DImage
                    myD3DImage.AddDirtyRect(new Int32Rect(0, 0, mySize.cx, mySize.cy));
                }
                myD3DImage.Unlock();
            }
        }
Ejemplo n.º 15
0
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            RenderingEventArgs args = (RenderingEventArgs)e;

            // It's possible for Rendering to call back twice in the same frame
            // so only render when we haven't already rendered in this frame.

            if (_d3dImage.IsFrontBufferAvailable && _lastRender != args.RenderingTime)
            {
                bool newSurfaceArrived;
                _pvpPresenter.HasNewSurfaceArrived(out newSurfaceArrived);
                if (newSurfaceArrived)
                {
                    _d3dImage.Lock();

                    IntPtr pSurface;
                    _pvpPresenter.GetBackBufferNoRef(out pSurface);

                    if (pSurface != null)
                    {
                        // Repeatedly calling SetBackBuffer with the same IntPtr is
                        // a no-op. There is no performance penalty.
                        _d3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, pSurface);

                        _d3dImage.AddDirtyRect(new Int32Rect(0, 0, _d3dImage.PixelWidth, _d3dImage.PixelHeight));
                    }

                    _d3dImage.Unlock();
                }

                _lastRender = args.RenderingTime;
                //System.Diagnostics.Debug.WriteLine("{0} : Repaint: {1}", args.RenderingTime, newSurfaceArrived);
            }
        }
Ejemplo n.º 16
0
        private void Compose()
        {
            if (_d3DImage == null)
            {
                return;
            }

            if (_d3DImage.IsFrontBufferAvailable &&
                Graphics.GraphicsDevice.GraphicsDeviceStatus == GraphicsDeviceStatus.Normal)
            {
                _d3DImage.Lock();

                if (_compositionTargetSetBackBufferRequired)
                {
                    _d3DImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, _frontBufferPointer);
                    _compositionTargetSetBackBufferRequired = false;
                }

                if (_frontBufferPointer != IntPtr.Zero)
                {
                    _d3DImage.AddDirtyRect(
                        new Int32Rect(
                            0,
                            0,
                            _d3DImage.PixelWidth,
                            _d3DImage.PixelHeight));
                }

                _d3DImage.Unlock();
            }
        }
Ejemplo n.º 17
0
        public int OnNewSurfaceArrived()
        {
            _d3dImage.Dispatcher.Invoke(new Action(() =>
            {
                if (_d3dImage.IsFrontBufferAvailable)
                {
                    _d3dImage.Lock();

                    IntPtr pSurface;
                    _pvpPresenter.GetBackBufferNoRef(out pSurface);

                    if (pSurface != null)
                    {
                        // Repeatedly calling SetBackBuffer with the same IntPtr is
                        // a no-op. There is no performance penalty.
                        _d3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, pSurface);

                        _d3dImage.AddDirtyRect(new Int32Rect(0, 0, _d3dImage.PixelWidth, _d3dImage.PixelHeight));
                    }

                    _d3dImage.Unlock();
                }
            }), System.Windows.Threading.DispatcherPriority.Send);

            return(0);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Configures D3DImage with a new surface.  This happens immediately
        /// </summary>
        private void SetBackBufferInternal(IntPtr backBuffer)
        {
            /* Do nothing if we don't have a new surface available */
            if (!m_newSurfaceAvailable)
            {
                return;
            }

            if (!D3DImage.Dispatcher.CheckAccess())
            {
                D3DImage.Dispatcher.BeginInvoke((Action)(() => SetBackBufferInternal(backBuffer)));
                return;
            }

            /* We have this around a try/catch just in case we
             * lose the device and our Surface is invalid. The
             * try/catch may not be needed, but testing needs
             * to take place before it's removed */
            try
            {
                D3DImage.Lock();
                D3DImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, backBuffer);
                D3DImage.Unlock();
                SetNaturalWidthHeight();
            }
            catch (Exception ex)
            { }

            /* Clear our flag, so this won't be ran again
             * until a new surface is sent */
            m_newSurfaceAvailable = false;
        }
 public void InvalidateImageSource()
 {
     _d3dImage.Lock();
     _d3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, _surface.NativePointer);
     _d3dImage.AddDirtyRect(new Int32Rect(0, 0, _d3dImage.PixelWidth, _d3dImage.PixelHeight));
     _d3dImage.Unlock();
 }
Ejemplo n.º 20
0
 internal unsafe void SetBackBuffer()
 {
     if (surfaceType == SurfaceType.DirectX9)
     {
         d3dImage.Lock();
         using (backBufferSurface = GraphicsDevice.GetBackBuffer(0, 0))
         {
             d3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, backBufferSurface.NativePointer);
         }
         d3dImage.Unlock();
     }
     else if (surfaceType == SurfaceType.Direct2D)
     {
         SetBackBuffer(graphicsDeviceService10.Texture9);
     }
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Invalidates the entire Direct3D image, notifying WPF to redraw
        /// </summary>
        protected void InternalInvalidateVideoImage()
        {
            /* Ensure we run on the correct Dispatcher */
            if (!D3DImage.Dispatcher.CheckAccess())
            {
                D3DImage.Dispatcher.Invoke((Action)(() => InvalidateVideoImage()));
                return;
            }

            /* If there is a new Surface to set,
             * this method will do the trick */
            SetBackBufferInternal(m_pBackBuffer);

            /* Only render the video image if possible, or if IsRenderingEnabled is true */
            if (D3DImage.IsFrontBufferAvailable && IsRenderingEnabled && m_pBackBuffer != IntPtr.Zero)
            {
                try
                {
                    /* Invalidate the entire image */
                    D3DImage.Lock();
                    D3DImage.AddDirtyRect(new Int32Rect(0,                   /* Left */
                                                        0,                   /* Top */
                                                        D3DImage.PixelWidth, /* Width */
                                                        D3DImage.PixelHeight /* Height */));
                    D3DImage.Unlock();
                }
                catch (Exception)
                { }
            }

            /* Invalidate all of our cloned D3DRenderers */
            InvalidateClonedVideoImages();
        }
Ejemplo n.º 22
0
 void m_source_IsFrontBufferAvailableChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (m_source.IsFrontBufferAvailable)
     {
         //lock (m_drawing)
         //{
         unsafe
         {
             m_source.Lock();
             lock (m_locker)
             {
                 if (!m_target.IsContentLost && !m_target.IsDisposed)
                 {
                     m_source.SetBackBuffer(D3DResourceType.IDirect3DSurface9, m_target.GetPtr());
                 }
             }
             m_source.Unlock();
         }
         m_drawing = true;
         //}
     }
     else
     {
         m_drawing = false;
     }
 }
Ejemplo n.º 23
0
        private void OnLoaded(object sender, EventArgs e)
        {
            UpdateTargetSize();

            InitializeXna();

            _d3dImage = new D3DImage();
            _d3dImage.Lock();

            try
            {
                _d3dImage.SetBackBuffer(
                    D3DResourceType.IDirect3DSurface9,
                    _frontBufferPointer);
            }
            finally
            {
                _d3dImage.Unlock();
            }

            _targetImage.Source = _d3dImage;

            if (_deviceManager.GraphicsDevice.GraphicsDeviceCapabilities.DeviceType == DeviceType.Hardware)
            {
                CompositionTarget.Rendering += OnCompositionTargetRendering;
            }
            else
            {
                _timer       = XnaHelper.CreateRenderTimer();
                _timer.Tick += OnCompositionTargetRendering;
                _timer.Start();
            }

            _stopwatch.Start();
        }
Ejemplo n.º 24
0
        private void OnCompositionTargetRendering(object sender, EventArgs eventArgs)
        {
            if (_d3dImage == null)
            {
                return;
            }

            this.Present();

            if (_d3dImage.IsFrontBufferAvailable &&
                _deviceManager.GraphicsDevice.GraphicsDeviceStatus == GraphicsDeviceStatus.Normal)
            {
                _d3dImage.Lock();

                if (_compositionTargetSetBackBufferRequired)
                {
                    _d3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, _frontBufferPointer);
                    _compositionTargetSetBackBufferRequired = false;
                }

                if (_frontBufferPointer != IntPtr.Zero)
                {
                    _d3dImage.AddDirtyRect(
                        new Int32Rect(
                            0,
                            0,
                            _d3dImage.PixelWidth,
                            _d3dImage.PixelHeight));
                }

                _d3dImage.Unlock();
            }
        }
        private void BeginRenderingScene()
        {
            if (_di.IsFrontBufferAvailable)
            {
                // create a custom D3D scene and get a pointer to its surface
                _scene = InitializeScene();

                // set the back buffer using the new scene pointer
                _di.Lock();
                _di.SetBackBuffer(D3DResourceType.IDirect3DSurface9, _scene);
                _di.Unlock();

                // leverage the Rendering event of WPF's composition target to
                // update the custom D3D scene
                CompositionTarget.Rendering += OnRendering;
            }
        }
Ejemplo n.º 26
0
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            if (counter++ % 2 == 0)
            {
                return;
            }
            if (image == null)
            {
                return;
            }

            try
            {
                if (sizeChanged)
                {
                    pp.BackBufferWidth  = (int)ActualWidth;
                    pp.BackBufferHeight = (int)ActualHeight;
                    device.Reset(pp);
                    sizeChanged = false;
                }

                if (image.IsFrontBufferAvailable)
                {
                    Result result = Device.TestCooperativeLevel();
                    if (result.IsFailure)
                    {
                        throw new Direct3D9Exception();
                    }
                    image.Lock();

                    device.SetRenderState(SlimDX.Direct3D9.RenderState.CullMode, Cull.None);
                    device.SetRenderState(SlimDX.Direct3D9.RenderState.ZEnable, true);
                    device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(1, 1, 1, 1), 1.0f, 0);
                    device.BeginScene();

                    try
                    {
                        Render.Raise(this);
                    }
                    catch (Exception exc)
                    {
                        Debug.WriteLine("Error in rendering in DirectXHost: " + exc.Message);
                    }

                    device.EndScene();
                    device.Present();

                    image.SetBackBuffer(D3DResourceType.IDirect3DSurface9, Device.GetBackBuffer(0, 0).ComPointer);
                    image.AddDirtyRect(new Int32Rect(0, 0, image.PixelWidth, image.PixelHeight));
                    image.Unlock();
                }
            }
            catch (Direct3D9Exception exc)
            {
                Device.Reset(pp);
                Debug.WriteLine("Exception in main render loop: " + exc.Message);
            }
        }
Ejemplo n.º 27
0
        void DrawingSurface_Loaded(object sender, RoutedEventArgs e)
        {
            if (GraphicsDeviceService == null)
            {
                GraphicsDeviceService = GraphicsDeviceService.AddRef(IntPtr.Zero, (int)ActualWidth, (int)ActualHeight, GraphicsProfile);
                GraphicsDeviceService.DeviceResetting += GraphicsDeviceService_DeviceResetting;

                D3dImage.Lock();
                D3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, backbuffer = Interop.GetBackBuffer(GraphicsDeviceService.GraphicsDevice));
                D3dImage.Unlock();
                Marshal.Release(backbuffer);

                CompositionTarget.Rendering += CompositionTarget_Rendering;

                stopWatch           = Stopwatch.StartNew();
                lastDrawTimestamp   = TimeSpan.Zero;
                contentNeedsRefresh = true;
            }
        }
 private void ResetBackBufferReference()
 {
     if (DesignerProperties.GetIsInDesignMode(this))
     {
         return;
     }
     if (_renderTarget != null)
     {
         _renderTarget.Dispose();
         _renderTarget = null;
     }
     if (_renderTargetD3D9 != null)
     {
         _renderTargetD3D9.Dispose();
         _renderTargetD3D9 = null;
     }
     _direct3DImage.Lock();
     _direct3DImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
     _direct3DImage.Unlock();
 }
Ejemplo n.º 29
0
 // Render the DirectX scene onto the D3DImage when WPF itself is ready to render
 private void CompositionTarget_Rendering(object sender, EventArgs e)
 {
     if (D3DImage.IsFrontBufferAvailable)
     {
         D3DImage.Lock();
         PlatformMethods.Render();
         // Invalidate the whole area:
         D3DImage.AddDirtyRect(new Int32Rect(0, 0, D3DImage.PixelWidth, D3DImage.PixelHeight));
         D3DImage.Unlock();
     }
 }
Ejemplo n.º 30
0
        public void Compute()
        {
            if (mD3dImage == null)
            {
                return;
            }

            mD3dImage.Lock();
            mD3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, mSurface.NativePointer);
            mD3dImage.AddDirtyRect(new Int32Rect(0, 0, mD3dImage.PixelWidth, mD3dImage.PixelHeight));
            mD3dImage.Unlock();
        }