/// <summary> /// /// </summary> public VertexBufferLicense(HardwareVertexBuffer originalBuffer, BufferLicenseRelease licenseType, int expiredDelay, HardwareVertexBuffer buffer, IHardwareBufferLicensee licensee) { this.originalBuffer = originalBuffer; this.licenseType = licenseType; this.expiredDelay = expiredDelay; this.buffer = buffer; this.licensee = licensee; }
/// <summary> /// Allocates a copy of a given vertex buffer. /// </summary> /// <remarks> /// This method allocates a temporary copy of an existing vertex buffer. /// This buffer is subsequently stored and can be made available for /// other purposes later without incurring the cost of construction / /// destruction. /// </remarks> /// <param name="sourceBuffer">The source buffer to use as a copy.</param> /// <param name="licenseType"> /// The type of license required on this buffer - automatic /// release causes this class to release licenses every frame so that /// they can be reallocated anew. /// </param> /// <param name="licensee"> /// Reference back to the class requesting the copy, which must /// implement <see cref="IHardwareBufferLicense"/> in order to be notified when the license /// expires. /// </param> /// <param name="copyData">If true, the current data is copied as well as the structure of the buffer.</param> /// <returns></returns> public virtual HardwareVertexBuffer AllocateVertexBufferCopy(HardwareVertexBuffer sourceBuffer, BufferLicenseRelease licenseType, IHardwareBufferLicensee licensee, bool copyData) { HardwareVertexBuffer vbuf = null; // Locate existing buffer copy in free list IList list = (IList)freeTempVertexBufferMap[sourceBuffer]; if (list == null) { list = new ArrayList(); freeTempVertexBufferMap[sourceBuffer] = list; } // Are there any free buffers? if (list.Count == 0) { // copy buffer, use shadow buffer and make dynamic vbuf = MakeBufferCopy(sourceBuffer, BufferUsage.DynamicWriteOnly, true); } else { // grab the available buffer and remove it from the free list int lastIndex = list.Count - 1; vbuf = (HardwareVertexBuffer)list[lastIndex]; list.RemoveAt(lastIndex); } // Copy data? if (copyData) { vbuf.CopyData(sourceBuffer, 0, 0, sourceBuffer.Size, true); } // Insert copy into licensee list tempVertexBufferLicenses.Add(new VertexBufferLicense(sourceBuffer, licenseType, expiredDelayFrameThreshold, vbuf, licensee)); return(vbuf); }
//public override RegisterVertexBufferSourceAndCopy( HardwareVertexBuffer sourceBuffer, HardwareVertexBuffer copy ) //{ //} public override HardwareVertexBuffer AllocateVertexBufferCopy( HardwareVertexBuffer sourceBuffer, BufferLicenseRelease licenseType, IHardwareBufferLicensee licensee, bool copyData ) { return _baseInstance.AllocateVertexBufferCopy( sourceBuffer, licenseType, licensee, copyData ); }
public override HardwareVertexBuffer AllocateVertexBufferCopy( HardwareVertexBuffer sourceBuffer, BufferLicenseRelease licenseType, #if NET_40 IHardwareBufferLicensee licensee, bool copyData = false )
/// <summary> /// Allocates a copy of a given vertex buffer. /// </summary> /// <remarks> /// This method allocates a temporary copy of an existing vertex buffer. /// This buffer is subsequently stored and can be made available for /// other purposes later without incurring the cost of construction / /// destruction. /// </remarks> /// <param name="sourceBuffer">The source buffer to use as a copy.</param> /// <param name="licenseType"> /// The type of license required on this buffer - automatic /// release causes this class to release licenses every frame so that /// they can be reallocated anew. /// </param> /// <param name="licensee"> /// Reference back to the class requesting the copy, which must /// implement <see cref="IHardwareBufferLicense"/> in order to be notified when the license /// expires. /// </param> /// <returns></returns> public virtual HardwareVertexBuffer AllocateVertexBufferCopy(HardwareVertexBuffer sourceBuffer, BufferLicenseRelease licenseType, IHardwareBufferLicensee licensee) { return(AllocateVertexBufferCopy(sourceBuffer, licenseType, licensee, false)); }
public virtual HardwareVertexBuffer AllocateVertexBufferCopy(HardwareVertexBuffer sourceBuffer, BufferLicenseRelease licenseType, #if NET_40 IHardwareBufferLicensee licensee, bool copyData = false)
/// <summary> /// Allocates a copy of a given vertex buffer. /// </summary> /// <remarks> /// This method allocates a temporary copy of an existing vertex buffer. /// This buffer is subsequently stored and can be made available for /// other purposes later without incurring the cost of construction / /// destruction. /// </remarks> /// <param name="sourceBuffer">The source buffer to use as a copy.</param> /// <param name="licenseType"> /// The type of license required on this buffer - automatic /// release causes this class to release licenses every frame so that /// they can be reallocated anew. /// </param> /// <param name="licensee"> /// Reference back to the class requesting the copy, which must /// implement <see cref="IHardwareBufferLicense"/> in order to be notified when the license /// expires. /// </param> /// <param name="copyData">If true, the current data is copied as well as the structure of the buffer.</param> /// <returns></returns> public virtual HardwareVertexBuffer AllocateVertexBufferCopy(HardwareVertexBuffer sourceBuffer, BufferLicenseRelease licenseType, IHardwareBufferLicensee licensee, bool copyData) { HardwareVertexBuffer vbuf = null; // Locate existing buffer copy in free list IList list = (IList)freeTempVertexBufferMap[sourceBuffer]; if(list == null) { list = new ArrayList(); freeTempVertexBufferMap[sourceBuffer] = list; } // Are there any free buffers? if(list.Count == 0) { // copy buffer, use shadow buffer and make dynamic vbuf = MakeBufferCopy(sourceBuffer, BufferUsage.DynamicWriteOnly, true); } else { // grab the available buffer and remove it from the free list int lastIndex = list.Count - 1; vbuf = (HardwareVertexBuffer)list[lastIndex]; list.RemoveAt(lastIndex); } // Copy data? if(copyData) { vbuf.CopyData(sourceBuffer, 0, 0, sourceBuffer.Size, true); } // Insert copy into licensee list tempVertexBufferLicenses.Add(new VertexBufferLicense(sourceBuffer, licenseType, expiredDelayFrameThreshold, vbuf, licensee)); return vbuf; }
/// <summary> /// Allocates a copy of a given vertex buffer. /// </summary> /// <remarks> /// This method allocates a temporary copy of an existing vertex buffer. /// This buffer is subsequently stored and can be made available for /// other purposes later without incurring the cost of construction / /// destruction. /// </remarks> /// <param name="sourceBuffer">The source buffer to use as a copy.</param> /// <param name="licenseType"> /// The type of license required on this buffer - automatic /// release causes this class to release licenses every frame so that /// they can be reallocated anew. /// </param> /// <param name="licensee"> /// Reference back to the class requesting the copy, which must /// implement <see cref="IHardwareBufferLicense"/> in order to be notified when the license /// expires. /// </param> /// <returns></returns> public virtual HardwareVertexBuffer AllocateVertexBufferCopy(HardwareVertexBuffer sourceBuffer, BufferLicenseRelease licenseType, IHardwareBufferLicensee licensee) { return AllocateVertexBufferCopy(sourceBuffer, licenseType, licensee, false); }