Aufgabe 7: Anwendung
Actual implementation of basic graphics printing functions. More...
#include <graphics/printer.h>
Public Member Functions | |
GraphicsPrinter () | |
Constructor. | |
void | init (unsigned width, unsigned height, unsigned pitch) |
Initialize printer with actual screen dimensions. More... | |
void | buffer (void *lfb) |
Set the video memory address. More... | |
void | clear () |
Clear all pixel of the current back buffer (set full screen to black) More... | |
bool | valid (const Point &p) const |
Check if a Point can be displayed at the current resolution. More... | |
unsigned | height () const |
Number of vertical pixels in current resolution. More... | |
unsigned | width () const |
Number of horizontal pixels in current resolution. More... | |
void | pixel (const Point &p, const Color &color) |
Draw a pixel. More... | |
void | pixel (const Point &p, const ColorAlpha &color) |
Draw a pixel. More... | |
void | line (const Point &start, const Point &end, const Color &color) |
Draw a line. More... | |
void | line (const Point &start, const Point &end, const ColorAlpha &color) |
Draw a line. More... | |
void | rectangle (const Point &start, const Point &end, const Color &color, bool filled) |
Draw a rectangle on the current back buffer. More... | |
void | rectangle (const Point &start, const Point &end, const ColorAlpha &color, bool filled) |
Draw a rectangle on the current back buffer. More... | |
void | font (const Font &new_font) |
Change the current font for text output in video mode. More... | |
void | text (const Point &p, const char *string, unsigned len, const Color &color, const Font *font) |
Print text (without automatic word wrap). More... | |
void | text (const Point &p, const char *string, unsigned len, const ColorAlpha &color, const Font *font) |
Print text (without automatic word wrap). More... | |
void | image (const Point &p, PNG &image, unsigned width=0, unsigned height=0, unsigned offset_x=0, unsigned offset_y=0) |
Draw a PNG image (or detail) More... | |
void | image (const Point &p, const GIMP &image, unsigned width=0, unsigned height=0, unsigned offset_x=0, unsigned offset_y=0) |
Draw a GIMP image (or detail) More... | |
void | image (const Point &p, const Color *image, unsigned width, unsigned height, unsigned offset_x=0, unsigned offset_y=0) |
Draw a sprite. More... | |
void | image (const Point &p, const ColorAlpha *image, unsigned width, unsigned height, unsigned offset_x=0, unsigned offset_y=0) |
Draw a sprite with alpha blending (transparency). More... | |
virtual void | init (unsigned width, unsigned height, unsigned pitch)=0 |
Initialize printer with actual screen dimensions. More... | |
virtual void | buffer (void *lfb)=0 |
Set the video memory address. More... | |
virtual void | clear ()=0 |
Clear all pixel of the current back buffer (set full screen to black) More... | |
virtual bool | valid (const Point &p) const =0 |
Check if a Point can be displayed at the current resolution. More... | |
virtual unsigned | height () const =0 |
Number of vertical pixels in current resolution. More... | |
virtual unsigned | width () const =0 |
Number of horizontal pixels in current resolution. More... | |
virtual void | pixel (const Point &p, const Color &color)=0 |
Draw a pixel. More... | |
virtual void | pixel (const Point &p, const ColorAlpha &color)=0 |
Draw a pixel. More... | |
virtual void | line (const Point &start, const Point &end, const Color &color)=0 |
Draw a line. More... | |
virtual void | line (const Point &start, const Point &end, const ColorAlpha &color)=0 |
Draw a line. More... | |
virtual void | rectangle (const Point &start, const Point &end, const Color &color, bool filled=true)=0 |
Draw a rectangle on the current back buffer. More... | |
virtual void | rectangle (const Point &start, const Point &end, const ColorAlpha &color, bool filled=true)=0 |
Draw a rectangle on the current back buffer. More... | |
virtual void | font (const Font &new_font)=0 |
Change the current font for text output in video mode. More... | |
virtual void | text (const Point &p, const char *string, unsigned len, const Color &color, const Font *font=nullptr)=0 |
Print text (without automatic word wrap). More... | |
virtual void | text (const Point &p, const char *string, unsigned len, const ColorAlpha &color, const Font *font=nullptr)=0 |
Print text (without automatic word wrap). More... | |
virtual void | image (const Point &p, PNG &image, unsigned width=0, unsigned height=0, unsigned offset_x=0, unsigned offset_y=0)=0 |
Draw a PNG image (or detail) More... | |
virtual void | image (const Point &p, const GIMP &image, unsigned width=0, unsigned height=0, unsigned offset_x=0, unsigned offset_y=0)=0 |
Draw a GIMP image (or detail) More... | |
virtual void | image (const Point &p, const Color *image, unsigned width, unsigned height, unsigned offset_x=0, unsigned offset_y=0)=0 |
Draw a sprite. More... | |
virtual void | image (const Point &p, const ColorAlpha *image, unsigned width, unsigned height, unsigned offset_x=0, unsigned offset_y=0)=0 |
Draw a sprite with alpha blending (transparency). More... | |
Protected Member Functions | |
bool | checkMode (uint8_t required_COLORDEPTH, uint8_t required_red_offset, uint8_t required_green_offset, uint8_t required_blue_offset, uint8_t required_red_size, uint8_t required_green_size, uint8_t required_blue_size) |
Check if a printer is available for a video mode. More... | |
Protected Member Functions inherited from Framebuffer< COLORDEPTH, OFFSET_RED, OFFSET_GREEN, OFFSET_BLUE, BITS_RED, BITS_GREEN, BITS_BLUE > | |
void | init (const unsigned width, const unsigned height, const unsigned pitch) |
Initialize screen dimensions. More... | |
void | buffer (void *lfb) |
Set the video memory address. More... | |
void | clear () |
Clear all pixel of the current back buffer (set full screen to black) | |
Pixel * | get (const unsigned x, const unsigned y) const |
Get pixel at position. More... | |
Pixel * | get (const Point &p) const |
Get pixel at position. More... | |
template<enum SpriteColorMode COLOR, bool ALPHA, unsigned BITS> | |
void | set (const unsigned x, const unsigned y, const SpritePixel< COLOR, ALPHA, BITS > &color) |
Assign color to a pixel at a given position. More... | |
template<enum SpriteColorMode COLOR, bool ALPHA, unsigned BITS> | |
void | set (const Point &p, const SpritePixel< COLOR, ALPHA, BITS > &color) |
Assign color to a pixel at a given position. More... | |
virtual bool | checkMode (uint8_t colordepth, uint8_t offset_red, uint8_t offset_green, uint8_t offset_blue, uint8_t bits_red, uint8_t bits_green, uint8_t bits_blue)=0 |
Check if a printer is available for a video mode. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from AbstractGraphicsPrinter | |
static AbstractGraphicsPrinter * | getMode (uint8_t colordepth, uint8_t offset_red, uint8_t offset_green, uint8_t offset_blue, uint8_t bits_red, uint8_t bits_green, uint8_t bits_blue) |
Protected Attributes inherited from Framebuffer< COLORDEPTH, OFFSET_RED, OFFSET_GREEN, OFFSET_BLUE, BITS_RED, BITS_GREEN, BITS_BLUE > | |
unsigned | screen_width |
Visible width of the screen. | |
unsigned | screen_height |
Visible height of the screen. | |
Detailed Description
class GraphicsPrinter< COLORDEPTH, OFFSET_RED, OFFSET_GREEN, OFFSET_BLUE, BITS_RED, BITS_GREEN, BITS_BLUE >
Actual implementation of basic graphics printing functions.
The implementation as template class requires the definition of the desired video mode during compile time (which is required anyways since the video mode is set in the Multiboot headers). Hence, the compiler is able to optimize the (intensively used) code for the actual color bit masks, which results in high performance gain.
- Template Parameters
-
COLORDEPTH color depth of video mode OFFSET_RED Bit position of red color mask in video mode OFFSET_GREEN Bit position of green color mask in video mode OFFSET_BLUE Bit position of blue color mask in video mode BITS_RED Size of red color mask in video mode BITS_GREEN Size of green color mask in video mode BITS_BLUE Size of blue color mask in video mode
Member Function Documentation
|
inlineprotectedvirtual |
Check if a printer is available for a video mode.
This is required since printers are defined during compile time for performance reasons.
- Template Parameters
-
colordepth color depth of video mode offset_red Bit position of red color mask in video mode offset_green Bit position of green color mask in video mode offset_blue Bit position of blue color mask in video mode bits_red Size of red color mask in video mode bits_green Size of green color mask in video mode bits_blue Size of blue color mask in video mode
- Returns
true
if a printer for the video mode is available
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Initialize printer with actual screen dimensions.
- Parameters
-
width visible width of graphics screen height visible height of graphics screen pitch width of graphics screen (including invisible part, has to be at least width
)
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Set the video memory address.
- Parameters
-
lfb pointer to the linear framebuffer (lfb)
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Clear all pixel of the current back buffer (set full screen to black)
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Check if a Point can be displayed at the current resolution.
- Parameters
-
p Coordinates to check
- Returns
- 'true' if can be displayed
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Number of vertical pixels in current resolution.
- Returns
- Height of the screen in current video mode
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Number of horizontal pixels in current resolution.
- Returns
- Width of the screen in current video mode
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Draw a pixel.
- Parameters
-
p Coordinates of the pixel color Color of the pixel
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Draw a pixel.
- Parameters
-
p Coordinates of the pixel color Color of the pixel
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Draw a line.
- Parameters
-
start Coordinates of the begin of the line end Coordinates of the end of the line color Color of the line
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Draw a line.
- Parameters
-
start Coordinates of the begin of the line end Coordinates of the end of the line color Color of the line
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Draw a rectangle on the current back buffer.
- Parameters
-
start Coordinate of the rectangles upper left corner end Coordinate of the rectangles lower right corner color Color of the rectangle filled If set, the rectangle will be filled with the same color. (otherwise only borders will be drawn)
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Draw a rectangle on the current back buffer.
- Parameters
-
start Coordinate of the rectangles upper left corner end Coordinate of the rectangles lower right corner color Color of the rectangle filled If set, the rectangle will be filled with the same color. (otherwise only borders will be drawn)
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Change the current font for text output in video mode.
- Parameters
-
new_font Font to be used on subsequent calls to AbstractGraphicsPrinter::text() (without explicit font parameter)
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Print text (without automatic word wrap).
- Parameters
-
p Upper left start position of the text string Pointer to char array containing the text to be displayed len Number of characters to be displayed color Color for the text characters font Explicit font – or nullptr
to use default font (set by font method)
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Print text (without automatic word wrap).
- Parameters
-
p Upper left start position of the text string Pointer to char array containing the text to be displayed len Number of characters to be displayed color Color for the text characters font Explicit font – or nullptr
to use default font (set by font method)
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Draw a PNG image (or detail)
The image can has to be in a supported PNG format. Alpha blending (transparency) is supported.
- Parameters
-
p Coordinate of the images upper left corner image Source image to display width Width of the image detail (full image width of the source image if zero/default value) height Height of the image detail (full image height of the source if zero/default value) offset_x Right offset of the source image offset_y Top offset of the source image
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Draw a GIMP image (or detail)
The image has to be exported as C-source (without Glib
types!) in GIMP, alpha blending (transparency) is supported.
- Parameters
-
p Coordinate of the images upper left corner image Source image to display width Width of the image detail (full image width of the source image if zero/default value) height Height of the image detail (full image height of the source if zero/default value) offset_x Right offset of the source image offset_y Top offset of the source image
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Draw a sprite.
Each element in the source array will be displayed as a single pixel.
- Parameters
-
p Coordinate of the sprites upper left corner image Source sprite to display width Width of the sprite detail height Height of the sprite detail offset_x Right offset of the source sprite offset_y Top offset of the source sprite
Implements AbstractGraphicsPrinter.
|
inlinevirtual |
Draw a sprite with alpha blending (transparency).
Each element in the source array will be displayed as a single pixel.
- Parameters
-
p Coordinate of the sprites upper left corner image Source sprite to display width Width of the sprite detail height Height of the sprite detail offset_x Right offset of the source sprite offset_y Top offset of the source sprite
Implements AbstractGraphicsPrinter.
The documentation for this class was generated from the following file:
- graphics/printer.h