示例#1
0
        /// <summary>
        /// Discard is valid only for dynamic buffers
        /// </summary>
        public static void SetData <T>(this IndexBuffer indexBuffer, T[] data, LockFlags flags = LockFlags.None)
            where T : struct
        {
            int itemSize = Utilities.SizeOf <T>();
            var ptr      = indexBuffer.LockToPointer(0, itemSize * data.Length, flags);

            Utilities.Write(ptr, data, 0, data.Length);
            indexBuffer.Unlock();
        }
    /// <summary>
    /// Locks the specified index buffer.
    /// </summary>
    /// <param name="offsetToLock">The offset in the buffer.</param>
    /// <param name="sizeToLock">The size of the buffer to lock.</param>
    /// <param name="lockFlags">The lock flags.</param>
    /// <returns>A <see cref="System.IntPtr" /> containing the locked index buffer.</returns>
    public IntPtr LockToPointer(int offsetToLock, int sizeToLock, LockFlags lockFlags = LockFlags.None)
    {
        if (sizeToLock == 0)
        {
            sizeToLock = Description.SizeInBytes;
        }

        return(Lock(offsetToLock, sizeToLock, lockFlags));
    }
示例#3
0
 public LockedRegion Lock(PixelFormat format, LockFlags flags)
 {
     var ptr = Allegro5.al_lock_bitmap(Ptr, format, flags);
     if (ptr == IntPtr.Zero)
     {
         return null;
     }
     return new LockedRegion(ptr, this);
 }
示例#4
0
 public LockData(string Tag = null)
     : base(Tag)
 {
     Level   = new Byte();
     Unused  = new byte[3];
     Key     = new FormID();
     Flags   = new LockFlags();
     Unknown = new byte[11];
 }
示例#5
0
 /// <summary>
 /// Locks a box on a volume resource.
 /// </summary>
 /// <param name="box">The box.</param>
 /// <param name="flags">The flags.</param>
 /// <returns>The locked region of this resource</returns>
 /// <unmanaged>HRESULT IDirect3DVolume9::LockBox([Out] D3DLOCKED_BOX* pLockedVolume,[In] const void* pBox,[In] D3DLOCK Flags)</unmanaged>
 public DataBox LockBox(Box box, LockFlags flags)
 {
     unsafe
     {
         LockedBox lockedBox;
         LockBox(out lockedBox, new IntPtr(&box), flags);
         return(new DataBox(lockedBox.PBits, lockedBox.RowPitch, lockedBox.SlicePitch));
     }
 }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FairReaderWriterLock"/> class.
        /// </summary>
        public FairReaderWriterLock(int lockTimeout)
        {
            _uMainLock    = new SpinLock(true);
            _uLockFlags   = LockFlags.None;
            _uSharedCount = 0;

            ReadLock  = new CommonReadLock(this, lockTimeout);
            WriteLock = new CommonWriteLock(this, lockTimeout);
        }
示例#7
0
        /// <summary>
        /// Locks the specified region for direct access.
        /// </summary>
        /// <param name="rect">The area to lock</param>
        /// <param name="readOnly">Specifies that the lock is read-only</param>
        /// <returns>An array containing the 32-bit pixel values of the canvas</returns>
        public GraphicsStream LockToGraphicsStream(bool readOnly)
        {
            LockFlags flags = LockFlags.None;

            if (readOnly)
            {
                flags |= LockFlags.ReadOnly;
            }
            return(tex.LockRectangle(0, flags));
        }
示例#8
0
        /// <summary>
        /// Locks the entire canvas for direct access.
        /// </summary>
        /// <param name="readOnly">Specifies that the lock is read-only.</param>
        /// <returns>An array containing the 32-bit pixel values of the canvas.</returns>
        public int[] Lock(bool readOnly)
        {
            LockFlags flags = LockFlags.None;

            if (readOnly)
            {
                flags |= LockFlags.ReadOnly;
            }
            return(tex.LockRectangle(typeof(int), 0, flags, size) as int[]);
        }
示例#9
0
        /// <summary>
        /// Locks the specified index buffer.
        /// </summary>
        /// <param name="offsetToLock">The offset in the buffer.</param>
        /// <param name="sizeToLock">The size of the buffer to lock.</param>
        /// <param name="lockFlags">The lock flags.</param>
        /// <returns>A <see cref="SharpDX.DataStream" /> containing the locked index buffer.</returns>
        /// <msdn-id>bb205867</msdn-id>	
        /// <unmanaged>HRESULT IDirect3DIndexBuffer9::Lock([In] unsigned int OffsetToLock,[In] unsigned int SizeToLock,[Out] void** ppbData,[In] D3DLOCK Flags)</unmanaged>	
        /// <unmanaged-short>IDirect3DIndexBuffer9::Lock</unmanaged-short>	
        public SharpDX.DataStream Lock(int offsetToLock, int sizeToLock, LockFlags lockFlags)
        {
            IntPtr pOut;
            if (sizeToLock == 0)
                sizeToLock = Description.Size;

            Lock(offsetToLock, sizeToLock, out pOut, lockFlags);

            return new DataStream(pOut, sizeToLock, true, (lockFlags & LockFlags.ReadOnly) == 0);
        }
示例#10
0
        public unsafe Span <T> Lock <T>(int offsetToLock, int sizeToLock, LockFlags lockFlags = LockFlags.None) where T : unmanaged
        {
            if (sizeToLock == 0)
            {
                sizeToLock = Description.SizeInBytes;
            }

            Lock(offsetToLock, sizeToLock, out var pOut, lockFlags);
            return(new Span <T>(pOut.ToPointer(), sizeToLock));
        }
示例#11
0
        public LockedRectangle LockRectangle(int level, D3DRect rect, LockFlags flags)
        {
            LockedRectangle lockedRect = new LockedRectangle();
            int             res        = Interop.Calli(comPointer, level, (IntPtr)(void *)&lockedRect, (IntPtr)(void *)&rect, (int)flags, (*(IntPtr **)comPointer)[19]);

            if (res < 0)
            {
                throw new SharpDXException(res);
            }
            return(lockedRect);
        }
示例#12
0
    public unsafe static class DataBuffser {     // Either 'VertexBuffer' or 'IndexBuffer
        public static IntPtr Lock(IntPtr ptr, int offsetToLock, int sizeToLock, LockFlags flags)
        {
            IntPtr data;
            int    res = Interop.Calli(ptr, offsetToLock, sizeToLock, (IntPtr)(void *)&data, (int)flags, (*(IntPtr **)ptr)[11]);

            if (res < 0)
            {
                throw new SharpDXException(res);
            }
            return(data);
        }
示例#13
0
        public static LockedRectangle LockRectangle(IntPtr ptr, int level, LockFlags flags)
        {
            LockedRectangle rect = new LockedRectangle();
            int             res  = Interop.Calli(ptr, level, (IntPtr)(void *)&rect, IntPtr.Zero, (int)flags, (*(IntPtr **)ptr)[19]);

            if (res < 0)
            {
                throw new SharpDXException(res);
            }
            return(rect);
        }
示例#14
0
        public IntPtr Lock(int offsetToLock, int sizeToLock, LockFlags flags)
        {
            IntPtr pOut;
            int    res = Interop.Calli(comPointer, offsetToLock, sizeToLock, (IntPtr)(void *)&pOut, (int)flags, (*(IntPtr **)comPointer)[11]);

            if (res < 0)
            {
                throw new SharpDXException(res);
            }
            return(pOut);
        }
示例#15
0
        /// <summary>
        /// Locks the specified index buffer.
        /// </summary>
        /// <param name="offsetToLock">The offset in the buffer.</param>
        /// <param name="sizeToLock">The size of the buffer to lock.</param>
        /// <param name="lockFlags">The lock flags.</param>
        /// <returns>A <see cref="SharpDX.DataStream" /> containing the locked index buffer.</returns>
        /// <msdn-id>bb205867</msdn-id>
        /// <unmanaged>HRESULT IDirect3DIndexBuffer9::Lock([In] unsigned int OffsetToLock,[In] unsigned int SizeToLock,[Out] void** ppbData,[In] D3DLOCK Flags)</unmanaged>
        /// <unmanaged-short>IDirect3DIndexBuffer9::Lock</unmanaged-short>
        public IntPtr LockToPointer(int offsetToLock, int sizeToLock, LockFlags lockFlags)
        {
            IntPtr pOut;

            if (sizeToLock == 0)
            {
                sizeToLock = Description.Size;
            }

            Lock(offsetToLock, sizeToLock, out pOut, lockFlags);

            return(pOut);
        }
示例#16
0
        /// <summary>
        /// Locks the specified index buffer.
        /// </summary>
        /// <param name="offsetToLock">The offset in the buffer.</param>
        /// <param name="sizeToLock">The size of the buffer to lock.</param>
        /// <param name="lockFlags">The lock flags.</param>
        /// <returns>A <see cref="SharpDX.DataStream" /> containing the locked index buffer.</returns>
        /// <msdn-id>bb205867</msdn-id>
        /// <unmanaged>HRESULT IDirect3DIndexBuffer9::Lock([In] unsigned int OffsetToLock,[In] unsigned int SizeToLock,[Out] void** ppbData,[In] D3DLOCK Flags)</unmanaged>
        /// <unmanaged-short>IDirect3DIndexBuffer9::Lock</unmanaged-short>
        public SharpDX.DataStream Lock(int offsetToLock, int sizeToLock, LockFlags lockFlags)
        {
            IntPtr pOut;

            if (sizeToLock == 0)
            {
                sizeToLock = Description.Size;
            }

            Lock(offsetToLock, sizeToLock, out pOut, lockFlags);

            return(new DataStream(pOut, sizeToLock, true, (lockFlags & LockFlags.ReadOnly) == 0));
        }
示例#17
0
        /// <summary>
        /// Discard is valid only for dynamic buffers
        /// </summary>
        public static void SetData <T>(this VertexBuffer vertexBuffer, T[] data, LockFlags flags = LockFlags.None, int numDataToWrite = -1)
            where T : struct
        {
            if (numDataToWrite == -1)
            {
                numDataToWrite = data.Length;
            }

            int itemSize = Utilities.SizeOf <T>();
            var ptr      = vertexBuffer.LockToPointer(0, itemSize * numDataToWrite, flags);

            Utilities.Write(ptr, data, 0, numDataToWrite);
            vertexBuffer.Unlock();
        }
示例#18
0
        /// <summary>
        /// Writes data to the buffer.
        /// </summary>
        /// <returns />
        public void Read <T>(T[] data, int startIndex, int count, int bufferOffset, LockFlags flags) where T : struct
        {
            DataStream stream2 = null;
            //Utilities.CheckArrayBounds(data, startIndex, ref count);
            int        bytes   = Utilities.SizeOf <T>() * count;
            DataStream stream1 = this.Lock(bufferOffset, bytes, flags, out stream2);
            int        count1  = (int)(((long)((int)stream1.Length)) / (Utilities.SizeOf <T>()));

            stream1.ReadRange(data, startIndex, count1);
            if ((stream2 != null) && (count > count1))
            {
                stream2.ReadRange <T>(data, count1 + startIndex, count - count1);
            }
            Unlock(stream1, stream2);
        }
示例#19
0
        /// <summary>
        /// The Lock method locks a portion of the buffer. Locking the buffer returns references into the buffer, allowing the application to read or write audio data into memory.
        /// </summary>
        /// <param name="offset">Offset, in bytes, from the start of the buffer to the point where the lock begins. </param>
        /// <param name="sizeBytes">Size, in bytes, of the portion of the buffer to lock. Because the buffer is conceptually circular, this number can exceed the number of bytes between dwOffset and the end of the buffer. </param>
        /// <param name="flags"> Flags modifying the lock event. The following flags are defined:  ValueDescription DSBLOCK_FROMWRITECURSORStart the lock at the write cursor. The dwOffset parameter is ignored. DSBLOCK_ENTIREBUFFERLock the entire buffer. The dwBytes parameter is ignored.  </param>
        /// <param name="secondPart"> Address of a variable that receives a pointer to the second locked part of the capture buffer. If NULL is returned, the ppvAudioPtr1 parameter points to the entire locked portion of the capture buffer. </param>
        /// <returns>Address of a variable that receives a pointer to the first locked part of the buffer.</returns>
        /// <unmanaged>HRESULT IDirectSoundCaptureBuffer::Lock([None] int dwOffset,[None] int dwBytes,[Out] void** ppvAudioPtr1,[Out] int* pdwAudioBytes1,[Out] void** ppvAudioPtr2,[Out, Optional] int* pdwAudioBytes2,[None] int dwFlags)</unmanaged>
        public DataStream Lock(int offset, int sizeBytes, LockFlags flags, out DataStream secondPart)
        {
            IntPtr dataPart1;
            int    sizePart1;
            IntPtr dataPart2;
            int    sizePart2;

            Lock(offset, sizeBytes, out dataPart1, out sizePart1, out dataPart2, out sizePart2, (int)flags);

            secondPart = null;
            if (dataPart2 != IntPtr.Zero)
            {
                secondPart = new DataStream(dataPart2, sizePart2, true, true);
            }

            return(new DataStream(dataPart1, sizePart1, true, true));
        }
示例#20
0
        /// <summary>
        /// Acceder al VertexBuffer del mesh.
        /// Una vez que se termina de trabajar con el buffer se debe invocar siempre a unlock.
        /// </summary>
        /// <param name="lockFlags">Flags de lectura del buffer</param>
        /// <returns>array de elementos</returns>
        public Array lockVertexBuffer(LockFlags lockFlags)
        {
            switch (renderType)
            {
            case MeshRenderType.VERTEX_COLOR:
                return((TgcSceneLoader.VertexColorVertex[])d3dMesh.LockVertexBuffer(
                           typeof(TgcSceneLoader.VertexColorVertex), lockFlags, d3dMesh.NumberVertices));

            case MeshRenderType.DIFFUSE_MAP:
                return((TgcSceneLoader.DiffuseMapVertex[])d3dMesh.LockVertexBuffer(
                           typeof(TgcSceneLoader.DiffuseMapVertex), lockFlags, d3dMesh.NumberVertices));

            case MeshRenderType.DIFFUSE_MAP_AND_LIGHTMAP:
                return((TgcSceneLoader.DiffuseMapAndLightmapVertex[])d3dMesh.LockVertexBuffer(
                           typeof(TgcSceneLoader.DiffuseMapAndLightmapVertex), lockFlags, d3dMesh.NumberVertices));
            }
            return(null);
        }
示例#21
0
        public void SetPartData(int level, LockFlags flags, IntPtr data, int x, int y, int width, int height)
        {
            D3DRect partRect;

            partRect.Left  = x; partRect.Top = y;
            partRect.Right = x + width; partRect.Bottom = y + height;
            LockedRectangle rect = LockRectangle(level, partRect, flags);

            // We need to copy scanline by scanline, as generally rect.stride != data.stride
            byte *src = (byte *)data, dst = (byte *)rect.DataPointer;

            for (int yy = 0; yy < height; yy++)
            {
                MemUtils.memcpy((IntPtr)src, (IntPtr)dst, width * 4);
                src += width * 4;
                dst += rect.Pitch;
            }
            UnlockRectangle(level);
        }
示例#22
0
 /// <summary>
 /// Writes data to the buffer.
 /// </summary>
 /// <returns />
 public void Read <T>(T[] data, int bufferOffset, LockFlags flags) where T : struct
 {
     this.Read <T>(data, 0, 0, bufferOffset, flags);
 }
示例#23
0
 public DataRectangle LockRectangle(int level, Rectangle rectangle, LockFlags flags, out DataStream stream)
 {
     return _texture.LockRectangle(level, rectangle, flags, out stream);
 }
 /// <summary>
 /// Locks a box on a volume resource.
 /// </summary>
 /// <param name="flags">The lock flags.</param>
 /// <returns>The locked region of this resource.</returns>
 public DataBox LockBox(LockFlags flags)
 {
     LockBox(out LockedBox lockedBox, IntPtr.Zero, flags);
     return(new DataBox(lockedBox.PBits, lockedBox.RowPitch, lockedBox.SlicePitch));
 }
示例#25
0
 public unsafe Array LockVertexBuffer(Type typeVertex, LockFlags flags, params int[] ranks)
 {
     throw new NotImplementedException();
 }
 internal static extern int /* HRESULT */ Lock( 
     System.Windows.Media.SafeMILHandle /* IWICBitmap */ THIS_PTR,
     ref Int32Rect prcLock,
     LockFlags flags,
     out SafeMILHandle /* IWICBitmapLock* */ ppILock); 
示例#27
0
 /// <summary>
 /// Locks a box on a volume resource.
 /// </summary>
 /// <param name="box">The box.</param>
 /// <param name="flags">The flags.</param>
 /// <returns>The locked region of this resource</returns>
 /// <unmanaged>HRESULT IDirect3DVolume9::LockBox([Out] D3DLOCKED_BOX* pLockedVolume,[In] const void* pBox,[In] D3DLOCK Flags)</unmanaged>
 public DataBox LockBox(Box box, LockFlags flags)
 {
     unsafe
     {
         LockedBox lockedBox;
         LockBox(out lockedBox, new IntPtr(&box), flags);
         return new DataBox(lockedBox.PBits, lockedBox.RowPitch, lockedBox.SlicePitch);
     }
 }
示例#28
0
    public void LockVector(int locker, LockFlags flags, LockRequest[] list) {
      DbRetVal ret; 
      int failedIndx;

      // allocate the arguments we need to pass
      DBT* objs = stackalloc DBT[list.Length];
      DB_LOCKREQ* lockReqs = stackalloc DB_LOCKREQ[list.Length];
      // calculate object buffer size and allocate on stack
      int objSize = 0;
      for (int indx = 0; indx < list.Length; indx++)
        objSize += list[indx].Obj.Size;
      byte* objBuf = stackalloc byte[objSize];

      // configure all DB_LOCKREQ instances
      DBT* currObjp = objs;
      byte* currObjBuf = objBuf;
      for (int indx = 0; indx < list.Length; indx++) {
        lockReqs[indx] = list[indx].PrepareLockReq(currObjp, ref currObjBuf);
        currObjp++;
      }

      // perform call into BDB
      lock (rscLock) {
        DB_ENV* evp = CheckDisposed();
        DB_LOCKREQ* lastp;
        ret = evp->LockVector(evp, unchecked((uint)locker), unchecked((UInt32)flags),
          lockReqs, list.Length, out lastp);
        if (ret != DbRetVal.SUCCESS)
          failedIndx = (int)(lastp - lockReqs);
        else
          failedIndx = list.Length;
      }

      // assign the acquired locks back to the initial LockRequest instances
      for (int indx = 0; indx < failedIndx; indx++) {
        LockOperation op = list[indx].Op;
        if (op == LockOperation.Acquire || op == LockOperation.AcquireTimeout)
          list[indx].lck = new Lock(lockReqs[indx].dblock);
      }

      if (ret != DbRetVal.SUCCESS)
        ThrowLockException(ret, failedIndx);
    }
示例#29
0
 public unsafe virtual LockData Lock(LockFlags flags)
 {
     Texture texture = this.CoreGetSurface();
     if (texture == null)
     {
         return new LockData();
     }
     LockFlags flags2 = 0x800;
     if (flags == LockFlags.ReadOnly)
     {
         flags2 |= 0x10;
     }
     int num = 0;
     GraphicsStream stream = texture.LockRectangle(0, flags2, ref num);
     LockData data = new LockData {
         Pitch = num,
         pvSrc = (void*) stream.get_InternalData(),
         Height = this.Height,
         Width = this.Width
     };
     this.m_LockStream = stream;
     return data;
 }
示例#30
0
文件: Surface.cs 项目: rbernon/monoDX
 public Array LockRectangle(Type typeLock, LockFlags flags, params int[] ranks)
 {
     throw new NotImplementedException();
 }
示例#31
0
文件: Surface.cs 项目: rbernon/monoDX
 public GraphicsStream LockRectangle(LockFlags flags)
 {
     throw new NotImplementedException();
 }
示例#32
0
 /// <summary>
 /// Acceder al VertexBuffer del mesh.
 /// Una vez que se termina de trabajar con el buffer se debe invocar siempre a unlock.
 /// </summary>
 /// <param name="lockFlags">Flags de lectura del buffer</param>
 /// <returns>array de elementos</returns>
 public Array lockVertexBuffer(LockFlags lockFlags)
 {
     switch (renderType)
     {
         case MeshRenderType.VERTEX_COLOR:
             return (TgcSceneLoader.VertexColorVertex[])d3dMesh.LockVertexBuffer(
                     typeof(TgcSceneLoader.VertexColorVertex), lockFlags, d3dMesh.NumberVertices);
         case MeshRenderType.DIFFUSE_MAP:
             return (TgcSceneLoader.DiffuseMapVertex[])d3dMesh.LockVertexBuffer(
                     typeof(TgcSceneLoader.DiffuseMapVertex), lockFlags, d3dMesh.NumberVertices);
         case MeshRenderType.DIFFUSE_MAP_AND_LIGHTMAP:
             return (TgcSceneLoader.DiffuseMapAndLightmapVertex[])d3dMesh.LockVertexBuffer(
                     typeof(TgcSceneLoader.DiffuseMapAndLightmapVertex), lockFlags, d3dMesh.NumberVertices);
     }
     return null;
 }
示例#33
0
 public Array LockIndexBuffer(Type typeIndex, LockFlags flags, params int[] ranks)
 {
     throw new NotImplementedException();
 }
示例#34
0
        /// <summary>
        /// Locks the specified index buffer.
        /// </summary>
        /// <param name="offsetToLock">The offset in the buffer.</param>
        /// <param name="sizeToLock">The size of the buffer to lock.</param>
        /// <param name="lockFlags">The lock flags.</param>
        /// <returns>A <see cref="SharpDX.DataStream" /> containing the locked index buffer.</returns>
        /// <msdn-id>bb205867</msdn-id>	
        /// <unmanaged>HRESULT IDirect3DIndexBuffer9::Lock([In] unsigned int OffsetToLock,[In] unsigned int SizeToLock,[Out] void** ppbData,[In] D3DLOCK Flags)</unmanaged>	
        /// <unmanaged-short>IDirect3DIndexBuffer9::Lock</unmanaged-short>	
        public IntPtr LockToPointer(int offsetToLock, int sizeToLock, LockFlags lockFlags)
        {
            IntPtr pOut;
            if (sizeToLock == 0)
                sizeToLock = Description.Size;

            Lock(offsetToLock, sizeToLock, out pOut, lockFlags);

            return pOut;
        }
示例#35
0
 public DataRectangle LockRectangle(int level, Rectangle rectangle, LockFlags flags)
 {
     return _texture.LockRectangle(level, rectangle, flags);
 }
示例#36
0
        /// <summary>
        /// Locks a box on a volume resource.
        /// </summary>
        /// <param name="flags">The flags.</param>
        /// <returns>
        /// The locked region of this resource
        /// </returns>
        /// <unmanaged>HRESULT IDirect3DVolume9::LockBox([Out] D3DLOCKED_BOX* pLockedVolume,[In] const void* pBox,[In] D3DLOCK Flags)</unmanaged>
        public DataBox LockBox(LockFlags flags)
        {

            LockedBox lockedBox;
            LockBox(out lockedBox, IntPtr.Zero, flags);
            return new DataBox(lockedBox.PBits, lockedBox.RowPitch, lockedBox.SlicePitch);
        }
示例#37
0
 public GraphicsStream LockVertexBuffer(LockFlags flags)
 {
     throw new NotImplementedException();
 }
示例#38
0
 public int[] LockAttributeBufferArray(LockFlags flags)
 {
     throw new NotImplementedException();
 }
示例#39
0
 public void SetIndexBufferData(object data, LockFlags flags)
 {
     throw new NotImplementedException();
 }
示例#40
0
文件: Surface.cs 项目: rbernon/monoDX
 public GraphicsStream LockRectangle(Rectangle rect, LockFlags flags, out int pitch)
 {
     throw new NotImplementedException();
 }
示例#41
0
 public GraphicsStream LockAttributeBuffer(LockFlags flags)
 {
     throw new NotImplementedException();
 }
示例#42
0
 public Lock AcquireLock(int locker, LockFlags flags, ref DbEntry obj, LockMode mode) {
   DbRetVal ret;
   Lock lck = new Lock();
   lock (rscLock) {
     DB_ENV* evp = CheckDisposed();
     fixed (byte* objBufP = obj.Buffer) {
       obj.dbt.data = objBufP + obj.Start;
       ret = evp->LockGet(evp, unchecked((uint)locker), unchecked((uint)flags), ref obj.dbt, (DB_LOCKMODE)mode, ref lck.dblck);
     }
   }
   if (ret != DbRetVal.SUCCESS)
     ThrowLockException(ret, -1);
   return lck;
 }