mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-02-06 18:31:57 +08:00
New API: GetSurfaceHandle, driGetDeviceFD, driGetSurfaceInfo; Tune operations of DriDriverOps
This commit is contained in:
@@ -96,15 +96,17 @@ typedef struct _DriDriver DriDriver;
|
||||
* MiniGUI NEWGAL engine for hardware surface.
|
||||
*/
|
||||
typedef struct _DriSurfaceBuffer {
|
||||
uint32_t buff_id;
|
||||
uint32_t handle;
|
||||
uint32_t id;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t pitch;
|
||||
|
||||
uint32_t drm_format;
|
||||
|
||||
uint16_t bpp:8;
|
||||
uint16_t cpp:8;
|
||||
|
||||
unsigned long size;
|
||||
uint8_t* pixels;
|
||||
} DriSurfaceBuffer;
|
||||
|
||||
@@ -157,8 +159,8 @@ typedef struct _DriDriverOps {
|
||||
|
||||
/**
|
||||
* This operation creates a buffer with the specified pixel format,
|
||||
* width, and height. If succeed, a valid (not zero) buffer identifier
|
||||
* and the picth (row stride in bytes) will be returned.
|
||||
* width, and height. If succeed, a valid (not zero) buffer identifier,
|
||||
* the picth (row stride in bytes), and the handle will be returned.
|
||||
* If failed, it returns 0.
|
||||
*
|
||||
* \note The driver must implement this operation.
|
||||
@@ -168,6 +170,20 @@ typedef struct _DriDriverOps {
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned int *pitch);
|
||||
|
||||
/**
|
||||
* This operation creates a buffer for the given system global name
|
||||
* with the specified pixel format, width, and height. If succeed,
|
||||
* a valid (not zero) buffer identifier,
|
||||
* the picth (row stride in bytes), and the handle will be returned.
|
||||
* If failed, it returns 0.
|
||||
*
|
||||
* \note The driver must implement this operation.
|
||||
*/
|
||||
uint32_t (* create_buffer_from_name) (DriDriver *driver,
|
||||
uint32_t name, uint32_t drm_format,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned int *pitch);
|
||||
|
||||
BOOL (* fetch_buffer) (DriDriver *driver,
|
||||
uint32_t buffer_id,
|
||||
unsigned int *width, unsigned int *height,
|
||||
|
||||
@@ -13646,6 +13646,18 @@ MG_EXPORT int GUIAPI SetUserCompositionOps (HDC hdc,
|
||||
CB_COMP_PUTHLINE comp_puthline,
|
||||
void* user_comp_ctxt);
|
||||
|
||||
/**
|
||||
* This function gets the handle to the surface which corresponds to the given
|
||||
* device context.
|
||||
*
|
||||
* \param hdc The device context.
|
||||
*
|
||||
* \return The handle to the surface; NULL on error.
|
||||
*
|
||||
* Since 4.0.3.
|
||||
*/
|
||||
MG_EXPORT GHANDLE GetSurfaceHandle (HDC hdc);
|
||||
|
||||
#ifdef _MGGAL_DRI
|
||||
|
||||
/**
|
||||
@@ -13668,50 +13680,44 @@ MG_EXPORT int GUIAPI SetUserCompositionOps (HDC hdc,
|
||||
/**
|
||||
* This function gets the file descriptor opened by the Linux DRI engine.
|
||||
*
|
||||
* \param screen_dc \a HDC_SCREEN or the DC returned by \a InitSlaveScreen or
|
||||
* \a InitSlaveScreenEx
|
||||
* \param surface The handle to a surface returned by \a GetSurfaceHandle.
|
||||
*
|
||||
* \return The file descriptor opened by the Linux DRI engine; >= 0 for success
|
||||
* and <0 on error. If \a screen_dc is not a DC created by the DRI engine,
|
||||
* this function returns -1.
|
||||
* \return The DRI device file descriptor opened by the Linux DRI engine;
|
||||
* >= 0 for success and < 0 on error. If \a surface is not a hardware
|
||||
* surface created by the DRI engine, this function returns -1.
|
||||
*/
|
||||
MG_EXPORT int GetDRIDeviceFD (HDC screen_dc);
|
||||
MG_EXPORT int driGetDeviceFD (GHANDLE surface);
|
||||
|
||||
/**
|
||||
* THe struct type defines the DRI surface information.
|
||||
*/
|
||||
typedef struct _DriSurfaceInfo {
|
||||
/** The local handle of the buffer object. */
|
||||
uint32_t handle;
|
||||
/** The buffer identifier. */
|
||||
uint32_t buff_id;
|
||||
/** The buffer name if it has a name. */
|
||||
uint32_t name;
|
||||
uint32_t id;
|
||||
/** The width of the surface. */
|
||||
uint32_t width;
|
||||
/** The height of the surface. */
|
||||
uint32_t height;
|
||||
/** The row stride of the surface. */
|
||||
uint32_t pitch;
|
||||
|
||||
/** The DRM pixel format. */
|
||||
uint32_t drm_format;
|
||||
|
||||
/** The bits per pixel */
|
||||
uint16_t bpp:8;
|
||||
|
||||
/** The bytes per pixel */
|
||||
uint16_t cpp:8;
|
||||
/** Size in bytes of the buffer object. */
|
||||
unsigned long size;
|
||||
} DriSurfaceInfo;
|
||||
|
||||
/**
|
||||
* This function gets the DRI surface information from a DC.
|
||||
* This function gets the DRI surface information from the handle of the surface.
|
||||
*
|
||||
* \param dc The device context.
|
||||
* \param surface The handle to the surface.
|
||||
* \param info The pointer to a DriSurfaceInfo structure to hold
|
||||
* the surface information.
|
||||
*
|
||||
* \return TRUE for success, FALSE for failure.
|
||||
*/
|
||||
MG_EXPORT BOOL GetDIMSurfaceInfoFromDC (HDC hdc, DriSurfaceInfo* info);
|
||||
MG_EXPORT BOOL driGetSurfaceInfo (GHANDLE surface, DriSurfaceInfo* info);
|
||||
|
||||
/** @} end of gdi_dri_fns */
|
||||
|
||||
|
||||
@@ -1539,7 +1539,7 @@ static void DRI_FreeHWSurface_Accl(_THIS, GAL_Surface *surface)
|
||||
surface_buffer = (DriSurfaceBuffer*)surface->hwdata;
|
||||
if (surface_buffer) {
|
||||
vdata->driver_ops->unmap_buffer(vdata->driver, surface_buffer);
|
||||
vdata->driver_ops->destroy_buffer(vdata->driver, surface_buffer->buff_id);
|
||||
vdata->driver_ops->destroy_buffer(vdata->driver, surface_buffer->id);
|
||||
}
|
||||
|
||||
surface->pixels = NULL;
|
||||
@@ -1653,5 +1653,40 @@ static int DRI_SetHWAlpha_Accl(_THIS, GAL_Surface *surface, Uint8 value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
MG_EXPORT int driGetDeviceFD (GHANDLE surface)
|
||||
{
|
||||
GAL_VideoDevice *this = (GAL_VideoDevice *)((GAL_Surface*)surface)->video;
|
||||
if (this && this->VideoInit == DRI_VideoInit) {
|
||||
DriVideoData* vdata = this->hidden;
|
||||
return vdata->dev_fd;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
MG_EXPORT BOOL driGetSurfaceInfo (GHANDLE surface_handle, DriSurfaceInfo* info)
|
||||
{
|
||||
GAL_Surface *surface = (GAL_Surface*)surface_handle;
|
||||
GAL_VideoDevice *this = (GAL_VideoDevice *)surface->video;
|
||||
|
||||
if (this && this->VideoInit == DRI_VideoInit &&
|
||||
(surface->flags & GAL_HWSURFACE)) {
|
||||
DriSurfaceBuffer* surface_buffer = (DriSurfaceBuffer*)surface->hwdata;
|
||||
|
||||
if (surface_buffer) {
|
||||
info->handle = surface_buffer->handle;
|
||||
info->id = surface_buffer->id;
|
||||
info->width = surface_buffer->width;
|
||||
info->height = surface_buffer->height;
|
||||
info->pitch = surface_buffer->pitch;
|
||||
info->drm_format = surface_buffer->drm_format;
|
||||
info->size = surface_buffer->size;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* _MGGAL_DRI */
|
||||
|
||||
|
||||
@@ -3709,6 +3709,12 @@ MG_EXPORT int GUIAPI SetUserCompositionOps (HDC hdc, CB_COMP_SETPIXEL comp_setpi
|
||||
return old_rop;
|
||||
}
|
||||
|
||||
MG_EXPORT GHANDLE GetSurfaceHandle (HDC hdc)
|
||||
{
|
||||
PDC pdc = dc_HDC2PDC (hdc);
|
||||
return (GHANDLE)pdc->surface;
|
||||
}
|
||||
|
||||
MG_EXPORT BOOL GUIAPI SyncUpdateDC (HDC hdc)
|
||||
{
|
||||
#ifdef _MGUSE_SYNC_UPDATE
|
||||
|
||||
Reference in New Issue
Block a user