public BufferObject(Device dev, uint _width, uint _height, SurfaceFormat format, SurfaceFlags flags) { handle = gbm_bo_create(dev.Handle, _width, _height, format, flags); if (handle == null) { throw new NotSupportedException("[GBM] BO creation failed."); } }
protected virtual void Dispose(bool disposing) { if (handle != null) { gbm_bo_destroy(handle); } handle = null; }
public gbm_bo *Lock() { gbm_bo *bo = gbm_surface_lock_front_buffer(handle); if (bo == null) { throw new Exception("[GBM]: Failed to lock front buffer."); } return(bo); }
private void Lock(Action <BufferObject, uint> action) { unsafe { var lastBo = this.boHandle; this.boHandle = gbm_surface_lock_front_buffer(this.surfaceHandle); if (this.boHandle == null) { throw new Exception("[GBM]: Failed to lock front buffer."); } var bo = new BufferObject(this.boHandle); action?.Invoke(bo, bo.GetFb(this.Device)); if (lastBo is not null) { this.Release(lastBo); } } }
internal static extern ulong gbm_bo_get_modifier(gbm_bo *bo);
static extern void gbm_surface_release_buffer(gbm_surface *surface, gbm_bo *bo);
internal static extern int gbm_bo_get_plane_count(gbm_bo *bo);
internal static extern nint gbm_bo_map(gbm_bo *bo, uint x, uint y, uint width, uint height, TransferFlags flags, ref uint stride, out nint data);
internal static extern void gbm_bo_set_user_data(gbm_bo *bo, nint data, DestroyUserDataCallback callback);
internal static extern gbm_device *gbm_bo_get_device(gbm_bo *bo);
internal static extern int gbm_bo_write(gbm_bo *bo, nint buf, nint count);
internal static extern void gbm_bo_destroy(gbm_bo *bo);
public void Release(gbm_bo *bo) { gbm_surface_release_buffer(handle, bo); }
static extern void gbm_surface_release_buffer(IntPtr surface, gbm_bo *buffer);
internal static extern int gbm_bo_write(gbm_bo *bo, IntPtr buf, IntPtr count);
internal static extern uint gbm_bo_get_stride_for_plane(gbm_bo *bo, int plane);
internal static extern uint gbm_bo_get_offset(gbm_bo *bo, int plane);
internal static extern gbm_bo_handle gbm_bo_get_handle_for_plane(gbm_bo *bo, int plane);
internal static extern nint gbm_bo_get_user_data(gbm_bo *bo);
internal static extern gbm_bo_handle gbm_bo_get_handle(gbm_bo *bo);
internal static extern void gbm_bo_unmap(gbm_bo *bo, nint data);
internal static extern uint gbm_bo_get_height(gbm_bo *bo);
public BufferObject(gbm_bo *handle) { this.handle = handle; }
internal static extern uint gbm_bo_get_width(gbm_bo *bo);
private void Release(gbm_bo *bo) { gbm_surface_release_buffer(surfaceHandle, bo); }
internal static extern uint gbm_bo_get_stride(gbm_bo *bo);
internal static extern SurfaceFormat gbm_bo_get_format(gbm_bo *bo);
public BufferObject(gbm_bo *_handle) { handle = _handle; }