diff options
author | Carl Worth <cworth@cworth.org> | 2006-02-13 16:45:28 -0800 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2006-02-13 16:45:28 -0800 |
commit | 5df303fcb78a5388ed0017cecab8033368f57dd8 (patch) | |
tree | c85201f744a22f1c3b43690a36bde71ac0f71068 | |
parent | 6aff3cbf96dca64e755075add11acc7fc35d6ebd (diff) |
Remove pixman since it shouldn't exist at this point of the history.SNAPSHOT_0_1_16
39 files changed, 0 insertions, 14345 deletions
diff --git a/pixman/.cvsignore b/pixman/.cvsignore deleted file mode 100644 index 45cc1f33f..000000000 --- a/pixman/.cvsignore +++ /dev/null @@ -1,13 +0,0 @@ -Makefile -Makefile.in -aclocal.m4 -config.cache -config.h -config.h.in -config.log -config.status -configure -libpixregion.pc -libtool -stamp-h -stamp-h.in diff --git a/pixman/AUTHORS b/pixman/AUTHORS deleted file mode 100644 index 1c0d9be2b..000000000 --- a/pixman/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -X Window System authors -(libpixregion now maintained by Carl Worth <cworth@isi.edu>) diff --git a/pixman/COPYING b/pixman/COPYING deleted file mode 100644 index b1d09b94d..000000000 --- a/pixman/COPYING +++ /dev/null @@ -1,42 +0,0 @@ -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. diff --git a/pixman/ChangeLog.libic b/pixman/ChangeLog.libic deleted file mode 100644 index b9b78c21e..000000000 --- a/pixman/ChangeLog.libic +++ /dev/null @@ -1,295 +0,0 @@ -2003-11-25 Carl Worth <cworth@east.isi.edu> - - * configure.in: Bump version to 0.1.5 for new 64-bit fixes. - - * src/icutil.c (icStipple8Bits): One more fix needed for 64-bit - machine (alpha in this case). Thanks to Jakub Bogusz - <qboosh@pld-linux.org>. - -2003-11-17 Carl Worth <cworth@isi.edu> - - * src/icutil.c (icStipple1Bits): - * src/icrop.h (IcStipple16Bits): Fixes needed to compile libic on - x86_64. Many thanks to David R Bacon <dbacon@cis.ksu.edu>. - -2003-11-06 Carl Worth <cworth@east.isi.edu> - - * configure.in: Bump version to 0.1.4 just to mark removal of the - version from ic.h, (so not an interesting change and nothing worth - upgrading to). - - * src/ic.h: Remove IC_MAJOR, IC_MINOR, and IC_REVISION, (which - were stale anyway so less than useful). - -2003-10-31 Carl Worth <cworth@isi.edu> - - * configure.in (LIBIC_VERSION): Bump version to 0.1.3 for new IcImageGetDepth. - - * src/icimage.c (IcImageGetDepth): Add IcImageGetDepth. - -2003-10-29 Carl Worth <cworth@isi.edu> - - * src/icimage.h: Remove currently unused DevUnion datatype to - squelch compiler warning. Remove prototype for currently - unimplemented IcImageChange function. - - * src/icimage.c (IcImageDestroy): Fixed memory leak of - image->transform. - -2003-10-29 Carl Worth <cworth@east.isi.edu> - - * configure.in: Drop AC_CONFIG_AUX_DIR(config) as it was confusing - "make distcheck" - -2003-10-29 Carl Worth <cworth@east.isi.edu> - - * configure.in: Bumped version to 0.1.2 to indicate new IcOperator - type. - - * Everywhere: A large patch from Bryan Worth <bryan@theworths.org> - to eliminate lots of leftover, undesired dependencies on X header - files. More details below: - - * src/ictransform.c: - * src/ictrap.c: - * src/ictri.c: - * src/icrect.c: - * src/iccompose.c: - * src/iccolor.c: - * src/icbltone.c: - * src/icblt.c: - * src/icimage.h: - * src/icimage.c: - * src/ic.c: - Replace CARD8/16/32 with uint8/16/32_t. - Replace INT16 with int16_t. - Use IcOperator in place of char or uint8_t. - Replace Bool/FALSE/TRUE with int/0/1. - - * src/icint.h: Remove includes of X11/X.h, X11/Xmd.h, - X11/Xprotostr.h and X11/extensions/Xrender.h. Add IcPoint. Lift - definitions from X headers for Mask, GXor, ClipByChildren, - PolyEdgeSharp, PolyModePrecise, CPClipMask, and CPLastBit. - - * src/icimage.h: Remove includes of X11/Xdefs.h and X11/Xprotostr.h. - Replace "pointer" with "void *". - Remove include of X11/Xutil.h. - Replace DDXPointRec with IcPoint. - Replace Atom/XID with unsigned long. - - * src/icimage.c: Remove instances of BadAlloc and Success. - Replace XID with unsigned int. - Replace "pointer" with "void *". - Replace Atom with unsigned long. - - * src/ic.h: Introduce new IcOperator enum, rather than using char - or uint8_t. - -2003-09-09 Carl Worth <cworth@isi.edu> - - * configure.in (SLIM_REQUIRED): Updated calls to slim_hidden_def - to track changes in slim 0.2.0. - -2003-09-05 Carl Worth <cworth@isi.edu> - - * configure.in (LIBIC_VERSION): Bumped version to 0.1.1. - - * src/ictrap.c (IcCreateAlphaPicture): Fixed memory leak. - - * src/icimage.h: icimage->image_format now a struct not a - pointer. Rename integral format_name to format_code. - - * src/iccompose.c: Remove unused functions: IcCombineSaturateU, - IcCombineSaturateC, IcFetch_a2b2g2r2, IcFetch_c8, IcFetch_c4, - IcFetch_g1, IcStore_c8, IcStore_g8, IcStore_c4, IcStore_g4, - IcStore_g1. - - * src/iccolor.c (_IcOnes): Rename Ones to _IcOnes and expose it - for internal use. - - * src/ic.h: Changed IcFormatName from an int to an enum. - Changed IcFormat from an exposed struct to an opaque type. - Now expose IcFormatCreate, IcFormatCreateMasks, and - IcFormatDestroy. - -2003-09-02 Carl Worth <cworth@isi.edu> - - * src/ic.h: Include inttypes.h rather than stdint.h on OpenBSD, - (Michael Schubert <michael@schubert.cx>) - -2003-07-31 Richard Henderson <rth@twiddle.net> - - * src/iccolor.c (Ones): Define as __builtin_popcount when available. - -2003-07-31 Richard Henderson <rth@twiddle.net> - - * configure.in: Check for slim revision. - * libic.pc.in: Depend on slim. - - * src/ic.c, src/iccompose.c: Don't include icimage.h. - * src/icimage.h: Don't include ic.h. - - * src/ic.h: Include slim_{export,import}.h as appropriate. Mark all - symbols __external_linkage. - * src/icint.h: Include slim_import.h; mark symbols __internal_linkage; - add slim hidden_proto declarations. - * src/icimage.h: Mark all symbols __internal_linkage. - * src/icrop.h: Likewise. - - * src/ic.c (IcComposite): Provide hidden definition. - * src/iccolor.c (IcColorToPixel): Likewise. - * src/icformat.c (IcFormatInit): Likewise. - * src/icimage.c (IcImageCreate, IcImageDestroy): Likewise. - (IcImageSetRepeat): Likewise. - * src/icrect.c (IcFillRectangles): Likewise. - * src/tri.c (IcRasterizeTriangle): Make static. - -2003-07-31 Richard Henderson <rth@twiddle.net> - - * src/ic.c: Make everything but IcComposite static. - * src/iccompose.c: Make everything except IcBuildCompositeOperand - and IcCompositeGeneral static. - * src/icbltone.c (Ic8Lane, Ic16Lane, Ic32Lane): Make static. - (IcLaneTable): Turn into a function. - (IcBltOne): Make IcLane const. - (icStipple24Bits): Make static. - * src/icimage.h: Remove lots of now static declarations. - * src/icrop.h: Likewise. - * src/icutil.c (icStipple8Bits, icStipple4Bits): Make static. - (icStipple2Bits, icStipple1Bits): Make static. - (IcStippleTable): Turn into a function. - -2003-07-30 Carl Worth <cworth@isi.edu> - - * src/ic.h: Fixed IcRectangle to be compatible with XRectangle. - -2003-07-29 Billy Biggs <vektor@dumbterm.net> - - * src/ic.h: Changed all references to CARD*/INT* to use stdint - names, (eg. uint32_t, int32_t). - -2003-07-10 Anders Carlsson <andersca@codefactory.se> - - * autogen.sh: - Pass --enable-maintainer-mode to configure - - * configure.in: - Add compiler warning flags to CFLAGS. - -2003-07-09 Anders Carlsson <andersca@codefactory.se> - - * src/ic.h: - * src/icimage.c: (IcImageGetData): - Add accessor for getting a pointer to the image data. - -2003-07-09 Anders Carlsson <andersca@codefactory.se> - - * src/ic.h: - * src/icimage.c: (IcImageGetWidth), (IcImageGetHeight), - (IcImageGetStride): - Add accessors. - -2003-05-14 Carl Worth <cworth@isi.edu> - - * src/ic.h: Add IcImageSetFilter. Fixed transform support. - -2003-05-05 Carl Worth <cworth@isi.edu> - - * src/ictrap.c (IcCompositeTrapezoids): Avoid crash if there's - nothing to draw. - -2003-04-26 Carl Worth <cworth@isi.edu> - - * src/icimage.c (IcImageDestroy): Fix memory leak of image->pixels - when owns_pixels == 1; - -2003-04-25 Carl Worth <cworth@east.isi.edu> - - * src/ic.h (IC_REVISION): Added #defines for version. - Don't reference undefined XFixed datatype. - Added IcFixed16_16, IcPointFixed, IcLineFixed, IcRectangle, - IcTriangle, and IcTrapzezoid to eliminate X datatypes in public - interface. - - * configure.in: Fixed libtool versioning. - -2003-04-17 Carl Worth <cworth@isi.edu> - - * src/icint.h: Removed reliance on some server include files, - (this included copy and paste of Xserver/render/picture.h into - icint.h) - - * src/icformat.c (IcFormatInit): Replaced public - IcFormatCreate/IcFormatDestroy with IcFormatInit and an exposed - IcFormat structure. - (_IcFormatCreate): Tracked changes now that IcFormat no longer has - direct and indexed sub-structure. - - * src/iccompose.c: Commented out all code supporting indexed - formats. - - * src/ic.h: Expose IcFormat structure, (with no support for - indexed formats). - - * src/ic.c (IcComposite): Track changes in IcImage structure - (format vs. format_name) - -2003-03-10 Carl Worth <cworth@isi.edu> - - * src/Makefile.am (INCLUDES): Cleaned up to no longer require - includes from X server source tree. - -2003-03-05 Carl Worth <cworth@isi.edu> - - * src/ictri.c (IcTriangles): - (IcTriStrip): - (IcTriFan): fixed argument order to match XRender - - * src/icrect.c (IcRectangle): Add IcRectangle convenience function. - (IcRectangles): fixed argument order to match XRender - - * src/ictri.c (IcTriangles): - (IcTriStrip): - (IcTriFan): Removed format argument from IcTri* functions. - - * src/ictrap.c (IcTrapezoids): Removed format argument from - IcTrapezoids. - - * src/icrect.c (IcRectangles): Initial (painfully slow) - implementation of IcRectangles. - - * src/icimage.c (IcImageCreate): Simplified IcImageCreate, (no - longer requires mask/vlist/error/error_value) - (IcImageSetRepeat): Added IcImageSetRepeat - (IcImageSetClipRegion): Implemented simple IcImageSetClipRegion. - -2003-02-25 Carl Worth <cworth@isi.edu> - - * src/icimage.c (IcImageInit): - (IcImageDestroy): - (IcImageDestroyClip): - (IcClipImageReg): - (IcClipImageSrc): - (IcClipImageSrc): - (SetPictureClipRects): - (IcComputeCompositeRegion): Converted to use libpixregion rather - than region code from Xlib. - - * src/iccompose.c (IcFetch_transform): Converted to use - libpixregion rather than region code from Xlib. - - * src/ic.c (IcComposite): Converted to use libpixregion rather - than region code from Xlib. - -2003-02-21 Carl Worth <cworth@isi.edu> - - * src/ictri.c (IcRasterizeTriangle): Added triangle support to - libic. - - * src/ic.h: Started cleaning up the public interface of - libic. Moved most of the cruft into icint.h. - -2003-02-20 Carl Worth <cworth@isi.edu> - - * AUTHORS: Added AUTHORS, NEWS, ChangeLog. - diff --git a/pixman/ChangeLog.libpixregion b/pixman/ChangeLog.libpixregion deleted file mode 100644 index fe5be9dbb..000000000 --- a/pixman/ChangeLog.libpixregion +++ /dev/null @@ -1,42 +0,0 @@ -2003-10-29 Carl Worth <cworth@east.isi.edu> - - * configure.in: Drop AC_CONFIG_AUX_DIR(config) as it was confusing - "make distcheck" - -2003-09-09 Carl Worth <cworth@isi.edu> - - * configure.in (SLIM_REQUIRED): Updated calls to slim_hidden_def - to track changes in slim 0.2.0. - -2003-07-30 Carl Worth <cworth@east.isi.edu> - - * src/pixregion.h: Implement our own 'extern "C"' block to avoid - false dependency on X. - - * configure.in: Remove unnecessary AC_PATH_XTRA check for X - headers. - -2003-07-30 Richard Henderson <rth@twiddle.net> - - * configure.in: Run PKG_CHECK_MODULES on slim. - * libpixregion.pc.in: Require slim. - * src/pixregion.c (PixRegionCreateSimple): Mark hidden. - (PixRegionCopy, PixRegionUnion): Mark hidden. - * src/pixregion.h: Include and use X11/Xfuncproto.h. Include - slim_{export,import}.h as appropriate. Mark all functions with - __external_linkage. - * src/pixregionint.h: Rename include protect to _PIXREGIONINT_H_. - -2003-04-22 Carl Worth <cworth@isi.edu> - - * configure.in (LIBPIXREGION_MAJOR_VERSION): Fixed typo (Owen Taylor) - -2003-02-25 Carl Worth <cworth@isi.edu> - - * src/pixregion.c (PixRegionCreateSimple): Eliminated useless size - parameter from PixRegionCreateSized, (the server only ever calls - it with a value of 1 or 0). - (PixRegionInit): - (PixRegionUninit): - (PixRegionBreak): Changed these three functions to be static. - diff --git a/pixman/ChangeLog.slim b/pixman/ChangeLog.slim deleted file mode 100644 index c830bf7e1..000000000 --- a/pixman/ChangeLog.slim +++ /dev/null @@ -1,39 +0,0 @@ -2003-09-23 Carl Worth <cworth@east.isi.edu> - - * src/slim_internal.h: The slim_hidden_def macros were causing - build failures with gcc 2.95.4. I've bumped the test for these - macros up to: __GNUC__ >= 3. We'll see if that's sufficient. - -2003-09-09 Carl Worth <cworth@isi.edu> - - * configure.in (SLIM_VERSION): Bump version number to 0.2.0 - instead, (this is an incompatible change after all). - - * configure.in (SLIM_VERSION): Bump version number to 0.1.1 - - * src/slim_internal.h (slim_hidden_def): Remove ';' from macro - definition, (forcing the user to provide it which looks better - anyway). This also helps to avoid confusing etags. - -2003-07-31 Richard Henderson <rth@twiddle.net> - - * src/slim_internal.h (__internal_linkage): Attribute visibility - not present until gcc 3.3. - -2003-07-30 Richard Henderson <rth@twiddle.net> - - * Makefile.am (EXTRA_DIST, pkgconfigdir, pkgconfig_DATA): New. - * configure.in (AC_OUTPUT): Add slim.pc. - * slim.pc.in: New file. - -2003-07-30 Richard Henderson <rth@twiddle.net> - - * src/slim_internal.h: New file. - * src/slim_export.h: New file. - * src/slim_import.h: New file. - * src/Makefile.am (include_HEADERS): Add them. - * configure.in (AC_INIT): Check for src/slim_export.h - -2003-07-29 Carl Worth <cworth@isi.edu> - - * Create package skeleton. diff --git a/pixman/INSTALL b/pixman/INSTALL deleted file mode 100644 index 5ccf1c308..000000000 --- a/pixman/INSTALL +++ /dev/null @@ -1,9 +0,0 @@ -This code uses automake, in order to generate the Makefiles use: - - $ autogen.sh - -After that, standard build procedures apply: - - $ make - # make install - diff --git a/pixman/Makefile.am b/pixman/Makefile.am deleted file mode 100644 index 80f361c83..000000000 --- a/pixman/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -SUBDIRS = . src - -EXTRA_DIST = \ - COPYING \ - libpixregion.pc.in - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libpixregion.pc diff --git a/pixman/NEWS b/pixman/NEWS deleted file mode 100644 index 8b1378917..000000000 --- a/pixman/NEWS +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pixman/README b/pixman/README deleted file mode 100644 index 95d3b44e0..000000000 --- a/pixman/README +++ /dev/null @@ -1,15 +0,0 @@ -libpixregion - Pixel region Library - -libpixregion is a generic library for manipulating pixel regions. A -PixRegion is a set of Y-X banded rectangles that cover the desired -region. - -The original code for libxregion was part of the reference X server -implementation of the X Window System. A modified copy of the code -also exists in the Xlib client library. libpixregion was formed so -that both the X server and client libraries could share common code -for region manipulation. - -libpixregion is also intended to be applicable outside of the X Window -System. The public interface of libpixregion does not depend on any -part of the X Window System. diff --git a/pixman/autogen.sh b/pixman/autogen.sh deleted file mode 100755 index 61b269ab8..000000000 --- a/pixman/autogen.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# Run this to generate all the initial makefiles, etc. - -set -e - -ARGV0=$0 - -if test -z "$ACLOCAL_FLAGS"; then - acdir=`aclocal --print-ac-dir` - if [ ! -f $acdir/pkg.m4 ]; then - echo "$ARGV0: Error: Could not find pkg-config macros." - echo " (Looked in $acdir/pkg.m4)" - echo " If pkg.m4 is available in /another/directory, please set" - echo " ACLOCAL_FLAGS=\"-I /another/directory\"" - echo " Otherwise, please install pkg-config." - echo "" - echo "pkg-config is available from:" - echo "http://www.freedesktop.org/software/pkgconfig/" - exit 1 - fi -fi - -if test -z "$*"; then - echo "$ARGV0: Note: \`./configure' will be run with no arguments." - echo " If you wish to pass any to it, please specify them on the" - echo " \`$0' command line." - echo -fi - -do_cmd() { - echo "$ARGV0: running \`$@'" - $@ -} - -do_cmd libtoolize --force --copy - -do_cmd aclocal ${ACLOCAL_FLAGS} - -do_cmd autoheader - -do_cmd automake --add-missing - -do_cmd autoconf - -do_cmd ./configure --enable-maintainer-mode ${1+"$@"} && echo "Now type \`make' to compile" || exit 1 diff --git a/pixman/configure.in b/pixman/configure.in deleted file mode 100644 index 00ea4e8a2..000000000 --- a/pixman/configure.in +++ /dev/null @@ -1,52 +0,0 @@ -# Process this file with autoconf to produce a configure script. - -AC_INIT(src/pixregion.h) - -dnl =========================================================================== - -# Package version number, (as distinct from shared library version) -# This must be manually synchronized with the version in src/ic.h -LIBPIXREGION_VERSION=0.1.0 - -# libtool shared library version - -# Increment if the interface has additions, changes, removals. -LT_CURRENT=1 - -# Increment any time the source changes; set to -# 0 if you increment CURRENT -LT_REVISION=0 - -# Increment if any interfaces have been added; set to 0 -# if any interfaces have been removed. removal has -# precedence over adding, so set to 0 if both happened. -LT_AGE=0 - -VERSION_INFO="$LT_CURRENT:$LT_REVISION:$LT_AGE" -AC_SUBST(VERSION_INFO) - -dnl =========================================================================== - -AM_INIT_AUTOMAKE(libpixregion, $LIBPIXREGION_VERSION) -AM_CONFIG_HEADER(config.h) - -AM_MAINTAINER_MODE - -AC_PROG_CC -AM_PROG_LIBTOOL - -dnl =========================================================================== - -SLIM_REQUIRED=0.2.0 -PKG_CHECK_MODULES(LIBPIXREGION, slim >= $SLIM_REQUIRED) - -AC_SUBST(LIBPIXREGION_CFLAGS) -AC_SUBST(LIBPIXREGION_LIBS) - -dnl =========================================================================== - -AC_OUTPUT([ -libpixregion.pc -Makefile -src/Makefile -]) diff --git a/pixman/libpixman.pc.in b/pixman/libpixman.pc.in deleted file mode 100644 index b7077064b..000000000 --- a/pixman/libpixman.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libpixregion -Description: Pixel region library -Requires: slim -Version: @VERSION@ -Libs: -L${libdir} -lpixregion -Cflags: -I${includedir} diff --git a/pixman/src/.cvsignore b/pixman/src/.cvsignore deleted file mode 100644 index dce75bf1e..000000000 --- a/pixman/src/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile -Makefile.in -*.la -*.lo -.libs -.deps diff --git a/pixman/src/Makefile.am b/pixman/src/Makefile.am deleted file mode 100644 index 3785b4064..000000000 --- a/pixman/src/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -lib_LTLIBRARIES = libpixregion.la -include_HEADERS = pixregion.h - -libpixregion_la_SOURCES = \ - pixregion.c \ - pixregion.h \ - pixregionint.h - -libpixregion_la_LDFLAGS = -version-info @VERSION_INFO@ - -INCLUDES = $(LIBPIXREGION_CFLAGS) - -libpixregion_la_LIBADD = $(LIBPIXREGION_LIBS) diff --git a/pixman/src/ic.c b/pixman/src/ic.c deleted file mode 100644 index 6c2369306..000000000 --- a/pixman/src/ic.c +++ /dev/null @@ -1,1140 +0,0 @@ -/* - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#include "icint.h" - -#ifndef __GNUC__ -#define __inline -#endif - - -#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \ - (((s) >> 5) & 0x07e0) | \ - (((s) >> 8) & 0xf800)) -#define cvt0565to8888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \ - ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \ - ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000))) - -#if IMAGE_BYTE_ORDER == MSBFirst -#define Fetch24(a) ((unsigned long) (a) & 1 ? \ - ((*(a) << 16) | *((uint16_t *) ((a)+1))) : \ - ((*((uint16_t *) (a)) << 8) | *((a)+2))) -#define Store24(a,v) ((unsigned long) (a) & 1 ? \ - ((*(a) = (uint8_t) ((v) >> 16)), \ - (*((uint16_t *) ((a)+1)) = (uint16_t) (v))) : \ - ((*((uint16_t *) (a)) = (uint16_t) ((v) >> 8)), \ - (*((a)+2) = (uint8_t) (v)))) -#else -#define Fetch24(a) ((unsigned long) (a) & 1 ? \ - ((*(a)) | (*((uint16_t *) ((a)+1)) << 8)) : \ - ((*((uint16_t *) (a))) | (*((a)+2) << 16))) -#define Store24(a,v) ((unsigned long) (a) & 1 ? \ - ((*(a) = (uint8_t) (v)), \ - (*((uint16_t *) ((a)+1)) = (uint16_t) ((v) >> 8))) : \ - ((*((uint16_t *) (a)) = (uint16_t) (v)),\ - (*((a)+2) = (uint8_t) ((v) >> 16)))) -#endif - -static uint32_t -IcOver (uint32_t x, uint32_t y) -{ - uint16_t a = ~x >> 24; - uint16_t t; - uint32_t m,n,o,p; - - m = IcOverU(x,y,0,a,t); - n = IcOverU(x,y,8,a,t); - o = IcOverU(x,y,16,a,t); - p = IcOverU(x,y,24,a,t); - return m|n|o|p; -} - -static uint32_t -IcOver24 (uint32_t x, uint32_t y) -{ - uint16_t a = ~x >> 24; - uint16_t t; - uint32_t m,n,o; - - m = IcOverU(x,y,0,a,t); - n = IcOverU(x,y,8,a,t); - o = IcOverU(x,y,16,a,t); - return m|n|o; -} - -static uint32_t -IcIn (uint32_t x, uint8_t y) -{ - uint16_t a = y; - uint16_t t; - uint32_t m,n,o,p; - - m = IcInU(x,0,a,t); - n = IcInU(x,8,a,t); - o = IcInU(x,16,a,t); - p = IcInU(x,24,a,t); - return m|n|o|p; -} - -#define IcComposeGetSolid(image, bits) { \ - IcBits *__bits__; \ - IcStride __stride__; \ - int __bpp__; \ - int __xoff__,__yoff__; \ -\ - IcGetPixels((image)->pixels,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \ - switch (__bpp__) { \ - case 32: \ - (bits) = *(uint32_t *) __bits__; \ - break; \ - case 24: \ - (bits) = Fetch24 ((uint8_t *) __bits__); \ - break; \ - case 16: \ - (bits) = *(uint16_t *) __bits__; \ - (bits) = cvt0565to8888(bits); \ - break; \ - default: \ - return; \ - } \ - /* manage missing src alpha */ \ - if ((image)->image_format.alphaMask == 0) \ - (bits) |= 0xff000000; \ -} - -#define IcComposeGetStart(image,x,y,type,stride,line,mul) {\ - IcBits *__bits__; \ - IcStride __stride__; \ - int __bpp__; \ - int __xoff__,__yoff__; \ -\ - IcGetPixels((image)->pixels,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \ - (stride) = __stride__ * sizeof (IcBits) / sizeof (type); \ - (line) = ((type *) __bits__) + (stride) * ((y) - __yoff__) + (mul) * ((x) - __xoff__); \ -} - -/* - * Naming convention: - * - * opSRCxMASKxDST - */ - -static void -IcCompositeSolidMask_nx8x8888 (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - uint32_t src, srca; - uint32_t *dstLine, *dst, d, dstMask; - uint8_t *maskLine, *mask, m; - IcStride dstStride, maskStride; - uint16_t w; - - IcComposeGetSolid(iSrc, src); - - dstMask = IcFullMask (iDst->pixels->depth); - srca = src >> 24; - if (src == 0) - return; - - IcComposeGetStart (iDst, xDst, yDst, uint32_t, dstStride, dstLine, 1); - IcComposeGetStart (iMask, xMask, yMask, uint8_t, maskStride, maskLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - while (w--) - { - m = *mask++; - if (m == 0xff) - { - if (srca == 0xff) - *dst = src & dstMask; - else - *dst = IcOver (src, *dst) & dstMask; - } - else if (m) - { - d = IcIn (src, m); - *dst = IcOver (d, *dst) & dstMask; - } - dst++; - } - } -} - -static void -IcCompositeSolidMask_nx8888x8888C (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - uint32_t src, srca; - uint32_t *dstLine, *dst, d, dstMask; - uint32_t *maskLine, *mask, ma; - IcStride dstStride, maskStride; - uint16_t w; - uint32_t m, n, o, p; - - IcComposeGetSolid(iSrc, src); - - dstMask = IcFullMask (iDst->pixels->depth); - srca = src >> 24; - if (src == 0) - return; - - IcComposeGetStart (iDst, xDst, yDst, uint32_t, dstStride, dstLine, 1); - IcComposeGetStart (iMask, xMask, yMask, uint32_t, maskStride, maskLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - while (w--) - { - ma = *mask++; - if (ma == 0xffffffff) - { - if (srca == 0xff) - *dst = src & dstMask; - else - *dst = IcOver (src, *dst) & dstMask; - } - else if (ma) - { - d = *dst; -#define IcInOverC(src,srca,msk,dst,i,result) { \ - uint16_t __a = IcGet8(msk,i); \ - uint32_t __t, __ta; \ - uint32_t __i; \ - __t = IcIntMult (IcGet8(src,i), __a,__i); \ - __ta = (uint8_t) ~IcIntMult (srca, __a,__i); \ - __t = __t + IcIntMult(IcGet8(dst,i),__ta,__i); \ - __t = (uint32_t) (uint8_t) (__t | (-(__t >> 8))); \ - result = __t << (i); \ -} - IcInOverC (src, srca, ma, d, 0, m); - IcInOverC (src, srca, ma, d, 8, n); - IcInOverC (src, srca, ma, d, 16, o); - IcInOverC (src, srca, ma, d, 24, p); - *dst = m|n|o|p; - } - dst++; - } - } -} - -static void -IcCompositeSolidMask_nx8x0888 (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - uint32_t src, srca; - uint8_t *dstLine, *dst; - uint32_t d; - uint8_t *maskLine, *mask, m; - IcStride dstStride, maskStride; - uint16_t w; - - IcComposeGetSolid(iSrc, src); - - srca = src >> 24; - if (src == 0) - return; - - IcComposeGetStart (iDst, xDst, yDst, uint8_t, dstStride, dstLine, 3); - IcComposeGetStart (iMask, xMask, yMask, uint8_t, maskStride, maskLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - while (w--) - { - m = *mask++; - if (m == 0xff) - { - if (srca == 0xff) - d = src; - else - { - d = Fetch24(dst); - d = IcOver24 (src, d); - } - Store24(dst,d); - } - else if (m) - { - d = IcOver24 (IcIn(src,m), Fetch24(dst)); - Store24(dst,d); - } - dst += 3; - } - } -} - -static void -IcCompositeSolidMask_nx8x0565 (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - uint32_t src, srca; - uint16_t *dstLine, *dst; - uint32_t d; - uint8_t *maskLine, *mask, m; - IcStride dstStride, maskStride; - uint16_t w; - - IcComposeGetSolid(iSrc, src); - - srca = src >> 24; - if (src == 0) - return; - - IcComposeGetStart (iDst, xDst, yDst, uint16_t, dstStride, dstLine, 1); - IcComposeGetStart (iMask, xMask, yMask, uint8_t, maskStride, maskLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - while (w--) - { - m = *mask++; - if (m == 0xff) - { - if (srca == 0xff) - d = src; - else - { - d = *dst; - d = IcOver24 (src, cvt0565to8888(d)); - } - *dst = cvt8888to0565(d); - } - else if (m) - { - d = *dst; - d = IcOver24 (IcIn(src,m), cvt0565to8888(d)); - *dst = cvt8888to0565(d); - } - dst++; - } - } -} - -static void -IcCompositeSolidMask_nx8888x0565C (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - uint32_t src, srca; - uint16_t src16; - uint16_t *dstLine, *dst; - uint32_t d; - uint32_t *maskLine, *mask, ma; - IcStride dstStride, maskStride; - uint16_t w; - uint32_t m, n, o; - - IcComposeGetSolid(iSrc, src); - - srca = src >> 24; - if (src == 0) - return; - - src16 = cvt8888to0565(src); - - IcComposeGetStart (iDst, xDst, yDst, uint16_t, dstStride, dstLine, 1); - IcComposeGetStart (iMask, xMask, yMask, uint32_t, maskStride, maskLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - while (w--) - { - ma = *mask++; - if (ma == 0xffffffff) - { - if (srca == 0xff) - { - *dst = src16; - } - else - { - d = *dst; - d = IcOver24 (src, cvt0565to8888(d)); - *dst = cvt8888to0565(d); - } - } - else if (ma) - { - d = *dst; - d = cvt0565to8888(d); - IcInOverC (src, srca, ma, d, 0, m); - IcInOverC (src, srca, ma, d, 8, n); - IcInOverC (src, srca, ma, d, 16, o); - d = m|n|o; - *dst = cvt8888to0565(d); - } - dst++; - } - } -} - -static void -IcCompositeSrc_8888x8888 (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - uint32_t *dstLine, *dst, dstMask; - uint32_t *srcLine, *src, s; - IcStride dstStride, srcStride; - uint8_t a; - uint16_t w; - - IcComposeGetStart (iDst, xDst, yDst, uint32_t, dstStride, dstLine, 1); - IcComposeGetStart (iSrc, xSrc, ySrc, uint32_t, srcStride, srcLine, 1); - - dstMask = IcFullMask (iDst->pixels->depth); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - { - s = *src++; - a = s >> 24; - if (a == 0xff) - *dst = s & dstMask; - else if (a) - *dst = IcOver (s, *dst) & dstMask; - dst++; - } - } -} - -static void -IcCompositeSrc_8888x0888 (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - uint8_t *dstLine, *dst; - uint32_t d; - uint32_t *srcLine, *src, s; - uint8_t a; - IcStride dstStride, srcStride; - uint16_t w; - - IcComposeGetStart (iDst, xDst, yDst, uint8_t, dstStride, dstLine, 3); - IcComposeGetStart (iSrc, xSrc, ySrc, uint32_t, srcStride, srcLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - { - s = *src++; - a = s >> 24; - if (a) - { - if (a == 0xff) - d = s; - else - d = IcOver24 (s, Fetch24(dst)); - Store24(dst,d); - } - dst += 3; - } - } -} - -static void -IcCompositeSrc_8888x0565 (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - uint16_t *dstLine, *dst; - uint32_t d; - uint32_t *srcLine, *src, s; - uint8_t a; - IcStride dstStride, srcStride; - uint16_t w; - - IcComposeGetStart (iSrc, xSrc, ySrc, uint32_t, srcStride, srcLine, 1); - IcComposeGetStart (iDst, xDst, yDst, uint16_t, dstStride, dstLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - { - s = *src++; - a = s >> 24; - if (a) - { - if (a == 0xff) - d = s; - else - { - d = *dst; - d = IcOver24 (s, cvt0565to8888(d)); - } - *dst = cvt8888to0565(d); - } - dst++; - } - } -} - -static void -IcCompositeSrc_0565x0565 (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - uint16_t *dstLine, *dst; - uint16_t *srcLine, *src; - IcStride dstStride, srcStride; - uint16_t w; - - IcComposeGetStart (iSrc, xSrc, ySrc, uint16_t, srcStride, srcLine, 1); - - IcComposeGetStart (iDst, xDst, yDst, uint16_t, dstStride, dstLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - *dst++ = *src++; - } -} - -static void -IcCompositeSrcAdd_8000x8000 (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - uint8_t *dstLine, *dst; - uint8_t *srcLine, *src; - IcStride dstStride, srcStride; - uint8_t w; - uint8_t s, d; - uint16_t t; - - IcComposeGetStart (iSrc, xSrc, ySrc, uint8_t, srcStride, srcLine, 1); - IcComposeGetStart (iDst, xDst, yDst, uint8_t, dstStride, dstLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - { - s = *src++; - if (s != 0xff) - { - d = *dst; - t = d + s; - s = t | (0 - (t >> 8)); - } - *dst++ = s; - } - } -} - -static void -IcCompositeSrcAdd_8888x8888 (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - uint32_t *dstLine, *dst; - uint32_t *srcLine, *src; - IcStride dstStride, srcStride; - uint16_t w; - uint32_t s, d; - uint16_t t; - uint32_t m,n,o,p; - - IcComposeGetStart (iSrc, xSrc, ySrc, uint32_t, srcStride, srcLine, 1); - IcComposeGetStart (iDst, xDst, yDst, uint32_t, dstStride, dstLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - { - s = *src++; - if (s != 0xffffffff) - { - d = *dst; - if (d) - { - m = IcAdd(s,d,0,t); - n = IcAdd(s,d,8,t); - o = IcAdd(s,d,16,t); - p = IcAdd(s,d,24,t); - s = m|n|o|p; - } - } - *dst++ = s; - } - } -} - -static void -IcCompositeSrcAdd_1000x1000 (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - IcBits *dstBits, *srcBits; - IcStride dstStride, srcStride; - int dstBpp, srcBpp; - int dstXoff, dstYoff; - int srcXoff, srcYoff; - - IcGetPixels(iSrc->pixels, srcBits, srcStride, srcBpp, srcXoff, srcYoff); - - IcGetPixels(iDst->pixels, dstBits, dstStride, dstBpp, dstXoff, dstYoff); - - IcBlt (srcBits + srcStride * (ySrc + srcYoff), - srcStride, - xSrc + srcXoff, - - dstBits + dstStride * (yDst + dstYoff), - dstStride, - xDst + dstXoff, - - width, - height, - - GXor, - IC_ALLONES, - srcBpp, - - 0, - 0); -} - -static void -IcCompositeSolidMask_nx1xn (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - IcBits *dstBits; - IcStip *maskBits; - IcStride dstStride, maskStride; - int dstBpp, maskBpp; - int dstXoff, dstYoff; - int maskXoff, maskYoff; - IcBits src; - - IcComposeGetSolid(iSrc, src); - - if ((src & 0xff000000) != 0xff000000) - { - IcCompositeGeneral (op, iSrc, iMask, iDst, - xSrc, ySrc, xMask, yMask, xDst, yDst, - width, height); - return; - } - IcGetStipPixels (iMask->pixels, maskBits, maskStride, maskBpp, maskXoff, maskYoff); - IcGetPixels (iDst->pixels, dstBits, dstStride, dstBpp, dstXoff, dstYoff); - - switch (dstBpp) { - case 32: - break; - case 24: - break; - case 16: - src = cvt8888to0565(src); - break; - } - - src = IcReplicatePixel (src, dstBpp); - - IcBltOne (maskBits + maskStride * (yMask + maskYoff), - maskStride, - xMask + maskXoff, - - dstBits + dstStride * (yDst + dstYoff), - dstStride, - (xDst + dstXoff) * dstBpp, - dstBpp, - - width * dstBpp, - height, - - 0x0, - src, - IC_ALLONES, - 0x0); -} - -# define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) - -void -IcComposite (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int xSrc, - int ySrc, - int xMask, - int yMask, - int xDst, - int yDst, - int width, - int height) -{ - PixRegion *region; - int n; - PixRegionBox *pbox; - CompositeFunc func; - int srcRepeat = iSrc->repeat; - int maskRepeat = 0; - int srcAlphaMap = iSrc->alphaMap != 0; - int maskAlphaMap = 0; - int dstAlphaMap = iDst->alphaMap != 0; - int x_msk, y_msk, x_src, y_src, x_dst, y_dst; - int w, h, w_this, h_this; - - xDst += iDst->pixels->x; - yDst += iDst->pixels->y; - xSrc += iSrc->pixels->x; - ySrc += iSrc->pixels->y; - if (iMask) - { - xMask += iMask->pixels->x; - yMask += iMask->pixels->y; - maskRepeat = iMask->repeat; - maskAlphaMap = iMask->alphaMap != 0; - } - - region = PixRegionCreate(); - PixRegionUnionRect (region, region, xDst, yDst, width, height); - - if (!IcComputeCompositeRegion (region, - iSrc, - iMask, - iDst, - xSrc, - ySrc, - xMask, - yMask, - xDst, - yDst, - width, - height)) - return; - - func = IcCompositeGeneral; - if (!iSrc->transform && !(iMask && iMask->transform)) - if (!maskAlphaMap && !srcAlphaMap && !dstAlphaMap) - switch (op) { - case IcOperatorOver: - if (iMask) - { - if (srcRepeat && - iSrc->pixels->width == 1 && - iSrc->pixels->height == 1) - { - srcRepeat = 0; - if (PICT_FORMAT_COLOR(iSrc->format_code)) { - switch (iMask->format_code) { - case PICT_a8: - switch (iDst->format_code) { - case PICT_r5g6b5: - case PICT_b5g6r5: - func = IcCompositeSolidMask_nx8x0565; - break; - case PICT_r8g8b8: - case PICT_b8g8r8: - func = IcCompositeSolidMask_nx8x0888; - break; - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - func = IcCompositeSolidMask_nx8x8888; - break; - } - break; - case PICT_a8r8g8b8: - if (iMask->componentAlpha) { - switch (iDst->format_code) { - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - func = IcCompositeSolidMask_nx8888x8888C; - break; - case PICT_r5g6b5: - func = IcCompositeSolidMask_nx8888x0565C; - break; - } - } - break; - case PICT_a8b8g8r8: - if (iMask->componentAlpha) { - switch (iDst->format_code) { - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - func = IcCompositeSolidMask_nx8888x8888C; - break; - case PICT_b5g6r5: - func = IcCompositeSolidMask_nx8888x0565C; - break; - } - } - break; - case PICT_a1: - switch (iDst->format_code) { - case PICT_r5g6b5: - case PICT_b5g6r5: - case PICT_r8g8b8: - case PICT_b8g8r8: - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - func = IcCompositeSolidMask_nx1xn; - break; - } - } - } - } - } - else - { - switch (iSrc->format_code) { - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - switch (iDst->format_code) { - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - func = IcCompositeSrc_8888x8888; - break; - case PICT_r8g8b8: - func = IcCompositeSrc_8888x0888; - break; - case PICT_r5g6b5: - func = IcCompositeSrc_8888x0565; - break; - } - break; - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - switch (iDst->format_code) { - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - func = IcCompositeSrc_8888x8888; - break; - case PICT_b8g8r8: - func = IcCompositeSrc_8888x0888; - break; - case PICT_b5g6r5: - func = IcCompositeSrc_8888x0565; - break; - } - break; - case PICT_r5g6b5: - switch (iDst->format_code) { - case PICT_r5g6b5: - func = IcCompositeSrc_0565x0565; - break; - } - break; - case PICT_b5g6r5: - switch (iDst->format_code) { - case PICT_b5g6r5: - func = IcCompositeSrc_0565x0565; - break; - } - break; - } - } - break; - case IcOperatorAdd: - if (iMask == 0) - { - switch (iSrc->format_code) { - case PICT_a8r8g8b8: - switch (iDst->format_code) { - case PICT_a8r8g8b8: - func = IcCompositeSrcAdd_8888x8888; - break; - } - break; - case PICT_a8b8g8r8: - switch (iDst->format_code) { - case PICT_a8b8g8r8: - func = IcCompositeSrcAdd_8888x8888; - break; - } - break; - case PICT_a8: - switch (iDst->format_code) { - case PICT_a8: - func = IcCompositeSrcAdd_8000x8000; - break; - } - break; - case PICT_a1: - switch (iDst->format_code) { - case PICT_a1: - func = IcCompositeSrcAdd_1000x1000; - break; - } - break; - } - } - break; - default: - func = IcCompositeGeneral; - break; - } - n = PixRegionNumRects (region); - pbox = PixRegionRects (region); - while (n--) - { - h = pbox->y2 - pbox->y1; - y_src = pbox->y1 - yDst + ySrc; - y_msk = pbox->y1 - yDst + yMask; - y_dst = pbox->y1; - while (h) - { - h_this = h; - w = pbox->x2 - pbox->x1; - x_src = pbox->x1 - xDst + xSrc; - x_msk = pbox->x1 - xDst + xMask; - x_dst = pbox->x1; - if (maskRepeat) - { - y_msk = mod (y_msk, iMask->pixels->height); - if (h_this > iMask->pixels->height - y_msk) - h_this = iMask->pixels->height - y_msk; - } - if (srcRepeat) - { - y_src = mod (y_src, iSrc->pixels->height); - if (h_this > iSrc->pixels->height - y_src) - h_this = iSrc->pixels->height - y_src; - } - while (w) - { - w_this = w; - if (maskRepeat) - { - x_msk = mod (x_msk, iMask->pixels->width); - if (w_this > iMask->pixels->width - x_msk) - w_this = iMask->pixels->width - x_msk; - } - if (srcRepeat) - { - x_src = mod (x_src, iSrc->pixels->width); - if (w_this > iSrc->pixels->width - x_src) - w_this = iSrc->pixels->width - x_src; - } - (*func) (op, iSrc, iMask, iDst, - x_src, y_src, x_msk, y_msk, x_dst, y_dst, - w_this, h_this); - w -= w_this; - x_src += w_this; - x_msk += w_this; - x_dst += w_this; - } - h -= h_this; - y_src += h_this; - y_msk += h_this; - y_dst += h_this; - } - pbox++; - } - PixRegionDestroy (region); -} -slim_hidden_def(IcComposite); diff --git a/pixman/src/ic.h b/pixman/src/ic.h deleted file mode 100644 index bc5541c94..000000000 --- a/pixman/src/ic.h +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef IC_H_INCLUDED -#define IC_H_INCLUDED - -#if defined (__SVR4) && defined (__sun) -# include <sys/int_types.h> -#else -# if defined (__OpenBSD__) -# include <inttypes.h> -# else -# include <stdint.h> -# endif -#endif - -#include <pixregion.h> - -#ifdef _ICINT_H_ -#include <slim_export.h> -#else -#include <slim_import.h> -#endif - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -/* icformat.c */ - - -typedef enum _IcOperator { - IcOperatorClear, - IcOperatorSrc, - IcOperatorDst, - IcOperatorOver, - IcOperatorOverReverse, - IcOperatorIn, - IcOperatorInReverse, - IcOperatorOut, - IcOperatorOutReverse, - IcOperatorAtop, - IcOperatorAtopReverse, - IcOperatorXor, - IcOperatorAdd, - IcOperatorSaturate, -} IcOperator; - - -typedef enum _IcFormatName { - IcFormatNameARGB32, - IcFormatNameRGB24, - IcFormatNameA8, - IcFormatNameA1 -} IcFormatName; - -typedef struct _IcFormat IcFormat; - -extern IcFormat * __external_linkage -IcFormatCreate (IcFormatName name); - -extern IcFormat * __external_linkage -IcFormatCreateMasks (int bpp, - int alpha_mask, - int red_mask, - int green_mask, - int blue_mask); - -extern void __external_linkage -IcFormatDestroy (IcFormat *format); - -/* icimage.c */ - -typedef struct _IcImage IcImage; - -extern IcImage * __external_linkage -IcImageCreate (IcFormat *format, - int width, - int height); - -/* - * This single define controls the basic size of data manipulated - * by this software; it must be log2(sizeof (IcBits) * 8) - */ - -#ifndef IC_SHIFT -# if defined(__alpha__) || defined(__alpha) || \ - defined(ia64) || defined(__ia64__) || \ - defined(__sparc64__) || \ - defined(__s390x__) || \ - defined(x86_64) || defined (__x86_64__) -#define IC_SHIFT 6 -typedef uint64_t IcBits; -# else -#define IC_SHIFT 5 -typedef uint32_t IcBits; -# endif -#endif - -extern IcImage * __external_linkage -IcImageCreateForData (IcBits *data, IcFormat *format, int width, int height, int bpp, int stride); - -extern void __external_linkage -IcImageDestroy (IcImage *image); - -extern int __external_linkage -IcImageSetClipRegion (IcImage *image, - PixRegion *region); - -typedef int IcFixed16_16; - -typedef struct _IcPointFixed { - IcFixed16_16 x, y; -} IcPointFixed; - -typedef struct _IcLineFixed { - IcPointFixed p1, p2; -} IcLineFixed; - -/* XXX: It's goofy that IcRectangle has integers while all the other - datatypes have fixed-point values. (Though by design, - IcFillRectangles is designed to fill only whole pixels) */ -typedef struct _IcRectangle { - short x, y; - unsigned short width, height; -} IcRectangle; - -typedef struct _IcTriangle { - IcPointFixed p1, p2, p3; -} IcTriangle; - -typedef struct _IcTrapezoid { - IcFixed16_16 top, bottom; - IcLineFixed left, right; -} IcTrapezoid; - -typedef struct _IcVector { - IcFixed16_16 vector[3]; -} IcVector; - -typedef struct _IcTransform { - IcFixed16_16 matrix[3][3]; -} IcTransform; - -typedef enum { - IcFilterFast, - IcFilterGood, - IcFilterBest, - IcFilterNearest, - IcFilterBilinear -} IcFilter; - -extern int __external_linkage -IcImageSetTransform (IcImage *image, - IcTransform *transform); - -extern void __external_linkage -IcImageSetRepeat (IcImage *image, - int repeat); - -extern void __external_linkage -IcImageSetFilter (IcImage *image, - IcFilter filter); - -extern int __external_linkage -IcImageGetWidth (IcImage *image); - -extern int __external_linkage -IcImageGetHeight (IcImage *image); - -extern int __external_linkage -IcImageGetStride (IcImage *image); - -extern int __external_linkage -IcImageGetDepth (IcImage *image); - -extern IcFormat * __external_linkage -IcImageGetFormat (IcImage *image); - -extern IcBits * __external_linkage -IcImageGetData (IcImage *image); - -/* iccolor.c */ - -/* XXX: Do we really need a struct here? Only IcRectangles uses this. */ -typedef struct { - unsigned short red; - unsigned short green; - unsigned short blue; - unsigned short alpha; -} IcColor; - -extern void __external_linkage -IcColorToPixel (const IcFormat *format, - const IcColor *color, - IcBits *pixel); - -extern void __external_linkage -IcPixelToColor (const IcFormat *format, - IcBits pixel, - IcColor *color); - -/* icrect.c */ - -extern void __external_linkage -IcFillRectangle (IcOperator op, - IcImage *dst, - const IcColor *color, - int x, - int y, - unsigned int width, - unsigned int height); - -extern void __external_linkage -IcFillRectangles (IcOperator op, - IcImage *dst, - const IcColor *color, - const IcRectangle *rects, - int nRects); - -/* ictrap.c */ - -/* XXX: Switch to enum for op */ -extern void __external_linkage -IcCompositeTrapezoids (IcOperator op, - IcImage *src, - IcImage *dst, - int xSrc, - int ySrc, - const IcTrapezoid *traps, - int ntrap); - -/* ictri.c */ - -extern void __external_linkage -IcCompositeTriangles (IcOperator op, - IcImage *src, - IcImage *dst, - int xSrc, - int ySrc, - const IcTriangle *tris, - int ntris); - -extern void __external_linkage -IcCompositeTriStrip (IcOperator op, - IcImage *src, - IcImage *dst, - int xSrc, - int ySrc, - const IcPointFixed *points, - int npoints); - - -extern void __external_linkage -IcCompositeTriFan (IcOperator op, - IcImage *src, - IcImage *dst, - int xSrc, - int ySrc, - const IcPointFixed *points, - int npoints); - -/* ic.c */ - -extern void __external_linkage -IcComposite (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int xSrc, - int ySrc, - int xMask, - int yMask, - int xDst, - int yDst, - int width, - int height); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#undef __external_linkage - -#endif /* IC_H_INCLUDED */ diff --git a/pixman/src/icblt.c b/pixman/src/icblt.c deleted file mode 100644 index bf1d2671b..000000000 --- a/pixman/src/icblt.c +++ /dev/null @@ -1,925 +0,0 @@ -/* - * Id: $ - * - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "icint.h" - -#define InitializeShifts(sx,dx,ls,rs) { \ - if (sx != dx) { \ - if (sx > dx) { \ - ls = sx - dx; \ - rs = IC_UNIT - ls; \ - } else { \ - rs = dx - sx; \ - ls = IC_UNIT - rs; \ - } \ - } \ -} - -void -IcBlt (IcBits *srcLine, - IcStride srcStride, - int srcX, - - IcBits *dstLine, - IcStride dstStride, - int dstX, - - int width, - int height, - - int alu, - IcBits pm, - int bpp, - - int reverse, - int upsidedown) -{ - IcBits *src, *dst; - int leftShift, rightShift; - IcBits startmask, endmask; - IcBits bits, bits1; - int n, nmiddle; - int destInvarient; - int startbyte, endbyte; - IcDeclareMergeRop (); - -#ifdef IC_24BIT - if (bpp == 24 && !IcCheck24Pix (pm)) - { - IcBlt24 (srcLine, srcStride, srcX, dstLine, dstStride, dstX, - width, height, alu, pm, reverse, upsidedown); - return; - } -#endif - IcInitializeMergeRop(alu, pm); - destInvarient = IcDestInvarientMergeRop(); - if (upsidedown) - { - srcLine += (height - 1) * (srcStride); - dstLine += (height - 1) * (dstStride); - srcStride = -srcStride; - dstStride = -dstStride; - } - IcMaskBitsBytes (dstX, width, destInvarient, startmask, startbyte, - nmiddle, endmask, endbyte); - if (reverse) - { - srcLine += ((srcX + width - 1) >> IC_SHIFT) + 1; - dstLine += ((dstX + width - 1) >> IC_SHIFT) + 1; - srcX = (srcX + width - 1) & IC_MASK; - dstX = (dstX + width - 1) & IC_MASK; - } - else - { - srcLine += srcX >> IC_SHIFT; - dstLine += dstX >> IC_SHIFT; - srcX &= IC_MASK; - dstX &= IC_MASK; - } - if (srcX == dstX) - { - while (height--) - { - src = srcLine; - srcLine += srcStride; - dst = dstLine; - dstLine += dstStride; - if (reverse) - { - if (endmask) - { - bits = *--src; - --dst; - IcDoRightMaskByteMergeRop(dst, bits, endbyte, endmask); - } - n = nmiddle; - if (destInvarient) - { - while (n--) - *--dst = IcDoDestInvarientMergeRop(*--src); - } - else - { - while (n--) - { - bits = *--src; - --dst; - *dst = IcDoMergeRop (bits, *dst); - } - } - if (startmask) - { - bits = *--src; - --dst; - IcDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask); - } - } - else - { - if (startmask) - { - bits = *src++; - IcDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask); - dst++; - } - n = nmiddle; - if (destInvarient) - { -#if 0 - /* - * This provides some speedup on screen->screen blts - * over the PCI bus, usually about 10%. But Ic - * isn't usually used for this operation... - */ - if (_ca2 + 1 == 0 && _cx2 == 0) - { - IcBits t1, t2, t3, t4; - while (n >= 4) - { - t1 = *src++; - t2 = *src++; - t3 = *src++; - t4 = *src++; - *dst++ = t1; - *dst++ = t2; - *dst++ = t3; - *dst++ = t4; - n -= 4; - } - } -#endif - while (n--) - *dst++ = IcDoDestInvarientMergeRop(*src++); - } - else - { - while (n--) - { - bits = *src++; - *dst = IcDoMergeRop (bits, *dst); - dst++; - } - } - if (endmask) - { - bits = *src; - IcDoRightMaskByteMergeRop(dst, bits, endbyte, endmask); - } - } - } - } - else - { - if (srcX > dstX) - { - leftShift = srcX - dstX; - rightShift = IC_UNIT - leftShift; - } - else - { - rightShift = dstX - srcX; - leftShift = IC_UNIT - rightShift; - } - while (height--) - { - src = srcLine; - srcLine += srcStride; - dst = dstLine; - dstLine += dstStride; - - bits1 = 0; - if (reverse) - { - if (srcX < dstX) - bits1 = *--src; - if (endmask) - { - bits = IcScrRight(bits1, rightShift); - if (IcScrRight(endmask, leftShift)) - { - bits1 = *--src; - bits |= IcScrLeft(bits1, leftShift); - } - --dst; - IcDoRightMaskByteMergeRop(dst, bits, endbyte, endmask); - } - n = nmiddle; - if (destInvarient) - { - while (n--) - { - bits = IcScrRight(bits1, rightShift); - bits1 = *--src; - bits |= IcScrLeft(bits1, leftShift); - --dst; - *dst = IcDoDestInvarientMergeRop(bits); - } - } - else - { - while (n--) - { - bits = IcScrRight(bits1, rightShift); - bits1 = *--src; - bits |= IcScrLeft(bits1, leftShift); - --dst; - *dst = IcDoMergeRop(bits, *dst); - } - } - if (startmask) - { - bits = IcScrRight(bits1, rightShift); - if (IcScrRight(startmask, leftShift)) - { - bits1 = *--src; - bits |= IcScrLeft(bits1, leftShift); - } - --dst; - IcDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask); - } - } - else - { - if (srcX > dstX) - bits1 = *src++; - if (startmask) - { - bits = IcScrLeft(bits1, leftShift); - bits1 = *src++; - bits |= IcScrRight(bits1, rightShift); - IcDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask); - dst++; - } - n = nmiddle; - if (destInvarient) - { - while (n--) - { - bits = IcScrLeft(bits1, leftShift); - bits1 = *src++; - bits |= IcScrRight(bits1, rightShift); - *dst = IcDoDestInvarientMergeRop(bits); - dst++; - } - } - else - { - while (n--) - { - bits = IcScrLeft(bits1, leftShift); - bits1 = *src++; - bits |= IcScrRight(bits1, rightShift); - *dst = IcDoMergeRop(bits, *dst); - dst++; - } - } - if (endmask) - { - bits = IcScrLeft(bits1, leftShift); - if (IcScrLeft(endmask, rightShift)) - { - bits1 = *src; - bits |= IcScrRight(bits1, rightShift); - } - IcDoRightMaskByteMergeRop (dst, bits, endbyte, endmask); - } - } - } - } -} - -#ifdef IC_24BIT - -#undef DEBUG_BLT24 -#ifdef DEBUG_BLT24 - -static unsigned long -getPixel (char *src, int x) -{ - unsigned long l; - - l = 0; - memcpy (&l, src + x * 3, 3); - return l; -} -#endif - -static void -IcBlt24Line (IcBits *src, - int srcX, - - IcBits *dst, - int dstX, - - int width, - - int alu, - IcBits pm, - - int reverse) -{ -#ifdef DEBUG_BLT24 - char *origDst = (char *) dst; - IcBits *origLine = dst + ((dstX >> IC_SHIFT) - 1); - int origNlw = ((width + IC_MASK) >> IC_SHIFT) + 3; - int origX = dstX / 24; -#endif - - int leftShift, rightShift; - IcBits startmask, endmask; - int n; - - IcBits bits, bits1; - IcBits mask; - - int rot; - IcDeclareMergeRop (); - - IcInitializeMergeRop (alu, IC_ALLONES); - IcMaskBits(dstX, width, startmask, n, endmask); -#ifdef DEBUG_BLT24 - ErrorF ("dstX %d width %d reverse %d\n", dstX, width, reverse); -#endif - if (reverse) - { - src += ((srcX + width - 1) >> IC_SHIFT) + 1; - dst += ((dstX + width - 1) >> IC_SHIFT) + 1; - rot = IcFirst24Rot (((dstX + width - 8) & IC_MASK)); - rot = IcPrev24Rot(rot); -#ifdef DEBUG_BLT24 - ErrorF ("dstX + width - 8: %d rot: %d\n", (dstX + width - 8) & IC_MASK, rot); -#endif - srcX = (srcX + width - 1) & IC_MASK; - dstX = (dstX + width - 1) & IC_MASK; - } - else - { - src += srcX >> IC_SHIFT; - dst += dstX >> IC_SHIFT; - srcX &= IC_MASK; - dstX &= IC_MASK; - rot = IcFirst24Rot (dstX); -#ifdef DEBUG_BLT24 - ErrorF ("dstX: %d rot: %d\n", dstX, rot); -#endif - } - mask = IcRot24(pm,rot); -#ifdef DEBUG_BLT24 - ErrorF ("pm 0x%x mask 0x%x\n", pm, mask); -#endif - if (srcX == dstX) - { - if (reverse) - { - if (endmask) - { - bits = *--src; - --dst; - *dst = IcDoMaskMergeRop (bits, *dst, mask & endmask); - mask = IcPrev24Pix (mask); - } - while (n--) - { - bits = *--src; - --dst; - *dst = IcDoMaskMergeRop (bits, *dst, mask); - mask = IcPrev24Pix (mask); - } - if (startmask) - { - bits = *--src; - --dst; - *dst = IcDoMaskMergeRop(bits, *dst, mask & startmask); - } - } - else - { - if (startmask) - { - bits = *src++; - *dst = IcDoMaskMergeRop (bits, *dst, mask & startmask); - dst++; - mask = IcNext24Pix(mask); - } - while (n--) - { - bits = *src++; - *dst = IcDoMaskMergeRop (bits, *dst, mask); - dst++; - mask = IcNext24Pix(mask); - } - if (endmask) - { - bits = *src; - *dst = IcDoMaskMergeRop(bits, *dst, mask & endmask); - } - } - } - else - { - if (srcX > dstX) - { - leftShift = srcX - dstX; - rightShift = IC_UNIT - leftShift; - } - else - { - rightShift = dstX - srcX; - leftShift = IC_UNIT - rightShift; - } - - bits1 = 0; - if (reverse) - { - if (srcX < dstX) - bits1 = *--src; - if (endmask) - { - bits = IcScrRight(bits1, rightShift); - if (IcScrRight(endmask, leftShift)) - { - bits1 = *--src; - bits |= IcScrLeft(bits1, leftShift); - } - --dst; - *dst = IcDoMaskMergeRop (bits, *dst, mask & endmask); - mask = IcPrev24Pix(mask); - } - while (n--) - { - bits = IcScrRight(bits1, rightShift); - bits1 = *--src; - bits |= IcScrLeft(bits1, leftShift); - --dst; - *dst = IcDoMaskMergeRop(bits, *dst, mask); - mask = IcPrev24Pix(mask); - } - if (startmask) - { - bits = IcScrRight(bits1, rightShift); - if (IcScrRight(startmask, leftShift)) - { - bits1 = *--src; - bits |= IcScrLeft(bits1, leftShift); - } - --dst; - *dst = IcDoMaskMergeRop (bits, *dst, mask & startmask); - } - } - else - { - if (srcX > dstX) - bits1 = *src++; - if (startmask) - { - bits = IcScrLeft(bits1, leftShift); - bits1 = *src++; - bits |= IcScrRight(bits1, rightShift); - *dst = IcDoMaskMergeRop (bits, *dst, mask & startmask); - dst++; - mask = IcNext24Pix(mask); - } - while (n--) - { - bits = IcScrLeft(bits1, leftShift); - bits1 = *src++; - bits |= IcScrRight(bits1, rightShift); - *dst = IcDoMaskMergeRop(bits, *dst, mask); - dst++; - mask = IcNext24Pix(mask); - } - if (endmask) - { - bits = IcScrLeft(bits1, leftShift); - if (IcScrLeft(endmask, rightShift)) - { - bits1 = *src; - bits |= IcScrRight(bits1, rightShift); - } - *dst = IcDoMaskMergeRop (bits, *dst, mask & endmask); - } - } - } -#ifdef DEBUG_BLT24 - { - int firstx, lastx, x; - - firstx = origX; - if (firstx) - firstx--; - lastx = origX + width/24 + 1; - for (x = firstx; x <= lastx; x++) - ErrorF ("%06x ", getPixel (origDst, x)); - ErrorF ("\n"); - while (origNlw--) - ErrorF ("%08x ", *origLine++); - ErrorF ("\n"); - } -#endif -} - -void -IcBlt24 (IcBits *srcLine, - IcStride srcStride, - int srcX, - - IcBits *dstLine, - IcStride dstStride, - int dstX, - - int width, - int height, - - int alu, - IcBits pm, - - int reverse, - int upsidedown) -{ - if (upsidedown) - { - srcLine += (height-1) * srcStride; - dstLine += (height-1) * dstStride; - srcStride = -srcStride; - dstStride = -dstStride; - } - while (height--) - { - IcBlt24Line (srcLine, srcX, dstLine, dstX, width, alu, pm, reverse); - srcLine += srcStride; - dstLine += dstStride; - } -#ifdef DEBUG_BLT24 - ErrorF ("\n"); -#endif -} -#endif /* IC_24BIT */ - -#if IC_SHIFT == IC_STIP_SHIFT + 1 - -/* - * Could be generalized to IC_SHIFT > IC_STIP_SHIFT + 1 by - * creating an ring of values stepped through for each line - */ - -void -IcBltOdd (IcBits *srcLine, - IcStride srcStrideEven, - IcStride srcStrideOdd, - int srcXEven, - int srcXOdd, - - IcBits *dstLine, - IcStride dstStrideEven, - IcStride dstStrideOdd, - int dstXEven, - int dstXOdd, - - int width, - int height, - - int alu, - IcBits pm, - int bpp) -{ - IcBits *src; - int leftShiftEven, rightShiftEven; - IcBits startmaskEven, endmaskEven; - int nmiddleEven; - - IcBits *dst; - int leftShiftOdd, rightShiftOdd; - IcBits startmaskOdd, endmaskOdd; - int nmiddleOdd; - - int leftShift, rightShift; - IcBits startmask, endmask; - int nmiddle; - - int srcX, dstX; - - IcBits bits, bits1; - int n; - - int destInvarient; - int even; - IcDeclareMergeRop (); - - IcInitializeMergeRop (alu, pm); - destInvarient = IcDestInvarientMergeRop(); - - srcLine += srcXEven >> IC_SHIFT; - dstLine += dstXEven >> IC_SHIFT; - srcXEven &= IC_MASK; - dstXEven &= IC_MASK; - srcXOdd &= IC_MASK; - dstXOdd &= IC_MASK; - - IcMaskBits(dstXEven, width, startmaskEven, nmiddleEven, endmaskEven); - IcMaskBits(dstXOdd, width, startmaskOdd, nmiddleOdd, endmaskOdd); - - even = 1; - InitializeShifts(srcXEven, dstXEven, leftShiftEven, rightShiftEven); - InitializeShifts(srcXOdd, dstXOdd, leftShiftOdd, rightShiftOdd); - while (height--) - { - src = srcLine; - dst = dstLine; - if (even) - { - srcX = srcXEven; - dstX = dstXEven; - startmask = startmaskEven; - endmask = endmaskEven; - nmiddle = nmiddleEven; - leftShift = leftShiftEven; - rightShift = rightShiftEven; - srcLine += srcStrideEven; - dstLine += dstStrideEven; - even = 0; - } - else - { - srcX = srcXOdd; - dstX = dstXOdd; - startmask = startmaskOdd; - endmask = endmaskOdd; - nmiddle = nmiddleOdd; - leftShift = leftShiftOdd; - rightShift = rightShiftOdd; - srcLine += srcStrideOdd; - dstLine += dstStrideOdd; - even = 1; - } - if (srcX == dstX) - { - if (startmask) - { - bits = *src++; - *dst = IcDoMaskMergeRop (bits, *dst, startmask); - dst++; - } - n = nmiddle; - if (destInvarient) - { - while (n--) - { - bits = *src++; - *dst = IcDoDestInvarientMergeRop(bits); - dst++; - } - } - else - { - while (n--) - { - bits = *src++; - *dst = IcDoMergeRop (bits, *dst); - dst++; - } - } - if (endmask) - { - bits = *src; - *dst = IcDoMaskMergeRop(bits, *dst, endmask); - } - } - else - { - bits = 0; - if (srcX > dstX) - bits = *src++; - if (startmask) - { - bits1 = IcScrLeft(bits, leftShift); - bits = *src++; - bits1 |= IcScrRight(bits, rightShift); - *dst = IcDoMaskMergeRop (bits1, *dst, startmask); - dst++; - } - n = nmiddle; - if (destInvarient) - { - while (n--) - { - bits1 = IcScrLeft(bits, leftShift); - bits = *src++; - bits1 |= IcScrRight(bits, rightShift); - *dst = IcDoDestInvarientMergeRop(bits1); - dst++; - } - } - else - { - while (n--) - { - bits1 = IcScrLeft(bits, leftShift); - bits = *src++; - bits1 |= IcScrRight(bits, rightShift); - *dst = IcDoMergeRop(bits1, *dst); - dst++; - } - } - if (endmask) - { - bits1 = IcScrLeft(bits, leftShift); - if (IcScrLeft(endmask, rightShift)) - { - bits = *src; - bits1 |= IcScrRight(bits, rightShift); - } - *dst = IcDoMaskMergeRop (bits1, *dst, endmask); - } - } - } -} - -#ifdef IC_24BIT -void -IcBltOdd24 (IcBits *srcLine, - IcStride srcStrideEven, - IcStride srcStrideOdd, - int srcXEven, - int srcXOdd, - - IcBits *dstLine, - IcStride dstStrideEven, - IcStride dstStrideOdd, - int dstXEven, - int dstXOdd, - - int width, - int height, - - int alu, - IcBits pm) -{ - int even = 1; - - while (height--) - { - if (even) - { - IcBlt24Line (srcLine, srcXEven, dstLine, dstXEven, - width, alu, pm, 0); - srcLine += srcStrideEven; - dstLine += dstStrideEven; - even = 0; - } - else - { - IcBlt24Line (srcLine, srcXOdd, dstLine, dstXOdd, - width, alu, pm, 0); - srcLine += srcStrideOdd; - dstLine += dstStrideOdd; - even = 1; - } - } -#if 0 - fprintf (stderr, "\n"); -#endif -} -#endif - -#endif - -#if IC_STIP_SHIFT != IC_SHIFT -void -IcSetBltOdd (IcStip *stip, - IcStride stipStride, - int srcX, - IcBits **bits, - IcStride *strideEven, - IcStride *strideOdd, - int *srcXEven, - int *srcXOdd) -{ - int srcAdjust; - int strideAdjust; - - /* - * bytes needed to align source - */ - srcAdjust = (((int) stip) & (IC_MASK >> 3)); - /* - * IcStip units needed to align stride - */ - strideAdjust = stipStride & (IC_MASK >> IC_STIP_SHIFT); - - *bits = (IcBits *) ((char *) stip - srcAdjust); - if (srcAdjust) - { - *strideEven = IcStipStrideToBitsStride (stipStride + 1); - *strideOdd = IcStipStrideToBitsStride (stipStride); - - *srcXEven = srcX + (srcAdjust << 3); - *srcXOdd = srcX + (srcAdjust << 3) - (strideAdjust << IC_STIP_SHIFT); - } - else - { - *strideEven = IcStipStrideToBitsStride (stipStride); - *strideOdd = IcStipStrideToBitsStride (stipStride + 1); - - *srcXEven = srcX; - *srcXOdd = srcX + (strideAdjust << IC_STIP_SHIFT); - } -} -#endif - -void -IcBltStip (IcStip *src, - IcStride srcStride, /* in IcStip units, not IcBits units */ - int srcX, - - IcStip *dst, - IcStride dstStride, /* in IcStip units, not IcBits units */ - int dstX, - - int width, - int height, - - int alu, - IcBits pm, - int bpp) -{ -#if IC_STIP_SHIFT != IC_SHIFT - if (IC_STIP_ODDSTRIDE(srcStride) || IC_STIP_ODDPTR(src) || - IC_STIP_ODDSTRIDE(dstStride) || IC_STIP_ODDPTR(dst)) - { - IcStride srcStrideEven, srcStrideOdd; - IcStride dstStrideEven, dstStrideOdd; - int srcXEven, srcXOdd; - int dstXEven, dstXOdd; - IcBits *s, *d; - int sx, dx; - - src += srcX >> IC_STIP_SHIFT; - srcX &= IC_STIP_MASK; - dst += dstX >> IC_STIP_SHIFT; - dstX &= IC_STIP_MASK; - - IcSetBltOdd (src, srcStride, srcX, - &s, - &srcStrideEven, &srcStrideOdd, - &srcXEven, &srcXOdd); - - IcSetBltOdd (dst, dstStride, dstX, - &d, - &dstStrideEven, &dstStrideOdd, - &dstXEven, &dstXOdd); - -#ifdef IC_24BIT - if (bpp == 24 && !IcCheck24Pix (pm)) - { - IcBltOdd24 (s, srcStrideEven, srcStrideOdd, - srcXEven, srcXOdd, - - d, dstStrideEven, dstStrideOdd, - dstXEven, dstXOdd, - - width, height, alu, pm); - } - else -#endif - { - IcBltOdd (s, srcStrideEven, srcStrideOdd, - srcXEven, srcXOdd, - - d, dstStrideEven, dstStrideOdd, - dstXEven, dstXOdd, - - width, height, alu, pm, bpp); - } - } - else -#endif - { - IcBlt ((IcBits *) src, IcStipStrideToBitsStride (srcStride), - srcX, - (IcBits *) dst, IcStipStrideToBitsStride (dstStride), - dstX, - width, height, - alu, pm, bpp, 0, 0); - } -} diff --git a/pixman/src/icbltone.c b/pixman/src/icbltone.c deleted file mode 100644 index ce31436de..000000000 --- a/pixman/src/icbltone.c +++ /dev/null @@ -1,742 +0,0 @@ -/* - * Id: $ - * - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "icint.h" - -/* - * Example: srcX = 13 dstX = 8 (IC unit 32 dstBpp 8) - * - * **** **** **** **** **** **** **** **** - * ^ - * ******** ******** ******** ******** - * ^ - * leftShift = 12 - * rightShift = 20 - * - * Example: srcX = 0 dstX = 8 (IC unit 32 dstBpp 8) - * - * **** **** **** **** **** **** **** **** - * ^ - * ******** ******** ******** ******** - * ^ - * - * leftShift = 24 - * rightShift = 8 - */ - -#define LoadBits {\ - if (leftShift) { \ - bitsRight = *src++; \ - bits = (IcStipLeft (bitsLeft, leftShift) | \ - IcStipRight(bitsRight, rightShift)); \ - bitsLeft = bitsRight; \ - } else \ - bits = *src++; \ -} - -#ifndef ICNOPIXADDR - -#define LaneCases1(n,a) case n: (void)IcLaneCase(n,a); break -#define LaneCases2(n,a) LaneCases1(n,a); LaneCases1(n+1,a) -#define LaneCases4(n,a) LaneCases2(n,a); LaneCases2(n+2,a) -#define LaneCases8(n,a) LaneCases4(n,a); LaneCases4(n+4,a) -#define LaneCases16(n,a) LaneCases8(n,a); LaneCases8(n+8,a) -#define LaneCases32(n,a) LaneCases16(n,a); LaneCases16(n+16,a) -#define LaneCases64(n,a) LaneCases32(n,a); LaneCases32(n+32,a) -#define LaneCases128(n,a) LaneCases64(n,a); LaneCases64(n+64,a) -#define LaneCases256(n,a) LaneCases128(n,a); LaneCases128(n+128,a) - -#if IC_SHIFT == 6 -#define LaneCases(a) LaneCases256(0,a) -#endif - -#if IC_SHIFT == 5 -#define LaneCases(a) LaneCases16(0,a) -#endif - -#if IC_SHIFT == 6 -static uint8_t const Ic8Lane[256] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, -60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, -79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, -98, 99, 100, 101, 102,103,104,105,106,107,108,109,110,111,112,113,114,115, -116, 117, 118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133, -134, 135, 136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151, -152, 153, 154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169, -170, 171, 172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187, -188, 189, 190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205, -206, 207, 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, -224, 225, 226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241, -242, 243, 244,245,246,247,248,249,250,251,252,253,254,255, -}; - -static uint8_t const Ic16Lane[256] = { - 0x00, 0x03, 0x0c, 0x0f, - 0x30, 0x33, 0x3c, 0x3f, - 0xc0, 0xc3, 0xcc, 0xcf, - 0xf0, 0xf3, 0xfc, 0xff, -}; - -static uint8_t const Ic32Lane[16] = { - 0x00, 0x0f, 0xf0, 0xff, -}; -#endif - -#if IC_SHIFT == 5 -static uint8_t const Ic8Lane[16] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 -}; - -static uint8_t const Ic16Lane[16] = { - 0, 3, 12, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static uint8_t const Ic32Lane[16] = { - 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; -#endif - -static const uint8_t * -IcLaneTable(int bpp) -{ - switch (bpp) { - case 8: - return Ic8Lane; - case 16: - return Ic16Lane; - case 32: - return Ic32Lane; - } - return 0; -} -#endif - -void -IcBltOne (IcStip *src, - IcStride srcStride, /* IcStip units per scanline */ - int srcX, /* bit position of source */ - IcBits *dst, - IcStride dstStride, /* IcBits units per scanline */ - int dstX, /* bit position of dest */ - int dstBpp, /* bits per destination unit */ - - int width, /* width in bits of destination */ - int height, /* height in scanlines */ - - IcBits fgand, /* rrop values */ - IcBits fgxor, - IcBits bgand, - IcBits bgxor) -{ - const IcBits *icbits; - int pixelsPerDst; /* dst pixels per IcBits */ - int unitsPerSrc; /* src patterns per IcStip */ - int leftShift, rightShift; /* align source with dest */ - IcBits startmask, endmask; /* dest scanline masks */ - IcStip bits=0, bitsLeft, bitsRight;/* source bits */ - IcStip left; - IcBits mask; - int nDst; /* dest longwords (w.o. end) */ - int w; - int n, nmiddle; - int dstS; /* stipple-relative dst X coordinate */ - int copy; /* accelerate dest-invariant */ - int transparent; /* accelerate 0 nop */ - int srcinc; /* source units consumed */ - int endNeedsLoad = 0; /* need load for endmask */ -#ifndef ICNOPIXADDR - const uint8_t *IcLane; -#endif - int startbyte, endbyte; - -#ifdef IC_24BIT - if (dstBpp == 24) - { - IcBltOne24 (src, srcStride, srcX, - dst, dstStride, dstX, dstBpp, - width, height, - fgand, fgxor, bgand, bgxor); - return; - } -#endif - - /* - * Number of destination units in IcBits == number of stipple pixels - * used each time - */ - pixelsPerDst = IC_UNIT / dstBpp; - - /* - * Number of source stipple patterns in IcStip - */ - unitsPerSrc = IC_STIP_UNIT / pixelsPerDst; - - copy = 0; - transparent = 0; - if (bgand == 0 && fgand == 0) - copy = 1; - else if (bgand == IC_ALLONES && bgxor == 0) - transparent = 1; - - /* - * Adjust source and dest to nearest IcBits boundary - */ - src += srcX >> IC_STIP_SHIFT; - dst += dstX >> IC_SHIFT; - srcX &= IC_STIP_MASK; - dstX &= IC_MASK; - - IcMaskBitsBytes(dstX, width, copy, - startmask, startbyte, nmiddle, endmask, endbyte); - - /* - * Compute effective dest alignment requirement for - * source -- must align source to dest unit boundary - */ - dstS = dstX / dstBpp; - /* - * Compute shift constants for effective alignement - */ - if (srcX >= dstS) - { - leftShift = srcX - dstS; - rightShift = IC_STIP_UNIT - leftShift; - } - else - { - rightShift = dstS - srcX; - leftShift = IC_STIP_UNIT - rightShift; - } - /* - * Get pointer to stipple mask array for this depth - */ - icbits = 0; /* unused */ - if (pixelsPerDst <= 8) - icbits = IcStippleTable(pixelsPerDst); -#ifndef ICNOPIXADDR - IcLane = 0; - if (transparent && fgand == 0 && dstBpp >= 8) - IcLane = IcLaneTable(dstBpp); -#endif - - /* - * Compute total number of destination words written, but - * don't count endmask - */ - nDst = nmiddle; - if (startmask) - nDst++; - - dstStride -= nDst; - - /* - * Compute total number of source words consumed - */ - - srcinc = (nDst + unitsPerSrc - 1) / unitsPerSrc; - - if (srcX > dstS) - srcinc++; - if (endmask) - { - endNeedsLoad = nDst % unitsPerSrc == 0; - if (endNeedsLoad) - srcinc++; - } - - srcStride -= srcinc; - - /* - * Copy rectangle - */ - while (height--) - { - w = nDst; /* total units across scanline */ - n = unitsPerSrc; /* units avail in single stipple */ - if (n > w) - n = w; - - bitsLeft = 0; - if (srcX > dstS) - bitsLeft = *src++; - if (n) - { - /* - * Load first set of stipple bits - */ - LoadBits; - - /* - * Consume stipple bits for startmask - */ - if (startmask) - { -#if IC_UNIT > 32 - if (pixelsPerDst == 16) - mask = IcStipple16Bits(IcLeftStipBits(bits,16)); - else -#endif - mask = icbits[IcLeftStipBits(bits,pixelsPerDst)]; -#ifndef ICNOPIXADDR - if (IcLane) - { - IcTransparentSpan (dst, mask & startmask, fgxor, 1); - } - else -#endif - { - if (mask || !transparent) - IcDoLeftMaskByteStippleRRop (dst, mask, - fgand, fgxor, bgand, bgxor, - startbyte, startmask); - } - bits = IcStipLeft (bits, pixelsPerDst); - dst++; - n--; - w--; - } - /* - * Consume stipple bits across scanline - */ - for (;;) - { - w -= n; - if (copy) - { - while (n--) - { -#if IC_UNIT > 32 - if (pixelsPerDst == 16) - mask = IcStipple16Bits(IcLeftStipBits(bits,16)); - else -#endif - mask = icbits[IcLeftStipBits(bits,pixelsPerDst)]; - *dst = IcOpaqueStipple (mask, fgxor, bgxor); - dst++; - bits = IcStipLeft(bits, pixelsPerDst); - } - } - else - { -#ifndef ICNOPIXADDR - if (IcLane) - { - while (bits && n) - { - switch (IcLane[IcLeftStipBits(bits,pixelsPerDst)]) { - LaneCases((uint8_t *) dst); - } - bits = IcStipLeft(bits,pixelsPerDst); - dst++; - n--; - } - dst += n; - } - else -#endif - { - while (n--) - { - left = IcLeftStipBits(bits,pixelsPerDst); - if (left || !transparent) - { - mask = icbits[left]; - *dst = IcStippleRRop (*dst, mask, - fgand, fgxor, bgand, bgxor); - } - dst++; - bits = IcStipLeft(bits, pixelsPerDst); - } - } - } - if (!w) - break; - /* - * Load another set and reset number of available units - */ - LoadBits; - n = unitsPerSrc; - if (n > w) - n = w; - } - } - /* - * Consume stipple bits for endmask - */ - if (endmask) - { - if (endNeedsLoad) - { - LoadBits; - } -#if IC_UNIT > 32 - if (pixelsPerDst == 16) - mask = IcStipple16Bits(IcLeftStipBits(bits,16)); - else -#endif - mask = icbits[IcLeftStipBits(bits,pixelsPerDst)]; -#ifndef ICNOPIXADDR - if (IcLane) - { - IcTransparentSpan (dst, mask & endmask, fgxor, 1); - } - else -#endif - { - if (mask || !transparent) - IcDoRightMaskByteStippleRRop (dst, mask, - fgand, fgxor, bgand, bgxor, - endbyte, endmask); - } - } - dst += dstStride; - src += srcStride; - } -} - -#ifdef IC_24BIT - -/* - * Crufty macros to initialize the mask array, most of this - * is to avoid compile-time warnings about shift overflow - */ - -#if BITMAP_BIT_ORDER == MSBFirst -#define Mask24Pos(x,r) ((x)*24-(r)) -#else -#define Mask24Pos(x,r) ((x)*24-((r) ? 24 - (r) : 0)) -#endif - -#define Mask24Neg(x,r) (Mask24Pos(x,r) < 0 ? -Mask24Pos(x,r) : 0) -#define Mask24Check(x,r) (Mask24Pos(x,r) < 0 ? 0 : \ - Mask24Pos(x,r) >= IC_UNIT ? 0 : Mask24Pos(x,r)) - -#define Mask24(x,r) (Mask24Pos(x,r) < IC_UNIT ? \ - (Mask24Pos(x,r) < 0 ? \ - 0xffffff >> Mask24Neg (x,r) : \ - 0xffffff << Mask24Check(x,r)) : 0) - -#define SelMask24(b,n,r) ((((b) >> n) & 1) * Mask24(n,r)) - -/* - * Untested for MSBFirst or IC_UNIT == 32 - */ - -#if IC_UNIT == 64 -#define C4_24(b,r) \ - (SelMask24(b,0,r) | \ - SelMask24(b,1,r) | \ - SelMask24(b,2,r) | \ - SelMask24(b,3,r)) - -#define IcStip24New(rot) (2 + (rot != 0)) -#define IcStip24Len 4 - -static const IcBits icStipple24Bits[3][1 << IcStip24Len] = { - /* rotate 0 */ - { - C4_24( 0, 0), C4_24( 1, 0), C4_24( 2, 0), C4_24( 3, 0), - C4_24( 4, 0), C4_24( 5, 0), C4_24( 6, 0), C4_24( 7, 0), - C4_24( 8, 0), C4_24( 9, 0), C4_24(10, 0), C4_24(11, 0), - C4_24(12, 0), C4_24(13, 0), C4_24(14, 0), C4_24(15, 0), - }, - /* rotate 8 */ - { - C4_24( 0, 8), C4_24( 1, 8), C4_24( 2, 8), C4_24( 3, 8), - C4_24( 4, 8), C4_24( 5, 8), C4_24( 6, 8), C4_24( 7, 8), - C4_24( 8, 8), C4_24( 9, 8), C4_24(10, 8), C4_24(11, 8), - C4_24(12, 8), C4_24(13, 8), C4_24(14, 8), C4_24(15, 8), - }, - /* rotate 16 */ - { - C4_24( 0,16), C4_24( 1,16), C4_24( 2,16), C4_24( 3,16), - C4_24( 4,16), C4_24( 5,16), C4_24( 6,16), C4_24( 7,16), - C4_24( 8,16), C4_24( 9,16), C4_24(10,16), C4_24(11,16), - C4_24(12,16), C4_24(13,16), C4_24(14,16), C4_24(15,16), - } -}; - -#endif - -#if IC_UNIT == 32 -#define C2_24(b,r) \ - (SelMask24(b,0,r) | \ - SelMask24(b,1,r)) - -#define IcStip24Len 2 -#if BITMAP_BIT_ORDER == MSBFirst -#define IcStip24New(rot) (1 + (rot == 0)) -#else -#define IcStip24New(rot) (1 + (rot == 8)) -#endif - -static const IcBits icStipple24Bits[3][1 << IcStip24Len] = { - /* rotate 0 */ - { - C2_24( 0, 0), C2_24 ( 1, 0), C2_24 ( 2, 0), C2_24 ( 3, 0), - }, - /* rotate 8 */ - { - C2_24( 0, 8), C2_24 ( 1, 8), C2_24 ( 2, 8), C2_24 ( 3, 8), - }, - /* rotate 16 */ - { - C2_24( 0,16), C2_24 ( 1,16), C2_24 ( 2,16), C2_24 ( 3,16), - } -}; -#endif - -#if BITMAP_BIT_ORDER == LSBFirst - -#define IcMergeStip24Bits(left, right, new) \ - (IcStipLeft (left, new) | IcStipRight ((right), (IcStip24Len - (new)))) - -#define IcMergePartStip24Bits(left, right, llen, rlen) \ - (left | IcStipRight(right, llen)) - -#else - -#define IcMergeStip24Bits(left, right, new) \ - ((IcStipLeft (left, new) & ((1 << IcStip24Len) - 1)) | right) - -#define IcMergePartStip24Bits(left, right, llen, rlen) \ - (IcStipLeft(left, rlen) | right) - -#endif - -#define IcFirstStipBits(len,stip) {\ - int __len = (len); \ - if (len <= remain) { \ - stip = IcLeftStipBits(bits, len); \ - } else { \ - stip = IcLeftStipBits(bits, remain); \ - bits = *src++; \ - __len = (len) - remain; \ - stip = IcMergePartStip24Bits(stip, IcLeftStipBits(bits, __len), \ - remain, __len); \ - remain = IC_STIP_UNIT; \ - } \ - bits = IcStipLeft (bits, __len); \ - remain -= __len; \ -} - -#define IcInitStipBits(offset,len,stip) {\ - bits = IcStipLeft (*src++,offset); \ - remain = IC_STIP_UNIT - offset; \ - IcFirstStipBits(len,stip); \ - stip = IcMergeStip24Bits (0, stip, len); \ -} - -#define IcNextStipBits(rot,stip) {\ - int __new = IcStip24New(rot); \ - IcStip __right; \ - IcFirstStipBits(__new, __right); \ - stip = IcMergeStip24Bits (stip, __right, __new); \ - rot = IcNext24Rot (rot); \ -} - -/* - * Use deep mask tables that incorporate rotation, pull - * a variable number of bits out of the stipple and - * reuse the right bits as needed for the next write - * - * Yes, this is probably too much code, but most 24-bpp screens - * have no acceleration so this code is used for stipples, copyplane - * and text - */ -void -IcBltOne24 (IcStip *srcLine, - IcStride srcStride, /* IcStip units per scanline */ - int srcX, /* bit position of source */ - IcBits *dst, - IcStride dstStride, /* IcBits units per scanline */ - int dstX, /* bit position of dest */ - int dstBpp, /* bits per destination unit */ - - int width, /* width in bits of destination */ - int height, /* height in scanlines */ - - IcBits fgand, /* rrop values */ - IcBits fgxor, - IcBits bgand, - IcBits bgxor) -{ - IcStip *src; - IcBits leftMask, rightMask, mask; - int nlMiddle, nl; - IcStip stip, bits; - int remain; - int dstS; - int firstlen; - int rot0, rot; - int nDst; - - srcLine += srcX >> IC_STIP_SHIFT; - dst += dstX >> IC_SHIFT; - srcX &= IC_STIP_MASK; - dstX &= IC_MASK; - rot0 = IcFirst24Rot (dstX); - - IcMaskBits (dstX, width, leftMask, nlMiddle, rightMask); - - dstS = (dstX + 23) / 24; - firstlen = IcStip24Len - dstS; - - nDst = nlMiddle; - if (leftMask) - nDst++; - dstStride -= nDst; - - /* opaque copy */ - if (bgand == 0 && fgand == 0) - { - while (height--) - { - rot = rot0; - src = srcLine; - srcLine += srcStride; - IcInitStipBits (srcX,firstlen, stip); - if (leftMask) - { - mask = icStipple24Bits[rot >> 3][stip]; - *dst = (*dst & ~leftMask) | (IcOpaqueStipple (mask, - IcRot24(fgxor, rot), - IcRot24(bgxor, rot)) - & leftMask); - dst++; - IcNextStipBits(rot,stip); - } - nl = nlMiddle; - while (nl--) - { - mask = icStipple24Bits[rot>>3][stip]; - *dst = IcOpaqueStipple (mask, - IcRot24(fgxor, rot), - IcRot24(bgxor, rot)); - dst++; - IcNextStipBits(rot,stip); - } - if (rightMask) - { - mask = icStipple24Bits[rot >> 3][stip]; - *dst = (*dst & ~rightMask) | (IcOpaqueStipple (mask, - IcRot24(fgxor, rot), - IcRot24(bgxor, rot)) - & rightMask); - } - dst += dstStride; - src += srcStride; - } - } - /* transparent copy */ - else if (bgand == IC_ALLONES && bgxor == 0 && fgand == 0) - { - while (height--) - { - rot = rot0; - src = srcLine; - srcLine += srcStride; - IcInitStipBits (srcX, firstlen, stip); - if (leftMask) - { - if (stip) - { - mask = icStipple24Bits[rot >> 3][stip] & leftMask; - *dst = (*dst & ~mask) | (IcRot24(fgxor, rot) & mask); - } - dst++; - IcNextStipBits (rot, stip); - } - nl = nlMiddle; - while (nl--) - { - if (stip) - { - mask = icStipple24Bits[rot>>3][stip]; - *dst = (*dst & ~mask) | (IcRot24(fgxor,rot) & mask); - } - dst++; - IcNextStipBits (rot, stip); - } - if (rightMask) - { - if (stip) - { - mask = icStipple24Bits[rot >> 3][stip] & rightMask; - *dst = (*dst & ~mask) | (IcRot24(fgxor, rot) & mask); - } - } - dst += dstStride; - } - } - else - { - while (height--) - { - rot = rot0; - src = srcLine; - srcLine += srcStride; - IcInitStipBits (srcX, firstlen, stip); - if (leftMask) - { - mask = icStipple24Bits[rot >> 3][stip]; - *dst = IcStippleRRopMask (*dst, mask, - IcRot24(fgand, rot), - IcRot24(fgxor, rot), - IcRot24(bgand, rot), - IcRot24(bgxor, rot), - leftMask); - dst++; - IcNextStipBits(rot,stip); - } - nl = nlMiddle; - while (nl--) - { - mask = icStipple24Bits[rot >> 3][stip]; - *dst = IcStippleRRop (*dst, mask, - IcRot24(fgand, rot), - IcRot24(fgxor, rot), - IcRot24(bgand, rot), - IcRot24(bgxor, rot)); - dst++; - IcNextStipBits(rot,stip); - } - if (rightMask) - { - mask = icStipple24Bits[rot >> 3][stip]; - *dst = IcStippleRRopMask (*dst, mask, - IcRot24(fgand, rot), - IcRot24(fgxor, rot), - IcRot24(bgand, rot), - IcRot24(bgxor, rot), - rightMask); - } - dst += dstStride; - } - } -} -#endif - diff --git a/pixman/src/iccolor.c b/pixman/src/iccolor.c deleted file mode 100644 index dbb1207fb..000000000 --- a/pixman/src/iccolor.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#include "icint.h" - -#ifdef ICINT_NEED_IC_ONES -/* Fall back on HACKMEM 169. */ -int -_IcOnes (unsigned long mask) -{ - register unsigned long y; - - y = (mask >> 1) &033333333333; - y = mask - y - ((y >>1) & 033333333333); - return (((y + (y >> 3)) & 030707070707) % 077); -} -#endif - -void -IcColorToPixel (const IcFormat *format, - const IcColor *color, - IcBits *pixel) -{ - uint32_t r, g, b, a; - - r = color->red >> (16 - _IcOnes (format->redMask)); - g = color->green >> (16 - _IcOnes (format->greenMask)); - b = color->blue >> (16 - _IcOnes (format->blueMask)); - a = color->alpha >> (16 - _IcOnes (format->alphaMask)); - r = r << format->red; - g = g << format->green; - b = b << format->blue; - a = a << format->alpha; - *pixel = r|g|b|a; -} -slim_hidden_def(IcColorToPixel); - -static uint16_t -IcFillColor (uint32_t pixel, int bits) -{ - while (bits < 16) - { - pixel |= pixel << bits; - bits <<= 1; - } - return (uint16_t) pixel; -} - -void -IcPixelToColor (const IcFormat *format, - const IcBits pixel, - IcColor *color) -{ - uint32_t r, g, b, a; - - r = (pixel >> format->red) & format->redMask; - g = (pixel >> format->green) & format->greenMask; - b = (pixel >> format->blue) & format->blueMask; - a = (pixel >> format->alpha) & format->alphaMask; - color->red = IcFillColor (r, _IcOnes (format->redMask)); - color->green = IcFillColor (r, _IcOnes (format->greenMask)); - color->blue = IcFillColor (r, _IcOnes (format->blueMask)); - color->alpha = IcFillColor (r, _IcOnes (format->alphaMask)); -} diff --git a/pixman/src/iccompose.c b/pixman/src/iccompose.c deleted file mode 100644 index 7d9a63c65..000000000 --- a/pixman/src/iccompose.c +++ /dev/null @@ -1,2713 +0,0 @@ -/* - * Copyright © 2000 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - - -#include "icint.h" - -/* - * General purpose compositing code optimized for minimal memory - * references - * - * All work is done on canonical ARGB values, functions for fetching - * and storing these exist for each format. - */ - -/* - * Combine src and mask using IN - */ - -static uint32_t -IcCombineMaskU (IcCompositeOperand *src, - IcCompositeOperand *msk) -{ - uint32_t x; - uint16_t a; - uint16_t t; - uint32_t m,n,o,p; - - if (!msk) - return (*src->fetch) (src); - - a = (*msk->fetch) (msk) >> 24; - if (!a) - return 0; - - x = (*src->fetch) (src); - if (a == 0xff) - return x; - - m = IcInU(x,0,a,t); - n = IcInU(x,8,a,t); - o = IcInU(x,16,a,t); - p = IcInU(x,24,a,t); - return m|n|o|p; -} - -static IcCompSrc -IcCombineMaskC (IcCompositeOperand *src, - IcCompositeOperand *msk) -{ - IcCompSrc s; - uint32_t x; - uint32_t a; - uint16_t xa; - uint16_t t; - uint32_t m,n,o,p; - - if (!msk) - { - x = (*src->fetch) (src); - s.value = x; - x = x >> 24; - x |= x << 8; - x |= x << 16; - s.alpha = x; - return s; - } - - a = (*msk->fetcha) (msk); - if (!a) - { - s.value = 0; - s.alpha = 0; - return s; - } - - x = (*src->fetch) (src); - if (a == 0xffffffff) - { - s.value = x; - x = x >> 24; - x |= x << 8; - x |= x << 16; - s.alpha = x; - return s; - } - - m = IcInC(x,0,a,t); - n = IcInC(x,8,a,t); - o = IcInC(x,16,a,t); - p = IcInC(x,24,a,t); - s.value = m|n|o|p; - xa = x >> 24; - m = IcInU(a,0,xa,t); - n = IcInU(a,8,xa,t); - o = IcInU(a,16,xa,t); - p = IcInU(a,24,xa,t); - s.alpha = m|n|o|p; - return s; -} - -static uint32_t -IcCombineMaskValueC (IcCompositeOperand *src, - IcCompositeOperand *msk) -{ - uint32_t x; - uint32_t a; - uint16_t t; - uint32_t m,n,o,p; - - if (!msk) - { - return (*src->fetch) (src); - } - - a = (*msk->fetcha) (msk); - if (!a) - return a; - - x = (*src->fetch) (src); - if (a == 0xffffffff) - return x; - - m = IcInC(x,0,a,t); - n = IcInC(x,8,a,t); - o = IcInC(x,16,a,t); - p = IcInC(x,24,a,t); - return m|n|o|p; -} - -/* - * Combine src and mask using IN, generating only the alpha component - */ -static uint32_t -IcCombineMaskAlphaU (IcCompositeOperand *src, - IcCompositeOperand *msk) -{ - uint32_t x; - uint16_t a; - uint16_t t; - - if (!msk) - return (*src->fetch) (src); - - a = (*msk->fetch) (msk) >> 24; - if (!a) - return 0; - - x = (*src->fetch) (src); - if (a == 0xff) - return x; - - return IcInU(x,24,a,t); -} - -static uint32_t -IcCombineMaskAlphaC (IcCompositeOperand *src, - IcCompositeOperand *msk) -{ - uint32_t x; - uint32_t a; - uint16_t t; - uint32_t m,n,o,p; - - if (!msk) - return (*src->fetch) (src); - - a = (*msk->fetcha) (msk); - if (!a) - return 0; - - x = (*src->fetcha) (src); - if (a == 0xffffffff) - return x; - - m = IcInC(x,0,a,t); - n = IcInC(x,8,a,t); - o = IcInC(x,16,a,t); - p = IcInC(x,24,a,t); - return m|n|o|p; -} - -/* - * All of the composing functions - */ -static void -IcCombineClear (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - (*dst->store) (dst, 0); -} - -static void -IcCombineSrcU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - (*dst->store) (dst, IcCombineMaskU (src, msk)); -} - -static void -IcCombineSrcC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - (*dst->store) (dst, IcCombineMaskValueC (src, msk)); -} - -static void -IcCombineDst (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - /* noop */ -} - -static void -IcCombineOverU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t a; - uint16_t t; - uint32_t m,n,o,p; - - s = IcCombineMaskU (src, msk); - a = ~s >> 24; - if (a != 0xff) - { - if (a) - { - d = (*dst->fetch) (dst); - m = IcOverU(s,d,0,a,t); - n = IcOverU(s,d,8,a,t); - o = IcOverU(s,d,16,a,t); - p = IcOverU(s,d,24,a,t); - s = m|n|o|p; - } - (*dst->store) (dst, s); - } -} - -static void -IcCombineOverC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCompSrc cs; - uint32_t s, d; - uint32_t a; - uint16_t t; - uint32_t m,n,o,p; - - cs = IcCombineMaskC (src, msk); - s = cs.value; - a = ~cs.alpha; - if (a != 0xffffffff) - { - if (a) - { - d = (*dst->fetch) (dst); - m = IcOverC(s,d,0,a,t); - n = IcOverC(s,d,8,a,t); - o = IcOverC(s,d,16,a,t); - p = IcOverC(s,d,24,a,t); - s = m|n|o|p; - } - (*dst->store) (dst, s); - } -} - -static void -IcCombineOverReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t a; - uint16_t t; - uint32_t m,n,o,p; - - d = (*dst->fetch) (dst); - a = ~d >> 24; - if (a) - { - s = IcCombineMaskU (src, msk); - if (a != 0xff) - { - m = IcOverU(d,s,0,a,t); - n = IcOverU(d,s,8,a,t); - o = IcOverU(d,s,16,a,t); - p = IcOverU(d,s,24,a,t); - s = m|n|o|p; - } - (*dst->store) (dst, s); - } -} - -static void -IcCombineOverReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint32_t a; - uint16_t t; - uint32_t m,n,o,p; - - d = (*dst->fetch) (dst); - a = ~d >> 24; - if (a) - { - s = IcCombineMaskValueC (src, msk); - if (a != 0xff) - { - m = IcOverU(d,s,0,a,t); - n = IcOverU(d,s,8,a,t); - o = IcOverU(d,s,16,a,t); - p = IcOverU(d,s,24,a,t); - s = m|n|o|p; - } - (*dst->store) (dst, s); - } -} - -static void -IcCombineInU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t a; - uint16_t t; - uint32_t m,n,o,p; - - d = (*dst->fetch) (dst); - a = d >> 24; - s = 0; - if (a) - { - s = IcCombineMaskU (src, msk); - if (a != 0xff) - { - m = IcInU(s,0,a,t); - n = IcInU(s,8,a,t); - o = IcInU(s,16,a,t); - p = IcInU(s,24,a,t); - s = m|n|o|p; - } - } - (*dst->store) (dst, s); -} - -static void -IcCombineInC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t a; - uint16_t t; - uint32_t m,n,o,p; - - d = (*dst->fetch) (dst); - a = d >> 24; - s = 0; - if (a) - { - s = IcCombineMaskValueC (src, msk); - if (a != 0xff) - { - m = IcInU(s,0,a,t); - n = IcInU(s,8,a,t); - o = IcInU(s,16,a,t); - p = IcInU(s,24,a,t); - s = m|n|o|p; - } - } - (*dst->store) (dst, s); -} - -static void -IcCombineInReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t a; - uint16_t t; - uint32_t m,n,o,p; - - s = IcCombineMaskAlphaU (src, msk); - a = s >> 24; - if (a != 0xff) - { - d = 0; - if (a) - { - d = (*dst->fetch) (dst); - m = IcInU(d,0,a,t); - n = IcInU(d,8,a,t); - o = IcInU(d,16,a,t); - p = IcInU(d,24,a,t); - d = m|n|o|p; - } - (*dst->store) (dst, d); - } -} - -static void -IcCombineInReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint32_t a; - uint16_t t; - uint32_t m,n,o,p; - - s = IcCombineMaskAlphaC (src, msk); - a = s; - if (a != 0xffffffff) - { - d = 0; - if (a) - { - d = (*dst->fetch) (dst); - m = IcInC(d,0,a,t); - n = IcInC(d,8,a,t); - o = IcInC(d,16,a,t); - p = IcInC(d,24,a,t); - d = m|n|o|p; - } - (*dst->store) (dst, d); - } -} - -static void -IcCombineOutU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t a; - uint16_t t; - uint32_t m,n,o,p; - - d = (*dst->fetch) (dst); - a = ~d >> 24; - s = 0; - if (a) - { - s = IcCombineMaskU (src, msk); - if (a != 0xff) - { - m = IcInU(s,0,a,t); - n = IcInU(s,8,a,t); - o = IcInU(s,16,a,t); - p = IcInU(s,24,a,t); - s = m|n|o|p; - } - } - (*dst->store) (dst, s); -} - -static void -IcCombineOutC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t a; - uint16_t t; - uint32_t m,n,o,p; - - d = (*dst->fetch) (dst); - a = ~d >> 24; - s = 0; - if (a) - { - s = IcCombineMaskValueC (src, msk); - if (a != 0xff) - { - m = IcInU(s,0,a,t); - n = IcInU(s,8,a,t); - o = IcInU(s,16,a,t); - p = IcInU(s,24,a,t); - s = m|n|o|p; - } - } - (*dst->store) (dst, s); -} - -static void -IcCombineOutReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t a; - uint16_t t; - uint32_t m,n,o,p; - - s = IcCombineMaskAlphaU (src, msk); - a = ~s >> 24; - if (a != 0xff) - { - d = 0; - if (a) - { - d = (*dst->fetch) (dst); - m = IcInU(d,0,a,t); - n = IcInU(d,8,a,t); - o = IcInU(d,16,a,t); - p = IcInU(d,24,a,t); - d = m|n|o|p; - } - (*dst->store) (dst, d); - } -} - -static void -IcCombineOutReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint32_t a; - uint16_t t; - uint32_t m,n,o,p; - - s = IcCombineMaskAlphaC (src, msk); - a = ~s; - if (a != 0xffffffff) - { - d = 0; - if (a) - { - d = (*dst->fetch) (dst); - m = IcInC(d,0,a,t); - n = IcInC(d,8,a,t); - o = IcInC(d,16,a,t); - p = IcInC(d,24,a,t); - d = m|n|o|p; - } - (*dst->store) (dst, d); - } -} - -static void -IcCombineAtopU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t ad, as; - uint16_t t,u,v; - uint32_t m,n,o,p; - - s = IcCombineMaskU (src, msk); - d = (*dst->fetch) (dst); - ad = ~s >> 24; - as = d >> 24; - m = IcGen(s,d,0,as,ad,t,u,v); - n = IcGen(s,d,8,as,ad,t,u,v); - o = IcGen(s,d,16,as,ad,t,u,v); - p = IcGen(s,d,24,as,ad,t,u,v); - (*dst->store) (dst, m|n|o|p); -} - -static void -IcCombineAtopC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCompSrc cs; - uint32_t s, d; - uint32_t ad; - uint16_t as; - uint16_t t, u, v; - uint32_t m,n,o,p; - - cs = IcCombineMaskC (src, msk); - d = (*dst->fetch) (dst); - s = cs.value; - ad = cs.alpha; - as = d >> 24; - m = IcGen(s,d,0,as,IcGet8(ad,0),t,u,v); - n = IcGen(s,d,8,as,IcGet8(ad,8),t,u,v); - o = IcGen(s,d,16,as,IcGet8(ad,16),t,u,v); - p = IcGen(s,d,24,as,IcGet8(ad,24),t,u,v); - (*dst->store) (dst, m|n|o|p); -} - -static void -IcCombineAtopReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t ad, as; - uint16_t t, u, v; - uint32_t m,n,o,p; - - s = IcCombineMaskU (src, msk); - d = (*dst->fetch) (dst); - ad = s >> 24; - as = ~d >> 24; - m = IcGen(s,d,0,as,ad,t,u,v); - n = IcGen(s,d,8,as,ad,t,u,v); - o = IcGen(s,d,16,as,ad,t,u,v); - p = IcGen(s,d,24,as,ad,t,u,v); - (*dst->store) (dst, m|n|o|p); -} - -static void -IcCombineAtopReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCompSrc cs; - uint32_t s, d, ad; - uint16_t as; - uint16_t t, u, v; - uint32_t m,n,o,p; - - cs = IcCombineMaskC (src, msk); - d = (*dst->fetch) (dst); - s = cs.value; - ad = cs.alpha; - as = ~d >> 24; - m = IcGen(s,d,0,as,IcGet8(ad,0),t,u,v); - n = IcGen(s,d,8,as,IcGet8(ad,8),t,u,v); - o = IcGen(s,d,16,as,IcGet8(ad,16),t,u,v); - p = IcGen(s,d,24,as,IcGet8(ad,24),t,u,v); - (*dst->store) (dst, m|n|o|p); -} - -static void -IcCombineXorU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t ad, as; - uint16_t t, u, v; - uint32_t m,n,o,p; - - s = IcCombineMaskU (src, msk); - d = (*dst->fetch) (dst); - ad = ~s >> 24; - as = ~d >> 24; - m = IcGen(s,d,0,as,ad,t,u,v); - n = IcGen(s,d,8,as,ad,t,u,v); - o = IcGen(s,d,16,as,ad,t,u,v); - p = IcGen(s,d,24,as,ad,t,u,v); - (*dst->store) (dst, m|n|o|p); -} - -static void -IcCombineXorC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCompSrc cs; - uint32_t s, d, ad; - uint16_t as; - uint16_t t, u, v; - uint32_t m,n,o,p; - - cs = IcCombineMaskC (src, msk); - d = (*dst->fetch) (dst); - s = cs.value; - ad = ~cs.alpha; - as = ~d >> 24; - m = IcGen(s,d,0,as,ad,t,u,v); - n = IcGen(s,d,8,as,ad,t,u,v); - o = IcGen(s,d,16,as,ad,t,u,v); - p = IcGen(s,d,24,as,ad,t,u,v); - (*dst->store) (dst, m|n|o|p); -} - -static void -IcCombineAddU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t t; - uint32_t m,n,o,p; - - s = IcCombineMaskU (src, msk); - if (s == ~0) - (*dst->store) (dst, s); - else - { - d = (*dst->fetch) (dst); - if (s && d != ~0) - { - m = IcAdd(s,d,0,t); - n = IcAdd(s,d,8,t); - o = IcAdd(s,d,16,t); - p = IcAdd(s,d,24,t); - (*dst->store) (dst, m|n|o|p); - } - } -} - -static void -IcCombineAddC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t t; - uint32_t m,n,o,p; - - s = IcCombineMaskValueC (src, msk); - if (s == ~0) - (*dst->store) (dst, s); - else - { - d = (*dst->fetch) (dst); - if (s && d != ~0) - { - m = IcAdd(s,d,0,t); - n = IcAdd(s,d,8,t); - o = IcAdd(s,d,16,t); - p = IcAdd(s,d,24,t); - (*dst->store) (dst, m|n|o|p); - } - } -} - -/* - * All of the disjoint composing functions - - The four entries in the first column indicate what source contributions - come from each of the four areas of the picture -- areas covered by neither - A nor B, areas covered only by A, areas covered only by B and finally - areas covered by both A and B. - - Disjoint Conjoint - Fa Fb Fa Fb -(0,0,0,0) 0 0 0 0 -(0,A,0,A) 1 0 1 0 -(0,0,B,B) 0 1 0 1 -(0,A,B,A) 1 min((1-a)/b,1) 1 max(1-a/b,0) -(0,A,B,B) min((1-b)/a,1) 1 max(1-b/a,0) 1 -(0,0,0,A) max(1-(1-b)/a,0) 0 min(1,b/a) 0 -(0,0,0,B) 0 max(1-(1-a)/b,0) 0 min(a/b,1) -(0,A,0,0) min(1,(1-b)/a) 0 max(1-b/a,0) 0 -(0,0,B,0) 0 min(1,(1-a)/b) 0 max(1-a/b,0) -(0,0,B,A) max(1-(1-b)/a,0) min(1,(1-a)/b) min(1,b/a) max(1-a/b,0) -(0,A,0,B) min(1,(1-b)/a) max(1-(1-a)/b,0) max(1-b/a,0) min(1,a/b) -(0,A,B,0) min(1,(1-b)/a) min(1,(1-a)/b) max(1-b/a,0) max(1-a/b,0) - - */ - -#define CombineAOut 1 -#define CombineAIn 2 -#define CombineBOut 4 -#define CombineBIn 8 - -#define CombineClear 0 -#define CombineA (CombineAOut|CombineAIn) -#define CombineB (CombineBOut|CombineBIn) -#define CombineAOver (CombineAOut|CombineBOut|CombineAIn) -#define CombineBOver (CombineAOut|CombineBOut|CombineBIn) -#define CombineAAtop (CombineBOut|CombineAIn) -#define CombineBAtop (CombineAOut|CombineBIn) -#define CombineXor (CombineAOut|CombineBOut) - -/* portion covered by a but not b */ -static uint8_t -IcCombineDisjointOutPart (uint8_t a, uint8_t b) -{ - /* min (1, (1-b) / a) */ - - b = ~b; /* 1 - b */ - if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */ - return 0xff; /* 1 */ - return IcIntDiv(b,a); /* (1-b) / a */ -} - -/* portion covered by both a and b */ -static uint8_t -IcCombineDisjointInPart (uint8_t a, uint8_t b) -{ - /* max (1-(1-b)/a,0) */ - /* = - min ((1-b)/a - 1, 0) */ - /* = 1 - min (1, (1-b)/a) */ - - b = ~b; /* 1 - b */ - if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */ - return 0; /* 1 - 1 */ - return ~IcIntDiv(b,a); /* 1 - (1-b) / a */ -} - -static void -IcCombineDisjointGeneralU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst, - uint8_t combine) -{ - uint32_t s, d; - uint32_t m,n,o,p; - uint16_t Fa, Fb, t, u, v; - uint8_t sa, da; - - s = IcCombineMaskU (src, msk); - sa = s >> 24; - - d = (*dst->fetch) (dst); - da = d >> 24; - - switch (combine & CombineA) { - default: - Fa = 0; - break; - case CombineAOut: - Fa = IcCombineDisjointOutPart (sa, da); - break; - case CombineAIn: - Fa = IcCombineDisjointInPart (sa, da); - break; - case CombineA: - Fa = 0xff; - break; - } - - switch (combine & CombineB) { - default: - Fb = 0; - break; - case CombineBOut: - Fb = IcCombineDisjointOutPart (da, sa); - break; - case CombineBIn: - Fb = IcCombineDisjointInPart (da, sa); - break; - case CombineB: - Fb = 0xff; - break; - } - m = IcGen (s,d,0,Fa,Fb,t,u,v); - n = IcGen (s,d,8,Fa,Fb,t,u,v); - o = IcGen (s,d,16,Fa,Fb,t,u,v); - p = IcGen (s,d,24,Fa,Fb,t,u,v); - s = m|n|o|p; - (*dst->store) (dst, s); -} - -static void -IcCombineDisjointGeneralC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst, - uint8_t combine) -{ - IcCompSrc cs; - uint32_t s, d; - uint32_t m,n,o,p; - uint32_t Fa; - uint16_t Fb, t, u, v; - uint32_t sa; - uint8_t da; - - cs = IcCombineMaskC (src, msk); - s = cs.value; - sa = cs.alpha; - - d = (*dst->fetch) (dst); - da = d >> 24; - - switch (combine & CombineA) { - default: - Fa = 0; - break; - case CombineAOut: - m = IcCombineDisjointOutPart ((uint8_t) (sa >> 0), da); - n = IcCombineDisjointOutPart ((uint8_t) (sa >> 8), da) << 8; - o = IcCombineDisjointOutPart ((uint8_t) (sa >> 16), da) << 16; - p = IcCombineDisjointOutPart ((uint8_t) (sa >> 24), da) << 24; - Fa = m|n|o|p; - break; - case CombineAIn: - m = IcCombineDisjointOutPart ((uint8_t) (sa >> 0), da); - n = IcCombineDisjointOutPart ((uint8_t) (sa >> 8), da) << 8; - o = IcCombineDisjointOutPart ((uint8_t) (sa >> 16), da) << 16; - p = IcCombineDisjointOutPart ((uint8_t) (sa >> 24), da) << 24; - Fa = m|n|o|p; - break; - case CombineA: - Fa = 0xffffffff; - break; - } - - switch (combine & CombineB) { - default: - Fb = 0; - break; - case CombineBOut: - Fb = IcCombineDisjointOutPart (da, sa); - break; - case CombineBIn: - Fb = IcCombineDisjointInPart (da, sa); - break; - case CombineB: - Fb = 0xff; - break; - } - m = IcGen (s,d,0,IcGet8(Fa,0),Fb,t,u,v); - n = IcGen (s,d,8,IcGet8(Fa,8),Fb,t,u,v); - o = IcGen (s,d,16,IcGet8(Fa,16),Fb,t,u,v); - p = IcGen (s,d,24,IcGet8(Fa,24),Fb,t,u,v); - s = m|n|o|p; - (*dst->store) (dst, s); -} - -static void -IcCombineDisjointOverU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s, d; - uint16_t a; - uint16_t t; - uint32_t m,n,o,p; - - s = IcCombineMaskU (src, msk); - a = s >> 24; - if (a != 0x00) - { - if (a != 0xff) - { - d = (*dst->fetch) (dst); - a = IcCombineDisjointOutPart (d >> 24, a); - m = IcOverU(s,d,0,a,t); - n = IcOverU(s,d,8,a,t); - o = IcOverU(s,d,16,a,t); - p = IcOverU(s,d,24,a,t); - s = m|n|o|p; - } - (*dst->store) (dst, s); - } -} - -static void -IcCombineDisjointOverC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralC (src, msk, dst, CombineAOver); -} - -static void -IcCombineDisjointOverReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralU (src, msk, dst, CombineBOver); -} - -static void -IcCombineDisjointOverReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralC (src, msk, dst, CombineBOver); -} - -static void -IcCombineDisjointInU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralU (src, msk, dst, CombineAIn); -} - -static void -IcCombineDisjointInC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralC (src, msk, dst, CombineAIn); -} - -static void -IcCombineDisjointInReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralU (src, msk, dst, CombineBIn); -} - -static void -IcCombineDisjointInReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralC (src, msk, dst, CombineBIn); -} - -static void -IcCombineDisjointOutU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralU (src, msk, dst, CombineAOut); -} - -static void -IcCombineDisjointOutC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralC (src, msk, dst, CombineAOut); -} - -static void -IcCombineDisjointOutReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralU (src, msk, dst, CombineBOut); -} - -static void -IcCombineDisjointOutReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralC (src, msk, dst, CombineBOut); -} - -static void -IcCombineDisjointAtopU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralU (src, msk, dst, CombineAAtop); -} - -static void -IcCombineDisjointAtopC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralC (src, msk, dst, CombineAAtop); -} - -static void -IcCombineDisjointAtopReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralU (src, msk, dst, CombineBAtop); -} - -static void -IcCombineDisjointAtopReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralC (src, msk, dst, CombineBAtop); -} - -static void -IcCombineDisjointXorU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralU (src, msk, dst, CombineXor); -} - -static void -IcCombineDisjointXorC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineDisjointGeneralC (src, msk, dst, CombineXor); -} - -/* portion covered by a but not b */ -static uint8_t -IcCombineConjointOutPart (uint8_t a, uint8_t b) -{ - /* max (1-b/a,0) */ - /* = 1-min(b/a,1) */ - - /* min (1, (1-b) / a) */ - - if (b >= a) /* b >= a -> b/a >= 1 */ - return 0x00; /* 0 */ - return ~IcIntDiv(b,a); /* 1 - b/a */ -} - -/* portion covered by both a and b */ -static uint8_t -IcCombineConjointInPart (uint8_t a, uint8_t b) -{ - /* min (1,b/a) */ - - if (b >= a) /* b >= a -> b/a >= 1 */ - return 0xff; /* 1 */ - return IcIntDiv(b,a); /* b/a */ -} - -static void -IcCombineConjointGeneralU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst, - uint8_t combine) -{ - uint32_t s, d; - uint32_t m,n,o,p; - uint16_t Fa, Fb, t, u, v; - uint8_t sa, da; - - s = IcCombineMaskU (src, msk); - sa = s >> 24; - - d = (*dst->fetch) (dst); - da = d >> 24; - - switch (combine & CombineA) { - default: - Fa = 0; - break; - case CombineAOut: - Fa = IcCombineConjointOutPart (sa, da); - break; - case CombineAIn: - Fa = IcCombineConjointInPart (sa, da); - break; - case CombineA: - Fa = 0xff; - break; - } - - switch (combine & CombineB) { - default: - Fb = 0; - break; - case CombineBOut: - Fb = IcCombineConjointOutPart (da, sa); - break; - case CombineBIn: - Fb = IcCombineConjointInPart (da, sa); - break; - case CombineB: - Fb = 0xff; - break; - } - m = IcGen (s,d,0,Fa,Fb,t,u,v); - n = IcGen (s,d,8,Fa,Fb,t,u,v); - o = IcGen (s,d,16,Fa,Fb,t,u,v); - p = IcGen (s,d,24,Fa,Fb,t,u,v); - s = m|n|o|p; - (*dst->store) (dst, s); -} - -static void -IcCombineConjointGeneralC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst, - uint8_t combine) -{ - IcCompSrc cs; - uint32_t s, d; - uint32_t m,n,o,p; - uint32_t Fa; - uint16_t Fb, t, u, v; - uint32_t sa; - uint8_t da; - - cs = IcCombineMaskC (src, msk); - s = cs.value; - sa = cs.alpha; - - d = (*dst->fetch) (dst); - da = d >> 24; - - switch (combine & CombineA) { - default: - Fa = 0; - break; - case CombineAOut: - m = IcCombineConjointOutPart ((uint8_t) (sa >> 0), da); - n = IcCombineConjointOutPart ((uint8_t) (sa >> 8), da) << 8; - o = IcCombineConjointOutPart ((uint8_t) (sa >> 16), da) << 16; - p = IcCombineConjointOutPart ((uint8_t) (sa >> 24), da) << 24; - Fa = m|n|o|p; - break; - case CombineAIn: - m = IcCombineConjointOutPart ((uint8_t) (sa >> 0), da); - n = IcCombineConjointOutPart ((uint8_t) (sa >> 8), da) << 8; - o = IcCombineConjointOutPart ((uint8_t) (sa >> 16), da) << 16; - p = IcCombineConjointOutPart ((uint8_t) (sa >> 24), da) << 24; - Fa = m|n|o|p; - break; - case CombineA: - Fa = 0xffffffff; - break; - } - - switch (combine & CombineB) { - default: - Fb = 0; - break; - case CombineBOut: - Fb = IcCombineConjointOutPart (da, sa); - break; - case CombineBIn: - Fb = IcCombineConjointInPart (da, sa); - break; - case CombineB: - Fb = 0xff; - break; - } - m = IcGen (s,d,0,IcGet8(Fa,0),Fb,t,u,v); - n = IcGen (s,d,8,IcGet8(Fa,8),Fb,t,u,v); - o = IcGen (s,d,16,IcGet8(Fa,16),Fb,t,u,v); - p = IcGen (s,d,24,IcGet8(Fa,24),Fb,t,u,v); - s = m|n|o|p; - (*dst->store) (dst, s); -} - -static void -IcCombineConjointOverU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralU (src, msk, dst, CombineAOver); -/* - uint32_t s, d; - uint16_t a; - uint16_t t; - uint32_t m,n,o,p; - - s = IcCombineMaskU (src, msk); - a = s >> 24; - if (a != 0x00) - { - if (a != 0xff) - { - d = (*dst->fetch) (dst); - a = IcCombineConjointOutPart (d >> 24, a); - m = IcOverU(s,d,0,a,t); - n = IcOverU(s,d,8,a,t); - o = IcOverU(s,d,16,a,t); - p = IcOverU(s,d,24,a,t); - s = m|n|o|p; - } - (*dst->store) (dst, s); - } - */ -} - -static void -IcCombineConjointOverC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralC (src, msk, dst, CombineAOver); -} - -static void -IcCombineConjointOverReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralU (src, msk, dst, CombineBOver); -} - -static void -IcCombineConjointOverReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralC (src, msk, dst, CombineBOver); -} - -static void -IcCombineConjointInU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralU (src, msk, dst, CombineAIn); -} - -static void -IcCombineConjointInC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralC (src, msk, dst, CombineAIn); -} - -static void -IcCombineConjointInReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralU (src, msk, dst, CombineBIn); -} - -static void -IcCombineConjointInReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralC (src, msk, dst, CombineBIn); -} - -static void -IcCombineConjointOutU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralU (src, msk, dst, CombineAOut); -} - -static void -IcCombineConjointOutC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralC (src, msk, dst, CombineAOut); -} - -static void -IcCombineConjointOutReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralU (src, msk, dst, CombineBOut); -} - -static void -IcCombineConjointOutReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralC (src, msk, dst, CombineBOut); -} - -static void -IcCombineConjointAtopU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralU (src, msk, dst, CombineAAtop); -} - -static void -IcCombineConjointAtopC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralC (src, msk, dst, CombineAAtop); -} - -static void -IcCombineConjointAtopReverseU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralU (src, msk, dst, CombineBAtop); -} - -static void -IcCombineConjointAtopReverseC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralC (src, msk, dst, CombineBAtop); -} - -static void -IcCombineConjointXorU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralU (src, msk, dst, CombineXor); -} - -static void -IcCombineConjointXorC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCombineConjointGeneralC (src, msk, dst, CombineXor); -} - -static IcCombineFunc const IcCombineFuncU[] = { - IcCombineClear, - IcCombineSrcU, - IcCombineDst, - IcCombineOverU, - IcCombineOverReverseU, - IcCombineInU, - IcCombineInReverseU, - IcCombineOutU, - IcCombineOutReverseU, - IcCombineAtopU, - IcCombineAtopReverseU, - IcCombineXorU, - IcCombineAddU, - IcCombineDisjointOverU, /* Saturate */ - 0, - 0, - IcCombineClear, - IcCombineSrcU, - IcCombineDst, - IcCombineDisjointOverU, - IcCombineDisjointOverReverseU, - IcCombineDisjointInU, - IcCombineDisjointInReverseU, - IcCombineDisjointOutU, - IcCombineDisjointOutReverseU, - IcCombineDisjointAtopU, - IcCombineDisjointAtopReverseU, - IcCombineDisjointXorU, - 0, - 0, - 0, - 0, - IcCombineClear, - IcCombineSrcU, - IcCombineDst, - IcCombineConjointOverU, - IcCombineConjointOverReverseU, - IcCombineConjointInU, - IcCombineConjointInReverseU, - IcCombineConjointOutU, - IcCombineConjointOutReverseU, - IcCombineConjointAtopU, - IcCombineConjointAtopReverseU, - IcCombineConjointXorU, -}; - -static IcCombineFunc const IcCombineFuncC[] = { - IcCombineClear, - IcCombineSrcC, - IcCombineDst, - IcCombineOverC, - IcCombineOverReverseC, - IcCombineInC, - IcCombineInReverseC, - IcCombineOutC, - IcCombineOutReverseC, - IcCombineAtopC, - IcCombineAtopReverseC, - IcCombineXorC, - IcCombineAddC, - IcCombineDisjointOverC, /* Saturate */ - 0, - 0, - IcCombineClear, /* 0x10 */ - IcCombineSrcC, - IcCombineDst, - IcCombineDisjointOverC, - IcCombineDisjointOverReverseC, - IcCombineDisjointInC, - IcCombineDisjointInReverseC, - IcCombineDisjointOutC, - IcCombineDisjointOutReverseC, - IcCombineDisjointAtopC, - IcCombineDisjointAtopReverseC, - IcCombineDisjointXorC, /* 0x1b */ - 0, - 0, - 0, - 0, - IcCombineClear, - IcCombineSrcC, - IcCombineDst, - IcCombineConjointOverC, - IcCombineConjointOverReverseC, - IcCombineConjointInC, - IcCombineConjointInReverseC, - IcCombineConjointOutC, - IcCombineConjointOutReverseC, - IcCombineConjointAtopC, - IcCombineConjointAtopReverseC, - IcCombineConjointXorC, -}; - -/* - * All of the fetch functions - */ - -static uint32_t -IcFetch_a8r8g8b8 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - return ((uint32_t *)line)[offset >> 5]; -} - -static uint32_t -IcFetch_x8r8g8b8 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - return ((uint32_t *)line)[offset >> 5] | 0xff000000; -} - -static uint32_t -IcFetch_a8b8g8r8 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint32_t *)line)[offset >> 5]; - - return ((pixel & 0xff000000) | - ((pixel >> 16) & 0xff) | - (pixel & 0x0000ff00) | - ((pixel & 0xff) << 16)); -} - -static uint32_t -IcFetch_x8b8g8r8 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint32_t *)line)[offset >> 5]; - - return ((0xff000000) | - ((pixel >> 16) & 0xff) | - (pixel & 0x0000ff00) | - ((pixel & 0xff) << 16)); -} - -static uint32_t -IcFetch_r8g8b8 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint8_t *pixel = ((uint8_t *) line) + (offset >> 3); -#if IMAGE_BYTE_ORDER == MSBFirst - return (0xff000000 | - (pixel[0] << 16) | - (pixel[1] << 8) | - (pixel[2])); -#else - return (0xff000000 | - (pixel[2] << 16) | - (pixel[1] << 8) | - (pixel[0])); -#endif -} - -static uint32_t -IcFetch_b8g8r8 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint8_t *pixel = ((uint8_t *) line) + (offset >> 3); -#if IMAGE_BYTE_ORDER == MSBFirst - return (0xff000000 | - (pixel[2] << 16) | - (pixel[1] << 8) | - (pixel[0])); -#else - return (0xff000000 | - (pixel[0] << 16) | - (pixel[1] << 8) | - (pixel[2])); -#endif -} - -static uint32_t -IcFetch_r5g6b5 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint16_t *) line)[offset >> 4]; - uint32_t r,g,b; - - r = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) << 8; - g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5; - b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; - return (0xff000000 | r | g | b); -} - -static uint32_t -IcFetch_b5g6r5 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint16_t *) line)[offset >> 4]; - uint32_t r,g,b; - - b = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) >> 8; - g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5; - r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; - return (0xff000000 | r | g | b); -} - -static uint32_t -IcFetch_a1r5g5b5 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint16_t *) line)[offset >> 4]; - uint32_t a,r,g,b; - - a = (uint32_t) ((uint8_t) (0 - ((pixel & 0x8000) >> 15))) << 24; - r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; - return (a | r | g | b); -} - -static uint32_t -IcFetch_x1r5g5b5 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint16_t *) line)[offset >> 4]; - uint32_t r,g,b; - - r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; - return (0xff000000 | r | g | b); -} - -static uint32_t -IcFetch_a1b5g5r5 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint16_t *) line)[offset >> 4]; - uint32_t a,r,g,b; - - a = (uint32_t) ((uint8_t) (0 - ((pixel & 0x8000) >> 15))) << 24; - b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; - return (a | r | g | b); -} - -static uint32_t -IcFetch_x1b5g5r5 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint16_t *) line)[offset >> 4]; - uint32_t r,g,b; - - b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; - return (0xff000000 | r | g | b); -} - -static uint32_t -IcFetch_a4r4g4b4 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint16_t *) line)[offset >> 4]; - uint32_t a,r,g,b; - - a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16; - r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); - return (a | r | g | b); -} - -static uint32_t -IcFetch_x4r4g4b4 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint16_t *) line)[offset >> 4]; - uint32_t r,g,b; - - r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); - return (0xff000000 | r | g | b); -} - -static uint32_t -IcFetch_a4b4g4r4 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint16_t *) line)[offset >> 4]; - uint32_t a,r,g,b; - - a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16; - b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); - return (a | r | g | b); -} - -static uint32_t -IcFetch_x4b4g4r4 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint16_t *) line)[offset >> 4]; - uint32_t r,g,b; - - b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); - return (0xff000000 | r | g | b); -} - -static uint32_t -IcFetch_a8 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint8_t *) line)[offset>>3]; - - return pixel << 24; -} - -static uint32_t -IcFetcha_a8 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint8_t *) line)[offset>>3]; - - pixel |= pixel << 8; - pixel |= pixel << 16; - return pixel; -} - -static uint32_t -IcFetch_r3g3b2 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint8_t *) line)[offset>>3]; - uint32_t r,g,b; - - r = ((pixel & 0xe0) | ((pixel & 0xe0) >> 3) | ((pixel & 0xc0) >> 6)) << 16; - g = ((pixel & 0x1c) | ((pixel & 0x18) >> 3) | ((pixel & 0x1c) << 3)) << 8; - b = (((pixel & 0x03) ) | - ((pixel & 0x03) << 2) | - ((pixel & 0x03) << 4) | - ((pixel & 0x03) << 6)); - return (0xff000000 | r | g | b); -} - -static uint32_t -IcFetch_b2g3r3 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint8_t *) line)[offset>>3]; - uint32_t r,g,b; - - b = (((pixel & 0xc0) ) | - ((pixel & 0xc0) >> 2) | - ((pixel & 0xc0) >> 4) | - ((pixel & 0xc0) >> 6)); - g = ((pixel & 0x38) | ((pixel & 0x38) >> 3) | ((pixel & 0x30) << 2)) << 8; - r = (((pixel & 0x07) ) | - ((pixel & 0x07) << 3) | - ((pixel & 0x06) << 6)) << 16; - return (0xff000000 | r | g | b); -} - -static uint32_t -IcFetch_a2r2g2b2 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint8_t *) line)[offset>>3]; - uint32_t a,r,g,b; - - a = ((pixel & 0xc0) * 0x55) << 18; - r = ((pixel & 0x30) * 0x55) << 12; - g = ((pixel & 0x0c) * 0x55) << 6; - b = ((pixel & 0x03) * 0x55); - return a|r|g|b; -} - -#define Fetch8(l,o) (((uint8_t *) (l))[(o) >> 3]) -#if IMAGE_BYTE_ORDER == MSBFirst -#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4) -#else -#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf) -#endif - -static uint32_t -IcFetch_a4 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = Fetch4(line, offset); - - pixel |= pixel << 4; - return pixel << 24; -} - -static uint32_t -IcFetcha_a4 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = Fetch4(line, offset); - - pixel |= pixel << 4; - pixel |= pixel << 8; - pixel |= pixel << 16; - return pixel; -} - -static uint32_t -IcFetch_r1g2b1 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = Fetch4(line, offset); - uint32_t r,g,b; - - r = ((pixel & 0x8) * 0xff) << 13; - g = ((pixel & 0x6) * 0x55) << 7; - b = ((pixel & 0x1) * 0xff); - return 0xff000000|r|g|b; -} - -static uint32_t -IcFetch_b1g2r1 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = Fetch4(line, offset); - uint32_t r,g,b; - - b = ((pixel & 0x8) * 0xff) >> 3; - g = ((pixel & 0x6) * 0x55) << 7; - r = ((pixel & 0x1) * 0xff) << 16; - return 0xff000000|r|g|b; -} - -static uint32_t -IcFetch_a1r1g1b1 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = Fetch4(line, offset); - uint32_t a,r,g,b; - - a = ((pixel & 0x8) * 0xff) << 21; - r = ((pixel & 0x4) * 0xff) << 14; - g = ((pixel & 0x2) * 0xff) << 7; - b = ((pixel & 0x1) * 0xff); - return a|r|g|b; -} - -static uint32_t -IcFetch_a1b1g1r1 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = Fetch4(line, offset); - uint32_t a,r,g,b; - - a = ((pixel & 0x8) * 0xff) << 21; - r = ((pixel & 0x4) * 0xff) >> 3; - g = ((pixel & 0x2) * 0xff) << 7; - b = ((pixel & 0x1) * 0xff) << 16; - return a|r|g|b; -} - -static uint32_t -IcFetcha_a1 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint32_t *)line)[offset >> 5]; - uint32_t a; -#if BITMAP_BIT_ORDER == MSBFirst - a = pixel >> (0x1f - (offset & 0x1f)); -#else - a = pixel >> (offset & 0x1f); -#endif - a = a & 1; - a |= a << 1; - a |= a << 2; - a |= a << 4; - a |= a << 8; - a |= a << 16; - return a; -} - -static uint32_t -IcFetch_a1 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint32_t *)line)[offset >> 5]; - uint32_t a; -#if BITMAP_BIT_ORDER == MSBFirst - a = pixel >> (0x1f - (offset & 0x1f)); -#else - a = pixel >> (offset & 0x1f); -#endif - a = a & 1; - a |= a << 1; - a |= a << 2; - a |= a << 4; - return a << 24; -} - -/* - * All the store functions - */ - -#define Splita(v) uint32_t a = ((v) >> 24), r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff -#define Split(v) uint32_t r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff - -static void -IcStore_a8r8g8b8 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - ((uint32_t *)line)[offset >> 5] = value; -} - -static void -IcStore_x8r8g8b8 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - ((uint32_t *)line)[offset >> 5] = value & 0xffffff; -} - -static void -IcStore_a8b8g8r8 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - Splita(value); - ((uint32_t *)line)[offset >> 5] = a << 24 | b << 16 | g << 8 | r; -} - -static void -IcStore_x8b8g8r8 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - Split(value); - ((uint32_t *)line)[offset >> 5] = b << 16 | g << 8 | r; -} - -static void -IcStore_r8g8b8 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint8_t *pixel = ((uint8_t *) line) + (offset >> 3); - Split(value); -#if IMAGE_BYTE_ORDER == MSBFirst - pixel[0] = r; - pixel[1] = g; - pixel[2] = b; -#else - pixel[0] = b; - pixel[1] = g; - pixel[2] = r; -#endif -} - -static void -IcStore_b8g8r8 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint8_t *pixel = ((uint8_t *) line) + (offset >> 3); - Split(value); -#if IMAGE_BYTE_ORDER == MSBFirst - pixel[0] = b; - pixel[1] = g; - pixel[2] = r; -#else - pixel[0] = r; - pixel[1] = g; - pixel[2] = b; -#endif -} - -static void -IcStore_r5g6b5 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint16_t *pixel = ((uint16_t *) line) + (offset >> 4); - Split(value); - *pixel = (((r << 8) & 0xf800) | - ((g << 3) & 0x07e0) | - ((b >> 3) )); -} - -static void -IcStore_b5g6r5 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint16_t *pixel = ((uint16_t *) line) + (offset >> 4); - Split(value); - *pixel = (((b << 8) & 0xf800) | - ((g << 3) & 0x07e0) | - ((r >> 3) )); -} - -static void -IcStore_a1r5g5b5 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint16_t *pixel = ((uint16_t *) line) + (offset >> 4); - Splita(value); - *pixel = (((a << 8) & 0x8000) | - ((r << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((b >> 3) )); -} - -static void -IcStore_x1r5g5b5 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint16_t *pixel = ((uint16_t *) line) + (offset >> 4); - Split(value); - *pixel = (((r << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((b >> 3) )); -} - -static void -IcStore_a1b5g5r5 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint16_t *pixel = ((uint16_t *) line) + (offset >> 4); - Splita(value); - *pixel = (((a << 8) & 0x8000) | - ((b << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((r >> 3) )); -} - -static void -IcStore_x1b5g5r5 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint16_t *pixel = ((uint16_t *) line) + (offset >> 4); - Split(value); - *pixel = (((b << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((r >> 3) )); -} - -static void -IcStore_a4r4g4b4 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint16_t *pixel = ((uint16_t *) line) + (offset >> 4); - Splita(value); - *pixel = (((a << 8) & 0xf000) | - ((r << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((b >> 4) )); -} - -static void -IcStore_x4r4g4b4 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint16_t *pixel = ((uint16_t *) line) + (offset >> 4); - Split(value); - *pixel = (((r << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((b >> 4) )); -} - -static void -IcStore_a4b4g4r4 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint16_t *pixel = ((uint16_t *) line) + (offset >> 4); - Splita(value); - *pixel = (((a << 8) & 0xf000) | - ((b << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((r >> 4) )); -} - -static void -IcStore_x4b4g4r4 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint16_t *pixel = ((uint16_t *) line) + (offset >> 4); - Split(value); - *pixel = (((b << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((r >> 4) )); -} - -static void -IcStore_a8 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint8_t *pixel = ((uint8_t *) line) + (offset >> 3); - *pixel = value >> 24; -} - -static void -IcStore_r3g3b2 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint8_t *pixel = ((uint8_t *) line) + (offset >> 3); - Split(value); - *pixel = (((r ) & 0xe0) | - ((g >> 3) & 0x1c) | - ((b >> 6) )); -} - -static void -IcStore_b2g3r3 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint8_t *pixel = ((uint8_t *) line) + (offset >> 3); - Split(value); - *pixel = (((b ) & 0xe0) | - ((g >> 3) & 0x1c) | - ((r >> 6) )); -} - -static void -IcStore_a2r2g2b2 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint8_t *pixel = ((uint8_t *) line) + (offset >> 3); - Splita(value); - *pixel = (((a ) & 0xc0) | - ((r >> 2) & 0x30) | - ((g >> 4) & 0x0c) | - ((b >> 6) )); -} - -#define Store8(l,o,v) (((uint8_t *) l)[(o) >> 3] = (v)) -#if IMAGE_BYTE_ORDER == MSBFirst -#define Store4(l,o,v) Store8(l,o,((o) & 4 ? \ - (Fetch8(l,o) & 0xf0) | (v) : \ - (Fetch8(l,o) & 0x0f) | ((v) << 4))) -#else -#define Store4(l,o,v) Store8(l,o,((o) & 4 ? \ - (Fetch8(l,o) & 0x0f) | ((v) << 4) : \ - (Fetch8(l,o) & 0xf0) | (v))) -#endif - -static void -IcStore_a4 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - Store4(line,offset,value>>28); -} - -static void -IcStore_r1g2b1 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel; - - Split(value); - pixel = (((r >> 4) & 0x8) | - ((g >> 5) & 0x6) | - ((b >> 7) )); - Store4(line,offset,pixel); -} - -static void -IcStore_b1g2r1 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel; - - Split(value); - pixel = (((b >> 4) & 0x8) | - ((g >> 5) & 0x6) | - ((r >> 7) )); - Store4(line,offset,pixel); -} - -static void -IcStore_a1r1g1b1 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel; - Splita(value); - pixel = (((a >> 4) & 0x8) | - ((r >> 5) & 0x4) | - ((g >> 6) & 0x2) | - ((b >> 7) )); - Store4(line,offset,pixel); -} - -static void -IcStore_a1b1g1r1 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel; - Splita(value); - pixel = (((a >> 4) & 0x8) | - ((b >> 5) & 0x4) | - ((g >> 6) & 0x2) | - ((r >> 7) )); - Store4(line,offset,pixel); -} - -static void -IcStore_a1 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t *pixel = ((uint32_t *) line) + (offset >> 5); - uint32_t mask = IcStipMask(offset & 0x1f, 1); - - value = value & 0x80000000 ? mask : 0; - *pixel = (*pixel & ~mask) | value; -} - -static uint32_t -IcFetch_external (IcCompositeOperand *op) -{ - uint32_t rgb = (*op[1].fetch) (&op[1]); - uint32_t a = (*op[2].fetch) (&op[2]); - - return (rgb & 0xffffff) | (a & 0xff000000); -} - - -static uint32_t -IcFetcha_external (IcCompositeOperand *op) -{ - return (*op[2].fetch) (&op[2]); -} - -static void -IcStore_external (IcCompositeOperand *op, uint32_t value) -{ - (*op[1].store) (&op[1], value | 0xff000000); - (*op[2].store) (&op[2], value & 0xff000000); -} - -static uint32_t -IcFetch_transform (IcCompositeOperand *op) -{ - IcVector v; - int x, y; - int minx, maxx, miny, maxy; - int n; - uint32_t rtot, gtot, btot, atot; - uint32_t xerr, yerr; - uint32_t bits; - PixRegionBox box; - - v.vector[0] = IntToxFixed(op->u.transform.x); - v.vector[1] = IntToxFixed(op->u.transform.y); - v.vector[2] = xFixed1; - if (!IcTransformPoint (op->u.transform.transform, &v)) - return 0; - switch (op->u.transform.filter) { - case IcFilterFast: - case IcFilterNearest: - y = xFixedToInt (v.vector[1]) + op->u.transform.top_y; - x = xFixedToInt (v.vector[0]) + op->u.transform.left_x; - if (PixRegionPointInRegion (op->clip, x, y, &box)) - { - (*op[1].set) (&op[1], x, y); - bits = (*op[1].fetch) (&op[1]); - } - else - bits = 0; - break; - case IcFilterGood: - case IcFilterBest: - case IcFilterBilinear: - rtot = gtot = btot = atot = 0; - miny = xFixedToInt (v.vector[1]) + op->u.transform.top_y; - maxy = xFixedToInt (xFixedCeil (v.vector[1])) + op->u.transform.top_y; - - minx = xFixedToInt (v.vector[0]) + op->u.transform.left_x; - maxx = xFixedToInt (xFixedCeil (v.vector[0])) + op->u.transform.left_x; - - yerr = xFixed1 - xFixedFrac (v.vector[1]); - for (y = miny; y <= maxy; y++) - { - uint32_t lrtot = 0, lgtot = 0, lbtot = 0, latot = 0; - - xerr = xFixed1 - xFixedFrac (v.vector[0]); - for (x = minx; x <= maxx; x++) - { - if (PixRegionPointInRegion (op->clip, x, y, &box)) - { - (*op[1].set) (&op[1], x, y); - bits = (*op[1].fetch) (&op[1]); - { - Splita(bits); - lrtot += r * xerr; - lgtot += g * xerr; - lbtot += b * xerr; - latot += a * xerr; - n++; - } - } - xerr = xFixed1 - xerr; - } - rtot += (lrtot >> 10) * yerr; - gtot += (lgtot >> 10) * yerr; - btot += (lbtot >> 10) * yerr; - atot += (latot >> 10) * yerr; - yerr = xFixed1 - yerr; - } - if ((atot >>= 22) > 0xff) atot = 0xff; - if ((rtot >>= 22) > 0xff) rtot = 0xff; - if ((gtot >>= 22) > 0xff) gtot = 0xff; - if ((btot >>= 22) > 0xff) btot = 0xff; - bits = ((atot << 24) | - (rtot << 16) | - (gtot << 8) | - (btot )); - break; - default: - bits = 0; - break; - } - return bits; -} - -static uint32_t -IcFetcha_transform (IcCompositeOperand *op) -{ - IcVector v; - int x, y; - int minx, maxx, miny, maxy; - int n; - uint32_t rtot, gtot, btot, atot; - uint32_t xerr, yerr; - uint32_t bits; - PixRegionBox box; - - v.vector[0] = IntToxFixed(op->u.transform.x); - v.vector[1] = IntToxFixed(op->u.transform.y); - v.vector[2] = xFixed1; - if (!IcTransformPoint (op->u.transform.transform, &v)) - return 0; - switch (op->u.transform.filter) { - case IcFilterFast: - case IcFilterNearest: - y = xFixedToInt (v.vector[1]) + op->u.transform.left_x; - x = xFixedToInt (v.vector[0]) + op->u.transform.top_y; - if (PixRegionPointInRegion (op->clip, x, y, &box)) - { - (*op[1].set) (&op[1], x, y); - bits = (*op[1].fetcha) (&op[1]); - } - else - bits = 0; - break; - case IcFilterGood: - case IcFilterBest: - case IcFilterBilinear: - rtot = gtot = btot = atot = 0; - - miny = xFixedToInt (v.vector[1]) + op->u.transform.top_y; - maxy = xFixedToInt (xFixedCeil (v.vector[1])) + op->u.transform.top_y; - - minx = xFixedToInt (v.vector[0]) + op->u.transform.left_x; - maxx = xFixedToInt (xFixedCeil (v.vector[0])) + op->u.transform.left_x; - - yerr = xFixed1 - xFixedFrac (v.vector[1]); - for (y = miny; y <= maxy; y++) - { - uint32_t lrtot = 0, lgtot = 0, lbtot = 0, latot = 0; - xerr = xFixed1 - xFixedFrac (v.vector[0]); - for (x = minx; x <= maxx; x++) - { - if (PixRegionPointInRegion (op->clip, x, y, &box)) - { - (*op[1].set) (&op[1], x, y); - bits = (*op[1].fetcha) (&op[1]); - { - Splita(bits); - lrtot += r * xerr; - lgtot += g * xerr; - lbtot += b * xerr; - latot += a * xerr; - n++; - } - } - x++; - xerr = xFixed1 - xerr; - } - rtot += (lrtot >> 10) * yerr; - gtot += (lgtot >> 10) * yerr; - btot += (lbtot >> 10) * yerr; - atot += (latot >> 10) * yerr; - y++; - yerr = xFixed1 - yerr; - } - if ((atot >>= 22) > 0xff) atot = 0xff; - if ((rtot >>= 22) > 0xff) rtot = 0xff; - if ((gtot >>= 22) > 0xff) gtot = 0xff; - if ((btot >>= 22) > 0xff) btot = 0xff; - bits = ((atot << 24) | - (rtot << 16) | - (gtot << 8) | - (btot )); - break; - default: - bits = 0; - break; - } - return bits; -} - -static IcAccessMap const icAccessMap[] = { - /* 32bpp formats */ - { PICT_a8r8g8b8, IcFetch_a8r8g8b8, IcFetch_a8r8g8b8, IcStore_a8r8g8b8 }, - { PICT_x8r8g8b8, IcFetch_x8r8g8b8, IcFetch_x8r8g8b8, IcStore_x8r8g8b8 }, - { PICT_a8b8g8r8, IcFetch_a8b8g8r8, IcFetch_a8b8g8r8, IcStore_a8b8g8r8 }, - { PICT_x8b8g8r8, IcFetch_x8b8g8r8, IcFetch_x8b8g8r8, IcStore_x8b8g8r8 }, - - /* 24bpp formats */ - { PICT_r8g8b8, IcFetch_r8g8b8, IcFetch_r8g8b8, IcStore_r8g8b8 }, - { PICT_b8g8r8, IcFetch_b8g8r8, IcFetch_b8g8r8, IcStore_b8g8r8 }, - - /* 16bpp formats */ - { PICT_r5g6b5, IcFetch_r5g6b5, IcFetch_r5g6b5, IcStore_r5g6b5 }, - { PICT_b5g6r5, IcFetch_b5g6r5, IcFetch_b5g6r5, IcStore_b5g6r5 }, - - { PICT_a1r5g5b5, IcFetch_a1r5g5b5, IcFetch_a1r5g5b5, IcStore_a1r5g5b5 }, - { PICT_x1r5g5b5, IcFetch_x1r5g5b5, IcFetch_x1r5g5b5, IcStore_x1r5g5b5 }, - { PICT_a1b5g5r5, IcFetch_a1b5g5r5, IcFetch_a1b5g5r5, IcStore_a1b5g5r5 }, - { PICT_x1b5g5r5, IcFetch_x1b5g5r5, IcFetch_x1b5g5r5, IcStore_x1b5g5r5 }, - { PICT_a4r4g4b4, IcFetch_a4r4g4b4, IcFetch_a4r4g4b4, IcStore_a4r4g4b4 }, - { PICT_x4r4g4b4, IcFetch_x4r4g4b4, IcFetch_x4r4g4b4, IcStore_x4r4g4b4 }, - { PICT_a4b4g4r4, IcFetch_a4b4g4r4, IcFetch_a4b4g4r4, IcStore_a4b4g4r4 }, - { PICT_x4b4g4r4, IcFetch_x4b4g4r4, IcFetch_x4b4g4r4, IcStore_x4b4g4r4 }, - - /* 8bpp formats */ - { PICT_a8, IcFetch_a8, IcFetcha_a8, IcStore_a8 }, - { PICT_r3g3b2, IcFetch_r3g3b2, IcFetch_r3g3b2, IcStore_r3g3b2 }, - { PICT_b2g3r3, IcFetch_b2g3r3, IcFetch_b2g3r3, IcStore_b2g3r3 }, - { PICT_a2r2g2b2, IcFetch_a2r2g2b2, IcFetch_a2r2g2b2, IcStore_a2r2g2b2 }, - - /* 4bpp formats */ - { PICT_a4, IcFetch_a4, IcFetcha_a4, IcStore_a4 }, - { PICT_r1g2b1, IcFetch_r1g2b1, IcFetch_r1g2b1, IcStore_r1g2b1 }, - { PICT_b1g2r1, IcFetch_b1g2r1, IcFetch_b1g2r1, IcStore_b1g2r1 }, - { PICT_a1r1g1b1, IcFetch_a1r1g1b1, IcFetch_a1r1g1b1, IcStore_a1r1g1b1 }, - { PICT_a1b1g1r1, IcFetch_a1b1g1r1, IcFetch_a1b1g1r1, IcStore_a1b1g1r1 }, - - /* 1bpp formats */ - { PICT_a1, IcFetch_a1, IcFetcha_a1, IcStore_a1 }, -}; -#define NumAccessMap (sizeof icAccessMap / sizeof icAccessMap[0]) - -static void -IcStepOver (IcCompositeOperand *op) -{ - op->u.drawable.offset += op->u.drawable.bpp; -} - -static void -IcStepDown (IcCompositeOperand *op) -{ - op->u.drawable.line += op->u.drawable.stride; - op->u.drawable.offset = op->u.drawable.start_offset; -} - -static void -IcSet (IcCompositeOperand *op, int x, int y) -{ - op->u.drawable.line = op->u.drawable.top_line + y * op->u.drawable.stride; - op->u.drawable.offset = op->u.drawable.left_offset + x * op->u.drawable.bpp; -} - -static void -IcStepOver_external (IcCompositeOperand *op) -{ - (*op[1].over) (&op[1]); - (*op[2].over) (&op[2]); -} - -static void -IcStepDown_external (IcCompositeOperand *op) -{ - (*op[1].down) (&op[1]); - (*op[2].down) (&op[2]); -} - -static void -IcSet_external (IcCompositeOperand *op, int x, int y) -{ - (*op[1].set) (&op[1], x, y); - (*op[2].set) (&op[2], - x - op->u.external.alpha_dx, - y - op->u.external.alpha_dy); -} - -static void -IcStepOver_transform (IcCompositeOperand *op) -{ - op->u.transform.x++; -} - -static void -IcStepDown_transform (IcCompositeOperand *op) -{ - op->u.transform.y++; - op->u.transform.x = op->u.transform.start_x; -} - -static void -IcSet_transform (IcCompositeOperand *op, int x, int y) -{ - op->u.transform.x = x - op->u.transform.left_x; - op->u.transform.y = y - op->u.transform.top_y; -} - - -int -IcBuildCompositeOperand (IcImage *image, - IcCompositeOperand op[4], - int16_t x, - int16_t y, - int transform, - int alpha) -{ - /* Check for transform */ - if (transform && image->transform) - { - if (!IcBuildCompositeOperand (image, &op[1], 0, 0, 0, alpha)) - return 0; - - op->u.transform.top_y = image->pixels->y; - op->u.transform.left_x = image->pixels->x; - - op->u.transform.start_x = x - op->u.transform.left_x; - op->u.transform.x = op->u.transform.start_x; - op->u.transform.y = y - op->u.transform.top_y; - op->u.transform.transform = image->transform; - op->u.transform.filter = image->filter; - - op->fetch = IcFetch_transform; - op->fetcha = IcFetcha_transform; - op->store = 0; - op->over = IcStepOver_transform; - op->down = IcStepDown_transform; - op->set = IcSet_transform; - - op->clip = op[1].clip; - - return 1; - } - /* Check for external alpha */ - else if (alpha && image->alphaMap) - { - if (!IcBuildCompositeOperand (image, &op[1], x, y, 0, 0)) - return 0; - if (!IcBuildCompositeOperand (image->alphaMap, &op[2], - x - image->alphaOrigin.x, - y - image->alphaOrigin.y, - 0, 0)) - return 0; - op->u.external.alpha_dx = image->alphaOrigin.x; - op->u.external.alpha_dy = image->alphaOrigin.y; - - op->fetch = IcFetch_external; - op->fetcha = IcFetcha_external; - op->store = IcStore_external; - op->over = IcStepOver_external; - op->down = IcStepDown_external; - op->set = IcSet_external; - - op->clip = op[1].clip; - - return 1; - } - /* Build simple operand */ - else - { - int i; - int xoff, yoff; - - for (i = 0; i < NumAccessMap; i++) - if (icAccessMap[i].format_code == image->format_code) - { - IcBits *bits; - IcStride stride; - int bpp; - - op->fetch = icAccessMap[i].fetch; - op->fetcha = icAccessMap[i].fetcha; - op->store = icAccessMap[i].store; - op->over = IcStepOver; - op->down = IcStepDown; - op->set = IcSet; - - op->clip = image->pCompositeClip; - - IcGetPixels (image->pixels, bits, stride, bpp, - xoff, yoff); - if (image->repeat && image->pixels->width == 1 && - image->pixels->height == 1) - { - bpp = 0; - stride = 0; - } - /* - * Coordinates of upper left corner of drawable - */ - op->u.drawable.top_line = bits + yoff * stride; - op->u.drawable.left_offset = xoff * bpp; - - /* - * Starting position within drawable - */ - op->u.drawable.start_offset = op->u.drawable.left_offset + x * bpp; - op->u.drawable.line = op->u.drawable.top_line + y * stride; - op->u.drawable.offset = op->u.drawable.start_offset; - - op->u.drawable.stride = stride; - op->u.drawable.bpp = bpp; - return 1; - } - return 0; - } -} - -void -IcCompositeGeneral (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - IcCompositeOperand src[4],msk[4],dst[4],*pmsk; - IcCompositeOperand *srcPict, *srcAlpha; - IcCompositeOperand *dstPict, *dstAlpha; - IcCompositeOperand *mskPict = 0, *mskAlpha = 0; - IcCombineFunc f; - int w; - - if (!IcBuildCompositeOperand (iSrc, src, xSrc, ySrc, 1, 1)) - return; - if (!IcBuildCompositeOperand (iDst, dst, xDst, yDst, 0, 1)) - return; - if (iSrc->alphaMap) - { - srcPict = &src[1]; - srcAlpha = &src[2]; - } - else - { - srcPict = &src[0]; - srcAlpha = 0; - } - if (iDst->alphaMap) - { - dstPict = &dst[1]; - dstAlpha = &dst[2]; - } - else - { - dstPict = &dst[0]; - dstAlpha = 0; - } - f = IcCombineFuncU[op]; - if (iMask) - { - if (!IcBuildCompositeOperand (iMask, msk, xMask, yMask, 1, 1)) - return; - pmsk = msk; - if (iMask->componentAlpha) - f = IcCombineFuncC[op]; - if (iMask->alphaMap) - { - mskPict = &msk[1]; - mskAlpha = &msk[2]; - } - else - { - mskPict = &msk[0]; - mskAlpha = 0; - } - } - else - pmsk = 0; - while (height--) - { - w = width; - - while (w--) - { - (*f) (src, pmsk, dst); - (*src->over) (src); - (*dst->over) (dst); - if (pmsk) - (*pmsk->over) (pmsk); - } - (*src->down) (src); - (*dst->down) (dst); - if (pmsk) - (*pmsk->down) (pmsk); - } -} - diff --git a/pixman/src/icformat.c b/pixman/src/icformat.c deleted file mode 100644 index 12c451cee..000000000 --- a/pixman/src/icformat.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#include "icint.h" - -#define Mask(n) ((n) == 32 ? 0xffffffff : ((1 << (n))-1)) - -IcFormat * -IcFormatCreate (IcFormatName name) -{ - switch (name) { - case IcFormatNameARGB32: - return IcFormatCreateMasks (32, - 0xff000000, - 0x00ff0000, - 0x0000ff00, - 0x000000ff); - case IcFormatNameRGB24: - return IcFormatCreateMasks (32, - 0x0, - 0xff0000, - 0x00ff00, - 0x0000ff); - case IcFormatNameA8: - return IcFormatCreateMasks (8, 0xff, - 0, 0, 0); - case IcFormatNameA1: - return IcFormatCreateMasks (1, 0x1, - 0, 0, 0); - } - - return NULL; -} - -/* XXX: There's some nonsense going on here. The macros above help - IcFormatCreateMasks to encode a format into an int, while - immediately afterwards IcFormatInit goes through the effort of - decoding it. This should all be disentagled, (it's probably - possible to just eliminate the encoding macros altogether). */ -IcFormat * -IcFormatCreateMasks (int bpp, - int alpha_mask, - int red_mask, - int green_mask, - int blue_mask) -{ - int type; - int format_code; - IcFormat *format; - - if (red_mask == 0 && green_mask == 0 && blue_mask == 0) - type = PICT_TYPE_A; - else if (red_mask > blue_mask) - type = PICT_TYPE_ARGB; - else - type = PICT_TYPE_ABGR; - - format_code = PICT_FORMAT (bpp, type, - _IcOnes (alpha_mask), - _IcOnes (red_mask), - _IcOnes (green_mask), - _IcOnes (blue_mask)); - - format = malloc (sizeof (IcFormat)); - if (format == NULL) - return NULL; - - IcFormatInit (format, format_code); - - return format; -} - -void -IcFormatInit (IcFormat *format, int format_code) -{ -/* XXX: What do we want to lodge in here? - format->id = FakeClientID (0); -*/ - format->format_code = format_code; - format->depth = PICT_FORMAT_BPP(format_code); - - switch (PICT_FORMAT_TYPE(format_code)) { - case PICT_TYPE_ARGB: - - format->alphaMask = Mask(PICT_FORMAT_A(format_code)); - if (format->alphaMask) - format->alpha = (PICT_FORMAT_R(format_code) + - PICT_FORMAT_G(format_code) + - PICT_FORMAT_B(format_code)); - - format->redMask = Mask(PICT_FORMAT_R(format_code)); - format->red = (PICT_FORMAT_G(format_code) + - PICT_FORMAT_B(format_code)); - - format->greenMask = Mask(PICT_FORMAT_G(format_code)); - format->green = PICT_FORMAT_B(format_code); - - format->blueMask = Mask(PICT_FORMAT_B(format_code)); - format->blue = 0; - break; - - case PICT_TYPE_ABGR: - - format->alphaMask = Mask(PICT_FORMAT_A(format_code)); - if (format->alphaMask) - format->alpha = (PICT_FORMAT_B(format_code) + - PICT_FORMAT_G(format_code) + - PICT_FORMAT_R(format_code)); - - format->blueMask = Mask(PICT_FORMAT_B(format_code)); - format->blue = (PICT_FORMAT_G(format_code) + - PICT_FORMAT_R(format_code)); - - format->greenMask = Mask(PICT_FORMAT_G(format_code)); - format->green = PICT_FORMAT_R(format_code); - - format->redMask = Mask(PICT_FORMAT_R(format_code)); - format->red = 0; - break; - - case PICT_TYPE_A: - - format->alpha = 0; - format->alphaMask = Mask(PICT_FORMAT_A(format_code)); - - /* remaining fields already set to zero */ - break; - } -} -slim_hidden_def(IcFormatInit); - -void -IcFormatDestroy (IcFormat *format) -{ - free (format); -} diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c deleted file mode 100644 index 2dfa99435..000000000 --- a/pixman/src/icimage.c +++ /dev/null @@ -1,616 +0,0 @@ -/* - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#include "icint.h" - -IcImage * -IcImageCreate (IcFormat *format, - int width, - int height) -{ - IcImage *image; - IcPixels *pixels; - - pixels = IcPixelsCreate (width, height, format->depth); - if (pixels == NULL) - return NULL; - - image = IcImageCreateForPixels (pixels, format); - if (image == NULL) { - IcPixelsDestroy (pixels); - return NULL; - } - - image->owns_pixels = 1; - - return image; -} -slim_hidden_def(IcImageCreate); - -IcImage * -IcImageCreateForData (IcBits *data, IcFormat *format, int width, int height, int bpp, int stride) -{ - IcImage *image; - IcPixels *pixels; - - pixels = IcPixelsCreateForData (data, width, height, format->depth, bpp, stride); - if (pixels == NULL) - return NULL; - - image = IcImageCreateForPixels (pixels, format); - if (image == NULL) { - IcPixelsDestroy (pixels); - return NULL; - } - - image->owns_pixels = 1; - - return image; -} - -IcImage * -IcImageCreateForPixels (IcPixels *pixels, - IcFormat *format) -{ - IcImage *image; - - image = malloc (sizeof (IcImage)); - if (!image) - { - return NULL; - } - - image->pixels = pixels; - image->image_format = *format; - image->format_code = format->format_code; -/* XXX: What's all this about? - if (pDrawable->type == DRAWABLE_PIXMAP) - { - ++((PixmapPtr)pDrawable)->refcnt; - image->pNext = 0; - } - else - { - image->pNext = GetPictureWindow(((WindowPtr) pDrawable)); - SetPictureWindow(((WindowPtr) pDrawable), image); - } -*/ - - IcImageInit (image); - - return image; -} - -void -IcImageInit (IcImage *image) -{ - image->refcnt = 1; - image->repeat = 0; - image->graphicsExposures = 0; - image->subWindowMode = ClipByChildren; - image->polyEdge = PolyEdgeSharp; - image->polyMode = PolyModePrecise; - /* XXX: In the server this was 0. Why? */ - image->freeCompClip = 1; - image->clientClipType = CT_NONE; - image->componentAlpha = 0; - - image->alphaMap = 0; - image->alphaOrigin.x = 0; - image->alphaOrigin.y = 0; - - image->clipOrigin.x = 0; - image->clipOrigin.y = 0; - image->clientClip = 0; - - image->dither = 0L; - - image->stateChanges = (1 << (CPLastBit+1)) - 1; -/* XXX: What to lodge here? - image->serialNumber = GC_CHANGE_SERIAL_BIT; -*/ - - image->pCompositeClip = PixRegionCreate(); - PixRegionUnionRect (image->pCompositeClip, image->pCompositeClip, - 0, 0, image->pixels->width, image->pixels->height); - - image->transform = NULL; - - image->filter = IcFilterNearest; - image->filter_params = 0; - image->filter_nparams = 0; - - - image->owns_pixels = 0; -} - -int -IcImageSetTransform (IcImage *image, - IcTransform *transform) -{ - static const IcTransform identity = { { - { xFixed1, 0x00000, 0x00000 }, - { 0x00000, xFixed1, 0x00000 }, - { 0x00000, 0x00000, xFixed1 }, - } }; - - if (transform && memcmp (transform, &identity, sizeof (IcTransform)) == 0) - transform = 0; - - if (transform) - { - if (!image->transform) - { - image->transform = malloc (sizeof (IcTransform)); - if (!image->transform) - return 1; - } - *image->transform = *transform; - } - else - { - if (image->transform) - { - free (image->transform); - image->transform = 0; - } - } - return 0; -} - -void -IcImageSetRepeat (IcImage *image, - int repeat) -{ - if (image) - image->repeat = repeat; -} -slim_hidden_def(IcImageSetRepeat); - -void -IcImageSetFilter (IcImage *image, - IcFilter filter) -{ - if (image) - image->filter = filter; -} - -int -IcImageGetWidth (IcImage *image) -{ - return image->pixels->width; -} - -int -IcImageGetHeight (IcImage *image) -{ - return image->pixels->height; -} - -int -IcImageGetDepth (IcImage *image) -{ - return image->pixels->depth; -} - -int -IcImageGetStride (IcImage *image) -{ - return image->pixels->stride; -} - -IcBits * -IcImageGetData (IcImage *image) -{ - return image->pixels->data; -} - -void -IcImageDestroy (IcImage *image) -{ - if (image->freeCompClip) - PixRegionDestroy (image->pCompositeClip); - - if (image->owns_pixels) - IcPixelsDestroy (image->pixels); - - if (image->transform) - free (image->transform); - - free (image); -} -slim_hidden_def(IcImageDestroy); - -void -IcImageDestroyClip (IcImage *image) -{ - switch (image->clientClipType) { - case CT_NONE: - return; - case CT_PIXMAP: - IcImageDestroy (image->clientClip); - break; - default: - PixRegionDestroy (image->clientClip); - break; - } - image->clientClip = NULL; - image->clientClipType = CT_NONE; -} - -int -IcImageSetClipRegion (IcImage *image, - PixRegion *region) -{ - IcImageDestroyClip (image); - image->clientClip = region; - image->clientClipType = CT_REGION; - image->stateChanges |= CPClipMask; - return 0; -} - -#define BOUND(v) (int16_t) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v)) - -static __inline int -IcClipImageReg (PixRegion *region, - PixRegion *clip, - int dx, - int dy) -{ - if (PixRegionNumRects (region) == 1 && - PixRegionNumRects (clip) == 1) - { - PixRegionBox *pRbox = PixRegionRects (region); - PixRegionBox *pCbox = PixRegionRects (clip); - int v; - - if (pRbox->x1 < (v = pCbox->x1 + dx)) - pRbox->x1 = BOUND(v); - if (pRbox->x2 > (v = pCbox->x2 + dx)) - pRbox->x2 = BOUND(v); - if (pRbox->y1 < (v = pCbox->y1 + dy)) - pRbox->y1 = BOUND(v); - if (pRbox->y2 > (v = pCbox->y2 + dy)) - pRbox->y2 = BOUND(v); - if (pRbox->x1 >= pRbox->x2 || - pRbox->y1 >= pRbox->y2) - { - PixRegionEmpty (region); - } - } - else - { - PixRegionTranslate (region, dx, dy); - PixRegionIntersect (region, clip, region); - PixRegionTranslate (region, -dx, -dy); - } - return 1; -} - -static __inline int -IcClipImageSrc (PixRegion *region, - IcImage *image, - int dx, - int dy) -{ - /* XXX what to do with clipping from transformed pictures? */ - if (image->transform) - return 1; - if (image->repeat) - { - if (image->clientClipType != CT_NONE) - { - PixRegionTranslate (region, - dx - image->clipOrigin.x, - dy - image->clipOrigin.y); - PixRegionIntersect (region, image->clientClip, region); - PixRegionTranslate (region, - - (dx - image->clipOrigin.x), - - (dy - image->clipOrigin.y)); - } - return 1; - } - else - { - return IcClipImageReg (region, - image->pCompositeClip, - dx, - dy); - } - return 1; -} - -/* XXX: Need to decide what to do with this -#define NEXT_VAL(_type) (vlist ? (_type) *vlist++ : (_type) ulist++->val) - -#define NEXT_PTR(_type) ((_type) ulist++->ptr) - -int -IcImageChange (IcImage *image, - Mask vmask, - unsigned int *vlist, - DevUnion *ulist, - int *error_value) -{ - BITS32 index2; - int error = 0; - BITS32 maskQ; - - maskQ = vmask; - while (vmask && !error) - { - index2 = (BITS32) lowbit (vmask); - vmask &= ~index2; - image->stateChanges |= index2; - switch (index2) - { - case CPRepeat: - { - unsigned int newr; - newr = NEXT_VAL(unsigned int); - if (newr <= xTrue) - image->repeat = newr; - else - { - *error_value = newr; - error = BadValue; - } - } - break; - case CPAlphaMap: - { - IcImage *iAlpha; - - iAlpha = NEXT_PTR(IcImage *); - if (iAlpha) - iAlpha->refcnt++; - if (image->alphaMap) - IcImageDestroy ((void *) image->alphaMap); - image->alphaMap = iAlpha; - } - break; - case CPAlphaXOrigin: - image->alphaOrigin.x = NEXT_VAL(int16_t); - break; - case CPAlphaYOrigin: - image->alphaOrigin.y = NEXT_VAL(int16_t); - break; - case CPClipXOrigin: - image->clipOrigin.x = NEXT_VAL(int16_t); - break; - case CPClipYOrigin: - image->clipOrigin.y = NEXT_VAL(int16_t); - break; - case CPClipMask: - { - IcImage *mask; - int clipType; - - mask = NEXT_PTR(IcImage *); - if (mask) { - clipType = CT_PIXMAP; - mask->refcnt++; - } else { - clipType = CT_NONE; - } - error = IcImageChangeClip (image, clipType, - (void *)mask, 0); - break; - } - case CPGraphicsExposure: - { - unsigned int newe; - newe = NEXT_VAL(unsigned int); - if (newe <= xTrue) - image->graphicsExposures = newe; - else - { - *error_value = newe; - error = BadValue; - } - } - break; - case CPSubwindowMode: - { - unsigned int news; - news = NEXT_VAL(unsigned int); - if (news == ClipByChildren || news == IncludeInferiors) - image->subWindowMode = news; - else - { - *error_value = news; - error = BadValue; - } - } - break; - case CPPolyEdge: - { - unsigned int newe; - newe = NEXT_VAL(unsigned int); - if (newe == PolyEdgeSharp || newe == PolyEdgeSmooth) - image->polyEdge = newe; - else - { - *error_value = newe; - error = BadValue; - } - } - break; - case CPPolyMode: - { - unsigned int newm; - newm = NEXT_VAL(unsigned int); - if (newm == PolyModePrecise || newm == PolyModeImprecise) - image->polyMode = newm; - else - { - *error_value = newm; - error = BadValue; - } - } - break; - case CPDither: - image->dither = NEXT_VAL(unsigned long); - break; - case CPComponentAlpha: - { - unsigned int newca; - - newca = NEXT_VAL (unsigned int); - if (newca <= xTrue) - image->componentAlpha = newca; - else - { - *error_value = newca; - error = BadValue; - } - } - break; - default: - *error_value = maskQ; - error = BadValue; - break; - } - } - return error; -} -*/ - -/* XXX: Do we need this? -int -SetPictureClipRects (PicturePtr pPicture, - int xOrigin, - int yOrigin, - int nRect, - xRectangle *rects) -{ - ScreenPtr pScreen = pPicture->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - PixRegion *clientClip; - int result; - - clientClip = RECTS_TO_REGION(pScreen, - nRect, rects, CT_UNSORTED); - if (!clientClip) - return 1; - result =(*ps->ChangePictureClip) (pPicture, CT_REGION, - (void *) clientClip, 0); - if (result == 0) - { - pPicture->clipOrigin.x = xOrigin; - pPicture->clipOrigin.y = yOrigin; - pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask; - pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; - } - return result; -} -*/ - -int -IcComputeCompositeRegion (PixRegion *region, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) -{ - int v; - int x1, y1, x2, y2; - - /* XXX: This code previously directly set the extents of the - region here. I need to decide whether removing that has broken - this. Also, it might be necessary to just make the PixRegion - data structure transparent anyway in which case I can just put - the code back. */ - x1 = xDst; - v = xDst + width; - x2 = BOUND(v); - y1 = yDst; - v = yDst + height; - y2 = BOUND(v); - /* Check for empty operation */ - if (x1 >= x2 || - y1 >= y2) - { - PixRegionEmpty (region); - return 1; - } - /* clip against src */ - if (!IcClipImageSrc (region, iSrc, xDst - xSrc, yDst - ySrc)) - { - PixRegionDestroy (region); - return 0; - } - if (iSrc->alphaMap) - { - if (!IcClipImageSrc (region, iSrc->alphaMap, - xDst - (xSrc + iSrc->alphaOrigin.x), - yDst - (ySrc + iSrc->alphaOrigin.y))) - { - PixRegionDestroy (region); - return 0; - } - } - /* clip against mask */ - if (iMask) - { - if (!IcClipImageSrc (region, iMask, xDst - xMask, yDst - yMask)) - { - PixRegionDestroy (region); - return 0; - } - if (iMask->alphaMap) - { - if (!IcClipImageSrc (region, iMask->alphaMap, - xDst - (xMask + iMask->alphaOrigin.x), - yDst - (yMask + iMask->alphaOrigin.y))) - { - PixRegionDestroy (region); - return 0; - } - } - } - if (!IcClipImageReg (region, iDst->pCompositeClip, 0, 0)) - { - PixRegionDestroy (region); - return 0; - } - if (iDst->alphaMap) - { - if (!IcClipImageReg (region, iDst->alphaMap->pCompositeClip, - -iDst->alphaOrigin.x, - -iDst->alphaOrigin.y)) - { - PixRegionDestroy (region); - return 0; - } - } - return 1; -} - diff --git a/pixman/src/icimage.h b/pixman/src/icimage.h deleted file mode 100644 index f1d5ca13e..000000000 --- a/pixman/src/icimage.h +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright © 2000 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* XXX: This whole file should be moved up into incint.h (and cleaned - up considerably as well) */ - -#ifndef _ICIMAGE_H_ -#define _ICIMAGE_H_ - -/* #include "glyphstr.h" */ -/* #include "scrnintstr.h" */ - -/* XXX: Hmmm... what's needed from here? -#include "resource.h" -*/ - - -#define IcIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) ) -#define IcIntDiv(a,b) (((uint16_t) (a) * 255) / (b)) - -#define IcGet8(v,i) ((uint16_t) (uint8_t) ((v) >> i)) - -/* - * There are two ways of handling alpha -- either as a single unified value or - * a separate value for each component, hence each macro must have two - * versions. The unified alpha version has a 'U' at the end of the name, - * the component version has a 'C'. Similarly, functions which deal with - * this difference will have two versions using the same convention. - */ - -#define IcOverU(x,y,i,a,t) ((t) = IcIntMult(IcGet8(y,i),(a),(t)) + IcGet8(x,i),\ - (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i)) - -#define IcOverC(x,y,i,a,t) ((t) = IcIntMult(IcGet8(y,i),IcGet8(a,i),(t)) + IcGet8(x,i),\ - (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i)) - -#define IcInU(x,i,a,t) ((uint32_t) IcIntMult(IcGet8(x,i),(a),(t)) << (i)) - -#define IcInC(x,i,a,t) ((uint32_t) IcIntMult(IcGet8(x,i),IcGet8(a,i),(t)) << (i)) - -#define IcGen(x,y,i,ax,ay,t,u,v) ((t) = (IcIntMult(IcGet8(y,i),ay,(u)) + \ - IcIntMult(IcGet8(x,i),ax,(v))),\ - (uint32_t) ((uint8_t) ((t) | \ - (0 - ((t) >> 8)))) << (i)) - -#define IcAdd(x,y,i,t) ((t) = IcGet8(x,i) + IcGet8(y,i), \ - (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i)) - -/* -typedef struct _IndexFormat { - VisualPtr pVisual; - ColormapPtr pColormap; - int nvalues; - xIndexValue *pValues; - void *devPrivate; -} IndexFormatRec; -*/ - -/* -typedef struct _IcFormat { - uint32_t id; - uint32_t format; - unsigned char type; - unsigned char depth; - DirectFormatRec direct; - IndexFormatRec index; -} IcFormatRec; -*/ - -struct _IcImage { - IcPixels *pixels; - IcFormat image_format; - int format_code; - int refcnt; - - unsigned int repeat : 1; - unsigned int graphicsExposures : 1; - unsigned int subWindowMode : 1; - unsigned int polyEdge : 1; - unsigned int polyMode : 1; - /* XXX: Do we need this field */ - unsigned int freeCompClip : 1; - unsigned int clientClipType : 2; - unsigned int componentAlpha : 1; - unsigned int unused : 23; - - struct _IcImage *alphaMap; - IcPoint alphaOrigin; - - IcPoint clipOrigin; - void *clientClip; - - unsigned long dither; - - unsigned long stateChanges; - unsigned long serialNumber; - - PixRegion *pCompositeClip; - - IcTransform *transform; - - IcFilter filter; - IcFixed16_16 *filter_params; - int filter_nparams; - - int owns_pixels; -}; - -#endif /* _ICIMAGE_H_ */ - -#ifndef _IC_MIPICT_H_ -#define _IC_MIPICT_H_ - -#define IC_MAX_INDEXED 256 /* XXX depth must be <= 8 */ - -#if IC_MAX_INDEXED <= 256 -typedef uint8_t IcIndexType; -#endif - -/* XXX: We're not supporting indexed operations, right? -typedef struct _IcIndexed { - int color; - uint32_t rgba[IC_MAX_INDEXED]; - IcIndexType ent[32768]; -} IcIndexedRec, *IcIndexedPtr; -*/ - -#define IcCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \ - (((s) >> 6) & 0x03e0) | \ - (((s) >> 9) & 0x7c00)) -#define IcIndexToEnt15(icf,rgb15) ((icf)->ent[rgb15]) -#define IcIndexToEnt24(icf,rgb24) IcIndexToEnt15(icf,IcCvtR8G8B8to15(rgb24)) - -#define IcIndexToEntY24(icf,rgb24) ((icf)->ent[CvtR8G8B8toY15(rgb24)]) - -/* -extern int __internal_linkage -IcCreatePicture (PicturePtr pPicture); -*/ - -extern void __internal_linkage -IcImageInit (IcImage *image); - -extern void __internal_linkage -IcImageDestroyClip (IcImage *image); - -/* -extern void __internal_linkage -IcValidatePicture (PicturePtr pPicture, - Mask mask); -*/ - - -/* XXX: What should this be? -extern int __internal_linkage -IcClipPicture (PixRegion *region, - IcImage *image, - int16_t xReg, - int16_t yReg, - int16_t xPict, - int16_t yPict); -*/ - -extern int __internal_linkage -IcComputeCompositeRegion (PixRegion *region, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height); - -/* -extern int __internal_linkage -IcPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats); -*/ - -/* -extern void __internal_linkage -IcGlyphs (IcOperator op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - int16_t xSrc, - int16_t ySrc, - int nlist, - GlyphListPtr list, - GlyphPtr *glyphs); -*/ - -/* -extern void __internal_linkage -IcCompositeRects (IcOperator op, - PicturePtr pDst, - xRenderColor *color, - int nRect, - xRectangle *rects); -*/ - -extern IcImage * __internal_linkage -IcCreateAlphaPicture (IcImage *dst, - IcFormat *format, - uint16_t width, - uint16_t height); - -typedef void (*CompositeFunc) (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height); - -typedef struct _IcCompositeOperand IcCompositeOperand; - -typedef uint32_t (*IcCompositeFetch)(IcCompositeOperand *op); -typedef void (*IcCompositeStore) (IcCompositeOperand *op, uint32_t value); - -typedef void (*IcCompositeStep) (IcCompositeOperand *op); -typedef void (*IcCompositeSet) (IcCompositeOperand *op, int x, int y); - -struct _IcCompositeOperand { - union { - struct { - IcBits *top_line; - int left_offset; - - int start_offset; - IcBits *line; - uint32_t offset; - IcStride stride; - int bpp; - } drawable; - struct { - int alpha_dx; - int alpha_dy; - } external; - struct { - int top_y; - int left_x; - int start_x; - int x; - int y; - IcTransform *transform; - IcFilter filter; - } transform; - } u; - IcCompositeFetch fetch; - IcCompositeFetch fetcha; - IcCompositeStore store; - IcCompositeStep over; - IcCompositeStep down; - IcCompositeSet set; -/* XXX: We're not supporting indexed operations, right? - IcIndexedPtr indexed; -*/ - PixRegion *clip; -}; - -typedef void (*IcCombineFunc) (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst); - -typedef struct _IcAccessMap { - uint32_t format_code; - IcCompositeFetch fetch; - IcCompositeFetch fetcha; - IcCompositeStore store; -} IcAccessMap; - -/* iccompose.c */ - -typedef struct _IcCompSrc { - uint32_t value; - uint32_t alpha; -} IcCompSrc; - -extern int __internal_linkage -IcBuildCompositeOperand (IcImage *image, - IcCompositeOperand op[4], - int16_t x, - int16_t y, - int transform, - int alpha); - -extern void __internal_linkage -IcCompositeGeneral (IcOperator op, - IcImage *iSrc, - IcImage *iMask, - IcImage *iDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height); - -#endif /* _IC_MIPICT_H_ */ diff --git a/pixman/src/icint.h b/pixman/src/icint.h deleted file mode 100644 index 54b6b1256..000000000 --- a/pixman/src/icint.h +++ /dev/null @@ -1,1020 +0,0 @@ -/* - * Copyright © 2003 Carl Worth - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Carl Worth not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Carl Worth makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * CARL WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL CARL WORTH BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef ICINT_H_INCLUDED -#define ICINT_H_INCLUDED - -#include "ic.h" - -#include <stdlib.h> -#include <string.h> -#include <limits.h> - - - -#include <slim_internal.h> - - - - - -typedef struct _IcPoint { - int16_t x,y ; -} IcPoint; - -typedef unsigned int Mask; - - -#define GXor 0x7 -#define ClipByChildren 0 -#define PolyEdgeSharp 0 -#define PolyModePrecise 0 -#define CPClipMask (1 << 6) -#define CPLastBit 11 - - - - -/* These few definitions avoid me needing to include servermd.h and misc.h from Xserver/include */ -#ifndef BITMAP_SCANLINE_PAD -#define BITMAP_SCANLINE_PAD 32 -#define LOG2_BITMAP_PAD 5 -#define LOG2_BYTES_PER_SCANLINE_PAD 2 -#endif - - - - -#define MAXSHORT SHRT_MAX -#define MINSHORT SHRT_MIN - -/* XXX: What do we need from here? -#include "picture.h" -*/ - - - -#include "ic.h" - -/* XXX: Most of this file is straight from fb.h and I imagine we can - drop quite a bit of it. Once the real ic code starts to come - together I can probably figure out what is not needed here. */ - -#define IC_UNIT (1 << IC_SHIFT) -#define IC_HALFUNIT (1 << (IC_SHIFT-1)) -#define IC_MASK (IC_UNIT - 1) -#define IC_ALLONES ((IcBits) -1) - -/* whether to bother to include 24bpp support */ -#ifndef ICNO24BIT -#define IC_24BIT -#endif - -/* - * Unless otherwise instructed, ic includes code to advertise 24bpp - * windows with 32bpp image format for application compatibility - */ - -#ifdef IC_24BIT -#ifndef ICNO24_32 -#define IC_24_32BIT -#endif -#endif - -#define IC_STIP_SHIFT LOG2_BITMAP_PAD -#define IC_STIP_UNIT (1 << IC_STIP_SHIFT) -#define IC_STIP_MASK (IC_STIP_UNIT - 1) -#define IC_STIP_ALLONES ((IcStip) -1) - -#define IC_STIP_ODDSTRIDE(s) (((s) & (IC_MASK >> IC_STIP_SHIFT)) != 0) -#define IC_STIP_ODDPTR(p) ((((long) (p)) & (IC_MASK >> 3)) != 0) - -#define IcStipStrideToBitsStride(s) (((s) >> (IC_SHIFT - IC_STIP_SHIFT))) -#define IcBitsStrideToStipStride(s) (((s) << (IC_SHIFT - IC_STIP_SHIFT))) - -#define IcFullMask(n) ((n) == IC_UNIT ? IC_ALLONES : ((((IcBits) 1) << n) - 1)) - - -typedef uint32_t IcStip; -typedef int IcStride; - - -#ifdef IC_DEBUG -extern void IcValidateDrawable(DrawablePtr d); -extern void IcInitializeDrawable(DrawablePtr d); -extern void IcSetBits (IcStip *bits, int stride, IcStip data); -#define IC_HEAD_BITS (IcStip) (0xbaadf00d) -#define IC_TAIL_BITS (IcStip) (0xbaddf0ad) -#else -#define IcValidateDrawable(d) -#define fdInitializeDrawable(d) -#endif - -#if BITMAP_BIT_ORDER == LSBFirst -#define IcScrLeft(x,n) ((x) >> (n)) -#define IcScrRight(x,n) ((x) << (n)) -/* #define IcLeftBits(x,n) ((x) & ((((IcBits) 1) << (n)) - 1)) */ -#define IcLeftStipBits(x,n) ((x) & ((((IcStip) 1) << (n)) - 1)) -#define IcStipMoveLsb(x,s,n) (IcStipRight (x,(s)-(n))) -#define IcPatternOffsetBits 0 -#else -#define IcScrLeft(x,n) ((x) << (n)) -#define IcScrRight(x,n) ((x) >> (n)) -/* #define IcLeftBits(x,n) ((x) >> (IC_UNIT - (n))) */ -#define IcLeftStipBits(x,n) ((x) >> (IC_STIP_UNIT - (n))) -#define IcStipMoveLsb(x,s,n) (x) -#define IcPatternOffsetBits (sizeof (IcBits) - 1) -#endif - -#define IcStipLeft(x,n) IcScrLeft(x,n) -#define IcStipRight(x,n) IcScrRight(x,n) - -#define IcRotLeft(x,n) IcScrLeft(x,n) | (n ? IcScrRight(x,IC_UNIT-n) : 0) -#define IcRotRight(x,n) IcScrRight(x,n) | (n ? IcScrLeft(x,IC_UNIT-n) : 0) - -#define IcRotStipLeft(x,n) IcStipLeft(x,n) | (n ? IcStipRight(x,IC_STIP_UNIT-n) : 0) -#define IcRotStipRight(x,n) IcStipRight(x,n) | (n ? IcStipLeft(x,IC_STIP_UNIT-n) : 0) - -#define IcLeftMask(x) ( ((x) & IC_MASK) ? \ - IcScrRight(IC_ALLONES,(x) & IC_MASK) : 0) -#define IcRightMask(x) ( ((IC_UNIT - (x)) & IC_MASK) ? \ - IcScrLeft(IC_ALLONES,(IC_UNIT - (x)) & IC_MASK) : 0) - -#define IcLeftStipMask(x) ( ((x) & IC_STIP_MASK) ? \ - IcStipRight(IC_STIP_ALLONES,(x) & IC_STIP_MASK) : 0) -#define IcRightStipMask(x) ( ((IC_STIP_UNIT - (x)) & IC_STIP_MASK) ? \ - IcScrLeft(IC_STIP_ALLONES,(IC_STIP_UNIT - (x)) & IC_STIP_MASK) : 0) - -#define IcBitsMask(x,w) (IcScrRight(IC_ALLONES,(x) & IC_MASK) & \ - IcScrLeft(IC_ALLONES,(IC_UNIT - ((x) + (w))) & IC_MASK)) - -#define IcStipMask(x,w) (IcStipRight(IC_STIP_ALLONES,(x) & IC_STIP_MASK) & \ - IcStipLeft(IC_STIP_ALLONES,(IC_STIP_UNIT - ((x)+(w))) & IC_STIP_MASK)) - - -#define IcMaskBits(x,w,l,n,r) { \ - n = (w); \ - r = IcRightMask((x)+n); \ - l = IcLeftMask(x); \ - if (l) { \ - n -= IC_UNIT - ((x) & IC_MASK); \ - if (n < 0) { \ - n = 0; \ - l &= r; \ - r = 0; \ - } \ - } \ - n >>= IC_SHIFT; \ -} - -#ifdef ICNOPIXADDR -#define IcMaskBitsBytes(x,w,copy,l,lb,n,r,rb) IcMaskBits(x,w,l,n,r) -#define IcDoLeftMaskByteRRop(dst,lb,l,and,xor) { \ - *dst = IcDoMaskRRop(*dst,and,xor,l); \ -} -#define IcDoRightMaskByteRRop(dst,rb,r,and,xor) { \ - *dst = IcDoMaskRRop(*dst,and,xor,r); \ -} -#else - -#define IcByteMaskInvalid 0x10 - -#define IcPatternOffset(o,t) ((o) ^ (IcPatternOffsetBits & ~(sizeof (t) - 1))) - -#define IcPtrOffset(p,o,t) ((t *) ((uint8_t *) (p) + (o))) -#define IcSelectPatternPart(xor,o,t) ((xor) >> (IcPatternOffset (o,t) << 3)) -#define IcStorePart(dst,off,t,xor) (*IcPtrOffset(dst,off,t) = \ - IcSelectPart(xor,off,t)) -#ifndef IcSelectPart -#define IcSelectPart(x,o,t) IcSelectPatternPart(x,o,t) -#endif - -#define IcMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \ - n = (w); \ - lb = 0; \ - rb = 0; \ - r = IcRightMask((x)+n); \ - if (r) { \ - /* compute right byte length */ \ - if ((copy) && (((x) + n) & 7) == 0) { \ - rb = (((x) + n) & IC_MASK) >> 3; \ - } else { \ - rb = IcByteMaskInvalid; \ - } \ - } \ - l = IcLeftMask(x); \ - if (l) { \ - /* compute left byte length */ \ - if ((copy) && ((x) & 7) == 0) { \ - lb = ((x) & IC_MASK) >> 3; \ - } else { \ - lb = IcByteMaskInvalid; \ - } \ - /* subtract out the portion painted by leftMask */ \ - n -= IC_UNIT - ((x) & IC_MASK); \ - if (n < 0) { \ - if (lb != IcByteMaskInvalid) { \ - if (rb == IcByteMaskInvalid) { \ - lb = IcByteMaskInvalid; \ - } else if (rb) { \ - lb |= (rb - lb) << (IC_SHIFT - 3); \ - rb = 0; \ - } \ - } \ - n = 0; \ - l &= r; \ - r = 0; \ - }\ - } \ - n >>= IC_SHIFT; \ -} - -#if IC_SHIFT == 6 -#define IcDoLeftMaskByteRRop6Cases(dst,xor) \ - case (sizeof (IcBits) - 7) | (1 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 7,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 7) | (2 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 7,uint8_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 6,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 7) | (3 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 7,uint8_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 6,uint16_t,xor); \ - break; \ - case (sizeof (IcBits) - 7) | (4 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 7,uint8_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 6,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 7) | (5 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 7,uint8_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 6,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint16_t,xor); \ - break; \ - case (sizeof (IcBits) - 7) | (6 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 7,uint8_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 6,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 2,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 7): \ - IcStorePart(dst,sizeof (IcBits) - 7,uint8_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 6,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint32_t,xor); \ - break; \ - case (sizeof (IcBits) - 6) | (1 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 6,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 6) | (2 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 6,uint16_t,xor); \ - break; \ - case (sizeof (IcBits) - 6) | (3 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 6,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 6) | (4 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 6,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint16_t,xor); \ - break; \ - case (sizeof (IcBits) - 6) | (5 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 6,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 2,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 6): \ - IcStorePart(dst,sizeof (IcBits) - 6,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint32_t,xor); \ - break; \ - case (sizeof (IcBits) - 5) | (1 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 5,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 5) | (2 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 5,uint8_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 5) | (3 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 5,uint8_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint16_t,xor); \ - break; \ - case (sizeof (IcBits) - 5) | (4 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 5,uint8_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 2,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 5): \ - IcStorePart(dst,sizeof (IcBits) - 5,uint8_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 4,uint32_t,xor); \ - break; \ - case (sizeof (IcBits) - 4) | (1 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 4,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 4) | (2 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 4,uint16_t,xor); \ - break; \ - case (sizeof (IcBits) - 4) | (3 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 4,uint16_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 2,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 4): \ - IcStorePart(dst,sizeof (IcBits) - 4,uint32_t,xor); \ - break; - -#define IcDoRightMaskByteRRop6Cases(dst,xor) \ - case 4: \ - IcStorePart(dst,0,uint32_t,xor); \ - break; \ - case 5: \ - IcStorePart(dst,0,uint32_t,xor); \ - IcStorePart(dst,4,uint8_t,xor); \ - break; \ - case 6: \ - IcStorePart(dst,0,uint32_t,xor); \ - IcStorePart(dst,4,uint16_t,xor); \ - break; \ - case 7: \ - IcStorePart(dst,0,uint32_t,xor); \ - IcStorePart(dst,4,uint16_t,xor); \ - IcStorePart(dst,6,uint8_t,xor); \ - break; -#else -#define IcDoLeftMaskByteRRop6Cases(dst,xor) -#define IcDoRightMaskByteRRop6Cases(dst,xor) -#endif - -#define IcDoLeftMaskByteRRop(dst,lb,l,and,xor) { \ - switch (lb) { \ - IcDoLeftMaskByteRRop6Cases(dst,xor) \ - case (sizeof (IcBits) - 3) | (1 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 3,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 3) | (2 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 3,uint8_t,xor); \ - IcStorePart(dst,sizeof (IcBits) - 2,uint8_t,xor); \ - break; \ - case (sizeof (IcBits) - 2) | (1 << (IC_SHIFT - 3)): \ - IcStorePart(dst,sizeof (IcBits) - 2,uint8_t,xor); \ - break; \ - case sizeof (IcBits) - 3: \ - IcStorePart(dst,sizeof (IcBits) - 3,uint8_t,xor); \ - case sizeof (IcBits) - 2: \ - IcStorePart(dst,sizeof (IcBits) - 2,uint16_t,xor); \ - break; \ - case sizeof (IcBits) - 1: \ - IcStorePart(dst,sizeof (IcBits) - 1,uint8_t,xor); \ - break; \ - default: \ - *dst = IcDoMaskRRop(*dst, and, xor, l); \ - break; \ - } \ -} - - -#define IcDoRightMaskByteRRop(dst,rb,r,and,xor) { \ - switch (rb) { \ - case 1: \ - IcStorePart(dst,0,uint8_t,xor); \ - break; \ - case 2: \ - IcStorePart(dst,0,uint16_t,xor); \ - break; \ - case 3: \ - IcStorePart(dst,0,uint16_t,xor); \ - IcStorePart(dst,2,uint8_t,xor); \ - break; \ - IcDoRightMaskByteRRop6Cases(dst,xor) \ - default: \ - *dst = IcDoMaskRRop (*dst, and, xor, r); \ - } \ -} -#endif - -#define IcMaskStip(x,w,l,n,r) { \ - n = (w); \ - r = IcRightStipMask((x)+n); \ - l = IcLeftStipMask(x); \ - if (l) { \ - n -= IC_STIP_UNIT - ((x) & IC_STIP_MASK); \ - if (n < 0) { \ - n = 0; \ - l &= r; \ - r = 0; \ - } \ - } \ - n >>= IC_STIP_SHIFT; \ -} - -/* - * These macros are used to transparently stipple - * in copy mode; the expected usage is with 'n' constant - * so all of the conditional parts collapse into a minimal - * sequence of partial word writes - * - * 'n' is the bytemask of which bytes to store, 'a' is the address - * of the IcBits base unit, 'o' is the offset within that unit - * - * The term "lane" comes from the hardware term "byte-lane" which - */ - -#define IcLaneCase1(n,a,o) ((n) == 0x01 ? \ - (*(uint8_t *) ((a)+IcPatternOffset(o,uint8_t)) = \ - fgxor) : 0) -#define IcLaneCase2(n,a,o) ((n) == 0x03 ? \ - (*(uint16_t *) ((a)+IcPatternOffset(o,uint16_t)) = \ - fgxor) : \ - ((void)IcLaneCase1((n)&1,a,o), \ - IcLaneCase1((n)>>1,a,(o)+1))) -#define IcLaneCase4(n,a,o) ((n) == 0x0f ? \ - (*(uint32_t *) ((a)+IcPatternOffset(o,uint32_t)) = \ - fgxor) : \ - ((void)IcLaneCase2((n)&3,a,o), \ - IcLaneCase2((n)>>2,a,(o)+2))) -#define IcLaneCase8(n,a,o) ((n) == 0x0ff ? (*(IcBits *) ((a)+(o)) = fgxor) : \ - ((void)IcLaneCase4((n)&15,a,o), \ - IcLaneCase4((n)>>4,a,(o)+4))) - -#if IC_SHIFT == 6 -#define IcLaneCase(n,a) IcLaneCase8(n,(uint8_t *) (a),0) -#endif - -#if IC_SHIFT == 5 -#define IcLaneCase(n,a) IcLaneCase4(n,(uint8_t *) (a),0) -#endif - -/* Rotate a filled pixel value to the specified alignement */ -#define IcRot24(p,b) (IcScrRight(p,b) | IcScrLeft(p,24-(b))) -#define IcRot24Stip(p,b) (IcStipRight(p,b) | IcStipLeft(p,24-(b))) - -/* step a filled pixel value to the next/previous IC_UNIT alignment */ -#define IcNext24Pix(p) (IcRot24(p,(24-IC_UNIT%24))) -#define IcPrev24Pix(p) (IcRot24(p,IC_UNIT%24)) -#define IcNext24Stip(p) (IcRot24(p,(24-IC_STIP_UNIT%24))) -#define IcPrev24Stip(p) (IcRot24(p,IC_STIP_UNIT%24)) - -/* step a rotation value to the next/previous rotation value */ -#if IC_UNIT == 64 -#define IcNext24Rot(r) ((r) == 16 ? 0 : (r) + 8) -#define IcPrev24Rot(r) ((r) == 0 ? 16 : (r) - 8) - -#if IMAGE_BYTE_ORDER == MSBFirst -#define IcFirst24Rot(x) (((x) + 8) % 24) -#else -#define IcFirst24Rot(x) ((x) % 24) -#endif - -#endif - -#if IC_UNIT == 32 -#define IcNext24Rot(r) ((r) == 0 ? 16 : (r) - 8) -#define IcPrev24Rot(r) ((r) == 16 ? 0 : (r) + 8) - -#if IMAGE_BYTE_ORDER == MSBFirst -#define IcFirst24Rot(x) (((x) + 16) % 24) -#else -#define IcFirst24Rot(x) ((x) % 24) -#endif -#endif - -#define IcNext24RotStip(r) ((r) == 0 ? 16 : (r) - 8) -#define IcPrev24RotStip(r) ((r) == 16 ? 0 : (r) + 8) - -/* Whether 24-bit specific code is needed for this filled pixel value */ -#define IcCheck24Pix(p) ((p) == IcNext24Pix(p)) - -#define IcGetPixels(icpixels, pointer, _stride_, _bpp_, xoff, yoff) { \ - (pointer) = icpixels->data; \ - (_stride_) = icpixels->stride / sizeof(IcBits); \ - (_bpp_) = icpixels->bpp; \ - (xoff) = icpixels->x; /* XXX: fb.h had this ifdef'd to constant 0. Why? */ \ - (yoff) = icpixels->y; /* XXX: fb.h had this ifdef'd to constant 0. Why? */ \ -} - -#define IcGetStipPixels(icpixels, pointer, _stride_, _bpp_, xoff, yoff) { \ - (pointer) = (IcStip *) icpixels->data; \ - (_stride_) = icpixels->stride; \ - (_bpp_) = icpixels->bpp; \ - (xoff) = icpixels->x; \ - (yoff) = icpixels->y; \ -} - -#ifdef IC_OLD_SCREEN -#define BitsPerPixel(d) (\ - ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \ - (PixmapWidthPaddingInfo[d].padRoundUp+1))) -#endif - -#define IcPowerOfTwo(w) (((w) & ((w) - 1)) == 0) -/* - * Accelerated tiles are power of 2 width <= IC_UNIT - */ -#define IcEvenTile(w) ((w) <= IC_UNIT && IcPowerOfTwo(w)) -/* - * Accelerated stipples are power of 2 width and <= IC_UNIT/dstBpp - * with dstBpp a power of 2 as well - */ -#define IcEvenStip(w,bpp) ((w) * (bpp) <= IC_UNIT && IcPowerOfTwo(w) && IcPowerOfTwo(bpp)) - -/* - * icblt.c - */ -extern void __internal_linkage -IcBlt (IcBits *src, - IcStride srcStride, - int srcX, - - IcBits *dst, - IcStride dstStride, - int dstX, - - int width, - int height, - - int alu, - IcBits pm, - int bpp, - - int reverse, - int upsidedown); - -extern void __internal_linkage -IcBlt24 (IcBits *srcLine, - IcStride srcStride, - int srcX, - - IcBits *dstLine, - IcStride dstStride, - int dstX, - - int width, - int height, - - int alu, - IcBits pm, - - int reverse, - int upsidedown); - -extern void __internal_linkage -IcBltStip (IcStip *src, - IcStride srcStride, /* in IcStip units, not IcBits units */ - int srcX, - - IcStip *dst, - IcStride dstStride, /* in IcStip units, not IcBits units */ - int dstX, - - int width, - int height, - - int alu, - IcBits pm, - int bpp); - -/* - * icbltone.c - */ -extern void __internal_linkage -IcBltOne (IcStip *src, - IcStride srcStride, - int srcX, - IcBits *dst, - IcStride dstStride, - int dstX, - int dstBpp, - - int width, - int height, - - IcBits fgand, - IcBits icxor, - IcBits bgand, - IcBits bgxor); - -#ifdef IC_24BIT -extern void __internal_linkage -IcBltOne24 (IcStip *src, - IcStride srcStride, /* IcStip units per scanline */ - int srcX, /* bit position of source */ - IcBits *dst, - IcStride dstStride, /* IcBits units per scanline */ - int dstX, /* bit position of dest */ - int dstBpp, /* bits per destination unit */ - - int width, /* width in bits of destination */ - int height, /* height in scanlines */ - - IcBits fgand, /* rrop values */ - IcBits fgxor, - IcBits bgand, - IcBits bgxor); -#endif - -/* - * icstipple.c - */ - -extern void __internal_linkage -IcTransparentSpan (IcBits *dst, - IcBits stip, - IcBits fgxor, - int n); - -extern void __internal_linkage -IcEvenStipple (IcBits *dst, - IcStride dstStride, - int dstX, - int dstBpp, - - int width, - int height, - - IcStip *stip, - IcStride stipStride, - int stipHeight, - - IcBits fgand, - IcBits fgxor, - IcBits bgand, - IcBits bgxor, - - int xRot, - int yRot); - -extern void __internal_linkage -IcOddStipple (IcBits *dst, - IcStride dstStride, - int dstX, - int dstBpp, - - int width, - int height, - - IcStip *stip, - IcStride stipStride, - int stipWidth, - int stipHeight, - - IcBits fgand, - IcBits fgxor, - IcBits bgand, - IcBits bgxor, - - int xRot, - int yRot); - -extern void __internal_linkage -IcStipple (IcBits *dst, - IcStride dstStride, - int dstX, - int dstBpp, - - int width, - int height, - - IcStip *stip, - IcStride stipStride, - int stipWidth, - int stipHeight, - int even, - - IcBits fgand, - IcBits fgxor, - IcBits bgand, - IcBits bgxor, - - int xRot, - int yRot); - -/* XXX: Is depth redundant here? */ -struct _IcFormat { - int format_code; - int depth; - int red, redMask; - int green, greenMask; - int blue, blueMask; - int alpha, alphaMask; -}; - -typedef struct _IcPixels { - IcBits *data; - unsigned int width; - unsigned int height; - unsigned int depth; - unsigned int bpp; - unsigned int stride; - int x; - int y; - unsigned int refcnt; -} IcPixels; - -/* XXX: This is to avoid including colormap.h from the server includes */ -typedef uint32_t Pixel; - -/* icutil.c */ -extern IcBits __internal_linkage -IcReplicatePixel (Pixel p, int bpp); - -/* XXX: This is to avoid including gc.h from the server includes */ -/* clientClipType field in GC */ -#define CT_NONE 0 -#define CT_PIXMAP 1 -#define CT_REGION 2 -#define CT_UNSORTED 6 -#define CT_YSORTED 10 -#define CT_YXSORTED 14 -#define CT_YXBANDED 18 - -#include "icimage.h" - -/* iccolor.c */ - -/* GCC 3.4 supports a "population count" builtin, which on many targets is - implemented with a single instruction. There is a fallback definition - in libgcc in case a target does not have one, which should be just as - good as the static function below. */ -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# if __INT_MIN__ == 0x7fffffff -# define _IcOnes(mask) __builtin_popcount(mask) -# else -# define _IcOnes(mask) __builtin_popcountl((mask) & 0xffffffff) -# endif -#else -# define ICINT_NEED_IC_ONES -int -_IcOnes(unsigned long mask); -#endif - -/* icformat.c */ - -extern void __internal_linkage -IcFormatInit (IcFormat *format, int format_code); - -/* icimage.c */ - -extern IcImage * __internal_linkage -IcImageCreateForPixels (IcPixels *pixels, - IcFormat *format); - -/* icpixels.c */ - -extern IcPixels * __internal_linkage -IcPixelsCreate (int width, int height, int depth); - -extern IcPixels * __internal_linkage -IcPixelsCreateForData (IcBits *data, int width, int height, int depth, int bpp, int stride); - -extern void __internal_linkage -IcPixelsDestroy (IcPixels *pixels); - -/* ictransform.c */ - -extern int __internal_linkage -IcTransformPoint (IcTransform *transform, - IcVector *vector); - -/* ictrap.c */ - -extern void __internal_linkage -IcRasterizeTrapezoid (IcImage *pMask, - const IcTrapezoid *pTrap, - int x_off, - int y_off); - -/* Avoid unnessecary PLT entries. */ - -slim_hidden_proto(IcImageCreate) -slim_hidden_proto(IcColorToPixel) -slim_hidden_proto(IcFormatInit) -slim_hidden_proto(IcImageDestroy) -slim_hidden_proto(IcFillRectangles) -slim_hidden_proto(IcImageSetRepeat) -slim_hidden_proto(IcComposite) - - -#include "icrop.h" - -/* XXX: For now, I'm just wholesale pasting Xserver/render/picture.h here: */ -#ifndef _PICTURE_H_ -#define _PICTURE_H_ - -typedef struct _DirectFormat *DirectFormatPtr; -typedef struct _PictFormat *PictFormatPtr; -typedef struct _Picture *PicturePtr; - -/* - * While the protocol is generous in format support, the - * sample implementation allows only packed RGB and GBR - * representations for data to simplify software rendering, - */ -#define PICT_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \ - ((type) << 16) | \ - ((a) << 12) | \ - ((r) << 8) | \ - ((g) << 4) | \ - ((b))) - -/* - * gray/color formats use a visual index instead of argb - */ -#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \ - ((type) << 16) | \ - ((vi))) - -#define PICT_FORMAT_BPP(f) (((f) >> 24) ) -#define PICT_FORMAT_TYPE(f) (((f) >> 16) & 0xff) -#define PICT_FORMAT_A(f) (((f) >> 12) & 0x0f) -#define PICT_FORMAT_R(f) (((f) >> 8) & 0x0f) -#define PICT_FORMAT_G(f) (((f) >> 4) & 0x0f) -#define PICT_FORMAT_B(f) (((f) ) & 0x0f) -#define PICT_FORMAT_RGB(f) (((f) ) & 0xfff) -#define PICT_FORMAT_VIS(f) (((f) ) & 0xffff) - -#define PICT_TYPE_OTHER 0 -#define PICT_TYPE_A 1 -#define PICT_TYPE_ARGB 2 -#define PICT_TYPE_ABGR 3 -#define PICT_TYPE_COLOR 4 -#define PICT_TYPE_GRAY 5 - -#define PICT_FORMAT_COLOR(f) (PICT_FORMAT_TYPE(f) & 2) - -/* 32bpp formats */ -#define PICT_a8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,8,8,8,8) -#define PICT_x8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,0,8,8,8) -#define PICT_a8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,8,8,8,8) -#define PICT_x8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,0,8,8,8) - -/* 24bpp formats */ -#define PICT_r8g8b8 PICT_FORMAT(24,PICT_TYPE_ARGB,0,8,8,8) -#define PICT_b8g8r8 PICT_FORMAT(24,PICT_TYPE_ABGR,0,8,8,8) - -/* 16bpp formats */ -#define PICT_r5g6b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,6,5) -#define PICT_b5g6r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,6,5) - -#define PICT_a1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,1,5,5,5) -#define PICT_x1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,5,5) -#define PICT_a1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5) -#define PICT_x1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5) -#define PICT_a4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4) -#define PICT_x4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4) -#define PICT_a4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4) -#define PICT_x4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4) - -/* 8bpp formats */ -#define PICT_a8 PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0) -#define PICT_r3g3b2 PICT_FORMAT(8,PICT_TYPE_ARGB,0,3,3,2) -#define PICT_b2g3r3 PICT_FORMAT(8,PICT_TYPE_ABGR,0,3,3,2) -#define PICT_a2r2g2b2 PICT_FORMAT(8,PICT_TYPE_ARGB,2,2,2,2) -#define PICT_a2b2g2r2 PICT_FORMAT(8,PICT_TYPE_ABGR,2,2,2,2) - -#define PICT_c8 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0) -#define PICT_g8 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0) - -/* 4bpp formats */ -#define PICT_a4 PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0) -#define PICT_r1g2b1 PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1) -#define PICT_b1g2r1 PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1) -#define PICT_a1r1g1b1 PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1) -#define PICT_a1b1g1r1 PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1) - -#define PICT_c4 PICT_FORMAT(4,PICT_TYPE_COLOR,0,0,0,0) -#define PICT_g4 PICT_FORMAT(4,PICT_TYPE_GRAY,0,0,0,0) - -/* 1bpp formats */ -#define PICT_a1 PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0) - -#define PICT_g1 PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0) - -/* - * For dynamic indexed visuals (GrayScale and PseudoColor), these control the - * selection of colors allocated for drawing to Pictures. The default - * policy depends on the size of the colormap: - * - * Size Default Policy - * ---------------------------- - * < 64 PolicyMono - * < 256 PolicyGray - * 256 PolicyColor (only on PseudoColor) - * - * The actual allocation code lives in miindex.c, and so is - * austensibly server dependent, but that code does: - * - * PolicyMono Allocate no additional colors, use black and white - * PolicyGray Allocate 13 gray levels (11 cells used) - * PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used) - * PolicyAll Allocate as big a cube as possible, fill with gray (all) - * - * Here's a picture to help understand how many colors are - * actually allocated (this is just the gray ramp): - * - * gray level - * all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff - * b/w 0000 ffff - * 4x4x4 5555 aaaa - * extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa - * - * The default colormap supplies two gray levels (black/white), the - * 4x4x4 cube allocates another two and nine more are allocated to fill - * in the 13 levels. When the 4x4x4 cube is not allocated, a total of - * 11 cells are allocated. - */ - -#define PictureCmapPolicyInvalid -1 -#define PictureCmapPolicyDefault 0 -#define PictureCmapPolicyMono 1 -#define PictureCmapPolicyGray 2 -#define PictureCmapPolicyColor 3 -#define PictureCmapPolicyAll 4 - -extern int PictureCmapPolicy __internal_linkage; - -int PictureParseCmapPolicy (const char *name); - -/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */ - -#ifdef WIN32 -typedef __int64 xFixed_32_32; -#else -# if defined(__alpha__) || defined(__alpha) || \ - defined(ia64) || defined(__ia64__) || \ - defined(__sparc64__) || \ - defined(__s390x__) || \ - defined(x86_64) || defined (__x86_64__) -typedef long xFixed_32_32; -# else -# if defined(__GNUC__) && \ - ((__GNUC__ > 2) || \ - ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7))) -__extension__ -# endif -typedef long long int xFixed_32_32; -# endif -#endif - -typedef uint32_t xFixed_1_31; -typedef uint32_t xFixed_1_16; -typedef int32_t xFixed_16_16; - -/* - * An unadorned "xFixed" is the same as xFixed_16_16, - * (since it's quite common in the code) - */ -typedef xFixed_16_16 xFixed; -#define XFIXED_BITS 16 - -#define xFixedToInt(f) (int) ((f) >> XFIXED_BITS) -#define IntToxFixed(i) ((xFixed) (i) << XFIXED_BITS) -#define xFixedE ((xFixed) 1) -#define xFixed1 (IntToxFixed(1)) -#define xFixed1MinusE (xFixed1 - xFixedE) -#define xFixedFrac(f) ((f) & xFixed1MinusE) -#define xFixedFloor(f) ((f) & ~xFixed1MinusE) -#define xFixedCeil(f) xFixedFloor((f) + xFixed1MinusE) - -#define xFixedFraction(f) ((f) & xFixed1MinusE) -#define xFixedMod2(f) ((f) & (xFixed1 | xFixed1MinusE)) - -/* whether 't' is a well defined not obviously empty trapezoid */ -#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \ - (t)->right.p1.y != (t)->right.p2.y && \ - (int) ((t)->bottom - (t)->top) > 0) - -/* - * Standard NTSC luminance conversions: - * - * y = r * 0.299 + g * 0.587 + b * 0.114 - * - * Approximate this for a bit more speed: - * - * y = (r * 153 + g * 301 + b * 58) / 512 - * - * This gives 17 bits of luminance; to get 15 bits, lop the low two - */ - -#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \ - (((s) >> 8) & 0xff) * 301 + \ - (((s) ) & 0xff) * 58) >> 2) - -#endif /* _PICTURE_H_ */ - -#endif /* ICINT_H_INCLUDED */ diff --git a/pixman/src/icpixels.c b/pixman/src/icpixels.c deleted file mode 100644 index 0215b6571..000000000 --- a/pixman/src/icpixels.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * $Id: icpixels.c,v 1.4 2003-09-05 22:24:45 cworth Exp $ - * - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "icint.h" - -static void -IcPixelsInit (IcPixels *pixels, IcBits *buf, int width, int height, int depth, int bpp, int stride); - -static unsigned int -IcBitsPerPixel (unsigned int depth); - -static unsigned int -IcBitsPerPixel (unsigned int depth) -{ - if (depth > 8) - if (depth > 16) - return 32; - else - return 16; - else - if (depth > 4) - return 8; - else if (depth > 1) - return 4; - else - return 1; -} - -IcPixels * -IcPixelsCreate (int width, int height, int depth) -{ - IcPixels *pixels; - IcBits *buf; - unsigned int buf_size; - unsigned int bpp; - unsigned int stride; - unsigned int adjust; - unsigned int base; - - bpp = IcBitsPerPixel (depth); - stride = ((width * bpp + IC_MASK) >> IC_SHIFT) * sizeof (IcBits); - buf_size = height * stride; - base = sizeof (IcPixels); - adjust = 0; - if (base & 7) - adjust = 8 - (base & 7); - buf_size += adjust; - - pixels = malloc(base + buf_size); - if (!pixels) - return NULL; - - buf = (IcBits *) ((char *)pixels + base + adjust); - - IcPixelsInit (pixels, buf, width, height, depth, bpp, stride); - - return pixels; -} - -IcPixels * -IcPixelsCreateForData (IcBits *data, int width, int height, int depth, int bpp, int stride) -{ - IcPixels *pixels; - - pixels = malloc (sizeof (IcPixels)); - if (pixels == NULL) - return NULL; - - IcPixelsInit (pixels, data, width, height, depth, bpp, stride); - - return pixels; -} - -static void -IcPixelsInit (IcPixels *pixels, IcBits *buf, int width, int height, int depth, int bpp, int stride) -{ - pixels->data = buf; - pixels->width = width; - pixels->height = height; - pixels->depth = depth; - pixels->bpp = bpp; - pixels->stride = stride; - pixels->x = 0; - pixels->y = 0; - pixels->refcnt = 1; -} - -void -IcPixelsDestroy (IcPixels *pixels) -{ - if(--pixels->refcnt) - return; - - free(pixels); -} - diff --git a/pixman/src/icrect.c b/pixman/src/icrect.c deleted file mode 100644 index 85375e524..000000000 --- a/pixman/src/icrect.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright © 2000 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "icint.h" - -/* XXX: I haven't ported this yet -static void -IcColorRects (IcImage *dst, - IcImage *clipPict, - IcColor *color, - int nRect, - IcRectangle *rects, - int xoff, - int yoff) -{ - uint32_t pixel; - uint32_t tmpval[4]; - Region *clip; - unsigned long mask; - - IcRenderColorToPixel (dst->image_format, color, &pixel); - - if (clipPict->clientClipType == CT_REGION) - { - tmpval[2] = dst->clipOrigin.x - xoff; - tmpval[3] = dst->clipOrigin.y - yoff; - mask |= CPClipXOrigin|CPClipYOrigin; - - clip = PixRegionCreate (); - PixRegionCopy (clip, pClipPict->clientClip); - (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0); - } - - if (xoff || yoff) - { - int i; - for (i = 0; i < nRect; i++) - { - rects[i].x -= xoff; - rects[i].y -= yoff; - } - } - (*pGC->ops->PolyFillRect) (pDst->pDrawable, pGC, nRect, rects); - if (xoff || yoff) - { - int i; - for (i = 0; i < nRect; i++) - { - rects[i].x += xoff; - rects[i].y += yoff; - } - } -} -*/ - -void IcFillRectangle (IcOperator op, - IcImage *dst, - const IcColor *color, - int x, - int y, - unsigned int width, - unsigned int height) -{ - IcRectangle rect; - - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height; - - IcFillRectangles (op, dst, color, &rect, 1); -} - -void -IcFillRectangles (IcOperator op, - IcImage *dst, - const IcColor *color, - const IcRectangle *rects, - int nRects) -{ - IcColor color_s = *color; - - if (color_s.alpha == 0xffff) - { - if (op == IcOperatorOver) - op = IcOperatorSrc; - } - if (op == IcOperatorClear) - color_s.red = color_s.green = color_s.blue = color_s.alpha = 0; - -/* XXX: Really need this to optimize solid rectangles - if (op == IcOperatorSource || op == IcOperatorClear) - { - IcColorRects (dst, dst, &color_s, nRects, rects, 0, 0); - if (dst->alphaMap) - IcColorRects (dst->alphaMap, dst, - &color_s, nRects, rects, - dst->alphaOrigin.x, - dst->alphaOrigin.y); - } - else -*/ - { - IcFormat rgbaFormat; - IcPixels *pixels; - IcImage *src; - IcBits pixel; - - IcFormatInit (&rgbaFormat, PICT_a8r8g8b8); - - pixels = IcPixelsCreate (1, 1, rgbaFormat.depth); - if (!pixels) - goto bail1; - - IcColorToPixel (&rgbaFormat, &color_s, &pixel); - - /* XXX: Originally, fb had the following: - - (*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one); - - I haven't checked to see what I might be breaking with a - trivial assignment instead. - */ - pixels->data[0] = pixel; - - src = IcImageCreateForPixels (pixels, &rgbaFormat); - if (!src) - goto bail2; - - IcImageSetRepeat (src, 1); - - while (nRects--) - { - IcComposite (op, src, 0, dst, 0, 0, 0, 0, - rects->x, - rects->y, - rects->width, - rects->height); - rects++; - } - - IcImageDestroy (src); -bail2: - IcPixelsDestroy (pixels); -bail1: - ; - } -} -slim_hidden_def(IcFillRectangles); diff --git a/pixman/src/icrop.h b/pixman/src/icrop.h deleted file mode 100644 index c3c57a3e6..000000000 --- a/pixman/src/icrop.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Id: $ - * - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _ICROP_H_ -#define _ICROP_H_ - -typedef struct _mergeRopBits { - IcBits ca1, cx1, ca2, cx2; -} IcMergeRopRec, *IcMergeRopPtr; - -extern const IcMergeRopRec IcMergeRopBits[16] __internal_linkage; - -#define IcDeclareMergeRop() IcBits _ca1, _cx1, _ca2, _cx2; -#define IcDeclarePrebuiltMergeRop() IcBits _cca, _ccx; - -#define IcInitializeMergeRop(alu,pm) {\ - const IcMergeRopRec *_bits; \ - _bits = &IcMergeRopBits[alu]; \ - _ca1 = _bits->ca1 & pm; \ - _cx1 = _bits->cx1 | ~pm; \ - _ca2 = _bits->ca2 & pm; \ - _cx2 = _bits->cx2 & pm; \ -} - -#define IcDestInvarientRop(alu,pm) ((pm) == IC_ALLONES && \ - (((alu) >> 1 & 5) == ((alu) & 5))) - -#define IcDestInvarientMergeRop() (_ca1 == 0 && _cx1 == 0) - -/* AND has higher precedence than XOR */ - -#define IcDoMergeRop(src, dst) \ - (((dst) & (((src) & _ca1) ^ _cx1)) ^ (((src) & _ca2) ^ _cx2)) - -#define IcDoDestInvarientMergeRop(src) (((src) & _ca2) ^ _cx2) - -#define IcDoMaskMergeRop(src, dst, mask) \ - (((dst) & ((((src) & _ca1) ^ _cx1) | ~(mask))) ^ ((((src) & _ca2) ^ _cx2) & (mask))) - -#define IcDoLeftMaskByteMergeRop(dst, src, lb, l) { \ - IcBits __xor = ((src) & _ca2) ^ _cx2; \ - IcDoLeftMaskByteRRop(dst,lb,l,((src) & _ca1) ^ _cx1,__xor); \ -} - -#define IcDoRightMaskByteMergeRop(dst, src, rb, r) { \ - IcBits __xor = ((src) & _ca2) ^ _cx2; \ - IcDoRightMaskByteRRop(dst,rb,r,((src) & _ca1) ^ _cx1,__xor); \ -} - -#define IcDoRRop(dst, and, xor) (((dst) & (and)) ^ (xor)) - -#define IcDoMaskRRop(dst, and, xor, mask) \ - (((dst) & ((and) | ~(mask))) ^ (xor & mask)) - -/* - * Take a single bit (0 or 1) and generate a full mask - */ -#define IcFillFromBit(b,t) (~((t) ((b) & 1)-1)) - -#define IcXorT(rop,fg,pm,t) ((((fg) & IcFillFromBit((rop) >> 1,t)) | \ - (~(fg) & IcFillFromBit((rop) >> 3,t))) & (pm)) - -#define IcAndT(rop,fg,pm,t) ((((fg) & IcFillFromBit (rop ^ (rop>>1),t)) | \ - (~(fg) & IcFillFromBit((rop>>2) ^ (rop>>3),t))) | \ - ~(pm)) - -#define IcXor(rop,fg,pm) IcXorT(rop,fg,pm,IcBits) - -#define IcAnd(rop,fg,pm) IcAndT(rop,fg,pm,IcBits) - -#define IcXorStip(rop,fg,pm) IcXorT(rop,fg,pm,IcStip) - -#define IcAndStip(rop,fg,pm) IcAndT(rop,fg,pm,IcStip) - -/* - * Stippling operations; - */ - -/* half of table */ -extern const IcBits icStipple16Bits[256] __internal_linkage; -#define IcStipple16Bits(b) \ - (icStipple16Bits[(b)&0xff] | icStipple16Bits[(b) >> 8] << IC_HALFUNIT) - -extern const IcBits * __internal_linkage -IcStippleTable(int bits); - -#define IcStippleRRop(dst, b, fa, fx, ba, bx) \ - (IcDoRRop(dst, fa, fx) & b) | (IcDoRRop(dst, ba, bx) & ~b) - -#define IcStippleRRopMask(dst, b, fa, fx, ba, bx, m) \ - (IcDoMaskRRop(dst, fa, fx, m) & (b)) | (IcDoMaskRRop(dst, ba, bx, m) & ~(b)) - -#define IcDoLeftMaskByteStippleRRop(dst, b, fa, fx, ba, bx, lb, l) { \ - IcBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \ - IcDoLeftMaskByteRRop(dst, lb, l, ((fa) & (b)) | ((ba) & ~(b)), __xor); \ -} - -#define IcDoRightMaskByteStippleRRop(dst, b, fa, fx, ba, bx, rb, r) { \ - IcBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \ - IcDoRightMaskByteRRop(dst, rb, r, ((fa) & (b)) | ((ba) & ~(b)), __xor); \ -} - -#define IcOpaqueStipple(b, fg, bg) (((fg) & (b)) | ((bg) & ~(b))) - -/* - * Compute rop for using tile code for 1-bit dest stipples; modifies - * existing rop to flip depending on pixel values - */ -#define IcStipple1RopPick(alu,b) (((alu) >> (2 - (((b) & 1) << 1))) & 3) - -#define IcOpaqueStipple1Rop(alu,fg,bg) (IcStipple1RopPick(alu,fg) | \ - (IcStipple1RopPick(alu,bg) << 2)) - -#define IcStipple1Rop(alu,fg) (IcStipple1RopPick(alu,fg) | 4) - -#endif diff --git a/pixman/src/icstipple.c b/pixman/src/icstipple.c deleted file mode 100644 index 9dc3cc79e..000000000 --- a/pixman/src/icstipple.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Id: $ - * - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "icint.h" - -#ifndef ICNOPIXADDR -/* - * This is a slight abuse of the preprocessor to generate repetitive - * code, the idea is to generate code for each case of a copy-mode - * transparent stipple - */ -#define LaneCases1(c,a) case c: \ - while (n--) { (void)IcLaneCase(c,a); a++; } \ - break -#define LaneCases2(c,a) LaneCases1(c,a); LaneCases1(c+1,a) -#define LaneCases4(c,a) LaneCases2(c,a); LaneCases2(c+2,a) -#define LaneCases8(c,a) LaneCases4(c,a); LaneCases4(c+4,a) -#define LaneCases16(c,a) LaneCases8(c,a); LaneCases8(c+8,a) -#define LaneCases32(c,a) LaneCases16(c,a); LaneCases16(c+16,a) -#define LaneCases64(c,a) LaneCases32(c,a); LaneCases32(c+32,a) -#define LaneCases128(c,a) LaneCases64(c,a); LaneCases64(c+64,a) -#define LaneCases256(c,a) LaneCases128(c,a); LaneCases128(c+128,a) - -#if IC_SHIFT == 6 -#define LaneCases(a) LaneCases256(0,a) -#endif - -#if IC_SHIFT == 5 -#define LaneCases(a) LaneCases16(0,a) -#endif - -/* - * Repeat a transparent stipple across a scanline n times - */ - -void -IcTransparentSpan (IcBits *dst, - IcBits stip, - IcBits fgxor, - int n) -{ - IcStip s; - - s = ((IcStip) (stip ) & 0x01); - s |= ((IcStip) (stip >> 8) & 0x02); - s |= ((IcStip) (stip >> 16) & 0x04); - s |= ((IcStip) (stip >> 24) & 0x08); -#if IC_SHIFT > 5 - s |= ((IcStip) (stip >> 32) & 0x10); - s |= ((IcStip) (stip >> 40) & 0x20); - s |= ((IcStip) (stip >> 48) & 0x40); - s |= ((IcStip) (stip >> 56) & 0x80); -#endif - switch (s) { - LaneCases(dst); - } -} -#endif diff --git a/pixman/src/ictransform.c b/pixman/src/ictransform.c deleted file mode 100644 index 80bc494c3..000000000 --- a/pixman/src/ictransform.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#include "icint.h" - -typedef xFixed_32_32 xFixed_48_16; - -#define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff) -#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31)) - -int -IcTransformPoint (IcTransform *transform, - IcVector *vector) -{ - IcVector result; - int i, j; - xFixed_32_32 partial; - xFixed_48_16 v; - - for (j = 0; j < 3; j++) - { - v = 0; - for (i = 0; i < 3; i++) - { - partial = ((xFixed_48_16) transform->matrix[j][i] * - (xFixed_48_16) vector->vector[i]); - v += partial >> 16; - } - if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16) - return 0; - result.vector[j] = (xFixed) v; - } - if (!result.vector[2]) - return 0; - for (j = 0; j < 2; j++) - { - partial = (xFixed_48_16) result.vector[j] << 16; - v = partial / result.vector[2]; - if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16) - return 0; - vector->vector[j] = (xFixed) v; - } - vector->vector[2] = xFixed1; - return 1; -} - diff --git a/pixman/src/ictrap.c b/pixman/src/ictrap.c deleted file mode 100644 index 9ff387733..000000000 --- a/pixman/src/ictrap.c +++ /dev/null @@ -1,1507 +0,0 @@ -/* - * Copyright © 2002 University of Southern California - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of University - * of Southern California not be used in advertising or publicity - * pertaining to distribution of the software without specific, - * written prior permission. University of Southern California makes - * no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied - * warranty. - * - * UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL UNIVERSITY OF - * SOUTHERN CALIFORNIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl Worth, USC, Information Sciences Institute */ - -#include "icint.h" - -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#define MAX(a,b) ((a) > (b) ? (a) : (b)) - -IcImage * -IcCreateAlphaPicture (IcImage *dst, - IcFormat *format, - uint16_t width, - uint16_t height) -{ - IcImage *image; - int own_format = 0; - - if (width > 32767 || height > 32767) - return 0; - - if (!format) - { - own_format = 1; - if (dst->polyEdge == PolyEdgeSharp) - format = IcFormatCreate (IcFormatNameA1); - else - format = IcFormatCreate (IcFormatNameA8); - if (!format) - return 0; - } - - image = IcImageCreate (format, width, height); - - if (own_format) - IcFormatDestroy (format); - - /* XXX: Is this a reasonable way to clear the image? Would - probably be preferable to use IcImageFillRectangle once such a - beast exists. */ - memset (image->pixels->data, 0, height * image->pixels->stride); - - return image; -} - -static IcFixed16_16 -IcLineFixedX (const IcLineFixed *l, IcFixed16_16 y, int ceil) -{ - IcFixed16_16 dx = l->p2.x - l->p1.x; - xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx; - IcFixed16_16 dy = l->p2.y - l->p1.y; - if (ceil) - ex += (dy - 1); - return l->p1.x + (IcFixed16_16) (ex / dy); -} - -static void -IcTrapezoidBounds (int ntrap, const IcTrapezoid *traps, PixRegionBox *box) -{ - box->y1 = MAXSHORT; - box->y2 = MINSHORT; - box->x1 = MAXSHORT; - box->x2 = MINSHORT; - for (; ntrap; ntrap--, traps++) - { - int16_t x1, y1, x2, y2; - - if (!xTrapezoidValid(traps)) - continue; - y1 = xFixedToInt (traps->top); - if (y1 < box->y1) - box->y1 = y1; - - y2 = xFixedToInt (xFixedCeil (traps->bottom)); - if (y2 > box->y2) - box->y2 = y2; - - x1 = xFixedToInt (MIN (IcLineFixedX (&traps->left, traps->top, 0), - IcLineFixedX (&traps->left, traps->bottom, 0))); - if (x1 < box->x1) - box->x1 = x1; - - x2 = xFixedToInt (xFixedCeil (MAX (IcLineFixedX (&traps->right, traps->top, 1), - IcLineFixedX (&traps->right, traps->bottom, 1)))); - if (x2 > box->x2) - box->x2 = x2; - } -} - -void -IcCompositeTrapezoids (IcOperator op, - IcImage *src, - IcImage *dst, - int xSrc, - int ySrc, - const IcTrapezoid *traps, - int ntraps) -{ - IcImage *image = NULL; - PixRegionBox bounds; - int16_t xDst, yDst; - int16_t xRel, yRel; - IcFormat *format; - - if (ntraps == 0) - return; - - xDst = traps[0].left.p1.x >> 16; - yDst = traps[0].left.p1.y >> 16; - - format = IcFormatCreate (IcFormatNameA8); - - if (format) - { - IcTrapezoidBounds (ntraps, traps, &bounds); - if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) - return; - image = IcCreateAlphaPicture (dst, format, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!image) - return; - } - for (; ntraps; ntraps--, traps++) - { - if (!xTrapezoidValid(traps)) - continue; - if (!format) - { - IcTrapezoidBounds (1, traps, &bounds); - if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) - continue; - image = IcCreateAlphaPicture (dst, format, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!image) - continue; - } - IcRasterizeTrapezoid (image, traps, - -bounds.x1, -bounds.y1); - if (!format) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - IcComposite (op, src, image, dst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - IcImageDestroy (image); - } - } - if (format) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - IcComposite (op, src, image, dst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - IcImageDestroy (image); - } - - IcFormatDestroy (format); -} - -#ifdef DEBUG -#include <stdio.h> -#include <assert.h> - -#define ASSERT(e) assert(e) - -#endif - -#ifndef ASSERT -#define ASSERT(e) -#endif - -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif -#ifndef MIN -#define ICN(a, b) ((a) < (b) ? (a) : (b)) -#endif - -#define MAX_AREA 0x80000000 - -/* - * A RationalPoint is an exact position along one of the trapezoid - * edges represented by an approximate position (x,y) and two error - * terms (ex_dy, ey_dx). The error in X is multiplied by the Y - * dimension of the line while the error in Y is multiplied by the - * X dimension of the line, allowing an exact measurement of the - * distance from (x,y) to the line. - * - * Generally, while walking an edge, one of ex_dy/ey_dx will be zero - * indicating that the position error is held in the other. - */ -typedef struct { - xFixed x; - xFixed ex_dy; - xFixed y; - xFixed ey_dx; -} RationalPoint; - -/* - * Edges are walked both horizontally and vertically - * They are walked vertically to get to a particular row - * of pixels, and then walked horizontally within that row - * to compute pixel coverage. - * - * Edges are always walked from top to bottom and from - * left to right. This means that for lines moving leftwards - * from top to bottom, the left to right walking actually moves - * backwards along the line with respect to the top to bottom - * walking. - */ - -/* - * A RationalRow represents the two positions where an - * edge intersects a row of the trapezoid. Either or - * both points may be on sub-pixel boundaries when at - * the top or bottom of the trapezoid. This is used to - * walk an edge vertically. - */ - -typedef struct { - RationalPoint top; /* intersection at top of row */ - RationalPoint bottom; /* intersection at bottom of row */ -} RationalRow; - -/* - * A RationalCol represents the two positions where an - * edge intersects a column of pixels. Both left and - * right are always on whole pixel boundaries. - */ - -typedef struct { - RationalPoint left; /* intersection at left of column */ - RationalPoint right; /* intersection at right of column */ -} RationalCol; - -/* - Here are some thoughts on line walking: - - Conditions: c2.x - c1.x = 1 - r2.y - r1.y = 1 - - A B C D E F G H - c1\ c1 c2 /c2 -r1 r1 |\ \ r1 r1 / r1/| r1 r1 -\-+---+ \-+---+ +-\-+ +\--+ +--/+ +-/-+ +---+-/ +---+-/ - \| | `.c1 | |r1\| | \ | | / | |/ | | .' | |/ -c1\ | |`-.|c2 | \c2 | | | | | | c1/ | c1|,_/|c2 | /c2 - |\ | | `. | |\ | \ | | / | /| | ./ | | /| - +-\-+ +---+-\ +---+-\ +--\+ +/--+ /-+---+ /-+---+ +-/-+ - r2\| r2 r2 r2\ /r2 r2 r2 |/r2 - \c2 c2 c1 c1/ - - Bottom Right Right Bottom Top Top Right Right - -State transitions: - -A -> C, D E -> E, F -B -> A, B F -> G, H -C -> A, B G -> G, H -D -> C, D H -> E, F - -*/ - -/* - * Values for PixelWalk.depart. Top and Bottom can have the same value - * as only one mode is possible given a line of either positive or - * negative slope. These mark the departure edge while walking - * rightwards across columns. - */ - -typedef enum _departure { - DepartTop = 0, /* edge exits top of pixel */ - DepartBottom = 0, /* edge exits bottom of pixel */ - DepartRight = 1 /* edge exits right edge of pixel */ -} Departure; - -/* - * PixelWalk - * - * This structure holds state to walk a single edge down the trapezoid. - * - * The edge is walked twice -- once by rows and once by columns. - * The two intersections of the pixel by the edge are then set - * from either the row or column position, depending on which edge - * is intersected. - * - * Note that for lines moving left, walking by rows moves down the - * line (increasing y) while walking by columns moves up the line - * (decreasing y). - */ -typedef struct { - xFixed dx; - xFixed ey_thresh; - xFixed dy; - xFixed ex_thresh; - - Departure depart; - - /* slope */ - xFixed m; - xFixed em_dx; - xFixed y_correct; - xFixed ey_correct; - - /* Inverse slope. Does this have a standard symbol? */ - xFixed p; - xFixed ep_dy; - xFixed x_correct; - xFixed ex_correct; - - /* - * Current edge positions along pixel rows and columns - */ - RationalRow row; - RationalCol col; - - /* - * The two intersections with the current pixel. - * These are copied from either row or col as appropriate. - */ - RationalPoint upper; - RationalPoint lower; -} PixelWalk; - -#if 0 -#ifdef GCC -#define INLINE inline -#endif -#endif - -#ifndef INLINE -#define INLINE -#endif - -/* - * Set a RationalPoint to an exact sub-pixel coordinate - */ -static void -rationalPointInit (RationalPoint *pt, xFixed x, xFixed y) -{ - pt->x = x; - pt->ex_dy = 0; - pt->y = y; - pt->ey_dx = 0; -} - -/* Calculate a / b, rounding down to the nearest integer */ -static xFixed -DivFloor(xFixed_32_32 a, xFixed b) -{ - xFixed q; - - /* C allows implementation-defined rounding when using / with - negative integers. Force all arguments to be positive to - guarantee consistency. */ - int neg = (a < 0 != b < 0); - if (a < 0) - a = -a; - if (b < 0) - b = -b; - - q = a / b; - - if (neg) - q = -q; - - return q; -} - -/* - * Step 'pt' vertically to 'newy'. - */ -static INLINE void -pixelWalkMovePointToY (PixelWalk *pw, RationalPoint *pt, xFixed newy) -{ - xFixed_32_32 oex; - xFixed xoff; - - /* X error of old X position and new Y position */ - oex = (xFixed_32_32) pw->dx * (newy - pt->y) - pt->ey_dx + pt->ex_dy; - - /* amount to step X by */ - xoff = DivFloor(oex, pw->dy); - - /* step X */ - pt->x = pt->x + xoff; - - /* set new X error value for new X position and new Y positition */ - pt->ex_dy = oex - (xFixed_32_32) pw->dy * xoff; - - /* Ensure that pt->x is always rounded down from the true X - position, (ie. pt->ex_dy must be positive) */ - if (pt->ex_dy < 0) - { - pt->x--; - pt->ex_dy += pw->dy; - } - - /* set new Y position, set Y error to zero */ - pt->y = newy; - pt->ey_dx = 0; -} - -/* - * Step 'pt' horizontally to 'newx' - */ -static INLINE void -pixelWalkMovePointToX (PixelWalk *pw, RationalPoint *pt, xFixed newx) -{ - xFixed_32_32 oey; - xFixed yoff; - - /* Special case vertical lines to arbitrary y */ - if (pw->dx == 0) - { - pt->x = newx; - pt->ex_dy = 0; - pt->y = 0; - pt->ey_dx = 0; - } - else - { - /* Y error of old Y position and new X position */ - oey = (xFixed_32_32) pw->dy * (newx - pt->x) - pt->ex_dy + pt->ey_dx; - - /* amount to step Y by */ - yoff = DivFloor(oey, pw->dx); - - /* step Y */ - pt->y = pt->y + yoff; - - /* set new Y error value for new Y position and new X position */ - pt->ey_dx = oey - (xFixed_32_32) pw->dx * yoff; - - /* Ensure that pt->y is always rounded down from the true Y - position, (ie. pt->ey_dx/pw->dx must be positive) */ - if ((pw->dx > 0 && pt->ey_dx < 0) - || (pw->dx < 0 && pt->ey_dx > 0)) - { - pt->y--; - pt->ey_dx += pw->dx; - } - - /* set new X position, set X error to zero */ - pt->x = newx; - pt->ex_dy = 0; - } -} - -/* - * Step the 'row' element of 'pw' vertically (increasing y) to the - * next y coordinate, (either the next full pixel value or the bottom - * of the trapezoid, whichever comes first). - */ -static INLINE void -pixelWalkStepRow (PixelWalk *pw) -{ - /* pw.row.top.y < pw.row.bottom.y */ - /* - * Copy the current bottom point into the top point - */ - pw->row.top = pw->row.bottom; - - /* - * Now incrementally walk bottom to the next column intersection - */ - pw->row.bottom.y += xFixed1; - pw->row.bottom.x += pw->p; - pw->row.bottom.ex_dy += pw->ep_dy; - if ((pw->row.bottom.ex_dy > pw->ex_thresh) - || - ((pw->dx < 0) && (pw->row.bottom.ex_dy < 0))) { - - pw->row.bottom.x += pw->x_correct; - pw->row.bottom.ex_dy += pw->ex_correct; - } -} - -/* - * Step the 'col' element of 'pw' horizontally - * (increasing x) by one whole pixel - */ -static INLINE void -pixelWalkStepCol (PixelWalk *pw) -{ - /* pw.col.p1.x < pw.col.p2.x */ - /* - * Copy the current right point into the left point - */ - pw->col.left = pw->col.right; - - /* - * Now incrementally walk right to the next column intersection - */ - pw->col.right.x += xFixed1; - pw->col.right.y += pw->m; - pw->col.right.ey_dx += pw->em_dx; - if ((pw->col.right.ey_dx > pw->ey_thresh) - || - ((pw->dx < 0) && (pw->col.right.ey_dx > 0))) - { - pw->col.right.y += pw->y_correct; - pw->col.right.ey_dx += pw->ey_correct; - } -} - -/* - * Walk to the nearest edge of the next pixel, filling in both p1 and - * p2 as necessary from either the row or col intersections. - * - * The "next" pixel is defined to be the next pixel intersected by the - * line with pixels visited in raster scan order, (for the benefit of - * cache performance). For lines with positive slope it is easy to - * achieve raster scan order by simply calling StepCol for each pixel - * in a given scanline, then calling StepRow once at the end of each - * scanline. - * - * However, for lines of negative slope where the magnitude of dx is - * greater than dy, a little more work needs to be done. The pixels of - * a particular scanline will be visited by succesive calls to StepCol - * as before. This will effectively step "up" the line as we scan from - * left to right. But, the call to StepRow at the end of the scan line - * will step "down" the line and the column information will be - * invalid at that point. - * - * For now, I fix up the column of all negative slope lines by calling - * MovePointToX at the end of each scanline. However, this is an - * extremely expensive operation since it involves a 64-bit multiply - * and a 64-bit divide. It would be much better, (at least as long as - * abs(dx) is not much greater than dy), to instead step the col - * backwards as many times as necessary. - */ -static INLINE void -pixelWalkNextPixel (PixelWalk *pw) -{ - if (pw->dx < 0) - { - /* - * left moving lines - * - * Check which pixel edge we're departing from - * - * Remember that in this case (dx < 0), the 'row' element of 'pw' - * walks down the line while 'col' walks up - */ - if (pw->depart == DepartTop) - { - /* - * The edge departs the row at this pixel, the - * next time it gets used will be for the next row - * - * Step down one row and then recompute the - * column values to start the next row of - * pixels - */ - pixelWalkStepRow(pw); - /* - * Set column exit pixel - */ - pixelWalkMovePointToX(pw, &pw->col.right, xFixedFloor(pw->row.bottom.x)); - /* - * This moves the exit pixel to the entry pixel - * and computes the next exit pixel - */ - pixelWalkStepCol(pw); - /* - * The first pixel on the next row will always - * be entered from below, set the lower - * intersection of this edge with that pixel - */ - pw->lower = pw->row.bottom; - } - else /* pw->depart == DepartRight */ - { - /* - * easy case -- just move right one pixel - */ - pixelWalkStepCol(pw); - /* - * Set the lower intersection of the edge with the - * pixel -- that's just where the edge entered - * the pixel from the left - */ - pw->lower = pw->col.left; - } - /* - * Now compute which edge the pixel - * is departing from - */ - if (pw->row.top.x <= pw->col.right.x) - { - /* - * row intersection is left of column intersection, - * that means the edge hits the top of the pixel - * before it hits the right edge - */ - pw->upper = pw->row.top; - pw->depart = DepartTop; - } - else - { - /* - * Row intersection is right of colum intersection, - * that means the edge hits the right edge of the - * pixel first - */ - pw->upper = pw->col.right; - pw->depart = DepartRight; - } - } - else - { - /* - * right moving lines - * - * Check which edge we're departing from - * - * In the dx >= 0 case, the row and col elements both - * walk downwards - */ - if (pw->depart == DepartBottom) - { - /* - * The edge departs the row at this pixel, - * the next time it gets used will be for the - * next row - * - * Step down one row and (maybe) over one - * column to prepare for the next row - */ - if (pw->row.bottom.x == pw->col.right.x) - { - /* - * right through the corner of the pixel, - * adjust the column - */ - pixelWalkStepCol(pw); - } - pixelWalkStepRow(pw); - /* - * Set the upper intersection of the edge with - * the pixel, the first pixel on the next - * row is always entered from the top - */ - pw->upper = pw->row.top; - } - else /* pw->depart == DepartRight */ - { - /* - * Easy case -- move right one - * pixel - */ - pixelWalkStepCol(pw); - /* - * Set the upper intersection of the edge - * with the pixel, that's along the left - * edge of the pixel - */ - pw->upper = pw->col.left; - } - /* - * Now compute the exit edge and the - * lower intersection of the edge with the pixel - */ - if (pw->row.bottom.x <= pw->col.right.x) - { - /* - * Hit the place where the edge leaves - * the pixel, the lower intersection is - * where the edge hits the bottom - */ - pw->lower = pw->row.bottom; - pw->depart = DepartBottom; - } - else - { - /* - * The edge goes through the - * next pixel on the row, - * the lower intersection is where the - * edge hits the right side of the pixel - */ - pw->lower = pw->col.right; - pw->depart = DepartRight; - } - } -} - -/* - * Compute the first pixel intersection points - * and the departure type from that pixel - */ -static void -pixelWalkFirstPixel (PixelWalk *pw) -{ - if (pw->dx < 0) - { - if (pw->row.top.x <= pw->col.right.x) - { - /* - * leaving through the top. - * upper position is the upper point of - * the 'row' element - */ - pw->depart = DepartTop; - pw->upper = pw->row.top; - } - else - { - /* - * leaving through the right side - * upper position is the right point of - * the 'col' element - */ - pw->depart = DepartRight; - pw->upper = pw->col.right; - } - /* - * Now find the lower pixel intersection point - */ - if (pw->row.bottom.x >= pw->col.left.x) - /* - * entering through bottom, - * lower position is the bottom point of - * the 'row' element - */ - pw->lower = pw->row.bottom; - else - /* - * entering through left side, - * lower position is the left point of - * the 'col' element - */ - pw->lower = pw->col.left; - } - else - { - if (pw->row.bottom.x <= pw->col.right.x) - { - /* - * leaving through the bottom (or corner). - * lower position is the lower point of - * the 'row' element - */ - pw->depart = DepartBottom; - pw->lower = pw->row.bottom; - } - else - { - /* - * leaving through the right side - * lower position is the right point of - * the 'col' element - */ - pw->depart = DepartRight; - pw->lower = pw->col.right; - } - /* - * Now find the upper pixel intersection point - */ - if (pw->row.top.x >= pw->col.left.x) - { - /* - * entering through the top (or corner), - * upper position is the top point - * of the 'row' element - */ - pw->upper = pw->row.top; - } - else - { - /* - * entering through the left side, - * upper position is the left point of - * the 'col' element - */ - pw->upper = pw->col.left; - } - } -} - -static void -pixelWalkInit (PixelWalk *pw, IcLineFixed *line, - IcFixed16_16 top_y, IcFixed16_16 bottom_y) -{ - xFixed_32_32 dy_inc, dx_inc; - IcPointFixed *top, *bot; - - /* - * Orient lines top down - */ - if (line->p1.y < line->p2.y) - { - top = &line->p1; - bot = &line->p2; - } - else - { - top = &line->p2; - bot = &line->p1; - } - pw->dx = bot->x - top->x; - pw->dy = bot->y - top->y; - - /* - * Set step values for walking lines. - * - * These values are constructed so that the approximations in line - * position will always be rounded down from the ideal position. - */ - pw->ex_thresh = pw->dy; - pw->ey_thresh = abs(pw->dx); - if (pw->dx < 0) - { - pw->x_correct = -1; - pw->ex_correct = pw->dy; - pw->y_correct = -1; - pw->ey_correct = pw->dx; - } - else - { - pw->x_correct = 1; - pw->ex_correct = -pw->dy; - pw->y_correct = 1; - pw->ey_correct = -pw->dx; - } - - /* - * Compute Bresenham values for walking edges incrementally - */ - dy_inc = (xFixed_32_32) xFixed1 * pw->dy; /* > 0 */ - if (pw->dx != 0) - { - pw->m = dy_inc / pw->dx; /* sign(dx) */ - pw->em_dx = dy_inc - (xFixed_32_32) pw->m * pw->dx; /* < 0 or > 0 */ - } - else - { - /* Vertical line. Setting these to zero prevents us from - having to put any conditions in pixelWalkStepCol. */ - pw->m = 0; - pw->em_dx = 0; - } - - dx_inc = (xFixed_32_32) xFixed1 * (xFixed_32_32) pw->dx; /* sign(dx) */ - pw->p = dx_inc / pw->dy; /* sign(dx) */ - pw->ep_dy = dx_inc - (xFixed_32_32) pw->p * pw->dy; /* < 0 or > 0 */ - - /* - * row.bottom must be on the line before it can move. - */ - rationalPointInit(&pw->row.bottom, top->x, top->y); - - /* - * Move row to the first scanline of the trapezoid. Do this by - * first moving 'bottom' to the top of the trapezoid, and then - * calling StepRow which copies that point to 'top' and computes - * the next 'bottom'. - */ - pixelWalkMovePointToY(pw, &pw->row.bottom, xFixedFloor(top_y)); - pixelWalkStepRow(pw); - - /* - * col.right must be on the line before it can move. - */ - rationalPointInit(&pw->col.right, top->x, top->y); - - /* - * Move col to the left-most pixel of the trapezoid in the first - * scanline. Do this by first setting 'right' based on the - * left-most endpoint of row, and then using StepCol which copies - * that point to 'left' and computes the next 'right'. - */ - pixelWalkMovePointToX(pw, &pw->col.right, - xFixedFloor(MIN(pw->row.top.x, - pw->row.bottom.x))); - pixelWalkStepCol(pw); - - /* - * Compute first pixel intersections and the - * first departure state - */ - pixelWalkFirstPixel (pw); -} - -#define RoundShift(a,b) (((a) + (1 << ((b) - 1))) >> (b)) -#define MaxAlpha(depth) ((1 << (depth)) - 1) - -#define AreaAlpha(area, depth) (RoundShift (RoundShift (area, depth) * \ - MaxAlpha (depth), \ - (31 - depth))) - -/* - Pixel coverage from the upper-left corner bounded by one horizontal - bottom line (bottom) and one line defined by two points, (x1,y1) and - (x2,y2), which intersect the pixel. y1 must be less than y2. There - are 8 cases yielding the following area calculations: - - A B C D E F G H -+---+ +---+ +-1-+ +1--+ +--1+ +-1-+ +---+ +---+ -| | 1 | | \| | \ | | / | |/ | | 1 | | -1 | |`-.| | 2 | | | | | | 2 | |,_/| | 1 -|\ | | 2 | | | \ | | / | | | 2 | | /| -+-2-+ +---+ +---+ +--2+ +2--+ +---+ +---+ +-2-+ - -A: (1/2 * x2 * (y2 - y1)) -B: (1/2 * x2 * (y2 - y1)) + (bottom - y2) * x2 -C: (1/2 * (x1 + x2) * y2 ) + (bottom - y2) * x2 -D: (1/2 * (x1 + x2) * y2 ) -E: (1/2 * (x1 + x2) * y2 ) -F: (1/2 * x1 * y2 ) -G: (1/2 * x1 * (y2 - y1)) + x1 * y1 -H: (1/2 * (x1 + x2) * (y2 - y1)) + x1 * y1 - -The union of these calculations is valid for all cases. Namely: - - (1/2 * (x1 + x2) * (y2 - y1)) + (bottom - y2) * x2 + x1 * y1 - -An exercise for later would perhaps be to optimize the calculations -for some of the cases above. Specifically, it's possible to eliminate -multiplications by zero in several cases, leaving a maximum of two -multiplies per pixel calculation. (This is even more promising now -that the higher level code actually computes the exact same 8 cases -as part of its pixel walking). - -But, for now, I just want to get something working correctly even if -slower. So, we'll use the non-optimized general equation. - -*/ - -/* 1.16 * 1.16 -> 1.31 */ -#define AREA_MULT(w, h) ( (xFixed_1_31) (((((xFixed_1_16)w)*((xFixed_1_16)h) + 1) >> 1) | (((xFixed_1_16)w)&((xFixed_1_16)h)&0x10000) << 15)) - -/* (1.16 + 1.16) / 2 -> 1.16 */ -#define WIDTH_AVG(x1,x2) (((x1) + (x2) + 1) >> 1) - -/* -#define AreaAboveLeft(bottom, x1, y1, x2, y2) \ -(xFixed_1_31) ( \ - AREA_MULT((x1), (y1)) \ - + AREA_MULT(WIDTH_AVG((x1), (x2)), (y2) - (y1))\ - + AREA_MULT((x2), (bottom) - (y2)) \ -) -*/ - -static xFixed_1_31 -AreaAboveLeft(xFixed_1_16 bottom, - xFixed_1_16 x1, - xFixed_1_16 y1, - xFixed_1_16 x2, - xFixed_1_16 y2) -{ - xFixed_1_16 x_trap; - xFixed_1_16 h_top, h_trap, h_bot; - xFixed_1_31 area; - - x_trap = WIDTH_AVG(x1,x2); - h_top = y1; - h_trap = (y2 - y1); - h_bot = (bottom - y2); - - area = AREA_MULT(x1, h_top) + - AREA_MULT(x_trap, h_trap) + - AREA_MULT(x2, h_bot); - - return area; -} - -#define AlphaAboveLeft(bottom, x1, y1, x2, y2, depth) \ -( \ - AreaAlpha( \ - AreaAboveLeft((bottom), (x1), (y1), (x2), (y2)), \ - (depth) \ - ) \ -) - -/* -static int -AlphaAboveLeft(xFixed_1_16 bottom, - xFixed_1_16 x1, - xFixed_1_16 y1, - xFixed_1_16 x2, - xFixed_1_16 y2, - int depth) -{ - xFixed_1_31 area; - - area = AreaAboveLeft(bottom, x1, y1, x2, y2); - - return AreaAlpha(area, depth); -} -*/ - -/* Alpha of a pixel above a given horizontal line */ -#define AlphaAbove(pixel_y, line_y, depth) \ -( \ - AreaAlpha(AREA_MULT((line_y) - (pixel_y), xFixed1), depth) \ -) - -static int -RectAlpha(xFixed pixel_y, xFixed top, xFixed bottom, int depth) -{ - if (depth == 1) - return top == pixel_y ? 1 : 0; - else { - return AlphaAbove (pixel_y, bottom, depth) - - AlphaAbove (pixel_y, top, depth); - } -} - -/* - Pixel coverage from the left edge bounded by two horizontal lines, - (top and bottom), as well as one line two points, p1 and p2, which - intersect the pixel. The following condition must be true: - - p2.y > p1.y -*/ - -/* - lr - |\ - +--|-\-------+ - | a| b\ | - =======|===\========== top - | c| d \ - =======|=====\======== bot - | | \ | - +--|-------\-+ - - alpha(d) = alpha(cd) - alpha(c) = alpha(abcd) - alpha(ab) - (alpha(ac) - alpha(a)) - - alpha(d) = pixel_alpha(top, bot, right) - pixel_alpha(top, bot, left) - - pixel_alpha(top, bot, line) = alpha_above_left(bot, line) - alpha_above_left(top, line) -*/ - -static int -PixelAlpha(xFixed pixel_x, - xFixed pixel_y, - xFixed top, - xFixed bottom, - PixelWalk *pw, - int depth) -{ - int alpha; - - /* - * Sharp polygons are different, alpha is 1 if the - * area includes the pixel origin, else zero, in - * the above figure, only 'a' has alpha 1 - */ - if (depth == 1) - { - alpha = 0; - if (top == pixel_y && pw->upper.x != pixel_x) - alpha = 1; - } - else - { - RationalPoint upper = pw->upper; - RationalPoint lower = pw->lower; - int bottom_alpha, top_alpha; - - bottom_alpha = 0; - if (bottom < upper.y) { - if (upper.x > lower.x) - bottom_alpha = RectAlpha(pixel_y, pixel_y, bottom, depth); - } else { - if (bottom < lower.y) - pixelWalkMovePointToY(pw, &lower, bottom); - bottom_alpha = AlphaAboveLeft(bottom - pixel_y, - upper.x - pixel_x, - upper.y - pixel_y, - lower.x - pixel_x, - lower.y - pixel_y, - depth); - } - - top_alpha = 0; - if (top < upper.y) { - if (upper.x > lower.x) - top_alpha = RectAlpha(pixel_y, pixel_y, top, depth); - } else { - if (top < lower.y) - pixelWalkMovePointToY(pw, &lower, top); - top_alpha = AlphaAboveLeft(top - pixel_y, - upper.x - pixel_x, - upper.y - pixel_y, - lower.x - pixel_x, - lower.y - pixel_y, - depth); - } - - alpha = bottom_alpha - top_alpha; - } - - return alpha; -} - -#define INCREMENT_X_AND_PIXEL \ -{ \ - pixel_x += xFixed1; \ - (*mask.over) (&mask); \ -} - -#define saturateAdd(t, a, b) (((t) = (a) + (b)), \ - ((uint8_t) ((t) | (0 - ((t) >> 8))))) - -#define addAlpha(mask, depth, alpha, temp) (\ - (*(mask)->store) ((mask), (alpha == (1 << depth) - 1) ? \ - 0xff000000 : \ - (saturateAdd (temp, \ - alpha << (8 - depth), \ - (*(mask)->fetch) (mask) >> 24) << 24)) \ -) - -void -IcRasterizeTrapezoid (IcImage *pMask, - const IcTrapezoid *pTrap, - int x_off, - int y_off) -{ - IcTrapezoid trap = *pTrap; - int alpha, temp; - - IcCompositeOperand mask; - - int depth = pMask->pixels->depth; - int max_alpha = (1 << depth) - 1; - int buf_width = pMask->pixels->width; - - xFixed x_off_fixed = IntToxFixed(x_off); - xFixed y_off_fixed = IntToxFixed(y_off); - xFixed buf_width_fixed = IntToxFixed(buf_width); - - PixelWalk left, right; - xFixed pixel_x, pixel_y; - xFixed first_right_x; - xFixed y, y_next; - - /* trap.left and trap.right must be non-horizontal */ - if (trap.left.p1.y == trap.left.p2.y - || trap.right.p1.y == trap.right.p2.y) { - return; - } - - trap.top += y_off_fixed; - trap.bottom += y_off_fixed; - trap.left.p1.x += x_off_fixed; - trap.left.p1.y += y_off_fixed; - trap.left.p2.x += x_off_fixed; - trap.left.p2.y += y_off_fixed; - trap.right.p1.x += x_off_fixed; - trap.right.p1.y += y_off_fixed; - trap.right.p2.x += x_off_fixed; - trap.right.p2.y += y_off_fixed; - - pixelWalkInit(&left, &trap.left, trap.top, trap.bottom); - pixelWalkInit(&right, &trap.right, trap.top, trap.bottom); - - if (!IcBuildCompositeOperand (pMask, &mask, 0, xFixedToInt (trap.top), 0, 0)) - return; - - for (y = trap.top; y < trap.bottom; y = y_next) - { - pixel_y = xFixedFloor (y); - y_next = pixel_y + xFixed1; - if (y_next > trap.bottom) - y_next = trap.bottom; - - ASSERT (left.row.top.y == y); - ASSERT (right.row.top.y == y); - - pixel_x = xFixedFloor(left.col.left.x); - - /* - * Walk pixels on this row that are left of the - * first possibly lit pixel - * - * pixelWalkNextPixel will change .row.top.y - * when the last pixel covered by the edge - * is passed - */ - - first_right_x = right.col.left.x; - while (right.row.top.y == pixel_y && first_right_x < pixel_x) - { - /* these are empty */ - pixelWalkNextPixel (&right); - /* step over */ - first_right_x += xFixed1; - } - - (*mask.set) (&mask, xFixedToInt (pixel_x), xFixedToInt (y)); - - /* - * Walk pixels on this row intersected by only trap.left - * - */ - while (left.row.top.y == pixel_y && pixel_x < first_right_x) - { - alpha = (RectAlpha (pixel_y, y, y_next, depth) - - PixelAlpha(pixel_x, pixel_y, y, y_next, &left, depth)); - if (alpha > 0) - { - if (0 <= pixel_x && pixel_x < buf_width_fixed) - addAlpha (&mask, depth, alpha, temp); - } - - /* - * Step right - */ - pixelWalkNextPixel(&left); - INCREMENT_X_AND_PIXEL; - } - - /* - * Either pixels are covered by both edges or - * there are fully covered pixels on this row - */ - if (pixel_x == first_right_x) - { - /* - * Now walk the pixels on this row intersected - * by both edges - */ - while (left.row.top.y == pixel_y && right.row.top.y == pixel_y) - { - alpha = (PixelAlpha(pixel_x, pixel_y, y, y_next, &right, depth) - - PixelAlpha(pixel_x, pixel_y, y, y_next, &left, depth)); - if (alpha > 0) - { - ASSERT (0 <= alpha && alpha <= max_alpha); - if (0 <= pixel_x && pixel_x < buf_width_fixed) - addAlpha (&mask, depth, alpha, temp); - } - pixelWalkNextPixel(&left); - pixelWalkNextPixel(&right); - INCREMENT_X_AND_PIXEL; - } - } - else - { - /* - * Fully covered pixels simply saturate - */ - alpha = RectAlpha (pixel_y, y, y_next, depth); - if (alpha == max_alpha) - { - while (pixel_x < first_right_x) - { - if (0 <= pixel_x && pixel_x < buf_width_fixed) - (*mask.store) (&mask, 0xff000000); - INCREMENT_X_AND_PIXEL; - } - } - else - { - while (pixel_x < first_right_x) - { - ASSERT (0 <= alpha && alpha <= max_alpha); - if (0 <= pixel_x && pixel_x < buf_width_fixed) - addAlpha (&mask, depth, alpha, temp); - INCREMENT_X_AND_PIXEL; - } - } - } - - /* - * Finally, pixels intersected only by trap.right - */ - while (right.row.top.y == pixel_y) - { - alpha = PixelAlpha(pixel_x, pixel_y, y, y_next, &right, depth); - if (alpha > 0) - { - if (0 <= pixel_x && pixel_x < buf_width_fixed) - addAlpha (&mask, depth, alpha, temp); - } - pixelWalkNextPixel(&right); - INCREMENT_X_AND_PIXEL; - } - - /* - * If the right edge is now left of the left edge, - * the left edge will end up only partially walked, - * walk it the rest of the way - */ - while (left.row.top.y == pixel_y) - pixelWalkNextPixel(&left); - } -} - -/* Some notes on walking while keeping track of errors in both dimensions: - -That's really pretty easy. Your bresenham should be walking sub-pixel -coordinates rather than pixel coordinates. Now you can calculate the -sub-pixel Y coordinate for any arbitrary sub-pixel X coordinate (or vice -versa). - - ey: y error term (distance from current Y sub-pixel to line) * dx - ex: x error term (distance from current X sub-pixel to line) * dy - dx: difference of X coordinates for line endpoints - dy: difference of Y coordinates for line endpoints - x: current fixed-point X coordinate - y: current fixed-point Y coordinate - -One of ey or ex will always be zero, depending on whether the distance to -the line was measured horizontally or vertically. - -In moving from x, y to x1, y1: - - (x1 + e1x/dy) - (x + ex/dy) dx - --------------------------- = -- - (y1 + e1y/dx) - (y + ey/dx) dy - - (x1dy + e1x) - (xdy + ex) = (y1dx + e1y) - (ydx + ey) - - dy(x1 - x) + (e1x - ex) = dx(y1-y) + (e1y - ey) - -So, if you know y1 and want to know x1: - - Set e1y to zero and compute the error from x: - - oex = dx(y1 - y) - ey + ex - - Compute the number of whole pixels to get close to the line: - - wx = oex / dy - - Set x1: - - Now compute the e1x: - - e1x = oex - wx * dy - -A similar operation moves to a known y1. Note that this computation (in -general) requires 64 bit arithmetic. I suggest just using the available -64 bit datatype for now, we can optimize the common cases with a few -conditionals. -*/ - -/* Here's a large-step Bresenham for jogging my memory. - -void large_bresenham_x_major(x1, y1, x2, y2, x_inc) -{ - int x, y, dx, dy, m; - int em_dx, ey_dx; - - dx = x2 - x1; - dy = y2 - y1; - - m = (x_inc * dy) / dx; - em_dx = (x_inc * dy) - m * dx; - - x = x1; - y = y1; - ey = 0; - - set(x,y); - - while (x < x2) { - x += x_inc; - y += m; - ey_dx += em_dx; - if (ey_dx > dx_2) { - y++; - ey_dx -= dx; - } - set(x,y); - } -} - -*/ - -/* Here are the latest, simplified equations for computing trapezoid - coverage of a pixel: - - alpha_from_area(A) = round(2**depth-1 * A) - - alpha(o) = 2**depth-1 - - alpha(a) = alpha_from_area(area(a)) - - alpha(ab) = alpha_from_area(area(ab)) - - alpha(b) = alpha(ab) - alpha (a) - - alpha(abc) = alpha_from_area(area(abc)) - - alpha(c) = alpha(abc) - alpha(ab) - - alpha(ad) = alpha_from_area(area(ad)) - - alpha (d) = alpha(ad) - alpha (a) - - alpha (abde) = alpha_from_area(area(abde)) - - alpha (de) = alpha (abde) - alpha (ab) - - alpha (e) = alpha (de) - alpha (d) - - alpha (abcdef) = alpha_from_area(area(abcdef)) - - alpha (def) = alpha (abcdef) - alpha (abc) - - alpha (f) = alpha (def) - alpha (de) - - alpha (adg) = alpha_from_area(area(adg)) - - alpha (g) = alpha (adg) - alpha (ad) - - alpha (abdegh) = alpha_from_area(area(abdegh)) - - alpha (gh) = alpha (abdegh) - alpha (abde) - - alpha (h) = alpha (gh) - alpha (g) - - alpha (abcdefghi) = alpha_from_area(area(abcdefghi)) = - alpha_from_area(area(o)) = alpha_from_area(1) = alpha(o) - - alpha (ghi) = alpha (abcdefghi) - alpha (abcdef) - - alpha (i) = alpha (ghi) - alpha (gh) -*/ - -/* Latest thoughts from Keith on implementing area/alpha computations: - -*** 1.16 * 1.16 -> 1.31 *** -#define AREA_MULT(w,h) ((w)&(h) == 0x10000 ? 0x80000000 : (((w)*(h) + 1) >> 1) - -*** (1.16 + 1.16) / 2 -> 1.16 *** -#define WIDTH_AVG(x1,x2) (((x1) + (x2) + 1) >> 1) - -xFixed_1_31 -SubpixelArea (xFixed_1_16 x1, - xFixed_1_16 x2, - xFixed_1_16 y1, - xFixed_1_16 y2, - xFixed_1_16 bottom) - { - xFixed_1_16 x_trap; - xFixed_1_16 h_top, h_trap, h_bot; - xFixed_1_31 area; - - x_trap = WIDTH_AVG(x1,x2); - h_top = y1; - h_trap = (y2 - y1); - h_bot = (bottom - y2); - - area = AREA_MULT(x1, h_top) + - AREA_MULT(x_trap, h_trap) + - AREA_MULT(x2, h_bot); - - return area; - } - -To convert this xFixed_1_31 value to alpha using 32 bit arithmetic: - -int -AreaAlpha (xFixed_1_31 area, int depth) - { - return ((area >> bits) * ((1 << depth) - 1)) >> (31 - depth); - } - -Avoiding the branch bubble in the AREA_MULT could be done with either: - -area = (w * h + 1) >> 1; -area |= ((area - 1) & 0x80000000); - -or - #define AREA_MULT(w,h) ((((w)*(h) + 1) >> 1) | ((w)&(h)&0x10000) << 15) - -depending on your preference, the first takes one less operation but -can't be expressed as a macro; the second takes a large constant which may -require an additional instruction on some processors. The differences -will be swamped by the cost of the multiply. - -*/ diff --git a/pixman/src/ictri.c b/pixman/src/ictri.c deleted file mode 100644 index 472c1efee..000000000 --- a/pixman/src/ictri.c +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Copyright © 2002 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "icint.h" - -static void -IcPointFixedBounds (int npoint, const IcPointFixed *points, PixRegionBox *bounds) -{ - bounds->x1 = xFixedToInt (points->x); - bounds->x2 = xFixedToInt (xFixedCeil (points->x)); - bounds->y1 = xFixedToInt (points->y); - bounds->y2 = xFixedToInt (xFixedCeil (points->y)); - points++; - npoint--; - while (npoint-- > 0) - { - int x1 = xFixedToInt (points->x); - int x2 = xFixedToInt (xFixedCeil (points->x)); - int y1 = xFixedToInt (points->y); - int y2 = xFixedToInt (xFixedCeil (points->y)); - - if (x1 < bounds->x1) - bounds->x1 = x1; - else if (x2 > bounds->x2) - bounds->x2 = x2; - if (y1 < bounds->y1) - bounds->y1 = y1; - else if (y2 > bounds->y2) - bounds->y2 = y2; - points++; - } -} - -static void -IcTriangleBounds (int ntri, const IcTriangle *tris, PixRegionBox *bounds) -{ - IcPointFixedBounds (ntri * 3, (IcPointFixed *) tris, bounds); -} - -static void -IcRasterizeTriangle (IcImage *image, - const IcTriangle *tri, - int x_off, - int y_off) -{ - const IcPointFixed *top, *left, *right, *t; - IcTrapezoid trap[2]; - - top = &tri->p1; - left = &tri->p2; - right = &tri->p3; - if (left->y < top->y) { - t = left; left = top; top = t; - } - if (right->y < top->y) { - t = right; right = top; top = t; - } - /* XXX: This code is broken, left and right must be determined by - comparing the angles of the two edges, (eg. we can only compare - X coordinates if we've already intersected each edge with the - same Y coordinate) */ - if (right->x < left->x) { - t = right; right = left; left = t; - } - - /* - * Two cases: - * - * + + - * / \ / \ - * / \ / \ - * / + + \ - * / -- -- \ - * / -- -- \ - * / --- --- \ - * +-- --+ - */ - - trap[0].top = top->y; - - trap[0].left.p1.x = top->x; - trap[0].left.p1.y = trap[0].top; - trap[0].left.p2.x = left->x; - trap[0].left.p2.y = left->y; - - trap[0].right.p1 = trap[0].left.p1; - trap[0].right.p2.x = right->x; - trap[0].right.p2.y = right->y; - - if (right->y < left->y) - { - trap[0].bottom = trap[0].right.p2.y; - - trap[1].top = trap[0].bottom; - trap[1].bottom = trap[0].left.p2.y; - - trap[1].left = trap[0].left; - trap[1].right.p1 = trap[0].right.p2; - trap[1].right.p2 = trap[0].left.p2; - } - else - { - trap[0].bottom = trap[0].left.p2.y; - - trap[1].top = trap[0].bottom; - trap[1].bottom = trap[0].right.p2.y; - - trap[1].right = trap[0].right; - trap[1].left.p1 = trap[0].left.p2; - trap[1].left.p2 = trap[0].right.p2; - } - if (trap[0].top != trap[0].bottom) - IcRasterizeTrapezoid (image, &trap[0], x_off, y_off); - if (trap[1].top != trap[1].bottom) - IcRasterizeTrapezoid (image, &trap[1], x_off, y_off); -} - -void -IcCompositeTriangles (IcOperator op, - IcImage *src, - IcImage *dst, - int xSrc, - int ySrc, - const IcTriangle *tris, - int ntris) -{ - PixRegionBox bounds; - IcImage *image = NULL; - int xDst, yDst; - int xRel, yRel; - IcFormat *format; - - xDst = tris[0].p1.x >> 16; - yDst = tris[0].p1.y >> 16; - - format = IcFormatCreate (IcFormatNameA8); - - if (format) - { - IcTriangleBounds (ntris, tris, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - return; - image = IcCreateAlphaPicture (dst, - format, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!image) - return; - } - for (; ntris; ntris--, tris++) - { - if (!format) - { - IcTriangleBounds (1, tris, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - continue; - image = IcCreateAlphaPicture (dst, - format, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!image) - break; - } - IcRasterizeTriangle (image, tris, -bounds.x1, -bounds.y1); - if (!format) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - IcComposite (op, src, image, dst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - IcImageDestroy (image); - } - /* XXX adjust xSrc and ySrc */ - } - if (format) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - IcComposite (op, src, image, dst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - IcImageDestroy (image); - } - - IcFormatDestroy (format); -} - -void -IcCompositeTriStrip (IcOperator op, - IcImage *src, - IcImage *dst, - int xSrc, - int ySrc, - const IcPointFixed *points, - int npoints) -{ - IcTriangle tri; - PixRegionBox bounds; - IcImage *image = NULL; - int xDst, yDst; - int xRel, yRel; - IcFormat *format; - - xDst = points[0].x >> 16; - yDst = points[0].y >> 16; - - format = IcFormatCreate (IcFormatNameA8); - - if (npoints < 3) - return; - if (format) - { - IcPointFixedBounds (npoints, points, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - return; - image = IcCreateAlphaPicture (dst, - format, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!image) - return; - } - for (; npoints >= 3; npoints--, points++) - { - tri.p1 = points[0]; - tri.p2 = points[1]; - tri.p3 = points[2]; - if (!format) - { - IcTriangleBounds (1, &tri, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - continue; - image = IcCreateAlphaPicture (dst, - format, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!image) - continue; - } - IcRasterizeTriangle (image, &tri, -bounds.x1, -bounds.y1); - if (!format) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - IcComposite (op, src, image, dst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - IcImageDestroy (image); - } - } - if (format) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - IcComposite (op, src, image, dst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - IcImageDestroy (image); - } - - IcFormatDestroy (format); -} - -void -IcCompositeTriFan (IcOperator op, - IcImage *src, - IcImage *dst, - int xSrc, - int ySrc, - const IcPointFixed *points, - int npoints) -{ - IcTriangle tri; - PixRegionBox bounds; - IcImage *image = NULL; - const IcPointFixed *first; - int xDst, yDst; - int xRel, yRel; - IcFormat *format; - - xDst = points[0].x >> 16; - yDst = points[0].y >> 16; - - format = IcFormatCreate (IcFormatNameA8); - - if (npoints < 3) - return; - if (format) - { - IcPointFixedBounds (npoints, points, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - return; - image = IcCreateAlphaPicture (dst, - format, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!image) - return; - } - first = points++; - npoints--; - for (; npoints >= 2; npoints--, points++) - { - tri.p1 = *first; - tri.p2 = points[0]; - tri.p3 = points[1]; - if (!format) - { - IcTriangleBounds (1, &tri, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - continue; - image = IcCreateAlphaPicture (dst, - format, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!image) - continue; - } - IcRasterizeTriangle (image, &tri, -bounds.x1, -bounds.y1); - if (!format) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - IcComposite (op, src, image, dst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - IcImageDestroy (image); - } - } - if (format) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - IcComposite (op, src, image, dst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - IcImageDestroy (image); - } - - IcFormatDestroy (format); -} - diff --git a/pixman/src/icutil.c b/pixman/src/icutil.c deleted file mode 100644 index d94e25a2d..000000000 --- a/pixman/src/icutil.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Id: $ - * - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "icint.h" - -IcBits -IcReplicatePixel (Pixel p, int bpp) -{ - IcBits b = p; - - b &= IcFullMask (bpp); - while (bpp < IC_UNIT) - { - b |= b << bpp; - bpp <<= 1; - } - return b; -} - -#define O 0 -#define I IC_ALLONES - -const IcMergeRopRec IcMergeRopBits[16] = { - { O,O,O,O }, /* clear 0x0 0 */ - { I,O,O,O }, /* and 0x1 src AND dst */ - { I,O,I,O }, /* andReverse 0x2 src AND NOT dst */ - { O,O,I,O }, /* copy 0x3 src */ - { I,I,O,O }, /* andInverted 0x4 NOT src AND dst */ - { O,I,O,O }, /* noop 0x5 dst */ - { O,I,I,O }, /* xor 0x6 src XOR dst */ - { I,I,I,O }, /* or 0x7 src OR dst */ - { I,I,I,I }, /* nor 0x8 NOT src AND NOT dst */ - { O,I,I,I }, /* equiv 0x9 NOT src XOR dst */ - { O,I,O,I }, /* invert 0xa NOT dst */ - { I,I,O,I }, /* orReverse 0xb src OR NOT dst */ - { O,O,I,I }, /* copyInverted 0xc NOT src */ - { I,O,I,I }, /* orInverted 0xd NOT src OR dst */ - { I,O,O,I }, /* nand 0xe NOT src OR NOT dst */ - { O,O,O,I }, /* set 0xf 1 */ -}; - -/* - * Stipple masks are independent of bit/byte order as long - * as bitorder == byteorder. IC doesn't handle the case - * where these differ - */ -#define BitsMask(x,w) ((IC_ALLONES << ((x) & IC_MASK)) & \ - (IC_ALLONES >> ((IC_UNIT - ((x) + (w))) & IC_MASK))) - -#define Mask(x,w) BitsMask((x)*(w),(w)) - - -#define SelMask(b,n,w) ((((b) >> n) & 1) * Mask(n,w)) - -#define C1(b,w) \ - (SelMask(b,0,w)) - -#define C2(b,w) \ - (SelMask(b,0,w) | \ - SelMask(b,1,w)) - -#define C4(b,w) \ - (SelMask(b,0,w) | \ - SelMask(b,1,w) | \ - SelMask(b,2,w) | \ - SelMask(b,3,w)) - -#define C8(b,w) \ - (SelMask(b,0,w) | \ - SelMask(b,1,w) | \ - SelMask(b,2,w) | \ - SelMask(b,3,w) | \ - SelMask(b,4,w) | \ - SelMask(b,5,w) | \ - SelMask(b,6,w) | \ - SelMask(b,7,w)) - -#if IC_UNIT == 16 -#define icStipple16Bits 0 -#define icStipple8Bits 0 -static const IcBits icStipple4Bits[16] = { - C4( 0,4), C4( 1,4), C4( 2,4), C4( 3,4), C4( 4,4), C4( 5,4), - C4( 6,4), C4( 7,4), C4( 8,4), C4( 9,4), C4( 10,4), C4( 11,4), - C4( 12,4), C4( 13,4), C4( 14,4), C4( 15,4),}; -static const IcBits icStipple2Bits[4] = { - C2( 0,8), C2( 1,8), C2( 2,8), C2( 3,8), -}; -static const IcBits icStipple1Bits[2] = { - C1( 0,16), C1( 1,16), -}; -#endif -#if IC_UNIT == 32 -#define icStipple16Bits 0 -static const IcBits icStipple8Bits[256] = { - C8( 0,4), C8( 1,4), C8( 2,4), C8( 3,4), C8( 4,4), C8( 5,4), - C8( 6,4), C8( 7,4), C8( 8,4), C8( 9,4), C8( 10,4), C8( 11,4), - C8( 12,4), C8( 13,4), C8( 14,4), C8( 15,4), C8( 16,4), C8( 17,4), - C8( 18,4), C8( 19,4), C8( 20,4), C8( 21,4), C8( 22,4), C8( 23,4), - C8( 24,4), C8( 25,4), C8( 26,4), C8( 27,4), C8( 28,4), C8( 29,4), - C8( 30,4), C8( 31,4), C8( 32,4), C8( 33,4), C8( 34,4), C8( 35,4), - C8( 36,4), C8( 37,4), C8( 38,4), C8( 39,4), C8( 40,4), C8( 41,4), - C8( 42,4), C8( 43,4), C8( 44,4), C8( 45,4), C8( 46,4), C8( 47,4), - C8( 48,4), C8( 49,4), C8( 50,4), C8( 51,4), C8( 52,4), C8( 53,4), - C8( 54,4), C8( 55,4), C8( 56,4), C8( 57,4), C8( 58,4), C8( 59,4), - C8( 60,4), C8( 61,4), C8( 62,4), C8( 63,4), C8( 64,4), C8( 65,4), - C8( 66,4), C8( 67,4), C8( 68,4), C8( 69,4), C8( 70,4), C8( 71,4), - C8( 72,4), C8( 73,4), C8( 74,4), C8( 75,4), C8( 76,4), C8( 77,4), - C8( 78,4), C8( 79,4), C8( 80,4), C8( 81,4), C8( 82,4), C8( 83,4), - C8( 84,4), C8( 85,4), C8( 86,4), C8( 87,4), C8( 88,4), C8( 89,4), - C8( 90,4), C8( 91,4), C8( 92,4), C8( 93,4), C8( 94,4), C8( 95,4), - C8( 96,4), C8( 97,4), C8( 98,4), C8( 99,4), C8(100,4), C8(101,4), - C8(102,4), C8(103,4), C8(104,4), C8(105,4), C8(106,4), C8(107,4), - C8(108,4), C8(109,4), C8(110,4), C8(111,4), C8(112,4), C8(113,4), - C8(114,4), C8(115,4), C8(116,4), C8(117,4), C8(118,4), C8(119,4), - C8(120,4), C8(121,4), C8(122,4), C8(123,4), C8(124,4), C8(125,4), - C8(126,4), C8(127,4), C8(128,4), C8(129,4), C8(130,4), C8(131,4), - C8(132,4), C8(133,4), C8(134,4), C8(135,4), C8(136,4), C8(137,4), - C8(138,4), C8(139,4), C8(140,4), C8(141,4), C8(142,4), C8(143,4), - C8(144,4), C8(145,4), C8(146,4), C8(147,4), C8(148,4), C8(149,4), - C8(150,4), C8(151,4), C8(152,4), C8(153,4), C8(154,4), C8(155,4), - C8(156,4), C8(157,4), C8(158,4), C8(159,4), C8(160,4), C8(161,4), - C8(162,4), C8(163,4), C8(164,4), C8(165,4), C8(166,4), C8(167,4), - C8(168,4), C8(169,4), C8(170,4), C8(171,4), C8(172,4), C8(173,4), - C8(174,4), C8(175,4), C8(176,4), C8(177,4), C8(178,4), C8(179,4), - C8(180,4), C8(181,4), C8(182,4), C8(183,4), C8(184,4), C8(185,4), - C8(186,4), C8(187,4), C8(188,4), C8(189,4), C8(190,4), C8(191,4), - C8(192,4), C8(193,4), C8(194,4), C8(195,4), C8(196,4), C8(197,4), - C8(198,4), C8(199,4), C8(200,4), C8(201,4), C8(202,4), C8(203,4), - C8(204,4), C8(205,4), C8(206,4), C8(207,4), C8(208,4), C8(209,4), - C8(210,4), C8(211,4), C8(212,4), C8(213,4), C8(214,4), C8(215,4), - C8(216,4), C8(217,4), C8(218,4), C8(219,4), C8(220,4), C8(221,4), - C8(222,4), C8(223,4), C8(224,4), C8(225,4), C8(226,4), C8(227,4), - C8(228,4), C8(229,4), C8(230,4), C8(231,4), C8(232,4), C8(233,4), - C8(234,4), C8(235,4), C8(236,4), C8(237,4), C8(238,4), C8(239,4), - C8(240,4), C8(241,4), C8(242,4), C8(243,4), C8(244,4), C8(245,4), - C8(246,4), C8(247,4), C8(248,4), C8(249,4), C8(250,4), C8(251,4), - C8(252,4), C8(253,4), C8(254,4), C8(255,4), -}; -static const IcBits icStipple4Bits[16] = { - C4( 0,8), C4( 1,8), C4( 2,8), C4( 3,8), C4( 4,8), C4( 5,8), - C4( 6,8), C4( 7,8), C4( 8,8), C4( 9,8), C4( 10,8), C4( 11,8), - C4( 12,8), C4( 13,8), C4( 14,8), C4( 15,8),}; -static const IcBits icStipple2Bits[4] = { - C2( 0,16), C2( 1,16), C2( 2,16), C2( 3,16), -}; -static const IcBits icStipple1Bits[2] = { - C1( 0,32), C1( 1,32), -}; -#endif -#if IC_UNIT == 64 -const IcBits icStipple16Bits[256] = { - C8( 0,4), C8( 1,4), C8( 2,4), C8( 3,4), C8( 4,4), C8( 5,4), - C8( 6,4), C8( 7,4), C8( 8,4), C8( 9,4), C8( 10,4), C8( 11,4), - C8( 12,4), C8( 13,4), C8( 14,4), C8( 15,4), C8( 16,4), C8( 17,4), - C8( 18,4), C8( 19,4), C8( 20,4), C8( 21,4), C8( 22,4), C8( 23,4), - C8( 24,4), C8( 25,4), C8( 26,4), C8( 27,4), C8( 28,4), C8( 29,4), - C8( 30,4), C8( 31,4), C8( 32,4), C8( 33,4), C8( 34,4), C8( 35,4), - C8( 36,4), C8( 37,4), C8( 38,4), C8( 39,4), C8( 40,4), C8( 41,4), - C8( 42,4), C8( 43,4), C8( 44,4), C8( 45,4), C8( 46,4), C8( 47,4), - C8( 48,4), C8( 49,4), C8( 50,4), C8( 51,4), C8( 52,4), C8( 53,4), - C8( 54,4), C8( 55,4), C8( 56,4), C8( 57,4), C8( 58,4), C8( 59,4), - C8( 60,4), C8( 61,4), C8( 62,4), C8( 63,4), C8( 64,4), C8( 65,4), - C8( 66,4), C8( 67,4), C8( 68,4), C8( 69,4), C8( 70,4), C8( 71,4), - C8( 72,4), C8( 73,4), C8( 74,4), C8( 75,4), C8( 76,4), C8( 77,4), - C8( 78,4), C8( 79,4), C8( 80,4), C8( 81,4), C8( 82,4), C8( 83,4), - C8( 84,4), C8( 85,4), C8( 86,4), C8( 87,4), C8( 88,4), C8( 89,4), - C8( 90,4), C8( 91,4), C8( 92,4), C8( 93,4), C8( 94,4), C8( 95,4), - C8( 96,4), C8( 97,4), C8( 98,4), C8( 99,4), C8(100,4), C8(101,4), - C8(102,4), C8(103,4), C8(104,4), C8(105,4), C8(106,4), C8(107,4), - C8(108,4), C8(109,4), C8(110,4), C8(111,4), C8(112,4), C8(113,4), - C8(114,4), C8(115,4), C8(116,4), C8(117,4), C8(118,4), C8(119,4), - C8(120,4), C8(121,4), C8(122,4), C8(123,4), C8(124,4), C8(125,4), - C8(126,4), C8(127,4), C8(128,4), C8(129,4), C8(130,4), C8(131,4), - C8(132,4), C8(133,4), C8(134,4), C8(135,4), C8(136,4), C8(137,4), - C8(138,4), C8(139,4), C8(140,4), C8(141,4), C8(142,4), C8(143,4), - C8(144,4), C8(145,4), C8(146,4), C8(147,4), C8(148,4), C8(149,4), - C8(150,4), C8(151,4), C8(152,4), C8(153,4), C8(154,4), C8(155,4), - C8(156,4), C8(157,4), C8(158,4), C8(159,4), C8(160,4), C8(161,4), - C8(162,4), C8(163,4), C8(164,4), C8(165,4), C8(166,4), C8(167,4), - C8(168,4), C8(169,4), C8(170,4), C8(171,4), C8(172,4), C8(173,4), - C8(174,4), C8(175,4), C8(176,4), C8(177,4), C8(178,4), C8(179,4), - C8(180,4), C8(181,4), C8(182,4), C8(183,4), C8(184,4), C8(185,4), - C8(186,4), C8(187,4), C8(188,4), C8(189,4), C8(190,4), C8(191,4), - C8(192,4), C8(193,4), C8(194,4), C8(195,4), C8(196,4), C8(197,4), - C8(198,4), C8(199,4), C8(200,4), C8(201,4), C8(202,4), C8(203,4), - C8(204,4), C8(205,4), C8(206,4), C8(207,4), C8(208,4), C8(209,4), - C8(210,4), C8(211,4), C8(212,4), C8(213,4), C8(214,4), C8(215,4), - C8(216,4), C8(217,4), C8(218,4), C8(219,4), C8(220,4), C8(221,4), - C8(222,4), C8(223,4), C8(224,4), C8(225,4), C8(226,4), C8(227,4), - C8(228,4), C8(229,4), C8(230,4), C8(231,4), C8(232,4), C8(233,4), - C8(234,4), C8(235,4), C8(236,4), C8(237,4), C8(238,4), C8(239,4), - C8(240,4), C8(241,4), C8(242,4), C8(243,4), C8(244,4), C8(245,4), - C8(246,4), C8(247,4), C8(248,4), C8(249,4), C8(250,4), C8(251,4), - C8(252,4), C8(253,4), C8(254,4), C8(255,4), -}; -static const IcBits icStipple8Bits[256] = { - C8( 0,8), C8( 1,8), C8( 2,8), C8( 3,8), C8( 4,8), C8( 5,8), - C8( 6,8), C8( 7,8), C8( 8,8), C8( 9,8), C8( 10,8), C8( 11,8), - C8( 12,8), C8( 13,8), C8( 14,8), C8( 15,8), C8( 16,8), C8( 17,8), - C8( 18,8), C8( 19,8), C8( 20,8), C8( 21,8), C8( 22,8), C8( 23,8), - C8( 24,8), C8( 25,8), C8( 26,8), C8( 27,8), C8( 28,8), C8( 29,8), - C8( 30,8), C8( 31,8), C8( 32,8), C8( 33,8), C8( 34,8), C8( 35,8), - C8( 36,8), C8( 37,8), C8( 38,8), C8( 39,8), C8( 40,8), C8( 41,8), - C8( 42,8), C8( 43,8), C8( 44,8), C8( 45,8), C8( 46,8), C8( 47,8), - C8( 48,8), C8( 49,8), C8( 50,8), C8( 51,8), C8( 52,8), C8( 53,8), - C8( 54,8), C8( 55,8), C8( 56,8), C8( 57,8), C8( 58,8), C8( 59,8), - C8( 60,8), C8( 61,8), C8( 62,8), C8( 63,8), C8( 64,8), C8( 65,8), - C8( 66,8), C8( 67,8), C8( 68,8), C8( 69,8), C8( 70,8), C8( 71,8), - C8( 72,8), C8( 73,8), C8( 74,8), C8( 75,8), C8( 76,8), C8( 77,8), - C8( 78,8), C8( 79,8), C8( 80,8), C8( 81,8), C8( 82,8), C8( 83,8), - C8( 84,8), C8( 85,8), C8( 86,8), C8( 87,8), C8( 88,8), C8( 89,8), - C8( 90,8), C8( 91,8), C8( 92,8), C8( 93,8), C8( 94,8), C8( 95,8), - C8( 96,8), C8( 97,8), C8( 98,8), C8( 99,8), C8(100,8), C8(101,8), - C8(102,8), C8(103,8), C8(104,8), C8(105,8), C8(106,8), C8(107,8), - C8(108,8), C8(109,8), C8(110,8), C8(111,8), C8(112,8), C8(113,8), - C8(114,8), C8(115,8), C8(116,8), C8(117,8), C8(118,8), C8(119,8), - C8(120,8), C8(121,8), C8(122,8), C8(123,8), C8(124,8), C8(125,8), - C8(126,8), C8(127,8), C8(128,8), C8(129,8), C8(130,8), C8(131,8), - C8(132,8), C8(133,8), C8(134,8), C8(135,8), C8(136,8), C8(137,8), - C8(138,8), C8(139,8), C8(140,8), C8(141,8), C8(142,8), C8(143,8), - C8(144,8), C8(145,8), C8(146,8), C8(147,8), C8(148,8), C8(149,8), - C8(150,8), C8(151,8), C8(152,8), C8(153,8), C8(154,8), C8(155,8), - C8(156,8), C8(157,8), C8(158,8), C8(159,8), C8(160,8), C8(161,8), - C8(162,8), C8(163,8), C8(164,8), C8(165,8), C8(166,8), C8(167,8), - C8(168,8), C8(169,8), C8(170,8), C8(171,8), C8(172,8), C8(173,8), - C8(174,8), C8(175,8), C8(176,8), C8(177,8), C8(178,8), C8(179,8), - C8(180,8), C8(181,8), C8(182,8), C8(183,8), C8(184,8), C8(185,8), - C8(186,8), C8(187,8), C8(188,8), C8(189,8), C8(190,8), C8(191,8), - C8(192,8), C8(193,8), C8(194,8), C8(195,8), C8(196,8), C8(197,8), - C8(198,8), C8(199,8), C8(200,8), C8(201,8), C8(202,8), C8(203,8), - C8(204,8), C8(205,8), C8(206,8), C8(207,8), C8(208,8), C8(209,8), - C8(210,8), C8(211,8), C8(212,8), C8(213,8), C8(214,8), C8(215,8), - C8(216,8), C8(217,8), C8(218,8), C8(219,8), C8(220,8), C8(221,8), - C8(222,8), C8(223,8), C8(224,8), C8(225,8), C8(226,8), C8(227,8), - C8(228,8), C8(229,8), C8(230,8), C8(231,8), C8(232,8), C8(233,8), - C8(234,8), C8(235,8), C8(236,8), C8(237,8), C8(238,8), C8(239,8), - C8(240,8), C8(241,8), C8(242,8), C8(243,8), C8(244,8), C8(245,8), - C8(246,8), C8(247,8), C8(248,8), C8(249,8), C8(250,8), C8(251,8), - C8(252,8), C8(253,8), C8(254,8), C8(255,8), -}; -static const IcBits icStipple4Bits[16] = { - C4( 0,16), C4( 1,16), C4( 2,16), C4( 3,16), C4( 4,16), C4( 5,16), - C4( 6,16), C4( 7,16), C4( 8,16), C4( 9,16), C4( 10,16), C4( 11,16), - C4( 12,16), C4( 13,16), C4( 14,16), C4( 15,16),}; -static const IcBits icStipple2Bits[4] = { - C2( 0,32), C2( 1,32), C2( 2,32), C2( 3,32), -}; -#define icStipple1Bits 0 -#endif - -const IcBits * -IcStippleTable(int bits) -{ - switch (bits) { - case 1: - return icStipple1Bits; - case 2: - return icStipple2Bits; - case 4: - return icStipple4Bits; - case 8: - return icStipple8Bits; - } - return 0; -} diff --git a/pixman/src/pixman.h b/pixman/src/pixman.h deleted file mode 100644 index b2561629d..000000000 --- a/pixman/src/pixman.h +++ /dev/null @@ -1,165 +0,0 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ -/* $Id: pixman.h,v 1.5 2003-07-30 17:36:50 cworth Exp $ */ - -#ifndef _PIXREGION_H_ -#define _PIXREGION_H_ - -#ifdef _PIXREGIONINT_H_ -#include <slim_export.h> -#else -#include <slim_import.h> -#endif - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -typedef struct _PixRegion PixRegion; - -typedef struct _PixRegionBox { - short x1, y1, x2, y2; -} PixRegionBox; - -typedef enum { - PixRegionStatusFailure, - PixRegionStatusSuccess -} PixRegionStatus; - -/* creation/destruction */ - -extern PixRegion * __external_linkage -PixRegionCreate (void); - -extern PixRegion * __external_linkage -PixRegionCreateSimple (PixRegionBox *extents); - -extern void __external_linkage -PixRegionDestroy (PixRegion *region); - -/* manipulation */ - -extern void __external_linkage -PixRegionTranslate (PixRegion *region, int x, int y); - -extern PixRegionStatus __external_linkage -PixRegionCopy (PixRegion *dest, PixRegion *source); - -extern PixRegionStatus __external_linkage -PixRegionIntersect (PixRegion *newReg, PixRegion *reg1, PixRegion *reg2); - -extern PixRegionStatus __external_linkage -PixRegionUnion (PixRegion *newReg, PixRegion *reg1, PixRegion *reg2); - -extern PixRegionStatus __external_linkage -PixRegionUnionRect(PixRegion *dest, PixRegion *source, - int x, int y, unsigned int width, unsigned int height); - -extern PixRegionStatus __external_linkage -PixRegionSubtract (PixRegion *regD, PixRegion *regM, PixRegion *regS); - -extern PixRegionStatus __external_linkage -PixRegionInverse (PixRegion *newReg, PixRegion *reg1, PixRegionBox *invRect); - -/* XXX: Need to fix this so it doesn't depend on an X data structure -extern PixRegion * __external_linkage -RectsToPixRegion (int nrects, xRectanglePtr prect, int ctype); -*/ - -/* querying */ - -/* XXX: These should proably be combined: PixRegionGetRects? */ -extern int __external_linkage -PixRegionNumRects (PixRegion *region); - -extern PixRegionBox * __external_linkage -PixRegionRects (PixRegion *region); - -/* XXX: Change to an enum */ -#define rgnOUT 0 -#define rgnIN 1 -#define rgnPART 2 - -extern int __external_linkage -PixRegionPointInRegion (PixRegion *region, int x, int y, PixRegionBox *box); - -extern int __external_linkage -PixRegionRectIn (PixRegion *PixRegion, PixRegionBox *prect); - -extern int __external_linkage -PixRegionNotEmpty (PixRegion *region); - -extern PixRegionBox * __external_linkage -PixRegionExtents (PixRegion *region); - -/* mucking around */ - -/* WARNING: calling PixRegionAppend may leave dest as an invalid - region. Follow-up with PixRegionValidate to fix it up. */ -extern PixRegionStatus __external_linkage -PixRegionAppend (PixRegion *dest, PixRegion *region); - -extern PixRegionStatus __external_linkage -PixRegionValidate (PixRegion *badreg, int *pOverlap); - -/* Unclassified functionality - * XXX: Do all of these need to be exported? - */ - -extern void __external_linkage -PixRegionReset (PixRegion *region, PixRegionBox *pBox); - -extern void __external_linkage -PixRegionEmpty (PixRegion *region); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#undef __external_linkage - -#endif /* _PIXREGION_H_ */ diff --git a/pixman/src/pixregion.c b/pixman/src/pixregion.c deleted file mode 100644 index 5c1400f63..000000000 --- a/pixman/src/pixregion.c +++ /dev/null @@ -1,2547 +0,0 @@ -/*********************************************************** - -Copyright 1987, 1988, 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987, 1988, 1989 by -Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - -#include <stdlib.h> -#include <limits.h> -#include <string.h> - -#include "pixregionint.h" -#include <slim_internal.h> - -#if defined (__GNUC__) && !defined (NO_INLINES) -#define INLINE __inline -#else -#define INLINE -#endif - -#undef assert -#ifdef DEBUG -#define assert(expr) {if (!(expr)) \ - FatalError("Assertion failed file %s, line %d: expr\n", \ - __FILE__, __LINE__); } -#else -#define assert(expr) -#endif - -#define good(reg) assert(PixRegionValidRegion(reg)) - -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#define MAX(a,b) ((a) > (b) ? (a) : (b)) - -static PixRegionBox PixRegionEmptyBox = {0, 0, 0, 0}; -static PixRegionData PixRegionEmptyData = {0, 0}; - -static PixRegionData PixRegionBrokenData = {0, 0}; -static PixRegion PixRegionBrokenRegion = { { 0, 0, 0, 0 }, &PixRegionBrokenData }; - -static PixRegionStatus -PixRegionBreak (PixRegion *pReg); - -static void -PixRegionInit (PixRegion *region, PixRegionBox *rect); - -static void -PixRegionUninit (PixRegion *region); - -slim_hidden_proto(PixRegionCreateSimple) -slim_hidden_proto(PixRegionCopy) -slim_hidden_proto(PixRegionUnion) - -/* - * The functions in this file implement the Region abstraction used extensively - * throughout the X11 sample server. A Region is simply a set of disjoint - * (non-overlapping) rectangles, plus an "extent" rectangle which is the - * smallest single rectangle that contains all the non-overlapping rectangles. - * - * A Region is implemented as a "y-x-banded" array of rectangles. This array - * imposes two degrees of order. First, all rectangles are sorted by top side - * y coordinate first (y1), and then by left side x coordinate (x1). - * - * Furthermore, the rectangles are grouped into "bands". Each rectangle in a - * band has the same top y coordinate (y1), and each has the same bottom y - * coordinate (y2). Thus all rectangles in a band differ only in their left - * and right side (x1 and x2). Bands are implicit in the array of rectangles: - * there is no separate list of band start pointers. - * - * The y-x band representation does not minimize rectangles. In particular, - * if a rectangle vertically crosses a band (the rectangle has scanlines in - * the y1 to y2 area spanned by the band), then the rectangle may be broken - * down into two or more smaller rectangles stacked one atop the other. - * - * ----------- ----------- - * | | | | band 0 - * | | -------- ----------- -------- - * | | | | in y-x banded | | | | band 1 - * | | | | form is | | | | - * ----------- | | ----------- -------- - * | | | | band 2 - * -------- -------- - * - * An added constraint on the rectangles is that they must cover as much - * horizontal area as possible: no two rectangles within a band are allowed - * to touch. - * - * Whenever possible, bands will be merged together to cover a greater vertical - * distance (and thus reduce the number of rectangles). Two bands can be merged - * only if the bottom of one touches the top of the other and they have - * rectangles in the same places (of the same width, of course). - * - * Adam de Boor wrote most of the original region code. Joel McCormack - * substantially modified or rewrote most of the core arithmetic routines, and - * added PixRegionValidate in order to support several speed improvements to - * PixRegionValidateTree. Bob Scheifler changed the representation to be more - * compact when empty or a single rectangle, and did a bunch of gratuitous - * reformatting. Carl Worth did further gratuitous reformatting while re-merging - * the server and client region code into libpixregion. - */ - -/* true iff two Boxes overlap */ -#define EXTENTCHECK(r1,r2) \ - (!( ((r1)->x2 <= (r2)->x1) || \ - ((r1)->x1 >= (r2)->x2) || \ - ((r1)->y2 <= (r2)->y1) || \ - ((r1)->y1 >= (r2)->y2) ) ) - -/* true iff (x,y) is in Box */ -#define INBOX(r,x,y) \ - ( ((r)->x2 > x) && \ - ((r)->x1 <= x) && \ - ((r)->y2 > y) && \ - ((r)->y1 <= y) ) - -/* true iff Box r1 contains Box r2 */ -#define SUBSUMES(r1,r2) \ - ( ((r1)->x1 <= (r2)->x1) && \ - ((r1)->x2 >= (r2)->x2) && \ - ((r1)->y1 <= (r2)->y1) && \ - ((r1)->y2 >= (r2)->y2) ) - -#define allocData(n) malloc(PIXREGION_SZOF(n)) -#define freeData(reg) if ((reg)->data && (reg)->data->size) free((reg)->data) - -#define RECTALLOC_BAIL(pReg,n,bail) \ -if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \ - if (!PixRegionRectAlloc(pReg, n)) { goto bail; } - -#define RECTALLOC(pReg,n) \ -if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \ - if (!PixRegionRectAlloc(pReg, n)) { return PixRegionStatusFailure; } - -#define ADDRECT(pNextRect,nx1,ny1,nx2,ny2) \ -{ \ - pNextRect->x1 = nx1; \ - pNextRect->y1 = ny1; \ - pNextRect->x2 = nx2; \ - pNextRect->y2 = ny2; \ - pNextRect++; \ -} - -#define NEWRECT(pReg,pNextRect,nx1,ny1,nx2,ny2) \ -{ \ - if (!(pReg)->data || ((pReg)->data->numRects == (pReg)->data->size))\ - { \ - if (!PixRegionRectAlloc(pReg, 1)) \ - return PixRegionStatusFailure; \ - pNextRect = PIXREGION_TOP(pReg); \ - } \ - ADDRECT(pNextRect,nx1,ny1,nx2,ny2); \ - pReg->data->numRects++; \ - assert(pReg->data->numRects<=pReg->data->size); \ -} - - -#define DOWNSIZE(reg,numRects) \ -if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \ -{ \ - PixRegionData * NewData; \ - NewData = (PixRegionData *)realloc((reg)->data, PIXREGION_SZOF(numRects)); \ - if (NewData) \ - { \ - NewData->size = (numRects); \ - (reg)->data = NewData; \ - } \ -} - - -#ifdef DEBUG -int -PixRegionPrintRegion(rgn) - PixRegion * rgn; -{ - int num, size; - int i; - PixRegionBox * rects; - - num = PIXREGION_NUM_RECTS(rgn); - size = PIXREGION_SIZE(rgn); - rects = PIXREGION_RECTS(rgn); - ErrorF("num: %d size: %d\n", num, size); - ErrorF("extents: %d %d %d %d\n", - rgn->extents.x1, rgn->extents.y1, rgn->extents.x2, rgn->extents.y2); - for (i = 0; i < num; i++) - ErrorF("%d %d %d %d \n", - rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2); - ErrorF("\n"); - return(num); -} - - -PixRegionStatus -PixRegionsEqual(reg1, reg2) - PixRegion * reg1; - PixRegion * reg2; -{ - int i; - PixRegionBox * rects1, rects2; - - if (reg1->extents.x1 != reg2->extents.x1) return PixRegionStatusFailure; - if (reg1->extents.x2 != reg2->extents.x2) return PixRegionStatusFailure; - if (reg1->extents.y1 != reg2->extents.y1) return PixRegionStatusFailure; - if (reg1->extents.y2 != reg2->extents.y2) return PixRegionStatusFailure; - if (PIXREGION_NUM_RECTS(reg1) != PIXREGION_NUM_RECTS(reg2)) return PixRegionStatusFailure; - - rects1 = PIXREGION_RECTS(reg1); - rects2 = PIXREGION_RECTS(reg2); - for (i = 0; i != PIXREGION_NUM_RECTS(reg1); i++) { - if (rects1[i].x1 != rects2[i].x1) return PixRegionStatusFailure; - if (rects1[i].x2 != rects2[i].x2) return PixRegionStatusFailure; - if (rects1[i].y1 != rects2[i].y1) return PixRegionStatusFailure; - if (rects1[i].y2 != rects2[i].y2) return PixRegionStatusFailure; - } - return PixRegionStatusSuccess; -} - -PixRegionStatus -PixRegionValidRegion(reg) - PixRegion * reg; -{ - int i, numRects; - - if ((reg->extents.x1 > reg->extents.x2) || - (reg->extents.y1 > reg->extents.y2)) - return PixRegionStatusFailure; - numRects = PIXREGION_NUM_RECTS(reg); - if (!numRects) - return ((reg->extents.x1 == reg->extents.x2) && - (reg->extents.y1 == reg->extents.y2) && - (reg->data->size || (reg->data == &PixRegionEmptyData))); - else if (numRects == 1) - return (!reg->data); - else - { - PixRegionBox * pboxP, pboxN; - PixRegionBox box; - - pboxP = PIXREGION_RECTS(reg); - box = *pboxP; - box.y2 = pboxP[numRects-1].y2; - pboxN = pboxP + 1; - for (i = numRects; --i > 0; pboxP++, pboxN++) - { - if ((pboxN->x1 >= pboxN->x2) || - (pboxN->y1 >= pboxN->y2)) - return PixRegionStatusFailure; - if (pboxN->x1 < box.x1) - box.x1 = pboxN->x1; - if (pboxN->x2 > box.x2) - box.x2 = pboxN->x2; - if ((pboxN->y1 < pboxP->y1) || - ((pboxN->y1 == pboxP->y1) && - ((pboxN->x1 < pboxP->x2) || (pboxN->y2 != pboxP->y2)))) - return PixRegionStatusFailure; - } - return ((box.x1 == reg->extents.x1) && - (box.x2 == reg->extents.x2) && - (box.y1 == reg->extents.y1) && - (box.y2 == reg->extents.y2)); - } -} - -#endif /* DEBUG */ - - -/* Create a new empty region */ -PixRegion * -PixRegionCreate (void) -{ - return PixRegionCreateSimple (NULL); -} - -/***************************************************************** - * PixRegionCreateSimple (extents) - * This routine creates a PixRegion for a simple - * rectangular region. - *****************************************************************/ -PixRegion * -PixRegionCreateSimple (PixRegionBox *extents) -{ - PixRegion *region; - - region = malloc (sizeof (PixRegion)); - if (region == NULL) - return &PixRegionBrokenRegion; - - PixRegionInit (region, extents); - - return region; -} -slim_hidden_def(PixRegionCreateSimple); - -/***************************************************************** - * RegionInit(pReg, rect, size) - * Outer region rect is statically allocated. - *****************************************************************/ - -static void -PixRegionInit(PixRegion *region, PixRegionBox *extents) -{ - if (extents) - { - region->extents = *extents; - region->data = NULL; - } - else - { - region->extents = PixRegionEmptyBox; - region->data = &PixRegionEmptyData; - } -} - -static void -PixRegionUninit (PixRegion *region) -{ - good (region); - freeData (region); -} - -void -PixRegionDestroy (PixRegion *region) -{ - PixRegionUninit (region); - - if (region != &PixRegionBrokenRegion) - free (region); -} - -int -PixRegionNumRects (PixRegion *region) -{ - return PIXREGION_NUM_RECTS (region); -} - -PixRegionBox * -PixRegionRects (PixRegion *region) -{ - return PIXREGION_RECTS (region); -} - -static PixRegionStatus -PixRegionBreak (PixRegion *region) -{ - freeData (region); - region->extents = PixRegionEmptyBox; - region->data = &PixRegionBrokenData; - return PixRegionStatusFailure; -} - -static PixRegionStatus -PixRegionRectAlloc(PixRegion * region, int n) -{ - PixRegionData *data; - - if (!region->data) - { - n++; - region->data = allocData(n); - if (!region->data) - return PixRegionBreak (region); - region->data->numRects = 1; - *PIXREGION_BOXPTR(region) = region->extents; - } - else if (!region->data->size) - { - region->data = allocData(n); - if (!region->data) - return PixRegionBreak (region); - region->data->numRects = 0; - } - else - { - if (n == 1) - { - n = region->data->numRects; - if (n > 500) /* XXX pick numbers out of a hat */ - n = 250; - } - n += region->data->numRects; - data = (PixRegionData *)realloc(region->data, PIXREGION_SZOF(n)); - if (!data) - return PixRegionBreak (region); - region->data = data; - } - region->data->size = n; - return PixRegionStatusSuccess; -} - -PixRegionStatus -PixRegionCopy(PixRegion *dst, PixRegion *src) -{ - good(dst); - good(src); - if (dst == src) - return PixRegionStatusSuccess; - dst->extents = src->extents; - if (!src->data || !src->data->size) - { - freeData(dst); - dst->data = src->data; - return PixRegionStatusSuccess; - } - if (!dst->data || (dst->data->size < src->data->numRects)) - { - freeData(dst); - dst->data = allocData(src->data->numRects); - if (!dst->data) - return PixRegionBreak (dst); - dst->data->size = src->data->numRects; - } - dst->data->numRects = src->data->numRects; - memmove((char *)PIXREGION_BOXPTR(dst),(char *)PIXREGION_BOXPTR(src), - dst->data->numRects * sizeof(PixRegionBox)); - return PixRegionStatusSuccess; -} -slim_hidden_def(PixRegionCopy); - - -/*====================================================================== - * Generic Region Operator - *====================================================================*/ - -/*- - *----------------------------------------------------------------------- - * PixRegionCoalesce -- - * Attempt to merge the boxes in the current band with those in the - * previous one. We are guaranteed that the current band extends to - * the end of the rects array. Used only by PixRegionOp. - * - * Results: - * The new index for the previous band. - * - * Side Effects: - * If coalescing takes place: - * - rectangles in the previous band will have their y2 fields - * altered. - * - region->data->numRects will be decreased. - * - *----------------------------------------------------------------------- - */ -INLINE static int -PixRegionCoalesce ( - PixRegion * region, /* Region to coalesce */ - int prevStart, /* Index of start of previous band */ - int curStart) /* Index of start of current band */ -{ - PixRegionBox * pPrevBox; /* Current box in previous band */ - PixRegionBox * pCurBox; /* Current box in current band */ - int numRects; /* Number rectangles in both bands */ - int y2; /* Bottom of current band */ - /* - * Figure out how many rectangles are in the band. - */ - numRects = curStart - prevStart; - assert(numRects == region->data->numRects - curStart); - - if (!numRects) return curStart; - - /* - * The bands may only be coalesced if the bottom of the previous - * matches the top scanline of the current. - */ - pPrevBox = PIXREGION_BOX(region, prevStart); - pCurBox = PIXREGION_BOX(region, curStart); - if (pPrevBox->y2 != pCurBox->y1) return curStart; - - /* - * Make sure the bands have boxes in the same places. This - * assumes that boxes have been added in such a way that they - * cover the most area possible. I.e. two boxes in a band must - * have some horizontal space between them. - */ - y2 = pCurBox->y2; - - do { - if ((pPrevBox->x1 != pCurBox->x1) || (pPrevBox->x2 != pCurBox->x2)) { - return (curStart); - } - pPrevBox++; - pCurBox++; - numRects--; - } while (numRects); - - /* - * The bands may be merged, so set the bottom y of each box - * in the previous band to the bottom y of the current band. - */ - numRects = curStart - prevStart; - region->data->numRects -= numRects; - do { - pPrevBox--; - pPrevBox->y2 = y2; - numRects--; - } while (numRects); - return prevStart; -} - - -/* Quicky macro to avoid trivial reject procedure calls to PixRegionCoalesce */ - -#define Coalesce(newReg, prevBand, curBand) \ - if (curBand - prevBand == newReg->data->numRects - curBand) { \ - prevBand = PixRegionCoalesce(newReg, prevBand, curBand); \ - } else { \ - prevBand = curBand; \ - } - -/*- - *----------------------------------------------------------------------- - * PixRegionAppendNonO -- - * Handle a non-overlapping band for the union and subtract operations. - * Just adds the (top/bottom-clipped) rectangles into the region. - * Doesn't have to check for subsumption or anything. - * - * Results: - * None. - * - * Side Effects: - * region->data->numRects is incremented and the rectangles overwritten - * with the rectangles we're passed. - * - *----------------------------------------------------------------------- - */ - -INLINE static PixRegionStatus -PixRegionAppendNonO ( - PixRegion * region, - PixRegionBox * r, - PixRegionBox * rEnd, - int y1, - int y2) -{ - PixRegionBox * pNextRect; - int newRects; - - newRects = rEnd - r; - - assert(y1 < y2); - assert(newRects != 0); - - /* Make sure we have enough space for all rectangles to be added */ - RECTALLOC(region, newRects); - pNextRect = PIXREGION_TOP(region); - region->data->numRects += newRects; - do { - assert(r->x1 < r->x2); - ADDRECT(pNextRect, r->x1, y1, r->x2, y2); - r++; - } while (r != rEnd); - - return PixRegionStatusSuccess; -} - -#define FindBand(r, rBandEnd, rEnd, ry1) \ -{ \ - ry1 = r->y1; \ - rBandEnd = r+1; \ - while ((rBandEnd != rEnd) && (rBandEnd->y1 == ry1)) { \ - rBandEnd++; \ - } \ -} - -#define AppendRegions(newReg, r, rEnd) \ -{ \ - int newRects; \ - if ((newRects = rEnd - r)) { \ - RECTALLOC(newReg, newRects); \ - memmove((char *)PIXREGION_TOP(newReg),(char *)r, \ - newRects * sizeof(PixRegionBox)); \ - newReg->data->numRects += newRects; \ - } \ -} - -/*- - *----------------------------------------------------------------------- - * PixRegionOp -- - * Apply an operation to two regions. Called by PixRegionUnion, PixRegionInverse, - * PixRegionSubtract, PixRegionIntersect.... Both regions MUST have at least one - * rectangle, and cannot be the same object. - * - * Results: - * PixRegionStatusSuccess if successful. - * - * Side Effects: - * The new region is overwritten. - * pOverlap set to PixRegionStatusSuccess if overlapFunc ever returns PixRegionStatusSuccess. - * - * Notes: - * The idea behind this function is to view the two regions as sets. - * Together they cover a rectangle of area that this function divides - * into horizontal bands where points are covered only by one region - * or by both. For the first case, the nonOverlapFunc is called with - * each the band and the band's upper and lower extents. For the - * second, the overlapFunc is called to process the entire band. It - * is responsible for clipping the rectangles in the band, though - * this function provides the boundaries. - * At the end of each band, the new region is coalesced, if possible, - * to reduce the number of rectangles in the region. - * - *----------------------------------------------------------------------- - */ - -typedef PixRegionStatus (*OverlapProcPtr)( - PixRegion *region, - PixRegionBox *r1, - PixRegionBox *r1End, - PixRegionBox *r2, - PixRegionBox *r2End, - short y1, - short y2, - int *pOverlap); - -static PixRegionStatus -PixRegionOp( - PixRegion * newReg, /* Place to store result */ - PixRegion * reg1, /* First region in operation */ - PixRegion * reg2, /* 2d region in operation */ - OverlapProcPtr overlapFunc, /* Function to call for over- - * lapping bands */ - int appendNon1, /* Append non-overlapping bands */ - /* in region 1 ? */ - int appendNon2, /* Append non-overlapping bands */ - /* in region 2 ? */ - int *pOverlap) -{ - PixRegionBox * r1; /* Pointer into first region */ - PixRegionBox * r2; /* Pointer into 2d region */ - PixRegionBox * r1End; /* End of 1st region */ - PixRegionBox * r2End; /* End of 2d region */ - short ybot; /* Bottom of intersection */ - short ytop; /* Top of intersection */ - PixRegionData * oldData; /* Old data for newReg */ - int prevBand; /* Index of start of - * previous band in newReg */ - int curBand; /* Index of start of current - * band in newReg */ - PixRegionBox * r1BandEnd; /* End of current band in r1 */ - PixRegionBox * r2BandEnd; /* End of current band in r2 */ - short top; /* Top of non-overlapping band */ - short bot; /* Bottom of non-overlapping band*/ - int r1y1; /* Temps for r1->y1 and r2->y1 */ - int r2y1; - int newSize; - int numRects; - - /* - * Break any region computed from a broken region - */ - if (PIXREGION_NAR (reg1) || PIXREGION_NAR(reg2)) - return PixRegionBreak (newReg); - - /* - * Initialization: - * set r1, r2, r1End and r2End appropriately, save the rectangles - * of the destination region until the end in case it's one of - * the two source regions, then mark the "new" region empty, allocating - * another array of rectangles for it to use. - */ - - r1 = PIXREGION_RECTS(reg1); - newSize = PIXREGION_NUM_RECTS(reg1); - r1End = r1 + newSize; - numRects = PIXREGION_NUM_RECTS(reg2); - r2 = PIXREGION_RECTS(reg2); - r2End = r2 + numRects; - assert(r1 != r1End); - assert(r2 != r2End); - - oldData = (PixRegionData *)NULL; - if (((newReg == reg1) && (newSize > 1)) || - ((newReg == reg2) && (numRects > 1))) - { - oldData = newReg->data; - newReg->data = &PixRegionEmptyData; - } - /* guess at new size */ - if (numRects > newSize) - newSize = numRects; - newSize <<= 1; - if (!newReg->data) - newReg->data = &PixRegionEmptyData; - else if (newReg->data->size) - newReg->data->numRects = 0; - if (newSize > newReg->data->size) - if (!PixRegionRectAlloc(newReg, newSize)) - return PixRegionStatusFailure; - - /* - * Initialize ybot. - * In the upcoming loop, ybot and ytop serve different functions depending - * on whether the band being handled is an overlapping or non-overlapping - * band. - * In the case of a non-overlapping band (only one of the regions - * has points in the band), ybot is the bottom of the most recent - * intersection and thus clips the top of the rectangles in that band. - * ytop is the top of the next intersection between the two regions and - * serves to clip the bottom of the rectangles in the current band. - * For an overlapping band (where the two regions intersect), ytop clips - * the top of the rectangles of both regions and ybot clips the bottoms. - */ - - ybot = MIN(r1->y1, r2->y1); - - /* - * prevBand serves to mark the start of the previous band so rectangles - * can be coalesced into larger rectangles. qv. PixRegionCoalesce, above. - * In the beginning, there is no previous band, so prevBand == curBand - * (curBand is set later on, of course, but the first band will always - * start at index 0). prevBand and curBand must be indices because of - * the possible expansion, and resultant moving, of the new region's - * array of rectangles. - */ - prevBand = 0; - - do { - /* - * This algorithm proceeds one source-band (as opposed to a - * destination band, which is determined by where the two regions - * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the - * rectangle after the last one in the current band for their - * respective regions. - */ - assert(r1 != r1End); - assert(r2 != r2End); - - FindBand(r1, r1BandEnd, r1End, r1y1); - FindBand(r2, r2BandEnd, r2End, r2y1); - - /* - * First handle the band that doesn't intersect, if any. - * - * Note that attention is restricted to one band in the - * non-intersecting region at once, so if a region has n - * bands between the current position and the next place it overlaps - * the other, this entire loop will be passed through n times. - */ - if (r1y1 < r2y1) { - if (appendNon1) { - top = MAX(r1y1, ybot); - bot = MIN(r1->y2, r2y1); - if (top != bot) { - curBand = newReg->data->numRects; - PixRegionAppendNonO(newReg, r1, r1BandEnd, top, bot); - Coalesce(newReg, prevBand, curBand); - } - } - ytop = r2y1; - } else if (r2y1 < r1y1) { - if (appendNon2) { - top = MAX(r2y1, ybot); - bot = MIN(r2->y2, r1y1); - if (top != bot) { - curBand = newReg->data->numRects; - PixRegionAppendNonO(newReg, r2, r2BandEnd, top, bot); - Coalesce(newReg, prevBand, curBand); - } - } - ytop = r1y1; - } else { - ytop = r1y1; - } - - /* - * Now see if we've hit an intersecting band. The two bands only - * intersect if ybot > ytop - */ - ybot = MIN(r1->y2, r2->y2); - if (ybot > ytop) { - curBand = newReg->data->numRects; - (* overlapFunc)(newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot, - pOverlap); - Coalesce(newReg, prevBand, curBand); - } - - /* - * If we've finished with a band (y2 == ybot) we skip forward - * in the region to the next band. - */ - if (r1->y2 == ybot) r1 = r1BandEnd; - if (r2->y2 == ybot) r2 = r2BandEnd; - - } while (r1 != r1End && r2 != r2End); - - /* - * Deal with whichever region (if any) still has rectangles left. - * - * We only need to worry about banding and coalescing for the very first - * band left. After that, we can just group all remaining boxes, - * regardless of how many bands, into one final append to the list. - */ - - if ((r1 != r1End) && appendNon1) { - /* Do first nonOverlap1Func call, which may be able to coalesce */ - FindBand(r1, r1BandEnd, r1End, r1y1); - curBand = newReg->data->numRects; - PixRegionAppendNonO(newReg, r1, r1BandEnd, MAX(r1y1, ybot), r1->y2); - Coalesce(newReg, prevBand, curBand); - /* Just append the rest of the boxes */ - AppendRegions(newReg, r1BandEnd, r1End); - - } else if ((r2 != r2End) && appendNon2) { - /* Do first nonOverlap2Func call, which may be able to coalesce */ - FindBand(r2, r2BandEnd, r2End, r2y1); - curBand = newReg->data->numRects; - PixRegionAppendNonO(newReg, r2, r2BandEnd, MAX(r2y1, ybot), r2->y2); - Coalesce(newReg, prevBand, curBand); - /* Append rest of boxes */ - AppendRegions(newReg, r2BandEnd, r2End); - } - - if (oldData) - free(oldData); - - if (!(numRects = newReg->data->numRects)) - { - freeData(newReg); - newReg->data = &PixRegionEmptyData; - } - else if (numRects == 1) - { - newReg->extents = *PIXREGION_BOXPTR(newReg); - freeData(newReg); - newReg->data = (PixRegionData *)NULL; - } - else - { - DOWNSIZE(newReg, numRects); - } - - return PixRegionStatusSuccess; -} - -/*- - *----------------------------------------------------------------------- - * PixRegionSetExtents -- - * Reset the extents of a region to what they should be. Called by - * PixRegionSubtract and PixRegionIntersect as they can't figure it out along the - * way or do so easily, as PixRegionUnion can. - * - * Results: - * None. - * - * Side Effects: - * The region's 'extents' structure is overwritten. - * - *----------------------------------------------------------------------- - */ -static void -PixRegionSetExtents (PixRegion *region) -{ - PixRegionBox *box, *boxEnd; - - if (!region->data) - return; - if (!region->data->size) - { - region->extents.x2 = region->extents.x1; - region->extents.y2 = region->extents.y1; - return; - } - - box = PIXREGION_BOXPTR(region); - boxEnd = PIXREGION_END(region); - - /* - * Since box is the first rectangle in the region, it must have the - * smallest y1 and since boxEnd is the last rectangle in the region, - * it must have the largest y2, because of banding. Initialize x1 and - * x2 from box and boxEnd, resp., as good things to initialize them - * to... - */ - region->extents.x1 = box->x1; - region->extents.y1 = box->y1; - region->extents.x2 = boxEnd->x2; - region->extents.y2 = boxEnd->y2; - - assert(region->extents.y1 < region->extents.y2); - while (box <= boxEnd) { - if (box->x1 < region->extents.x1) - region->extents.x1 = box->x1; - if (box->x2 > region->extents.x2) - region->extents.x2 = box->x2; - box++; - }; - - assert(region->extents.x1 < region->extents.x2); -} - -/*====================================================================== - * Region Intersection - *====================================================================*/ -/*- - *----------------------------------------------------------------------- - * PixRegionIntersectO -- - * Handle an overlapping band for PixRegionIntersect. - * - * Results: - * PixRegionStatusSuccess if successful. - * - * Side Effects: - * Rectangles may be added to the region. - * - *----------------------------------------------------------------------- - */ -/*ARGSUSED*/ -static PixRegionStatus -PixRegionIntersectO ( - PixRegion * region, - PixRegionBox * r1, - PixRegionBox * r1End, - PixRegionBox * r2, - PixRegionBox * r2End, - short y1, - short y2, - int *pOverlap) -{ - int x1; - int x2; - PixRegionBox * pNextRect; - - pNextRect = PIXREGION_TOP(region); - - assert(y1 < y2); - assert(r1 != r1End && r2 != r2End); - - do { - x1 = MAX(r1->x1, r2->x1); - x2 = MIN(r1->x2, r2->x2); - - /* - * If there's any overlap between the two rectangles, add that - * overlap to the new region. - */ - if (x1 < x2) - NEWRECT(region, pNextRect, x1, y1, x2, y2); - - /* - * Advance the pointer(s) with the leftmost right side, since the next - * rectangle on that list may still overlap the other region's - * current rectangle. - */ - if (r1->x2 == x2) { - r1++; - } - if (r2->x2 == x2) { - r2++; - } - } while ((r1 != r1End) && (r2 != r2End)); - - return PixRegionStatusSuccess; -} - - -PixRegionStatus -PixRegionIntersect(newReg, reg1, reg2) - PixRegion * newReg; /* destination Region */ - PixRegion * reg1; - PixRegion * reg2; /* source regions */ -{ - good(reg1); - good(reg2); - good(newReg); - /* check for trivial reject */ - if (PIXREGION_NIL(reg1) || PIXREGION_NIL(reg2) || - !EXTENTCHECK(®1->extents, ®2->extents)) - { - /* Covers about 20% of all cases */ - freeData(newReg); - newReg->extents.x2 = newReg->extents.x1; - newReg->extents.y2 = newReg->extents.y1; - if (PIXREGION_NAR(reg1) || PIXREGION_NAR(reg2)) - { - newReg->data = &PixRegionBrokenData; - return PixRegionStatusFailure; - } - else - newReg->data = &PixRegionEmptyData; - } - else if (!reg1->data && !reg2->data) - { - /* Covers about 80% of cases that aren't trivially rejected */ - newReg->extents.x1 = MAX(reg1->extents.x1, reg2->extents.x1); - newReg->extents.y1 = MAX(reg1->extents.y1, reg2->extents.y1); - newReg->extents.x2 = MIN(reg1->extents.x2, reg2->extents.x2); - newReg->extents.y2 = MIN(reg1->extents.y2, reg2->extents.y2); - freeData(newReg); - newReg->data = (PixRegionData *)NULL; - } - else if (!reg2->data && SUBSUMES(®2->extents, ®1->extents)) - { - return PixRegionCopy(newReg, reg1); - } - else if (!reg1->data && SUBSUMES(®1->extents, ®2->extents)) - { - return PixRegionCopy(newReg, reg2); - } - else if (reg1 == reg2) - { - return PixRegionCopy(newReg, reg1); - } - else - { - /* General purpose intersection */ - int overlap; /* result ignored */ - if (!PixRegionOp(newReg, reg1, reg2, PixRegionIntersectO, PixRegionStatusFailure, PixRegionStatusFailure, - &overlap)) - return PixRegionStatusFailure; - PixRegionSetExtents(newReg); - } - - good(newReg); - return(PixRegionStatusSuccess); -} - -#define MERGERECT(r) \ -{ \ - if (r->x1 <= x2) { \ - /* Merge with current rectangle */ \ - if (r->x1 < x2) *pOverlap = PixRegionStatusSuccess; \ - if (x2 < r->x2) x2 = r->x2; \ - } else { \ - /* Add current rectangle, start new one */ \ - NEWRECT(region, pNextRect, x1, y1, x2, y2); \ - x1 = r->x1; \ - x2 = r->x2; \ - } \ - r++; \ -} - -/*====================================================================== - * Region Union - *====================================================================*/ - -/*- - *----------------------------------------------------------------------- - * PixRegionUnionO -- - * Handle an overlapping band for the union operation. Picks the - * left-most rectangle each time and merges it into the region. - * - * Results: - * PixRegionStatusSuccess if successful. - * - * Side Effects: - * region is overwritten. - * pOverlap is set to PixRegionStatusSuccess if any boxes overlap. - * - *----------------------------------------------------------------------- - */ -static PixRegionStatus -PixRegionUnionO ( - PixRegion *region, - PixRegionBox *r1, - PixRegionBox *r1End, - PixRegionBox *r2, - PixRegionBox *r2End, - short y1, - short y2, - int *pOverlap) -{ - PixRegionBox * pNextRect; - int x1; /* left and right side of current union */ - int x2; - - assert (y1 < y2); - assert(r1 != r1End && r2 != r2End); - - pNextRect = PIXREGION_TOP(region); - - /* Start off current rectangle */ - if (r1->x1 < r2->x1) - { - x1 = r1->x1; - x2 = r1->x2; - r1++; - } - else - { - x1 = r2->x1; - x2 = r2->x2; - r2++; - } - while (r1 != r1End && r2 != r2End) - { - if (r1->x1 < r2->x1) MERGERECT(r1) else MERGERECT(r2); - } - - /* Finish off whoever (if any) is left */ - if (r1 != r1End) - { - do - { - MERGERECT(r1); - } while (r1 != r1End); - } - else if (r2 != r2End) - { - do - { - MERGERECT(r2); - } while (r2 != r2End); - } - - /* Add current rectangle */ - NEWRECT(region, pNextRect, x1, y1, x2, y2); - - return PixRegionStatusSuccess; -} - -/* Convenience function for performing union of region with a single rectangle */ -PixRegionStatus -PixRegionUnionRect(PixRegion *dest, PixRegion *source, - int x, int y, unsigned int width, unsigned int height) -{ - PixRegion region; - - if (!width || !height) - return PixRegionStatusFailure; - region.data = NULL; - region.extents.x1 = x; - region.extents.y1 = y; - region.extents.x2 = x + width; - region.extents.y2 = y + height; - - return PixRegionUnion (dest, source, ®ion); -} - -PixRegionStatus -PixRegionUnion(PixRegion *newReg, PixRegion *reg1, PixRegion *reg2) -{ - int overlap; /* result ignored */ - - /* Return PixRegionStatusSuccess if some overlap between reg1, reg2 */ - good(reg1); - good(reg2); - good(newReg); - /* checks all the simple cases */ - - /* - * Region 1 and 2 are the same - */ - if (reg1 == reg2) - { - return PixRegionCopy(newReg, reg1); - } - - /* - * Region 1 is empty - */ - if (PIXREGION_NIL(reg1)) - { - if (PIXREGION_NAR(reg1)) - return PixRegionBreak (newReg); - if (newReg != reg2) - return PixRegionCopy(newReg, reg2); - return PixRegionStatusSuccess; - } - - /* - * Region 2 is empty - */ - if (PIXREGION_NIL(reg2)) - { - if (PIXREGION_NAR(reg2)) - return PixRegionBreak (newReg); - if (newReg != reg1) - return PixRegionCopy(newReg, reg1); - return PixRegionStatusSuccess; - } - - /* - * Region 1 completely subsumes region 2 - */ - if (!reg1->data && SUBSUMES(®1->extents, ®2->extents)) - { - if (newReg != reg1) - return PixRegionCopy(newReg, reg1); - return PixRegionStatusSuccess; - } - - /* - * Region 2 completely subsumes region 1 - */ - if (!reg2->data && SUBSUMES(®2->extents, ®1->extents)) - { - if (newReg != reg2) - return PixRegionCopy(newReg, reg2); - return PixRegionStatusSuccess; - } - - if (!PixRegionOp(newReg, reg1, reg2, PixRegionUnionO, PixRegionStatusSuccess, PixRegionStatusSuccess, &overlap)) - return PixRegionStatusFailure; - - newReg->extents.x1 = MIN(reg1->extents.x1, reg2->extents.x1); - newReg->extents.y1 = MIN(reg1->extents.y1, reg2->extents.y1); - newReg->extents.x2 = MAX(reg1->extents.x2, reg2->extents.x2); - newReg->extents.y2 = MAX(reg1->extents.y2, reg2->extents.y2); - good(newReg); - return PixRegionStatusSuccess; -} -slim_hidden_def(PixRegionUnion); - - -/*====================================================================== - * Batch Rectangle Union - *====================================================================*/ - -/*- - *----------------------------------------------------------------------- - * PixRegionAppend -- - * - * "Append" the rgn rectangles onto the end of dstrgn, maintaining - * knowledge of YX-banding when it's easy. Otherwise, dstrgn just - * becomes a non-y-x-banded random collection of rectangles, and not - * yet a true region. After a sequence of appends, the caller must - * call PixRegionValidate to ensure that a valid region is constructed. - * - * Results: - * PixRegionStatusSuccess if successful. - * - * Side Effects: - * dstrgn is modified if rgn has rectangles. - * - */ -PixRegionStatus -PixRegionAppend(dstrgn, rgn) - PixRegion * dstrgn; - PixRegion * rgn; -{ - int numRects, dnumRects, size; - PixRegionBox *new, *old; - int prepend; - - if (PIXREGION_NAR(rgn)) - return PixRegionBreak (dstrgn); - - if (!rgn->data && (dstrgn->data == &PixRegionEmptyData)) - { - dstrgn->extents = rgn->extents; - dstrgn->data = (PixRegionData *)NULL; - return PixRegionStatusSuccess; - } - - numRects = PIXREGION_NUM_RECTS(rgn); - if (!numRects) - return PixRegionStatusSuccess; - prepend = PixRegionStatusFailure; - size = numRects; - dnumRects = PIXREGION_NUM_RECTS(dstrgn); - if (!dnumRects && (size < 200)) - size = 200; /* XXX pick numbers out of a hat */ - RECTALLOC(dstrgn, size); - old = PIXREGION_RECTS(rgn); - if (!dnumRects) - dstrgn->extents = rgn->extents; - else if (dstrgn->extents.x2 > dstrgn->extents.x1) - { - PixRegionBox *first, *last; - - first = old; - last = PIXREGION_BOXPTR(dstrgn) + (dnumRects - 1); - if ((first->y1 > last->y2) || - ((first->y1 == last->y1) && (first->y2 == last->y2) && - (first->x1 > last->x2))) - { - if (rgn->extents.x1 < dstrgn->extents.x1) - dstrgn->extents.x1 = rgn->extents.x1; - if (rgn->extents.x2 > dstrgn->extents.x2) - dstrgn->extents.x2 = rgn->extents.x2; - dstrgn->extents.y2 = rgn->extents.y2; - } - else - { - first = PIXREGION_BOXPTR(dstrgn); - last = old + (numRects - 1); - if ((first->y1 > last->y2) || - ((first->y1 == last->y1) && (first->y2 == last->y2) && - (first->x1 > last->x2))) - { - prepend = PixRegionStatusSuccess; - if (rgn->extents.x1 < dstrgn->extents.x1) - dstrgn->extents.x1 = rgn->extents.x1; - if (rgn->extents.x2 > dstrgn->extents.x2) - dstrgn->extents.x2 = rgn->extents.x2; - dstrgn->extents.y1 = rgn->extents.y1; - } - else - dstrgn->extents.x2 = dstrgn->extents.x1; - } - } - if (prepend) - { - new = PIXREGION_BOX(dstrgn, numRects); - if (dnumRects == 1) - *new = *PIXREGION_BOXPTR(dstrgn); - else - memmove((char *)new,(char *)PIXREGION_BOXPTR(dstrgn), - dnumRects * sizeof(PixRegionBox)); - new = PIXREGION_BOXPTR(dstrgn); - } - else - new = PIXREGION_BOXPTR(dstrgn) + dnumRects; - if (numRects == 1) - *new = *old; - else - memmove((char *)new, (char *)old, numRects * sizeof(PixRegionBox)); - dstrgn->data->numRects += numRects; - return PixRegionStatusSuccess; -} - - -#define ExchangeRects(a, b) \ -{ \ - PixRegionBox t; \ - t = rects[a]; \ - rects[a] = rects[b]; \ - rects[b] = t; \ -} - -static void -QuickSortRects( - PixRegionBox rects[], - int numRects) -{ - int y1; - int x1; - int i, j; - PixRegionBox *r; - - /* Always called with numRects > 1 */ - - do - { - if (numRects == 2) - { - if (rects[0].y1 > rects[1].y1 || - (rects[0].y1 == rects[1].y1 && rects[0].x1 > rects[1].x1)) - ExchangeRects(0, 1); - return; - } - - /* Choose partition element, stick in location 0 */ - ExchangeRects(0, numRects >> 1); - y1 = rects[0].y1; - x1 = rects[0].x1; - - /* Partition array */ - i = 0; - j = numRects; - do - { - r = &(rects[i]); - do - { - r++; - i++; - } while (i != numRects && - (r->y1 < y1 || (r->y1 == y1 && r->x1 < x1))); - r = &(rects[j]); - do - { - r--; - j--; - } while (y1 < r->y1 || (y1 == r->y1 && x1 < r->x1)); - if (i < j) - ExchangeRects(i, j); - } while (i < j); - - /* Move partition element back to middle */ - ExchangeRects(0, j); - - /* Recurse */ - if (numRects-j-1 > 1) - QuickSortRects(&rects[j+1], numRects-j-1); - numRects = j; - } while (numRects > 1); -} - -/*- - *----------------------------------------------------------------------- - * PixRegionValidate -- - * - * Take a ``region'' which is a non-y-x-banded random collection of - * rectangles, and compute a nice region which is the union of all the - * rectangles. - * - * Results: - * PixRegionStatusSuccess if successful. - * - * Side Effects: - * The passed-in ``region'' may be modified. - * pOverlap set to PixRegionStatusSuccess if any retangles overlapped, else PixRegionStatusFailure; - * - * Strategy: - * Step 1. Sort the rectangles into ascending order with primary key y1 - * and secondary key x1. - * - * Step 2. Split the rectangles into the minimum number of proper y-x - * banded regions. This may require horizontally merging - * rectangles, and vertically coalescing bands. With any luck, - * this step in an identity tranformation (ala the Box widget), - * or a coalescing into 1 box (ala Menus). - * - * Step 3. Merge the separate regions down to a single region by calling - * PixRegionUnion. Maximize the work each PixRegionUnion call does by using - * a binary merge. - * - *----------------------------------------------------------------------- - */ - -PixRegionStatus -PixRegionValidate(badreg, pOverlap) - PixRegion * badreg; - int *pOverlap; -{ - /* Descriptor for regions under construction in Step 2. */ - typedef struct { - PixRegion reg; - int prevBand; - int curBand; - } RegionInfo; - - int numRects; /* Original numRects for badreg */ - RegionInfo *ri; /* Array of current regions */ - int numRI; /* Number of entries used in ri */ - int sizeRI; /* Number of entries available in ri */ - int i; /* Index into rects */ - int j; /* Index into ri */ - RegionInfo *rit; /* &ri[j] */ - PixRegion * reg; /* ri[j].reg */ - PixRegionBox * box; /* Current box in rects */ - PixRegionBox * riBox; /* Last box in ri[j].reg */ - PixRegion * hreg; /* ri[j_half].reg */ - int ret = PixRegionStatusSuccess; - - *pOverlap = PixRegionStatusFailure; - if (!badreg->data) - { - good(badreg); - return PixRegionStatusSuccess; - } - numRects = badreg->data->numRects; - if (!numRects) - { - if (PIXREGION_NAR(badreg)) - return PixRegionStatusFailure; - good(badreg); - return PixRegionStatusSuccess; - } - if (badreg->extents.x1 < badreg->extents.x2) - { - if ((numRects) == 1) - { - freeData(badreg); - badreg->data = (PixRegionData *) NULL; - } - else - { - DOWNSIZE(badreg, numRects); - } - good(badreg); - return PixRegionStatusSuccess; - } - - /* Step 1: Sort the rects array into ascending (y1, x1) order */ - QuickSortRects(PIXREGION_BOXPTR(badreg), numRects); - - /* Step 2: Scatter the sorted array into the minimum number of regions */ - - /* Set up the first region to be the first rectangle in badreg */ - /* Note that step 2 code will never overflow the ri[0].reg rects array */ - ri = (RegionInfo *) malloc(4 * sizeof(RegionInfo)); - if (!ri) - return PixRegionBreak (badreg); - sizeRI = 4; - numRI = 1; - ri[0].prevBand = 0; - ri[0].curBand = 0; - ri[0].reg = *badreg; - box = PIXREGION_BOXPTR(&ri[0].reg); - ri[0].reg.extents = *box; - ri[0].reg.data->numRects = 1; - - /* Now scatter rectangles into the minimum set of valid regions. If the - next rectangle to be added to a region would force an existing rectangle - in the region to be split up in order to maintain y-x banding, just - forget it. Try the next region. If it doesn't fit cleanly into any - region, make a new one. */ - - for (i = numRects; --i > 0;) - { - box++; - /* Look for a region to append box to */ - for (j = numRI, rit = ri; --j >= 0; rit++) - { - reg = &rit->reg; - riBox = PIXREGION_END(reg); - - if (box->y1 == riBox->y1 && box->y2 == riBox->y2) - { - /* box is in same band as riBox. Merge or append it */ - if (box->x1 <= riBox->x2) - { - /* Merge it with riBox */ - if (box->x1 < riBox->x2) *pOverlap = PixRegionStatusSuccess; - if (box->x2 > riBox->x2) riBox->x2 = box->x2; - } - else - { - RECTALLOC_BAIL(reg, 1, bail); - *PIXREGION_TOP(reg) = *box; - reg->data->numRects++; - } - goto NextRect; /* So sue me */ - } - else if (box->y1 >= riBox->y2) - { - /* Put box into new band */ - if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2; - if (reg->extents.x1 > box->x1) reg->extents.x1 = box->x1; - Coalesce(reg, rit->prevBand, rit->curBand); - rit->curBand = reg->data->numRects; - RECTALLOC_BAIL(reg, 1, bail); - *PIXREGION_TOP(reg) = *box; - reg->data->numRects++; - goto NextRect; - } - /* Well, this region was inappropriate. Try the next one. */ - } /* for j */ - - /* Uh-oh. No regions were appropriate. Create a new one. */ - if (sizeRI == numRI) - { - /* Oops, allocate space for new region information */ - sizeRI <<= 1; - rit = (RegionInfo *) realloc(ri, sizeRI * sizeof(RegionInfo)); - if (!rit) - goto bail; - ri = rit; - rit = &ri[numRI]; - } - numRI++; - rit->prevBand = 0; - rit->curBand = 0; - rit->reg.extents = *box; - rit->reg.data = (PixRegionData *)NULL; - if (!PixRegionRectAlloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */ - goto bail; -NextRect: ; - } /* for i */ - - /* Make a final pass over each region in order to Coalesce and set - extents.x2 and extents.y2 */ - - for (j = numRI, rit = ri; --j >= 0; rit++) - { - reg = &rit->reg; - riBox = PIXREGION_END(reg); - reg->extents.y2 = riBox->y2; - if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2; - Coalesce(reg, rit->prevBand, rit->curBand); - if (reg->data->numRects == 1) /* keep unions happy below */ - { - freeData(reg); - reg->data = (PixRegionData *)NULL; - } - } - - /* Step 3: Union all regions into a single region */ - while (numRI > 1) - { - int half = numRI/2; - for (j = numRI & 1; j < (half + (numRI & 1)); j++) - { - reg = &ri[j].reg; - hreg = &ri[j+half].reg; - if (!PixRegionOp(reg, reg, hreg, PixRegionUnionO, PixRegionStatusSuccess, PixRegionStatusSuccess, pOverlap)) - ret = PixRegionStatusFailure; - if (hreg->extents.x1 < reg->extents.x1) - reg->extents.x1 = hreg->extents.x1; - if (hreg->extents.y1 < reg->extents.y1) - reg->extents.y1 = hreg->extents.y1; - if (hreg->extents.x2 > reg->extents.x2) - reg->extents.x2 = hreg->extents.x2; - if (hreg->extents.y2 > reg->extents.y2) - reg->extents.y2 = hreg->extents.y2; - freeData(hreg); - } - numRI -= half; - } - *badreg = ri[0].reg; - free(ri); - good(badreg); - return ret; -bail: - for (i = 0; i < numRI; i++) - freeData(&ri[i].reg); - free (ri); - return PixRegionBreak (badreg); -} - -/* XXX: Need to fix this to not use any X data structure -PixRegion * -PixRegionRectsToRegion(nrects, prect, ctype) - int nrects; - xRectangle *prect; - int ctype; -{ - PixRegion * region; - PixRegionData * pData; - PixRegionBox * box; - int i; - int x1, y1, x2, y2; - - region = PixRegionCreate(NullBox, 0); - if (PIXREGION_NAR (region)) - return region; - if (!nrects) - return region; - if (nrects == 1) - { - x1 = prect->x; - y1 = prect->y; - if ((x2 = x1 + (int) prect->width) > SHRT_MAX) - x2 = SHRT_MAX; - if ((y2 = y1 + (int) prect->height) > SHRT_MAX) - y2 = SHRT_MAX; - if (x1 != x2 && y1 != y2) - { - region->extents.x1 = x1; - region->extents.y1 = y1; - region->extents.x2 = x2; - region->extents.y2 = y2; - region->data = (PixRegionData *)NULL; - } - return region; - } - pData = allocData(nrects); - if (!pData) - { - PixRegionBreak (region); - return region; - } - box = (PixRegionBox *) (pData + 1); - for (i = nrects; --i >= 0; prect++) - { - x1 = prect->x; - y1 = prect->y; - if ((x2 = x1 + (int) prect->width) > SHRT_MAX) - x2 = SHRT_MAX; - if ((y2 = y1 + (int) prect->height) > SHRT_MAX) - y2 = SHRT_MAX; - if (x1 != x2 && y1 != y2) - { - box->x1 = x1; - box->y1 = y1; - box->x2 = x2; - box->y2 = y2; - box++; - } - } - if (box != (PixRegionBox *) (pData + 1)) - { - pData->size = nrects; - pData->numRects = box - (PixRegionBox *) (pData + 1); - region->data = pData; - if (ctype != CT_YXBANDED) - { - int overlap; - region->extents.x1 = region->extents.x2 = 0; - PixRegionValidate(region, &overlap); - } - else - PixRegionSetExtents(region); - good(region); - } - else - { - free (pData); - } - return region; -} -*/ - -/*====================================================================== - * Region Subtraction - *====================================================================*/ - - -/*- - *----------------------------------------------------------------------- - * PixRegionSubtractO -- - * Overlapping band subtraction. x1 is the left-most point not yet - * checked. - * - * Results: - * PixRegionStatusSuccess if successful. - * - * Side Effects: - * region may have rectangles added to it. - * - *----------------------------------------------------------------------- - */ -/*ARGSUSED*/ -static PixRegionStatus -PixRegionSubtractO ( - PixRegion * region, - PixRegionBox * r1, - PixRegionBox * r1End, - PixRegionBox * r2, - PixRegionBox * r2End, - short y1, - short y2, - int *pOverlap) -{ - PixRegionBox * pNextRect; - int x1; - - x1 = r1->x1; - - assert(y1<y2); - assert(r1 != r1End && r2 != r2End); - - pNextRect = PIXREGION_TOP(region); - - do - { - if (r2->x2 <= x1) - { - /* - * Subtrahend entirely to left of minuend: go to next subtrahend. - */ - r2++; - } - else if (r2->x1 <= x1) - { - /* - * Subtrahend preceeds minuend: nuke left edge of minuend. - */ - x1 = r2->x2; - if (x1 >= r1->x2) - { - /* - * Minuend completely covered: advance to next minuend and - * reset left fence to edge of new minuend. - */ - r1++; - if (r1 != r1End) - x1 = r1->x1; - } - else - { - /* - * Subtrahend now used up since it doesn't extend beyond - * minuend - */ - r2++; - } - } - else if (r2->x1 < r1->x2) - { - /* - * Left part of subtrahend covers part of minuend: add uncovered - * part of minuend to region and skip to next subtrahend. - */ - assert(x1<r2->x1); - NEWRECT(region, pNextRect, x1, y1, r2->x1, y2); - - x1 = r2->x2; - if (x1 >= r1->x2) - { - /* - * Minuend used up: advance to new... - */ - r1++; - if (r1 != r1End) - x1 = r1->x1; - } - else - { - /* - * Subtrahend used up - */ - r2++; - } - } - else - { - /* - * Minuend used up: add any remaining piece before advancing. - */ - if (r1->x2 > x1) - NEWRECT(region, pNextRect, x1, y1, r1->x2, y2); - r1++; - if (r1 != r1End) - x1 = r1->x1; - } - } while ((r1 != r1End) && (r2 != r2End)); - - - /* - * Add remaining minuend rectangles to region. - */ - while (r1 != r1End) - { - assert(x1<r1->x2); - NEWRECT(region, pNextRect, x1, y1, r1->x2, y2); - r1++; - if (r1 != r1End) - x1 = r1->x1; - } - return PixRegionStatusSuccess; -} - -/*- - *----------------------------------------------------------------------- - * PixRegionSubtract -- - * Subtract regS from regM and leave the result in regD. - * S stands for subtrahend, M for minuend and D for difference. - * - * Results: - * PixRegionStatusSuccess if successful. - * - * Side Effects: - * regD is overwritten. - * - *----------------------------------------------------------------------- - */ -PixRegionStatus -PixRegionSubtract(regD, regM, regS) - PixRegion * regD; - PixRegion * regM; - PixRegion * regS; -{ - int overlap; /* result ignored */ - - good(regM); - good(regS); - good(regD); - /* check for trivial rejects */ - if (PIXREGION_NIL(regM) || PIXREGION_NIL(regS) || - !EXTENTCHECK(®M->extents, ®S->extents)) - { - if (PIXREGION_NAR (regS)) - return PixRegionBreak (regD); - return PixRegionCopy(regD, regM); - } - else if (regM == regS) - { - freeData(regD); - regD->extents.x2 = regD->extents.x1; - regD->extents.y2 = regD->extents.y1; - regD->data = &PixRegionEmptyData; - return PixRegionStatusSuccess; - } - - /* Add those rectangles in region 1 that aren't in region 2, - do yucky substraction for overlaps, and - just throw away rectangles in region 2 that aren't in region 1 */ - if (!PixRegionOp(regD, regM, regS, PixRegionSubtractO, PixRegionStatusSuccess, PixRegionStatusFailure, &overlap)) - return PixRegionStatusFailure; - - /* - * Can't alter RegD's extents before we call PixRegionOp because - * it might be one of the source regions and PixRegionOp depends - * on the extents of those regions being unaltered. Besides, this - * way there's no checking against rectangles that will be nuked - * due to coalescing, so we have to examine fewer rectangles. - */ - PixRegionSetExtents(regD); - good(regD); - return PixRegionStatusSuccess; -} - -/*====================================================================== - * Region Inversion - *====================================================================*/ - -/*- - *----------------------------------------------------------------------- - * PixRegionInverse -- - * Take a region and a box and return a region that is everything - * in the box but not in the region. The careful reader will note - * that this is the same as subtracting the region from the box... - * - * Results: - * PixRegionStatusSuccess. - * - * Side Effects: - * newReg is overwritten. - * - *----------------------------------------------------------------------- - */ -PixRegionStatus -PixRegionInverse(newReg, reg1, invRect) - PixRegion * newReg; /* Destination region */ - PixRegion * reg1; /* Region to invert */ - PixRegionBox * invRect; /* Bounding box for inversion */ -{ - PixRegion invReg; /* Quick and dirty region made from the - * bounding box */ - int overlap; /* result ignored */ - - good(reg1); - good(newReg); - /* check for trivial rejects */ - if (PIXREGION_NIL(reg1) || !EXTENTCHECK(invRect, ®1->extents)) - { - if (PIXREGION_NAR(reg1)) - return PixRegionBreak (newReg); - newReg->extents = *invRect; - freeData(newReg); - newReg->data = (PixRegionData *)NULL; - return PixRegionStatusSuccess; - } - - /* Add those rectangles in region 1 that aren't in region 2, - do yucky substraction for overlaps, and - just throw away rectangles in region 2 that aren't in region 1 */ - invReg.extents = *invRect; - invReg.data = (PixRegionData *)NULL; - if (!PixRegionOp(newReg, &invReg, reg1, PixRegionSubtractO, PixRegionStatusSuccess, PixRegionStatusFailure, &overlap)) - return PixRegionStatusFailure; - - /* - * Can't alter newReg's extents before we call PixRegionOp because - * it might be one of the source regions and PixRegionOp depends - * on the extents of those regions being unaltered. Besides, this - * way there's no checking against rectangles that will be nuked - * due to coalescing, so we have to examine fewer rectangles. - */ - PixRegionSetExtents(newReg); - good(newReg); - return PixRegionStatusSuccess; -} - -/* - * RectIn(region, rect) - * This routine takes a pointer to a region and a pointer to a box - * and determines if the box is outside/inside/partly inside the region. - * - * The idea is to travel through the list of rectangles trying to cover the - * passed box with them. Anytime a piece of the rectangle isn't covered - * by a band of rectangles, partOut is set PixRegionStatusSuccess. Any time a rectangle in - * the region covers part of the box, partIn is set PixRegionStatusSuccess. The process ends - * when either the box has been completely covered (we reached a band that - * doesn't overlap the box, partIn is PixRegionStatusSuccess and partOut is false), the - * box has been partially covered (partIn == partOut == PixRegionStatusSuccess -- because of - * the banding, the first time this is true we know the box is only - * partially in the region) or is outside the region (we reached a band - * that doesn't overlap the box at all and partIn is false) - */ - -int -PixRegionRectIn(region, prect) - PixRegion * region; - PixRegionBox * prect; -{ - int x; - int y; - PixRegionBox * pbox; - PixRegionBox * pboxEnd; - int partIn, partOut; - int numRects; - - good(region); - numRects = PIXREGION_NUM_RECTS(region); - /* useful optimization */ - if (!numRects || !EXTENTCHECK(®ion->extents, prect)) - return(rgnOUT); - - if (numRects == 1) - { - /* We know that it must be rgnIN or rgnPART */ - if (SUBSUMES(®ion->extents, prect)) - return(rgnIN); - else - return(rgnPART); - } - - partOut = PixRegionStatusFailure; - partIn = PixRegionStatusFailure; - - /* (x,y) starts at upper left of rect, moving to the right and down */ - x = prect->x1; - y = prect->y1; - - /* can stop when both partOut and partIn are PixRegionStatusSuccess, or we reach prect->y2 */ - for (pbox = PIXREGION_BOXPTR(region), pboxEnd = pbox + numRects; - pbox != pboxEnd; - pbox++) - { - - if (pbox->y2 <= y) - continue; /* getting up to speed or skipping remainder of band */ - - if (pbox->y1 > y) - { - partOut = PixRegionStatusSuccess; /* missed part of rectangle above */ - if (partIn || (pbox->y1 >= prect->y2)) - break; - y = pbox->y1; /* x guaranteed to be == prect->x1 */ - } - - if (pbox->x2 <= x) - continue; /* not far enough over yet */ - - if (pbox->x1 > x) - { - partOut = PixRegionStatusSuccess; /* missed part of rectangle to left */ - if (partIn) - break; - } - - if (pbox->x1 < prect->x2) - { - partIn = PixRegionStatusSuccess; /* definitely overlap */ - if (partOut) - break; - } - - if (pbox->x2 >= prect->x2) - { - y = pbox->y2; /* finished with this band */ - if (y >= prect->y2) - break; - x = prect->x1; /* reset x out to left again */ - } - else - { - /* - * Because boxes in a band are maximal width, if the first box - * to overlap the rectangle doesn't completely cover it in that - * band, the rectangle must be partially out, since some of it - * will be uncovered in that band. partIn will have been set true - * by now... - */ - partOut = PixRegionStatusSuccess; - break; - } - } - - return(partIn ? ((y < prect->y2) ? rgnPART : rgnIN) : rgnOUT); -} - -/* PixRegionTranslate (region, x, y) - translates in place -*/ - -void -PixRegionTranslate (PixRegion * region, int x, int y) -{ - int x1, x2, y1, y2; - int nbox; - PixRegionBox * pbox; - - good(region); - region->extents.x1 = x1 = region->extents.x1 + x; - region->extents.y1 = y1 = region->extents.y1 + y; - region->extents.x2 = x2 = region->extents.x2 + x; - region->extents.y2 = y2 = region->extents.y2 + y; - if (((x1 - SHRT_MIN)|(y1 - SHRT_MIN)|(SHRT_MAX - x2)|(SHRT_MAX - y2)) >= 0) - { - if (region->data && (nbox = region->data->numRects)) - { - for (pbox = PIXREGION_BOXPTR(region); nbox--; pbox++) - { - pbox->x1 += x; - pbox->y1 += y; - pbox->x2 += x; - pbox->y2 += y; - } - } - return; - } - if (((x2 - SHRT_MIN)|(y2 - SHRT_MIN)|(SHRT_MAX - x1)|(SHRT_MAX - y1)) <= 0) - { - region->extents.x2 = region->extents.x1; - region->extents.y2 = region->extents.y1; - freeData(region); - region->data = &PixRegionEmptyData; - return; - } - if (x1 < SHRT_MIN) - region->extents.x1 = SHRT_MIN; - else if (x2 > SHRT_MAX) - region->extents.x2 = SHRT_MAX; - if (y1 < SHRT_MIN) - region->extents.y1 = SHRT_MIN; - else if (y2 > SHRT_MAX) - region->extents.y2 = SHRT_MAX; - if (region->data && (nbox = region->data->numRects)) - { - PixRegionBox * pboxout; - - for (pboxout = pbox = PIXREGION_BOXPTR(region); nbox--; pbox++) - { - pboxout->x1 = x1 = pbox->x1 + x; - pboxout->y1 = y1 = pbox->y1 + y; - pboxout->x2 = x2 = pbox->x2 + x; - pboxout->y2 = y2 = pbox->y2 + y; - if (((x2 - SHRT_MIN)|(y2 - SHRT_MIN)| - (SHRT_MAX - x1)|(SHRT_MAX - y1)) <= 0) - { - region->data->numRects--; - continue; - } - if (x1 < SHRT_MIN) - pboxout->x1 = SHRT_MIN; - else if (x2 > SHRT_MAX) - pboxout->x2 = SHRT_MAX; - if (y1 < SHRT_MIN) - pboxout->y1 = SHRT_MIN; - else if (y2 > SHRT_MAX) - pboxout->y2 = SHRT_MAX; - pboxout++; - } - if (pboxout != pbox) - { - if (region->data->numRects == 1) - { - region->extents = *PIXREGION_BOXPTR(region); - freeData(region); - region->data = (PixRegionData *)NULL; - } - else - PixRegionSetExtents(region); - } - } -} - -/* XXX: Do we need this? -static PixRegionStatus -PixRegionDataCopy(PixRegion * dst, PixRegion * src) -{ - good(dst); - good(src); - if (dst->data) - return PixRegionStatusSuccess; - if (dst == src) - return PixRegionStatusSuccess; - if (!src->data || !src->data->size) - { - freeData(dst); - dst->data = (PixRegionData *)NULL; - return PixRegionStatusSuccess; - } - if (!dst->data || (dst->data->size < src->data->numRects)) - { - freeData(dst); - dst->data = allocData(src->data->numRects); - if (!dst->data) - return PixRegionBreak (dst); - } - dst->data->size = src->data->size; - dst->data->numRects = src->data->numRects; - return PixRegionStatusSuccess; -} -*/ - -void -PixRegionReset(PixRegion *region, PixRegionBox *box) -{ - good(region); - assert(box->x1<=box->x2); - assert(box->y1<=box->y2); - region->extents = *box; - freeData(region); - region->data = (PixRegionData *)NULL; -} - -int -PixRegionPointInRegion(region, x, y, box) - PixRegion * region; - int x, y; - PixRegionBox * box; /* "return" value */ -{ - PixRegionBox *pbox, *pboxEnd; - int numRects; - - good(region); - numRects = PIXREGION_NUM_RECTS(region); - if (!numRects || !INBOX(®ion->extents, x, y)) - return(PixRegionStatusFailure); - if (numRects == 1) - { - *box = region->extents; - return(PixRegionStatusSuccess); - } - for (pbox = PIXREGION_BOXPTR(region), pboxEnd = pbox + numRects; - pbox != pboxEnd; - pbox++) - { - if (y >= pbox->y2) - continue; /* not there yet */ - if ((y < pbox->y1) || (x < pbox->x1)) - break; /* missed it */ - if (x >= pbox->x2) - continue; /* not there yet */ - *box = *pbox; - return(PixRegionStatusSuccess); - } - return(PixRegionStatusFailure); -} - -int -PixRegionNotEmpty(region) - PixRegion * region; -{ - good(region); - return(!PIXREGION_NIL(region)); -} - -/* XXX: Do we need this? -static int -PixRegionBroken(PixRegion * region) -{ - good(region); - return (PIXREGION_NAR(region)); -} -*/ - -void -PixRegionEmpty(region) - PixRegion * region; -{ - good(region); - freeData(region); - region->extents.x2 = region->extents.x1; - region->extents.y2 = region->extents.y1; - region->data = &PixRegionEmptyData; -} - -PixRegionBox * -PixRegionExtents(region) - PixRegion * region; -{ - good(region); - return(®ion->extents); -} - -#define ExchangeSpans(a, b) \ -{ \ - PixRegionPoint tpt; \ - int tw; \ - \ - tpt = spans[a]; spans[a] = spans[b]; spans[b] = tpt; \ - tw = widths[a]; widths[a] = widths[b]; widths[b] = tw; \ -} - -/* ||| I should apply the merge sort code to rectangle sorting above, and see - if mapping time can be improved. But right now I've been at work 12 hours, - so forget it. -*/ - -static void QuickSortSpans( - PixRegionPoint spans[], - int widths[], - int numSpans) -{ - int y; - int i, j, m; - PixRegionPoint *r; - - /* Always called with numSpans > 1 */ - /* Sorts only by y, doesn't bother to sort by x */ - - do - { - if (numSpans < 9) - { - /* Do insertion sort */ - int yprev; - - yprev = spans[0].y; - i = 1; - do - { /* while i != numSpans */ - y = spans[i].y; - if (yprev > y) - { - /* spans[i] is out of order. Move into proper location. */ - PixRegionPoint tpt; - int tw, k; - - for (j = 0; y >= spans[j].y; j++) {} - tpt = spans[i]; - tw = widths[i]; - for (k = i; k != j; k--) - { - spans[k] = spans[k-1]; - widths[k] = widths[k-1]; - } - spans[j] = tpt; - widths[j] = tw; - y = spans[i].y; - } /* if out of order */ - yprev = y; - i++; - } while (i != numSpans); - return; - } - - /* Choose partition element, stick in location 0 */ - m = numSpans / 2; - if (spans[m].y > spans[0].y) ExchangeSpans(m, 0); - if (spans[m].y > spans[numSpans-1].y) ExchangeSpans(m, numSpans-1); - if (spans[m].y > spans[0].y) ExchangeSpans(m, 0); - y = spans[0].y; - - /* Partition array */ - i = 0; - j = numSpans; - do - { - r = &(spans[i]); - do - { - r++; - i++; - } while (i != numSpans && r->y < y); - r = &(spans[j]); - do - { - r--; - j--; - } while (y < r->y); - if (i < j) - ExchangeSpans(i, j); - } while (i < j); - - /* Move partition element back to middle */ - ExchangeSpans(0, j); - - /* Recurse */ - if (numSpans-j-1 > 1) - QuickSortSpans(&spans[j+1], &widths[j+1], numSpans-j-1); - numSpans = j; - } while (numSpans > 1); -} - -#define NextBand() \ -{ \ - clipy1 = pboxBandStart->y1; \ - clipy2 = pboxBandStart->y2; \ - pboxBandEnd = pboxBandStart + 1; \ - while (pboxBandEnd != pboxLast && pboxBandEnd->y1 == clipy1) { \ - pboxBandEnd++; \ - } \ - for (; ppt != pptLast && ppt->y < clipy1; ppt++, pwidth++) {} \ -} - -/* - Clip a list of scanlines to a region. The caller has allocated the - space. FSorted is non-zero if the scanline origins are in ascending - order. - returns the number of new, clipped scanlines. -*/ - -#ifdef XXX_DO_WE_NEED_THIS -static int -PixRegionClipSpans( - PixRegion *prgnDst, - PixRegionPoint *ppt, - int *pwidth, - int nspans, - PixRegionPoint *pptNew, - int *pwidthNew, - int fSorted) -{ - PixRegionPoint *pptLast; - int *pwidthNewStart; /* the vengeance of Xerox! */ - int y, x1, x2; - int numRects; - - good(prgnDst); - pptLast = ppt + nspans; - pwidthNewStart = pwidthNew; - - if (!prgnDst->data) - { - /* Do special fast code with clip boundaries in registers(?) */ - /* It doesn't pay much to make use of fSorted in this case, - so we lump everything together. */ - - int clipx1, clipx2, clipy1, clipy2; - - clipx1 = prgnDst->extents.x1; - clipy1 = prgnDst->extents.y1; - clipx2 = prgnDst->extents.x2; - clipy2 = prgnDst->extents.y2; - - for (; ppt != pptLast; ppt++, pwidth++) - { - y = ppt->y; - x1 = ppt->x; - if (clipy1 <= y && y < clipy2) - { - x2 = x1 + *pwidth; - if (x1 < clipx1) x1 = clipx1; - if (x2 > clipx2) x2 = clipx2; - if (x1 < x2) - { - /* part of span in clip rectangle */ - pptNew->x = x1; - pptNew->y = y; - *pwidthNew = x2 - x1; - pptNew++; - pwidthNew++; - } - } - } /* end for */ - - } - else if ((numRects = prgnDst->data->numRects)) - { - /* Have to clip against many boxes */ - PixRegionBox *pboxBandStart, *pboxBandEnd; - PixRegionBox *pbox; - PixRegionBox *pboxLast; - int clipy1, clipy2; - - /* In this case, taking advantage of sorted spans gains more than - the sorting costs. */ - if ((! fSorted) && (nspans > 1)) - QuickSortSpans(ppt, pwidth, nspans); - - pboxBandStart = PIXREGION_BOXPTR(prgnDst); - pboxLast = pboxBandStart + numRects; - - NextBand(); - - for (; ppt != pptLast; ) - { - y = ppt->y; - if (y < clipy2) - { - /* span is in the current band */ - pbox = pboxBandStart; - x1 = ppt->x; - x2 = x1 + *pwidth; - do - { /* For each box in band */ - int newx1, newx2; - - newx1 = x1; - newx2 = x2; - if (newx1 < pbox->x1) newx1 = pbox->x1; - if (newx2 > pbox->x2) newx2 = pbox->x2; - if (newx1 < newx2) - { - /* Part of span in clip rectangle */ - pptNew->x = newx1; - pptNew->y = y; - *pwidthNew = newx2 - newx1; - pptNew++; - pwidthNew++; - } - pbox++; - } while (pbox != pboxBandEnd); - ppt++; - pwidth++; - } - else - { - /* Move to next band, adjust ppt as needed */ - pboxBandStart = pboxBandEnd; - if (pboxBandStart == pboxLast) - break; /* We're completely done */ - NextBand(); - } - } - } - return (pwidthNew - pwidthNewStart); -} - -/* find the band in a region with the most rectangles */ -static int -PixRegionFindMaxBand(PixRegion * prgn) -{ - int nbox; - PixRegionBox * pbox; - int nThisBand; - int nMaxBand = 0; - short yThisBand; - - good(prgn); - nbox = PIXREGION_NUM_RECTS(prgn); - pbox = PIXREGION_RECTS(prgn); - - while(nbox > 0) - { - yThisBand = pbox->y1; - nThisBand = 0; - while((nbox > 0) && (pbox->y1 == yThisBand)) - { - nbox--; - pbox++; - nThisBand++; - } - if (nThisBand > nMaxBand) - nMaxBand = nThisBand; - } - return (nMaxBand); -} -#endif /* XXX_DO_WE_NEED_THIS */ diff --git a/pixman/src/pixregionint.h b/pixman/src/pixregionint.h deleted file mode 100644 index b06b2b650..000000000 --- a/pixman/src/pixregionint.h +++ /dev/null @@ -1,83 +0,0 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ -/* $Id: pixregionint.h,v 1.3 2003-07-30 17:06:34 rth Exp $ */ - -#ifndef _PIXREGIONINT_H_ -#define _PIXREGIONINT_H_ - -#include "pixregion.h" - -typedef struct _PixRegionData { - long size; - long numRects; - /* XXX: And why, exactly, do we have this bogus struct definition? */ -/* PixRegionBox rects[size]; in memory but not explicitly declared */ -} PixRegionData; - -struct _PixRegion { - PixRegionBox extents; - PixRegionData *data; -}; - -typedef struct _PixRegionPoint { - int x, y; -} PixRegionPoint; - -#define PIXREGION_NIL(reg) ((reg)->data && !(reg)->data->numRects) -/* not a region */ -#define PIXREGION_NAR(reg) ((reg)->data == &PixRegionBrokenData) -#define PIXREGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1) -#define PIXREGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0) -#define PIXREGION_RECTS(reg) ((reg)->data ? (PixRegionBox *)((reg)->data + 1) \ - : &(reg)->extents) -#define PIXREGION_BOXPTR(reg) ((PixRegionBox *)((reg)->data + 1)) -#define PIXREGION_BOX(reg,i) (&PIXREGION_BOXPTR(reg)[i]) -#define PIXREGION_TOP(reg) PIXREGION_BOX(reg, (reg)->data->numRects) -#define PIXREGION_END(reg) PIXREGION_BOX(reg, (reg)->data->numRects - 1) -#define PIXREGION_SZOF(n) (sizeof(PixRegionData) + ((n) * sizeof(PixRegionBox))) - -#endif /* _PIXREGIONINT_H_ */ diff --git a/pixman/src/slim_export.h b/pixman/src/slim_export.h deleted file mode 100644 index 1abcdbcb9..000000000 --- a/pixman/src/slim_export.h +++ /dev/null @@ -1,54 +0,0 @@ -/* slim - Shared Library Interface Macros - * - * Copyright © 2003 Richard Henderson - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of Richard Henderson - * not be used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Richard Henderson makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * RICHARD HENDERSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN - * NO EVENT SHALL RICHARD HENDERSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Richard Henderson <rth@twiddle.net> - */ - -/* This file is included multiple times. Don't ifdef protect it. */ - -/* This macro marks a symbol as being exported from an external library. - Explicitly exporting any symbols overrides the default action of the - linker to export all symbols. This prevents users of the library from - knowingly or unknowingly accessing library internals that may change - in future releases. - - The macro should be placed either immediately before a function name, - - extern int __external_linkage - somefunction(void); - - or after a data name, - - extern int somedata __external_linkage; - - This header should be included after all other headers at the beginning - of a package's external header, and __external_linkage should be #undef'ed - at the end. */ -/* ??? Not marked with "slim" because that makes it look too much - like the function name instead of just an attribute. */ - -#if defined(WIN32) || defined(__CYGWIN__) -#define __external_linkage __declspec(dllexport) -#else -#define __external_linkage -#endif diff --git a/pixman/src/slim_import.h b/pixman/src/slim_import.h deleted file mode 100644 index 0d7d61232..000000000 --- a/pixman/src/slim_import.h +++ /dev/null @@ -1,53 +0,0 @@ -/* slim - Shared Library Interface Macros - * - * Copyright © 2003 Richard Henderson - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of Richard Henderson - * not be used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Richard Henderson makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * RICHARD HENDERSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN - * NO EVENT SHALL RICHARD HENDERSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Richard Henderson <rth@twiddle.net> - */ - -/* This file is included multiple times. Don't ifdef protect it. */ - -/* This macro marks a symbol as being imported from an external library. - This is essential for data symbols as otherwise the compiler can't - generate the address properly. It is advised for functions, as the - compiler can generate the indirect call inline. - - The macro should be placed either immediately before a function name, - - extern int __external_linkage - somefunction(void); - - or after a data name, - - extern int somedata __external_linkage; - - This header should be included after all other headers at the beginning - of a package's external header, and __external_linkage should be #undef'ed - at the end. */ -/* ??? Not marked with "slim" because that makes it look too much - like the function name instead of just an attribute. */ - -#if defined(WIN32) || defined(__CYGWIN__) -#define __external_linkage __declspec(dllimport) -#else -#define __external_linkage -#endif diff --git a/pixman/src/slim_internal.h b/pixman/src/slim_internal.h deleted file mode 100644 index abd0fb0a5..000000000 --- a/pixman/src/slim_internal.h +++ /dev/null @@ -1,99 +0,0 @@ -/* slim - Shared Library Interface Macros - * - * Copyright © 2003 Richard Henderson - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of Richard Henderson - * not be used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Richard Henderson makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * RICHARD HENDERSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN - * NO EVENT SHALL RICHARD HENDERSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Richard Henderson <rth@twiddle.net> - */ - -#ifndef _SLIM_INTERNAL_H_ -#define _SLIM_INTERNAL_H_ 1 - -/* This macro marks a symbol as STV_HIDDEN, which prevents it from being - added to the dynamic symbol table of the shared library. This prevents - users of the library from knowingly or unknowingly accessing library - internals that may change in future releases. It also allows the - compiler to generate slightly more efficient code in some cases. - - The macro should be placed either immediately before a function name, - - extern int __internal_linkage - somefunction(void); - - or after a data name, - - extern int somedata __internal_linkage; - - The ELF visibility attribute did not exist before gcc 3.3. */ -/* ??? Not marked with "slim" because that makes it look too much - like the function name instead of just an attribute. */ - -#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) -#define __internal_linkage __attribute__((__visibility__("hidden"))) -#else -#define __internal_linkage -#endif - -/* The following macros are used for PLT bypassing. First of all, - you need to have the function prototyped somewhere, say in foo.h: - - int foo (int __bar); - - If calls to foo within libfoo.so should always go to foo defined - in libfoo.so, then in fooint.h you add: - - slim_hidden_proto (foo) - - and after the foo function definition: - - int foo (int __bar) - { - return __bar; - } - slim_hidden_def (foo); - - This works by arranging for the C symbol "foo" to be renamed to - "INT_foo" at the assembly level, which is marked __internal_linkage. - We then create another symbol at the same address (an alias) with - the C symbol "EXT_foo", which is renamed to "foo" at the assembly - level. */ - -#if __GNUC__ >= 3 && defined(__ELF__) -# define slim_hidden_proto(name) slim_hidden_proto1(name, INT_##name) -# define slim_hidden_def(name) slim_hidden_def1(name, INT_##name) -# define slim_hidden_proto1(name, internal) \ - extern __typeof (name) name \ - __asm__ (slim_hidden_asmname (internal)) \ - __internal_linkage; -# define slim_hidden_def1(name, internal) \ - extern __typeof (name) EXT_##name __asm__(slim_hidden_asmname(name)) \ - __attribute__((__alias__(slim_hidden_asmname(internal)))) -# define slim_hidden_ulp slim_hidden_ulp1(__USER_LABEL_PREFIX__) -# define slim_hidden_ulp1(x) slim_hidden_ulp2(x) -# define slim_hidden_ulp2(x) #x -# define slim_hidden_asmname(name) slim_hidden_asmname1(name) -# define slim_hidden_asmname1(name) slim_hidden_ulp #name -#else -# define slim_hidden_proto(name) -# define slim_hidden_def(name) -#endif - -#endif /* _SLIM_INTERNAL_H_ */ |