xref: /qemu/hw/display/framebuffer.h (revision fc524567087c2537b5103cdfc1d41e4f442892b6)
1714fa308Spbrook #ifndef QEMU_FRAMEBUFFER_H
2714fa308Spbrook #define QEMU_FRAMEBUFFER_H
3714fa308Spbrook 
4*8be545baSRichard Henderson #include "system/memory.h"
575c9d6c2SAvi Kivity 
6714fa308Spbrook /* Framebuffer device helper routines.  */
7714fa308Spbrook 
8714fa308Spbrook typedef void (*drawfn)(void *, uint8_t *, const uint8_t *, int, int);
9714fa308Spbrook 
10c1076c3eSPaolo Bonzini /* framebuffer_update_memory_section: Update framebuffer
11c1076c3eSPaolo Bonzini  * #MemoryRegionSection, for example if the framebuffer is switched to
12c1076c3eSPaolo Bonzini  * a different memory area.
13c1076c3eSPaolo Bonzini  *
14c1076c3eSPaolo Bonzini  * @mem_section: Output #MemoryRegionSection, to be passed to
15c1076c3eSPaolo Bonzini  * framebuffer_update_display().
16c1076c3eSPaolo Bonzini  * @root: #MemoryRegion within which the framebuffer lies
17c1076c3eSPaolo Bonzini  * @base: Base address of the framebuffer within @root.
18c1076c3eSPaolo Bonzini  * @rows: Height of the screen.
19c1076c3eSPaolo Bonzini  * @src_width: Number of bytes in framebuffer memory between two rows.
20c1076c3eSPaolo Bonzini  */
21c1076c3eSPaolo Bonzini void framebuffer_update_memory_section(
22c1076c3eSPaolo Bonzini     MemoryRegionSection *mem_section,
23c1076c3eSPaolo Bonzini     MemoryRegion *root,
24c1076c3eSPaolo Bonzini     hwaddr base,
25c1076c3eSPaolo Bonzini     unsigned rows,
26c1076c3eSPaolo Bonzini     unsigned src_width);
27c1076c3eSPaolo Bonzini 
28c1076c3eSPaolo Bonzini /* framebuffer_update_display: Draw the framebuffer on a surface.
29c1076c3eSPaolo Bonzini  *
30c1076c3eSPaolo Bonzini  * @ds: #DisplaySurface to draw to.
31c1076c3eSPaolo Bonzini  * @mem_section: #MemoryRegionSection provided by
32c1076c3eSPaolo Bonzini  * framebuffer_update_memory_section().
33c1076c3eSPaolo Bonzini  * @cols: Width the screen.
34c1076c3eSPaolo Bonzini  * @rows: Height of the screen.
35c1076c3eSPaolo Bonzini  * @src_width: Number of bytes in framebuffer memory between two rows.
36c1076c3eSPaolo Bonzini  * @dest_row_pitch: Number of bytes in the surface data between two rows.
37c1076c3eSPaolo Bonzini  * Negative if the framebuffer is stored in the opposite order (e.g.
38c1076c3eSPaolo Bonzini  * bottom-to-top) compared to the framebuffer.
39c1076c3eSPaolo Bonzini  * @dest_col_pitch: Number of bytes in the surface data between two pixels.
40c1076c3eSPaolo Bonzini  * Negative if the framebuffer is stored in the opposite order (e.g.
41c1076c3eSPaolo Bonzini  * right-to-left) compared to the framebuffer.
42c1076c3eSPaolo Bonzini  * @invalidate: True if the function should redraw the whole screen
43c1076c3eSPaolo Bonzini  * without checking the DIRTY_MEMORY_VGA dirty bitmap.
44c1076c3eSPaolo Bonzini  * @fn: Drawing function to be called for each row that has to be drawn.
45c1076c3eSPaolo Bonzini  * @opaque: Opaque pointer passed to @fn.
46c1076c3eSPaolo Bonzini  * @first_row: Pointer to an integer, receives the number of the first row
47c1076c3eSPaolo Bonzini  * that was drawn (either the first dirty row, or 0 if @invalidate is true).
48c1076c3eSPaolo Bonzini  * @last_row: Pointer to an integer, receives the number of the last row that
49c1076c3eSPaolo Bonzini  * was drawn (either the last dirty row, or @rows-1 if @invalidate is true).
50c1076c3eSPaolo Bonzini  */
51714fa308Spbrook void framebuffer_update_display(
52c78f7137SGerd Hoffmann     DisplaySurface *ds,
53c1076c3eSPaolo Bonzini     MemoryRegionSection *mem_section,
54714fa308Spbrook     int cols,
55714fa308Spbrook     int rows,
56714fa308Spbrook     int src_width,
57714fa308Spbrook     int dest_row_pitch,
58714fa308Spbrook     int dest_col_pitch,
59714fa308Spbrook     int invalidate,
60714fa308Spbrook     drawfn fn,
61714fa308Spbrook     void *opaque,
62714fa308Spbrook     int *first_row,
63714fa308Spbrook     int *last_row);
64714fa308Spbrook 
65714fa308Spbrook #endif
66