disp_draw_contextfuncs_t

Table of a driver's context 2D drawing functions

Synopsis:

#include <draw.h>

typedef struct disp_draw_contextfuncs {
    void (*draw_span) ();
    void (*draw_span_list) ();
    void (*draw_rect) ();
    void (*blit) ();
    void (*update_general) ();
    void (*update_color) ();
    void (*update_rop3) ();
    void (*update_chroma) ();
    void (*update_alpha) ();
    void (*scaled_blit) ();
    void (*update_planemask) ();
    void (*draw_line) ();
    int (*fill_poly) ();
    int (*draw_polyline) ();
    void (*update_line) ();
    void (*blend_pixels) ();


} disp_draw_contextfuncs_t;

Description:

The disp_draw_contextfuncs_t structure is a table that your driver uses to define the context 2D drawing functions that it provides to the graphics framework. Your driver's devg_get_contextfuncs() entry point must fill in this structure.

All functions in the context drawing structure must obey the members of the disp_draw_context_t structure (e.g. the current foreground color, and the alpha- and chroma-related members); check the flags to see which members of the context structure need to be obeyed. Note also that the core functions update_pattern() and update_draw_surface() affect the operation of these (the context) functions.

draw_span()

The graphics framework calls this function to draw a single, horizontal line from (x1, y) to (x2, y). The prototype is:

void (*draw_span) (disp_draw_context_t *context,
                  int x1,
                  int x2,
                  int y)

Fallback function: ffb_ctx_draw_span()

draw_span_list()

The graphics framework calls this function to draw count number of horizontal lines as given by the arrays x1, x2, and y. This function must clip to within the clipping rectangle defined by context->clip_*. The prototype is:

void (*draw_span_list) (
         disp_draw_context_t *context,
         int count,
         int *x1,
         int *x2,
         int *y)

Fallback function: ffb_ctx_draw_span_list()

draw_rect()

The graphics framework calls this function to draw a rectangle from (x1, y1) to (x2, y2). The prototype is:

void (*draw_rect) (disp_draw_context_t *context,
                   int x1,
                   int y1,
                   int x2,
                   int y2)

Fallback function: ffb_ctx_draw_rect()

blit()

The graphics framework calls this function to perform a blit. The prototype is:

void (*blit) (disp_draw_context_t *context,
              disp_surface_t *src,
              disp_surface_t *dst,
              int sx,
              int sy,
              int dx,
              int dy,
              int width,
              int height)

This function should move the pixels from the source surface (src) specified by the rectangle beginning at (sx, sy) for the specified size (length and height) to the destination surface beginning with the rectangle at (dx, dy) for the same size.


Note: The disp_surface_t structures pointed to by src and dst may actually describe the same 2D surface. In this case, the driver must be prepared to handle the case where the source and destination areas intersect (i.e. this function must handle overlapping blits).

Fallback function: ffb_ctx_blit()

update_general()

The graphics framework calls this function to notify the driver that potentially all the members of the context structure have changed. The prototype is:

void (*update_general) (
         disp_draw_context_t *context)

Fallback function: ffb_ctx_update_general()

update_color()

The graphics framework calls this function to notify the driver that the fg_color and bg_color members of the context structure could have changed. The prototype is:

void (*update_color) (disp_draw_context_t *context)

Fallback function: ffb_ctx_update_color()

update_rop3()

The graphics framework calls this function to notify the driver that the rop3 member of the context structure could have changed. The prototype is:

void (*update_rop3) (disp_draw_context_t *context)

Fallback function: ffb_ctx_update_rop3()

update_chroma()

The graphics framework calls this function to notify the driver that the chroma-related members of the context structure could have changed. This includes the flags, chroma_mode and chroma_color0 members. The prototype is:

void (*update_chroma) (
         disp_draw_context_t *context)

Fallback function: ffb_ctx_update_chroma()

update_alpha()

The graphics framework calls this function to notify the driver that the alpha-related members of the context structure could have changed. This includes the flags, alpha_mode, d_alpha, alpha_map_width, alpha_map_height, alpha_map_xoff, alpha_map_yoff, and alpha_map members. The prototype is:

void (*update_alpha) (disp_draw_context_t *context)

Fallback function: ffb_ctx_update_alpha()

scaled_blit()

The graphics framework calls this function to copy pixels from an area of the source surface src to an area of the destination surface dst. The prototype is:

void (*scaled_blit) (disp_draw_context_t *context,
        disp_surface_t *src,
        disp_surface_t *dst,
        int sx1,
        int sy1,
        int sx2,
        int sy2,
        int dx1,
        int dy1,
        int dx2,
        int dy2);

The size of the source and destination areas may be different, and this function must scale the image data to make it fit into the destination area. The source area is specified by (sx1, sy1, sx2, sy2). The destination area is specified by (dx1, dy1, dx2, dy2). The image data may need to be scaled up, or down in both the horizontal and vertical directions. Scaling up in one direction, while scaling down


Note: The disp_surface_t structures pointed to by src and dst must describe different 2D surfaces. They can't be the same surface.

Fallback function: ffb_ctx_scaled_blit()

update_planemask()

The graphics framework calls this function to notify the driver that the plane_mask member of the context structure could have changed. The prototype is:

void (*update_planemask) (disp_draw_context_t *context);

Fallback function: ffb_ctx_update_planemask()

draw_line()

The graphics framework calls this function to draw a single-pixel wide line, using Bresenham's algorithm, from the point (x1, y1) to the point (x2, y2). No flags are currently defined. The prototype is:

void (*draw_line) (disp_draw_context_t *context,
    int x1,
    int y1,
    int x2,
    int y2,
    unsigned flags);

Fallback function: ffb_ctx_draw_line()

fill_poly()

The graphics framework calls this function to draw a filled polygon with npoints vertexes whose vertex values are specified as a list of points. The prototype is:

int (*fill_poly) (disp_draw_context_t *ctx,
        disp_point_t *pointlist,
        int npoints,
        unsigned flags);

There is no FFB fallback for this function. If the driver is unable to render the polygon correctly, it should return -1, without performing any drawing, so that the software fallback can be performed at a higher level.

draw_polyline()

The graphics framework calls this function to draw a sequence of connected lines of a specified thickness according to the specified list of points. The prototype is:

int (*draw_polyline) (disp_draw_context_t *ctx,
        disp_point_t *pointlist,
        int npoints,
        int width,
        unsigned flags);

There is no FFB fallback for this function. If the driver is unable to render the polygon correctly, it should return -1, without performing any rendering, so that the software fallback can be performed at a higher level.

update_line()

The graphics framework calls this function to notify the driver that members of the context structure specifically related to polyline rendering could have changed. This applies to the following members:

The prototype is:

void (*update_line) (disp_draw_context_t *context);

Fallback function: ffb_ctx_update_line()

blend_pixels()

The graphics framework calls this function to blend a list of pixels with the destination surface.

The prototype is:

void (*blend_pixels)(
        disp_draw_context_t *ctx,
        int x[],
        int y[],
        uint8_t alpha[],
        int npixels );

Pixels are drawn at the coordinates specified by the x and y arrays, using the corresponding values in the alpha array as coverage values. The coverage values specify the intensity of the pixel (0xFF is full intensity, 0x00 is no intensity) when it is finally written to the destination. If alpha blending is enabled, the coverage value is moderated with the source alpha value. Otherwise, the final pixel value is written to the destination with the following blend operation:

Pdst - (Pv × coverage) + Pdst × (1 - coverage)

Where:

Classification:

Neutrino

See also:

disp_draw_context_t, disp_surface_t

FFB library — 2D software fallback routines in the Libraries chapter