muteki
Loading...
Searching...
No Matches
surface.h File Reference

Surface API. More...

#include <muteki/ui/common.h>

Go to the source code of this file.

Functions

size_t SizeofGraphic (lcd_surface_t *surface)
 Calculate the total on-memory size of a surface (including descriptor).
 
lcd_surface_tInitGraphic (lcd_surface_t *surface, short width, short height, short depth)
 Initialize a buffer as an all-in-one surface.
 
void _BitBlt (lcd_surface_t *dst, short xdstoffset, short ydstoffset, short xsize, short ysize, lcd_surface_t *src, int xsrcoffset, int ysrcoffset, unsigned short flags)
 Perform blit operation from src surface to dst surface.
 
size_t GetImageSize (short width, short height)
 Calculate the buffer size required for an all-in-one surface of a specific size.
 
size_t GetImageSizeExt (short width, short height, short depth)
 Calculate the buffer size required for an all-in-one surface of a specific pixel format and size.
 
void * ImageData (lcd_surface_t *surface)
 Get the palette and bitmap buffer for an all-in-one surface.
 
size_t SizeofImage (lcd_surface_t *surface)
 Get the total on-memory size of a surface, in bytes.
 
void FreeImage (lcd_surface_t *surface)
 Dispose an all-in-one surface.
 

Detailed Description

Surface API.

Function Documentation

◆ _BitBlt()

void _BitBlt ( lcd_surface_t dst,
short  xdstoffset,
short  ydstoffset,
short  xsize,
short  ysize,
lcd_surface_t src,
int  xsrcoffset,
int  ysrcoffset,
unsigned short  flags 
)
extern

Perform blit operation from src surface to dst surface.

This copies a rectangle of size (xsize, ysize) px on the src surface, with its the top left corner located at (xsrcoffset, ysrcoffset) px, to the dst surface. The top left corner of that rectangle will be aligned to a point on the dst surface at (xdstoffset, ydstoffset) px. Optionally one can specify one or more processing flags to let the blitter perform certain pixel operations on-the-fly.

Syscall Number
0x10089
Parameters
dstDestination surface.
xdstoffsetX coordinate of the destination surface that align with the top left corner of the blitted image, in pixels.
ydstoffsetY coordinate of the destination surface that align with the top left corner of the blitted image, in pixels.
xsizeNumber of pixel columns to copy.
ysizeNumber of pixel rows to copy.
srcSource surface.
xsrcoffsetX coordinate of the source surface that align with the top left corner of the blitted image, in pixels.
ysrcoffsetY coordinate of the source surface that align with the top left corner of the blitted image, in pixels.
flagsProcess flags.

Returns
None.

See also
blit_flag_e Accepted processing flags.
BitBlt in WinGDI, which this function has been loosely based on.

◆ FreeImage()

void FreeImage ( lcd_surface_t surface)
extern

Dispose an all-in-one surface.

This is simply a wrapper around _lfree().

Warning
Behavior is undefined when not called on a dymically allocated (via lmalloc(), lcalloc() or lrealloc()) all-in-one surface.
Syscall Number
0x10099
Parameters
surfaceThe surface descriptor.

Returns
None.

◆ GetImageSize()

size_t GetImageSize ( short  width,
short  height 
)
extern

Calculate the buffer size required for an all-in-one surface of a specific size.

This assumes the surface will be in the same format as the surface linked to the current active LCD.

Syscall Number
0x10095
Parameters
widthThe width of the desired surface.
heightThe height of the desired surface.
Returns
The buffer size required to contain the entire surface.

◆ GetImageSizeExt()

size_t GetImageSizeExt ( short  width,
short  height,
short  depth 
)
extern

Calculate the buffer size required for an all-in-one surface of a specific pixel format and size.

This is similar to GetImageSize() but it allows arbitrary pixel bit depth.

Syscall Number
0x10096
Parameters
widthThe width of the desired surface.
heightThe height of the desired surface.
depthThe pixel bit depth of the desired surface.
Returns
The buffer size required to contain the entire surface.
See also
InitGraphic For some assumptions made for an all-in-one surface format.

◆ ImageData()

void * ImageData ( lcd_surface_t surface)
extern

Get the palette and bitmap buffer for an all-in-one surface.

Warning
The behavior of calling this on a hardware framebuffer backed surface is undefined as those surfaces may allocate the palette and/or the pixel buffer not immediately after the descriptor. Use lcd_surface_t::palette or lcd_surface_t::buffer instead for those surfaces.
Syscall Number
0x10097
Parameters
surfaceThe surface descriptor.
Returns
Pointer to surface palette buffer when a palette is available, or otherwise pointer to the pixel buffer.

◆ InitGraphic()

lcd_surface_t * InitGraphic ( lcd_surface_t surface,
short  width,
short  height,
short  depth 
)
extern

Initialize a buffer as an all-in-one surface.

If a palette is required (depth is 8-bit or less), the palette is assumed to follow the descriptor immediately, then the pixel buffer is assumed to start immediately after the palette. Otherwise the pixel buffer is assumed to follow the descriptor immediately (i.e. palette size is 0) and lcd_surface_t::palette will be set to NULL.

Note
This function does not allocate any memory. The caller is responsible for allocating a buffer that is large enough to hold the descriptor, the palette (if required) and the pixel buffer.
Syscall Number
0x1005b
Parameters
surfaceA buffer that will hold the data.
widthWidth of the surface in pixels.
heightHeight of the surface in pixels.
depthThe pixel bit depth.
Returns
The same buffer.
See also
GetImageSizeExt A function that can be used to estimate the required size of the surface buffer, based on the same parameters that will be passed to this function.

◆ SizeofGraphic()

size_t SizeofGraphic ( lcd_surface_t surface)
extern

Calculate the total on-memory size of a surface (including descriptor).

Syscall Number
0x1005a
Parameters
surfaceThe surface descriptor.
Returns
The total on-memory size of this surface in bytes.

◆ SizeofImage()

size_t SizeofImage ( lcd_surface_t surface)
extern

Get the total on-memory size of a surface, in bytes.

This is equivalent to

size_t SizeofImage(lcd_surface_t *surface) {
return GetImageSize(surface->width, surface->height);
}
Descriptor of an LCD drawing surface or hardware framebuffer.
Definition common.h:728
short height
Height of the framebuffer.
Definition common.h:741
short width
Width of the framebuffer.
Definition common.h:737
size_t GetImageSize(short width, short height)
Calculate the buffer size required for an all-in-one surface of a specific size.
size_t SizeofImage(lcd_surface_t *surface)
Get the total on-memory size of a surface, in bytes.
Syscall Number
0x10098
Parameters
surfacePointer to the surface descriptor.
Returns
The on-memory size of the surface.