2
* Copyright © 1998 Keith Packard
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.
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.
23
#include "pixmanint.h"
25
#include "pixman-xserver-compat.h"
28
FbPixelsInit (FbPixels *pixels, pixman_bits_t *buf, int width, int height, int depth, int bpp, int stride);
31
pixman_bits_per_pixel (unsigned int depth);
34
pixman_bits_per_pixel (unsigned int depth)
51
FbPixelsCreate (int width, int height, int depth)
55
unsigned int buf_size;
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);
67
adjust = 8 - (base & 7);
70
pixels = calloc(base + buf_size, 1);
74
buf = (pixman_bits_t *) ((char *)pixels + base + adjust);
76
FbPixelsInit (pixels, buf, width, height, depth, bpp, stride);
82
FbPixelsCreateForData (pixman_bits_t *data, int width, int height, int depth, int bpp, int stride)
86
pixels = malloc (sizeof (FbPixels));
90
FbPixelsInit (pixels, data, width, height, depth, bpp, stride);
96
FbPixelsInit (FbPixels *pixels, pixman_bits_t *buf, int width, int height, int depth, int bpp, int stride)
99
pixels->width = width;
100
pixels->height = height;
101
pixels->depth = depth;
103
pixels->stride = stride;
110
FbPixelsDestroy (FbPixels *pixels)