[Previous] [Contents] [Index] [Next]

disp_draw_context_t

Draw context for a graphics driver

Synopsis:

#include <draw.h>

typedef struct disp_draw_context {
    int             size;
    disp_adapter_t  *adapter;
    void            *gd_ctx;
    struct disp_draw_corefuncs *cfuncs;
    unsigned        flags;
    disp_color_t    fgcolor;
    disp_color_t    bgcolor;
    uint8_t         *pat;
    unsigned short  pat_xoff;
    unsigned short  pat_yoff;
    unsigned short  pattern_format;
    unsigned short  rop3;
    unsigned short  chroma_mode;
    disp_color_t    chroma_color0;
    disp_color_t    chroma_color1;
    disp_color_t    chroma_mask;
    unsigned        alpha_mode;
    unsigned        s_alpha;
    unsigned        d_alpha;
    unsigned        alpha_map_width;
    unsigned        alpha_map_height;
    unsigned        alpha_map_xoff;
    unsigned        alpha_map_yoff;
    unsigned char   *alpha_map;
    disp_surface_t  *dsurf
    char            *sysram_workspace;
    int             sysram_workspace_size;
} disp_draw_context_t;

Description:

The disp_draw_context_t structure defines the graphics driver's draw context. The graphics framework passes this structure to of all the 2D drawing entry points.

The members include:

size
The size of the structure, in bytes.
adapter
A pointer to the disp_adapter_t structure.
gd_ctx
The 2D module's private context structure.
cfuncs
A pointer to the disp_draw_corefuncs_t structure that lists the core functions for rendering into the currently targeted draw surface. This surface is of the type specified by the dsurf structure's pixel_format member.
flags
Flags that indicate what kind of operations should be performed in all subsequent "context draw" functions. Selected from one or more of the following (bitmap):
fgcolor
The foreground color.
bgcolor
The background color.
pat
Pattern buffer; see the description in "Patterns" (in the "Conventions" section of the Writing a Graphics Driver chapter), as well as the context functions draw_rect_pat8x8(), and draw_rect_trans8x8().
pat_xoff, pat_yoff
Horizontal and vertical offsets for the pattern to cause it to be shifted. For more information, see "Patterns" in the Writing a Graphics Driver chapter.
pattern_format
One of DISP_PATTERN_FORMAT_MONO_8x1 or DISP_PATTERN_FORMAT_MONO_8x8 (from draw.h).
rop3
Bitmapped raster operations, range between 0 and 255 inclusive. See the memcpy_x.c file in the flat framebuffer library source for a sample implementation.
chroma_mode
Selected from the following, see "Chroma mode bits," below: either DISP_CHROMA_OP_SRC_MATCH or DISP_CHROMA_OP_DST_MATCH, and/or either DISP_CHROMA_OP_DRAW or DISP_CHROMA_OP_NO_DRAW. (In other words, SRC and DST are mutually exclusive, as are DRAW and NO_DRAW.)
chroma_color0
The chroma key; indicates the color to test on.
chroma_color1, chroma_mask
Reserved; don't examine or modify.
alpha_mode
A bitmask indicating alpha blending operations, see "Alpha mode bits," below. For unrecognized alpha operations, call the supplied flat frame buffer functions.
s_alpha
The source alpha blending factor.
d_alpha
The destination alpha blending factor.
alpha_map_width, alpha_map_height
The width and height of the alpha map (below) in pixels.
alpha_map_xoff, alpha_map_yoff
The X and Y offset of the alpha map (below). See the discussion above in "Patterns" for more information.
alpha_map
The alpha mapping grid, whose size is determined by alpha_map_width and alpha_map_height (above). Each element of the map is one byte, corresponding to one pixel. If this member is NULL, there's no alpha map. The stride here is equal to the width, i.e. one byte per element.
dsurf
A pointer to a disp_surface_t structure that contains the definition of the currently targeted draw surface. All draw operations target this surface by default, unless parameters to the draw function explicitly override this.
sysram_workspace
A "scratch" area that the 2D driver and FFB library routines may use for temporary storage.
sysram_workspace_size
The size of the workspace, in bytes. If the driver wishes, it may reallocate the workspace in order to increase its size. This member should be updated to reflect the change in size. The driver should never decrease the size of the workspace.

When using an alpha map, blending factors come from the alpha_map, and not from the s_alpha or d_alpha members.

Chroma mode bits

The following bits apply to the chroma mode flag mode, which performs a per-pixel test:

DISP_CHROMA_OP_SRC_MATCH
Perform match on source image.
DISP_CHROMA_OP_DST_MATCH
Perform match on destination image.
DISP_CHROMA_OP_DRAW
If match, draw pixel.
DISP_CHROMA_OP_NO_DRAW
If match, don't draw pixel.

Note that DISP_CHROMA_OP_SRC_MATCH and DISP_CHROMA_OP_DST_MATCH are mutually exclusive, as are DISP_CHROMA_OP_DRAW and DISP_CHROMA_OP_NO_DRAW.

Alpha mode bits (alpha_mode)

The alpha modes are:

DISP_ALPHA_OP_TEST
Perform an Alpha Testing operation
DISP_ALPHA_OP_BLEND
Perform an Alpha Blending operation
DISP_ALPHA_OP_DST_PIXEL_ALPHA
Use the Alpha component of the destination pixels.
DISP_ALPHA_OP_SRC_PIXEL_ALPHA
Use the Alpha component of the source pixels
DISP_ALPHA_OP_DST_GLOBAL
Use global destination blend factor from the d_alpha member
DISP_ALPHA_OP_SRC_GLOBAL
Use global source blend factor from the s_alpha member
DISP_ALPHA_OP_SRC_MAP
Blending factors come from the Alpha Map

Alpha mode blending (source) operation

Use the DISP_BLEND_SRC_FACTOR to extract this value from alpha_mode. The source operations are:

DISP_BLEND_SRC_ZERO
(0,0,0,0)
DISP_BLEND_SRC_ONE
(1,1,1,1)
DISP_BLEND_SRC_DST_COLOR
(Ad,Rd,Gd,Bd)
DISP_BLEND_SRC_ONE_MINUS_DST
(1,1,1,1)-(Ad,Rd,Gd,Bd)
DISP_BLEND_SRC_SRC_ALPHA
(As,As,As,As)
DISP_BLEND_SRC_ONE_MINUS_SRC_ALPHA
(1,1,1,1)-(As,As,As,As)
DISP_BLEND_SRC_DST_ALPHA
(Ad,Ad,Ad,Ad)
DISP_BLEND_SRC_ONE_MINUS_DST_ALPHA
(1,1,1,1)-(Ad,Ad,Ad,Ad)

Alpha mode blending (destination) operation

Use the DISP_BLEND_DST_FACTOR to extract this value from alpha_mode: The destination operations are:

DISP_BLEND_DST_ZERO
(0,0,0,0)
DISP_BLEND_DST_ONE
(1,1,1,1)
DISP_BLEND_DST_SRC_COLOR
(As,Rs,Gs,Bs)
DISP_BLEND_DST_ONE_MINUS_SRC
(1,1,1,1)-(As,Rs,Gs,Bs)
DISP_BLEND_DST_SRC_ALPHA
(As,As,As,As)
DISP_BLEND_DST_ONE_MINUS_SRC_ALPHA
(1,1,1,1)-(As,As,As,As)
DISP_BLEND_DST_DST_ALPHA
(Ad,Ad,Ad,Ad)
DISP_BLEND_DST_ONE_MINUS_DST_ALPHA
(1,1,1,1)-(Ad,Ad,Ad,Ad)

Classification:

Photon

See also:

disp_adapter_t, disp_draw_corefuncs_t, disp_surface_t


[Previous] [Contents] [Index] [Next]