~ubuntu-branches/ubuntu/intrepid/libcairo/intrepid

« back to all changes in this revision

Viewing changes to pixman/src/icpixels.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher, Fabien Tassin
  • Date: 2007-12-21 11:46:45 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20071221114645-v1bx91voavqus4uw
Tags: 1.5.4-0ubuntu1
* debian/rules:
  - updated shlibs version

[ Fabien Tassin ]
* new upstream snapshot: 1.5.4
* Drop patches no longer useful:
  - debian/patches/91_malloc-overflow-fixes.dpatch
  - debian/patches/90_from_git_fix_zero_sized_bitmap_handling.dpatch
  - debian/patches/90_from_git_fix_not_available_glyph_handling.dpatch
* Replace Ubuntu's lcd patch by patch from Freedesktop bug #10301
  - drop debian/patches/02-cairo-1.4.8-lcd-filter-2.dpatch
  - add debian/patches/02-lcd_filter_freedesktop_bug10301.patch
* Move from 16.16 to 24.8 fixed point precision
  - add debian/patches/01-fixed_point_24.8_precision.dpatch
* Add libpixman-1-dev (>= 0.9.4) to Build-deps
  - update debian/control
* Update debian/patches/00list

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 1998 Keith Packard
3
 
 *
4
 
 * Permission to use, copy, modify, distribute, and sell this software and its
5
 
 * documentation for any purpose is hereby granted without fee, provided that
6
 
 * the above copyright notice appear in all copies and that both that
7
 
 * copyright notice and this permission notice appear in supporting
8
 
 * documentation, and that the name of Keith Packard not be used in
9
 
 * advertising or publicity pertaining to distribution of the software without
10
 
 * specific, written prior permission.  Keith Packard makes no
11
 
 * representations about the suitability of this software for any purpose.  It
12
 
 * is provided "as is" without express or implied warranty.
13
 
 *
14
 
 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15
 
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16
 
 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17
 
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18
 
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19
 
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
 
 * PERFORMANCE OF THIS SOFTWARE.
21
 
 */
22
 
 
23
 
#include "pixmanint.h"
24
 
 
25
 
#include "pixman-xserver-compat.h"
26
 
 
27
 
static void
28
 
FbPixelsInit (FbPixels *pixels, pixman_bits_t *buf, int width, int height, int depth, int bpp, int stride);
29
 
 
30
 
static unsigned int
31
 
pixman_bits_per_pixel (unsigned int depth);
32
 
 
33
 
static unsigned int
34
 
pixman_bits_per_pixel (unsigned int depth)
35
 
{
36
 
    if (depth > 8)
37
 
        if (depth > 16)
38
 
            return 32;
39
 
        else
40
 
            return 16;
41
 
    else
42
 
        if (depth > 4)
43
 
            return 8;
44
 
        else if (depth > 1)
45
 
            return 4;
46
 
        else
47
 
            return 1;
48
 
}
49
 
 
50
 
FbPixels *
51
 
FbPixelsCreate (int width, int height, int depth)
52
 
{
53
 
    FbPixels            *pixels;
54
 
    pixman_bits_t               *buf;
55
 
    unsigned int        buf_size;
56
 
    unsigned int        bpp;
57
 
    unsigned int        stride;
58
 
    unsigned int        adjust;
59
 
    unsigned int        base;
60
 
 
61
 
    bpp = pixman_bits_per_pixel (depth);
62
 
    stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (pixman_bits_t);
63
 
    buf_size = height * stride;
64
 
    base = sizeof (FbPixels);
65
 
    adjust = 0;
66
 
    if (base & 7)
67
 
        adjust = 8 - (base & 7);
68
 
    buf_size += adjust;
69
 
 
70
 
    pixels = calloc(base + buf_size, 1);
71
 
    if (!pixels)
72
 
        return NULL;
73
 
 
74
 
    buf = (pixman_bits_t *) ((char *)pixels + base + adjust);
75
 
 
76
 
    FbPixelsInit (pixels, buf, width, height, depth, bpp, stride);
77
 
 
78
 
    return pixels;
79
 
}
80
 
 
81
 
FbPixels *
82
 
FbPixelsCreateForData (pixman_bits_t *data, int width, int height, int depth, int bpp, int stride)
83
 
{
84
 
    FbPixels *pixels;
85
 
 
86
 
    pixels = malloc (sizeof (FbPixels));
87
 
    if (pixels == NULL)
88
 
        return NULL;
89
 
 
90
 
    FbPixelsInit (pixels, data, width, height, depth, bpp, stride);
91
 
 
92
 
    return pixels;
93
 
}
94
 
 
95
 
static void
96
 
FbPixelsInit (FbPixels *pixels, pixman_bits_t *buf, int width, int height, int depth, int bpp, int stride)
97
 
{
98
 
    pixels->data = buf;
99
 
    pixels->width = width;
100
 
    pixels->height = height;
101
 
    pixels->depth = depth;
102
 
    pixels->bpp = bpp;
103
 
    pixels->stride = stride;
104
 
    pixels->x = 0;
105
 
    pixels->y = 0;
106
 
    pixels->refcnt = 1;
107
 
}
108
 
 
109
 
void
110
 
FbPixelsDestroy (FbPixels *pixels)
111
 
{
112
 
    if(--pixels->refcnt)
113
 
        return;
114
 
 
115
 
    free(pixels);
116
 
}