コード例 #1
0
        public void Dispose()
        {
            SetBackBufferSlimDX(null);
            if (SharedTexture != null)
            {
                SharedTexture.Dispose();
                SharedTexture = null;
            }

            NumActiveImages--;
            ShutdownD3D9();
        }
コード例 #2
0
        void Cleanup()
        {
            if (RedTexture != null)
            {
                RedTexture.Dispose();
                RedTexture = null;
            }

            /*
             * if (OrangeTexture != null)
             * {
             *  OrangeTexture.Dispose();
             *  OrangeTexture = null;
             * }
             *
             * if (MenuFont != null)
             * {
             *  MenuFont.Dispose();
             *  MenuFont = null;
             * }
             *
             * if (MenuLine != null)
             * {
             *  MenuLine.Dispose();
             *  MenuLine.Dispose();
             * }
             */
        }
コード例 #3
0
ファイル: HTMLTextureRenderer.cs プロジェクト: VRaul/vvvv-sdk
 private void DestroyTexture(CefBrowser browser, EX9.Texture texture)
 {
     lock (FTextures)
     {
         FTextures.Remove(texture);
         texture.Dispose();
     }
 }
コード例 #4
0
 private void DestroyTexture(CefBrowser browser, EX9.Texture texture, DestroyReason reason)
 {
     lock (FTextureResource)
     {
         var sysmemTexture = texture.Tag as EX9.Texture;
         sysmemTexture.Dispose();
         texture.Dispose();
     }
 }
コード例 #5
0
 public void OnDeviceDestroyed(object sender, EventArgs e)
 {
     if (_sprite != null && !_sprite.Disposed)
     {
         _sprite.Dispose();
     }
     if (_shipSprite != null && !_shipSprite.Disposed)
     {
         _shipSprite.Dispose();
     }
     if (_texture != null && !_texture.Disposed)
     {
         _texture.Dispose();
         _texture = null;
     }
     if (_font != null && !_font.Disposed)
     {
         _font.Dispose();
         _font = null;
     }
 }
コード例 #6
0
        public void Shutdown()
        {
            renderThread.Abort();
            if (interlaceSprite != null)
            {
                interlaceSprite.Dispose();
            }
            if (interlaceOverlay2 != null)
            {
                interlaceOverlay2.Dispose();
            }

            gdiDisplay.Dispose();
            tapeIcon.Dispose();
            diskIcon.Dispose();

            if (displaySurface != null)
            {
                displaySurface.Dispose();
            }
            if (dxDisplay != null)
            {
                dxDisplay.Dispose();
            }
            if (sprite != null)
            {
                sprite.Dispose();
            }
            if (dxDevice != null)
            {
                dxDevice.Dispose();
            }
            if (direct3D9 != null)
            {
                direct3D9.Dispose();
            }
        }
コード例 #7
0
        public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex)
        {
            //TODO - lazy create and cache resolving target in RT
            var target = new d3d9.Texture(dev, tex.IntWidth, tex.IntHeight, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.SystemMemory);
            var tw     = tex.Opaque as TextureWrapper;

            dev.GetRenderTargetData(tw.Texture.GetSurfaceLevel(0), target.GetSurfaceLevel(0));
            var dr = target.LockRectangle(0, LockFlags.ReadOnly);

            if (dr.Pitch != tex.IntWidth * 4)
            {
                throw new InvalidOperationException();
            }
            int[] pixels = new int[tex.IntWidth * tex.IntHeight];
            dr.Data.ReadRange(pixels, 0, tex.IntWidth * tex.IntHeight);
            var bb = new BitmapBuffer(tex.IntWidth, tex.IntHeight, pixels);

            target.UnlockRectangle(0);
            target.Dispose();             //buffer churn warning
            return(bb);
        }
コード例 #8
0
        public RenderTarget CreateRenderTarget(int w, int h)
        {
            var d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default);
            var tw     = new TextureWrapper()
            {
                Texture = d3dtex
            };
            var          tex = new Texture2d(this, tw, w, h);
            RenderTarget rt  = new RenderTarget(this, tw, tex);

            ResetHandlers.Add(rt, "RenderTarget",
                              () =>
            {
                d3dtex.Dispose();
                tw.Texture = null;
            },
                              () =>
            {
                d3dtex     = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default);
                tw.Texture = d3dtex;
            }
                              );
            return(rt);
        }
コード例 #9
0
ファイル: IGL_SlimDX9.cs プロジェクト: SaxxonPike/BizHawk
		public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex)
		{
			//TODO - lazy create and cache resolving target in RT
			var target = new d3d9.Texture(dev, tex.IntWidth, tex.IntHeight, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.SystemMemory);
			var tw = tex.Opaque as TextureWrapper;
			dev.GetRenderTargetData(tw.Texture.GetSurfaceLevel(0), target.GetSurfaceLevel(0));
			var dr = target.LockRectangle(0, LockFlags.ReadOnly);
			if (dr.Pitch != tex.IntWidth * 4) throw new InvalidOperationException();
			int[] pixels = new int[tex.IntWidth * tex.IntHeight];
			dr.Data.ReadRange(pixels, 0, tex.IntWidth * tex.IntHeight);
			var bb = new BitmapBuffer(tex.IntWidth, tex.IntHeight, pixels);
			target.UnlockRectangle(0);
			target.Dispose(); //buffer churn warning
			return bb;
		}
コード例 #10
0
		///<summary>
		///    Copies a region of this pixelbuffer to normal memory.
		///</summary>
		///<param name="srcBox">BasicBox describing the source region of this buffer</param>
		///<param name="dst">PixelBox describing the destination pixels and format in memory</param>
		///<remarks>
		///    The source and destination regions don't have to match, in which
		///    case scaling is done.
		///    Only call this function when the buffer is unlocked.
		///</remarks>
		public override void BlitToMemory( BasicBox srcBox, PixelBox dst )
		{
			// Decide on pixel format of temp surface
			PixelFormat tmpFormat = Format;
			if ( D3DHelper.ConvertEnum( dst.Format ) == D3D.Format.Unknown )
				tmpFormat = dst.Format;
			if ( surface != null )
			{
				Debug.Assert( srcBox.Depth == 1 && dst.Depth == 1 );
				// Create temp texture
				D3D.Texture tmp =
					new D3D.Texture( device, dst.Width, dst.Height,
									1, // 1 mip level ie topmost, generate no mipmaps
									0, D3DHelper.ConvertEnum( tmpFormat ),
									D3D.Pool.Scratch );
				D3D.Surface subSurface = tmp.GetSurfaceLevel( 0 );
				// Copy texture to this temp surface
				System.Drawing.Rectangle destRect, srcRect;
				srcRect = ToD3DRectangle( srcBox );
				destRect = ToD3DRectangleExtent( dst );

				D3D.Surface.FromSurface( subSurface, surface, D3D.Filter.None, 0, srcRect, destRect );

				// Lock temp surface and copy it to memory
				int pitch; // Filled in by D3D
				DX.DataRectangle data = subSurface.LockRectangle( D3D.LockFlags.ReadOnly );
				// Copy it
				PixelBox locked = new PixelBox( dst.Width, dst.Height, dst.Depth, tmpFormat );
				FromD3DLock( locked, data );
				PixelConverter.BulkPixelConversion( locked, dst );
				subSurface.UnlockRectangle();
				// Release temporary surface and texture
				subSurface.Dispose();
				tmp.Dispose();
			}
			else
			{
				// Create temp texture
				D3D.VolumeTexture tmp =
					new D3D.VolumeTexture( device, dst.Width, dst.Height, dst.Depth,
										   0, D3D.Usage.None,
										   D3DHelper.ConvertEnum( tmpFormat ),
										   D3D.Pool.Scratch );
				D3D.Volume subVolume = tmp.GetVolumeLevel( 0 );
				// Volume
				D3D.Box ddestBox = ToD3DBoxExtent( dst );
				D3D.Box dsrcBox = ToD3DBox( srcBox );

				D3D.Volume.FromVolume( subVolume, volume, D3D.Filter.None, 0, dsrcBox, ddestBox );
				// Lock temp surface and copy it to memory
				//D3D.LockedBox lbox; // Filled in by D3D
				DX.DataBox data = subVolume.LockBox( D3D.LockFlags.ReadOnly );

				// Copy it
				PixelBox locked = new PixelBox( dst.Width, dst.Height, dst.Depth, tmpFormat );
				FromD3DLock( locked, data );
				PixelConverter.BulkPixelConversion( locked, dst );
				subVolume.UnlockBox();
				// Release temporary surface and texture
				subVolume.Dispose();
				tmp.Dispose();
			}
		}
コード例 #11
0
ファイル: IGL_SlimDX9.cs プロジェクト: CadeLaRen/BizHawk
 public RenderTarget CreateRenderTarget(int w, int h)
 {
     var d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default);
     var tw = new TextureWrapper() { Texture = d3dtex };
     var tex = new Texture2d(this, tw, w, h);
     RenderTarget rt = new RenderTarget(this, tw, tex);
     ResetHandlers.Add(rt, "RenderTarget",
         () =>
         {
             d3dtex.Dispose();
             tw.Texture = null;
         },
         () =>
         {
             d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default);
             tw.Texture = d3dtex;
         }
     );
     return rt;
 }