diff options
author | Simon Glass <sjg@chromium.org> | 2016-01-14 18:10:37 -0700 |
---|---|---|
committer | Anatolij Gustschin <agust@denx.de> | 2016-01-30 10:53:26 +0100 |
commit | f266178698307608ee23741e69b9626196e66481 (patch) | |
tree | cee098f37679faf65c38592bb1e8f212fa78885f /include/video_console.h | |
parent | 6e42e251964d79117f4b3d16a2352083037a251c (diff) | |
download | u-boot-f266178698307608ee23741e69b9626196e66481.tar.gz |
video: Use fractional units for X coordinates
With anti-aliased fonts we need a more fine-grained horizontal position
than a single pixel. Characters can be positioned to start part-way through
a pixel, with anti-aliasing (greyscale edges) taking care of the visual
effect.
To cope with this, use fractional units (1/256 pixel) for horizontal
positions in the text console.
Signed-off-by: Simon Glass <sjg@chromium.org>
[agust: rebased]
Signed-off-by: Anatolij Gustschin <agust@denx.de>
Diffstat (limited to 'include/video_console.h')
-rw-r--r-- | include/video_console.h | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/include/video_console.h b/include/video_console.h index c0fc79273a..eeba368d63 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -7,21 +7,37 @@ #ifndef __video_console_h #define __video_console_h +#define VID_FRAC_DIV 256 + +#define VID_TO_PIXEL(x) ((x) / VID_FRAC_DIV) +#define VID_TO_POS(x) ((x) * VID_FRAC_DIV) + /** * struct vidconsole_priv - uclass-private data about a console device * + * Drivers must set up @rows, @cols, @x_charsize, @y_charsize in their probe() + * method. Drivers may set up @xstart_frac if desired. + * * @sdev: stdio device, acting as an output sink - * @curr_col: Current text column (0=left) - * @curr_row: Current row (0=top) + * @xcur_frac: Current X position, in fractional units (VID_TO_POS(x)) + * @curr_row: Current Y position in pixels (0=top) * @rows: Number of text rows * @cols: Number of text columns + * @x_charsize: Character width in pixels + * @y_charsize: Character height in pixels + * @tab_width_frac: Tab width in fractional units + * @xsize_frac: Width of the display in fractional units */ struct vidconsole_priv { struct stdio_dev sdev; - int curr_col; - int curr_row; + int xcur_frac; + int ycur; int rows; int cols; + int x_charsize; + int y_charsize; + int tab_width_frac; + int xsize_frac; }; /** @@ -36,12 +52,15 @@ struct vidconsole_ops { * putc_xy() - write a single character to a position * * @dev: Device to write to - * @x: Pixel X position (0=left-most pixel) + * @x_frac: Fractional pixel X position (0=left-most pixel) which + * is the X position multipled by VID_FRAC_DIV. * @y: Pixel Y position (0=top-most pixel) * @ch: Character to write - * @return 0 if OK, -ve on error + * @return number of fractional pixels that the cursor should move, + * if all is OK, -EAGAIN if we ran out of space on this line, other -ve + * on error */ - int (*putc_xy)(struct udevice *dev, uint x, uint y, char ch); + int (*putc_xy)(struct udevice *dev, uint x_frac, uint y, char ch); /** * move_rows() - Move text rows from one place to another @@ -75,10 +94,13 @@ struct vidconsole_ops { * vidconsole_putc_xy() - write a single character to a position * * @dev: Device to write to - * @x: Pixel X position (0=left-most pixel) + * @x_frac: Fractional pixel X position (0=left-most pixel) which + * is the X position multipled by VID_FRAC_DIV. * @y: Pixel Y position (0=top-most pixel) * @ch: Character to write - * @return 0 if OK, -ve on error + * @return number of fractional pixels that the cursor should move, + * if all is OK, -EAGAIN if we ran out of space on this line, other -ve + * on error */ int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch); |