コード例 #1
0
        /// <summary>
        /// Creates a new instance of the resource factory
        /// </summary>
        /// <param name="canvas">The DirectCanvasFactory this factory belongs to</param>
        public ResourceFactory(DirectCanvasFactory canvas)
        {
            m_directCanvasFactory = canvas;
            m_textureResourceOwner = new RenderTargetTexture(m_directCanvasFactory.DeviceContext.Device, 
                                                             MINIMUM_RENDERTARGET_WIDTH, 
                                                             MINIMUM_RENDERTARGET_HEIGHT);

            m_renderTargetResourceOwner = new Direct2DRenderTarget(m_directCanvasFactory.DeviceContext, 
                                                                   m_textureResourceOwner.InternalDxgiSurface);
        }
コード例 #2
0
        public virtual void Dispose()
        {
            if(SystemMemoryTexture != null)
            {
                SystemMemoryTexture.Dispose();
                SystemMemoryTexture = null;
            }

            if(m_d2DRenderTarget != null)
            {
                m_d2DRenderTarget.Dispose();
                m_d2DRenderTarget = null;
            }

            if (m_renderTargetTexture != null)
            {
                m_renderTargetTexture.Dispose();
                m_renderTargetTexture = null;
            }

            if (m_textFormat != null)
            {
                m_textFormat.Dispose();
                m_textFormat = null;
            }

            if(m_directWriteFactory != null)
            {
                m_directWriteFactory.Dispose();
                m_directWriteFactory = null;
            }

            foreach (var stateBlock in m_stateStack)
            {
                stateBlock.Dispose();
            }

            m_stateStack.Clear();
        }
コード例 #3
0
        /// <summary>
        /// Creates a new instance of the DrawingLayer
        /// </summary>
        /// <param name="directCanvasFactory">The factory that the DrawingLayer belongs to</param>
        /// <param name="renderTargetTexture">The Direct3D texture to use</param>
        internal DrawingLayer(DirectCanvasFactory directCanvasFactory, RenderTargetTexture renderTargetTexture)
        {
            m_directCanvasFactory = directCanvasFactory;
            m_format = renderTargetTexture.Description.Format;

            m_drawStateManagement = new DrawStateManagement();

            /* Set our Direct3D texture */
            RenderTargetTexture = renderTargetTexture;

            /* Create the Direct2D render target, using our Direct3D texture we were passed */
            D2DRenderTarget = new Direct2DRenderTarget(m_directCanvasFactory.DeviceContext,
                                                       m_renderTargetTexture.InternalDxgiSurface, 
                                                       m_format);
        }
コード例 #4
0
        /// <summary>
        /// Creates a new instance of the DrawingLayer
        /// </summary>
        /// <param name="directCanvasFactory">The factory that the DrawingLayer belongs to</param>
        /// <param name="width">The pixel size in width to make the D3D texture</param>
        /// <param name="height">The pixel size in height to make the D3D texture</param>
        /// <param name="format">The color format to make the D3D texture</param>
        /// <param name="optionFlags">Option flags to use on the creation of the D3D texture</param>
        internal DrawingLayer(DirectCanvasFactory directCanvasFactory, 
                              int width, 
                              int height, 
                              Format format = Format.B8G8R8A8_UNorm, 
                              ResourceOptionFlags optionFlags = ResourceOptionFlags.None)
        {
            m_directCanvasFactory = directCanvasFactory;
            m_format = format;

            m_drawStateManagement = new DrawStateManagement();

            var device = m_directCanvasFactory.DeviceContext.Device;

            /* Create our Direct3D texture */
            RenderTargetTexture = new RenderTargetTexture(device, width, height, m_format, optionFlags);

            /* Create the Direct2D render target, using our Direct3D texture we just created */
            D2DRenderTarget = new Direct2DRenderTarget(m_directCanvasFactory.DeviceContext,
                                                       m_renderTargetTexture.InternalDxgiSurface, 
                                                       m_format);
        }
コード例 #5
0
        public void Dispose()
        {
           if(m_renderTargetResourceOwner != null)
           {
               m_renderTargetResourceOwner.Dispose();
               m_renderTargetResourceOwner = null;
           }

            if(m_textureResourceOwner != null)
            {
                m_textureResourceOwner.Dispose();
                m_textureResourceOwner = null;
            }
        }