Draw context for 2D rendering
#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_xoff;
    unsigned        alpha_map_yoff;
    disp_surface_t  *alpha_map;
    disp_surface_t  *dsurf
    unsigned char   *sysram_workspace;
    int             sysram_workspace_size;
    unsigned        plane_mask;
    int             clip_left;
    int             clip_top;
    int             clip_right;
    int             clip_bottom;
    unsigned char   *palette_lut;
    disp_color_t    *dest_palette;
    int             dest_palette_size;
    disp_fx_t       xform_matrix[4];
    int             xlate_x;
    int             xlate_y;
    unsigned        line_flags;
    int             line_join;
    uint32_t        line_pat;
    int             line_repeat;
    int             line_initial_offset;
    int             cap_style;
    int             poly_fill;
} disp_draw_context_t;
The disp_draw_context_t structure defines the graphics
driver's 2D 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):
  
- DISP_DRAW_FLAG_COMPLEX_ROP
    
  
- DISP_DRAW_FLAG_MONO_PATTERN
    
  
- DISP_DRAW_FLAG_SIMPLE_ROP
    
  
- DISP_DRAW_FLAG_TRANS_PATTERN
    
  
- DISP_DRAW_FLAG_USE_ALPHA
    
  
- DISP_DRAW_FLAG_USE_CHROMA
     
  
- DISP_DRAW_FLAG_SUBPIXEL
     
  
- DISP_DRAW_FLAG_FILTERED_SCALING
     
  
- DISP_DRAW_FLAG_SOFTWARE_SCALING
     
  
- DISP_DRAW_FLAG_USE_PLANE_MASK
     
  
- DISP_DRAW_FLAG_ANTIALIAS
     
  
- DISP_DRAW_FLAG_TRANSFORM
     
  
 
- 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. For blending
configurations, multiplier 1, (M1),
is the global alpha multiplier equivalent to s_alpha.
  
- d_alpha
- The destination alpha blending factor.  For blending
configurations, multiplier 2 M2,
is the global alpha multiplier equivalent to d_alpha.
  
- 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
- A pointer to a
  disp_surface_t
  structure that contains the alpha map used for alpha operations.
- 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.
- plane_mask
- A bit mask applied to writes to the frame buffer.  When plan masking is enabled, a bit that is set prevents the corresponding bit in the frame buffer from being modified during operations.  The number of bits that are used depends on the pixel format of the destination surface.  For example, if the destination surface is 16 bpp, on the 16 least-significant bits of the plane mask are used.
- clip_left, clip_top, clip_right, clip_bottom
- These coordinates define an inclusive clipping rectangle which is applied to certain primitives, including lines, polylines, polygons and scaled blits.
- palette_lut
- A pointer to a 4k palette look up table (444 true color to palette index conversions)
- dest_palette
- A pointer to a palette to be used for 8-bit alpha blending
- dest_palette_size
- The size of dest_palette, in bytes.
- xform_matrix[4]
- An array representing a 2×2 matrix for transformations.
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.
The (Group 1) alpha modes are:
- DISP_ALPHA_M1_SRC_PIXEL_ALPHA
- The M1 multiplier comes from the Alpha component of the source
pixels.
  
- DISP_ALPHA_M1_DST_PIXEL_ALPHA
- The M1 multiplier comes from the Alpha component of the
destination pixels.
  
- DISP_ALPHA_M1_GLOBAL
- The M1multiplier comes from the global blending factor, s_alpha.
  
- DISP_ALPHA_M1_MAP
- The M1multiplier comes from the Alpha map.
  
The (Group 2) alpha modes are:
- DISP_ALPHA_M2_SRC_PIXEL_ALPHA
- Use the M2 multiplier for the Alpha component of the source pixels.
  
- DISP_ALPHA_M2_DST_PIXEL_ALPHA
- Use the M2 multiplier for the Alpha component of the destination pixels.
  
- DISP_ALPHA_M2_GLOBAL
- Use global destination blend factor from the M2 multiplier.
  
- DISP_ALPHA_M2_MAP
- Use the alpha map for the M2 multiplier.
  
The (Group 3) alpha_mode source operations are:
- DISP_BLEND_SRC_0
- Ms = (0,0,0,0)
  
- DISP_BLEND_SRC_M1
- Ms = (M1,M1,M1,M1)
  
- DISP_BLEND_SRC_1mM1
- Ms = (1-M1,1-M1,1-M1,1-M1)
  
- DISP_BLEND_SRC_1mD
- Ms = (1-M2,1-Rd,1-Gd,1-Bd)
  
- DISP_BLEND_SRC_M2
- Ms = (M2,M2,M2,M2)
  
- DISP_BLEND_SRC_D
- Ms = (M2,Rd,Gd,Bd)
  
- DISP_BLEND_SRC_1
- Ms = (1,1,1,1)
  
- DISP_BLEND_SRC_A1M1
- Ms = (1,M1,M1,M1)
  
- DISP_BLEND_SRC_1mM2
- Ms = (1-M2,1-M2,1-M2,1-M2)
  
- DISP_BLEND_SRC_1mA1M1
- Ms = (1-1,1-M1,1-M1,1-M1)
  
- DISP_BLEND_SRC_A1M2
- Ms = (1,M2,M2,M2)
  
- DISP_BLEND_SRC_1mA1M2
- Ms = (1-1,1-M2,1-M2,1-M2)
  
- DISP_BLEND_SRC_A0M1
- Ms = (0,M1,M1,M1)
  
- DISP_BLEND_SRC_1mA0M1
- Ms = (1-0,1-M1,1-M1,1-M1)
  
- DISP_BLEND_SRC_A0M2
- Ms = (0,M2,M2,M2)
  
- DISP_BLEND_SRC_1mA0M2
- Ms = (1-0,1-M2,1-M2,1-M2)
  
The (Group 4) alpha_mode destination operations are:
- DISP_BLEND_DST_0
- Md = (0,0,0,0)
  
- DISP_BLEND_DST_M1
- Md = (M1,M1,M1,M1)
  
- DISP_BLEND_DST_1mM1
- Md = (1-M1,1-M1,1-M1,1-M1)
  
- DISP_BLEND_DST_1mS
- Md = (1-M1,1-Rs,1-Gs,1-Bs)
  
- DISP_BLEND_DST_M2
- Md = (M2,M2,M2,M2)
  
- DISP_BLEND_DST_S
- Md = (M1,Rs,Gs,Bs)
  
- DISP_BLEND_DST_1
- Md = (1,1,1,1)
  
- DISP_BLEND_DST_A1M1
- Md = (1,M1,M1,M1)
  
- DISP_BLEND_DST_1mM2
- Md = (1-M2,1-M2,1-M2,1-M2)
  
- DISP_BLEND_DST_1mA1M1
- Md = (1-1,1-M1,1-M1,1-M1)
  
- DISP_BLEND_DST_A1M2
- Md = (1,M2,M2,M2)
  
- DISP_BLEND_DST_1mA1M2
- Md = (1-1,1-M2,1-M2,1-M2)
  
- DISP_BLEND_DST_A0M1
- Md = (0,M1,M1,M1)
  
- DISP_BLEND_DST_1mA0M1
- Md = (1-0,1-M1,1-M1,1-M1)
  
- DISP_BLEND_DST_A0M2
- Md = (0,M2,M2,M2)
  
- DISP_BLEND_DST_1mA0M2
- Md = (1-0,1-M2,1-M2,1-M2)
  
|  | For each pixel, the value of the blended pixel
is derived by combining the source and the destination pixels
with the multipliers, as shown in the following equation:
Pd = Ps * Ms + Pd * Md, where
Pd is the destination pixel value, and Ps
is the source pixel value. | 
Neutrino
disp_adapter_t,
disp_draw_corefuncs_t,
disp_surface_t