Changeset 00ddb40 in mainline


Ignore:
Timestamp:
2014-08-31T20:10:20Z (10 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5713e5f
Parents:
8d3512f1
Message:

Get rid of black alias at the edge of rotated windows

Location:
uspace
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/io/pixelmap.h

    r8d3512f1 r00ddb40  
    11/*
    22 * Copyright (c) 2011 Petr Koupy
     3 * Copyright (c) 2014 Martin Sucha
    34 * All rights reserved.
    45 *
     
    4041#include <unistd.h>
    4142#include <io/pixel.h>
     43
     44/* Defines how a pixel outside of pixmap rectangle shall be treated */
     45typedef enum {
     46        /* Pixels outside of a pixmap are PIXEL(0, 0, 0, 0) */
     47        PIXELMAP_EXTEND_TRANSPARENT_BLACK = 0,
     48       
     49        /* The pixmap is repeated infinetely */
     50        PIXELMAP_EXTEND_TILE,
     51       
     52        /* If outside of a pixmap, return closest pixel from the edge */
     53        PIXELMAP_EXTEND_SIDES,
     54       
     55        /* If outside of a pixmap, return closest pixel from the edge,
     56         * with alpha = 0
     57         */
     58        PIXELMAP_EXTEND_TRANSPARENT_SIDES
     59} pixelmap_extend_t;
    4260
    4361typedef struct {
     
    86104}
    87105
     106static inline pixel_t pixelmap_get_extended_pixel(pixelmap_t *pixmap,
     107    native_t x, native_t y, pixelmap_extend_t extend)
     108{
     109        bool transparent = false;
     110        if (extend == PIXELMAP_EXTEND_TILE) {
     111                x %= pixmap->width;
     112                y %= pixmap->height;
     113        }
     114        else if (extend == PIXELMAP_EXTEND_SIDES ||
     115            extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES) {
     116                bool transparent_outside =
     117                    (extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES);
     118                if (x < 0) {
     119                        x = 0;
     120                        transparent = transparent_outside;
     121                }
     122                else if (((sysarg_t) x) >= pixmap->width) {
     123                        x = pixmap->width - 1;
     124                        transparent = transparent_outside;
     125                }
     126               
     127                if (y < 0) {
     128                        y = 0;
     129                        transparent = transparent_outside;
     130                }
     131                else if (((sysarg_t) y) >= pixmap->height) {
     132                        y = pixmap->height - 1;
     133                        transparent = transparent_outside;
     134                }
     135        }
     136       
     137        if (x < 0 || ((sysarg_t) x) >= pixmap->width ||
     138            y < 0 || ((sysarg_t) y) >= pixmap->height)
     139                return PIXEL(0, 0, 0, 0);
     140
     141        pixel_t pixel = pixelmap_get_pixel(pixmap, x, y);
     142       
     143        if (transparent)
     144                pixel = PIXEL(0, RED(pixel), GREEN(pixel), BLUE(pixel));
     145       
     146        return pixel;
     147}
     148
     149
    88150#endif
    89151
  • uspace/lib/draw/font/bitmap_backend.c

    r8d3512f1 r00ddb40  
    143143        source_t source;
    144144        source_init(&source);
    145         source_set_texture(&source, raw_surface, false);
     145        source_set_texture(&source, raw_surface, PIXELMAP_EXTEND_TRANSPARENT_BLACK);
    146146
    147147        transform_t transform;
  • uspace/lib/draw/source.c

    r8d3512f1 r00ddb40  
    4545        source->color = PIXEL(0, 0, 0, 0);
    4646        source->texture = NULL;
    47         source->texture_tile = false;
     47        source->texture_extend = PIXELMAP_EXTEND_TRANSPARENT_BLACK;
    4848
    4949        source->alpha = PIXEL(255, 0, 0, 0);
    5050        source->mask = NULL;
    51         source->mask_tile = false;
     51        source->mask_extend = PIXELMAP_EXTEND_TRANSPARENT_BLACK;
    5252}
    5353
     
    7373}
    7474
    75 void source_set_texture(source_t *source, surface_t *texture, bool tile)
     75void source_set_texture(source_t *source, surface_t *texture,
     76    pixelmap_extend_t extend)
    7677{
    7778        source->texture = texture;
    78         source->texture_tile = tile;
     79        source->texture_extend = extend;
    7980}
    8081
     
    8485}
    8586
    86 void source_set_mask(source_t *source, surface_t *mask, bool tile)
     87void source_set_mask(source_t *source, surface_t *mask,
     88    pixelmap_extend_t extend)
    8789{
    8890        source->mask = mask;
    89         source->mask_tile = tile;
     91        source->mask_extend = extend;
    9092}
    9193
     
    9597            (source->alpha == (pixel_t) PIXEL(255, 0, 0, 0)) &&
    9698            (source->texture != NULL) &&
    97             (source->texture_tile == false) &&
     99            (source->texture_extend == PIXELMAP_EXTEND_TRANSPARENT_BLACK) &&
    98100            (transform_is_fast(&source->transform)));
    99101}
     
    120122                mask_pix = source->filter(
    121123                    surface_pixmap_access(source->mask),
    122                     x, y, source->mask_tile);
     124                    x, y, source->mask_extend);
    123125        } else {
    124126                mask_pix = source->alpha;
     
    133135                texture_pix = source->filter(
    134136                    surface_pixmap_access(source->texture),
    135                     x, y, source->texture_tile);
     137                    x, y, source->texture_extend);
    136138        } else {
    137139                texture_pix = source->color;
  • uspace/lib/draw/source.h

    r8d3512f1 r00ddb40  
    4242#include <transform.h>
    4343#include <filter.h>
     44#include <io/pixelmap.h>
    4445
    4546#include "surface.h"
     
    5152        pixel_t color;
    5253        surface_t *texture;
    53         bool texture_tile;
     54        pixelmap_extend_t texture_extend;
    5455
    5556        pixel_t alpha;
    5657        surface_t *mask;
    57         bool mask_tile;
     58        pixelmap_extend_t mask_extend;
    5859} source_t;
    5960
     
    6667
    6768extern void source_set_color(source_t *, pixel_t);
    68 extern void source_set_texture(source_t *, surface_t *, bool);
     69extern void source_set_texture(source_t *, surface_t *, pixelmap_extend_t);
    6970
    7071extern void source_set_alpha(source_t *, pixel_t);
    71 extern void source_set_mask(source_t *, surface_t *, bool);
     72extern void source_set_mask(source_t *, surface_t *, pixelmap_extend_t);
    7273
    7374extern bool source_is_fast(source_t *);
  • uspace/lib/gui/canvas.c

    r8d3512f1 r00ddb40  
    5858        source_init(&source);
    5959        source_set_transform(&source, transform);
    60         source_set_texture(&source, canvas->surface, false);
     60        source_set_texture(&source, canvas->surface,
     61            PIXELMAP_EXTEND_TRANSPARENT_BLACK);
    6162       
    6263        drawctx_t drawctx;
  • uspace/lib/softrend/filter.c

    r8d3512f1 r00ddb40  
    3838#include <io/pixel.h>
    3939
     40
    4041static long round(double val)
    4142{
     
    5960}
    6061
    61 static pixel_t get_pixel(pixelmap_t *pixmap, sysarg_t x, sysarg_t y, bool tile)
    62 {
    63         if (tile) {
    64                 x %= pixmap->width;
    65                 y %= pixmap->height;
    66         }
    67 
    68         return pixelmap_get_pixel(pixmap, (sysarg_t) x, (sysarg_t) y);
    69 }
    7062
    7163static inline pixel_t blend_pixels(size_t count, float *weights,
     
    8476}
    8577
    86 pixel_t filter_nearest(pixelmap_t *pixmap, double x, double y, bool tile)
     78pixel_t filter_nearest(pixelmap_t *pixmap, double x, double y,
     79    pixelmap_extend_t extend)
    8780{
    88         return get_pixel(pixmap, round(x), round(y), tile);
     81        return pixelmap_get_extended_pixel(pixmap, round(x), round(y), extend);
    8982}
    9083
    91 pixel_t filter_bilinear(pixelmap_t *pixmap, double x, double y, bool tile)
     84pixel_t filter_bilinear(pixelmap_t *pixmap, double x, double y,
     85    pixelmap_extend_t extend)
    9286{
    9387        long x1 = floor(x);
     
    9791       
    9892        if (y1 == y2 && x1 == x2) {
    99                 return get_pixel(pixmap, (sysarg_t) x1, (sysarg_t) y1,
    100                     tile);
     93                return pixelmap_get_extended_pixel(pixmap,
     94                    (sysarg_t) x1, (sysarg_t) y1, extend);
    10195        }
    10296       
     
    10599       
    106100        pixel_t pixels[4];
    107         pixels[0] = get_pixel(pixmap, x1, y1, tile);
    108         pixels[1] = get_pixel(pixmap, x2, y1, tile);
    109         pixels[2] = get_pixel(pixmap, x1, y2, tile);
    110         pixels[3] = get_pixel(pixmap, x2, y2, tile);
     101        pixels[0] = pixelmap_get_extended_pixel(pixmap, x1, y1, extend);
     102        pixels[1] = pixelmap_get_extended_pixel(pixmap, x2, y1, extend);
     103        pixels[2] = pixelmap_get_extended_pixel(pixmap, x1, y2, extend);
     104        pixels[3] = pixelmap_get_extended_pixel(pixmap, x2, y2, extend);
    111105       
    112106        float weights[4];
     
    119113}
    120114
    121 pixel_t filter_bicubic(pixelmap_t *pixmap, double x, double y, bool tile)
     115pixel_t filter_bicubic(pixelmap_t *pixmap, double x, double y,
     116    pixelmap_extend_t extend)
    122117{
    123118        // TODO
  • uspace/lib/softrend/filter.h

    r8d3512f1 r00ddb40  
    4040#include <io/pixelmap.h>
    4141
    42 typedef pixel_t (*filter_t)(pixelmap_t *, double, double, bool);
     42typedef pixel_t (*filter_t)(pixelmap_t *, double, double, pixelmap_extend_t);
    4343
    44 extern pixel_t filter_nearest(pixelmap_t *, double, double, bool);
    45 extern pixel_t filter_bilinear(pixelmap_t *, double, double, bool);
    46 extern pixel_t filter_bicubic(pixelmap_t *, double, double, bool);
     44extern pixel_t filter_nearest(pixelmap_t *, double, double, pixelmap_extend_t);
     45extern pixel_t filter_bilinear(pixelmap_t *, double, double, pixelmap_extend_t);
     46extern pixel_t filter_bicubic(pixelmap_t *, double, double, pixelmap_extend_t);
    4747
    4848#endif
  • uspace/srv/hid/compositor/compositor.c

    r8d3512f1 r00ddb40  
    444444
    445445                                        source_set_transform(&source, transform);
    446                                         source_set_texture(&source, win->surface, false);
     446                                        source_set_texture(&source, win->surface,
     447                                            PIXELMAP_EXTEND_TRANSPARENT_SIDES);
    447448                                        source_set_alpha(&source, PIXEL(win->opacity, 0, 0, 0));
    448449
Note: See TracChangeset for help on using the changeset viewer.