Changeset 7e38970d in mainline for uspace/lib/gfx/src


Ignore:
Timestamp:
2020-12-07T00:08:37Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
25f26600
Parents:
7a873f0 (diff), 8596474 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'jxsvoboda-gfx' into master

Location:
uspace/lib/gfx/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gfx/src/bitmap.c

    r7a873f0 r7e38970d  
    6262 *
    6363 * @return EOK on success, EINVAL if parameters are invald,
    64  *         ENOMEM if insufficient resources, EIO if grahic device connection
     64 *         ENOMEM if insufficient resources, EIO if graphic device connection
    6565 *         was lost
    6666 */
     
    9292 * @param bitmap Bitmap
    9393 *
    94  * @return EOK on success, EIO if grahic device connection was lost
     94 * @return EOK on success, EIO if graphic device connection was lost
    9595 */
    9696errno_t gfx_bitmap_destroy(gfx_bitmap_t *bitmap)
     
    112112 * @param offs Bitmap offset or @c NULL for zero offset
    113113 *
    114  * @return EOK on success, EIO if grahic device connection was lost
     114 * @return EOK on success, EIO if graphic device connection was lost
    115115 */
    116116errno_t gfx_bitmap_render(gfx_bitmap_t *bitmap, gfx_rect_t *srect,
     
    125125 * @param alloc Allocation info structure to fill in
    126126 *
    127  * @return EOK on success, EIO if grahic device connection was lost
     127 * @return EOK on success, EIO if graphic device connection was lost
    128128 */
    129129errno_t gfx_bitmap_get_alloc(gfx_bitmap_t *bitmap, gfx_bitmap_alloc_t *alloc)
  • uspace/lib/gfx/src/coord.c

    r7a873f0 r7e38970d  
    3939#include <stddef.h>
    4040
     41/** Divide @a a by @a b and round towards negative numbers.
     42 *
     43 * Regular integer division always rounds towards zero. This is not useful
     44 * e.g. for scaling down, where we always need to round towards negative
     45 * numbers.
     46 *
     47 * @param a Dividend
     48 * @param b Divisor
     49 * @return Quotient
     50 */
     51gfx_coord_t gfx_coord_div_rneg(gfx_coord_t a, gfx_coord_t b)
     52{
     53        if ((a > 0 && b > 0) || (a < 0 && b < 0)) {
     54                /* Result is non-negative, round towards zero */
     55                return a / b;
     56        } else {
     57                /* Result is negative, round away from zero */
     58                return (a - b + 1) / b;
     59        }
     60}
     61
    4162/** Add two vectors.
    4263 *
     
    217238}
    218239
     240/** Center rectangle on rectangle.
     241 *
     242 * Translate rectangle @a a so that its center coincides with the
     243 * center of rectangle @a b, saving the result in @a dest.
     244 *
     245 * @param a Rectnagle to translate
     246 * @param b Rectangle on which to center
     247 * @param dest Place to store resulting rectangle
     248 */
     249void gfx_rect_ctr_on_rect(gfx_rect_t *a, gfx_rect_t *b, gfx_rect_t *dest)
     250{
     251        gfx_coord2_t adim;
     252        gfx_coord2_t bdim;
     253
     254        gfx_rect_dims(a, &adim);
     255        gfx_rect_dims(b, &bdim);
     256
     257        dest->p0.x = b->p0.x + bdim.x / 2 - adim.x / 2;
     258        dest->p0.y = b->p0.y + bdim.y / 2 - adim.y / 2;
     259
     260        dest->p1.x = dest->p0.x + adim.x;
     261        dest->p1.y = dest->p0.y + adim.y;
     262}
     263
    219264/** Sort points of a rectangle.
    220265 *
Note: See TracChangeset for help on using the changeset viewer.