示例#1
0
文件: vm_segment.c 项目: akat1/impala
/**
 * Rezerwuje ciągły obszar w danym segmencie.
 * @param vseg deskryptor segmentu.
 * @param size rozmiar ciągłego obszaru.
 * @param _res adres zmiennej, do uzupełnienia przydzielonym adresem.
 */
int
vm_seg_reserve(vm_seg_t *vseg, vm_size_t size, void *_res)
{
    int expand = EXPAND_UP;
    vm_addr_t *res = _res;
    size = PAGE_ROUND(size);
    vm_region_t *region = list_head(&vseg->regions);
    if (region == NULL) {
        if (do_first_region(vseg, &region)) return -1;
    }

    // sprawdzamy czy istnieje dziura pomiędzy początkiem segmentu
    // a pierwszym regionem
    if (size < region->begin - vseg->base) {
        *res = region->begin - size;
        return expand_region(vseg, region, size, EXPAND_DOWN, _res);
    }

    // Ok, no to szukamy dziury za regionem
    region = list_find(&vseg->regions, has_hole_after_reg, size);
    if (region == NULL) {
        if (vseg->flags & VM_SEG_EXPDOWN) {
            expand = EXPAND_DOWN;
            region = list_head(&vseg->regions);
            *res = region->begin - size;
        } else {
            region = list_tail(&vseg->regions);
            *res = region->end;
        }
    } else {
        *res = region->end;
    }
    return expand_region(vseg, region, size, expand, _res);
}
示例#2
0
/**
 * meta_make_border_region:
 * @region: a #cairo_region_t
 * @x_amount: distance from the border to extend horizontally
 * @y_amount: distance from the border to extend vertically
 * @flip: if true, the result is computed with x and y interchanged
 *
 * Computes the "border region" of a given region, which is roughly
 * speaking the set of points near the boundary of the region.  If we
 * define the operation of growing a region as computing the set of
 * points within a given manhattan distance of the region, then the
 * border is 'grow(region) intersect grow(inverse(region))'.
 *
 * If we create an image by filling the region with a solid color,
 * the border is the region affected by blurring the region.
 *
 * Return value: a new region which is the border of the given region
 */
cairo_region_t *
meta_make_border_region (cairo_region_t *region,
                         int             x_amount,
                         int             y_amount,
                         gboolean        flip)
{
  cairo_region_t *border_region;
  cairo_region_t *inverse_region;

  border_region = expand_region (region, x_amount, y_amount, flip);
  inverse_region = expand_region_inverse (region, x_amount, y_amount, flip);
  cairo_region_intersect (border_region, inverse_region);
  cairo_region_destroy (inverse_region);

  return border_region;
}