picture.h revision f0ab104f070bc7f569404826fea1828ed985638c
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * Copyright © 2000 SuSE, Inc.
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * Permission to use, copy, modify, distribute, and sell this software and its
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * documentation for any purpose is hereby granted without fee, provided that
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * the above copyright notice appear in all copies and that both that
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * copyright notice and this permission notice appear in supporting
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * documentation, and that the name of SuSE not be used in advertising or
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * publicity pertaining to distribution of the software without specific,
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * written prior permission. SuSE makes no representations about the
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * suitability of this software for any purpose. It is provided "as is"
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * without express or implied warranty.
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * Author: Keith Packard, SuSE, Inc.
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * While the protocol is generous in format support, the
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * sample implementation allows only packed RGB and GBR
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * representations for data to simplify software rendering,
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define PICT_FORMAT(bpp,type,a,r,g,b) PIXMAN_FORMAT(bpp, type, a, r, g, b)
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * gray/color formats use a visual index instead of argb
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \
f0ab104f070bc7f569404826fea1828ed985638cvboxsync/* 32bpp formats */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync/* 24bpp formats */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync/* 16bpp formats */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync/* 8bpp formats */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync/* 4bpp formats */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync/* 1bpp formats */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * For dynamic indexed visuals (GrayScale and PseudoColor), these control the
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * selection of colors allocated for drawing to Pictures. The default
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * policy depends on the size of the colormap:
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * Size Default Policy
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * ----------------------------
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * < 64 PolicyMono
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * < 256 PolicyGray
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * 256 PolicyColor (only on PseudoColor)
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * The actual allocation code lives in miindex.c, and so is
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * austensibly server dependent, but that code does:
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * PolicyMono Allocate no additional colors, use black and white
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * PolicyGray Allocate 13 gray levels (11 cells used)
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used)
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * PolicyAll Allocate as big a cube as possible, fill with gray (all)
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * Here's a picture to help understand how many colors are
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * actually allocated (this is just the gray ramp):
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * gray level
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * b/w 0000 ffff
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * 4x4x4 5555 aaaa
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * The default colormap supplies two gray levels (black/white), the
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * 4x4x4 cube allocates another two and nine more are allocated to fill
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * in the 13 levels. When the 4x4x4 cube is not allocated, a total of
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * 11 cells are allocated.
f0ab104f070bc7f569404826fea1828ed985638cvboxsyncextern _X_EXPORT int PictureParseCmapPolicy (const char *name);
f0ab104f070bc7f569404826fea1828ed985638cvboxsync/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * An unadorned "xFixed" is the same as xFixed_16_16,
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * (since it's quite common in the code)
f0ab104f070bc7f569404826fea1828ed985638cvboxsync/* whether 't' is a well defined not obviously empty trapezoid */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * Standard NTSC luminance conversions:
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * y = r * 0.299 + g * 0.587 + b * 0.114
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * Approximate this for a bit more speed:
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * y = (r * 153 + g * 301 + b * 58) / 512
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * This gives 17 bits of luminance; to get 15 bits, lop the low two
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#endif /* _PICTURE_H_ */