## Draw Draw — drawing helpers for tests |

## Functions

const char * | igt_draw_get_method_name ()
void | igt_draw_rect ()
void | igt_draw_rect_fb ()
void | igt_draw_fill_fb ()

## Types and Values

enum | igt_draw_method

## Includes

    #include <igt.h>

## Description

This library contains some functions for drawing rectangles on buffers using the many different drawing methods we have. It also contains some wrappers that make the process easier if you have the abstract objects in hand.

This library only claims support for some pixel formats, but adding support for more formats should be faily easy now that we support both 16bpp and 32bpp. If you need a new pixel format, make sure you update both this file and tests/kms_draw_crc.c.

## Functions

### igt_draw_get_method_name ()

    const char *
    igt_draw_get_method_name (enum igt_draw_method method);

Simple function to transform the enum into a string. Useful when naming subtests and printing debug messages.

#### Parameters

method | draw method |

### igt_draw_rect ()

    void
    igt_draw_rect (int fd,
                   drm_intel_bufmgr *bufmgr,
                   drm_intel_context *context,
                   uint32_t buf_handle,
                   uint32_t buf_size,
                   uint32_t buf_stride,
                   enum igt_draw_method method,
                   int rect_x,
                   int rect_y,
                   int rect_w,
                   int rect_h,
                   uint32_t color,
                   int bpp);

This function draws a colored rectangle on the destination buffer, allowing you to specify the method used to draw the rectangle.

#### Parameters

fd | the DRM file descriptor |
bufmgr | the libdrm bufmgr, only required for IGT_DRAW_BLT and IGT_DRAW_RENDER |
context | the context, can be NULL if you don't want to think about it |
buf_handle | the handle of the buffer where you're going to draw to |
buf_size | the size of the buffer |
buf_stride | the stride of the buffer |
method | method you're going to use to write to the buffer |
rect_x | horizontal position on the buffer where your rectangle starts |
rect_y | vertical position on the buffer where your rectangle starts |
rect_w | width of the rectangle |
rect_h | height of the rectangle |
color | color of the rectangle |
bpp | bits per pixel |

### igt_draw_rect_fb ()

    void
    igt_draw_rect_fb (int fd,
                      drm_intel_bufmgr *bufmgr,
                      drm_intel_context *context,
                      struct igt_fb *fb,
                      enum igt_draw_method method,
                      int rect_x,
                      int rect_y,
                      int rect_w,
                      int rect_h,
                      uint32_t color);

This is exactly the same as igt_draw_rect, but you can pass an igt_fb instead of manually providing its details. See igt_draw_rect.

#### Parameters

fd | the DRM file descriptor |
bufmgr | the libdrm bufmgr, only required for IGT_DRAW_BLT and IGT_DRAW_RENDER |
context | the context, can be NULL if you don't want to think about it |
fb | framebuffer |
method | method you're going to use to write to the buffer |
rect_x | horizontal position on the buffer where your rectangle starts |
rect_y | vertical position on the buffer where your rectangle starts |
rect_w | width of the rectangle |
rect_h | height of the rectangle |
color | color of the rectangle |

### igt_draw_fill_fb ()

    void
    igt_draw_fill_fb (int fd,
                      struct igt_fb *fb,
                      uint32_t color);

This function just paints an igt_fb using the provided color.

#### Parameters

fd | the DRM file descriptor |
fb | the FB that is going to be filled |
color | the color you're going to paint it |

## Types and Values

### enum igt_draw_method

#### Members

IGT_DRAW_MMAP_CPU | draw using a CPU mmap. |
IGT_DRAW_MMAP_GTT | draw using a GTT mmap. |
IGT_DRAW_MMAP_WC | draw using the WC mmap. |
IGT_DRAW_PWRITE | draw using the pwrite ioctl. |
IGT_DRAW_BLT | draw using the BLT ring. |
IGT_DRAW_RENDER | draw using the render ring. |
IGT_DRAW_METHOD_COUNT | useful for iterating through everything. |