Axiom.RenderSystems.DirectX9.D3DHardwarePixelBuffer.LockImpl C# (CSharp) Метод

LockImpl() защищенный Метод

Lock a box
protected LockImpl ( BasicBox lockBox, BufferLocking options ) : PixelBox
lockBox Axiom.Media.BasicBox
options BufferLocking
Результат Axiom.Media.PixelBox
		protected override PixelBox LockImpl( BasicBox lockBox, BufferLocking options )
		{
			// Check for misuse
			if ( ( (int)usage & (int)TextureUsage.RenderTarget ) != 0 )
				throw new Exception( "DirectX does not allow locking of or directly writing to RenderTargets. Use BlitFromMemory if you need the contents." );
			// Set extents and format
			PixelBox rval = new PixelBox( lockBox, Format );
			// Set locking flags according to options
			D3D.LockFlags flags = D3D.LockFlags.None;
			switch ( options )
			{
				case BufferLocking.Discard:
					// D3D only likes D3D.LockFlags.Discard if you created the texture with D3DUSAGE_DYNAMIC
					// debug runtime flags this up, could cause problems on some drivers
					if ( ( usage & BufferUsage.Dynamic ) != 0 )
						flags |= D3D.LockFlags.Discard;
					break;
				case BufferLocking.ReadOnly:
					flags |= D3D.LockFlags.ReadOnly;
					break;
				default:
					break;
			}

			if ( surface != null )
			{
				// Surface
				DX.DataRectangle data = null;
				try
				{
					if ( lockBox.Left == 0 && lockBox.Top == 0 &&
						 lockBox.Right == Width && lockBox.Bottom == Height )
					{
						// Lock whole surface
						data = surface.LockRectangle( flags );
					}
					else
					{
						System.Drawing.Rectangle prect = ToD3DRectangle( lockBox ); // specify range to lock
						data = surface.LockRectangle( prect, flags );
					}
				}
				catch ( Exception e )
				{
					throw new Exception( "Surface locking failed.", e );
				}

				FromD3DLock( rval, data );
			}
			else
			{
				// Volume
				D3D.Box pbox = ToD3DBox( lockBox ); // specify range to lock

				DX.DataBox data = volume.LockBox( pbox, flags );
				FromD3DLock( rval, data );
			}
			return rval;
		}