... | @@ -92,7 +92,9 @@ for your GPU externally. |
... | @@ -92,7 +92,9 @@ for your GPU externally. |
|
|
|
|
|
First, you need to implement the following external stub:
|
|
First, you need to implement the following external stub:
|
|
|
|
|
|
DriDriverOps* __dri_ex_driver_get (const char* driver_name);
|
|
```C
|
|
|
|
DriDriverOps* __dri_ex_driver_get (const char* driver_name);
|
|
|
|
```
|
|
|
|
|
|
This function takes an argument `driver_name` and returns NULL or
|
|
This function takes an argument `driver_name` and returns NULL or
|
|
a valid pointer of `DriDriverOps` to MiniGUI. The argument `driver_name`
|
|
a valid pointer of `DriDriverOps` to MiniGUI. The argument `driver_name`
|
... | @@ -108,139 +110,141 @@ instead. |
... | @@ -108,139 +110,141 @@ instead. |
|
The `DriDriverOps` is a struct type consisted by a set of operators
|
|
The `DriDriverOps` is a struct type consisted by a set of operators
|
|
(callbacks):
|
|
(callbacks):
|
|
|
|
|
|
|
|
```C
|
|
|
|
/**
|
|
|
|
* The struct type defines the operators for a DRI driver.
|
|
|
|
*/
|
|
|
|
typedef struct _DriDriverOps {
|
|
|
|
/**
|
|
|
|
* This operator creates the DriDriver object.
|
|
|
|
*
|
|
|
|
* \note The driver must implement this operator.
|
|
|
|
*/
|
|
|
|
DriDriver* (*create_driver) (int device_fd);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This operator destroies the DriDriver object.
|
|
|
|
*
|
|
|
|
* \note The driver must implement this operator.
|
|
|
|
*/
|
|
|
|
void (*destroy_driver) (DriDriver *driver);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This operator flushs the batch buffer of the driver or the hardware cache.
|
|
|
|
*
|
|
|
|
* \note This operator can be NULL.
|
|
|
|
*/
|
|
|
|
void (* flush_driver) (DriDriver *driver);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This operator 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.
|
|
|
|
* If failed, it returns 0.
|
|
|
|
*
|
|
|
|
* \note The driver must implement this operator.
|
|
|
|
*/
|
|
|
|
uint32_t (* create_buffer) (DriDriver *driver,
|
|
|
|
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,
|
|
|
|
unsigned int *pitch);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This operator maps the buffer into the current process's virtual memory
|
|
|
|
* space, and returns the virtual address. If failed, it returns NULL.
|
|
|
|
*
|
|
|
|
* \note The driver must implement this operator.
|
|
|
|
*/
|
|
|
|
DriSurfaceBuffer* (* map_buffer) (DriDriver *driver,
|
|
|
|
uint32_t buffer_id);
|
|
|
|
|
|
/**
|
|
/**
|
|
* The struct type defines the operators for a DRI driver.
|
|
* This operator un-maps a buffer.
|
|
|
|
*
|
|
|
|
* \note The driver must implement this operator.
|
|
*/
|
|
*/
|
|
typedef struct _DriDriverOps {
|
|
void (* unmap_buffer) (DriDriver *driver, DriSurfaceBuffer* buffer);
|
|
/**
|
|
|
|
* This operator creates the DriDriver object.
|
|
/**
|
|
*
|
|
* This operator destroies a buffer.
|
|
* \note The driver must implement this operator.
|
|
*
|
|
*/
|
|
* \note The driver must implement this operator.
|
|
DriDriver* (*create_driver) (int device_fd);
|
|
*/
|
|
|
|
void (* destroy_buffer) (DriDriver *driver, uint32_t buffer_id);
|
|
/**
|
|
|
|
* This operator destroies the DriDriver object.
|
|
/**
|
|
*
|
|
* This operator clears the specific rectangle area of a buffer
|
|
* \note The driver must implement this operator.
|
|
* with the specific pixel value. If succeed, it returns 0.
|
|
*/
|
|
*
|
|
void (*destroy_driver) (DriDriver *driver);
|
|
* \note If this operator is set as NULL, the driver does not support
|
|
|
|
* hardware accelerated clear operation.
|
|
/**
|
|
*/
|
|
* This operator flushs the batch buffer of the driver or the hardware cache.
|
|
int (* clear_buffer) (DriDriver *driver,
|
|
*
|
|
DriSurfaceBuffer* dst_buf, const GAL_Rect* rc, uint32_t pixel_value);
|
|
* \note This operator can be NULL.
|
|
|
|
*/
|
|
/**
|
|
void (* flush_driver) (DriDriver *driver);
|
|
* This operator checks whether a hardware accelerated blit
|
|
|
|
* can be done between the source buffer and the destination buffer.
|
|
/**
|
|
* If succeed, it returns 0.
|
|
* This operator creates a buffer with the specified pixel format,
|
|
*
|
|
* width, and height. If succeed, a valid (not zero) buffer identifier
|
|
* \note If this operator is set as NULL, it will be supposed that
|
|
* and the picth (row stride in bytes) will be returned.
|
|
* the driver does not support any hardware accelerated blit operation.
|
|
* If failed, it returns 0.
|
|
*/
|
|
*
|
|
int (* check_blit) (DriDriver *driver,
|
|
* \note The driver must implement this operator.
|
|
DriSurfaceBuffer* src_buf, DriSurfaceBuffer* dst_buf);
|
|
*/
|
|
|
|
uint32_t (* create_buffer) (DriDriver *driver,
|
|
/**
|
|
uint32_t drm_format,
|
|
* This operator copies bits from a source buffer to a destination buffer.
|
|
unsigned int width, unsigned int height,
|
|
*
|
|
unsigned int *pitch);
|
|
* \note If this operator is set as NULL, the driver does not support
|
|
|
|
* hardware accelerated copy blit.
|
|
BOOL (* fetch_buffer) (DriDriver *driver,
|
|
*/
|
|
uint32_t buffer_id,
|
|
int (* copy_blit) (DriDriver *driver,
|
|
unsigned int *width, unsigned int *height,
|
|
DriSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
|
|
unsigned int *pitch);
|
|
DriSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
|
|
|
|
enum DriColorLogicOp logic_op);
|
|
/**
|
|
|
|
* This operator maps the buffer into the current process's virtual memory
|
|
/**
|
|
* space, and returns the virtual address. If failed, it returns NULL.
|
|
* This operator blits pixles from a source buffer with the source alpha value
|
|
*
|
|
* specified to a destination buffer.
|
|
* \note The driver must implement this operator.
|
|
*
|
|
*/
|
|
* \note If this operator is set as NULL, the driver does not support
|
|
DriSurfaceBuffer* (* map_buffer) (DriDriver *driver,
|
|
* hardware accelerated blit with alpha.
|
|
uint32_t buffer_id);
|
|
*/
|
|
|
|
int (* alpha_blit) (DriDriver *driver,
|
|
/**
|
|
DriSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
|
|
* This operator un-maps a buffer.
|
|
DriSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc, uint8_t alpha);
|
|
*
|
|
|
|
* \note The driver must implement this operator.
|
|
/**
|
|
*/
|
|
* This operator blits pixles from a source buffer to a destination buffer,
|
|
void (* unmap_buffer) (DriDriver *driver, DriSurfaceBuffer* buffer);
|
|
* but skipping the pixel value specified by \a color_key.
|
|
|
|
*
|
|
/**
|
|
* \note If this operator is set as NULL, the driver does not support
|
|
* This operator destroies a buffer.
|
|
* hardware accelerated blit with color key.
|
|
*
|
|
*/
|
|
* \note The driver must implement this operator.
|
|
int (* key_blit) (DriDriver *driver,
|
|
*/
|
|
DriSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
|
|
void (* destroy_buffer) (DriDriver *driver, uint32_t buffer_id);
|
|
DriSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc, uint32_t color_key);
|
|
|
|
|
|
/**
|
|
/**
|
|
* This operator clears the specific rectangle area of a buffer
|
|
* This operator blits pixles from a source buffer with the source alpha value
|
|
* with the specific pixel value. If succeed, it returns 0.
|
|
* specified to a destination buffer, but skipping the pixel value specified.
|
|
*
|
|
*
|
|
* \note If this operator is set as NULL, the driver does not support
|
|
* \note If this operator is set as NULL, the driver does not support
|
|
* hardware accelerated clear operation.
|
|
* hardware accelerated blit with alpha and color key.
|
|
*/
|
|
*/
|
|
int (* clear_buffer) (DriDriver *driver,
|
|
int (* alpha_key_blit) (DriDriver *driver,
|
|
DriSurfaceBuffer* dst_buf, const GAL_Rect* rc, uint32_t pixel_value);
|
|
DriSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
|
|
|
|
DriSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
|
|
/**
|
|
uint8_t alpha, uint32_t color_key);
|
|
* This operator checks whether a hardware accelerated blit
|
|
|
|
* can be done between the source buffer and the destination buffer.
|
|
} DriDriverOps;
|
|
* If succeed, it returns 0.
|
|
```
|
|
*
|
|
|
|
* \note If this operator is set as NULL, it will be supposed that
|
|
|
|
* the driver does not support any hardware accelerated blit operation.
|
|
|
|
*/
|
|
|
|
int (* check_blit) (DriDriver *driver,
|
|
|
|
DriSurfaceBuffer* src_buf, DriSurfaceBuffer* dst_buf);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This operator copies bits from a source buffer to a destination buffer.
|
|
|
|
*
|
|
|
|
* \note If this operator is set as NULL, the driver does not support
|
|
|
|
* hardware accelerated copy blit.
|
|
|
|
*/
|
|
|
|
int (* copy_blit) (DriDriver *driver,
|
|
|
|
DriSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
|
|
|
|
DriSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
|
|
|
|
enum DriColorLogicOp logic_op);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This operator blits pixles from a source buffer with the source alpha value
|
|
|
|
* specified to a destination buffer.
|
|
|
|
*
|
|
|
|
* \note If this operator is set as NULL, the driver does not support
|
|
|
|
* hardware accelerated blit with alpha.
|
|
|
|
*/
|
|
|
|
int (* alpha_blit) (DriDriver *driver,
|
|
|
|
DriSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
|
|
|
|
DriSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc, uint8_t alpha);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This operator blits pixles from a source buffer to a destination buffer,
|
|
|
|
* but skipping the pixel value specified by \a color_key.
|
|
|
|
*
|
|
|
|
* \note If this operator is set as NULL, the driver does not support
|
|
|
|
* hardware accelerated blit with color key.
|
|
|
|
*/
|
|
|
|
int (* key_blit) (DriDriver *driver,
|
|
|
|
DriSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
|
|
|
|
DriSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc, uint32_t color_key);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This operator blits pixles from a source buffer with the source alpha value
|
|
|
|
* specified to a destination buffer, but skipping the pixel value specified.
|
|
|
|
*
|
|
|
|
* \note If this operator is set as NULL, the driver does not support
|
|
|
|
* hardware accelerated blit with alpha and color key.
|
|
|
|
*/
|
|
|
|
int (* alpha_key_blit) (DriDriver *driver,
|
|
|
|
DriSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
|
|
|
|
DriSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
|
|
|
|
uint8_t alpha, uint32_t color_key);
|
|
|
|
|
|
|
|
} DriDriverOps;
|
|
|
|
|
|
|
|
If the external stub `__dri_ex_driver_get` returns a valid pointer
|
|
If the external stub `__dri_ex_driver_get` returns a valid pointer
|
|
of `DriDriverOps`, MiniGUI will call the operator `create_driver`
|
|
of `DriDriverOps`, MiniGUI will call the operator `create_driver`
|
... | @@ -251,12 +255,14 @@ need this pointer as the context of your DRI driver. |
... | @@ -251,12 +255,14 @@ need this pointer as the context of your DRI driver. |
|
Note that MiniGUI does not defined the detailed structure of
|
|
Note that MiniGUI does not defined the detailed structure of
|
|
`DriDriver`, it is up to your implementation:
|
|
`DriDriver`, it is up to your implementation:
|
|
|
|
|
|
/**
|
|
```C
|
|
* The struct type represents the DRI sub driver.
|
|
/**
|
|
* The concrete struct should be defined by the driver.
|
|
* The struct type represents the DRI sub driver.
|
|
*/
|
|
* The concrete struct should be defined by the driver.
|
|
struct _DriDriver;
|
|
*/
|
|
typedef struct _DriDriver DriDriver;
|
|
struct _DriDriver;
|
|
|
|
typedef struct _DriDriver DriDriver;
|
|
|
|
```
|
|
|
|
|
|
For other operators, please see the comments above.
|
|
For other operators, please see the comments above.
|
|
|
|
|
... | | ... | |