зеркало из https://github.com/mozilla/gecko-dev.git
b=383960, Cairo 1.5.x: pixman
This commit is contained in:
Родитель
5069dab5e9
Коммит
4ab74b7cf4
|
@ -1,19 +0,0 @@
|
|||
David R Bacon <dbacon@cis.ksu.edu> Fixes to compile on x86_64.
|
||||
Billy Biggs <vektor@dumbterm.net> Fix to use stdint datatypes.
|
||||
Dave Beckett <Dave.Beckett@bristol.ac.uk> Combined libpixregion, libic, and slim.
|
||||
Jakub Bogusz <qboosh@pld-linux.org> Fixes for 64-bit machines.
|
||||
Anders Carlsson <andersca@gnome.org> Build fixes. New accessor functions.
|
||||
Richard Henderson <rth@twiddle.net> "slim" macros for better shared libraries
|
||||
Owen Taylor <otaylor@redhat.com> Support for both transform and repeat
|
||||
Keith Packard <keithp@keithp.com> The original implementation of the compositing code.
|
||||
David Reveman <c99drn@cs.umu.se> Byte-order, clipping and format fixes.
|
||||
Vladimir Vukicevic <vladimir@pobox.com> Bug fix.
|
||||
Bryan Worth <bryan@theworths.org> Cleanups to not depend on X header files.
|
||||
Carl Worth <carl@theworths.org> General maintenance. Original port from X server code.
|
||||
Richard Worth <richard@theworths.org> Build fixes for cygwin.
|
||||
|
||||
and the "X Window System authors" (pixregion code)
|
||||
|
||||
(Please let us know if we have missed anyone. I would be interested in
|
||||
having more precise attribution for the pixregion code if anyone knows
|
||||
who wrote that.)
|
|
@ -1,92 +0,0 @@
|
|||
libpixregion
|
||||
|
||||
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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
libic
|
||||
|
||||
Copyright © 2001 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
slim
|
||||
|
||||
slim is 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.
|
||||
|
|
@ -1,9 +1,234 @@
|
|||
This code uses automake, in order to generate the Makefiles use:
|
||||
Installation Instructions
|
||||
*************************
|
||||
|
||||
$ autogen.sh
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
|
||||
2006 Free Software Foundation, Inc.
|
||||
|
||||
After that, standard build procedures apply:
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
$ make
|
||||
# make install
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
Briefly, the shell commands `./configure; make; make install' should
|
||||
configure, build, and install this package. The following
|
||||
more-detailed instructions are generic; see the `README' file for
|
||||
instructions specific to this package.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You need `configure.ac' if
|
||||
you want to change it or regenerate `configure' using a newer version
|
||||
of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system.
|
||||
|
||||
Running `configure' might take a while. While running, it prints
|
||||
some messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that the
|
||||
`configure' script does not know about. Run `./configure --help' for
|
||||
details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c99 CFLAGS=-g LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you can use GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
With a non-GNU `make', it is safer to compile the package for one
|
||||
architecture at a time in the source code directory. After you have
|
||||
installed the package for one architecture, use `make distclean' before
|
||||
reconfiguring for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' installs the package's commands under
|
||||
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||
can specify an installation prefix other than `/usr/local' by giving
|
||||
`configure' the option `--prefix=PREFIX'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=DIR' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out automatically,
|
||||
but needs to determine by the type of machine the package will run on.
|
||||
Usually, assuming the package is built to be run on the _same_
|
||||
architectures, `configure' can figure that out, but if it prints a
|
||||
message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the option `--target=TYPE' to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share, you
|
||||
can create a site shell script called `config.site' that gives default
|
||||
values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
|
||||
an Autoconf bug. Until the bug is fixed you can use this workaround:
|
||||
|
||||
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
|
|
|
@ -1,135 +0,0 @@
|
|||
Snapshot 0.1.6 (2005-07-28 Carl Worth <cworth@cworth.org>)
|
||||
==========================================================
|
||||
Behavioral changes
|
||||
------------------
|
||||
Clips are changed to only affect destination operands, not
|
||||
sources. This gives the desired behavior for cairo. If the X server's
|
||||
Render implementation wants to use pixman it will have to select
|
||||
source clipping, (presumably through a new API call that we can add at
|
||||
that point).
|
||||
|
||||
Bug fixes
|
||||
---------
|
||||
Fix leak of the clip region associated with an image in
|
||||
pixman_image_destroy.
|
||||
|
||||
Fix units for stride return to be FbStip-sized, (this bug was causing
|
||||
non antialiased text in cairo to appear as garbage).
|
||||
|
||||
Other changes
|
||||
-------------
|
||||
The implementation has been merged considerably with xserver/fb. Most
|
||||
of the merge was just name changes, but there were likely some bug
|
||||
fixes or performance improvements in there as well.
|
||||
|
||||
Snapshot 0.1.5 (2005-05-18 Carl Worth <cworth@cworth.org>)
|
||||
==========================================================
|
||||
Bug fixes
|
||||
---------
|
||||
Fix confusion of depth and bpp which was causing cairo to crash on
|
||||
some X servers.
|
||||
|
||||
Properly declare pixman_fixed16_16_t as int32_t which fixes
|
||||
compilation failures on some platforms.
|
||||
|
||||
Fix to find inttypes.h on AIX.
|
||||
|
||||
Fix bug in compositing when the source image has no alpha channel.
|
||||
|
||||
Some fixes to the clipping code.
|
||||
|
||||
Fix memory leak when asked to draw a degenerate trapezoid list.
|
||||
|
||||
Snapshot 0.1.4 (2005-03-07 Carl Worth <cworth@cworth.org>)
|
||||
==========================================================
|
||||
API Addition
|
||||
------------
|
||||
Add new function:
|
||||
|
||||
void
|
||||
pixman_add_trapezoids (pixman_image_t *dst,
|
||||
int x_off,
|
||||
int y_off,
|
||||
const pixman_trapezoid_t *traps,
|
||||
int ntraps);
|
||||
|
||||
Performance improvement
|
||||
-----------------------
|
||||
Restrict size of intermediate surface used while compositing
|
||||
trapezoids based on the bounds of the desination surface.
|
||||
|
||||
Bug fixes
|
||||
---------
|
||||
Fix rendering on 64-bit platforms.
|
||||
|
||||
Snapshot 0.1.3 (2005-01-21 Carl Worth <cworth@cworth.org>)
|
||||
==========================================================
|
||||
Performance improvements
|
||||
------------------------
|
||||
Solid fills are now much faster, (thanks to Alexander Larsson).
|
||||
|
||||
Bug fixes
|
||||
---------
|
||||
Fixed to quiet warnings in newer versions of gcc.
|
||||
|
||||
Don't divide-by-zero if given an image of size 0x0.
|
||||
|
||||
Fixed several corner cases where values outside a trapezoid would be
|
||||
drawn with alpha 1/255 (in the 8-bit case).
|
||||
|
||||
Internal changes
|
||||
----------------
|
||||
Imported the newer point-sampling trapezoid rasterization code that
|
||||
Keith Packard wrote for the X server. This provide pixel-perfect
|
||||
matching with the Render extension as well as code that is simpler,
|
||||
more robust, and easier to maintain.
|
||||
|
||||
Snapshot 0.1.2 (2004-10-27 Carl Worth <cworth@cworth.org>)
|
||||
==========================================================
|
||||
New functionality
|
||||
-----------------
|
||||
Added three new functions:
|
||||
|
||||
pixman_image_set_component_alpha
|
||||
pixman_format_get_masks
|
||||
pixman_image_get_format
|
||||
|
||||
The first enables component-alpha compositing which can be used for
|
||||
optimizing sub-pixel rendering of text and other geometry. This is
|
||||
useful when the geometrical relationship of the sub-pixel components
|
||||
of the display device are known, (eg. with flat-panel monitors rather
|
||||
than CRTs).
|
||||
|
||||
The other two functions are simple query functions that were missing.
|
||||
|
||||
Bug fixes
|
||||
---------
|
||||
Enabling both transform and repeat simultaneously now works.
|
||||
Some byte-order fixes.
|
||||
Clipping fixes: pixman now takes a copy of the client clipping region
|
||||
client clipping is now actually used, it wasn't earlier.
|
||||
|
||||
Snapshot 0.1.1 (2004-04-16 Carl Worth <cworth@east.isi.edu>)
|
||||
============================================================
|
||||
Build fixes for cygwin
|
||||
----------------------
|
||||
This snapshot adds the -no-undefined flag during compilation which is
|
||||
necessart for building a shared library under cygwin.
|
||||
|
||||
Cleanup of the public API
|
||||
-------------------------
|
||||
We recently noticed that there were a coupld of bugs in the script
|
||||
that renamed libic to libpixman. Fixing this requires the following
|
||||
changes in the public API:
|
||||
|
||||
PIXMAN_FORMAT_AR_GB32 -> PIXMAN_FORMAT_ARGB32
|
||||
PIXMAN_FORMAT_RG_B24 -> PIXMAN_FORMAT_RGB24
|
||||
|
||||
While we're changing that, we also normalized the names of structure
|
||||
tags, for example:
|
||||
|
||||
struct _pixman_region16_t -> struct pixman_region16
|
||||
etc.
|
||||
|
||||
but users are expected to use typedefs such as pixman_region16_t
|
||||
anyway.
|
|
@ -1,47 +0,0 @@
|
|||
libpixman - Pixel manipulation library
|
||||
|
||||
libpixman is a merge of libpixregion and libic.
|
||||
It also includes the slim headers.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
libic - Image compositing library
|
||||
|
||||
libic is a generic image compositing library. libic provides
|
||||
Porter/Duff compositing of images and implicit mask generation for
|
||||
geometric primitives including trapezoids, triangles, and rectangles.
|
||||
|
||||
The semantics of libic are designed to precisely match the
|
||||
specification of the X Render extension. In fact, the initial
|
||||
implementation of libic was lifted from the reference implementation
|
||||
of RENDER from the X server.
|
||||
|
||||
However, libic is intended to be useful independent of the X Window
|
||||
System. The public interface exported by libic does not contain any
|
||||
X-specific data structures.
|
||||
|
||||
Carl Worth
|
||||
cworth@isi.edu
|
||||
|
||||
Keith Packard (keithp@keithp.com) originally wrote all the original
|
||||
RENDER code that was yanked out to become libic. Keith also provided
|
||||
impetus and guidance in the development of libic.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
slim - Shared Library Interface Macros
|
|
@ -1,10 +1,139 @@
|
|||
Need to finish up libpixman to the point where there X server can use
|
||||
it in place of its original copy of all this code (eg. in fb). This
|
||||
means merging features that have happened in either tree since the
|
||||
birth of libpixman. Off-hand I can think of the following things that
|
||||
have happened:
|
||||
- Go through things marked FIXME
|
||||
|
||||
* libpixman has fix for transform + repeat
|
||||
* X server has some (MMX? SSE?) optimized compositing code
|
||||
- Add calls to prepare and finish access where necessary. grep for
|
||||
ACCESS_MEM, and make sure they are correctly wrapped in prepare
|
||||
and finish.
|
||||
|
||||
- restore READ/WRITE in the fbcompose combiners since they sometimes
|
||||
store directly to destination drawables.
|
||||
|
||||
- It probably makes sense to move the more strange X region API
|
||||
into pixman as well, but guarded with PIXMAN_XORG_COMPATIBILITY
|
||||
|
||||
- Reinstate the FbBits typedef? At the moment we don't
|
||||
even have the FbBits type; we just use uint32_t everywhere.
|
||||
|
||||
Keith says in bug 2335:
|
||||
|
||||
The 64-bit code in fb (pixman) is probably broken; it hasn't been
|
||||
used in quite some time as PCI (and AGP) is 32-bits wide, so
|
||||
doing things 64-bits at a time is a net loss. To quickly fix
|
||||
this, I suggest just using 32-bit datatypes by setting
|
||||
IC_SHIFT to 5 for all machines.
|
||||
|
||||
- Consider whether calling regions region16 is really such a great
|
||||
idea Vlad wants 32 bit regions for Cairo. This will break X server
|
||||
ABI, but should otherwise be mostly harmless, though a
|
||||
pixman_region_get_boxes16() may be useful.
|
||||
|
||||
- Make source clipping optional.
|
||||
- done: source clipping happens through an indirection.
|
||||
still needs to make the indirection settable. (And call it
|
||||
from X)
|
||||
|
||||
- Consider optimizing the 8/16 bit solid fills in pixman-util.c by
|
||||
storing more than one value at a time.
|
||||
|
||||
- Add an image cache to prevent excessive malloc/free. Note that pixman
|
||||
needs to be thread safe when used from cairo.
|
||||
|
||||
- Review the pixman_format_code_t enum to make sure it will support
|
||||
future formats. Some formats we will probably need:
|
||||
|
||||
ARGB/ABGR with 16/32/64 bit integer/floating channels
|
||||
YUV2,
|
||||
YV12
|
||||
|
||||
Also we may need the ability to distinguish between PICT_c8 and
|
||||
PICT_x4c4. (This could be done by interpreting the A channel as
|
||||
the depth for TYPE_COLOR and TYPE_GRAY formats).
|
||||
|
||||
A possibility may be to reserve the two top bits and make them
|
||||
encode "number of places to shift the channel widths given" Since
|
||||
these bits are 00 at the moment everything will continue to work,
|
||||
but these additional widths will be allowed:
|
||||
|
||||
All even widths between 18-32
|
||||
All multiples of four widths between 33 and 64
|
||||
All multiples of eight between 64 and 128
|
||||
|
||||
This means things like r21g22b21 won't work - is that worth
|
||||
worrying about? I don't think so. And of course the bpp field
|
||||
can't handle a depth of over 256, so > 64 bit channels arent'
|
||||
really all that useful.
|
||||
|
||||
We could reserve one extra bit to indicate floating point, but
|
||||
we may also just add
|
||||
|
||||
PIXMAN_TYPE_ARGB_FLOAT
|
||||
PIXMAN_TYPE_BGRA_FLOAT
|
||||
PIXMAN_TYPE_A_FLOAT
|
||||
|
||||
image types. With five bits we can support up to 32 different
|
||||
format types, which should be enough for everybody, even if we
|
||||
decide to support all the various video formats here:
|
||||
|
||||
http://www.fourcc.org/yuv.php
|
||||
|
||||
It may make sense to have a PIXMAN_TYPE_YUV, and then use the
|
||||
channel bits to specify the exact subtype.
|
||||
|
||||
What about color spaces such a linear vs. srGB etc.?
|
||||
|
||||
|
||||
done:
|
||||
|
||||
- Run cairo test suite; fix bugs
|
||||
- one bug in source-scale-clip
|
||||
|
||||
- Remove the warning suppression in the ACCESS_MEM macro and fix the
|
||||
warnings that are real
|
||||
- irrelevant now.
|
||||
|
||||
- make the wrapper functions global instead of image specific
|
||||
- this won't work since pixman is linked to both fb and wfb
|
||||
|
||||
- Add non-mmx solid fill
|
||||
|
||||
- Make sure the endian-ness macros are defined correctly.
|
||||
|
||||
- The rectangles in a region probably shouldn't be returned const as
|
||||
the X server will be changing them.
|
||||
|
||||
- Right now we _always_ have a clip region, which is empty by default.
|
||||
Why does this work at all? It probably doesn't. The server
|
||||
distinguishes two cases, one where nothing is clipped (CT_NONE), and
|
||||
one where there is a clip region (CT_REGION).
|
||||
|
||||
- Default clip region should be the full image
|
||||
|
||||
- Test if pseudo color still works. It does, but it also shows that
|
||||
copying a pixman_indexed_t on every composite operation is not
|
||||
going to fly. So, for now set_indexed() does not copy the
|
||||
indexed table.
|
||||
|
||||
Also just the malloc() to allocate a pixman image shows up pretty
|
||||
high.
|
||||
|
||||
Options include
|
||||
|
||||
- Make all the setters not copy their arguments
|
||||
|
||||
- Possibly combined with going back to the stack allocated
|
||||
approach that we already use for regions.
|
||||
|
||||
- Keep a cached pixman_image_t around for every picture. It would
|
||||
have to be kept uptodate every time something changes about the
|
||||
picture.
|
||||
|
||||
- Break the X server ABI and simply have the relevant parameter
|
||||
stored in the pixman image. This would have the additional benefits
|
||||
that:
|
||||
|
||||
- We can get rid of the annoying repeat field which is duplicated
|
||||
elsewhere.
|
||||
|
||||
- We can use pixman_color_t and pixman_gradient_stop_t
|
||||
etc. instead of the types that are defined in
|
||||
renderproto.h
|
||||
|
||||
But see the logs for more details.
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
# Contributor(s):
|
||||
# Brian Ryner <bryner@brianryner.com>
|
||||
# Stuart Parmenter <pavlov@pavlov.net>
|
||||
# Vladimir Vukicevic <vladimir@pobox.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -63,33 +64,26 @@ endif
|
|||
endif
|
||||
|
||||
CSRCS = \
|
||||
fbcompose.c \
|
||||
fbedge.c \
|
||||
fbpict.c \
|
||||
fbtrap.c \
|
||||
icblt.c \
|
||||
icbltone.c \
|
||||
iccolor.c \
|
||||
icformat.c \
|
||||
icimage.c \
|
||||
icpixels.c \
|
||||
icrect.c \
|
||||
icstipple.c \
|
||||
ictransform.c \
|
||||
ictrap.c \
|
||||
ictri.c \
|
||||
icutil.c \
|
||||
pixregion.c \
|
||||
renderedge.c \
|
||||
pixman-compose-accessors.c \
|
||||
pixman-compose-noaccessors.c \
|
||||
pixman-compute-region.c \
|
||||
pixman-edge-accessors.c \
|
||||
pixman-edge-noaccessors.c \
|
||||
pixman-image.c \
|
||||
pixman-pict.c \
|
||||
pixman-region.c \
|
||||
pixman-timer.c \
|
||||
pixman-trap.c \
|
||||
pixman-utils.c \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_X11
|
||||
#CSRCS += fbmmx.c
|
||||
#CSRCS += pixman-mmx.c
|
||||
#DEFINES += -DUSE_MMX
|
||||
endif
|
||||
|
||||
ifdef _MSC_VER
|
||||
CSRCS += fbmmx.c
|
||||
CSRCS += pixman-mmx.c
|
||||
DEFINES += -DUSE_MMX
|
||||
endif
|
||||
|
||||
|
@ -103,6 +97,8 @@ FORCE_USE_PIC = 1
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CFLAGS += -DPACKAGE="mozpixman"
|
||||
|
||||
ifdef MOZ_X11
|
||||
#CFLAGS += -mmmx -msse -Winline --param inline-unit-growth=10000 --param large-function-growth=10000
|
||||
endif
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,301 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 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 <string.h>
|
||||
#include "pixman-xserver-compat.h"
|
||||
|
||||
#ifdef RENDER
|
||||
|
||||
/*
|
||||
* 4 bit alpha
|
||||
*/
|
||||
|
||||
#define N_BITS 4
|
||||
#define rasterizeEdges fbRasterizeEdges4
|
||||
|
||||
#if BITMAP_BIT_ORDER == LSBFirst
|
||||
#define Shift4(o) ((o) << 2)
|
||||
#else
|
||||
#define Shift4(o) ((1-(o)) << 2)
|
||||
#endif
|
||||
|
||||
#define Get4(x,o) (((x) >> Shift4(o)) & 0xf)
|
||||
#define Put4(x,o,v) (((x) & ~(0xf << Shift4(o))) | (((v) & 0xf) << Shift4(o)))
|
||||
|
||||
#define DefineAlpha(line,x) \
|
||||
CARD8 *__ap = (CARD8 *) line + ((x) >> 1); \
|
||||
int __ao = (x) & 1
|
||||
|
||||
#define StepAlpha ((__ap += __ao), (__ao ^= 1))
|
||||
|
||||
#define AddAlpha(a) { \
|
||||
CARD8 __o = *__ap; \
|
||||
CARD8 __a = (a) + Get4(__o, __ao); \
|
||||
*__ap = Put4 (__o, __ao, __a | (0 - ((__a) >> 4))); \
|
||||
}
|
||||
|
||||
#include "fbedgeimp.h"
|
||||
|
||||
#undef AddAlpha
|
||||
#undef StepAlpha
|
||||
#undef DefineAlpha
|
||||
#undef rasterizeEdges
|
||||
#undef N_BITS
|
||||
|
||||
/*
|
||||
* 1 bit alpha
|
||||
*/
|
||||
|
||||
#define N_BITS 1
|
||||
#define rasterizeEdges fbRasterizeEdges1
|
||||
|
||||
#include "fbedgeimp.h"
|
||||
|
||||
#undef rasterizeEdges
|
||||
#undef N_BITS
|
||||
|
||||
/*
|
||||
* 8 bit alpha
|
||||
*/
|
||||
|
||||
static INLINE CARD8
|
||||
clip255 (int x)
|
||||
{
|
||||
if (x > 255) return 255;
|
||||
return x;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
add_saturate_8 (CARD8 *buf, int value, int length)
|
||||
{
|
||||
while (length--)
|
||||
{
|
||||
*buf = clip255 (*buf + value);
|
||||
buf++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We want to detect the case where we add the same value to a long
|
||||
* span of pixels. The triangles on the end are filled in while we
|
||||
* count how many sub-pixel scanlines contribute to the middle section.
|
||||
*
|
||||
* +--------------------------+
|
||||
* fill_height =| \ /
|
||||
* +------------------+
|
||||
* |================|
|
||||
* fill_start fill_end
|
||||
*/
|
||||
static void
|
||||
fbRasterizeEdges8 (FbBits *buf,
|
||||
int width,
|
||||
int stride,
|
||||
RenderEdge *l,
|
||||
RenderEdge *r,
|
||||
xFixed t,
|
||||
xFixed b)
|
||||
{
|
||||
xFixed y = t;
|
||||
FbBits *line;
|
||||
int fill_start = -1, fill_end = -1;
|
||||
int fill_size = 0;
|
||||
|
||||
line = buf + xFixedToInt (y) * stride;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
CARD8 *ap = (CARD8 *) line;
|
||||
xFixed lx, rx;
|
||||
int lxi, rxi;
|
||||
|
||||
/* clip X */
|
||||
lx = l->x;
|
||||
if (lx < 0)
|
||||
lx = 0;
|
||||
rx = r->x;
|
||||
if (xFixedToInt (rx) >= width)
|
||||
rx = IntToxFixed (width);
|
||||
|
||||
/* Skip empty (or backwards) sections */
|
||||
if (rx > lx)
|
||||
{
|
||||
int lxs, rxs;
|
||||
|
||||
/* Find pixel bounds for span. */
|
||||
lxi = xFixedToInt (lx);
|
||||
rxi = xFixedToInt (rx);
|
||||
|
||||
/* Sample coverage for edge pixels */
|
||||
lxs = RenderSamplesX (lx, 8);
|
||||
rxs = RenderSamplesX (rx, 8);
|
||||
|
||||
/* Add coverage across row */
|
||||
if (lxi == rxi)
|
||||
{
|
||||
ap[lxi] = clip255 (ap[lxi] + rxs - lxs);
|
||||
}
|
||||
else
|
||||
{
|
||||
ap[lxi] = clip255 (ap[lxi] + N_X_FRAC(8) - lxs);
|
||||
|
||||
/* Move forward so that lxi/rxi is the pixel span */
|
||||
lxi++;
|
||||
|
||||
/* Don't bother trying to optimize the fill unless
|
||||
* the span is longer than 4 pixels. */
|
||||
if (rxi - lxi > 4)
|
||||
{
|
||||
if (fill_start < 0)
|
||||
{
|
||||
fill_start = lxi;
|
||||
fill_end = rxi;
|
||||
fill_size++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lxi >= fill_end || rxi < fill_start)
|
||||
{
|
||||
/* We're beyond what we saved, just fill it */
|
||||
add_saturate_8 (ap + fill_start,
|
||||
fill_size * N_X_FRAC(8),
|
||||
fill_end - fill_start);
|
||||
fill_start = lxi;
|
||||
fill_end = rxi;
|
||||
fill_size = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Update fill_start */
|
||||
if (lxi > fill_start)
|
||||
{
|
||||
add_saturate_8 (ap + fill_start,
|
||||
fill_size * N_X_FRAC(8),
|
||||
lxi - fill_start);
|
||||
fill_start = lxi;
|
||||
}
|
||||
else if (lxi < fill_start)
|
||||
{
|
||||
add_saturate_8 (ap + lxi, N_X_FRAC(8),
|
||||
fill_start - lxi);
|
||||
}
|
||||
|
||||
/* Update fill_end */
|
||||
if (rxi < fill_end)
|
||||
{
|
||||
add_saturate_8 (ap + rxi,
|
||||
fill_size * N_X_FRAC(8),
|
||||
fill_end - rxi);
|
||||
fill_end = rxi;
|
||||
}
|
||||
else if (fill_end < rxi)
|
||||
{
|
||||
add_saturate_8 (ap + fill_end,
|
||||
N_X_FRAC(8),
|
||||
rxi - fill_end);
|
||||
}
|
||||
fill_size++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
add_saturate_8 (ap + lxi, N_X_FRAC(8), rxi - lxi);
|
||||
}
|
||||
|
||||
/* Do not add in a 0 alpha here. This check is
|
||||
* necessary to avoid a buffer overrun, (when rx
|
||||
* is exactly on a pixel boundary). */
|
||||
if (rxs)
|
||||
ap[rxi] = clip255 (ap[rxi] + rxs);
|
||||
}
|
||||
}
|
||||
|
||||
if (y == b) {
|
||||
/* We're done, make sure we clean up any remaining fill. */
|
||||
if (fill_start != fill_end) {
|
||||
if (fill_size == N_Y_FRAC(8))
|
||||
{
|
||||
memset (ap + fill_start, 0xff, fill_end - fill_start);
|
||||
}
|
||||
else
|
||||
{
|
||||
add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8),
|
||||
fill_end - fill_start);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (xFixedFrac (y) != Y_FRAC_LAST(8))
|
||||
{
|
||||
RenderEdgeStepSmall (l);
|
||||
RenderEdgeStepSmall (r);
|
||||
y += STEP_Y_SMALL(8);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderEdgeStepBig (l);
|
||||
RenderEdgeStepBig (r);
|
||||
y += STEP_Y_BIG(8);
|
||||
if (fill_start != fill_end)
|
||||
{
|
||||
if (fill_size == N_Y_FRAC(8))
|
||||
{
|
||||
memset (ap + fill_start, 0xff, fill_end - fill_start);
|
||||
}
|
||||
else
|
||||
{
|
||||
add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8),
|
||||
fill_end - fill_start);
|
||||
}
|
||||
fill_start = fill_end = -1;
|
||||
fill_size = 0;
|
||||
}
|
||||
line += stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fbRasterizeEdges (FbBits *buf,
|
||||
int bpp,
|
||||
int width,
|
||||
int stride,
|
||||
RenderEdge *l,
|
||||
RenderEdge *r,
|
||||
xFixed t,
|
||||
xFixed b)
|
||||
{
|
||||
switch (bpp) {
|
||||
case 1:
|
||||
fbRasterizeEdges1 (buf, width, stride, l, r, t, b);
|
||||
break;
|
||||
case 4:
|
||||
fbRasterizeEdges4 (buf, width, stride, l, r, t, b);
|
||||
break;
|
||||
case 8:
|
||||
fbRasterizeEdges8 (buf, width, stride, l, r, t, b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* RENDER */
|
|
@ -1,317 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 Red Hat, Inc.
|
||||
* Copyright © 2005 Trolltech AS
|
||||
*
|
||||
* 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 Red Hat not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Red Hat makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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: Søren Sandmann (sandmann@redhat.com)
|
||||
* Lars Knoll (lars@trolltech.com)
|
||||
*
|
||||
* Based on work by Owen Taylor
|
||||
*/
|
||||
#ifdef USE_MMX
|
||||
|
||||
#if !defined(__amd64__) && !defined(__x86_64__)
|
||||
pixman_private
|
||||
Bool fbHaveMMX(void);
|
||||
#else
|
||||
#define fbHaveMMX() TRUE
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define fbHaveMMX() FALSE
|
||||
#endif
|
||||
|
||||
#ifdef USE_MMX
|
||||
|
||||
pixman_private
|
||||
void fbComposeSetupMMX(void);
|
||||
|
||||
pixman_private
|
||||
void fbCompositeIn_nx8x8mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
|
||||
pixman_private
|
||||
void fbCompositeSolidMask_nx8888x0565Cmmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSrcAdd_8888x8888mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSolidMask_nx8888x8888Cmmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSolidMask_nx8x8888mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSolidMaskSrc_nx8x8888mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
|
||||
pixman_private
|
||||
void fbCompositeSrcAdd_8888x8x8mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
|
||||
pixman_private
|
||||
void fbCompositeIn_8x8mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
|
||||
pixman_private
|
||||
void fbCompositeSrcAdd_8000x8000mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSrc_8888RevNPx8888mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSrc_8888x0565mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSrc_8888RevNPx0565mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSolid_nx8888mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSolid_nx0565mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSolidMask_nx8x0565mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSrc_x888x8x8888mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSrc_8888x8x8888mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
void fbCompositeSrc_8888x8888mmx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
pixman_private
|
||||
Bool fbCopyAreammx (FbPixels *pSrc,
|
||||
FbPixels *pDst,
|
||||
int src_x,
|
||||
int src_y,
|
||||
int dst_x,
|
||||
int dst_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
pixman_private
|
||||
void fbCompositeCopyAreammx (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
|
||||
pixman_private
|
||||
Bool fbSolidFillmmx (FbPixels *pDraw,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
FbBits xor);
|
||||
|
||||
#endif /* USE_MMX */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,361 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2000 Keith Packard
|
||||
* 2005 Lars Knoll & Zack Rusin, Trolltech
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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 _FBPICT_H_
|
||||
#define _FBPICT_H_
|
||||
|
||||
#include "pixman-xserver-compat.h"
|
||||
#include "renderedge.h"
|
||||
|
||||
#define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
|
||||
#define FbIntDiv(a,b) (((CARD16) (a) * 255) / (b))
|
||||
|
||||
#define FbGet8(v,i) ((CARD16) (CARD8) ((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 FbOverU(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),(a),(t)) + FbGet8(x,i),\
|
||||
(CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
|
||||
|
||||
#define FbOverC(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),FbGet8(a,i),(t)) + FbGet8(x,i),\
|
||||
(CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
|
||||
|
||||
#define FbInU(x,i,a,t) ((CARD32) FbIntMult(FbGet8(x,i),(a),(t)) << (i))
|
||||
|
||||
#define FbInC(x,i,a,t) ((CARD32) FbIntMult(FbGet8(x,i),FbGet8(a,i),(t)) << (i))
|
||||
|
||||
#define FbGen(x,y,i,ax,ay,t,u,v) ((t) = (FbIntMult(FbGet8(y,i),ay,(u)) + \
|
||||
FbIntMult(FbGet8(x,i),ax,(v))),\
|
||||
(CARD32) ((CARD8) ((t) | \
|
||||
(0 - ((t) >> 8)))) << (i))
|
||||
|
||||
#define FbAdd(x,y,i,t) ((t) = FbGet8(x,i) + FbGet8(y,i), \
|
||||
(CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
|
||||
|
||||
#define Alpha(x) ((x) >> 24)
|
||||
#define Red(x) (((x) >> 16) & 0xff)
|
||||
#define Green(x) (((x) >> 8) & 0xff)
|
||||
#define Blue(x) ((x) & 0xff)
|
||||
|
||||
#define IsRGB(pict) ((pict)->image_format.red > (pict)->image_format.blue)
|
||||
|
||||
#define fbComposeGetSolid(pict, dest, bits) { \
|
||||
FbBits *__bits__; \
|
||||
FbStride __stride__; \
|
||||
int __bpp__; \
|
||||
int __xoff__,__yoff__; \
|
||||
\
|
||||
fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
|
||||
switch (__bpp__) { \
|
||||
case 32: \
|
||||
(bits) = *(CARD32 *) __bits__; \
|
||||
break; \
|
||||
case 24: \
|
||||
(bits) = Fetch24 ((CARD8 *) __bits__); \
|
||||
break; \
|
||||
case 16: \
|
||||
(bits) = *(CARD16 *) __bits__; \
|
||||
(bits) = cvt0565to0888(bits); \
|
||||
break; \
|
||||
case 8: \
|
||||
(bits) = *(CARD8 *) __bits__; \
|
||||
(bits) = (bits) << 24; \
|
||||
break; \
|
||||
case 1: \
|
||||
(bits) = *(CARD32 *) __bits__; \
|
||||
(bits) = FbLeftStipBits((bits),1) ? 0xff000000 : 0x00000000;\
|
||||
break; \
|
||||
default: \
|
||||
return; \
|
||||
} \
|
||||
/* manage missing src alpha */ \
|
||||
if ((pict)->image_format.alphaMask == 0) \
|
||||
(bits) |= 0xff000000; \
|
||||
/* Handle RGB/BGR mismatch */ \
|
||||
if (dest && IsRGB(dest) != IsRGB(pict)) \
|
||||
bits = (((bits & 0xff000000)) | \
|
||||
((bits & 0x00ff0000) >> 16) | \
|
||||
((bits & 0x0000ff00)) | \
|
||||
((bits & 0x000000ff) << 16)); \
|
||||
}
|
||||
|
||||
#define fbComposeGetStart(pict,x,y,type,stride,line,mul) {\
|
||||
FbBits *__bits__; \
|
||||
FbStride __stride__; \
|
||||
int __bpp__; \
|
||||
int __xoff__,__yoff__; \
|
||||
\
|
||||
fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
|
||||
(stride) = __stride__ * sizeof (FbBits) / sizeof (type); \
|
||||
(line) = ((type *) __bits__) + (stride) * ((y) + __yoff__) + (mul) * ((x) + __xoff__); \
|
||||
}
|
||||
|
||||
#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \
|
||||
(((s) >> 5) & 0x07e0) | \
|
||||
(((s) >> 8) & 0xf800))
|
||||
#define cvt0565to0888(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) | *((CARD16 *) ((a)+1))) : \
|
||||
((*((CARD16 *) (a)) << 8) | *((a)+2)))
|
||||
#define Store24(a,v) ((unsigned long) (a) & 1 ? \
|
||||
((*(a) = (CARD8) ((v) >> 16)), \
|
||||
(*((CARD16 *) ((a)+1)) = (CARD16) (v))) : \
|
||||
((*((CARD16 *) (a)) = (CARD16) ((v) >> 8)), \
|
||||
(*((a)+2) = (CARD8) (v))))
|
||||
#else
|
||||
#define Fetch24(a) ((unsigned long) (a) & 1 ? \
|
||||
((*(a)) | (*((CARD16 *) ((a)+1)) << 8)) : \
|
||||
((*((CARD16 *) (a))) | (*((a)+2) << 16)))
|
||||
#define Store24(a,v) ((unsigned long) (a) & 1 ? \
|
||||
((*(a) = (CARD8) (v)), \
|
||||
(*((CARD16 *) ((a)+1)) = (CARD16) ((v) >> 8))) : \
|
||||
((*((CARD16 *) (a)) = (CARD16) (v)),\
|
||||
(*((a)+2) = (CARD8) ((v) >> 16))))
|
||||
#endif
|
||||
|
||||
/*
|
||||
The methods below use some tricks to be able to do two color
|
||||
components at the same time.
|
||||
*/
|
||||
|
||||
/*
|
||||
x_c = (x_c * a) / 255
|
||||
*/
|
||||
#define FbByteMul(x, a) do { \
|
||||
CARD32 t = ((x & 0xff00ff) * a) + 0x800080; \
|
||||
t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
|
||||
t &= 0xff00ff; \
|
||||
\
|
||||
x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
|
||||
x = (x + ((x >> 8) & 0xff00ff)); \
|
||||
x &= 0xff00ff00; \
|
||||
x += t; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = (x_c * a) / 255 + y
|
||||
*/
|
||||
#define FbByteMulAdd(x, a, y) do { \
|
||||
CARD32 t = ((x & 0xff00ff) * a) + 0x800080; \
|
||||
t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
|
||||
t &= 0xff00ff; \
|
||||
t += y & 0xff00ff; \
|
||||
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
|
||||
t &= 0xff00ff; \
|
||||
\
|
||||
x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
|
||||
x = (x + ((x >> 8) & 0xff00ff)) >> 8; \
|
||||
x &= 0xff00ff; \
|
||||
x += (y >> 8) & 0xff00ff; \
|
||||
x |= 0x1000100 - ((t >> 8) & 0xff00ff); \
|
||||
x &= 0xff00ff; \
|
||||
x <<= 8; \
|
||||
x += t; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = (x_c * a + y_c * b) / 255
|
||||
*/
|
||||
#define FbByteAddMul(x, a, y, b) do { \
|
||||
CARD32 t; \
|
||||
CARD32 r = (x >> 24) * a + (y >> 24) * b + 0x80; \
|
||||
r += (r >> 8); \
|
||||
r >>= 8; \
|
||||
\
|
||||
t = (x & 0xff00) * a + (y & 0xff00) * b + 0x8000; \
|
||||
t += (t >> 8); \
|
||||
t >>= 16; \
|
||||
\
|
||||
t |= r << 16; \
|
||||
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
|
||||
t &= 0xff00ff; \
|
||||
t <<= 8; \
|
||||
\
|
||||
r = ((x >> 16) & 0xff) * a + ((y >> 16) & 0xff) * b + 0x80; \
|
||||
r += (r >> 8); \
|
||||
r >>= 8; \
|
||||
\
|
||||
x = (x & 0xff) * a + (y & 0xff) * b + 0x80; \
|
||||
x += (x >> 8); \
|
||||
x >>= 8; \
|
||||
x |= r << 16; \
|
||||
x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
|
||||
x &= 0xff00ff; \
|
||||
x |= t; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = (x_c * a + y_c *b) / 256
|
||||
*/
|
||||
#define FbByteAddMul_256(x, a, y, b) do { \
|
||||
CARD32 t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; \
|
||||
t >>= 8; \
|
||||
t &= 0xff00ff; \
|
||||
\
|
||||
x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; \
|
||||
x &= 0xff00ff00; \
|
||||
x += t; \
|
||||
} while (0)
|
||||
/*
|
||||
x_c = (x_c * a_c) / 255
|
||||
*/
|
||||
#define FbByteMulC(x, a) do { \
|
||||
CARD32 t; \
|
||||
CARD32 r = (x & 0xff) * (a & 0xff); \
|
||||
r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
|
||||
r += 0x800080; \
|
||||
r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
|
||||
r &= 0xff00ff; \
|
||||
\
|
||||
x >>= 8; \
|
||||
t = (x & 0xff) * ((a >> 8) & 0xff); \
|
||||
t |= (x & 0xff0000) * (a >> 24); \
|
||||
t += 0x800080; \
|
||||
t = t + ((t >> 8) & 0xff00ff); \
|
||||
x = r | (t & 0xff00ff00); \
|
||||
\
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = (x_c * a) / 255 + y
|
||||
*/
|
||||
#define FbByteMulAddC(x, a, y) do { \
|
||||
CARD32 t; \
|
||||
CARD32 r = (x & 0xff) * (a & 0xff); \
|
||||
r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
|
||||
r += 0x800080; \
|
||||
r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
|
||||
r &= 0xff00ff; \
|
||||
r += y & 0xff00ff; \
|
||||
r |= 0x1000100 - ((r >> 8) & 0xff00ff); \
|
||||
r &= 0xff00ff; \
|
||||
\
|
||||
x >>= 8; \
|
||||
t = (x & 0xff) * ((a >> 8) & 0xff); \
|
||||
t |= (x & 0xff0000) * (a >> 24); \
|
||||
t += 0x800080; \
|
||||
t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
|
||||
t &= 0xff00ff; \
|
||||
t += (y >> 8) & 0xff00ff; \
|
||||
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
|
||||
t &= 0xff00ff; \
|
||||
x = r | (t << 8); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = (x_c * a_c + y_c * b) / 255
|
||||
*/
|
||||
#define FbByteAddMulC(x, a, y, b) do { \
|
||||
CARD32 t; \
|
||||
CARD32 r = (x >> 24) * (a >> 24) + (y >> 24) * b + 0x80; \
|
||||
r += (r >> 8); \
|
||||
r >>= 8; \
|
||||
\
|
||||
t = (x & 0xff00) * ((a >> 8) & 0xff) + (y & 0xff00) * b + 0x8000; \
|
||||
t += (t >> 8); \
|
||||
t >>= 16; \
|
||||
\
|
||||
t |= r << 16; \
|
||||
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
|
||||
t &= 0xff00ff; \
|
||||
t <<= 8; \
|
||||
\
|
||||
r = ((x >> 16) & 0xff) * ((a >> 16) & 0xff) + ((y >> 16) & 0xff) * b + 0x80; \
|
||||
r += (r >> 8); \
|
||||
r >>= 8; \
|
||||
\
|
||||
x = (x & 0xff) * (a & 0xff) + (y & 0xff) * b + 0x80; \
|
||||
x += (x >> 8); \
|
||||
x >>= 8; \
|
||||
x |= r << 16; \
|
||||
x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
|
||||
x &= 0xff00ff; \
|
||||
x |= t; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = min(x_c + y_c, 255)
|
||||
*/
|
||||
#define FbByteAdd(x, y) do { \
|
||||
CARD32 t; \
|
||||
CARD32 r = (x & 0xff00ff) + (y & 0xff00ff); \
|
||||
r |= 0x1000100 - ((r >> 8) & 0xff00ff); \
|
||||
r &= 0xff00ff; \
|
||||
\
|
||||
t = ((x >> 8) & 0xff00ff) + ((y >> 8) & 0xff00ff); \
|
||||
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
|
||||
r |= (t & 0xff00ff) << 8; \
|
||||
x = r; \
|
||||
} while (0)
|
||||
|
||||
#define div_255(x) (((x) + 0x80 + (((x) + 0x80) >> 8)) >> 8)
|
||||
|
||||
#if defined(__i386__) && defined(__GNUC__)
|
||||
#define FASTCALL __attribute__((regparm(3)))
|
||||
#else
|
||||
#define FASTCALL
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define INLINE __inline__
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
|
||||
typedef struct _FbComposeData {
|
||||
CARD8 op;
|
||||
PicturePtr src;
|
||||
PicturePtr mask;
|
||||
PicturePtr dest;
|
||||
INT16 xSrc;
|
||||
INT16 ySrc;
|
||||
INT16 xMask;
|
||||
INT16 yMask;
|
||||
INT16 xDest;
|
||||
INT16 yDest;
|
||||
CARD16 width;
|
||||
CARD16 height;
|
||||
} FbComposeData;
|
||||
|
||||
typedef FASTCALL void (*CombineMaskU) (CARD32 *src, const CARD32 *mask, int width);
|
||||
typedef FASTCALL void (*CombineFuncU) (CARD32 *dest, const CARD32 *src, int width);
|
||||
typedef FASTCALL void (*CombineFuncC) (CARD32 *dest, CARD32 *src, CARD32 *mask, int width);
|
||||
|
||||
typedef struct _FbComposeFunctions {
|
||||
CombineFuncU *combineU;
|
||||
CombineFuncC *combineC;
|
||||
CombineMaskU combineMaskU;
|
||||
} FbComposeFunctions;
|
||||
|
||||
#endif /* _FBPICT_H_ */
|
|
@ -1,236 +0,0 @@
|
|||
/*
|
||||
* $Id: fbtrap.c,v 1.21 2007/07/24 19:24:27 vladimir%pobox.com Exp $
|
||||
*
|
||||
* Copyright © 2004 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 "pixman-xserver-compat.h"
|
||||
|
||||
#ifdef RENDER
|
||||
|
||||
/* XXX: Haven't added addTraps to libpixman yet. */
|
||||
#if 0
|
||||
void
|
||||
fbAddTraps (PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off,
|
||||
int ntrap,
|
||||
xTrap *traps)
|
||||
{
|
||||
FbBits *buf;
|
||||
int bpp;
|
||||
int width;
|
||||
int stride;
|
||||
int height;
|
||||
int pxoff, pyoff;
|
||||
|
||||
xFixed x_off_fixed;
|
||||
xFixed y_off_fixed;
|
||||
RenderEdge l, r;
|
||||
xFixed t, b;
|
||||
|
||||
fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
|
||||
|
||||
width = pPicture->pDrawable->width;
|
||||
height = pPicture->pDrawable->height;
|
||||
x_off += pxoff;
|
||||
y_off += pyoff;
|
||||
|
||||
x_off_fixed = IntToxFixed(y_off);
|
||||
y_off_fixed = IntToxFixed(y_off);
|
||||
|
||||
while (ntrap--)
|
||||
{
|
||||
t = traps->top.y + y_off_fixed;
|
||||
if (t < 0)
|
||||
t = 0;
|
||||
t = RenderSampleCeilY (t, bpp);
|
||||
|
||||
b = traps->bot.y + y_off_fixed;
|
||||
if (xFixedToInt (b) >= height)
|
||||
b = IntToxFixed (height) - 1;
|
||||
b = RenderSampleFloorY (b, bpp);
|
||||
|
||||
if (b >= t)
|
||||
{
|
||||
/* initialize edge walkers */
|
||||
RenderEdgeInit (&l, bpp, t,
|
||||
traps->top.l + x_off_fixed,
|
||||
traps->top.y + y_off_fixed,
|
||||
traps->bot.l + x_off_fixed,
|
||||
traps->bot.y + y_off_fixed);
|
||||
|
||||
RenderEdgeInit (&r, bpp, t,
|
||||
traps->top.r + x_off_fixed,
|
||||
traps->top.y + y_off_fixed,
|
||||
traps->bot.r + x_off_fixed,
|
||||
traps->bot.y + y_off_fixed);
|
||||
|
||||
fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b);
|
||||
}
|
||||
traps++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
fbRasterizeTrapezoid (PicturePtr pPicture,
|
||||
const xTrapezoid *trap,
|
||||
int x_off,
|
||||
int y_off)
|
||||
{
|
||||
FbBits *buf;
|
||||
int bpp;
|
||||
int width;
|
||||
int stride;
|
||||
int height;
|
||||
int pxoff, pyoff;
|
||||
|
||||
xFixed x_off_fixed;
|
||||
xFixed y_off_fixed;
|
||||
RenderEdge l, r;
|
||||
xFixed t, b;
|
||||
|
||||
fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
|
||||
|
||||
width = pPicture->pDrawable->width;
|
||||
height = pPicture->pDrawable->height;
|
||||
x_off += pxoff;
|
||||
y_off += pyoff;
|
||||
|
||||
x_off_fixed = IntToxFixed(x_off);
|
||||
y_off_fixed = IntToxFixed(y_off);
|
||||
t = trap->top + y_off_fixed;
|
||||
if (t < 0)
|
||||
t = 0;
|
||||
t = RenderSampleCeilY (t, bpp);
|
||||
|
||||
b = trap->bottom + y_off_fixed;
|
||||
if (xFixedToInt (b) >= height)
|
||||
b = IntToxFixed (height) - 1;
|
||||
b = RenderSampleFloorY (b, bpp);
|
||||
|
||||
if (b >= t)
|
||||
{
|
||||
/* initialize edge walkers */
|
||||
RenderLineFixedEdgeInit (&l, bpp, t, &trap->left, x_off, y_off);
|
||||
RenderLineFixedEdgeInit (&r, bpp, t, &trap->right, x_off, y_off);
|
||||
|
||||
fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b);
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX: Haven't add addTriangles to libpixman yet. */
|
||||
#if 0
|
||||
static int
|
||||
_GreaterY (xPointFixed *a, xPointFixed *b)
|
||||
{
|
||||
if (a->y == b->y)
|
||||
return a->x > b->x;
|
||||
return a->y > b->y;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that the definition of this function is a bit odd because
|
||||
* of the X coordinate space (y increasing downwards).
|
||||
*/
|
||||
static int
|
||||
_Clockwise (xPointFixed *ref, xPointFixed *a, xPointFixed *b)
|
||||
{
|
||||
xPointFixed ad, bd;
|
||||
|
||||
ad.x = a->x - ref->x;
|
||||
ad.y = a->y - ref->y;
|
||||
bd.x = b->x - ref->x;
|
||||
bd.y = b->y - ref->y;
|
||||
|
||||
return ((xFixed_32_32) bd.y * ad.x - (xFixed_32_32) ad.y * bd.x) < 0;
|
||||
}
|
||||
|
||||
/* FIXME -- this could be made more efficient */
|
||||
void
|
||||
fbAddTriangles (PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off,
|
||||
int ntri,
|
||||
xTriangle *tris)
|
||||
{
|
||||
xPointFixed *top, *left, *right, *tmp;
|
||||
xTrapezoid trap;
|
||||
|
||||
for (; ntri; ntri--, tris++)
|
||||
{
|
||||
top = &tris->p1;
|
||||
left = &tris->p2;
|
||||
right = &tris->p3;
|
||||
if (_GreaterY (top, left)) {
|
||||
tmp = left; left = top; top = tmp;
|
||||
}
|
||||
if (_GreaterY (top, right)) {
|
||||
tmp = right; right = top; top = tmp;
|
||||
}
|
||||
if (_Clockwise (top, right, left)) {
|
||||
tmp = right; right = left; left = tmp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Two cases:
|
||||
*
|
||||
* + +
|
||||
* / \ / \
|
||||
* / \ / \
|
||||
* / + + \
|
||||
* / -- -- \
|
||||
* / -- -- \
|
||||
* / --- --- \
|
||||
* +-- --+
|
||||
*/
|
||||
|
||||
trap.top = top->y;
|
||||
trap.left.p1 = *top;
|
||||
trap.left.p2 = *left;
|
||||
trap.right.p1 = *top;
|
||||
trap.right.p2 = *right;
|
||||
if (right->y < left->y)
|
||||
trap.bottom = right->y;
|
||||
else
|
||||
trap.bottom = left->y;
|
||||
fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
|
||||
if (right->y < left->y)
|
||||
{
|
||||
trap.top = right->y;
|
||||
trap.bottom = left->y;
|
||||
trap.right.p1 = *right;
|
||||
trap.right.p2 = *left;
|
||||
}
|
||||
else
|
||||
{
|
||||
trap.top = left->y;
|
||||
trap.bottom = right->y;
|
||||
trap.left.p1 = *left;
|
||||
trap.left.p2 = *right;
|
||||
}
|
||||
fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RENDER */
|
|
@ -1,949 +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 "pixman-xserver-compat.h"
|
||||
|
||||
#define InitializeShifts(sx,dx,ls,rs) { \
|
||||
if (sx != dx) { \
|
||||
if (sx > dx) { \
|
||||
ls = sx - dx; \
|
||||
rs = FB_UNIT - ls; \
|
||||
} else { \
|
||||
rs = dx - sx; \
|
||||
ls = FB_UNIT - rs; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
void
|
||||
fbBlt (FbBits *srcLine,
|
||||
FbStride srcStride,
|
||||
int srcX,
|
||||
|
||||
FbBits *dstLine,
|
||||
FbStride dstStride,
|
||||
int dstX,
|
||||
|
||||
int width,
|
||||
int height,
|
||||
|
||||
int alu,
|
||||
FbBits pm,
|
||||
int bpp,
|
||||
|
||||
Bool reverse,
|
||||
Bool upsidedown)
|
||||
{
|
||||
FbBits *src, *dst;
|
||||
int leftShift, rightShift;
|
||||
FbBits startmask, endmask;
|
||||
FbBits bits, bits1;
|
||||
int n, nmiddle;
|
||||
Bool destInvarient;
|
||||
int startbyte, endbyte;
|
||||
FbDeclareMergeRop ();
|
||||
|
||||
/* are we just copying multiples of 8 bits? if so, run, forrest, run!
|
||||
the memcpy()'s should be pluggable ala mplayer|xine - perhaps we can get
|
||||
one of the above to give up their code for us.
|
||||
*/
|
||||
if((pm==FB_ALLONES) && (alu==GXcopy) && !reverse && (srcX&7)==0 && (dstX&7)==0 && (width&7)==0)
|
||||
{
|
||||
CARD8 *isrc=(CARD8 *)srcLine;
|
||||
CARD8 *idst=(CARD8 *)dstLine;
|
||||
int sstride=srcStride*sizeof(FbBits);
|
||||
int dstride=dstStride*sizeof(FbBits);
|
||||
int j;
|
||||
width>>=3;
|
||||
isrc+=(srcX>>3);
|
||||
idst+=(dstX>>3);
|
||||
if(!upsidedown)
|
||||
for(j=0;j<height;j++)
|
||||
memcpy(idst+j*dstride, isrc+j*sstride, width);
|
||||
else
|
||||
for(j=(height-1);j>=0;j--)
|
||||
memcpy(idst+j*dstride, isrc+j*sstride, width);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef FB_24BIT
|
||||
if (bpp == 24 && !FbCheck24Pix (pm))
|
||||
{
|
||||
fbBlt24 (srcLine, srcStride, srcX, dstLine, dstStride, dstX,
|
||||
width, height, alu, pm, reverse, upsidedown);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
FbInitializeMergeRop(alu, pm);
|
||||
destInvarient = FbDestInvarientMergeRop();
|
||||
if (upsidedown)
|
||||
{
|
||||
srcLine += (height - 1) * (srcStride);
|
||||
dstLine += (height - 1) * (dstStride);
|
||||
srcStride = -srcStride;
|
||||
dstStride = -dstStride;
|
||||
}
|
||||
FbMaskBitsBytes (dstX, width, destInvarient, startmask, startbyte,
|
||||
nmiddle, endmask, endbyte);
|
||||
if (reverse)
|
||||
{
|
||||
srcLine += ((srcX + width - 1) >> FB_SHIFT) + 1;
|
||||
dstLine += ((dstX + width - 1) >> FB_SHIFT) + 1;
|
||||
srcX = (srcX + width - 1) & FB_MASK;
|
||||
dstX = (dstX + width - 1) & FB_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcLine += srcX >> FB_SHIFT;
|
||||
dstLine += dstX >> FB_SHIFT;
|
||||
srcX &= FB_MASK;
|
||||
dstX &= FB_MASK;
|
||||
}
|
||||
if (srcX == dstX)
|
||||
{
|
||||
while (height--)
|
||||
{
|
||||
src = srcLine;
|
||||
srcLine += srcStride;
|
||||
dst = dstLine;
|
||||
dstLine += dstStride;
|
||||
if (reverse)
|
||||
{
|
||||
if (endmask)
|
||||
{
|
||||
bits = *--src;
|
||||
--dst;
|
||||
FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
|
||||
}
|
||||
n = nmiddle;
|
||||
if (destInvarient)
|
||||
{
|
||||
while (n--)
|
||||
*--dst = FbDoDestInvarientMergeRop(*--src);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
bits = *--src;
|
||||
--dst;
|
||||
*dst = FbDoMergeRop (bits, *dst);
|
||||
}
|
||||
}
|
||||
if (startmask)
|
||||
{
|
||||
bits = *--src;
|
||||
--dst;
|
||||
FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startmask)
|
||||
{
|
||||
bits = *src++;
|
||||
FbDoLeftMaskByteMergeRop(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 fb
|
||||
* isn't usually used for this operation...
|
||||
*/
|
||||
if (_ca2 + 1 == 0 && _cx2 == 0)
|
||||
{
|
||||
FbBits 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++ = FbDoDestInvarientMergeRop(*src++);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
bits = *src++;
|
||||
*dst = FbDoMergeRop (bits, *dst);
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
if (endmask)
|
||||
{
|
||||
bits = *src;
|
||||
FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (srcX > dstX)
|
||||
{
|
||||
leftShift = srcX - dstX;
|
||||
rightShift = FB_UNIT - leftShift;
|
||||
}
|
||||
else
|
||||
{
|
||||
rightShift = dstX - srcX;
|
||||
leftShift = FB_UNIT - rightShift;
|
||||
}
|
||||
while (height--)
|
||||
{
|
||||
src = srcLine;
|
||||
srcLine += srcStride;
|
||||
dst = dstLine;
|
||||
dstLine += dstStride;
|
||||
|
||||
bits1 = 0;
|
||||
if (reverse)
|
||||
{
|
||||
if (srcX < dstX)
|
||||
bits1 = *--src;
|
||||
if (endmask)
|
||||
{
|
||||
bits = FbScrRight(bits1, rightShift);
|
||||
if (FbScrRight(endmask, leftShift))
|
||||
{
|
||||
bits1 = *--src;
|
||||
bits |= FbScrLeft(bits1, leftShift);
|
||||
}
|
||||
--dst;
|
||||
FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
|
||||
}
|
||||
n = nmiddle;
|
||||
if (destInvarient)
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
bits = FbScrRight(bits1, rightShift);
|
||||
bits1 = *--src;
|
||||
bits |= FbScrLeft(bits1, leftShift);
|
||||
--dst;
|
||||
*dst = FbDoDestInvarientMergeRop(bits);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
bits = FbScrRight(bits1, rightShift);
|
||||
bits1 = *--src;
|
||||
bits |= FbScrLeft(bits1, leftShift);
|
||||
--dst;
|
||||
*dst = FbDoMergeRop(bits, *dst);
|
||||
}
|
||||
}
|
||||
if (startmask)
|
||||
{
|
||||
bits = FbScrRight(bits1, rightShift);
|
||||
if (FbScrRight(startmask, leftShift))
|
||||
{
|
||||
bits1 = *--src;
|
||||
bits |= FbScrLeft(bits1, leftShift);
|
||||
}
|
||||
--dst;
|
||||
FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (srcX > dstX)
|
||||
bits1 = *src++;
|
||||
if (startmask)
|
||||
{
|
||||
bits = FbScrLeft(bits1, leftShift);
|
||||
bits1 = *src++;
|
||||
bits |= FbScrRight(bits1, rightShift);
|
||||
FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
|
||||
dst++;
|
||||
}
|
||||
n = nmiddle;
|
||||
if (destInvarient)
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
bits = FbScrLeft(bits1, leftShift);
|
||||
bits1 = *src++;
|
||||
bits |= FbScrRight(bits1, rightShift);
|
||||
*dst = FbDoDestInvarientMergeRop(bits);
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
bits = FbScrLeft(bits1, leftShift);
|
||||
bits1 = *src++;
|
||||
bits |= FbScrRight(bits1, rightShift);
|
||||
*dst = FbDoMergeRop(bits, *dst);
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
if (endmask)
|
||||
{
|
||||
bits = FbScrLeft(bits1, leftShift);
|
||||
if (FbScrLeft(endmask, rightShift))
|
||||
{
|
||||
bits1 = *src;
|
||||
bits |= FbScrRight(bits1, rightShift);
|
||||
}
|
||||
FbDoRightMaskByteMergeRop (dst, bits, endbyte, endmask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FB_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
|
||||
fbBlt24Line (FbBits *src,
|
||||
int srcX,
|
||||
|
||||
FbBits *dst,
|
||||
int dstX,
|
||||
|
||||
int width,
|
||||
|
||||
int alu,
|
||||
FbBits pm,
|
||||
|
||||
Bool reverse)
|
||||
{
|
||||
#ifdef DEBUG_BLT24
|
||||
char *origDst = (char *) dst;
|
||||
FbBits *origLine = dst + ((dstX >> FB_SHIFT) - 1);
|
||||
int origNlw = ((width + FB_MASK) >> FB_SHIFT) + 3;
|
||||
int origX = dstX / 24;
|
||||
#endif
|
||||
|
||||
int leftShift, rightShift;
|
||||
FbBits startmask, endmask;
|
||||
int n;
|
||||
|
||||
FbBits bits, bits1;
|
||||
FbBits mask;
|
||||
|
||||
int rot;
|
||||
FbDeclareMergeRop ();
|
||||
|
||||
FbInitializeMergeRop (alu, FB_ALLONES);
|
||||
FbMaskBits(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) >> FB_SHIFT) + 1;
|
||||
dst += ((dstX + width - 1) >> FB_SHIFT) + 1;
|
||||
rot = FbFirst24Rot (((dstX + width - 8) & FB_MASK));
|
||||
rot = FbPrev24Rot(rot);
|
||||
#ifdef DEBUG_BLT24
|
||||
ErrorF ("dstX + width - 8: %d rot: %d\n", (dstX + width - 8) & FB_MASK, rot);
|
||||
#endif
|
||||
srcX = (srcX + width - 1) & FB_MASK;
|
||||
dstX = (dstX + width - 1) & FB_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
src += srcX >> FB_SHIFT;
|
||||
dst += dstX >> FB_SHIFT;
|
||||
srcX &= FB_MASK;
|
||||
dstX &= FB_MASK;
|
||||
rot = FbFirst24Rot (dstX);
|
||||
#ifdef DEBUG_BLT24
|
||||
ErrorF ("dstX: %d rot: %d\n", dstX, rot);
|
||||
#endif
|
||||
}
|
||||
mask = FbRot24(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 = FbDoMaskMergeRop (bits, *dst, mask & endmask);
|
||||
mask = FbPrev24Pix (mask);
|
||||
}
|
||||
while (n--)
|
||||
{
|
||||
bits = *--src;
|
||||
--dst;
|
||||
*dst = FbDoMaskMergeRop (bits, *dst, mask);
|
||||
mask = FbPrev24Pix (mask);
|
||||
}
|
||||
if (startmask)
|
||||
{
|
||||
bits = *--src;
|
||||
--dst;
|
||||
*dst = FbDoMaskMergeRop(bits, *dst, mask & startmask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startmask)
|
||||
{
|
||||
bits = *src++;
|
||||
*dst = FbDoMaskMergeRop (bits, *dst, mask & startmask);
|
||||
dst++;
|
||||
mask = FbNext24Pix(mask);
|
||||
}
|
||||
while (n--)
|
||||
{
|
||||
bits = *src++;
|
||||
*dst = FbDoMaskMergeRop (bits, *dst, mask);
|
||||
dst++;
|
||||
mask = FbNext24Pix(mask);
|
||||
}
|
||||
if (endmask)
|
||||
{
|
||||
bits = *src;
|
||||
*dst = FbDoMaskMergeRop(bits, *dst, mask & endmask);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (srcX > dstX)
|
||||
{
|
||||
leftShift = srcX - dstX;
|
||||
rightShift = FB_UNIT - leftShift;
|
||||
}
|
||||
else
|
||||
{
|
||||
rightShift = dstX - srcX;
|
||||
leftShift = FB_UNIT - rightShift;
|
||||
}
|
||||
|
||||
bits1 = 0;
|
||||
if (reverse)
|
||||
{
|
||||
if (srcX < dstX)
|
||||
bits1 = *--src;
|
||||
if (endmask)
|
||||
{
|
||||
bits = FbScrRight(bits1, rightShift);
|
||||
if (FbScrRight(endmask, leftShift))
|
||||
{
|
||||
bits1 = *--src;
|
||||
bits |= FbScrLeft(bits1, leftShift);
|
||||
}
|
||||
--dst;
|
||||
*dst = FbDoMaskMergeRop (bits, *dst, mask & endmask);
|
||||
mask = FbPrev24Pix(mask);
|
||||
}
|
||||
while (n--)
|
||||
{
|
||||
bits = FbScrRight(bits1, rightShift);
|
||||
bits1 = *--src;
|
||||
bits |= FbScrLeft(bits1, leftShift);
|
||||
--dst;
|
||||
*dst = FbDoMaskMergeRop(bits, *dst, mask);
|
||||
mask = FbPrev24Pix(mask);
|
||||
}
|
||||
if (startmask)
|
||||
{
|
||||
bits = FbScrRight(bits1, rightShift);
|
||||
if (FbScrRight(startmask, leftShift))
|
||||
{
|
||||
bits1 = *--src;
|
||||
bits |= FbScrLeft(bits1, leftShift);
|
||||
}
|
||||
--dst;
|
||||
*dst = FbDoMaskMergeRop (bits, *dst, mask & startmask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (srcX > dstX)
|
||||
bits1 = *src++;
|
||||
if (startmask)
|
||||
{
|
||||
bits = FbScrLeft(bits1, leftShift);
|
||||
bits1 = *src++;
|
||||
bits |= FbScrRight(bits1, rightShift);
|
||||
*dst = FbDoMaskMergeRop (bits, *dst, mask & startmask);
|
||||
dst++;
|
||||
mask = FbNext24Pix(mask);
|
||||
}
|
||||
while (n--)
|
||||
{
|
||||
bits = FbScrLeft(bits1, leftShift);
|
||||
bits1 = *src++;
|
||||
bits |= FbScrRight(bits1, rightShift);
|
||||
*dst = FbDoMaskMergeRop(bits, *dst, mask);
|
||||
dst++;
|
||||
mask = FbNext24Pix(mask);
|
||||
}
|
||||
if (endmask)
|
||||
{
|
||||
bits = FbScrLeft(bits1, leftShift);
|
||||
if (FbScrLeft(endmask, rightShift))
|
||||
{
|
||||
bits1 = *src;
|
||||
bits |= FbScrRight(bits1, rightShift);
|
||||
}
|
||||
*dst = FbDoMaskMergeRop (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
|
||||
fbBlt24 (FbBits *srcLine,
|
||||
FbStride srcStride,
|
||||
int srcX,
|
||||
|
||||
FbBits *dstLine,
|
||||
FbStride dstStride,
|
||||
int dstX,
|
||||
|
||||
int width,
|
||||
int height,
|
||||
|
||||
int alu,
|
||||
FbBits pm,
|
||||
|
||||
Bool reverse,
|
||||
Bool upsidedown)
|
||||
{
|
||||
if (upsidedown)
|
||||
{
|
||||
srcLine += (height-1) * srcStride;
|
||||
dstLine += (height-1) * dstStride;
|
||||
srcStride = -srcStride;
|
||||
dstStride = -dstStride;
|
||||
}
|
||||
while (height--)
|
||||
{
|
||||
fbBlt24Line (srcLine, srcX, dstLine, dstX, width, alu, pm, reverse);
|
||||
srcLine += srcStride;
|
||||
dstLine += dstStride;
|
||||
}
|
||||
#ifdef DEBUG_BLT24
|
||||
ErrorF ("\n");
|
||||
#endif
|
||||
}
|
||||
#endif /* FB_24BIT */
|
||||
|
||||
#if FB_SHIFT == FB_STIP_SHIFT + 1
|
||||
|
||||
/*
|
||||
* Could be generalized to FB_SHIFT > FB_STIP_SHIFT + 1 by
|
||||
* creating an ring of values stepped through for each line
|
||||
*/
|
||||
|
||||
void
|
||||
fbBltOdd (FbBits *srcLine,
|
||||
FbStride srcStrideEven,
|
||||
FbStride srcStrideOdd,
|
||||
int srcXEven,
|
||||
int srcXOdd,
|
||||
|
||||
FbBits *dstLine,
|
||||
FbStride dstStrideEven,
|
||||
FbStride dstStrideOdd,
|
||||
int dstXEven,
|
||||
int dstXOdd,
|
||||
|
||||
int width,
|
||||
int height,
|
||||
|
||||
int alu,
|
||||
FbBits pm,
|
||||
int bpp)
|
||||
{
|
||||
FbBits *src;
|
||||
int leftShiftEven, rightShiftEven;
|
||||
FbBits startmaskEven, endmaskEven;
|
||||
int nmiddleEven;
|
||||
|
||||
FbBits *dst;
|
||||
int leftShiftOdd, rightShiftOdd;
|
||||
FbBits startmaskOdd, endmaskOdd;
|
||||
int nmiddleOdd;
|
||||
|
||||
int leftShift, rightShift;
|
||||
FbBits startmask, endmask;
|
||||
int nmiddle;
|
||||
|
||||
int srcX, dstX;
|
||||
|
||||
FbBits bits, bits1;
|
||||
int n;
|
||||
|
||||
Bool destInvarient;
|
||||
Bool even;
|
||||
FbDeclareMergeRop ();
|
||||
|
||||
FbInitializeMergeRop (alu, pm);
|
||||
destInvarient = FbDestInvarientMergeRop();
|
||||
|
||||
srcLine += srcXEven >> FB_SHIFT;
|
||||
dstLine += dstXEven >> FB_SHIFT;
|
||||
srcXEven &= FB_MASK;
|
||||
dstXEven &= FB_MASK;
|
||||
srcXOdd &= FB_MASK;
|
||||
dstXOdd &= FB_MASK;
|
||||
|
||||
FbMaskBits(dstXEven, width, startmaskEven, nmiddleEven, endmaskEven);
|
||||
FbMaskBits(dstXOdd, width, startmaskOdd, nmiddleOdd, endmaskOdd);
|
||||
|
||||
even = TRUE;
|
||||
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 = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcX = srcXOdd;
|
||||
dstX = dstXOdd;
|
||||
startmask = startmaskOdd;
|
||||
endmask = endmaskOdd;
|
||||
nmiddle = nmiddleOdd;
|
||||
leftShift = leftShiftOdd;
|
||||
rightShift = rightShiftOdd;
|
||||
srcLine += srcStrideOdd;
|
||||
dstLine += dstStrideOdd;
|
||||
even = TRUE;
|
||||
}
|
||||
if (srcX == dstX)
|
||||
{
|
||||
if (startmask)
|
||||
{
|
||||
bits = *src++;
|
||||
*dst = FbDoMaskMergeRop (bits, *dst, startmask);
|
||||
dst++;
|
||||
}
|
||||
n = nmiddle;
|
||||
if (destInvarient)
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
bits = *src++;
|
||||
*dst = FbDoDestInvarientMergeRop(bits);
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
bits = *src++;
|
||||
*dst = FbDoMergeRop (bits, *dst);
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
if (endmask)
|
||||
{
|
||||
bits = *src;
|
||||
*dst = FbDoMaskMergeRop(bits, *dst, endmask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bits = 0;
|
||||
if (srcX > dstX)
|
||||
bits = *src++;
|
||||
if (startmask)
|
||||
{
|
||||
bits1 = FbScrLeft(bits, leftShift);
|
||||
bits = *src++;
|
||||
bits1 |= FbScrRight(bits, rightShift);
|
||||
*dst = FbDoMaskMergeRop (bits1, *dst, startmask);
|
||||
dst++;
|
||||
}
|
||||
n = nmiddle;
|
||||
if (destInvarient)
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
bits1 = FbScrLeft(bits, leftShift);
|
||||
bits = *src++;
|
||||
bits1 |= FbScrRight(bits, rightShift);
|
||||
*dst = FbDoDestInvarientMergeRop(bits1);
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
bits1 = FbScrLeft(bits, leftShift);
|
||||
bits = *src++;
|
||||
bits1 |= FbScrRight(bits, rightShift);
|
||||
*dst = FbDoMergeRop(bits1, *dst);
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
if (endmask)
|
||||
{
|
||||
bits1 = FbScrLeft(bits, leftShift);
|
||||
if (FbScrLeft(endmask, rightShift))
|
||||
{
|
||||
bits = *src;
|
||||
bits1 |= FbScrRight(bits, rightShift);
|
||||
}
|
||||
*dst = FbDoMaskMergeRop (bits1, *dst, endmask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FB_24BIT
|
||||
void
|
||||
fbBltOdd24 (FbBits *srcLine,
|
||||
FbStride srcStrideEven,
|
||||
FbStride srcStrideOdd,
|
||||
int srcXEven,
|
||||
int srcXOdd,
|
||||
|
||||
FbBits *dstLine,
|
||||
FbStride dstStrideEven,
|
||||
FbStride dstStrideOdd,
|
||||
int dstXEven,
|
||||
int dstXOdd,
|
||||
|
||||
int width,
|
||||
int height,
|
||||
|
||||
int alu,
|
||||
FbBits pm)
|
||||
{
|
||||
Bool even = TRUE;
|
||||
|
||||
while (height--)
|
||||
{
|
||||
if (even)
|
||||
{
|
||||
fbBlt24Line (srcLine, srcXEven, dstLine, dstXEven,
|
||||
width, alu, pm, FALSE);
|
||||
srcLine += srcStrideEven;
|
||||
dstLine += dstStrideEven;
|
||||
even = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
fbBlt24Line (srcLine, srcXOdd, dstLine, dstXOdd,
|
||||
width, alu, pm, FALSE);
|
||||
srcLine += srcStrideOdd;
|
||||
dstLine += dstStrideOdd;
|
||||
even = TRUE;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
fprintf (stderr, "\n");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if FB_STIP_SHIFT != FB_SHIFT
|
||||
void
|
||||
fbSetBltOdd (FbStip *stip,
|
||||
FbStride stipStride,
|
||||
int srcX,
|
||||
FbBits **bits,
|
||||
FbStride *strideEven,
|
||||
FbStride *strideOdd,
|
||||
int *srcXEven,
|
||||
int *srcXOdd)
|
||||
{
|
||||
int srcAdjust;
|
||||
int strideAdjust;
|
||||
|
||||
/*
|
||||
* bytes needed to align source
|
||||
*/
|
||||
srcAdjust = (((int) stip) & (FB_MASK >> 3));
|
||||
/*
|
||||
* FbStip units needed to align stride
|
||||
*/
|
||||
strideAdjust = stipStride & (FB_MASK >> FB_STIP_SHIFT);
|
||||
|
||||
*bits = (FbBits *) ((char *) stip - srcAdjust);
|
||||
if (srcAdjust)
|
||||
{
|
||||
*strideEven = FbStipStrideToBitsStride (stipStride + 1);
|
||||
*strideOdd = FbStipStrideToBitsStride (stipStride);
|
||||
|
||||
*srcXEven = srcX + (srcAdjust << 3);
|
||||
*srcXOdd = srcX + (srcAdjust << 3) - (strideAdjust << FB_STIP_SHIFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
*strideEven = FbStipStrideToBitsStride (stipStride);
|
||||
*strideOdd = FbStipStrideToBitsStride (stipStride + 1);
|
||||
|
||||
*srcXEven = srcX;
|
||||
*srcXOdd = srcX + (strideAdjust << FB_STIP_SHIFT);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
fbBltStip (FbStip *src,
|
||||
FbStride srcStride, /* in FbStip units, not FbBits units */
|
||||
int srcX,
|
||||
|
||||
FbStip *dst,
|
||||
FbStride dstStride, /* in FbStip units, not FbBits units */
|
||||
int dstX,
|
||||
|
||||
int width,
|
||||
int height,
|
||||
|
||||
int alu,
|
||||
FbBits pm,
|
||||
int bpp)
|
||||
{
|
||||
#if FB_STIP_SHIFT != FB_SHIFT
|
||||
if (FB_STIP_ODDSTRIDE(srcStride) || FB_STIP_ODDPTR(src) ||
|
||||
FB_STIP_ODDSTRIDE(dstStride) || FB_STIP_ODDPTR(dst))
|
||||
{
|
||||
FbStride srcStrideEven, srcStrideOdd;
|
||||
FbStride dstStrideEven, dstStrideOdd;
|
||||
int srcXEven, srcXOdd;
|
||||
int dstXEven, dstXOdd;
|
||||
FbBits *s, *d;
|
||||
int sx, dx;
|
||||
|
||||
src += srcX >> FB_STIP_SHIFT;
|
||||
srcX &= FB_STIP_MASK;
|
||||
dst += dstX >> FB_STIP_SHIFT;
|
||||
dstX &= FB_STIP_MASK;
|
||||
|
||||
fbSetBltOdd (src, srcStride, srcX,
|
||||
&s,
|
||||
&srcStrideEven, &srcStrideOdd,
|
||||
&srcXEven, &srcXOdd);
|
||||
|
||||
fbSetBltOdd (dst, dstStride, dstX,
|
||||
&d,
|
||||
&dstStrideEven, &dstStrideOdd,
|
||||
&dstXEven, &dstXOdd);
|
||||
|
||||
#ifdef FB_24BIT
|
||||
if (bpp == 24 && !FbCheck24Pix (pm))
|
||||
{
|
||||
fbBltOdd24 (s, srcStrideEven, srcStrideOdd,
|
||||
srcXEven, srcXOdd,
|
||||
|
||||
d, dstStrideEven, dstStrideOdd,
|
||||
dstXEven, dstXOdd,
|
||||
|
||||
width, height, alu, pm);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
fbBltOdd (s, srcStrideEven, srcStrideOdd,
|
||||
srcXEven, srcXOdd,
|
||||
|
||||
d, dstStrideEven, dstStrideOdd,
|
||||
dstXEven, dstXOdd,
|
||||
|
||||
width, height, alu, pm, bpp);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
fbBlt ((FbBits *) src, FbStipStrideToBitsStride (srcStride),
|
||||
srcX,
|
||||
(FbBits *) dst, FbStipStrideToBitsStride (dstStride),
|
||||
dstX,
|
||||
width, height,
|
||||
alu, pm, bpp, FALSE, FALSE);
|
||||
}
|
||||
}
|
|
@ -1,741 +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 "pixman-xserver-compat.h"
|
||||
|
||||
/*
|
||||
* Example: srcX = 13 dstX = 8 (FB unit 32 dstBpp 8)
|
||||
*
|
||||
* **** **** **** **** **** **** **** ****
|
||||
* ^
|
||||
* ******** ******** ******** ********
|
||||
* ^
|
||||
* leftShift = 12
|
||||
* rightShift = 20
|
||||
*
|
||||
* Example: srcX = 0 dstX = 8 (FB unit 32 dstBpp 8)
|
||||
*
|
||||
* **** **** **** **** **** **** **** ****
|
||||
* ^
|
||||
* ******** ******** ******** ********
|
||||
* ^
|
||||
*
|
||||
* leftShift = 24
|
||||
* rightShift = 8
|
||||
*/
|
||||
|
||||
#define LoadBits {\
|
||||
if (leftShift) { \
|
||||
bitsRight = *src++; \
|
||||
bits = (FbStipLeft (bitsLeft, leftShift) | \
|
||||
FbStipRight(bitsRight, rightShift)); \
|
||||
bitsLeft = bitsRight; \
|
||||
} else \
|
||||
bits = *src++; \
|
||||
}
|
||||
|
||||
#ifndef FBNOPIXADDR
|
||||
|
||||
#define LaneCases1(n,a) case n: (void)FbLaneCase(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 FB_SHIFT == 6
|
||||
#define LaneCases(a) LaneCases256(0,a)
|
||||
#endif
|
||||
|
||||
#if FB_SHIFT == 5
|
||||
#define LaneCases(a) LaneCases16(0,a)
|
||||
#endif
|
||||
|
||||
#if FB_SHIFT == 6
|
||||
static uint8_t const fb8Lane[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 fb16Lane[256] = {
|
||||
0x00, 0x03, 0x0c, 0x0f,
|
||||
0x30, 0x33, 0x3c, 0x3f,
|
||||
0xc0, 0xc3, 0xcc, 0xcf,
|
||||
0xf0, 0xf3, 0xfc, 0xff,
|
||||
};
|
||||
|
||||
static uint8_t const fb32Lane[16] = {
|
||||
0x00, 0x0f, 0xf0, 0xff,
|
||||
};
|
||||
#endif
|
||||
|
||||
#if FB_SHIFT == 5
|
||||
static uint8_t const fb8Lane[16] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
|
||||
};
|
||||
|
||||
static uint8_t const fb16Lane[16] = {
|
||||
0, 3, 12, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
static uint8_t const fb32Lane[16] = {
|
||||
0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
#endif
|
||||
|
||||
static const uint8_t *
|
||||
fbLaneTable(int bpp)
|
||||
{
|
||||
switch (bpp) {
|
||||
case 8:
|
||||
return fb8Lane;
|
||||
case 16:
|
||||
return fb16Lane;
|
||||
case 32:
|
||||
return fb32Lane;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
fbBltOne (FbStip *src,
|
||||
FbStride srcStride, /* FbStip units per scanline */
|
||||
int srcX, /* bit position of source */
|
||||
FbBits *dst,
|
||||
FbStride dstStride, /* FbBits 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 */
|
||||
|
||||
FbBits fgand, /* rrop values */
|
||||
FbBits fgxor,
|
||||
FbBits bgand,
|
||||
FbBits bgxor)
|
||||
{
|
||||
const FbBits *fbBits;
|
||||
int pixelsPerDst; /* dst pixels per FbBits */
|
||||
int unitsPerSrc; /* src patterns per FbStip */
|
||||
int leftShift, rightShift; /* align source with dest */
|
||||
FbBits startmask, endmask; /* dest scanline masks */
|
||||
FbStip bits=0, bitsLeft, bitsRight;/* source bits */
|
||||
FbStip left;
|
||||
FbBits mask;
|
||||
int nDst; /* dest longwords (w.o. end) */
|
||||
int w;
|
||||
int n, nmiddle;
|
||||
int dstS; /* stipple-relative dst X coordinate */
|
||||
Bool copy; /* accelerate dest-invariant */
|
||||
Bool transparent; /* accelerate 0 nop */
|
||||
int srcinc; /* source units consumed */
|
||||
Bool endNeedsLoad = FALSE; /* need load for endmask */
|
||||
#ifndef FBNOPIXADDR
|
||||
const CARD8 *fbLane;
|
||||
#endif
|
||||
int startbyte, endbyte;
|
||||
|
||||
#ifdef FB_24BIT
|
||||
if (dstBpp == 24)
|
||||
{
|
||||
fbBltOne24 (src, srcStride, srcX,
|
||||
dst, dstStride, dstX, dstBpp,
|
||||
width, height,
|
||||
fgand, fgxor, bgand, bgxor);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Number of destination units in FbBits == number of stipple pixels
|
||||
* used each time
|
||||
*/
|
||||
pixelsPerDst = FB_UNIT / dstBpp;
|
||||
|
||||
/*
|
||||
* Number of source stipple patterns in FbStip
|
||||
*/
|
||||
unitsPerSrc = FB_STIP_UNIT / pixelsPerDst;
|
||||
|
||||
copy = FALSE;
|
||||
transparent = FALSE;
|
||||
if (bgand == 0 && fgand == 0)
|
||||
copy = TRUE;
|
||||
else if (bgand == FB_ALLONES && bgxor == 0)
|
||||
transparent = TRUE;
|
||||
|
||||
/*
|
||||
* Adjust source and dest to nearest FbBits boundary
|
||||
*/
|
||||
src += srcX >> FB_STIP_SHIFT;
|
||||
dst += dstX >> FB_SHIFT;
|
||||
srcX &= FB_STIP_MASK;
|
||||
dstX &= FB_MASK;
|
||||
|
||||
FbMaskBitsBytes(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 = FB_STIP_UNIT - leftShift;
|
||||
}
|
||||
else
|
||||
{
|
||||
rightShift = dstS - srcX;
|
||||
leftShift = FB_STIP_UNIT - rightShift;
|
||||
}
|
||||
/*
|
||||
* Get pointer to stipple mask array for this depth
|
||||
*/
|
||||
fbBits = NULL; /* unused */
|
||||
if (pixelsPerDst <= 8)
|
||||
fbBits = fbStippleTable(pixelsPerDst);
|
||||
#ifndef FBNOPIXADDR
|
||||
fbLane = NULL;
|
||||
if (transparent && fgand == 0 && dstBpp >= 8)
|
||||
fbLane = fbLaneTable(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 FB_UNIT > 32
|
||||
if (pixelsPerDst == 16)
|
||||
mask = FbStipple16Bits(FbLeftStipBits(bits,16));
|
||||
else
|
||||
#endif
|
||||
mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
|
||||
#ifndef FBNOPIXADDR
|
||||
if (fbLane)
|
||||
{
|
||||
fbTransparentSpan (dst, mask & startmask, fgxor, 1);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (mask || !transparent)
|
||||
FbDoLeftMaskByteStippleRRop (dst, mask,
|
||||
fgand, fgxor, bgand, bgxor,
|
||||
startbyte, startmask);
|
||||
}
|
||||
bits = FbStipLeft (bits, pixelsPerDst);
|
||||
dst++;
|
||||
n--;
|
||||
w--;
|
||||
}
|
||||
/*
|
||||
* Consume stipple bits across scanline
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
w -= n;
|
||||
if (copy)
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
#if FB_UNIT > 32
|
||||
if (pixelsPerDst == 16)
|
||||
mask = FbStipple16Bits(FbLeftStipBits(bits,16));
|
||||
else
|
||||
#endif
|
||||
mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
|
||||
*dst = FbOpaqueStipple (mask, fgxor, bgxor);
|
||||
dst++;
|
||||
bits = FbStipLeft(bits, pixelsPerDst);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef FBNOPIXADDR
|
||||
if (fbLane)
|
||||
{
|
||||
while (bits && n)
|
||||
{
|
||||
switch (fbLane[FbLeftStipBits(bits,pixelsPerDst)]) {
|
||||
LaneCases((CARD8 *) dst);
|
||||
}
|
||||
bits = FbStipLeft(bits,pixelsPerDst);
|
||||
dst++;
|
||||
n--;
|
||||
}
|
||||
dst += n;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
left = FbLeftStipBits(bits,pixelsPerDst);
|
||||
if (left || !transparent)
|
||||
{
|
||||
mask = fbBits[left];
|
||||
*dst = FbStippleRRop (*dst, mask,
|
||||
fgand, fgxor, bgand, bgxor);
|
||||
}
|
||||
dst++;
|
||||
bits = FbStipLeft(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 FB_UNIT > 32
|
||||
if (pixelsPerDst == 16)
|
||||
mask = FbStipple16Bits(FbLeftStipBits(bits,16));
|
||||
else
|
||||
#endif
|
||||
mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
|
||||
#ifndef FBNOPIXADDR
|
||||
if (fbLane)
|
||||
{
|
||||
fbTransparentSpan (dst, mask & endmask, fgxor, 1);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (mask || !transparent)
|
||||
FbDoRightMaskByteStippleRRop (dst, mask,
|
||||
fgand, fgxor, bgand, bgxor,
|
||||
endbyte, endmask);
|
||||
}
|
||||
}
|
||||
dst += dstStride;
|
||||
src += srcStride;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FB_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) >= FB_UNIT ? 0 : Mask24Pos(x,r))
|
||||
|
||||
#define Mask24(x,r) (Mask24Pos(x,r) < FB_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 FB_UNIT == 32
|
||||
*/
|
||||
|
||||
#if FB_UNIT == 64
|
||||
#define C4_24(b,r) \
|
||||
(SelMask24(b,0,r) | \
|
||||
SelMask24(b,1,r) | \
|
||||
SelMask24(b,2,r) | \
|
||||
SelMask24(b,3,r))
|
||||
|
||||
#define FbStip24New(rot) (2 + (rot != 0))
|
||||
#define FbStip24Len 4
|
||||
|
||||
static const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
|
||||
/* 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 FB_UNIT == 32
|
||||
#define C2_24(b,r) \
|
||||
(SelMask24(b,0,r) | \
|
||||
SelMask24(b,1,r))
|
||||
|
||||
#define FbStip24Len 2
|
||||
#if BITMAP_BIT_ORDER == MSBFirst
|
||||
#define FbStip24New(rot) (1 + (rot == 0))
|
||||
#else
|
||||
#define FbStip24New(rot) (1 + (rot == 8))
|
||||
#endif
|
||||
|
||||
static const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
|
||||
/* 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 FbMergeStip24Bits(left, right, new) \
|
||||
(FbStipLeft (left, new) | FbStipRight ((right), (FbStip24Len - (new))))
|
||||
|
||||
#define FbMergePartStip24Bits(left, right, llen, rlen) \
|
||||
(left | FbStipRight(right, llen))
|
||||
|
||||
#else
|
||||
|
||||
#define FbMergeStip24Bits(left, right, new) \
|
||||
((FbStipLeft (left, new) & ((1 << FbStip24Len) - 1)) | right)
|
||||
|
||||
#define FbMergePartStip24Bits(left, right, llen, rlen) \
|
||||
(FbStipLeft(left, rlen) | right)
|
||||
|
||||
#endif
|
||||
|
||||
#define fbFirstStipBits(len,stip) {\
|
||||
int __len = (len); \
|
||||
if (len <= remain) { \
|
||||
stip = FbLeftStipBits(bits, len); \
|
||||
} else { \
|
||||
stip = FbLeftStipBits(bits, remain); \
|
||||
bits = *src++; \
|
||||
__len = (len) - remain; \
|
||||
stip = FbMergePartStip24Bits(stip, FbLeftStipBits(bits, __len), \
|
||||
remain, __len); \
|
||||
remain = FB_STIP_UNIT; \
|
||||
} \
|
||||
bits = FbStipLeft (bits, __len); \
|
||||
remain -= __len; \
|
||||
}
|
||||
|
||||
#define fbInitStipBits(offset,len,stip) {\
|
||||
bits = FbStipLeft (*src++,offset); \
|
||||
remain = FB_STIP_UNIT - offset; \
|
||||
fbFirstStipBits(len,stip); \
|
||||
stip = FbMergeStip24Bits (0, stip, len); \
|
||||
}
|
||||
|
||||
#define fbNextStipBits(rot,stip) {\
|
||||
int __new = FbStip24New(rot); \
|
||||
FbStip __right; \
|
||||
fbFirstStipBits(__new, __right); \
|
||||
stip = FbMergeStip24Bits (stip, __right, __new); \
|
||||
rot = FbNext24Rot (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
|
||||
fbBltOne24 (FbStip *srcLine,
|
||||
FbStride srcStride, /* FbStip units per scanline */
|
||||
int srcX, /* bit position of source */
|
||||
FbBits *dst,
|
||||
FbStride dstStride, /* FbBits 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 */
|
||||
|
||||
FbBits fgand, /* rrop values */
|
||||
FbBits fgxor,
|
||||
FbBits bgand,
|
||||
FbBits bgxor)
|
||||
{
|
||||
FbStip *src;
|
||||
FbBits leftMask, rightMask, mask;
|
||||
int nlMiddle, nl;
|
||||
FbStip stip, bits;
|
||||
int remain;
|
||||
int dstS;
|
||||
int firstlen;
|
||||
int rot0, rot;
|
||||
int nDst;
|
||||
|
||||
srcLine += srcX >> FB_STIP_SHIFT;
|
||||
dst += dstX >> FB_SHIFT;
|
||||
srcX &= FB_STIP_MASK;
|
||||
dstX &= FB_MASK;
|
||||
rot0 = FbFirst24Rot (dstX);
|
||||
|
||||
FbMaskBits (dstX, width, leftMask, nlMiddle, rightMask);
|
||||
|
||||
dstS = (dstX + 23) / 24;
|
||||
firstlen = FbStip24Len - dstS;
|
||||
|
||||
nDst = nlMiddle;
|
||||
if (leftMask)
|
||||
nDst++;
|
||||
dstStride -= nDst;
|
||||
|
||||
/* opaque copy */
|
||||
if (bgand == 0 && fgand == 0)
|
||||
{
|
||||
while (height--)
|
||||
{
|
||||
rot = rot0;
|
||||
src = srcLine;
|
||||
srcLine += srcStride;
|
||||
fbInitStipBits (srcX,firstlen, stip);
|
||||
if (leftMask)
|
||||
{
|
||||
mask = fbStipple24Bits[rot >> 3][stip];
|
||||
*dst = (*dst & ~leftMask) | (FbOpaqueStipple (mask,
|
||||
FbRot24(fgxor, rot),
|
||||
FbRot24(bgxor, rot))
|
||||
& leftMask);
|
||||
dst++;
|
||||
fbNextStipBits(rot,stip);
|
||||
}
|
||||
nl = nlMiddle;
|
||||
while (nl--)
|
||||
{
|
||||
mask = fbStipple24Bits[rot>>3][stip];
|
||||
*dst = FbOpaqueStipple (mask,
|
||||
FbRot24(fgxor, rot),
|
||||
FbRot24(bgxor, rot));
|
||||
dst++;
|
||||
fbNextStipBits(rot,stip);
|
||||
}
|
||||
if (rightMask)
|
||||
{
|
||||
mask = fbStipple24Bits[rot >> 3][stip];
|
||||
*dst = (*dst & ~rightMask) | (FbOpaqueStipple (mask,
|
||||
FbRot24(fgxor, rot),
|
||||
FbRot24(bgxor, rot))
|
||||
& rightMask);
|
||||
}
|
||||
dst += dstStride;
|
||||
src += srcStride;
|
||||
}
|
||||
}
|
||||
/* transparent copy */
|
||||
else if (bgand == FB_ALLONES && bgxor == 0 && fgand == 0)
|
||||
{
|
||||
while (height--)
|
||||
{
|
||||
rot = rot0;
|
||||
src = srcLine;
|
||||
srcLine += srcStride;
|
||||
fbInitStipBits (srcX, firstlen, stip);
|
||||
if (leftMask)
|
||||
{
|
||||
if (stip)
|
||||
{
|
||||
mask = fbStipple24Bits[rot >> 3][stip] & leftMask;
|
||||
*dst = (*dst & ~mask) | (FbRot24(fgxor, rot) & mask);
|
||||
}
|
||||
dst++;
|
||||
fbNextStipBits (rot, stip);
|
||||
}
|
||||
nl = nlMiddle;
|
||||
while (nl--)
|
||||
{
|
||||
if (stip)
|
||||
{
|
||||
mask = fbStipple24Bits[rot>>3][stip];
|
||||
*dst = (*dst & ~mask) | (FbRot24(fgxor,rot) & mask);
|
||||
}
|
||||
dst++;
|
||||
fbNextStipBits (rot, stip);
|
||||
}
|
||||
if (rightMask)
|
||||
{
|
||||
if (stip)
|
||||
{
|
||||
mask = fbStipple24Bits[rot >> 3][stip] & rightMask;
|
||||
*dst = (*dst & ~mask) | (FbRot24(fgxor, rot) & mask);
|
||||
}
|
||||
}
|
||||
dst += dstStride;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (height--)
|
||||
{
|
||||
rot = rot0;
|
||||
src = srcLine;
|
||||
srcLine += srcStride;
|
||||
fbInitStipBits (srcX, firstlen, stip);
|
||||
if (leftMask)
|
||||
{
|
||||
mask = fbStipple24Bits[rot >> 3][stip];
|
||||
*dst = FbStippleRRopMask (*dst, mask,
|
||||
FbRot24(fgand, rot),
|
||||
FbRot24(fgxor, rot),
|
||||
FbRot24(bgand, rot),
|
||||
FbRot24(bgxor, rot),
|
||||
leftMask);
|
||||
dst++;
|
||||
fbNextStipBits(rot,stip);
|
||||
}
|
||||
nl = nlMiddle;
|
||||
while (nl--)
|
||||
{
|
||||
mask = fbStipple24Bits[rot >> 3][stip];
|
||||
*dst = FbStippleRRop (*dst, mask,
|
||||
FbRot24(fgand, rot),
|
||||
FbRot24(fgxor, rot),
|
||||
FbRot24(bgand, rot),
|
||||
FbRot24(bgxor, rot));
|
||||
dst++;
|
||||
fbNextStipBits(rot,stip);
|
||||
}
|
||||
if (rightMask)
|
||||
{
|
||||
mask = fbStipple24Bits[rot >> 3][stip];
|
||||
*dst = FbStippleRRopMask (*dst, mask,
|
||||
FbRot24(fgand, rot),
|
||||
FbRot24(fgxor, rot),
|
||||
FbRot24(bgand, rot),
|
||||
FbRot24(bgxor, rot),
|
||||
rightMask);
|
||||
}
|
||||
dst += dstStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,83 +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
|
||||
_FbOnes (unsigned int mask)
|
||||
{
|
||||
register int y;
|
||||
|
||||
y = (mask >> 1) &033333333333;
|
||||
y = mask - y - ((y >>1) & 033333333333);
|
||||
return (((y + (y >> 3)) & 030707070707) % 077);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
pixman_color_to_pixel (const pixman_format_t *format,
|
||||
const pixman_color_t *color,
|
||||
pixman_bits_t *pixel)
|
||||
{
|
||||
uint32_t r, g, b, a;
|
||||
|
||||
r = color->red >> (16 - _FbOnes (format->redMask));
|
||||
g = color->green >> (16 - _FbOnes (format->greenMask));
|
||||
b = color->blue >> (16 - _FbOnes (format->blueMask));
|
||||
a = color->alpha >> (16 - _FbOnes (format->alphaMask));
|
||||
r = r << format->red;
|
||||
g = g << format->green;
|
||||
b = b << format->blue;
|
||||
a = a << format->alpha;
|
||||
*pixel = r|g|b|a;
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
FbFillColor (uint32_t pixel, int bits)
|
||||
{
|
||||
while (bits < 16)
|
||||
{
|
||||
pixel |= pixel << bits;
|
||||
bits <<= 1;
|
||||
}
|
||||
return (uint16_t) pixel;
|
||||
}
|
||||
|
||||
void
|
||||
pixman_pixel_to_color (const pixman_format_t *format,
|
||||
const pixman_bits_t pixel,
|
||||
pixman_color_t *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 = FbFillColor (r, _FbOnes (format->redMask));
|
||||
color->green = FbFillColor (r, _FbOnes (format->greenMask));
|
||||
color->blue = FbFillColor (r, _FbOnes (format->blueMask));
|
||||
color->alpha = FbFillColor (r, _FbOnes (format->alphaMask));
|
||||
}
|
|
@ -1,210 +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 : (unsigned) ((1 << (n))-1))
|
||||
|
||||
pixman_format_t *
|
||||
pixman_format_create (pixman_format_name_t name)
|
||||
{
|
||||
switch (name) {
|
||||
case PIXMAN_FORMAT_NAME_ARGB32:
|
||||
return pixman_format_create_masks (32,
|
||||
0xff000000,
|
||||
0x00ff0000,
|
||||
0x0000ff00,
|
||||
0x000000ff);
|
||||
case PIXMAN_FORMAT_NAME_RGB24:
|
||||
return pixman_format_create_masks (32,
|
||||
0x0,
|
||||
0xff0000,
|
||||
0x00ff00,
|
||||
0x0000ff);
|
||||
case PIXMAN_FORMAT_NAME_A8:
|
||||
return pixman_format_create_masks (8, 0xff,
|
||||
0, 0, 0);
|
||||
case PIXMAN_FORMAT_NAME_A1:
|
||||
return pixman_format_create_masks (1, 0x1,
|
||||
0, 0, 0);
|
||||
case PIXMAN_FORMAT_NAME_RGB16_565:
|
||||
return pixman_format_create_masks (16,
|
||||
0x0,
|
||||
0xf800,
|
||||
0x07e0,
|
||||
0x001f);
|
||||
case PIXMAN_FORMAT_NAME_ABGR32:
|
||||
return pixman_format_create_masks (32,
|
||||
0xff000000,
|
||||
0x000000ff,
|
||||
0x0000ff00,
|
||||
0x00ff0000);
|
||||
case PIXMAN_FORMAT_NAME_BGR24:
|
||||
return pixman_format_create_masks (32,
|
||||
0x0,
|
||||
0x000000ff,
|
||||
0x0000ff00,
|
||||
0x00ff0000);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* XXX: There's some nonsense going on here. The macros above help
|
||||
pixman_format_create_masks to encode a format into an int, while
|
||||
immediately afterwards pixman_format_init goes through the effort of
|
||||
decoding it. This should all be disentagled, (it's probably
|
||||
possible to just eliminate the encoding macros altogether). */
|
||||
pixman_format_t *
|
||||
pixman_format_create_masks (int bpp,
|
||||
int alpha_mask,
|
||||
int red_mask,
|
||||
int green_mask,
|
||||
int blue_mask)
|
||||
{
|
||||
int type;
|
||||
int format_code;
|
||||
pixman_format_t *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,
|
||||
_FbOnes (alpha_mask),
|
||||
_FbOnes (red_mask),
|
||||
_FbOnes (green_mask),
|
||||
_FbOnes (blue_mask));
|
||||
|
||||
format = malloc (sizeof (pixman_format_t));
|
||||
if (format == NULL)
|
||||
return NULL;
|
||||
|
||||
pixman_format_init (format, format_code);
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
void
|
||||
pixman_format_init (pixman_format_t *format, int format_code)
|
||||
{
|
||||
memset (format, 0, sizeof (pixman_format_t));
|
||||
|
||||
/* XXX: What do we want to lodge in here?
|
||||
format->id = FakeClientID (0);
|
||||
*/
|
||||
format->format_code = 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;
|
||||
}
|
||||
|
||||
format->depth = _FbOnes ((format->alphaMask << format->alpha) |
|
||||
(format->redMask << format->red) |
|
||||
(format->blueMask << format->blue) |
|
||||
(format->greenMask << format->green));
|
||||
}
|
||||
|
||||
void
|
||||
pixman_format_destroy (pixman_format_t *format)
|
||||
{
|
||||
free (format);
|
||||
}
|
||||
|
||||
void
|
||||
pixman_format_get_masks (pixman_format_t *format,
|
||||
unsigned int *bpp,
|
||||
unsigned int *alpha_mask,
|
||||
unsigned int *red_mask,
|
||||
unsigned int *green_mask,
|
||||
unsigned int *blue_mask)
|
||||
{
|
||||
*bpp = PICT_FORMAT_BPP (format->format_code);
|
||||
|
||||
if (format->alphaMask)
|
||||
*alpha_mask = format->alphaMask << format->alpha;
|
||||
else
|
||||
*alpha_mask = 0;
|
||||
|
||||
if (format->redMask)
|
||||
*red_mask = format->redMask << format->red;
|
||||
else
|
||||
*red_mask = 0;
|
||||
|
||||
if (format->greenMask)
|
||||
*green_mask = format->greenMask << format->green;
|
||||
else
|
||||
*green_mask = 0;
|
||||
|
||||
if (format->blueMask)
|
||||
*blue_mask = format->blueMask << format->blue;
|
||||
else
|
||||
*blue_mask = 0;
|
||||
}
|
|
@ -1,937 +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 "pixman-xserver-compat.h"
|
||||
|
||||
pixman_image_t *
|
||||
pixman_image_create (pixman_format_t *format,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
pixman_image_t *image;
|
||||
FbPixels *pixels;
|
||||
|
||||
pixels = FbPixelsCreate (width, height, format->depth);
|
||||
if (pixels == NULL)
|
||||
return NULL;
|
||||
|
||||
image = pixman_image_createForPixels (pixels, format);
|
||||
if (image == NULL) {
|
||||
FbPixelsDestroy (pixels);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image->owns_pixels = 1;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
pixman_image_t *
|
||||
pixman_image_create_for_data (FbBits *data, pixman_format_t *format, int width, int height, int bpp, int stride)
|
||||
{
|
||||
pixman_image_t *image;
|
||||
FbPixels *pixels;
|
||||
|
||||
pixels = FbPixelsCreateForData (data, width, height, format->depth, bpp, stride);
|
||||
if (pixels == NULL)
|
||||
return NULL;
|
||||
|
||||
image = pixman_image_createForPixels (pixels, format);
|
||||
if (image == NULL) {
|
||||
FbPixelsDestroy (pixels);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image->owns_pixels = 1;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
pixman_image_t *
|
||||
pixman_image_createForPixels (FbPixels *pixels,
|
||||
pixman_format_t *format)
|
||||
{
|
||||
pixman_image_t *image;
|
||||
|
||||
image = malloc (sizeof (pixman_image_t));
|
||||
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);
|
||||
}
|
||||
*/
|
||||
|
||||
pixman_image_init (image);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static CARD32 xRenderColorToCard32(pixman_color_t c)
|
||||
{
|
||||
return
|
||||
(c.alpha >> 8 << 24) |
|
||||
(c.red >> 8 << 16) |
|
||||
(c.green & 0xff00) |
|
||||
(c.blue >> 8);
|
||||
}
|
||||
|
||||
static uint32_t premultiply(uint32_t x)
|
||||
{
|
||||
uint32_t a = x >> 24;
|
||||
uint32_t t = (x & 0xff00ff) * a + 0x800080;
|
||||
t = (t + ((t >> 8) & 0xff00ff)) >> 8;
|
||||
t &= 0xff00ff;
|
||||
|
||||
x = ((x >> 8) & 0xff) * a + 0x80;
|
||||
x = (x + ((x >> 8) & 0xff));
|
||||
x &= 0xff00;
|
||||
x |= t | (a << 24);
|
||||
return x;
|
||||
}
|
||||
|
||||
static uint32_t INTERPOLATE_PIXEL_256(uint32_t x, uint32_t a, uint32_t y, uint32_t b)
|
||||
{
|
||||
CARD32 t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
|
||||
t >>= 8;
|
||||
t &= 0xff00ff;
|
||||
|
||||
x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
|
||||
x &= 0xff00ff00;
|
||||
x |= t;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
pixman_gradient_color (pixman_gradient_stop_t *stop1,
|
||||
pixman_gradient_stop_t *stop2,
|
||||
uint32_t x)
|
||||
{
|
||||
uint32_t current_color, next_color;
|
||||
int dist, idist;
|
||||
|
||||
current_color = xRenderColorToCard32 (stop1->color);
|
||||
next_color = xRenderColorToCard32 (stop2->color);
|
||||
|
||||
dist = (int) (256 * (x - stop1->x) / (stop2->x - stop1->x));
|
||||
idist = 256 - dist;
|
||||
|
||||
return premultiply (INTERPOLATE_PIXEL_256 (current_color, idist,
|
||||
next_color, dist));
|
||||
}
|
||||
|
||||
static int
|
||||
_pixman_init_gradient (pixman_gradient_image_t *gradient,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops)
|
||||
{
|
||||
pixman_fixed16_16_t dpos;
|
||||
int i;
|
||||
|
||||
if (n_stops <= 0)
|
||||
return 1;
|
||||
|
||||
dpos = -1;
|
||||
for (i = 0; i < n_stops; i++)
|
||||
{
|
||||
if (stops[i].x < dpos || stops[i].x > (1 << 16))
|
||||
return 1;
|
||||
|
||||
dpos = stops[i].x;
|
||||
}
|
||||
|
||||
gradient->class = SourcePictClassUnknown;
|
||||
gradient->stopRange = 0xffff;
|
||||
gradient->colorTable = NULL;
|
||||
gradient->colorTableSize = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static pixman_image_t *
|
||||
_pixman_create_source_image (void)
|
||||
{
|
||||
pixman_image_t *image;
|
||||
|
||||
image = (pixman_image_t *) malloc (sizeof (pixman_image_t));
|
||||
image->pDrawable = NULL;
|
||||
image->pixels = NULL;
|
||||
image->format_code = PICT_a8r8g8b8;
|
||||
|
||||
pixman_image_init (image);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
pixman_image_t *
|
||||
pixman_image_create_linear_gradient (const pixman_linear_gradient_t *gradient,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops)
|
||||
{
|
||||
pixman_linear_gradient_image_t *linear;
|
||||
pixman_image_t *image;
|
||||
|
||||
if (n_stops < 2)
|
||||
return NULL;
|
||||
|
||||
image = _pixman_create_source_image ();
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
linear = malloc (sizeof (pixman_linear_gradient_image_t) +
|
||||
sizeof (pixman_gradient_stop_t) * n_stops);
|
||||
if (!linear)
|
||||
{
|
||||
free (image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
linear->stops = (pixman_gradient_stop_t *) (linear + 1);
|
||||
linear->nstops = n_stops;
|
||||
|
||||
memcpy (linear->stops, stops, sizeof (pixman_gradient_stop_t) * n_stops);
|
||||
|
||||
linear->type = SourcePictTypeLinear;
|
||||
linear->p1 = gradient->p1;
|
||||
linear->p2 = gradient->p2;
|
||||
|
||||
image->pSourcePict = (pixman_source_image_t *) linear;
|
||||
|
||||
if (_pixman_init_gradient (&image->pSourcePict->gradient, stops, n_stops))
|
||||
{
|
||||
free (linear);
|
||||
free (image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
pixman_image_t *
|
||||
pixman_image_create_radial_gradient (const pixman_radial_gradient_t *gradient,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops)
|
||||
{
|
||||
pixman_radial_gradient_image_t *radial;
|
||||
pixman_image_t *image;
|
||||
|
||||
if (n_stops < 2)
|
||||
return NULL;
|
||||
|
||||
image = _pixman_create_source_image ();
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
radial = malloc (sizeof (pixman_radial_gradient_image_t) +
|
||||
sizeof (pixman_gradient_stop_t) * n_stops);
|
||||
if (!radial)
|
||||
{
|
||||
free (image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
radial->stops = (pixman_gradient_stop_t *) (radial + 1);
|
||||
radial->nstops = n_stops;
|
||||
|
||||
memcpy (radial->stops, stops, sizeof (pixman_gradient_stop_t) * n_stops);
|
||||
|
||||
radial->type = SourcePictTypeRadial;
|
||||
radial->c1 = gradient->c1;
|
||||
radial->c2 = gradient->c2;
|
||||
radial->cdx = xFixedToDouble (gradient->c2.x - gradient->c1.x);
|
||||
radial->cdy = xFixedToDouble (gradient->c2.y - gradient->c1.y);
|
||||
radial->dr = xFixedToDouble (gradient->c2.radius - gradient->c1.radius);
|
||||
radial->A = ( radial->cdx * radial->cdx
|
||||
+ radial->cdy * radial->cdy
|
||||
- radial->dr * radial->dr);
|
||||
|
||||
image->pSourcePict = (pixman_source_image_t *) radial;
|
||||
|
||||
if (_pixman_init_gradient (&image->pSourcePict->gradient, stops, n_stops))
|
||||
{
|
||||
free (radial);
|
||||
free (image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
void
|
||||
pixman_image_init (pixman_image_t *image)
|
||||
{
|
||||
image->refcnt = 1;
|
||||
image->repeat = PIXMAN_REPEAT_NONE;
|
||||
image->graphicsExposures = 0;
|
||||
image->subWindowMode = ClipByChildren;
|
||||
image->polyEdge = PolyEdgeSharp;
|
||||
image->polyMode = PolyModePrecise;
|
||||
/*
|
||||
* In the server this was 0 because the composite clip list
|
||||
* can be referenced from a window (and often is)
|
||||
*/
|
||||
image->freeCompClip = 0;
|
||||
image->freeSourceClip = 0;
|
||||
image->clientClipType = CT_NONE;
|
||||
image->componentAlpha = 0;
|
||||
image->compositeClipSource = 0;
|
||||
|
||||
image->alphaMap = NULL;
|
||||
image->alphaOrigin.x = 0;
|
||||
image->alphaOrigin.y = 0;
|
||||
|
||||
image->clipOrigin.x = 0;
|
||||
image->clipOrigin.y = 0;
|
||||
image->clientClip = NULL;
|
||||
|
||||
image->dither = 0L;
|
||||
|
||||
image->stateChanges = (1 << (CPLastBit+1)) - 1;
|
||||
/* XXX: What to lodge here?
|
||||
image->serialNumber = GC_CHANGE_SERIAL_BIT;
|
||||
*/
|
||||
|
||||
if (image->pixels)
|
||||
{
|
||||
image->pCompositeClip = pixman_region_create();
|
||||
pixman_region_union_rect (image->pCompositeClip, image->pCompositeClip,
|
||||
0, 0, image->pixels->width,
|
||||
image->pixels->height);
|
||||
image->freeCompClip = 1;
|
||||
|
||||
image->pSourceClip = pixman_region_create ();
|
||||
pixman_region_union_rect (image->pSourceClip, image->pSourceClip,
|
||||
0, 0, image->pixels->width,
|
||||
image->pixels->height);
|
||||
image->freeSourceClip = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
image->pCompositeClip = NULL;
|
||||
image->pSourceClip = NULL;
|
||||
}
|
||||
|
||||
image->transform = NULL;
|
||||
|
||||
image->filter = PIXMAN_FILTER_NEAREST;
|
||||
image->filter_params = NULL;
|
||||
image->filter_nparams = 0;
|
||||
|
||||
image->owns_pixels = 0;
|
||||
|
||||
image->pSourcePict = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
pixman_image_set_component_alpha (pixman_image_t *image,
|
||||
int component_alpha)
|
||||
{
|
||||
if (image)
|
||||
image->componentAlpha = component_alpha;
|
||||
}
|
||||
|
||||
int
|
||||
pixman_image_set_transform (pixman_image_t *image,
|
||||
pixman_transform_t *transform)
|
||||
{
|
||||
static const pixman_transform_t identity = { {
|
||||
{ xFixed1, 0x00000, 0x00000 },
|
||||
{ 0x00000, xFixed1, 0x00000 },
|
||||
{ 0x00000, 0x00000, xFixed1 },
|
||||
} };
|
||||
|
||||
if (transform && memcmp (transform, &identity, sizeof (pixman_transform_t)) == 0)
|
||||
transform = NULL;
|
||||
|
||||
if (transform)
|
||||
{
|
||||
if (!image->transform)
|
||||
{
|
||||
image->transform = malloc (sizeof (pixman_transform_t));
|
||||
if (!image->transform)
|
||||
return 1;
|
||||
}
|
||||
*image->transform = *transform;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image->transform)
|
||||
{
|
||||
free (image->transform);
|
||||
image->transform = NULL;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
pixman_image_set_repeat (pixman_image_t *image,
|
||||
pixman_repeat_t repeat)
|
||||
{
|
||||
if (image)
|
||||
image->repeat = repeat;
|
||||
}
|
||||
|
||||
void
|
||||
pixman_image_set_filter (pixman_image_t *image,
|
||||
pixman_filter_t filter)
|
||||
{
|
||||
if (image)
|
||||
image->filter = filter;
|
||||
}
|
||||
|
||||
int
|
||||
pixman_image_get_width (pixman_image_t *image)
|
||||
{
|
||||
if (image->pixels)
|
||||
return image->pixels->width;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
pixman_image_get_height (pixman_image_t *image)
|
||||
{
|
||||
if (image->pixels)
|
||||
return image->pixels->height;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
pixman_image_get_depth (pixman_image_t *image)
|
||||
{
|
||||
if (image->pixels)
|
||||
return image->pixels->depth;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
pixman_image_get_stride (pixman_image_t *image)
|
||||
{
|
||||
if (image->pixels)
|
||||
return image->pixels->stride;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
pixman_format_t *
|
||||
pixman_image_get_format (pixman_image_t *image)
|
||||
{
|
||||
return &image->image_format;
|
||||
}
|
||||
|
||||
FbBits *
|
||||
pixman_image_get_data (pixman_image_t *image)
|
||||
{
|
||||
if (image->pixels)
|
||||
return image->pixels->data;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
pixman_image_destroy (pixman_image_t *image)
|
||||
{
|
||||
pixman_image_destroyClip (image);
|
||||
|
||||
if (image->freeCompClip) {
|
||||
pixman_region_destroy (image->pCompositeClip);
|
||||
image->pCompositeClip = NULL;
|
||||
}
|
||||
|
||||
if (image->freeSourceClip) {
|
||||
pixman_region_destroy (image->pSourceClip);
|
||||
image->pSourceClip = NULL;
|
||||
}
|
||||
|
||||
if (image->owns_pixels) {
|
||||
FbPixelsDestroy (image->pixels);
|
||||
image->pixels = NULL;
|
||||
}
|
||||
|
||||
if (image->transform) {
|
||||
free (image->transform);
|
||||
image->transform = NULL;
|
||||
}
|
||||
|
||||
if (image->pSourcePict) {
|
||||
free (image->pSourcePict);
|
||||
image->pSourcePict = NULL;
|
||||
}
|
||||
|
||||
free (image);
|
||||
}
|
||||
|
||||
void
|
||||
pixman_image_destroyClip (pixman_image_t *image)
|
||||
{
|
||||
switch (image->clientClipType) {
|
||||
case CT_NONE:
|
||||
return;
|
||||
case CT_PIXMAP:
|
||||
pixman_image_destroy (image->clientClip);
|
||||
break;
|
||||
default:
|
||||
pixman_region_destroy (image->clientClip);
|
||||
break;
|
||||
}
|
||||
image->clientClip = NULL;
|
||||
image->clientClipType = CT_NONE;
|
||||
}
|
||||
|
||||
int
|
||||
pixman_image_set_clip_region (pixman_image_t *image,
|
||||
pixman_region16_t *region)
|
||||
{
|
||||
pixman_image_destroyClip (image);
|
||||
if (region) {
|
||||
image->clientClip = pixman_region_create ();
|
||||
pixman_region_copy (image->clientClip, region);
|
||||
image->clientClipType = CT_REGION;
|
||||
}
|
||||
|
||||
image->stateChanges |= CPClipMask;
|
||||
if (image->pSourcePict)
|
||||
return 0;
|
||||
|
||||
if (image->freeCompClip)
|
||||
pixman_region_destroy (image->pCompositeClip);
|
||||
image->pCompositeClip = pixman_region_create();
|
||||
pixman_region_union_rect (image->pCompositeClip, image->pCompositeClip,
|
||||
0, 0, image->pixels->width, image->pixels->height);
|
||||
image->freeCompClip = 1;
|
||||
if (region) {
|
||||
pixman_region_translate (image->pCompositeClip,
|
||||
- image->clipOrigin.x,
|
||||
- image->clipOrigin.y);
|
||||
pixman_region_intersect (image->pCompositeClip,
|
||||
image->pCompositeClip,
|
||||
region);
|
||||
pixman_region_translate (image->pCompositeClip,
|
||||
image->clipOrigin.x,
|
||||
image->clipOrigin.y);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define BOUND(v) (int16_t) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v))
|
||||
|
||||
static __inline int
|
||||
FbClipImageReg (pixman_region16_t *region,
|
||||
pixman_region16_t *clip,
|
||||
int dx,
|
||||
int dy)
|
||||
{
|
||||
if (pixman_region_num_rects (region) == 1 &&
|
||||
pixman_region_num_rects (clip) == 1)
|
||||
{
|
||||
pixman_box16_t *pRbox = pixman_region_rects (region);
|
||||
pixman_box16_t *pCbox = pixman_region_rects (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)
|
||||
{
|
||||
pixman_region_empty (region);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pixman_region_translate (region, dx, dy);
|
||||
pixman_region_intersect (region, clip, region);
|
||||
pixman_region_translate (region, -dx, -dy);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static __inline int
|
||||
FbClipImageSrc (pixman_region16_t *region,
|
||||
pixman_image_t *image,
|
||||
int dx,
|
||||
int dy)
|
||||
{
|
||||
/* XXX what to do with clipping from transformed pictures? */
|
||||
if (image->transform)
|
||||
return 1;
|
||||
/* XXX davidr hates this, wants to never use source-based clipping */
|
||||
if (image->repeat != PIXMAN_REPEAT_NONE || image->pSourcePict)
|
||||
{
|
||||
/* XXX no source clipping */
|
||||
if (image->compositeClipSource &&
|
||||
image->clientClipType != CT_NONE)
|
||||
{
|
||||
pixman_region_translate (region,
|
||||
dx - image->clipOrigin.x,
|
||||
dy - image->clipOrigin.y);
|
||||
pixman_region_intersect (region, image->clientClip, region);
|
||||
pixman_region_translate (region,
|
||||
- (dx - image->clipOrigin.x),
|
||||
- (dy - image->clipOrigin.y));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixman_region16_t *clip;
|
||||
|
||||
if (image->compositeClipSource)
|
||||
clip = image->pCompositeClip;
|
||||
else
|
||||
clip = image->pSourceClip;
|
||||
return FbClipImageReg (region,
|
||||
clip,
|
||||
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
|
||||
pixman_image_change (pixman_image_t *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:
|
||||
{
|
||||
pixman_image_t *iAlpha;
|
||||
|
||||
iAlpha = NEXT_PTR(pixman_image_t *);
|
||||
if (iAlpha)
|
||||
iAlpha->refcnt++;
|
||||
if (image->alphaMap)
|
||||
pixman_image_destroy ((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:
|
||||
{
|
||||
pixman_image_t *mask;
|
||||
int clipType;
|
||||
|
||||
mask = NEXT_PTR(pixman_image_t *);
|
||||
if (mask) {
|
||||
clipType = CT_PIXMAP;
|
||||
mask->refcnt++;
|
||||
} else {
|
||||
clipType = CT_NONE;
|
||||
}
|
||||
error = pixman_image_change_clip (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);
|
||||
pixman_region16_t *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
|
||||
FbComputeCompositeRegion (pixman_region16_t *region,
|
||||
pixman_image_t *iSrc,
|
||||
pixman_image_t *iMask,
|
||||
pixman_image_t *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 pixman_region16_t
|
||||
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)
|
||||
{
|
||||
pixman_region_empty (region);
|
||||
return 1;
|
||||
}
|
||||
/* clip against src */
|
||||
if (!FbClipImageSrc (region, iSrc, xDst - xSrc, yDst - ySrc))
|
||||
{
|
||||
pixman_region_destroy (region);
|
||||
return 0;
|
||||
}
|
||||
if (iSrc->alphaMap)
|
||||
{
|
||||
if (!FbClipImageSrc (region, iSrc->alphaMap,
|
||||
xDst - (xSrc + iSrc->alphaOrigin.x),
|
||||
yDst - (ySrc + iSrc->alphaOrigin.y)))
|
||||
{
|
||||
pixman_region_destroy (region);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* clip against mask */
|
||||
if (iMask)
|
||||
{
|
||||
if (!FbClipImageSrc (region, iMask, xDst - xMask, yDst - yMask))
|
||||
{
|
||||
pixman_region_destroy (region);
|
||||
return 0;
|
||||
}
|
||||
if (iMask->alphaMap)
|
||||
{
|
||||
if (!FbClipImageSrc (region, iMask->alphaMap,
|
||||
xDst - (xMask + iMask->alphaOrigin.x),
|
||||
yDst - (yMask + iMask->alphaOrigin.y)))
|
||||
{
|
||||
pixman_region_destroy (region);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!FbClipImageReg (region, iDst->pCompositeClip, 0, 0))
|
||||
{
|
||||
pixman_region_destroy (region);
|
||||
return 0;
|
||||
}
|
||||
if (iDst->alphaMap)
|
||||
{
|
||||
if (!FbClipImageReg (region, iDst->alphaMap->pCompositeClip,
|
||||
-iDst->alphaOrigin.x,
|
||||
-iDst->alphaOrigin.y))
|
||||
{
|
||||
pixman_region_destroy (region);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
miIsSolidAlpha (pixman_image_t *src)
|
||||
{
|
||||
char line[1];
|
||||
|
||||
/* Alpha-only */
|
||||
if (PICT_FORMAT_TYPE (src->format_code) != PICT_TYPE_A)
|
||||
return 0;
|
||||
/* repeat */
|
||||
if (!src->repeat)
|
||||
return 0;
|
||||
/* 1x1 */
|
||||
if (src->pixels->width != 1 || src->pixels->height != 1)
|
||||
return 0;
|
||||
line[0] = 1;
|
||||
/* XXX: For the next line, fb has:
|
||||
(*pScreen->GetImage) (src->pixels, 0, 0, 1, 1, ZPixmap, ~0L, line);
|
||||
Is the following simple assignment sufficient?
|
||||
*/
|
||||
line[0] = src->pixels->data[0];
|
||||
switch (src->pixels->bpp) {
|
||||
case 1:
|
||||
return (uint8_t) line[0] == 1 || (uint8_t) line[0] == 0x80;
|
||||
case 4:
|
||||
return (uint8_t) line[0] == 0xf || (uint8_t) line[0] == 0xf0;
|
||||
case 8:
|
||||
return (uint8_t) line[0] == 0xff;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,384 +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"
|
||||
*/
|
||||
|
||||
/*
|
||||
typedef struct _IndexFormat {
|
||||
VisualPtr pVisual;
|
||||
ColormapPtr pColormap;
|
||||
int nvalues;
|
||||
xIndexValue *pValues;
|
||||
void *devPrivate;
|
||||
} IndexFormatRec;
|
||||
*/
|
||||
|
||||
/*
|
||||
typedef struct pixman_format {
|
||||
uint32_t id;
|
||||
uint32_t format;
|
||||
unsigned char type;
|
||||
unsigned char depth;
|
||||
DirectFormatRec direct;
|
||||
IndexFormatRec index;
|
||||
} pixman_format_t;
|
||||
*/
|
||||
|
||||
#define PICT_GRADIENT_STOPTABLE_SIZE 1024
|
||||
|
||||
#define SourcePictTypeSolidFill 0
|
||||
#define SourcePictTypeLinear 1
|
||||
#define SourcePictTypeRadial 2
|
||||
#define SourcePictTypeConical 3
|
||||
|
||||
#define SourcePictClassUnknown 0
|
||||
#define SourcePictClassHorizontal 1
|
||||
#define SourcePictClassVertical 2
|
||||
|
||||
typedef struct _pixman_solid_fill_image {
|
||||
unsigned int type;
|
||||
unsigned int class;
|
||||
uint32_t color;
|
||||
} pixman_solid_fill_image_t;
|
||||
|
||||
typedef struct _pixman_gradient_image {
|
||||
unsigned int type;
|
||||
unsigned int class;
|
||||
pixman_gradient_stop_t *stops;
|
||||
int nstops;
|
||||
int stopRange;
|
||||
uint32_t *colorTable;
|
||||
int colorTableSize;
|
||||
} pixman_gradient_image_t;
|
||||
|
||||
typedef struct _pixman_linear_gradient_image {
|
||||
unsigned int type;
|
||||
unsigned int class;
|
||||
pixman_gradient_stop_t *stops;
|
||||
int nstops;
|
||||
int stopRange;
|
||||
uint32_t *colorTable;
|
||||
int colorTableSize;
|
||||
pixman_point_fixed_t p1;
|
||||
pixman_point_fixed_t p2;
|
||||
} pixman_linear_gradient_image_t;
|
||||
|
||||
typedef struct _pixman_radial_gradient_image {
|
||||
unsigned int type;
|
||||
unsigned int class;
|
||||
pixman_gradient_stop_t *stops;
|
||||
int nstops;
|
||||
int stopRange;
|
||||
uint32_t *colorTable;
|
||||
int colorTableSize;
|
||||
pixman_circle_t c1;
|
||||
pixman_circle_t c2;
|
||||
double cdx;
|
||||
double cdy;
|
||||
double dr;
|
||||
double A;
|
||||
} pixman_radial_gradient_image_t;
|
||||
|
||||
typedef struct _pixman_conical_gradient_image {
|
||||
unsigned int type;
|
||||
unsigned int class;
|
||||
pixman_gradient_stop_t *stops;
|
||||
int nstops;
|
||||
int stopRange;
|
||||
uint32_t *colorTable;
|
||||
int colorTableSize;
|
||||
pixman_point_fixed_t center;
|
||||
pixman_fixed16_16_t angle;
|
||||
} pixman_conical_gradient_image_t;
|
||||
|
||||
typedef union _pixman_source_image {
|
||||
unsigned int type;
|
||||
pixman_solid_fill_image_t solidFill;
|
||||
pixman_gradient_image_t gradient;
|
||||
pixman_linear_gradient_image_t linear;
|
||||
pixman_radial_gradient_image_t radial;
|
||||
pixman_conical_gradient_image_t conical;
|
||||
} pixman_source_image_t;
|
||||
|
||||
typedef pixman_source_image_t *SourcePictPtr;
|
||||
|
||||
struct pixman_image {
|
||||
FbPixels *pixels;
|
||||
pixman_format_t image_format;
|
||||
int format_code;
|
||||
int refcnt;
|
||||
|
||||
unsigned int repeat : 2;
|
||||
unsigned int graphicsExposures : 1;
|
||||
unsigned int subWindowMode : 1;
|
||||
unsigned int polyEdge : 1;
|
||||
unsigned int polyMode : 1;
|
||||
unsigned int freeCompClip : 1;
|
||||
unsigned int freeSourceClip : 1;
|
||||
unsigned int clientClipType : 2;
|
||||
unsigned int componentAlpha : 1;
|
||||
unsigned int compositeClipSource : 1;
|
||||
unsigned int unused : 20;
|
||||
|
||||
struct pixman_image *alphaMap;
|
||||
FbPoint alphaOrigin;
|
||||
|
||||
FbPoint clipOrigin;
|
||||
void *clientClip;
|
||||
|
||||
unsigned long dither;
|
||||
|
||||
unsigned long stateChanges;
|
||||
unsigned long serialNumber;
|
||||
|
||||
pixman_region16_t *pCompositeClip;
|
||||
pixman_region16_t *pSourceClip;
|
||||
|
||||
pixman_transform_t *transform;
|
||||
|
||||
pixman_filter_t filter;
|
||||
pixman_fixed16_16_t *filter_params;
|
||||
int filter_nparams;
|
||||
|
||||
int owns_pixels;
|
||||
|
||||
pixman_source_image_t *pSourcePict;
|
||||
};
|
||||
|
||||
#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 FbIndexType;
|
||||
#endif
|
||||
|
||||
/* XXX: We're not supporting indexed operations, right? */
|
||||
typedef struct _FbIndexed {
|
||||
int color;
|
||||
uint32_t rgba[IC_MAX_INDEXED];
|
||||
FbIndexType ent[32768];
|
||||
} FbIndexedRec, *FbIndexedPtr;
|
||||
|
||||
#define FbCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \
|
||||
(((s) >> 6) & 0x03e0) | \
|
||||
(((s) >> 9) & 0x7c00))
|
||||
#define FbIndexToEnt15(icf,rgb15) ((icf)->ent[rgb15])
|
||||
#define FbIndexToEnt24(icf,rgb24) FbIndexToEnt15(icf,FbCvtR8G8B8to15(rgb24))
|
||||
|
||||
#define FbIndexToEntY24(icf,rgb24) ((icf)->ent[CvtR8G8B8toY15(rgb24)])
|
||||
|
||||
/*
|
||||
pixman_private int
|
||||
FbCreatePicture (PicturePtr pPicture);
|
||||
*/
|
||||
|
||||
pixman_private void
|
||||
pixman_image_init (pixman_image_t *image);
|
||||
|
||||
pixman_private void
|
||||
pixman_image_destroyClip (pixman_image_t *image);
|
||||
|
||||
/*
|
||||
pixman_private void
|
||||
FbValidatePicture (PicturePtr pPicture,
|
||||
Mask mask);
|
||||
*/
|
||||
|
||||
/* XXX: What should this be?
|
||||
pixman_private int
|
||||
FbClipPicture (pixman_region16_t *region,
|
||||
pixman_image_t *image,
|
||||
int16_t xReg,
|
||||
int16_t yReg,
|
||||
int16_t xPict,
|
||||
int16_t yPict);
|
||||
*/
|
||||
|
||||
pixman_private int
|
||||
FbComputeCompositeRegion (pixman_region16_t *region,
|
||||
pixman_image_t *iSrc,
|
||||
pixman_image_t *iMask,
|
||||
pixman_image_t *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);
|
||||
|
||||
pixman_private int
|
||||
miIsSolidAlpha (pixman_image_t *src);
|
||||
|
||||
/*
|
||||
pixman_private int
|
||||
FbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
|
||||
*/
|
||||
|
||||
/*
|
||||
pixman_private void
|
||||
FbGlyphs (pixman_operator_t op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int nlist,
|
||||
GlyphListPtr list,
|
||||
GlyphPtr *glyphs);
|
||||
*/
|
||||
|
||||
/*
|
||||
pixman_private void
|
||||
pixman_compositeRects (pixman_operator_t op,
|
||||
PicturePtr pDst,
|
||||
xRenderColor *color,
|
||||
int nRect,
|
||||
xRectangle *rects);
|
||||
*/
|
||||
|
||||
pixman_private pixman_image_t *
|
||||
FbCreateAlphaPicture (pixman_image_t *dst,
|
||||
pixman_format_t *format,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
|
||||
typedef void (*CompositeFunc) (pixman_operator_t op,
|
||||
pixman_image_t *iSrc,
|
||||
pixman_image_t *iMask,
|
||||
pixman_image_t *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 _FbCompositeOperand FbCompositeOperand;
|
||||
|
||||
typedef uint32_t (*pixman_compositeFetch)(FbCompositeOperand *op);
|
||||
typedef void (*pixman_compositeStore) (FbCompositeOperand *op, uint32_t value);
|
||||
|
||||
typedef void (*pixman_compositeStep) (FbCompositeOperand *op);
|
||||
typedef void (*pixman_compositeSet) (FbCompositeOperand *op, int x, int y);
|
||||
|
||||
struct _FbCompositeOperand {
|
||||
union {
|
||||
struct {
|
||||
pixman_bits_t *top_line;
|
||||
int left_offset;
|
||||
|
||||
int start_offset;
|
||||
pixman_bits_t *line;
|
||||
uint32_t offset;
|
||||
FbStride 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;
|
||||
pixman_transform_t *transform;
|
||||
pixman_filter_t filter;
|
||||
int repeat;
|
||||
int width;
|
||||
int height;
|
||||
} transform;
|
||||
} u;
|
||||
pixman_compositeFetch fetch;
|
||||
pixman_compositeFetch fetcha;
|
||||
pixman_compositeStore store;
|
||||
pixman_compositeStep over;
|
||||
pixman_compositeStep down;
|
||||
pixman_compositeSet set;
|
||||
/* XXX: We're not supporting indexed operations, right?
|
||||
FbIndexedPtr indexed;
|
||||
*/
|
||||
pixman_region16_t *dst_clip;
|
||||
pixman_region16_t *src_clip;
|
||||
};
|
||||
|
||||
typedef void (*FbCombineFunc) (FbCompositeOperand *src,
|
||||
FbCompositeOperand *msk,
|
||||
FbCompositeOperand *dst);
|
||||
|
||||
typedef struct _FbAccessMap {
|
||||
uint32_t format_code;
|
||||
pixman_compositeFetch fetch;
|
||||
pixman_compositeFetch fetcha;
|
||||
pixman_compositeStore store;
|
||||
} FbAccessMap;
|
||||
|
||||
/* iccompose.c */
|
||||
|
||||
typedef struct _FbCompSrc {
|
||||
uint32_t value;
|
||||
uint32_t alpha;
|
||||
} FbCompSrc;
|
||||
|
||||
pixman_private int
|
||||
fbBuildCompositeOperand (pixman_image_t *image,
|
||||
FbCompositeOperand op[4],
|
||||
int16_t x,
|
||||
int16_t y,
|
||||
int transform,
|
||||
int alpha);
|
||||
|
||||
pixman_private void
|
||||
pixman_compositeGeneral (pixman_operator_t op,
|
||||
pixman_image_t *iSrc,
|
||||
pixman_image_t *iMask,
|
||||
pixman_image_t *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_ */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,114 +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.
|
||||
*/
|
||||
|
||||
#include "pixman-xserver-compat.h"
|
||||
|
||||
static void
|
||||
FbPixelsInit (FbPixels *pixels, pixman_bits_t *buf, int width, int height, int depth, int bpp, int stride);
|
||||
|
||||
static unsigned int
|
||||
pixman_bits_per_pixel (unsigned int depth);
|
||||
|
||||
static unsigned int
|
||||
pixman_bits_per_pixel (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;
|
||||
}
|
||||
|
||||
FbPixels *
|
||||
FbPixelsCreate (int width, int height, int depth)
|
||||
{
|
||||
FbPixels *pixels;
|
||||
pixman_bits_t *buf;
|
||||
unsigned int buf_size;
|
||||
unsigned int bpp;
|
||||
unsigned int stride;
|
||||
unsigned int adjust;
|
||||
unsigned int base;
|
||||
|
||||
bpp = pixman_bits_per_pixel (depth);
|
||||
stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (pixman_bits_t);
|
||||
buf_size = height * stride;
|
||||
base = sizeof (FbPixels);
|
||||
adjust = 0;
|
||||
if (base & 7)
|
||||
adjust = 8 - (base & 7);
|
||||
buf_size += adjust;
|
||||
|
||||
pixels = calloc(base + buf_size, 1);
|
||||
if (!pixels)
|
||||
return NULL;
|
||||
|
||||
buf = (pixman_bits_t *) ((char *)pixels + base + adjust);
|
||||
|
||||
FbPixelsInit (pixels, buf, width, height, depth, bpp, stride);
|
||||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
FbPixels *
|
||||
FbPixelsCreateForData (pixman_bits_t *data, int width, int height, int depth, int bpp, int stride)
|
||||
{
|
||||
FbPixels *pixels;
|
||||
|
||||
pixels = malloc (sizeof (FbPixels));
|
||||
if (pixels == NULL)
|
||||
return NULL;
|
||||
|
||||
FbPixelsInit (pixels, data, width, height, depth, bpp, stride);
|
||||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
static void
|
||||
FbPixelsInit (FbPixels *pixels, pixman_bits_t *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
|
||||
FbPixelsDestroy (FbPixels *pixels)
|
||||
{
|
||||
if(--pixels->refcnt)
|
||||
return;
|
||||
|
||||
free(pixels);
|
||||
}
|
|
@ -1,365 +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"
|
||||
|
||||
typedef void (*FillFunc) (pixman_image_t *dst,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height,
|
||||
pixman_bits_t *pixel);
|
||||
|
||||
static void
|
||||
pixman_fill_rect_1bpp (pixman_image_t *dst,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height,
|
||||
pixman_bits_t *pixel)
|
||||
{
|
||||
uint32_t value = *pixel ? 0xffffffff : 0;
|
||||
char *line;
|
||||
|
||||
line = (char *)dst->pixels->data
|
||||
+ yDst * dst->pixels->stride;
|
||||
|
||||
if ((width + xDst - 1) / 32 == xDst / 32) {
|
||||
uint32_t mask = 0;
|
||||
int pos = xDst / 32;
|
||||
int i;
|
||||
|
||||
for (i = xDst; i < width; i++)
|
||||
#if BITMAP_BIT_ORDER == MSBFirst
|
||||
mask |= 1 << (0x1f - i);
|
||||
#else
|
||||
mask |= 1 << i;
|
||||
#endif
|
||||
|
||||
while (height-- > 0) {
|
||||
uint32_t *cur = (uint32_t *) line;
|
||||
cur [pos] = (cur [pos] & ~mask) | (value & mask);
|
||||
line += dst->pixels->stride;
|
||||
}
|
||||
} else {
|
||||
uint32_t smask = 0, emask = 0;
|
||||
int end = ((xDst + width) / 32);
|
||||
int i;
|
||||
|
||||
if (xDst % 32)
|
||||
for (i = (xDst % 32); i < 32; i++)
|
||||
#if BITMAP_BIT_ORDER == MSBFirst
|
||||
smask |= 1 << (0x1f - i);
|
||||
#else
|
||||
smask |= 1 << i;
|
||||
#endif
|
||||
|
||||
if ((width + xDst) % 32)
|
||||
for (i = 0; i < (width + xDst) % 32; i++)
|
||||
#if BITMAP_BIT_ORDER == MSBFirst
|
||||
emask |= 1 << (0x1f - i);
|
||||
#else
|
||||
emask |= 1 << i;
|
||||
#endif
|
||||
|
||||
while (height-- > 0) {
|
||||
uint32_t *cur = (uint32_t *) line;
|
||||
int start = (xDst / 32);
|
||||
|
||||
if (smask) {
|
||||
cur [start] = (cur [start] & ~smask) | (value & smask);
|
||||
start++;
|
||||
}
|
||||
|
||||
if (emask)
|
||||
cur [end] = (cur [end] & ~emask) | (value & emask);
|
||||
|
||||
if (end > start)
|
||||
memset (cur + start, value, (end - start) * 4);
|
||||
line += dst->pixels->stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pixman_fill_rect_8bpp (pixman_image_t *dst,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height,
|
||||
pixman_bits_t *pixel)
|
||||
{
|
||||
int value = (int) (*pixel);
|
||||
char *line;
|
||||
|
||||
line = (char *)dst->pixels->data +
|
||||
xDst + yDst * dst->pixels->stride;
|
||||
while (height-- > 0) {
|
||||
memset (line, value, width);
|
||||
line += dst->pixels->stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pixman_fill_rect_32bpp (pixman_image_t *dst,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height,
|
||||
pixman_bits_t *pixel)
|
||||
{
|
||||
uint32_t int_pixel;
|
||||
char *line;
|
||||
char *data;
|
||||
int w;
|
||||
|
||||
line = (char *)dst->pixels->data +
|
||||
xDst * 4 + yDst * dst->pixels->stride;
|
||||
|
||||
int_pixel = *(uint32_t *)pixel;
|
||||
while (height-- > 0) {
|
||||
data = line;
|
||||
w = width;
|
||||
while (w-- > 0) {
|
||||
*(uint32_t *)data = int_pixel;
|
||||
data += 4;
|
||||
}
|
||||
line += dst->pixels->stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pixman_fill_rect_general (pixman_image_t *dst,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height,
|
||||
pixman_bits_t *pixel)
|
||||
{
|
||||
int pixel_size;
|
||||
char *line;
|
||||
char *data;
|
||||
int w;
|
||||
|
||||
pixel_size = dst->pixels->bpp >> 3;
|
||||
|
||||
line = (char *)dst->pixels->data +
|
||||
xDst * pixel_size + yDst * dst->pixels->stride;
|
||||
|
||||
while (height-- > 0) {
|
||||
data = line;
|
||||
w = width;
|
||||
while (w-- > 0) {
|
||||
memcpy (data, pixel, pixel_size);
|
||||
data += pixel_size;
|
||||
}
|
||||
line += dst->pixels->stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pixman_color_rects (pixman_image_t *dst,
|
||||
pixman_image_t *clipPict,
|
||||
pixman_color_t *color,
|
||||
int nRect,
|
||||
pixman_rectangle_t *rects,
|
||||
int xoff,
|
||||
int yoff)
|
||||
{
|
||||
pixman_bits_t pixel;
|
||||
pixman_region16_t *clip;
|
||||
pixman_region16_t *rects_as_region;
|
||||
pixman_box16_t *clipped_rects;
|
||||
int i, n_clipped_rects;
|
||||
FillFunc func;
|
||||
|
||||
pixman_color_to_pixel (&dst->image_format,
|
||||
color,
|
||||
&pixel);
|
||||
|
||||
/* offset to the right place on the destination image */
|
||||
xoff -= dst->pixels->x;
|
||||
yoff -= dst->pixels->y;
|
||||
|
||||
clip = pixman_region_create();
|
||||
pixman_region_union_rect (clip, clip,
|
||||
dst->pixels->x, dst->pixels->y,
|
||||
dst->pixels->width, dst->pixels->height);
|
||||
|
||||
pixman_region_intersect (clip, clip, clipPict->pCompositeClip);
|
||||
if (clipPict->alphaMap)
|
||||
{
|
||||
pixman_region_translate (clip,
|
||||
-clipPict->alphaOrigin.x,
|
||||
-clipPict->alphaOrigin.y);
|
||||
pixman_region_intersect (clip, clip, clipPict->alphaMap->pCompositeClip);
|
||||
pixman_region_translate (clip,
|
||||
clipPict->alphaOrigin.x,
|
||||
clipPict->alphaOrigin.y);
|
||||
}
|
||||
|
||||
if (xoff || yoff)
|
||||
{
|
||||
for (i = 0; i < nRect; i++)
|
||||
{
|
||||
rects[i].x -= xoff;
|
||||
rects[i].y -= yoff;
|
||||
}
|
||||
}
|
||||
|
||||
rects_as_region = pixman_region_create ();
|
||||
for (i = 0; i < nRect; i++)
|
||||
{
|
||||
pixman_region_union_rect (rects_as_region, rects_as_region,
|
||||
rects[i].x, rects[i].y,
|
||||
rects[i].width, rects[i].height);
|
||||
}
|
||||
|
||||
pixman_region_intersect (rects_as_region, rects_as_region, clip);
|
||||
pixman_region_destroy (clip);
|
||||
|
||||
n_clipped_rects = pixman_region_num_rects (rects_as_region);
|
||||
clipped_rects = pixman_region_rects (rects_as_region);
|
||||
|
||||
if (dst->pixels->bpp == 8)
|
||||
func = pixman_fill_rect_8bpp;
|
||||
else if (dst->pixels->bpp == 32)
|
||||
func = pixman_fill_rect_32bpp;
|
||||
else if (dst->pixels->bpp == 1)
|
||||
func = pixman_fill_rect_1bpp;
|
||||
else
|
||||
func = pixman_fill_rect_general;
|
||||
|
||||
for (i = 0; i < n_clipped_rects; i++) {
|
||||
(*func) (dst,
|
||||
clipped_rects[i].x1,
|
||||
clipped_rects[i].y1,
|
||||
clipped_rects[i].x2 - clipped_rects[i].x1,
|
||||
clipped_rects[i].y2 - clipped_rects[i].y1,
|
||||
&pixel);
|
||||
}
|
||||
|
||||
pixman_region_destroy (rects_as_region);
|
||||
|
||||
if (xoff || yoff)
|
||||
{
|
||||
for (i = 0; i < nRect; i++)
|
||||
{
|
||||
rects[i].x += xoff;
|
||||
rects[i].y += yoff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pixman_fill_rectangle (pixman_operator_t op,
|
||||
pixman_image_t *dst,
|
||||
const pixman_color_t *color,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int width,
|
||||
unsigned int height)
|
||||
{
|
||||
pixman_rectangle_t rect;
|
||||
|
||||
rect.x = x;
|
||||
rect.y = y;
|
||||
rect.width = width;
|
||||
rect.height = height;
|
||||
|
||||
pixman_fill_rectangles (op, dst, color, &rect, 1);
|
||||
}
|
||||
|
||||
void
|
||||
pixman_fill_rectangles (pixman_operator_t op,
|
||||
pixman_image_t *dst,
|
||||
const pixman_color_t *color,
|
||||
const pixman_rectangle_t *rects,
|
||||
int nRects)
|
||||
{
|
||||
pixman_color_t color_s = *color;
|
||||
|
||||
if (color_s.alpha == 0xffff)
|
||||
{
|
||||
if (op == PIXMAN_OPERATOR_OVER)
|
||||
op = PIXMAN_OPERATOR_SRC;
|
||||
}
|
||||
if (op == PIXMAN_OPERATOR_CLEAR)
|
||||
color_s.red = color_s.green = color_s.blue = color_s.alpha = 0;
|
||||
|
||||
if (op == PIXMAN_OPERATOR_SRC || op == PIXMAN_OPERATOR_CLEAR)
|
||||
{
|
||||
/* We cast away the constness of rects here, because pixman_color_rects
|
||||
temporarily modifies it */
|
||||
pixman_color_rects (dst, dst, &color_s, nRects, (pixman_rectangle_t *)rects, 0, 0);
|
||||
if (dst->alphaMap)
|
||||
pixman_color_rects (dst->alphaMap, dst,
|
||||
&color_s, nRects, (pixman_rectangle_t *)rects,
|
||||
dst->alphaOrigin.x,
|
||||
dst->alphaOrigin.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
pixman_format_t rgbaFormat;
|
||||
FbPixels *pixels;
|
||||
pixman_image_t *src;
|
||||
pixman_bits_t pixel;
|
||||
|
||||
pixman_format_init (&rgbaFormat, PICT_a8r8g8b8);
|
||||
|
||||
pixels = FbPixelsCreate (1, 1, rgbaFormat.depth);
|
||||
if (!pixels)
|
||||
goto bail1;
|
||||
|
||||
pixman_color_to_pixel (&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 = pixman_image_createForPixels (pixels, &rgbaFormat);
|
||||
if (!src)
|
||||
goto bail2;
|
||||
|
||||
pixman_image_set_repeat (src, PIXMAN_REPEAT_NORMAL);
|
||||
|
||||
while (nRects--)
|
||||
{
|
||||
pixman_composite (op, src, NULL, dst, 0, 0, 0, 0,
|
||||
rects->x,
|
||||
rects->y,
|
||||
rects->width,
|
||||
rects->height);
|
||||
rects++;
|
||||
}
|
||||
|
||||
pixman_image_destroy (src);
|
||||
bail2:
|
||||
FbPixelsDestroy (pixels);
|
||||
bail1:
|
||||
;
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
FbBits ca1, cx1, ca2, cx2;
|
||||
} FbMergeRopRec, *FbMergeRopPtr;
|
||||
|
||||
extern pixman_private const FbMergeRopRec FbMergeRopBits[16];
|
||||
|
||||
#define FbDeclareMergeRop() FbBits _ca1, _cx1, _ca2, _cx2;
|
||||
#define FbDeclarePrebuiltMergeRop() FbBits _cca, _ccx;
|
||||
|
||||
#define FbInitializeMergeRop(alu,pm) {\
|
||||
const FbMergeRopRec *_bits; \
|
||||
_bits = &FbMergeRopBits[alu]; \
|
||||
_ca1 = _bits->ca1 & pm; \
|
||||
_cx1 = _bits->cx1 | ~pm; \
|
||||
_ca2 = _bits->ca2 & pm; \
|
||||
_cx2 = _bits->cx2 & pm; \
|
||||
}
|
||||
|
||||
#define FbDestInvarientRop(alu,pm) ((pm) == FB_ALLONES && \
|
||||
(((alu) >> 1 & 5) == ((alu) & 5)))
|
||||
|
||||
#define FbDestInvarientMergeRop() (_ca1 == 0 && _cx1 == 0)
|
||||
|
||||
/* AND has higher precedence than XOR */
|
||||
|
||||
#define FbDoMergeRop(src, dst) \
|
||||
(((dst) & (((src) & _ca1) ^ _cx1)) ^ (((src) & _ca2) ^ _cx2))
|
||||
|
||||
#define FbDoDestInvarientMergeRop(src) (((src) & _ca2) ^ _cx2)
|
||||
|
||||
#define FbDoMaskMergeRop(src, dst, mask) \
|
||||
(((dst) & ((((src) & _ca1) ^ _cx1) | ~(mask))) ^ ((((src) & _ca2) ^ _cx2) & (mask)))
|
||||
|
||||
#define FbDoLeftMaskByteMergeRop(dst, src, lb, l) { \
|
||||
FbBits __xor = ((src) & _ca2) ^ _cx2; \
|
||||
FbDoLeftMaskByteRRop(dst,lb,l,((src) & _ca1) ^ _cx1,__xor); \
|
||||
}
|
||||
|
||||
#define FbDoRightMaskByteMergeRop(dst, src, rb, r) { \
|
||||
FbBits __xor = ((src) & _ca2) ^ _cx2; \
|
||||
FbDoRightMaskByteRRop(dst,rb,r,((src) & _ca1) ^ _cx1,__xor); \
|
||||
}
|
||||
|
||||
#define FbDoRRop(dst, and, xor) (((dst) & (and)) ^ (xor))
|
||||
|
||||
#define FbDoMaskRRop(dst, and, xor, mask) \
|
||||
(((dst) & ((and) | ~(mask))) ^ (xor & mask))
|
||||
|
||||
/*
|
||||
* Take a single bit (0 or 1) and generate a full mask
|
||||
*/
|
||||
#define fbFillFromBit(b,t) (~((t) ((b) & 1)-1))
|
||||
|
||||
#define fbXorT(rop,fg,pm,t) ((((fg) & fbFillFromBit((rop) >> 1,t)) | \
|
||||
(~(fg) & fbFillFromBit((rop) >> 3,t))) & (pm))
|
||||
|
||||
#define fbAndT(rop,fg,pm,t) ((((fg) & fbFillFromBit (rop ^ (rop>>1),t)) | \
|
||||
(~(fg) & fbFillFromBit((rop>>2) ^ (rop>>3),t))) | \
|
||||
~(pm))
|
||||
|
||||
#define fbXor(rop,fg,pm) fbXorT(rop,fg,pm,FbBits)
|
||||
|
||||
#define fbAnd(rop,fg,pm) fbAndT(rop,fg,pm,FbBits)
|
||||
|
||||
#define fbXorStip(rop,fg,pm) fbXorT(rop,fg,pm,FbStip)
|
||||
|
||||
#define fbAndStip(rop,fg,pm) fbAndT(rop,fg,pm,FbStip)
|
||||
|
||||
/*
|
||||
* Stippling operations;
|
||||
*/
|
||||
|
||||
/* half of table */
|
||||
extern pixman_private const pixman_bits_t fbStipple16Bits[256];
|
||||
#define FbStipple16Bits(b) \
|
||||
(fbStipple16Bits[(b)&0xff] | fbStipple16Bits[(b) >> 8] << FB_HALFUNIT)
|
||||
|
||||
pixman_private const pixman_bits_t *
|
||||
fbStippleTable(int bits);
|
||||
|
||||
#define FbStippleRRop(dst, b, fa, fx, ba, bx) \
|
||||
(FbDoRRop(dst, fa, fx) & b) | (FbDoRRop(dst, ba, bx) & ~b)
|
||||
|
||||
#define FbStippleRRopMask(dst, b, fa, fx, ba, bx, m) \
|
||||
(FbDoMaskRRop(dst, fa, fx, m) & (b)) | (FbDoMaskRRop(dst, ba, bx, m) & ~(b))
|
||||
|
||||
#define FbDoLeftMaskByteStippleRRop(dst, b, fa, fx, ba, bx, lb, l) { \
|
||||
FbBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \
|
||||
FbDoLeftMaskByteRRop(dst, lb, l, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
|
||||
}
|
||||
|
||||
#define FbDoRightMaskByteStippleRRop(dst, b, fa, fx, ba, bx, rb, r) { \
|
||||
FbBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \
|
||||
FbDoRightMaskByteRRop(dst, rb, r, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
|
||||
}
|
||||
|
||||
#define FbOpaqueStipple(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 FbStipple1RopPick(alu,b) (((alu) >> (2 - (((b) & 1) << 1))) & 3)
|
||||
|
||||
#define FbOpaqueStipple1Rop(alu,fg,bg) (FbStipple1RopPick(alu,fg) | \
|
||||
(FbStipple1RopPick(alu,bg) << 2))
|
||||
|
||||
#define FbStipple1Rop(alu,fg) (FbStipple1RopPick(alu,fg) | 4)
|
||||
|
||||
#endif
|
|
@ -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 "pixman-xserver-compat.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)FbLaneCase(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 FB_SHIFT == 6
|
||||
#define LaneCases(a) LaneCases256(0,a)
|
||||
#endif
|
||||
|
||||
#if FB_SHIFT == 5
|
||||
#define LaneCases(a) LaneCases16(0,a)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Repeat a transparent stipple across a scanline n times
|
||||
*/
|
||||
|
||||
void
|
||||
fbTransparentSpan (FbBits *dst,
|
||||
FbBits stip,
|
||||
FbBits fgxor,
|
||||
int n)
|
||||
{
|
||||
FbStip s;
|
||||
|
||||
s = ((FbStip) (stip ) & 0x01);
|
||||
s |= ((FbStip) (stip >> 8) & 0x02);
|
||||
s |= ((FbStip) (stip >> 16) & 0x04);
|
||||
s |= ((FbStip) (stip >> 24) & 0x08);
|
||||
#if FB_SHIFT > 5
|
||||
s |= ((FbStip) (stip >> 32) & 0x10);
|
||||
s |= ((FbStip) (stip >> 40) & 0x20);
|
||||
s |= ((FbStip) (stip >> 48) & 0x40);
|
||||
s |= ((FbStip) (stip >> 56) & 0x80);
|
||||
#endif
|
||||
switch (s) {
|
||||
LaneCases(dst);
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,63 +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 MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff)
|
||||
#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31))
|
||||
|
||||
int
|
||||
pixman_transform_point (pixman_transform_t *transform,
|
||||
pixman_vector_t *vector)
|
||||
{
|
||||
pixman_vector_t 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;
|
||||
}
|
|
@ -1,206 +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"
|
||||
|
||||
pixman_image_t *
|
||||
FbCreateAlphaPicture (pixman_image_t *dst,
|
||||
pixman_format_t *format,
|
||||
uint16_t width,
|
||||
uint16_t height)
|
||||
{
|
||||
pixman_image_t *image;
|
||||
int own_format = 0;
|
||||
|
||||
if (width > 32767 || height > 32767)
|
||||
return NULL;
|
||||
|
||||
if (!format)
|
||||
{
|
||||
own_format = 1;
|
||||
if (dst->polyEdge == PolyEdgeSharp)
|
||||
format = pixman_format_create (PIXMAN_FORMAT_NAME_A1);
|
||||
else
|
||||
format = pixman_format_create (PIXMAN_FORMAT_NAME_A8);
|
||||
if (!format)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* pixman_image_create zeroes out the pixels, so we don't have to */
|
||||
image = pixman_image_create (format, width, height);
|
||||
|
||||
if (own_format)
|
||||
pixman_format_destroy (format);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static pixman_fixed16_16_t
|
||||
pixman_line_fixed_x (const pixman_line_fixed_t *l, pixman_fixed16_16_t y, int ceil)
|
||||
{
|
||||
pixman_fixed16_16_t dx = l->p2.x - l->p1.x;
|
||||
xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
|
||||
pixman_fixed16_16_t dy = l->p2.y - l->p1.y;
|
||||
if (ceil)
|
||||
ex += (dy - 1);
|
||||
return l->p1.x + (pixman_fixed16_16_t) (ex / dy);
|
||||
}
|
||||
|
||||
static void
|
||||
pixman_trapezoid_bounds (int ntrap, const pixman_trapezoid_t *traps, pixman_box16_t *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 (pixman_line_fixed_x (&traps->left, traps->top, 0),
|
||||
pixman_line_fixed_x (&traps->left, traps->bottom, 0)));
|
||||
if (x1 < box->x1)
|
||||
box->x1 = x1;
|
||||
|
||||
x2 = xFixedToInt (xFixedCeil (MAX (pixman_line_fixed_x (&traps->right, traps->top, 1),
|
||||
pixman_line_fixed_x (&traps->right, traps->bottom, 1))));
|
||||
if (x2 > box->x2)
|
||||
box->x2 = x2;
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX: There are failure cases in this function. Don't we need to
|
||||
* propagate the errors out?
|
||||
*/
|
||||
void
|
||||
pixman_composite_trapezoids (pixman_operator_t op,
|
||||
pixman_image_t *src,
|
||||
pixman_image_t *dst,
|
||||
int xSrc,
|
||||
int ySrc,
|
||||
const pixman_trapezoid_t *traps,
|
||||
int ntraps)
|
||||
{
|
||||
pixman_image_t *image = NULL;
|
||||
pixman_box16_t traps_bounds, dst_bounds, bounds;
|
||||
pixman_region16_t *traps_region, *dst_region;
|
||||
int16_t xDst, yDst;
|
||||
int16_t xRel, yRel;
|
||||
pixman_format_t *format;
|
||||
|
||||
if (ntraps == 0)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Check for solid alpha add
|
||||
*/
|
||||
if (op == PIXMAN_OPERATOR_ADD && miIsSolidAlpha (src))
|
||||
{
|
||||
for (; ntraps; ntraps--, traps++)
|
||||
fbRasterizeTrapezoid (dst, traps, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
xDst = traps[0].left.p1.x >> 16;
|
||||
yDst = traps[0].left.p1.y >> 16;
|
||||
|
||||
pixman_trapezoid_bounds (ntraps, traps, &traps_bounds);
|
||||
|
||||
traps_region = pixman_region_create_simple (&traps_bounds);
|
||||
|
||||
/* XXX: If the image has a clip region set, we should really be
|
||||
* fetching it here instead, but it looks like we don't yet expose
|
||||
* a pixman_image_get_clip_region function. */
|
||||
dst_bounds.x1 = 0;
|
||||
dst_bounds.y1 = 0;
|
||||
dst_bounds.x2 = pixman_image_get_width (dst);
|
||||
dst_bounds.y2 = pixman_image_get_height (dst);
|
||||
|
||||
dst_region = pixman_region_create_simple (&dst_bounds);
|
||||
|
||||
pixman_region_intersect (traps_region, traps_region, dst_region);
|
||||
|
||||
bounds = *(pixman_region_extents (traps_region));
|
||||
|
||||
pixman_region_destroy (traps_region);
|
||||
pixman_region_destroy (dst_region);
|
||||
|
||||
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
|
||||
return;
|
||||
|
||||
format = pixman_format_create (PIXMAN_FORMAT_NAME_A8);
|
||||
if (!format)
|
||||
return;
|
||||
|
||||
image = FbCreateAlphaPicture (dst, format,
|
||||
bounds.x2 - bounds.x1,
|
||||
bounds.y2 - bounds.y1);
|
||||
if (!image)
|
||||
{
|
||||
pixman_format_destroy (format);
|
||||
return;
|
||||
}
|
||||
|
||||
for (; ntraps; ntraps--, traps++)
|
||||
{
|
||||
if (!xTrapezoidValid(traps))
|
||||
continue;
|
||||
fbRasterizeTrapezoid (image, traps,
|
||||
-bounds.x1, -bounds.y1);
|
||||
}
|
||||
|
||||
xRel = bounds.x1 + xSrc - xDst;
|
||||
yRel = bounds.y1 + ySrc - yDst;
|
||||
pixman_composite (op, src, image, dst,
|
||||
xRel, yRel, 0, 0, bounds.x1, bounds.y1,
|
||||
bounds.x2 - bounds.x1,
|
||||
bounds.y2 - bounds.y1);
|
||||
pixman_image_destroy (image);
|
||||
|
||||
pixman_format_destroy (format);
|
||||
}
|
||||
|
||||
void
|
||||
pixman_add_trapezoids (pixman_image_t *dst,
|
||||
int x_off,
|
||||
int y_off,
|
||||
const pixman_trapezoid_t *traps,
|
||||
int ntraps)
|
||||
{
|
||||
for (; ntraps; ntraps--, traps++)
|
||||
{
|
||||
if (!xTrapezoidValid (traps))
|
||||
continue;
|
||||
|
||||
fbRasterizeTrapezoid (dst, traps, x_off, y_off);
|
||||
}
|
||||
}
|
|
@ -1,363 +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
|
||||
pixman_point_fixed_bounds (int npoint, const pixman_point_fixed_t *points, pixman_box16_t *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
|
||||
pixman_triangle_bounds (int ntri, const pixman_triangle_t *tris, pixman_box16_t *bounds)
|
||||
{
|
||||
pixman_point_fixed_bounds (ntri * 3, (pixman_point_fixed_t *) tris, bounds);
|
||||
}
|
||||
|
||||
static void
|
||||
FbRasterizeTriangle (pixman_image_t *image,
|
||||
const pixman_triangle_t *tri,
|
||||
int x_off,
|
||||
int y_off)
|
||||
{
|
||||
const pixman_point_fixed_t *top, *left, *right, *t;
|
||||
pixman_trapezoid_t 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)
|
||||
fbRasterizeTrapezoid (image, &trap[0], x_off, y_off);
|
||||
if (trap[1].top != trap[1].bottom)
|
||||
fbRasterizeTrapezoid (image, &trap[1], x_off, y_off);
|
||||
}
|
||||
|
||||
void
|
||||
pixman_composite_triangles (pixman_operator_t op,
|
||||
pixman_image_t *src,
|
||||
pixman_image_t *dst,
|
||||
int xSrc,
|
||||
int ySrc,
|
||||
const pixman_triangle_t *tris,
|
||||
int ntris)
|
||||
{
|
||||
pixman_box16_t bounds = {0, 0, 0, 0}; /* shut gcc up */
|
||||
pixman_image_t *image = NULL;
|
||||
int xDst, yDst;
|
||||
int xRel, yRel;
|
||||
pixman_format_t *format;
|
||||
|
||||
xDst = tris[0].p1.x >> 16;
|
||||
yDst = tris[0].p1.y >> 16;
|
||||
|
||||
format = pixman_format_create (PIXMAN_FORMAT_NAME_A8);
|
||||
|
||||
if (format)
|
||||
{
|
||||
pixman_triangle_bounds (ntris, tris, &bounds);
|
||||
if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
|
||||
return;
|
||||
image = FbCreateAlphaPicture (dst,
|
||||
format,
|
||||
bounds.x2 - bounds.x1,
|
||||
bounds.y2 - bounds.y1);
|
||||
if (!image)
|
||||
return;
|
||||
}
|
||||
for (; ntris; ntris--, tris++)
|
||||
{
|
||||
if (!format)
|
||||
{
|
||||
pixman_triangle_bounds (1, tris, &bounds);
|
||||
if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
|
||||
continue;
|
||||
image = FbCreateAlphaPicture (dst,
|
||||
format,
|
||||
bounds.x2 - bounds.x1,
|
||||
bounds.y2 - bounds.y1);
|
||||
if (!image)
|
||||
break;
|
||||
}
|
||||
FbRasterizeTriangle (image, tris, -bounds.x1, -bounds.y1);
|
||||
if (!format)
|
||||
{
|
||||
xRel = bounds.x1 + xSrc - xDst;
|
||||
yRel = bounds.y1 + ySrc - yDst;
|
||||
pixman_composite (op, src, image, dst,
|
||||
xRel, yRel, 0, 0, bounds.x1, bounds.y1,
|
||||
bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
|
||||
pixman_image_destroy (image);
|
||||
}
|
||||
/* XXX adjust xSrc and ySrc */
|
||||
}
|
||||
if (format)
|
||||
{
|
||||
xRel = bounds.x1 + xSrc - xDst;
|
||||
yRel = bounds.y1 + ySrc - yDst;
|
||||
pixman_composite (op, src, image, dst,
|
||||
xRel, yRel, 0, 0, bounds.x1, bounds.y1,
|
||||
bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
|
||||
pixman_image_destroy (image);
|
||||
}
|
||||
|
||||
pixman_format_destroy (format);
|
||||
}
|
||||
|
||||
void
|
||||
pixman_composite_tri_strip (pixman_operator_t op,
|
||||
pixman_image_t *src,
|
||||
pixman_image_t *dst,
|
||||
int xSrc,
|
||||
int ySrc,
|
||||
const pixman_point_fixed_t *points,
|
||||
int npoints)
|
||||
{
|
||||
pixman_triangle_t tri;
|
||||
pixman_box16_t bounds = {0, 0, 0, 0}; /* shut gcc up */
|
||||
pixman_image_t *image = NULL;
|
||||
int xDst, yDst;
|
||||
int xRel, yRel;
|
||||
pixman_format_t *format;
|
||||
|
||||
if (npoints < 3)
|
||||
return;
|
||||
|
||||
xDst = points[0].x >> 16;
|
||||
yDst = points[0].y >> 16;
|
||||
|
||||
format = pixman_format_create (PIXMAN_FORMAT_NAME_A8);
|
||||
|
||||
if (format)
|
||||
{
|
||||
pixman_point_fixed_bounds (npoints, points, &bounds);
|
||||
if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
|
||||
return;
|
||||
image = FbCreateAlphaPicture (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)
|
||||
{
|
||||
pixman_triangle_bounds (1, &tri, &bounds);
|
||||
if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
|
||||
continue;
|
||||
image = FbCreateAlphaPicture (dst,
|
||||
format,
|
||||
bounds.x2 - bounds.x1,
|
||||
bounds.y2 - bounds.y1);
|
||||
if (!image)
|
||||
continue;
|
||||
}
|
||||
FbRasterizeTriangle (image, &tri, -bounds.x1, -bounds.y1);
|
||||
if (!format)
|
||||
{
|
||||
xRel = bounds.x1 + xSrc - xDst;
|
||||
yRel = bounds.y1 + ySrc - yDst;
|
||||
pixman_composite (op, src, image, dst,
|
||||
xRel, yRel, 0, 0, bounds.x1, bounds.y1,
|
||||
bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
|
||||
pixman_image_destroy (image);
|
||||
}
|
||||
}
|
||||
if (format)
|
||||
{
|
||||
xRel = bounds.x1 + xSrc - xDst;
|
||||
yRel = bounds.y1 + ySrc - yDst;
|
||||
pixman_composite (op, src, image, dst,
|
||||
xRel, yRel, 0, 0, bounds.x1, bounds.y1,
|
||||
bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
|
||||
pixman_image_destroy (image);
|
||||
}
|
||||
|
||||
pixman_format_destroy (format);
|
||||
}
|
||||
|
||||
void
|
||||
pixman_composite_tri_fan (pixman_operator_t op,
|
||||
pixman_image_t *src,
|
||||
pixman_image_t *dst,
|
||||
int xSrc,
|
||||
int ySrc,
|
||||
const pixman_point_fixed_t *points,
|
||||
int npoints)
|
||||
{
|
||||
pixman_triangle_t tri;
|
||||
pixman_box16_t bounds = {0, 0, 0, 0}; /* shut gcc up */
|
||||
pixman_image_t *image = NULL;
|
||||
const pixman_point_fixed_t *first;
|
||||
int xDst, yDst;
|
||||
int xRel, yRel;
|
||||
pixman_format_t *format;
|
||||
|
||||
if (npoints < 3)
|
||||
return;
|
||||
|
||||
xDst = points[0].x >> 16;
|
||||
yDst = points[0].y >> 16;
|
||||
|
||||
format = pixman_format_create (PIXMAN_FORMAT_NAME_A8);
|
||||
|
||||
if (format)
|
||||
{
|
||||
pixman_point_fixed_bounds (npoints, points, &bounds);
|
||||
if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
|
||||
return;
|
||||
image = FbCreateAlphaPicture (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)
|
||||
{
|
||||
pixman_triangle_bounds (1, &tri, &bounds);
|
||||
if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
|
||||
continue;
|
||||
image = FbCreateAlphaPicture (dst,
|
||||
format,
|
||||
bounds.x2 - bounds.x1,
|
||||
bounds.y2 - bounds.y1);
|
||||
if (!image)
|
||||
continue;
|
||||
}
|
||||
FbRasterizeTriangle (image, &tri, -bounds.x1, -bounds.y1);
|
||||
if (!format)
|
||||
{
|
||||
xRel = bounds.x1 + xSrc - xDst;
|
||||
yRel = bounds.y1 + ySrc - yDst;
|
||||
pixman_composite (op, src, image, dst,
|
||||
xRel, yRel, 0, 0, bounds.x1, bounds.y1,
|
||||
bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
|
||||
pixman_image_destroy (image);
|
||||
}
|
||||
}
|
||||
if (format)
|
||||
{
|
||||
xRel = bounds.x1 + xSrc - xDst;
|
||||
yRel = bounds.y1 + ySrc - yDst;
|
||||
pixman_composite (op, src, image, dst,
|
||||
xRel, yRel, 0, 0, bounds.x1, bounds.y1,
|
||||
bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
|
||||
pixman_image_destroy (image);
|
||||
}
|
||||
|
||||
pixman_format_destroy (format);
|
||||
}
|
|
@ -1,285 +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 "pixman-xserver-compat.h"
|
||||
|
||||
pixman_bits_t
|
||||
fbReplicatePixel (Pixel p, int bpp)
|
||||
{
|
||||
pixman_bits_t b = p;
|
||||
|
||||
b &= FbFullMask (bpp);
|
||||
while (bpp < FB_UNIT)
|
||||
{
|
||||
b |= b << bpp;
|
||||
bpp <<= 1;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
#define O 0
|
||||
#define I FB_ALLONES
|
||||
|
||||
const FbMergeRopRec FbMergeRopBits[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. FB doesn't handle the case
|
||||
* where these differ
|
||||
*/
|
||||
#define BitsMask(x,w) ((FB_ALLONES << ((x) & FB_MASK)) & \
|
||||
(FB_ALLONES >> ((FB_UNIT - ((x) + (w))) & FB_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 FB_UNIT == 16
|
||||
#define fbStipple16Bits 0
|
||||
#define fbStipple8Bits 0
|
||||
static const pixman_bits_t fbStipple4Bits[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 pixman_bits_t fbStipple2Bits[4] = {
|
||||
C2( 0,8), C2( 1,8), C2( 2,8), C2( 3,8),
|
||||
};
|
||||
static const pixman_bits_t fbStipple1Bits[2] = {
|
||||
C1( 0,16), C1( 1,16),
|
||||
};
|
||||
#endif
|
||||
#if FB_UNIT == 32
|
||||
#define fbStipple16Bits 0
|
||||
static const pixman_bits_t fbStipple8Bits[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 pixman_bits_t fbStipple4Bits[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 pixman_bits_t fbStipple2Bits[4] = {
|
||||
C2( 0,16), C2( 1,16), C2( 2,16), C2( 3,16),
|
||||
};
|
||||
static const pixman_bits_t fbStipple1Bits[2] = {
|
||||
C1( 0,32), C1( 1,32),
|
||||
};
|
||||
#endif
|
||||
#if FB_UNIT == 64
|
||||
const pixman_bits_t fbStipple16Bits[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 pixman_bits_t fbStipple8Bits[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 pixman_bits_t fbStipple4Bits[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 pixman_bits_t fbStipple2Bits[4] = {
|
||||
C2( 0,32), C2( 1,32), C2( 2,32), C2( 3,32),
|
||||
};
|
||||
#define fbStipple1Bits 0
|
||||
#endif
|
||||
|
||||
const pixman_bits_t *
|
||||
fbStippleTable(int bits)
|
||||
{
|
||||
switch (bits) {
|
||||
case 1:
|
||||
return fbStipple1Bits;
|
||||
case 2:
|
||||
return fbStipple2Bits;
|
||||
case 4:
|
||||
return fbStipple4Bits;
|
||||
case 8:
|
||||
return fbStipple8Bits;
|
||||
}
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
#define PIXMAN_FB_ACCESSORS
|
||||
|
||||
#include "pixman-compose.c"
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
#undef PIXMAN_FB_ACCESSORS
|
||||
|
||||
#include "pixman-compose.c"
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,206 @@
|
|||
/*
|
||||
*
|
||||
* Copyright © 1999 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 <config.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "pixman-private.h"
|
||||
|
||||
#define BOUND(v) (int16_t) ((v) < INT16_MIN ? INT16_MIN : (v) > INT16_MAX ? INT16_MAX : (v))
|
||||
|
||||
static inline pixman_bool_t
|
||||
miClipPictureReg (pixman_region16_t * pRegion,
|
||||
pixman_region16_t * pClip,
|
||||
int dx,
|
||||
int dy)
|
||||
{
|
||||
if (pixman_region_n_rects(pRegion) == 1 &&
|
||||
pixman_region_n_rects(pClip) == 1)
|
||||
{
|
||||
pixman_box16_t * pRbox = pixman_region_rectangles(pRegion, NULL);
|
||||
pixman_box16_t * pCbox = pixman_region_rectangles(pClip, NULL);
|
||||
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)
|
||||
{
|
||||
pixman_region_init (pRegion);
|
||||
}
|
||||
}
|
||||
else if (!pixman_region_not_empty (pClip))
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
if (dx || dy)
|
||||
pixman_region_translate (pRegion, -dx, -dy);
|
||||
if (!pixman_region_intersect (pRegion, pRegion, pClip))
|
||||
return FALSE;
|
||||
if (dx || dy)
|
||||
pixman_region_translate(pRegion, dx, dy);
|
||||
}
|
||||
return pixman_region_not_empty(pRegion);
|
||||
}
|
||||
|
||||
|
||||
static inline pixman_bool_t
|
||||
miClipPictureSrc (pixman_region16_t * pRegion,
|
||||
pixman_image_t * pPicture,
|
||||
int dx,
|
||||
int dy)
|
||||
{
|
||||
/* XXX what to do with clipping from transformed pictures? */
|
||||
if (pPicture->common.transform || pPicture->type != BITS)
|
||||
return TRUE;
|
||||
|
||||
if (pPicture->common.repeat)
|
||||
{
|
||||
/* If the clip region was set by a client, then it should be intersected
|
||||
* with the composite region since it's interpreted as happening
|
||||
* after the repeat algorithm.
|
||||
*
|
||||
* If the clip region was not set by a client, then it was imposed by
|
||||
* boundaries of the pixmap, or by sibling or child windows, which means
|
||||
* it should in theory be repeated along. FIXME: we ignore that case.
|
||||
* It is only relevant for windows that are (a) clipped by siblings/children
|
||||
* and (b) used as source. However this case is not useful anyway due
|
||||
* to lack of GraphicsExpose events.
|
||||
*/
|
||||
if (pPicture->common.has_client_clip)
|
||||
{
|
||||
pixman_region_translate ( pRegion, dx, dy);
|
||||
|
||||
if (!pixman_region_intersect (pRegion, pRegion,
|
||||
(pixman_region16_t *) pPicture->common.src_clip))
|
||||
return FALSE;
|
||||
|
||||
pixman_region_translate ( pRegion, -dx, -dy);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return miClipPictureReg (pRegion,
|
||||
pPicture->common.src_clip,
|
||||
dx,
|
||||
dy);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* returns FALSE if the final region is empty. Indistinguishable from
|
||||
* an allocation failure, but rendering ignores those anyways.
|
||||
*/
|
||||
|
||||
pixman_bool_t
|
||||
pixman_compute_composite_region (pixman_region16_t * pRegion,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
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;
|
||||
|
||||
pRegion->extents.x1 = xDst;
|
||||
v = xDst + width;
|
||||
pRegion->extents.x2 = BOUND(v);
|
||||
pRegion->extents.y1 = yDst;
|
||||
v = yDst + height;
|
||||
pRegion->extents.y2 = BOUND(v);
|
||||
pRegion->data = 0;
|
||||
/* Check for empty operation */
|
||||
if (pRegion->extents.x1 >= pRegion->extents.x2 ||
|
||||
pRegion->extents.y1 >= pRegion->extents.y2)
|
||||
{
|
||||
pixman_region_init (pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
/* clip against dst */
|
||||
if (!miClipPictureReg (pRegion, &pDst->common.clip_region, 0, 0))
|
||||
{
|
||||
pixman_region_fini (pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
if (pDst->common.alpha_map)
|
||||
{
|
||||
if (!miClipPictureReg (pRegion, &pDst->common.alpha_map->common.clip_region,
|
||||
-pDst->common.alpha_origin.x,
|
||||
-pDst->common.alpha_origin.y))
|
||||
{
|
||||
pixman_region_fini (pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
/* clip against src */
|
||||
if (!miClipPictureSrc (pRegion, pSrc, xDst - xSrc, yDst - ySrc))
|
||||
{
|
||||
pixman_region_fini (pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
if (pSrc->common.alpha_map)
|
||||
{
|
||||
if (!miClipPictureSrc (pRegion, (pixman_image_t *)pSrc->common.alpha_map,
|
||||
xDst - (xSrc + pSrc->common.alpha_origin.x),
|
||||
yDst - (ySrc + pSrc->common.alpha_origin.y)))
|
||||
{
|
||||
pixman_region_fini (pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
/* clip against mask */
|
||||
if (pMask)
|
||||
{
|
||||
if (!miClipPictureSrc (pRegion, pMask, xDst - xMask, yDst - yMask))
|
||||
{
|
||||
pixman_region_fini (pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
if (pMask->common.alpha_map)
|
||||
{
|
||||
if (!miClipPictureSrc (pRegion, (pixman_image_t *)pMask->common.alpha_map,
|
||||
xDst - (xMask + pMask->common.alpha_origin.x),
|
||||
yDst - (yMask + pMask->common.alpha_origin.y)))
|
||||
{
|
||||
pixman_region_fini (pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
#define PIXMAN_FB_ACCESSORS
|
||||
|
||||
#include "pixman-edge.c"
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* $Id: pixman-edge-imp.h,v 1.3 2007/08/02 06:54:41 vladimir%pobox.com Exp $
|
||||
*
|
||||
* Copyright © 2004 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
|
@ -24,68 +26,75 @@
|
|||
#endif
|
||||
|
||||
static void
|
||||
rasterizeEdges (FbBits *buf,
|
||||
int width,
|
||||
int stride,
|
||||
RenderEdge *l,
|
||||
RenderEdge *r,
|
||||
xFixed t,
|
||||
xFixed b)
|
||||
rasterizeEdges (pixman_image_t *image,
|
||||
pixman_edge_t *l,
|
||||
pixman_edge_t *r,
|
||||
pixman_fixed_t t,
|
||||
pixman_fixed_t b)
|
||||
{
|
||||
xFixed y = t;
|
||||
FbBits *line;
|
||||
|
||||
line = buf + xFixedToInt (y) * stride;
|
||||
|
||||
pixman_fixed_t y = t;
|
||||
uint32_t *line;
|
||||
uint32_t *buf = (image)->bits.bits;
|
||||
uint32_t stride = (image)->bits.rowstride;
|
||||
uint32_t width = (image)->bits.width;
|
||||
|
||||
line = buf + pixman_fixed_to_int (y) * stride;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
xFixed lx, rx;
|
||||
int lxi, rxi;
|
||||
|
||||
pixman_fixed_t lx;
|
||||
pixman_fixed_t rx;
|
||||
int lxi;
|
||||
int rxi;
|
||||
|
||||
/* clip X */
|
||||
lx = l->x;
|
||||
if (lx < 0)
|
||||
lx = 0;
|
||||
rx = r->x;
|
||||
if (xFixedToInt (rx) >= width)
|
||||
rx = IntToxFixed (width);
|
||||
|
||||
if (pixman_fixed_to_int (rx) >= width)
|
||||
rx = pixman_int_to_fixed (width);
|
||||
|
||||
/* Skip empty (or backwards) sections */
|
||||
if (rx > lx)
|
||||
{
|
||||
|
||||
/* Find pixel bounds for span. */
|
||||
lxi = xFixedToInt (lx);
|
||||
rxi = xFixedToInt (rx);
|
||||
|
||||
|
||||
/* Find pixel bounds for span */
|
||||
lxi = pixman_fixed_to_int (lx);
|
||||
rxi = pixman_fixed_to_int (rx);
|
||||
|
||||
#if N_BITS == 1
|
||||
{
|
||||
FbBits *a = line;
|
||||
FbBits startmask, endmask;
|
||||
uint32_t *a = line;
|
||||
uint32_t startmask;
|
||||
uint32_t endmask;
|
||||
int nmiddle;
|
||||
int width = rxi - lxi;
|
||||
int x = lxi;
|
||||
|
||||
|
||||
a += x >> FB_SHIFT;
|
||||
x &= FB_MASK;
|
||||
|
||||
|
||||
FbMaskBits (x, width, startmask, nmiddle, endmask);
|
||||
if (startmask)
|
||||
*a++ |= startmask;
|
||||
while (nmiddle--)
|
||||
*a++ = FB_ALLONES;
|
||||
if (endmask)
|
||||
*a |= endmask;
|
||||
if (startmask) {
|
||||
WRITE(a, READ(a) | startmask);
|
||||
a++;
|
||||
}
|
||||
while (nmiddle--)
|
||||
WRITE(a++, FB_ALLONES);
|
||||
if (endmask)
|
||||
WRITE(a, READ(a) | endmask);
|
||||
}
|
||||
#else
|
||||
{
|
||||
DefineAlpha(line,lxi);
|
||||
int lxs, rxs;
|
||||
|
||||
int lxs;
|
||||
int rxs;
|
||||
|
||||
/* Sample coverage for edge pixels */
|
||||
lxs = RenderSamplesX (lx, N_BITS);
|
||||
rxs = RenderSamplesX (rx, N_BITS);
|
||||
|
||||
|
||||
/* Add coverage across row */
|
||||
if (lxi == rxi)
|
||||
{
|
||||
|
@ -94,7 +103,7 @@ rasterizeEdges (FbBits *buf,
|
|||
else
|
||||
{
|
||||
int xi;
|
||||
|
||||
|
||||
AddAlpha (N_X_FRAC(N_BITS) - lxs);
|
||||
StepAlpha;
|
||||
for (xi = lxi + 1; xi < rxi; xi++)
|
||||
|
@ -102,21 +111,22 @@ rasterizeEdges (FbBits *buf,
|
|||
AddAlpha (N_X_FRAC(N_BITS));
|
||||
StepAlpha;
|
||||
}
|
||||
/* Do not add in a 0 alpha here. This check is
|
||||
* necessary to avoid a buffer overrun, (when rx
|
||||
* is exactly on a pixel boundary). */
|
||||
if (rxs)
|
||||
/* Do not add in a 0 alpha here. This check is necessary
|
||||
* to avoid a buffer overrun when rx is exactly on a pixel
|
||||
* boundary.
|
||||
*/
|
||||
if (rxs != 0)
|
||||
AddAlpha (rxs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if (y == b)
|
||||
break;
|
||||
|
||||
|
||||
#if N_BITS > 1
|
||||
if (xFixedFrac (y) != Y_FRAC_LAST(N_BITS))
|
||||
if (pixman_fixed_frac (y) != Y_FRAC_LAST(N_BITS))
|
||||
{
|
||||
RenderEdgeStepSmall (l);
|
||||
RenderEdgeStepSmall (r);
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
#undef PIXMAN_FB_ACCESSORS
|
||||
|
||||
#include "pixman-edge.c"
|
|
@ -0,0 +1,329 @@
|
|||
/*
|
||||
* $Id: pixman-edge.c,v 1.4 2007/08/02 06:54:41 vladimir%pobox.com Exp $
|
||||
*
|
||||
* Copyright © 2004 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 <config.h>
|
||||
#include <string.h>
|
||||
#include "pixman.h"
|
||||
#include "pixman-private.h"
|
||||
|
||||
#ifdef PIXMAN_FB_ACCESSORS
|
||||
#define PIXMAN_RASTERIZE_EDGES pixman_rasterize_edges_accessors
|
||||
#else
|
||||
#define PIXMAN_RASTERIZE_EDGES pixman_rasterize_edges_no_accessors
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 4 bit alpha
|
||||
*/
|
||||
|
||||
#define N_BITS 4
|
||||
#define rasterizeEdges fbRasterizeEdges4
|
||||
|
||||
#if BITMAP_BIT_ORDER == LSBFirst
|
||||
#define Shift4(o) ((o) << 2)
|
||||
#else
|
||||
#define Shift4(o) ((1-(o)) << 2)
|
||||
#endif
|
||||
|
||||
#define Get4(x,o) (((x) >> Shift4(o)) & 0xf)
|
||||
#define Put4(x,o,v) (((x) & ~(0xf << Shift4(o))) | (((v) & 0xf) << Shift4(o)))
|
||||
|
||||
#define DefineAlpha(line,x) \
|
||||
uint8_t *__ap = (uint8_t *) line + ((x) >> 1); \
|
||||
int __ao = (x) & 1
|
||||
|
||||
#define StepAlpha ((__ap += __ao), (__ao ^= 1))
|
||||
|
||||
#define AddAlpha(a) { \
|
||||
uint8_t __o = READ(__ap); \
|
||||
uint8_t __a = (a) + Get4(__o, __ao); \
|
||||
WRITE(__ap, Put4 (__o, __ao, __a | (0 - ((__a) >> 4)))); \
|
||||
}
|
||||
|
||||
#include "pixman-edge-imp.h"
|
||||
|
||||
#undef AddAlpha
|
||||
#undef StepAlpha
|
||||
#undef DefineAlpha
|
||||
#undef rasterizeEdges
|
||||
#undef N_BITS
|
||||
|
||||
|
||||
/*
|
||||
* 1 bit alpha
|
||||
*/
|
||||
|
||||
#define N_BITS 1
|
||||
#define rasterizeEdges fbRasterizeEdges1
|
||||
|
||||
#include "pixman-edge-imp.h"
|
||||
|
||||
#undef rasterizeEdges
|
||||
#undef N_BITS
|
||||
|
||||
/*
|
||||
* 8 bit alpha
|
||||
*/
|
||||
|
||||
static inline uint8_t
|
||||
clip255 (int x)
|
||||
{
|
||||
if (x > 255) return 255;
|
||||
return x;
|
||||
}
|
||||
|
||||
#define add_saturate_8(buf,val,length) \
|
||||
do { \
|
||||
int i__ = (length); \
|
||||
uint8_t *buf__ = (buf); \
|
||||
int val__ = (val); \
|
||||
\
|
||||
while (i__--) \
|
||||
{ \
|
||||
WRITE((buf__), clip255 (READ((buf__)) + (val__))); \
|
||||
(buf__)++; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* We want to detect the case where we add the same value to a long
|
||||
* span of pixels. The triangles on the end are filled in while we
|
||||
* count how many sub-pixel scanlines contribute to the middle section.
|
||||
*
|
||||
* +--------------------------+
|
||||
* fill_height =| \ /
|
||||
* +------------------+
|
||||
* |================|
|
||||
* fill_start fill_end
|
||||
*/
|
||||
static void
|
||||
fbRasterizeEdges8 (pixman_image_t *image,
|
||||
pixman_edge_t *l,
|
||||
pixman_edge_t *r,
|
||||
pixman_fixed_t t,
|
||||
pixman_fixed_t b)
|
||||
{
|
||||
pixman_fixed_t y = t;
|
||||
uint32_t *line;
|
||||
int fill_start = -1, fill_end = -1;
|
||||
int fill_size = 0;
|
||||
uint32_t *buf = (image)->bits.bits;
|
||||
int32_t stride = (image)->bits.rowstride;
|
||||
uint32_t width = (image)->bits.width;
|
||||
|
||||
line = buf + pixman_fixed_to_int (y) * stride;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
uint8_t *ap = (uint8_t *) line;
|
||||
pixman_fixed_t lx, rx;
|
||||
int lxi, rxi;
|
||||
|
||||
/* clip X */
|
||||
lx = l->x;
|
||||
if (lx < 0)
|
||||
lx = 0;
|
||||
rx = r->x;
|
||||
if (pixman_fixed_to_int (rx) >= width)
|
||||
rx = pixman_int_to_fixed (width);
|
||||
|
||||
/* Skip empty (or backwards) sections */
|
||||
if (rx > lx)
|
||||
{
|
||||
int lxs, rxs;
|
||||
|
||||
/* Find pixel bounds for span. */
|
||||
lxi = pixman_fixed_to_int (lx);
|
||||
rxi = pixman_fixed_to_int (rx);
|
||||
|
||||
/* Sample coverage for edge pixels */
|
||||
lxs = RenderSamplesX (lx, 8);
|
||||
rxs = RenderSamplesX (rx, 8);
|
||||
|
||||
/* Add coverage across row */
|
||||
if (lxi == rxi)
|
||||
{
|
||||
WRITE(ap +lxi, clip255 (READ(ap + lxi) + rxs - lxs));
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE(ap + lxi, clip255 (READ(ap + lxi) + N_X_FRAC(8) - lxs));
|
||||
|
||||
/* Move forward so that lxi/rxi is the pixel span */
|
||||
lxi++;
|
||||
|
||||
/* Don't bother trying to optimize the fill unless
|
||||
* the span is longer than 4 pixels. */
|
||||
if (rxi - lxi > 4)
|
||||
{
|
||||
if (fill_start < 0)
|
||||
{
|
||||
fill_start = lxi;
|
||||
fill_end = rxi;
|
||||
fill_size++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lxi >= fill_end || rxi < fill_start)
|
||||
{
|
||||
/* We're beyond what we saved, just fill it */
|
||||
add_saturate_8 (ap + fill_start,
|
||||
fill_size * N_X_FRAC(8),
|
||||
fill_end - fill_start);
|
||||
fill_start = lxi;
|
||||
fill_end = rxi;
|
||||
fill_size = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Update fill_start */
|
||||
if (lxi > fill_start)
|
||||
{
|
||||
add_saturate_8 (ap + fill_start,
|
||||
fill_size * N_X_FRAC(8),
|
||||
lxi - fill_start);
|
||||
fill_start = lxi;
|
||||
}
|
||||
else if (lxi < fill_start)
|
||||
{
|
||||
add_saturate_8 (ap + lxi, N_X_FRAC(8),
|
||||
fill_start - lxi);
|
||||
}
|
||||
|
||||
/* Update fill_end */
|
||||
if (rxi < fill_end)
|
||||
{
|
||||
add_saturate_8 (ap + rxi,
|
||||
fill_size * N_X_FRAC(8),
|
||||
fill_end - rxi);
|
||||
fill_end = rxi;
|
||||
}
|
||||
else if (fill_end < rxi)
|
||||
{
|
||||
add_saturate_8 (ap + fill_end,
|
||||
N_X_FRAC(8),
|
||||
rxi - fill_end);
|
||||
}
|
||||
fill_size++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
add_saturate_8 (ap + lxi, N_X_FRAC(8), rxi - lxi);
|
||||
}
|
||||
|
||||
/* Do not add in a 0 alpha here. This check is
|
||||
* necessary to avoid a buffer overrun, (when rx
|
||||
* is exactly on a pixel boundary). */
|
||||
if (rxs)
|
||||
WRITE(ap + rxi, clip255 (READ(ap + rxi) + rxs));
|
||||
}
|
||||
}
|
||||
|
||||
if (y == b) {
|
||||
/* We're done, make sure we clean up any remaining fill. */
|
||||
if (fill_start != fill_end) {
|
||||
if (fill_size == N_Y_FRAC(8))
|
||||
{
|
||||
MEMSET_WRAPPED (ap + fill_start, 0xff, fill_end - fill_start);
|
||||
}
|
||||
else
|
||||
{
|
||||
add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8),
|
||||
fill_end - fill_start);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (pixman_fixed_frac (y) != Y_FRAC_LAST(8))
|
||||
{
|
||||
RenderEdgeStepSmall (l);
|
||||
RenderEdgeStepSmall (r);
|
||||
y += STEP_Y_SMALL(8);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderEdgeStepBig (l);
|
||||
RenderEdgeStepBig (r);
|
||||
y += STEP_Y_BIG(8);
|
||||
if (fill_start != fill_end)
|
||||
{
|
||||
if (fill_size == N_Y_FRAC(8))
|
||||
{
|
||||
MEMSET_WRAPPED (ap + fill_start, 0xff, fill_end - fill_start);
|
||||
}
|
||||
else
|
||||
{
|
||||
add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8),
|
||||
fill_end - fill_start);
|
||||
}
|
||||
fill_start = fill_end = -1;
|
||||
fill_size = 0;
|
||||
}
|
||||
line += stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef PIXMAN_FB_ACCESSORS
|
||||
static
|
||||
#endif
|
||||
void
|
||||
PIXMAN_RASTERIZE_EDGES (pixman_image_t *image,
|
||||
pixman_edge_t *l,
|
||||
pixman_edge_t *r,
|
||||
pixman_fixed_t t,
|
||||
pixman_fixed_t b)
|
||||
{
|
||||
switch (PIXMAN_FORMAT_BPP (image->bits.format))
|
||||
{
|
||||
case 1:
|
||||
fbRasterizeEdges1 (image, l, r, t, b);
|
||||
break;
|
||||
case 4:
|
||||
fbRasterizeEdges4 (image, l, r, t, b);
|
||||
break;
|
||||
case 8:
|
||||
fbRasterizeEdges8 (image, l, r, t, b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef PIXMAN_FB_ACCESSORS
|
||||
|
||||
void
|
||||
pixman_rasterize_edges (pixman_image_t *image,
|
||||
pixman_edge_t *l,
|
||||
pixman_edge_t *r,
|
||||
pixman_fixed_t t,
|
||||
pixman_fixed_t b)
|
||||
{
|
||||
if (image->common.read_func || image->common.write_func)
|
||||
pixman_rasterize_edges_accessors (image, l, r, t, b);
|
||||
else
|
||||
pixman_rasterize_edges_no_accessors (image, l, r, t, b);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,683 @@
|
|||
/*
|
||||
* Copyright © 2000 SuSE, Inc.
|
||||
* Copyright © 2007 Red Hat, 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.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pixman.h"
|
||||
#include "pixman-private.h"
|
||||
|
||||
static void
|
||||
init_source_image (source_image_t *image)
|
||||
{
|
||||
image->class = SOURCE_IMAGE_CLASS_UNKNOWN;
|
||||
}
|
||||
|
||||
static pixman_bool_t
|
||||
init_gradient (gradient_t *gradient,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops)
|
||||
{
|
||||
return_val_if_fail (n_stops > 0, FALSE);
|
||||
|
||||
init_source_image (&gradient->common);
|
||||
|
||||
gradient->stops = pixman_malloc_ab (n_stops, sizeof (pixman_gradient_stop_t));
|
||||
if (!gradient->stops)
|
||||
return FALSE;
|
||||
|
||||
memcpy (gradient->stops, stops, n_stops * sizeof (pixman_gradient_stop_t));
|
||||
|
||||
gradient->n_stops = n_stops;
|
||||
|
||||
gradient->stop_range = 0xffff;
|
||||
gradient->color_table = NULL;
|
||||
gradient->color_table_size = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
color_to_uint32 (const pixman_color_t *color)
|
||||
{
|
||||
return
|
||||
(color->alpha >> 8 << 24) |
|
||||
(color->red >> 8 << 16) |
|
||||
(color->green & 0xff00) |
|
||||
(color->blue >> 8);
|
||||
}
|
||||
|
||||
static pixman_image_t *
|
||||
allocate_image (void)
|
||||
{
|
||||
pixman_image_t *image = malloc (sizeof (pixman_image_t));
|
||||
|
||||
if (image)
|
||||
{
|
||||
image_common_t *common = &image->common;
|
||||
|
||||
pixman_region_init (&common->full_region);
|
||||
pixman_region_init (&common->clip_region);
|
||||
common->src_clip = &common->full_region;
|
||||
common->has_client_clip = FALSE;
|
||||
common->transform = NULL;
|
||||
common->repeat = PIXMAN_REPEAT_NONE;
|
||||
common->filter = PIXMAN_FILTER_NEAREST;
|
||||
common->filter_params = NULL;
|
||||
common->n_filter_params = 0;
|
||||
common->alpha_map = NULL;
|
||||
common->component_alpha = FALSE;
|
||||
common->ref_count = 1;
|
||||
common->read_func = NULL;
|
||||
common->write_func = NULL;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
/* Ref Counting */
|
||||
pixman_image_t *
|
||||
pixman_image_ref (pixman_image_t *image)
|
||||
{
|
||||
image->common.ref_count++;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
void
|
||||
pixman_image_unref (pixman_image_t *image)
|
||||
{
|
||||
image_common_t *common = (image_common_t *)image;
|
||||
|
||||
common->ref_count--;
|
||||
|
||||
if (common->ref_count == 0)
|
||||
{
|
||||
pixman_region_fini (&common->clip_region);
|
||||
pixman_region_fini (&common->full_region);
|
||||
|
||||
if (common->transform)
|
||||
free (common->transform);
|
||||
|
||||
if (common->filter_params)
|
||||
free (common->filter_params);
|
||||
|
||||
if (common->alpha_map)
|
||||
pixman_image_unref ((pixman_image_t *)common->alpha_map);
|
||||
|
||||
#if 0
|
||||
if (image->type == BITS && image->bits.indexed)
|
||||
free (image->bits.indexed);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
memset (image, 0xaa, sizeof (pixman_image_t));
|
||||
#endif
|
||||
if (image->type == LINEAR || image->type == RADIAL || image->type == CONICAL)
|
||||
{
|
||||
if (image->gradient.stops)
|
||||
free (image->gradient.stops);
|
||||
}
|
||||
|
||||
|
||||
if (image->type == BITS && image->bits.free_me)
|
||||
free (image->bits.free_me);
|
||||
|
||||
free (image);
|
||||
}
|
||||
}
|
||||
|
||||
/* Constructors */
|
||||
pixman_image_t *
|
||||
pixman_image_create_solid_fill (pixman_color_t *color)
|
||||
{
|
||||
pixman_image_t *img = allocate_image();
|
||||
if (!img)
|
||||
return NULL;
|
||||
|
||||
init_source_image (&img->solid.common);
|
||||
|
||||
img->type = SOLID;
|
||||
img->solid.color = color_to_uint32 (color);
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
pixman_image_t *
|
||||
pixman_image_create_linear_gradient (pixman_point_fixed_t *p1,
|
||||
pixman_point_fixed_t *p2,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops)
|
||||
{
|
||||
pixman_image_t *image;
|
||||
linear_gradient_t *linear;
|
||||
|
||||
return_val_if_fail (n_stops >= 2, NULL);
|
||||
|
||||
image = allocate_image();
|
||||
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
linear = &image->linear;
|
||||
|
||||
if (!init_gradient (&linear->common, stops, n_stops))
|
||||
{
|
||||
free (image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
linear->p1 = *p1;
|
||||
linear->p2 = *p2;
|
||||
|
||||
image->type = LINEAR;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
pixman_image_t *
|
||||
pixman_image_create_radial_gradient (pixman_point_fixed_t *inner,
|
||||
pixman_point_fixed_t *outer,
|
||||
pixman_fixed_t inner_radius,
|
||||
pixman_fixed_t outer_radius,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops)
|
||||
{
|
||||
pixman_image_t *image;
|
||||
radial_gradient_t *radial;
|
||||
|
||||
return_val_if_fail (n_stops >= 2, NULL);
|
||||
|
||||
image = allocate_image();
|
||||
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
radial = &image->radial;
|
||||
|
||||
if (!init_gradient (&radial->common, stops, n_stops))
|
||||
{
|
||||
free (image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image->type = RADIAL;
|
||||
|
||||
radial->c1.x = inner->x;
|
||||
radial->c1.y = inner->y;
|
||||
radial->c1.radius = inner_radius;
|
||||
radial->c2.x = outer->x;
|
||||
radial->c2.y = outer->y;
|
||||
radial->c2.radius = outer_radius;
|
||||
radial->cdx = pixman_fixed_to_double (radial->c2.x - radial->c1.x);
|
||||
radial->cdy = pixman_fixed_to_double (radial->c2.y - radial->c1.y);
|
||||
radial->dr = pixman_fixed_to_double (radial->c2.radius - radial->c1.radius);
|
||||
radial->A = (radial->cdx * radial->cdx
|
||||
+ radial->cdy * radial->cdy
|
||||
- radial->dr * radial->dr);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
pixman_image_t *
|
||||
pixman_image_create_conical_gradient (pixman_point_fixed_t *center,
|
||||
pixman_fixed_t angle,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops)
|
||||
{
|
||||
pixman_image_t *image = allocate_image();
|
||||
conical_gradient_t *conical;
|
||||
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
conical = &image->conical;
|
||||
|
||||
if (!init_gradient (&conical->common, stops, n_stops))
|
||||
{
|
||||
free (image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image->type = CONICAL;
|
||||
conical->center = *center;
|
||||
conical->angle = angle;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static uint32_t *
|
||||
create_bits (pixman_format_code_t format,
|
||||
int width,
|
||||
int height,
|
||||
int *rowstride_bytes)
|
||||
{
|
||||
int stride;
|
||||
int buf_size;
|
||||
int bpp;
|
||||
|
||||
bpp = PIXMAN_FORMAT_BPP (format);
|
||||
stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (uint32_t);
|
||||
buf_size = height * stride;
|
||||
|
||||
if (rowstride_bytes)
|
||||
*rowstride_bytes = stride;
|
||||
|
||||
return calloc (buf_size, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
reset_clip_region (pixman_image_t *image)
|
||||
{
|
||||
pixman_region_fini (&image->common.clip_region);
|
||||
|
||||
if (image->type == BITS)
|
||||
{
|
||||
pixman_region_init_rect (&image->common.clip_region, 0, 0,
|
||||
image->bits.width, image->bits.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
pixman_region_init (&image->common.clip_region);
|
||||
}
|
||||
}
|
||||
|
||||
pixman_image_t *
|
||||
pixman_image_create_bits (pixman_format_code_t format,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t *bits,
|
||||
int rowstride_bytes)
|
||||
{
|
||||
pixman_image_t *image;
|
||||
uint32_t *free_me = NULL;
|
||||
|
||||
/* must be a whole number of uint32_t's
|
||||
*/
|
||||
return_val_if_fail (bits == NULL ||
|
||||
(rowstride_bytes % sizeof (uint32_t)) == 0, NULL);
|
||||
|
||||
if (!bits)
|
||||
{
|
||||
free_me = bits = create_bits (format, width, height, &rowstride_bytes);
|
||||
if (!bits)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image = allocate_image();
|
||||
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
image->type = BITS;
|
||||
image->bits.format = format;
|
||||
image->bits.width = width;
|
||||
image->bits.height = height;
|
||||
image->bits.bits = bits;
|
||||
image->bits.free_me = free_me;
|
||||
|
||||
image->bits.rowstride = rowstride_bytes / sizeof (uint32_t); /* we store it in number
|
||||
* of uint32_t's
|
||||
*/
|
||||
image->bits.indexed = NULL;
|
||||
|
||||
pixman_region_fini (&image->common.full_region);
|
||||
pixman_region_init_rect (&image->common.full_region, 0, 0,
|
||||
image->bits.width, image->bits.height);
|
||||
|
||||
reset_clip_region (image);
|
||||
return image;
|
||||
}
|
||||
|
||||
pixman_bool_t
|
||||
pixman_image_set_clip_region (pixman_image_t *image,
|
||||
pixman_region16_t *region)
|
||||
{
|
||||
image_common_t *common = (image_common_t *)image;
|
||||
|
||||
if (region)
|
||||
{
|
||||
return pixman_region_copy (&common->clip_region, region);
|
||||
}
|
||||
else
|
||||
{
|
||||
reset_clip_region (image);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Sets whether the clip region includes a clip region set by the client
|
||||
*/
|
||||
void
|
||||
pixman_image_set_has_client_clip (pixman_image_t *image,
|
||||
pixman_bool_t client_clip)
|
||||
{
|
||||
image->common.has_client_clip = client_clip;
|
||||
}
|
||||
|
||||
pixman_bool_t
|
||||
pixman_image_set_transform (pixman_image_t *image,
|
||||
const pixman_transform_t *transform)
|
||||
{
|
||||
static const pixman_transform_t id =
|
||||
{
|
||||
{ { pixman_fixed_1, 0, 0 },
|
||||
{ 0, pixman_fixed_1, 0 },
|
||||
{ 0, 0, pixman_fixed_1 }
|
||||
}
|
||||
};
|
||||
|
||||
image_common_t *common = (image_common_t *)image;
|
||||
|
||||
if (common->transform == transform)
|
||||
return TRUE;
|
||||
|
||||
if (memcmp (&id, transform, sizeof (pixman_transform_t)) == 0)
|
||||
{
|
||||
transform = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (common->transform)
|
||||
free (common->transform);
|
||||
|
||||
if (transform)
|
||||
{
|
||||
common->transform = malloc (sizeof (pixman_transform_t));
|
||||
if (!common->transform)
|
||||
return FALSE;
|
||||
|
||||
*common->transform = *transform;
|
||||
}
|
||||
else
|
||||
{
|
||||
common->transform = NULL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
pixman_image_set_repeat (pixman_image_t *image,
|
||||
pixman_repeat_t repeat)
|
||||
{
|
||||
image->common.repeat = repeat;
|
||||
}
|
||||
|
||||
pixman_bool_t
|
||||
pixman_image_set_filter (pixman_image_t *image,
|
||||
pixman_filter_t filter,
|
||||
const pixman_fixed_t *params,
|
||||
int n_params)
|
||||
{
|
||||
image_common_t *common = (image_common_t *)image;
|
||||
pixman_fixed_t *new_params;
|
||||
|
||||
if (params == common->filter_params && filter == common->filter)
|
||||
return TRUE;
|
||||
|
||||
new_params = NULL;
|
||||
if (params)
|
||||
{
|
||||
new_params = pixman_malloc_ab (n_params, sizeof (pixman_fixed_t));
|
||||
if (!new_params)
|
||||
return FALSE;
|
||||
|
||||
memcpy (new_params,
|
||||
params, n_params * sizeof (pixman_fixed_t));
|
||||
}
|
||||
|
||||
common->filter = filter;
|
||||
|
||||
if (common->filter_params)
|
||||
free (common->filter_params);
|
||||
|
||||
common->filter_params = new_params;
|
||||
common->n_filter_params = n_params;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Unlike all the other property setters, this function does not
|
||||
* copy the content of indexed. Doing this copying is simply
|
||||
* way, way too expensive.
|
||||
*/
|
||||
void
|
||||
pixman_image_set_indexed (pixman_image_t *image,
|
||||
const pixman_indexed_t *indexed)
|
||||
{
|
||||
bits_image_t *bits = (bits_image_t *)image;
|
||||
|
||||
bits->indexed = indexed;
|
||||
}
|
||||
|
||||
void
|
||||
pixman_image_set_alpha_map (pixman_image_t *image,
|
||||
pixman_image_t *alpha_map,
|
||||
int16_t x,
|
||||
int16_t y)
|
||||
{
|
||||
image_common_t *common = (image_common_t *)image;
|
||||
|
||||
return_if_fail (!alpha_map || alpha_map->type == BITS);
|
||||
|
||||
if (common->alpha_map != (bits_image_t *)alpha_map)
|
||||
{
|
||||
if (common->alpha_map)
|
||||
pixman_image_unref ((pixman_image_t *)common->alpha_map);
|
||||
|
||||
if (alpha_map)
|
||||
common->alpha_map = (bits_image_t *)pixman_image_ref (alpha_map);
|
||||
else
|
||||
common->alpha_map = NULL;
|
||||
}
|
||||
|
||||
common->alpha_origin.x = x;
|
||||
common->alpha_origin.y = y;
|
||||
}
|
||||
|
||||
void
|
||||
pixman_image_set_component_alpha (pixman_image_t *image,
|
||||
pixman_bool_t component_alpha)
|
||||
{
|
||||
image->common.component_alpha = component_alpha;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pixman_image_set_accessors (pixman_image_t *image,
|
||||
pixman_read_memory_func_t read_func,
|
||||
pixman_write_memory_func_t write_func)
|
||||
{
|
||||
return_if_fail (image != NULL);
|
||||
|
||||
image->common.read_func = read_func;
|
||||
image->common.write_func = write_func;
|
||||
}
|
||||
|
||||
uint32_t *
|
||||
pixman_image_get_data (pixman_image_t *image)
|
||||
{
|
||||
if (image->type == BITS)
|
||||
return image->bits.bits;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
pixman_image_get_width (pixman_image_t *image)
|
||||
{
|
||||
if (image->type == BITS)
|
||||
return image->bits.width;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
pixman_image_get_height (pixman_image_t *image)
|
||||
{
|
||||
if (image->type == BITS)
|
||||
return image->bits.height;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
pixman_image_get_stride (pixman_image_t *image)
|
||||
{
|
||||
if (image->type == BITS)
|
||||
return image->bits.rowstride * sizeof (uint32_t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
pixman_image_get_depth (pixman_image_t *image)
|
||||
{
|
||||
if (image->type == BITS)
|
||||
return PIXMAN_FORMAT_DEPTH (image->bits.format);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
pixman_bool_t
|
||||
color_to_pixel (pixman_color_t *color,
|
||||
uint32_t *pixel,
|
||||
pixman_format_code_t format)
|
||||
{
|
||||
uint32_t c = color_to_uint32 (color);
|
||||
|
||||
if (!(format == PIXMAN_a8r8g8b8 ||
|
||||
format == PIXMAN_x8r8g8b8 ||
|
||||
format == PIXMAN_a8b8g8r8 ||
|
||||
format == PIXMAN_x8b8g8r8 ||
|
||||
format == PIXMAN_r5g6b5 ||
|
||||
format == PIXMAN_b5g6r5 ||
|
||||
format == PIXMAN_a8))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_ABGR)
|
||||
{
|
||||
c = ((c & 0xff000000) >> 0) |
|
||||
((c & 0x00ff0000) >> 16) |
|
||||
((c & 0x0000ff00) >> 0) |
|
||||
((c & 0x000000ff) << 16);
|
||||
}
|
||||
|
||||
if (format == PIXMAN_a8)
|
||||
c = c >> 24;
|
||||
else if (format == PIXMAN_r5g6b5 ||
|
||||
format == PIXMAN_b5g6r5)
|
||||
c = cvt8888to0565 (c);
|
||||
|
||||
#if 0
|
||||
printf ("color: %x %x %x %x\n", color->alpha, color->red, color->green, color->blue);
|
||||
printf ("pixel: %x\n", c);
|
||||
#endif
|
||||
|
||||
*pixel = c;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
pixman_bool_t
|
||||
pixman_image_fill_rectangles (pixman_op_t op,
|
||||
pixman_image_t *dest,
|
||||
pixman_color_t *color,
|
||||
int n_rects,
|
||||
const pixman_rectangle16_t *rects)
|
||||
{
|
||||
pixman_image_t *solid;
|
||||
pixman_color_t c;
|
||||
int i;
|
||||
|
||||
if (color->alpha == 0xffff)
|
||||
{
|
||||
if (op == PIXMAN_OP_OVER)
|
||||
op = PIXMAN_OP_SRC;
|
||||
}
|
||||
|
||||
if (op == PIXMAN_OP_CLEAR)
|
||||
{
|
||||
c.red = 0;
|
||||
c.green = 0;
|
||||
c.blue = 0;
|
||||
c.alpha = 0;
|
||||
|
||||
color = &c;
|
||||
|
||||
op = PIXMAN_OP_SRC;
|
||||
}
|
||||
|
||||
if (op == PIXMAN_OP_SRC)
|
||||
{
|
||||
uint32_t pixel;
|
||||
|
||||
if (color_to_pixel (color, &pixel, dest->bits.format))
|
||||
{
|
||||
for (i = 0; i < n_rects; ++i)
|
||||
{
|
||||
pixman_region16_t fill_region;
|
||||
int n_boxes, j;
|
||||
pixman_box16_t *boxes;
|
||||
|
||||
pixman_region_init_rect (&fill_region, rects[i].x, rects[i].y, rects[i].width, rects[i].height);
|
||||
pixman_region_intersect (&fill_region, &fill_region, &dest->common.clip_region);
|
||||
|
||||
boxes = pixman_region_rectangles (&fill_region, &n_boxes);
|
||||
for (j = 0; j < n_boxes; ++j)
|
||||
{
|
||||
const pixman_box16_t *box = &(boxes[j]);
|
||||
pixman_fill (dest->bits.bits, dest->bits.rowstride, PIXMAN_FORMAT_BPP (dest->bits.format),
|
||||
box->x1, box->y1, box->x2 - box->x1, box->y2 - box->y1,
|
||||
pixel);
|
||||
}
|
||||
|
||||
pixman_region_fini (&fill_region);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
solid = pixman_image_create_solid_fill (color);
|
||||
if (!solid)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < n_rects; ++i)
|
||||
{
|
||||
const pixman_rectangle16_t *rect = &(rects[i]);
|
||||
|
||||
pixman_image_composite (op, solid, NULL, dest,
|
||||
0, 0, 0, 0,
|
||||
rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
}
|
||||
|
||||
pixman_image_unref (solid);
|
||||
|
||||
return TRUE;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,315 @@
|
|||
/*
|
||||
* Copyright © 2004 Red Hat, Inc.
|
||||
* Copyright © 2005 Trolltech AS
|
||||
*
|
||||
* 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 Red Hat not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Red Hat makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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: Søren Sandmann (sandmann@redhat.com)
|
||||
* Lars Knoll (lars@trolltech.com)
|
||||
*
|
||||
* Based on work by Owen Taylor
|
||||
*/
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include "pixman-private.h"
|
||||
|
||||
#ifdef USE_MMX
|
||||
|
||||
#if !defined(__amd64__) && !defined(__x86_64__)
|
||||
pixman_bool_t pixman_have_mmx(void);
|
||||
#else
|
||||
#define pixman_have_mmx() TRUE
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define pixman_have_mmx() FALSE
|
||||
#endif
|
||||
|
||||
#ifdef USE_MMX
|
||||
|
||||
pixman_bool_t
|
||||
pixman_blt_mmx (uint32_t *src_bits,
|
||||
uint32_t *dst_bits,
|
||||
int src_stride,
|
||||
int dst_stride,
|
||||
int src_bpp,
|
||||
int dst_bpp,
|
||||
int src_x, int src_y,
|
||||
int dst_x, int dst_y,
|
||||
int width, int height);
|
||||
pixman_bool_t
|
||||
pixman_fill_mmx (uint32_t *bits,
|
||||
int stride,
|
||||
int bpp,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t xor);
|
||||
|
||||
void fbComposeSetupMMX(void);
|
||||
|
||||
void fbCompositeSolidMask_nx8888x0565Cmmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSrcAdd_8888x8888mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSrc_8888x8888mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void
|
||||
fbCompositeSolidMaskSrc_nx8x8888mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void
|
||||
fbCompositeSrc_x888xnx8888mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSolidMask_nx8888x8888Cmmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSolidMask_nx8x8888mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeIn_nx8x8mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeIn_8x8mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSrcAdd_8888x8x8mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSrcAdd_8000x8000mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSrc_8888RevNPx8888mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSrc_8888x0565mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSrc_8888RevNPx0565mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSolid_nx8888mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSolid_nx0565mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSolidMask_nx8x0565mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeSrc_8888x8x8888mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void fbCompositeCopyAreammx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void
|
||||
fbCompositeOver_x888x8x8888mmx (pixman_op_t op,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
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 /* USE_MMX */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,821 @@
|
|||
#ifndef PACKAGE
|
||||
# error config.h must be included before pixman-private.h
|
||||
#endif
|
||||
|
||||
#ifndef PIXMAN_PRIVATE_H
|
||||
#define PIXMAN_PRIVATE_H
|
||||
|
||||
#include "pixman.h"
|
||||
#include <time.h>
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#define MSBFirst 0
|
||||
#define LSBFirst 1
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# define IMAGE_BYTE_ORDER MSBFirst
|
||||
# define BITMAP_BIT_ORDER MSBFirst
|
||||
#else
|
||||
# define IMAGE_BYTE_ORDER LSBFirst
|
||||
# define BITMAP_BIT_ORDER LSBFirst
|
||||
#endif
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# define FUNC ((const char*) (__PRETTY_FUNCTION__))
|
||||
#elif defined (__sun) || (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
|
||||
# define FUNC ((const char*) (__func__))
|
||||
#else
|
||||
# define FUNC ((const char*) ("???"))
|
||||
#endif
|
||||
|
||||
|
||||
#define FB_SHIFT 5
|
||||
#define FB_UNIT (1 << FB_SHIFT)
|
||||
#define FB_HALFUNIT (1 << (FB_SHIFT-1))
|
||||
#define FB_MASK (FB_UNIT - 1)
|
||||
#define FB_ALLONES ((uint32_t) -1)
|
||||
|
||||
/* Memory allocation helpers */
|
||||
void *pixman_malloc_ab (unsigned int n, unsigned int b);
|
||||
void *pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c);
|
||||
|
||||
#if DEBUG
|
||||
|
||||
#define return_if_fail(expr) \
|
||||
do \
|
||||
{ \
|
||||
if (!(expr)) \
|
||||
{ \
|
||||
fprintf(stderr, "In %s: %s failed\n", FUNC, #expr); \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define return_val_if_fail(expr, retval) \
|
||||
do \
|
||||
{ \
|
||||
if (!(expr)) \
|
||||
{ \
|
||||
fprintf(stderr, "In %s: %s failed\n", FUNC, #expr); \
|
||||
return (retval); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define return_if_fail(expr) \
|
||||
do \
|
||||
{ \
|
||||
if (!(expr)) \
|
||||
return; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define return_val_if_fail(expr, retval) \
|
||||
do \
|
||||
{ \
|
||||
if (!(expr)) \
|
||||
return (retval); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct image_common image_common_t;
|
||||
typedef struct source_image source_image_t;
|
||||
typedef struct solid_fill solid_fill_t;
|
||||
typedef struct gradient gradient_t;
|
||||
typedef struct linear_gradient linear_gradient_t;
|
||||
typedef struct horizontal_gradient horizontal_gradient_t;
|
||||
typedef struct vertical_gradient vertical_gradient_t;
|
||||
typedef struct conical_gradient conical_gradient_t;
|
||||
typedef struct radial_gradient radial_gradient_t;
|
||||
typedef struct bits_image bits_image_t;
|
||||
typedef struct circle circle_t;
|
||||
typedef struct point point_t;
|
||||
|
||||
/* FIXME - the types and structures below should be give proper names
|
||||
*/
|
||||
|
||||
#define FASTCALL
|
||||
typedef FASTCALL void (*CombineMaskU) (uint32_t *src, const uint32_t *mask, int width);
|
||||
typedef FASTCALL void (*CombineFuncU) (uint32_t *dest, const uint32_t *src, int width);
|
||||
typedef FASTCALL void (*CombineFuncC) (uint32_t *dest, uint32_t *src, uint32_t *mask, int width);
|
||||
|
||||
typedef struct _FbComposeData {
|
||||
uint8_t op;
|
||||
pixman_image_t *src;
|
||||
pixman_image_t *mask;
|
||||
pixman_image_t *dest;
|
||||
int16_t xSrc;
|
||||
int16_t ySrc;
|
||||
int16_t xMask;
|
||||
int16_t yMask;
|
||||
int16_t xDest;
|
||||
int16_t yDest;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
} FbComposeData;
|
||||
|
||||
typedef struct _FbComposeFunctions {
|
||||
CombineFuncU *combineU;
|
||||
CombineFuncC *combineC;
|
||||
CombineMaskU combineMaskU;
|
||||
} FbComposeFunctions;
|
||||
|
||||
extern FbComposeFunctions pixman_composeFunctions;
|
||||
|
||||
void pixman_composite_rect_general_accessors (const FbComposeData *data,
|
||||
uint32_t *scanline_buffer);
|
||||
void pixman_composite_rect_general (const FbComposeData *data,
|
||||
uint32_t *scanline_buffer);
|
||||
|
||||
/* end */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BITS,
|
||||
LINEAR,
|
||||
CONICAL,
|
||||
RADIAL,
|
||||
SOLID
|
||||
} image_type_t;
|
||||
|
||||
#define IS_SOURCE_IMAGE(img) (((image_common_t *)img)->type > BITS)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SOURCE_IMAGE_CLASS_UNKNOWN,
|
||||
SOURCE_IMAGE_CLASS_HORIZONTAL,
|
||||
SOURCE_IMAGE_CLASS_VERTICAL
|
||||
} source_pict_class_t;
|
||||
|
||||
struct point
|
||||
{
|
||||
int16_t x, y;
|
||||
};
|
||||
|
||||
struct image_common
|
||||
{
|
||||
image_type_t type;
|
||||
int32_t ref_count;
|
||||
pixman_region16_t full_region;
|
||||
pixman_region16_t clip_region;
|
||||
pixman_region16_t *src_clip;
|
||||
pixman_bool_t has_client_clip;
|
||||
pixman_transform_t *transform;
|
||||
pixman_repeat_t repeat;
|
||||
pixman_filter_t filter;
|
||||
pixman_fixed_t *filter_params;
|
||||
int n_filter_params;
|
||||
bits_image_t *alpha_map;
|
||||
point_t alpha_origin;
|
||||
pixman_bool_t component_alpha;
|
||||
pixman_read_memory_func_t read_func;
|
||||
pixman_write_memory_func_t write_func;
|
||||
};
|
||||
|
||||
struct source_image
|
||||
{
|
||||
image_common_t common;
|
||||
source_pict_class_t class;
|
||||
};
|
||||
|
||||
struct solid_fill
|
||||
{
|
||||
source_image_t common;
|
||||
uint32_t color; /* FIXME: shouldn't this be a pixman_color_t? */
|
||||
};
|
||||
|
||||
struct gradient
|
||||
{
|
||||
source_image_t common;
|
||||
int n_stops;
|
||||
pixman_gradient_stop_t * stops;
|
||||
int stop_range;
|
||||
uint32_t * color_table;
|
||||
int color_table_size;
|
||||
};
|
||||
|
||||
struct linear_gradient
|
||||
{
|
||||
gradient_t common;
|
||||
pixman_point_fixed_t p1;
|
||||
pixman_point_fixed_t p2;
|
||||
};
|
||||
|
||||
struct circle
|
||||
{
|
||||
pixman_fixed_t x;
|
||||
pixman_fixed_t y;
|
||||
pixman_fixed_t radius;
|
||||
};
|
||||
|
||||
struct radial_gradient
|
||||
{
|
||||
gradient_t common;
|
||||
|
||||
circle_t c1;
|
||||
circle_t c2;
|
||||
double cdx;
|
||||
double cdy;
|
||||
double dr;
|
||||
double A;
|
||||
};
|
||||
|
||||
struct conical_gradient
|
||||
{
|
||||
gradient_t common;
|
||||
pixman_point_fixed_t center;
|
||||
pixman_fixed_t angle;
|
||||
};
|
||||
|
||||
struct bits_image
|
||||
{
|
||||
image_common_t common;
|
||||
pixman_format_code_t format;
|
||||
const pixman_indexed_t *indexed;
|
||||
int width;
|
||||
int height;
|
||||
uint32_t * bits;
|
||||
uint32_t * free_me;
|
||||
int rowstride; /* in number of uint32_t's */
|
||||
};
|
||||
|
||||
union pixman_image
|
||||
{
|
||||
image_type_t type;
|
||||
image_common_t common;
|
||||
bits_image_t bits;
|
||||
gradient_t gradient;
|
||||
linear_gradient_t linear;
|
||||
conical_gradient_t conical;
|
||||
radial_gradient_t radial;
|
||||
solid_fill_t solid;
|
||||
};
|
||||
|
||||
#define LOG2_BITMAP_PAD 5
|
||||
#define FB_STIP_SHIFT LOG2_BITMAP_PAD
|
||||
#define FB_STIP_UNIT (1 << FB_STIP_SHIFT)
|
||||
#define FB_STIP_MASK (FB_STIP_UNIT - 1)
|
||||
#define FB_STIP_ALLONES ((uint32_t) -1)
|
||||
|
||||
#if BITMAP_BIT_ORDER == LSBFirst
|
||||
#define FbScrLeft(x,n) ((x) >> (n))
|
||||
#define FbScrRight(x,n) ((x) << (n))
|
||||
#define FbLeftStipBits(x,n) ((x) & ((((uint32_t) 1) << (n)) - 1))
|
||||
#else
|
||||
#define FbScrLeft(x,n) ((x) << (n))
|
||||
#define FbScrRight(x,n) ((x) >> (n))
|
||||
#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
|
||||
#endif
|
||||
|
||||
#define FbStipLeft(x,n) FbScrLeft(x,n)
|
||||
#define FbStipRight(x,n) FbScrRight(x,n)
|
||||
#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \
|
||||
FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))
|
||||
|
||||
#define FbLeftMask(x) ( ((x) & FB_MASK) ? \
|
||||
FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
|
||||
#define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \
|
||||
FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
|
||||
|
||||
#define FbMaskBits(x,w,l,n,r) { \
|
||||
n = (w); \
|
||||
r = FbRightMask((x)+n); \
|
||||
l = FbLeftMask(x); \
|
||||
if (l) { \
|
||||
n -= FB_UNIT - ((x) & FB_MASK); \
|
||||
if (n < 0) { \
|
||||
n = 0; \
|
||||
l &= r; \
|
||||
r = 0; \
|
||||
} \
|
||||
} \
|
||||
n >>= FB_SHIFT; \
|
||||
}
|
||||
|
||||
#if IMAGE_BYTE_ORDER == MSBFirst
|
||||
#define Fetch24(a) ((unsigned long) (a) & 1 ? \
|
||||
((READ(a) << 16) | READ((uint16_t *) ((a)+1))) : \
|
||||
((READ((uint16_t *) (a)) << 8) | READ((a)+2)))
|
||||
#define Store24(a,v) ((unsigned long) (a) & 1 ? \
|
||||
(WRITE(a, (uint8_t) ((v) >> 16)), \
|
||||
WRITE((uint16_t *) ((a)+1), (uint16_t) (v))) : \
|
||||
(WRITE((uint16_t *) (a), (uint16_t) ((v) >> 8)), \
|
||||
WRITE((a)+2, (uint8_t) (v))))
|
||||
#else
|
||||
#define Fetch24(a) ((unsigned long) (a) & 1 ? \
|
||||
(READ(a) | (READ((uint16_t *) ((a)+1)) << 8)) : \
|
||||
(READ((uint16_t *) (a)) | (READ((a)+2) << 16)))
|
||||
#define Store24(a,v) ((unsigned long) (a) & 1 ? \
|
||||
(WRITE(a, (uint8_t) (v)), \
|
||||
WRITE((uint16_t *) ((a)+1), (uint16_t) ((v) >> 8))) : \
|
||||
(WRITE((uint16_t *) (a), (uint16_t) (v)), \
|
||||
WRITE((a)+2, (uint8_t) ((v) >> 16))))
|
||||
#endif
|
||||
|
||||
#define Alpha(x) ((x) >> 24)
|
||||
#define Red(x) (((x) >> 16) & 0xff)
|
||||
#define Green(x) (((x) >> 8) & 0xff)
|
||||
#define Blue(x) ((x) & 0xff)
|
||||
|
||||
#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
|
||||
(((s) >> 8) & 0xff) * 301 + \
|
||||
(((s) ) & 0xff) * 58) >> 2)
|
||||
#define miCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \
|
||||
(((s) >> 6) & 0x03e0) | \
|
||||
(((s) >> 9) & 0x7c00))
|
||||
#define miIndexToEnt15(mif,rgb15) ((mif)->ent[rgb15])
|
||||
#define miIndexToEnt24(mif,rgb24) miIndexToEnt15(mif,miCvtR8G8B8to15(rgb24))
|
||||
|
||||
#define miIndexToEntY24(mif,rgb24) ((mif)->ent[CvtR8G8B8toY15(rgb24)])
|
||||
|
||||
|
||||
#define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
|
||||
#define FbIntDiv(a,b) (((uint16_t) (a) * 255) / (b))
|
||||
|
||||
#define FbGet8(v,i) ((uint16_t) (uint8_t) ((v) >> i))
|
||||
|
||||
|
||||
#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \
|
||||
(((s) >> 5) & 0x07e0) | \
|
||||
(((s) >> 8) & 0xf800))
|
||||
#define cvt0565to0888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
|
||||
((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
|
||||
((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
|
||||
|
||||
/*
|
||||
* 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 FbOverU(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),(a),(t)) + FbGet8(x,i), \
|
||||
(uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))
|
||||
|
||||
#define FbOverC(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),FbGet8(a,i),(t)) + FbGet8(x,i), \
|
||||
(uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))
|
||||
|
||||
#define FbInU(x,i,a,t) ((uint32_t) FbIntMult(FbGet8(x,i),(a),(t)) << (i))
|
||||
|
||||
#define FbInC(x,i,a,t) ((uint32_t) FbIntMult(FbGet8(x,i),FbGet8(a,i),(t)) << (i))
|
||||
|
||||
#define FbGen(x,y,i,ax,ay,t,u,v) ((t) = (FbIntMult(FbGet8(y,i),ay,(u)) + \
|
||||
FbIntMult(FbGet8(x,i),ax,(v))), \
|
||||
(uint32_t) ((uint8_t) ((t) | \
|
||||
(0 - ((t) >> 8)))) << (i))
|
||||
|
||||
#define FbAdd(x,y,i,t) ((t) = FbGet8(x,i) + FbGet8(y,i), \
|
||||
(uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))
|
||||
|
||||
|
||||
/*
|
||||
The methods below use some tricks to be able to do two color
|
||||
components at the same time.
|
||||
*/
|
||||
|
||||
/*
|
||||
x_c = (x_c * a) / 255
|
||||
*/
|
||||
#define FbByteMul(x, a) do { \
|
||||
uint32_t t = ((x & 0xff00ff) * a) + 0x800080; \
|
||||
t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
|
||||
t &= 0xff00ff; \
|
||||
\
|
||||
x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
|
||||
x = (x + ((x >> 8) & 0xff00ff)); \
|
||||
x &= 0xff00ff00; \
|
||||
x += t; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = (x_c * a) / 255 + y
|
||||
*/
|
||||
#define FbByteMulAdd(x, a, y) do { \
|
||||
uint32_t t = ((x & 0xff00ff) * a) + 0x800080; \
|
||||
t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
|
||||
t &= 0xff00ff; \
|
||||
t += y & 0xff00ff; \
|
||||
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
|
||||
t &= 0xff00ff; \
|
||||
\
|
||||
x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
|
||||
x = (x + ((x >> 8) & 0xff00ff)) >> 8; \
|
||||
x &= 0xff00ff; \
|
||||
x += (y >> 8) & 0xff00ff; \
|
||||
x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
|
||||
x &= 0xff00ff; \
|
||||
x <<= 8; \
|
||||
x += t; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = (x_c * a + y_c * b) / 255
|
||||
*/
|
||||
#define FbByteAddMul(x, a, y, b) do { \
|
||||
uint32_t t; \
|
||||
uint32_t r = (x >> 24) * a + (y >> 24) * b + 0x80; \
|
||||
r += (r >> 8); \
|
||||
r >>= 8; \
|
||||
\
|
||||
t = (x & 0xff00) * a + (y & 0xff00) * b; \
|
||||
t += (t >> 8) + 0x8000; \
|
||||
t >>= 16; \
|
||||
\
|
||||
t |= r << 16; \
|
||||
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
|
||||
t &= 0xff00ff; \
|
||||
t <<= 8; \
|
||||
\
|
||||
r = ((x >> 16) & 0xff) * a + ((y >> 16) & 0xff) * b + 0x80; \
|
||||
r += (r >> 8); \
|
||||
r >>= 8; \
|
||||
\
|
||||
x = (x & 0xff) * a + (y & 0xff) * b + 0x80; \
|
||||
x += (x >> 8); \
|
||||
x >>= 8; \
|
||||
x |= r << 16; \
|
||||
x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
|
||||
x &= 0xff00ff; \
|
||||
x |= t; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = (x_c * a + y_c *b) / 256
|
||||
*/
|
||||
#define FbByteAddMul_256(x, a, y, b) do { \
|
||||
uint32_t t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; \
|
||||
t >>= 8; \
|
||||
t &= 0xff00ff; \
|
||||
\
|
||||
x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; \
|
||||
x &= 0xff00ff00; \
|
||||
x += t; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = (x_c * a_c) / 255
|
||||
*/
|
||||
#define FbByteMulC(x, a) do { \
|
||||
uint32_t t; \
|
||||
uint32_t r = (x & 0xff) * (a & 0xff); \
|
||||
r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
|
||||
r += 0x800080; \
|
||||
r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
|
||||
r &= 0xff00ff; \
|
||||
\
|
||||
x >>= 8; \
|
||||
t = (x & 0xff) * ((a >> 8) & 0xff); \
|
||||
t |= (x & 0xff0000) * (a >> 24); \
|
||||
t += 0x800080; \
|
||||
t = t + ((t >> 8) & 0xff00ff); \
|
||||
x = r | (t & 0xff00ff00); \
|
||||
\
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = (x_c * a) / 255 + y
|
||||
*/
|
||||
#define FbByteMulAddC(x, a, y) do { \
|
||||
uint32_t t; \
|
||||
uint32_t r = (x & 0xff) * (a & 0xff); \
|
||||
r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
|
||||
r += 0x800080; \
|
||||
r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
|
||||
r &= 0xff00ff; \
|
||||
r += y & 0xff00ff; \
|
||||
r |= 0x1000100 - ((r >> 8) & 0xff00ff); \
|
||||
r &= 0xff00ff; \
|
||||
\
|
||||
x >>= 8; \
|
||||
t = (x & 0xff) * ((a >> 8) & 0xff); \
|
||||
t |= (x & 0xff0000) * (a >> 24); \
|
||||
t += 0x800080; \
|
||||
t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
|
||||
t &= 0xff00ff; \
|
||||
t += (y >> 8) & 0xff00ff; \
|
||||
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
|
||||
t &= 0xff00ff; \
|
||||
x = r | (t << 8); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = (x_c * a_c + y_c * b) / 255
|
||||
*/
|
||||
#define FbByteAddMulC(x, a, y, b) do { \
|
||||
uint32_t t; \
|
||||
uint32_t r = (x >> 24) * (a >> 24) + (y >> 24) * b; \
|
||||
r += (r >> 8) + 0x80; \
|
||||
r >>= 8; \
|
||||
\
|
||||
t = (x & 0xff00) * ((a >> 8) & 0xff) + (y & 0xff00) * b; \
|
||||
t += (t >> 8) + 0x8000; \
|
||||
t >>= 16; \
|
||||
\
|
||||
t |= r << 16; \
|
||||
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
|
||||
t &= 0xff00ff; \
|
||||
t <<= 8; \
|
||||
\
|
||||
r = ((x >> 16) & 0xff) * ((a >> 16) & 0xff) + ((y >> 16) & 0xff) * b + 0x80; \
|
||||
r += (r >> 8); \
|
||||
r >>= 8; \
|
||||
\
|
||||
x = (x & 0xff) * (a & 0xff) + (y & 0xff) * b + 0x80; \
|
||||
x += (x >> 8); \
|
||||
x >>= 8; \
|
||||
x |= r << 16; \
|
||||
x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
|
||||
x &= 0xff00ff; \
|
||||
x |= t; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
x_c = min(x_c + y_c, 255)
|
||||
*/
|
||||
#define FbByteAdd(x, y) do { \
|
||||
uint32_t t; \
|
||||
uint32_t r = (x & 0xff00ff) + (y & 0xff00ff); \
|
||||
r |= 0x1000100 - ((r >> 8) & 0xff00ff); \
|
||||
r &= 0xff00ff; \
|
||||
\
|
||||
t = ((x >> 8) & 0xff00ff) + ((y >> 8) & 0xff00ff); \
|
||||
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
|
||||
r |= (t & 0xff00ff) << 8; \
|
||||
x = r; \
|
||||
} while (0)
|
||||
|
||||
#define div_255(x) (((x) + 0x80 + (((x) + 0x80) >> 8)) >> 8)
|
||||
|
||||
#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
|
||||
|
||||
#define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) : \
|
||||
((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
|
||||
|
||||
#if 0
|
||||
/* FIXME: the MOD macro above is equivalent, but faster I think */
|
||||
#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
|
||||
#endif
|
||||
|
||||
/* FIXME: the (void)__read_func hides lots of warnings (which is what they
|
||||
* are supposed to do), but some of them are real. For example the one
|
||||
* where Fetch4 doesn't have a READ
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/* Framebuffer access support macros */
|
||||
#define ACCESS_MEM(code) \
|
||||
do { \
|
||||
const image_common_t *const com__ = \
|
||||
(image_common_t *)image; \
|
||||
\
|
||||
if (!com__->read_func && !com__->write_func) \
|
||||
{ \
|
||||
const int do_access__ = 0; \
|
||||
const pixman_read_memory_func_t read_func__ = NULL; \
|
||||
const pixman_write_memory_func_t write_func__ = NULL; \
|
||||
(void)read_func__; \
|
||||
(void)write_func__; \
|
||||
(void)do_access__; \
|
||||
\
|
||||
{code} \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
const int do_access__ = 1; \
|
||||
const pixman_read_memory_func_t read_func__ = \
|
||||
com__->read_func; \
|
||||
const pixman_write_memory_func_t write_func__ = \
|
||||
com__->write_func; \
|
||||
(void)read_func__; \
|
||||
(void)write_func__; \
|
||||
(void)do_access__; \
|
||||
\
|
||||
{code} \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef PIXMAN_FB_ACCESSORS
|
||||
|
||||
#define READ(ptr) \
|
||||
(image->common.read_func ((ptr), sizeof(*(ptr))))
|
||||
#define WRITE(ptr,val) \
|
||||
(image->common.write_func ((ptr), (val), sizeof (*(ptr))))
|
||||
|
||||
#define MEMCPY_WRAPPED(dst, src, size) \
|
||||
do { \
|
||||
size_t _i; \
|
||||
uint8_t *_dst = (uint8_t*)(dst), *_src = (uint8_t*)(src); \
|
||||
for(_i = 0; _i < size; _i++) { \
|
||||
WRITE(_dst +_i, READ(_src + _i)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define MEMSET_WRAPPED(dst, val, size) \
|
||||
do { \
|
||||
size_t _i; \
|
||||
uint8_t *_dst = (uint8_t*)(dst); \
|
||||
for(_i = 0; _i < size; _i++) { \
|
||||
WRITE(_dst +_i, (val)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* FIXME */
|
||||
#define fbPrepareAccess(x)
|
||||
#define fbFinishAccess(x)
|
||||
|
||||
#else
|
||||
|
||||
#define READ(ptr) (*(ptr))
|
||||
#define WRITE(ptr, val) (*(ptr) = (val))
|
||||
#define MEMCPY_WRAPPED(dst, src, size) \
|
||||
memcpy(dst, src, size)
|
||||
#define MEMSET_WRAPPED(dst, val, size) \
|
||||
memset(dst, val, size)
|
||||
#define fbPrepareAccess(x)
|
||||
#define fbFinishAccess(x)
|
||||
#endif
|
||||
|
||||
#define fbComposeGetSolid(img, res, fmt) \
|
||||
do \
|
||||
{ \
|
||||
pixman_format_code_t format__; \
|
||||
if (img->type == SOLID) \
|
||||
{ \
|
||||
format__ = PIXMAN_a8r8g8b8; \
|
||||
(res) = img->solid.color; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
uint32_t *bits__ = (img)->bits.bits; \
|
||||
format__ = (img)->bits.format; \
|
||||
\
|
||||
switch (PIXMAN_FORMAT_BPP((img)->bits.format)) \
|
||||
{ \
|
||||
case 32: \
|
||||
(res) = READ((uint32_t *)bits__); \
|
||||
break; \
|
||||
case 24: \
|
||||
(res) = Fetch24 ((uint8_t *) bits__); \
|
||||
break; \
|
||||
case 16: \
|
||||
(res) = READ((uint16_t *) bits__); \
|
||||
(res) = cvt0565to0888(res); \
|
||||
break; \
|
||||
case 8: \
|
||||
(res) = READ((uint8_t *) bits__); \
|
||||
(res) = (res) << 24; \
|
||||
break; \
|
||||
case 1: \
|
||||
(res) = READ((uint32_t *) bits__); \
|
||||
(res) = FbLeftStipBits((res),1) ? 0xff000000 : 0x00000000; \
|
||||
break; \
|
||||
default: \
|
||||
return; \
|
||||
} \
|
||||
/* manage missing src alpha */ \
|
||||
if (!PIXMAN_FORMAT_A((img)->bits.format)) \
|
||||
(res) |= 0xff000000; \
|
||||
} \
|
||||
\
|
||||
/* If necessary, convert RGB <--> BGR. */ \
|
||||
if (PIXMAN_FORMAT_TYPE (format__) != PIXMAN_FORMAT_TYPE(fmt)) \
|
||||
{ \
|
||||
(res) = ((((res) & 0xff000000) >> 0) | \
|
||||
(((res) & 0x00ff0000) >> 16) | \
|
||||
(((res) & 0x0000ff00) >> 0) | \
|
||||
(((res) & 0x000000ff) << 16)); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define fbComposeGetStart(pict,x,y,type,out_stride,line,mul) do { \
|
||||
uint32_t *__bits__; \
|
||||
int __stride__; \
|
||||
int __bpp__; \
|
||||
\
|
||||
__bits__ = pict->bits.bits; \
|
||||
__stride__ = pict->bits.rowstride; \
|
||||
__bpp__ = PIXMAN_FORMAT_BPP(pict->bits.format); \
|
||||
(out_stride) = __stride__ * sizeof (uint32_t) / sizeof (type); \
|
||||
(line) = ((type *) __bits__) + \
|
||||
(out_stride) * (y) + (mul) * (x); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* Edges
|
||||
*/
|
||||
|
||||
#define MAX_ALPHA(n) ((1 << (n)) - 1)
|
||||
#define N_Y_FRAC(n) ((n) == 1 ? 1 : (1 << ((n)/2)) - 1)
|
||||
#define N_X_FRAC(n) ((1 << ((n)/2)) + 1)
|
||||
|
||||
#define STEP_Y_SMALL(n) (pixman_fixed_1 / N_Y_FRAC(n))
|
||||
#define STEP_Y_BIG(n) (pixman_fixed_1 - (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n))
|
||||
|
||||
#define Y_FRAC_FIRST(n) (STEP_Y_SMALL(n) / 2)
|
||||
#define Y_FRAC_LAST(n) (Y_FRAC_FIRST(n) + (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n))
|
||||
|
||||
#define STEP_X_SMALL(n) (pixman_fixed_1 / N_X_FRAC(n))
|
||||
#define STEP_X_BIG(n) (pixman_fixed_1 - (N_X_FRAC(n) - 1) * STEP_X_SMALL(n))
|
||||
|
||||
#define X_FRAC_FIRST(n) (STEP_X_SMALL(n) / 2)
|
||||
#define X_FRAC_LAST(n) (X_FRAC_FIRST(n) + (N_X_FRAC(n) - 1) * STEP_X_SMALL(n))
|
||||
|
||||
#define RenderSamplesX(x,n) ((n) == 1 ? 0 : (pixman_fixed_frac (x) + X_FRAC_FIRST(n)) / STEP_X_SMALL(n))
|
||||
|
||||
/*
|
||||
* Step across a small sample grid gap
|
||||
*/
|
||||
#define RenderEdgeStepSmall(edge) { \
|
||||
edge->x += edge->stepx_small; \
|
||||
edge->e += edge->dx_small; \
|
||||
if (edge->e > 0) \
|
||||
{ \
|
||||
edge->e -= edge->dy; \
|
||||
edge->x += edge->signdx; \
|
||||
} \
|
||||
}
|
||||
|
||||
/*
|
||||
* Step across a large sample grid gap
|
||||
*/
|
||||
#define RenderEdgeStepBig(edge) { \
|
||||
edge->x += edge->stepx_big; \
|
||||
edge->e += edge->dx_big; \
|
||||
if (edge->e > 0) \
|
||||
{ \
|
||||
edge->e -= edge->dy; \
|
||||
edge->x += edge->signdx; \
|
||||
} \
|
||||
}
|
||||
|
||||
void
|
||||
pixman_rasterize_edges_accessors (pixman_image_t *image,
|
||||
pixman_edge_t *l,
|
||||
pixman_edge_t *r,
|
||||
pixman_fixed_t t,
|
||||
pixman_fixed_t b);
|
||||
|
||||
|
||||
/* Timing */
|
||||
static inline uint64_t
|
||||
oil_profile_stamp_rdtsc (void)
|
||||
{
|
||||
uint64_t ts;
|
||||
__asm__ __volatile__("rdtsc\n" : "=A" (ts));
|
||||
return ts;
|
||||
}
|
||||
#define OIL_STAMP oil_profile_stamp_rdtsc
|
||||
|
||||
typedef struct PixmanTimer PixmanTimer;
|
||||
|
||||
struct PixmanTimer
|
||||
{
|
||||
int initialized;
|
||||
const char *name;
|
||||
uint64_t n_times;
|
||||
uint64_t total;
|
||||
PixmanTimer *next;
|
||||
};
|
||||
|
||||
extern int timer_defined;
|
||||
void pixman_timer_register (PixmanTimer *timer);
|
||||
|
||||
#define TIMER_BEGIN(tname) \
|
||||
{ \
|
||||
static PixmanTimer timer##tname; \
|
||||
uint64_t begin##tname; \
|
||||
\
|
||||
if (!timer##tname.initialized) \
|
||||
{ \
|
||||
timer##tname.initialized = 1; \
|
||||
timer##tname.name = #tname; \
|
||||
pixman_timer_register (&timer##tname); \
|
||||
} \
|
||||
\
|
||||
timer##tname.n_times++; \
|
||||
begin##tname = OIL_STAMP();
|
||||
|
||||
#define TIMER_END(tname) \
|
||||
timer##tname.total += OIL_STAMP() - begin##tname; \
|
||||
}
|
||||
|
||||
|
||||
#endif /* PIXMAN_PRIVATE_H */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,80 +1,59 @@
|
|||
#define pixman_add_trapezoids _cairo_pixman_add_trapezoids
|
||||
#define pixman_color_to_pixel _cairo_pixman_color_to_pixel
|
||||
#define composeFunctions _cairo_pixman_compose_functions
|
||||
#define fbComposeSetupMMX _cairo_pixman_compose_setup_mmx
|
||||
#define pixman_composite _cairo_pixman_composite
|
||||
#define fbCompositeCopyAreammx _cairo_pixman_composite_copy_area_mmx
|
||||
#define fbCompositeSolidMask_nx8888x0565Cmmx _cairo_pixman_composite_solid_mask_nx8888x0565Cmmx
|
||||
#define fbCompositeSolidMask_nx8888x8888Cmmx _cairo_pixman_composite_solid_mask_nx8888x8888Cmmx
|
||||
#define fbCompositeSolidMask_nx8x0565mmx _cairo_pixman_composite_solid_mask_nx8x0565mmx
|
||||
#define fbCompositeSolidMask_nx8x8888mmx _cairo_pixman_composite_solid_mask_nx8x8888mmx
|
||||
#define fbCompositeSolidMaskSrc_nx8x8888mmx _cairo_pixman_composite_solid_mask_src_nx8x8888mmx
|
||||
#define fbCompositeSolid_nx0565mmx _cairo_pixman_composite_solid_nx0565mmx
|
||||
#define fbCompositeSolid_nx8888mmx _cairo_pixman_composite_solid_nx8888mmx
|
||||
#define fbCompositeSrc_8888RevNPx0565mmx _cairo_pixman_composite_src_8888RevNPx0565mmx
|
||||
#define fbCompositeSrc_8888RevNPx8888mmx _cairo_pixman_composite_src_8888RevNPx8888_mmx
|
||||
#define fbCompositeSrc_8888x0565mmx _cairo_pixman_composite_src_8888x0565mmx
|
||||
#define fbCompositeSrc_8888x8888mmx _cairo_pixman_composite_src_8888x8888mmx
|
||||
#define fbCompositeSrc_8888x8x8888mmx _cairo_pixman_composite_src_8888x8x8888mmx
|
||||
#define fbCompositeSrcAdd_8000x8000mmx _cairo_pixman_composite_src_add_8000x8000mmx
|
||||
#define fbCompositeSrcAdd_8888x8888mmx _cairo_pixman_composite_src_add_8888x8888mmx
|
||||
#define fbCompositeSrc_x888x8x8888mmx _cairo_pixman_composite_src_x888x8x8888mmx
|
||||
#define pixman_composite_trapezoids _cairo_pixman_composite_trapezoids
|
||||
#define pixman_composite_tri_fan _cairo_pixman_composite_tri_fan
|
||||
#define pixman_composite_tri_strip _cairo_pixman_composite_tri_strip
|
||||
#define pixman_composite_triangles _cairo_pixman_composite_triangles
|
||||
#define fbCopyAreammx _cairo_pixman_copy_area_mmx
|
||||
#define pixman_fill_rectangle _cairo_pixman_fill_rectangle
|
||||
#define pixman_fill_rectangles _cairo_pixman_fill_rectangles
|
||||
#define pixman_format_create _cairo_pixman_format_create
|
||||
#define pixman_format_create_masks _cairo_pixman_format_create_masks
|
||||
#define pixman_format_destroy _cairo_pixman_format_destroy
|
||||
#define pixman_format_get_masks _cairo_pixman_format_get_masks
|
||||
#define pixman_format_init _cairo_pixman_format_init
|
||||
#if defined(USE_MMX) && !defined(__amd64__) && !defined(__x86_64__)
|
||||
#define fbHaveMMX _cairo_pixman_have_mmx
|
||||
#endif
|
||||
#define pixman_image_create _cairo_pixman_image_create
|
||||
#define pixman_image_create_for_data _cairo_pixman_image_create_for_data
|
||||
#define pixman_image_destroy _cairo_pixman_image_destroy
|
||||
#define pixman_image_get_data _cairo_pixman_image_get_data
|
||||
#define pixman_image_get_depth _cairo_pixman_image_get_depth
|
||||
#define pixman_image_get_format _cairo_pixman_image_get_format
|
||||
#define pixman_image_get_height _cairo_pixman_image_get_height
|
||||
#define pixman_image_get_stride _cairo_pixman_image_get_stride
|
||||
#define pixman_image_get_width _cairo_pixman_image_get_width
|
||||
#define pixman_image_set_clip_region _cairo_pixman_image_set_clip_region
|
||||
#define pixman_image_set_component_alpha _cairo_pixman_image_set_component_alpha
|
||||
#define pixman_image_set_filter _cairo_pixman_image_set_filter
|
||||
#define pixman_image_set_repeat _cairo_pixman_image_set_repeat
|
||||
#define pixman_image_set_transform _cairo_pixman_image_set_transform
|
||||
#define pixman_image_create_linear_gradient _cairo_pixman_image_create_linear_gradient
|
||||
#define pixman_image_create_radial_gradient _cairo_pixman_image_create_radial_gradient
|
||||
#define miIsSolidAlpha _cairo_pixman_is_solid_alpha
|
||||
#define pixman_pixel_to_color _cairo_pixman_pixel_to_color
|
||||
#define pixman_region_append _cairo_pixman_region_append
|
||||
#define pixman_region_contains_point _cairo_pixman_region_contains_point
|
||||
#define pixman_region_contains_rectangle _cairo_pixman_region_contains_rectangle
|
||||
#define pixman_region_copy _cairo_pixman_region_copy
|
||||
#define pixman_region_create _cairo_pixman_region_create
|
||||
#define pixman_region_create_simple _cairo_pixman_region_create_simple
|
||||
#define pixman_region_destroy _cairo_pixman_region_destroy
|
||||
#define pixman_region_empty _cairo_pixman_region_empty
|
||||
#define pixman_region_extents _cairo_pixman_region_extents
|
||||
#define pixman_region_intersect _cairo_pixman_region_intersect
|
||||
#define pixman_region_inverse _cairo_pixman_region_inverse
|
||||
#define pixman_region_not_empty _cairo_pixman_region_not_empty
|
||||
#define pixman_region_num_rects _cairo_pixman_region_num_rects
|
||||
#define pixman_region_rects _cairo_pixman_region_rects
|
||||
#define pixman_region_reset _cairo_pixman_region_reset
|
||||
#define pixman_region_subtract _cairo_pixman_region_subtract
|
||||
#define pixman_region_translate _cairo_pixman_region_translate
|
||||
#define pixman_region_union _cairo_pixman_region_union
|
||||
#define pixman_region_union_rect _cairo_pixman_region_union_rect
|
||||
#define pixman_region_validate _cairo_pixman_region_validate
|
||||
#define RenderEdgeInit _cairo_pixman_render_edge_init
|
||||
#define RenderEdgeStep _cairo_pixman_render_edge_step
|
||||
#define RenderLineFixedEdgeInit _cairo_pixman_render_line_fixed_edge_init
|
||||
#define RenderSampleCeilY _cairo_pixman_render_sample_ceil_y
|
||||
#define RenderSampleFloorY _cairo_pixman_render_sample_floor_y
|
||||
#define fbSolidFillmmx _cairo_pixman_solid_fill_mmx
|
||||
#define pixman_transform_point_3d _moz_pixman_transform_point_3d
|
||||
#define pixman_region_set_static_pointers _moz_pixman_region_set_static_pointers
|
||||
#define pixman_region_init _moz_pixman_region_init
|
||||
#define pixman_region_init_rect _moz_pixman_region_init_rect
|
||||
#define pixman_region_init_with_extents _moz_pixman_region_init_with_extents
|
||||
#define pixman_region_fini _moz_pixman_region_fini
|
||||
#define pixman_region_translate _moz_pixman_region_translate
|
||||
#define pixman_region_copy _moz_pixman_region_copy
|
||||
#define pixman_region_intersect _moz_pixman_region_intersect
|
||||
#define pixman_region_union _moz_pixman_region_union
|
||||
#define pixman_region_union_rect _moz_pixman_region_union_rect
|
||||
#define pixman_region_subtract _moz_pixman_region_subtract
|
||||
#define pixman_region_inverse _moz_pixman_region_inverse
|
||||
#define pixman_region_contains_point _moz_pixman_region_contains_point
|
||||
#define pixman_region_contains_rectangle _moz_pixman_region_contains_rectangle
|
||||
#define pixman_region_not_empty _moz_pixman_region_not_empty
|
||||
#define pixman_region_extents _moz_pixman_region_extents
|
||||
#define pixman_region_n_rects _moz_pixman_region_n_rects
|
||||
#define pixman_region_rectangles _moz_pixman_region_rectangles
|
||||
#define pixman_region_equal _moz_pixman_region_equal
|
||||
#define pixman_region_selfcheck _moz_pixman_region_selfcheck
|
||||
#define pixman_region_reset _moz_pixman_region_reset
|
||||
#define pixman_region_init_rects _moz_pixman_region_init_rects
|
||||
#define pixman_blt _moz_pixman_blt
|
||||
#define pixman_fill _moz_pixman_fill
|
||||
#define pixman_image_create_solid_fill _moz_pixman_image_create_solid_fill
|
||||
#define pixman_image_create_linear_gradient _moz_pixman_image_create_linear_gradient
|
||||
#define pixman_image_create_radial_gradient _moz_pixman_image_create_radial_gradient
|
||||
#define pixman_image_create_conical_gradient _moz_pixman_image_create_conical_gradient
|
||||
#define pixman_image_create_bits _moz_pixman_image_create_bits
|
||||
#define pixman_image_ref _moz_pixman_image_ref
|
||||
#define pixman_image_unref _moz_pixman_image_unref
|
||||
#define pixman_image_set_clip_region _moz_pixman_image_set_clip_region
|
||||
#define pixman_image_set_has_client_clip _moz_pixman_image_set_has_client_clip
|
||||
#define pixman_image_set_transform _moz_pixman_image_set_transform
|
||||
#define pixman_image_set_repeat _moz_pixman_image_set_repeat
|
||||
#define pixman_image_set_filter _moz_pixman_image_set_filter
|
||||
#define pixman_image_set_filter_params _moz_pixman_image_set_filter_params
|
||||
#define pixman_image_set_alpha_map _moz_pixman_image_set_alpha_map
|
||||
#define pixman_image_set_component_alpha _moz_pixman_image_set_component_alpha
|
||||
#define pixman_image_set_accessors _moz_pixman_image_set_accessors
|
||||
#define pixman_image_set_indexed _moz_pixman_image_set_indexed
|
||||
#define pixman_image_get_data _moz_pixman_image_get_data
|
||||
#define pixman_image_get_width _moz_pixman_image_get_width
|
||||
#define pixman_image_get_height _moz_pixman_image_get_height
|
||||
#define pixman_image_get_stride _moz_pixman_image_get_stride
|
||||
#define pixman_image_get_depth _moz_pixman_image_get_depth
|
||||
#define pixman_image_fill_rectangles _moz_pixman_image_fill_rectangles
|
||||
#define pixman_compute_composite_region _moz_pixman_compute_composite_region
|
||||
#define pixman_image_composite _moz_pixman_image_composite
|
||||
#define pixman_sample_ceil_y _moz_pixman_sample_ceil_y
|
||||
#define pixman_sample_floor_y _moz_pixman_sample_floor_y
|
||||
#define pixman_edge_step _moz_pixman_edge_step
|
||||
#define pixman_edge_init _moz_pixman_edge_init
|
||||
#define pixman_line_fixed_edge_init _moz_pixman_line_fixed_edge_init
|
||||
#define pixman_rasterize_edges _moz_pixman_rasterize_edges
|
||||
#define pixman_add_traps _moz_pixman_add_traps
|
||||
#define pixman_add_trapezoids _moz_pixman_add_trapezoids
|
||||
#define pixman_rasterize_trapezoid _moz_pixman_rasterize_trapezoid
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright © 2007 Red Hat, 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 Red Hat not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Red Hat makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
|
||||
* 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 <config.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "pixman-private.h"
|
||||
|
||||
static PixmanTimer *timers;
|
||||
|
||||
static void
|
||||
dump_timers (void)
|
||||
{
|
||||
PixmanTimer *timer;
|
||||
|
||||
for (timer = timers; timer != NULL; timer = timer->next)
|
||||
{
|
||||
printf ("%s: total: %llu n: %llu avg: %f\n",
|
||||
timer->name,
|
||||
timer->total,
|
||||
timer->n_times,
|
||||
timer->total / (double)timer->n_times);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pixman_timer_register (PixmanTimer *timer)
|
||||
{
|
||||
static int initialized;
|
||||
|
||||
int atexit(void (*function)(void));
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
atexit (dump_timers);
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
timer->next = timers;
|
||||
timers = timer;
|
||||
}
|
|
@ -0,0 +1,285 @@
|
|||
/*
|
||||
* $Id: pixman-trap.c,v 1.4 2007/08/02 06:54:41 vladimir%pobox.com Exp $
|
||||
*
|
||||
* Copyright © 2004 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 <config.h>
|
||||
#include <stdio.h>
|
||||
#include "pixman-private.h"
|
||||
|
||||
typedef uint32_t FbBits;
|
||||
|
||||
void
|
||||
pixman_add_traps (pixman_image_t * image,
|
||||
int16_t x_off,
|
||||
int16_t y_off,
|
||||
int ntrap,
|
||||
pixman_trap_t *traps)
|
||||
{
|
||||
int bpp;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
pixman_fixed_t x_off_fixed;
|
||||
pixman_fixed_t y_off_fixed;
|
||||
pixman_edge_t l, r;
|
||||
pixman_fixed_t t, b;
|
||||
|
||||
width = image->bits.width;
|
||||
height = image->bits.height;
|
||||
bpp = PIXMAN_FORMAT_BPP (image->bits.format);
|
||||
|
||||
x_off_fixed = pixman_int_to_fixed(y_off);
|
||||
y_off_fixed = pixman_int_to_fixed(y_off);
|
||||
|
||||
while (ntrap--)
|
||||
{
|
||||
t = traps->top.y + y_off_fixed;
|
||||
if (t < 0)
|
||||
t = 0;
|
||||
t = pixman_sample_ceil_y (t, bpp);
|
||||
|
||||
b = traps->bot.y + y_off_fixed;
|
||||
if (pixman_fixed_to_int (b) >= height)
|
||||
b = pixman_int_to_fixed (height) - 1;
|
||||
b = pixman_sample_floor_y (b, bpp);
|
||||
|
||||
if (b >= t)
|
||||
{
|
||||
/* initialize edge walkers */
|
||||
pixman_edge_init (&l, bpp, t,
|
||||
traps->top.l + x_off_fixed,
|
||||
traps->top.y + y_off_fixed,
|
||||
traps->bot.l + x_off_fixed,
|
||||
traps->bot.y + y_off_fixed);
|
||||
|
||||
pixman_edge_init (&r, bpp, t,
|
||||
traps->top.r + x_off_fixed,
|
||||
traps->top.y + y_off_fixed,
|
||||
traps->bot.r + x_off_fixed,
|
||||
traps->bot.y + y_off_fixed);
|
||||
|
||||
pixman_rasterize_edges (image, &l, &r, t, b);
|
||||
}
|
||||
traps++;
|
||||
}
|
||||
|
||||
fbFinishAccess (pPicture->pDrawable);
|
||||
}
|
||||
|
||||
static void
|
||||
dump_image (pixman_image_t *image,
|
||||
const char *title)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (!image->type == BITS)
|
||||
{
|
||||
printf ("%s is not a regular image\n", title);
|
||||
}
|
||||
|
||||
if (!image->bits.format == PIXMAN_a8)
|
||||
{
|
||||
printf ("%s is not an alpha mask\n", title);
|
||||
}
|
||||
|
||||
printf ("\n\n\n%s: \n", title);
|
||||
|
||||
for (i = 0; i < image->bits.height; ++i)
|
||||
{
|
||||
uint8_t *line =
|
||||
(uint8_t *)&(image->bits.bits[i * image->bits.rowstride]);
|
||||
|
||||
for (j = 0; j < image->bits.width; ++j)
|
||||
printf ("%c", line[j]? '#' : ' ');
|
||||
|
||||
printf ("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pixman_add_trapezoids (pixman_image_t *image,
|
||||
int16_t x_off,
|
||||
int y_off,
|
||||
int ntraps,
|
||||
const pixman_trapezoid_t *traps)
|
||||
{
|
||||
int i;
|
||||
|
||||
#if 0
|
||||
dump_image (image, "before");
|
||||
#endif
|
||||
|
||||
for (i = 0; i < ntraps; ++i)
|
||||
{
|
||||
const pixman_trapezoid_t *trap = &(traps[i]);
|
||||
|
||||
if (!pixman_trapezoid_valid (trap))
|
||||
continue;
|
||||
|
||||
pixman_rasterize_trapezoid (image, trap, x_off, y_off);
|
||||
}
|
||||
|
||||
#if 0
|
||||
dump_image (image, "after");
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
pixman_rasterize_trapezoid (pixman_image_t * image,
|
||||
const pixman_trapezoid_t *trap,
|
||||
int x_off,
|
||||
int y_off)
|
||||
{
|
||||
int bpp;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
pixman_fixed_t x_off_fixed;
|
||||
pixman_fixed_t y_off_fixed;
|
||||
pixman_edge_t l, r;
|
||||
pixman_fixed_t t, b;
|
||||
|
||||
return_if_fail (image->type == BITS);
|
||||
|
||||
if (!pixman_trapezoid_valid (trap))
|
||||
return;
|
||||
|
||||
width = image->bits.width;
|
||||
height = image->bits.height;
|
||||
bpp = PIXMAN_FORMAT_BPP (image->bits.format);
|
||||
|
||||
x_off_fixed = pixman_int_to_fixed(x_off);
|
||||
y_off_fixed = pixman_int_to_fixed(y_off);
|
||||
t = trap->top + y_off_fixed;
|
||||
if (t < 0)
|
||||
t = 0;
|
||||
t = pixman_sample_ceil_y (t, bpp);
|
||||
|
||||
b = trap->bottom + y_off_fixed;
|
||||
if (pixman_fixed_to_int (b) >= height)
|
||||
b = pixman_int_to_fixed (height) - 1;
|
||||
b = pixman_sample_floor_y (b, bpp);
|
||||
|
||||
if (b >= t)
|
||||
{
|
||||
/* initialize edge walkers */
|
||||
pixman_line_fixed_edge_init (&l, bpp, t, &trap->left, x_off, y_off);
|
||||
pixman_line_fixed_edge_init (&r, bpp, t, &trap->right, x_off, y_off);
|
||||
|
||||
pixman_rasterize_edges (image, &l, &r, t, b);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int
|
||||
_GreaterY (pixman_point_fixed_t *a, pixman_point_fixed_t *b)
|
||||
{
|
||||
if (a->y == b->y)
|
||||
return a->x > b->x;
|
||||
return a->y > b->y;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that the definition of this function is a bit odd because
|
||||
* of the X coordinate space (y increasing downwards).
|
||||
*/
|
||||
static int
|
||||
_Clockwise (pixman_point_fixed_t *ref, pixman_point_fixed_t *a, pixman_point_fixed_t *b)
|
||||
{
|
||||
pixman_point_fixed_t ad, bd;
|
||||
|
||||
ad.x = a->x - ref->x;
|
||||
ad.y = a->y - ref->y;
|
||||
bd.x = b->x - ref->x;
|
||||
bd.y = b->y - ref->y;
|
||||
|
||||
return ((pixman_fixed_32_32_t) bd.y * ad.x - (pixman_fixed_32_32_t) ad.y * bd.x) < 0;
|
||||
}
|
||||
|
||||
/* FIXME -- this could be made more efficient */
|
||||
void
|
||||
fbAddTriangles (pixman_image_t * pPicture,
|
||||
int16_t x_off,
|
||||
int16_t y_off,
|
||||
int ntri,
|
||||
xTriangle *tris)
|
||||
{
|
||||
pixman_point_fixed_t *top, *left, *right, *tmp;
|
||||
xTrapezoid trap;
|
||||
|
||||
for (; ntri; ntri--, tris++)
|
||||
{
|
||||
top = &tris->p1;
|
||||
left = &tris->p2;
|
||||
right = &tris->p3;
|
||||
if (_GreaterY (top, left)) {
|
||||
tmp = left; left = top; top = tmp;
|
||||
}
|
||||
if (_GreaterY (top, right)) {
|
||||
tmp = right; right = top; top = tmp;
|
||||
}
|
||||
if (_Clockwise (top, right, left)) {
|
||||
tmp = right; right = left; left = tmp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Two cases:
|
||||
*
|
||||
* + +
|
||||
* / \ / \
|
||||
* / \ / \
|
||||
* / + + \
|
||||
* / -- -- \
|
||||
* / -- -- \
|
||||
* / --- --- \
|
||||
* +-- --+
|
||||
*/
|
||||
|
||||
trap.top = top->y;
|
||||
trap.left.p1 = *top;
|
||||
trap.left.p2 = *left;
|
||||
trap.right.p1 = *top;
|
||||
trap.right.p2 = *right;
|
||||
if (right->y < left->y)
|
||||
trap.bottom = right->y;
|
||||
else
|
||||
trap.bottom = left->y;
|
||||
fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
|
||||
if (right->y < left->y)
|
||||
{
|
||||
trap.top = right->y;
|
||||
trap.bottom = left->y;
|
||||
trap.right.p1 = *right;
|
||||
trap.right.p2 = *left;
|
||||
}
|
||||
else
|
||||
{
|
||||
trap.top = left->y;
|
||||
trap.bottom = right->y;
|
||||
trap.left.p1 = *left;
|
||||
trap.left.p2 = *right;
|
||||
}
|
||||
fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,392 @@
|
|||
/*
|
||||
* 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 <config.h>
|
||||
#include <stdlib.h>
|
||||
#include "pixman.h"
|
||||
#include "pixman-private.h"
|
||||
#include "pixman-mmx.h"
|
||||
|
||||
pixman_bool_t
|
||||
pixman_transform_point_3d (pixman_transform_t *transform,
|
||||
pixman_vector_t *vector)
|
||||
{
|
||||
pixman_vector_t result;
|
||||
int i, j;
|
||||
pixman_fixed_32_32_t partial;
|
||||
pixman_fixed_48_16_t v;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
v = 0;
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
partial = ((pixman_fixed_48_16_t) transform->matrix[j][i] *
|
||||
(pixman_fixed_48_16_t) vector->vector[i]);
|
||||
v += partial >> 16;
|
||||
}
|
||||
|
||||
if (v > pixman_max_fixed_48_16 || v < pixman_min_fixed_48_16)
|
||||
return FALSE;
|
||||
|
||||
result.vector[j] = (pixman_fixed_48_16_t) v;
|
||||
}
|
||||
|
||||
if (!result.vector[2])
|
||||
return FALSE;
|
||||
|
||||
*vector = result;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
pixman_bool_t
|
||||
pixman_blt (uint32_t *src_bits,
|
||||
uint32_t *dst_bits,
|
||||
int src_stride,
|
||||
int dst_stride,
|
||||
int src_bpp,
|
||||
int dst_bpp,
|
||||
int src_x, int src_y,
|
||||
int dst_x, int dst_y,
|
||||
int width, int height)
|
||||
{
|
||||
#ifdef USE_MMX
|
||||
if (pixman_have_mmx())
|
||||
{
|
||||
return pixman_blt_mmx (src_bits, dst_bits, src_stride, dst_stride, src_bpp, dst_bpp,
|
||||
src_x, src_y, dst_x, dst_y, width, height);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
pixman_fill8 (uint32_t *bits,
|
||||
int stride,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t xor)
|
||||
{
|
||||
int byte_stride = stride * sizeof (uint32_t);
|
||||
uint8_t *dst = (uint8_t *) bits;
|
||||
uint8_t v = xor & 0xff;
|
||||
int i;
|
||||
|
||||
dst = dst + y * byte_stride + x;
|
||||
|
||||
while (height--)
|
||||
{
|
||||
for (i = 0; i < width; ++i)
|
||||
dst[i] = v;
|
||||
|
||||
dst += byte_stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pixman_fill16 (uint32_t *bits,
|
||||
int stride,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t xor)
|
||||
{
|
||||
int short_stride = (stride * sizeof (uint32_t)) / sizeof (uint16_t);
|
||||
uint16_t *dst = (uint16_t *)bits;
|
||||
uint16_t v = xor & 0xffff;
|
||||
int i;
|
||||
|
||||
dst = dst + y * short_stride + x;
|
||||
|
||||
while (height--)
|
||||
{
|
||||
for (i = 0; i < width; ++i)
|
||||
dst[i] = v;
|
||||
|
||||
dst += short_stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pixman_fill32 (uint32_t *bits,
|
||||
int stride,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t xor)
|
||||
{
|
||||
int i;
|
||||
|
||||
bits = bits + y * stride + x;
|
||||
|
||||
while (height--)
|
||||
{
|
||||
for (i = 0; i < width; ++i)
|
||||
bits[i] = xor;
|
||||
|
||||
bits += stride;
|
||||
}
|
||||
}
|
||||
|
||||
pixman_bool_t
|
||||
pixman_fill (uint32_t *bits,
|
||||
int stride,
|
||||
int bpp,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t xor)
|
||||
{
|
||||
#if 0
|
||||
printf ("filling: %d %d %d %d (stride: %d, bpp: %d) pixel: %x\n",
|
||||
x, y, width, height, stride, bpp, xor);
|
||||
#endif
|
||||
|
||||
#ifdef USE_MMX
|
||||
if (!pixman_have_mmx() || !pixman_fill_mmx (bits, stride, bpp, x, y, width, height, xor))
|
||||
#endif
|
||||
{
|
||||
switch (bpp)
|
||||
{
|
||||
case 8:
|
||||
pixman_fill8 (bits, stride, x, y, width, height, xor);
|
||||
break;
|
||||
|
||||
case 16:
|
||||
pixman_fill16 (bits, stride, x, y, width, height, xor);
|
||||
break;
|
||||
|
||||
case 32:
|
||||
pixman_fill32 (bits, stride, x, y, width, height, xor);
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Compute the smallest value no less than y which is on a
|
||||
* grid row
|
||||
*/
|
||||
|
||||
pixman_fixed_t
|
||||
pixman_sample_ceil_y (pixman_fixed_t y, int n)
|
||||
{
|
||||
pixman_fixed_t f = pixman_fixed_frac(y);
|
||||
pixman_fixed_t i = pixman_fixed_floor(y);
|
||||
|
||||
f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
|
||||
if (f > Y_FRAC_LAST(n))
|
||||
{
|
||||
f = Y_FRAC_FIRST(n);
|
||||
i += pixman_fixed_1;
|
||||
}
|
||||
return (i | f);
|
||||
}
|
||||
|
||||
#define _div(a,b) ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b)))
|
||||
|
||||
/*
|
||||
* Compute the largest value no greater than y which is on a
|
||||
* grid row
|
||||
*/
|
||||
pixman_fixed_t
|
||||
pixman_sample_floor_y (pixman_fixed_t y, int n)
|
||||
{
|
||||
pixman_fixed_t f = pixman_fixed_frac(y);
|
||||
pixman_fixed_t i = pixman_fixed_floor (y);
|
||||
|
||||
f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
|
||||
if (f < Y_FRAC_FIRST(n))
|
||||
{
|
||||
f = Y_FRAC_LAST(n);
|
||||
i -= pixman_fixed_1;
|
||||
}
|
||||
return (i | f);
|
||||
}
|
||||
|
||||
/*
|
||||
* Step an edge by any amount (including negative values)
|
||||
*/
|
||||
void
|
||||
pixman_edge_step (pixman_edge_t *e, int n)
|
||||
{
|
||||
pixman_fixed_48_16_t ne;
|
||||
|
||||
e->x += n * e->stepx;
|
||||
|
||||
ne = e->e + n * (pixman_fixed_48_16_t) e->dx;
|
||||
|
||||
if (n >= 0)
|
||||
{
|
||||
if (ne > 0)
|
||||
{
|
||||
int nx = (ne + e->dy - 1) / e->dy;
|
||||
e->e = ne - nx * (pixman_fixed_48_16_t) e->dy;
|
||||
e->x += nx * e->signdx;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ne <= -e->dy)
|
||||
{
|
||||
int nx = (-ne) / e->dy;
|
||||
e->e = ne + nx * (pixman_fixed_48_16_t) e->dy;
|
||||
e->x -= nx * e->signdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A private routine to initialize the multi-step
|
||||
* elements of an edge structure
|
||||
*/
|
||||
static void
|
||||
_pixman_edge_tMultiInit (pixman_edge_t *e, int n, pixman_fixed_t *stepx_p, pixman_fixed_t *dx_p)
|
||||
{
|
||||
pixman_fixed_t stepx;
|
||||
pixman_fixed_48_16_t ne;
|
||||
|
||||
ne = n * (pixman_fixed_48_16_t) e->dx;
|
||||
stepx = n * e->stepx;
|
||||
if (ne > 0)
|
||||
{
|
||||
int nx = ne / e->dy;
|
||||
ne -= nx * e->dy;
|
||||
stepx += nx * e->signdx;
|
||||
}
|
||||
*dx_p = ne;
|
||||
*stepx_p = stepx;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize one edge structure given the line endpoints and a
|
||||
* starting y value
|
||||
*/
|
||||
void
|
||||
pixman_edge_init (pixman_edge_t *e,
|
||||
int n,
|
||||
pixman_fixed_t y_start,
|
||||
pixman_fixed_t x_top,
|
||||
pixman_fixed_t y_top,
|
||||
pixman_fixed_t x_bot,
|
||||
pixman_fixed_t y_bot)
|
||||
{
|
||||
pixman_fixed_t dx, dy;
|
||||
|
||||
e->x = x_top;
|
||||
e->e = 0;
|
||||
dx = x_bot - x_top;
|
||||
dy = y_bot - y_top;
|
||||
e->dy = dy;
|
||||
e->dx = 0;
|
||||
if (dy)
|
||||
{
|
||||
if (dx >= 0)
|
||||
{
|
||||
e->signdx = 1;
|
||||
e->stepx = dx / dy;
|
||||
e->dx = dx % dy;
|
||||
e->e = -dy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e->signdx = -1;
|
||||
e->stepx = -(-dx / dy);
|
||||
e->dx = -dx % dy;
|
||||
e->e = 0;
|
||||
}
|
||||
|
||||
_pixman_edge_tMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small);
|
||||
_pixman_edge_tMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big);
|
||||
}
|
||||
pixman_edge_step (e, y_start - y_top);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize one edge structure given a line, starting y value
|
||||
* and a pixel offset for the line
|
||||
*/
|
||||
void
|
||||
pixman_line_fixed_edge_init (pixman_edge_t *e,
|
||||
int n,
|
||||
pixman_fixed_t y,
|
||||
const pixman_line_fixed_t *line,
|
||||
int x_off,
|
||||
int y_off)
|
||||
{
|
||||
pixman_fixed_t x_off_fixed = pixman_int_to_fixed(x_off);
|
||||
pixman_fixed_t y_off_fixed = pixman_int_to_fixed(y_off);
|
||||
const pixman_point_fixed_t *top, *bot;
|
||||
|
||||
if (line->p1.y <= line->p2.y)
|
||||
{
|
||||
top = &line->p1;
|
||||
bot = &line->p2;
|
||||
}
|
||||
else
|
||||
{
|
||||
top = &line->p2;
|
||||
bot = &line->p1;
|
||||
}
|
||||
pixman_edge_init (e, n, y,
|
||||
top->x + x_off_fixed,
|
||||
top->y + y_off_fixed,
|
||||
bot->x + x_off_fixed,
|
||||
bot->y + y_off_fixed);
|
||||
}
|
||||
|
||||
void *
|
||||
pixman_malloc_ab(unsigned int a,
|
||||
unsigned int b)
|
||||
{
|
||||
if (a >= INT32_MAX / b)
|
||||
return NULL;
|
||||
|
||||
return malloc (a * b);
|
||||
}
|
||||
|
||||
void *
|
||||
pixman_malloc_abc (unsigned int a,
|
||||
unsigned int b,
|
||||
unsigned int c)
|
||||
{
|
||||
if (a >= INT32_MAX / b)
|
||||
return NULL;
|
||||
else if (a * b >= INT32_MAX / c)
|
||||
return NULL;
|
||||
else
|
||||
return malloc (a * b * c);
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Red Hat, 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 Red Hat,
|
||||
* Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior
|
||||
* permission. Red Hat, Inc. makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL RED HAT, INC. 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, Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _PIXMAN_XSERVER_COMPAT_H_
|
||||
#define _PIXMAN_XSERVER_COMPAT_H_
|
||||
|
||||
/* This is a compatibility header file, designed to make it easier to
|
||||
* synchronize files between libpixman and the xserver repository.
|
||||
*
|
||||
* Of course, long-term we would instead like to have the X server
|
||||
* depend on libpixman to eliminate the code duplication. But for now,
|
||||
* we at least make it easy to share files.
|
||||
*
|
||||
* The libpixman code base regards the xserver repository as canonical
|
||||
* for any shared files, so changes should be pushed up there. Then,
|
||||
* to merge changes back down into libpixman, the process should be to
|
||||
* simply copy the file and to replace the block of include directives
|
||||
* with:
|
||||
*
|
||||
* #include "pixman-xserver-compat.h"
|
||||
*/
|
||||
|
||||
/* First, include the primary internal header file for libpixman. */
|
||||
|
||||
#include "icint.h"
|
||||
|
||||
/* Then, define any names that the server code will be expecting in
|
||||
* terms of libpixman names. */
|
||||
/*
|
||||
typedef uint8_t CARD8;
|
||||
typedef uint16_t CARD16;
|
||||
typedef int16_t INT16;
|
||||
|
||||
typedef int Bool;
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
typedef pixman_bits_t FbBits;
|
||||
typedef pixman_image_t* PicturePtr;
|
||||
typedef pixman_box16_t BoxRec;
|
||||
typedef pixman_box16_t* BoxPtr;
|
||||
|
||||
typedef pixman_point_fixed_t xPointFixed;
|
||||
typedef pixman_line_fixed_t xLineFixed;
|
||||
typedef pixman_trapezoid_t xTrapezoid;
|
||||
typedef pixman_triangle_t xTriangle;
|
||||
*/
|
||||
#define RENDER 1
|
||||
/*
|
||||
#define FB_SHIFT IC_SHIFT
|
||||
#define FB_MASK IC_MASK
|
||||
#define FB_ALLONES IC_ALLONES
|
||||
#define FbMaskBits IcMaskBits
|
||||
*/
|
||||
|
||||
/* XXX: We changed some function and field names which makes for some
|
||||
* ugly hacks... */
|
||||
#define pDrawable pixels
|
||||
#define fbGetDrawable(pDrawable, buf, outstride, outbpp, xoff, yoff) { \
|
||||
(buf) = (pDrawable)->data; \
|
||||
(outstride) = ((int) pDrawable->stride) / sizeof (pixman_bits_t); \
|
||||
(outbpp) = (pDrawable)->bpp; \
|
||||
(xoff) = 0; \
|
||||
(yoff) = 0; \
|
||||
}
|
||||
|
||||
/* Extended repeat attributes included in 0.10 */
|
||||
#define RepeatNone 0
|
||||
#define RepeatNormal 1
|
||||
#define RepeatPad 2
|
||||
#define RepeatReflect 3
|
||||
|
||||
typedef pixman_vector_t PictVector;
|
||||
typedef pixman_vector_t* PictVectorPtr;
|
||||
|
||||
#define miIndexedPtr FbIndexedPtr
|
||||
#define miIndexToEnt24 FbIndexToEnt24
|
||||
#define miIndexToEntY24 FbIndexToEntY24
|
||||
|
||||
#define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff)
|
||||
#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31))
|
||||
|
||||
/* Then, include any header files that have been copied directly
|
||||
* from xserver. */
|
||||
|
||||
#include "renderedge.h"
|
||||
|
||||
/* And finally, this one prototype must come after the include of
|
||||
* renderedge.h, so it can't live alongside the other prototypes in
|
||||
* the horrible mess that is icint.h.
|
||||
*/
|
||||
|
||||
pixman_private void
|
||||
fbRasterizeEdges (pixman_bits_t *buf,
|
||||
int bpp,
|
||||
int width,
|
||||
int stride,
|
||||
RenderEdge *l,
|
||||
RenderEdge *r,
|
||||
pixman_fixed16_16_t t,
|
||||
pixman_fixed16_16_t b);
|
||||
|
||||
#endif
|
|
@ -1,10 +1,3 @@
|
|||
#ifndef _PIXMAN_H_
|
||||
#define _PIXMAN_H_
|
||||
|
||||
/* pixman.h - a merge of pixregion.h and ic.h */
|
||||
|
||||
/* from pixregion.h */
|
||||
|
||||
/***********************************************************
|
||||
|
||||
Copyright 1987, 1998 The Open Group
|
||||
|
@ -50,10 +43,9 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|||
SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
/* libic.h */
|
||||
|
||||
/*
|
||||
* Copyright © 1998 Keith Packard
|
||||
* Copyright © 1998, 2004 Keith Packard
|
||||
* Copyright 2007 Red Hat, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
|
@ -74,455 +66,548 @@ SOFTWARE.
|
|||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#elif HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#elif HAVE_SYS_INT_TYPES_H
|
||||
# include <sys/int_types.h>
|
||||
#elif defined(_MSC_VER)
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.)
|
||||
#endif
|
||||
#ifndef PIXMAN_H__
|
||||
#define PIXMAN_H__
|
||||
|
||||
#include "pixman-remap.h"
|
||||
|
||||
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun__)
|
||||
#define pixman_private __attribute__((__visibility__("hidden")))
|
||||
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
|
||||
#define pixman_private __hidden
|
||||
#else /* not gcc >= 3.3 and not Sun Studio >= 8 */
|
||||
#define pixman_private
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* pixregion.h */
|
||||
|
||||
typedef struct pixman_region16 pixman_region16_t;
|
||||
|
||||
typedef struct pixman_box16 {
|
||||
short x1, y1, x2, y2;
|
||||
} pixman_box16_t;
|
||||
|
||||
typedef enum {
|
||||
PIXMAN_REGION_STATUS_FAILURE,
|
||||
PIXMAN_REGION_STATUS_SUCCESS
|
||||
} pixman_region_status_t;
|
||||
|
||||
/* creation/destruction */
|
||||
|
||||
pixman_private pixman_region16_t *
|
||||
pixman_region_create (void);
|
||||
|
||||
pixman_private pixman_region16_t *
|
||||
pixman_region_create_simple (pixman_box16_t *extents);
|
||||
|
||||
pixman_private void
|
||||
pixman_region_destroy (pixman_region16_t *region);
|
||||
|
||||
/* manipulation */
|
||||
|
||||
pixman_private void
|
||||
pixman_region_translate (pixman_region16_t *region, int x, int y);
|
||||
|
||||
pixman_private pixman_region_status_t
|
||||
pixman_region_copy (pixman_region16_t *dest, pixman_region16_t *source);
|
||||
|
||||
pixman_private pixman_region_status_t
|
||||
pixman_region_intersect (pixman_region16_t *newReg, pixman_region16_t *reg1, pixman_region16_t *reg2);
|
||||
|
||||
pixman_private pixman_region_status_t
|
||||
pixman_region_union (pixman_region16_t *newReg, pixman_region16_t *reg1, pixman_region16_t *reg2);
|
||||
|
||||
pixman_private pixman_region_status_t
|
||||
pixman_region_union_rect(pixman_region16_t *dest, pixman_region16_t *source,
|
||||
int x, int y, unsigned int width, unsigned int height);
|
||||
|
||||
pixman_private pixman_region_status_t
|
||||
pixman_region_subtract (pixman_region16_t *regD, pixman_region16_t *regM, pixman_region16_t *regS);
|
||||
|
||||
pixman_private pixman_region_status_t
|
||||
pixman_region_inverse (pixman_region16_t *newReg, pixman_region16_t *reg1, pixman_box16_t *invRect);
|
||||
|
||||
/* XXX: Need to fix this so it doesn't depend on an X data structure
|
||||
pixman_region16_t *
|
||||
RectsTopixman_region16_t (int nrects, xRectanglePtr prect, int ctype);
|
||||
*/
|
||||
|
||||
/* querying */
|
||||
|
||||
/* XXX: These should proably be combined: pixman_region_get_rects? */
|
||||
pixman_private int
|
||||
pixman_region_num_rects (pixman_region16_t *region);
|
||||
|
||||
pixman_private pixman_box16_t *
|
||||
pixman_region_rects (pixman_region16_t *region);
|
||||
|
||||
/* XXX: Change to an enum */
|
||||
#define rgnOUT 0
|
||||
#define rgnIN 1
|
||||
#define rgnPART 2
|
||||
|
||||
pixman_private int
|
||||
pixman_region_contains_point (pixman_region16_t *region, int x, int y, pixman_box16_t *box);
|
||||
|
||||
pixman_private int
|
||||
pixman_region_contains_rectangle (pixman_region16_t *pixman_region16_t, pixman_box16_t *prect);
|
||||
|
||||
pixman_private int
|
||||
pixman_region_not_empty (pixman_region16_t *region);
|
||||
|
||||
pixman_private pixman_box16_t *
|
||||
pixman_region_extents (pixman_region16_t *region);
|
||||
|
||||
/* mucking around */
|
||||
|
||||
/* WARNING: calling pixman_region_append may leave dest as an invalid
|
||||
region. Follow-up with pixman_region_validate to fix it up. */
|
||||
pixman_private pixman_region_status_t
|
||||
pixman_region_append (pixman_region16_t *dest, pixman_region16_t *region);
|
||||
|
||||
pixman_private pixman_region_status_t
|
||||
pixman_region_validate (pixman_region16_t *badreg, int *pOverlap);
|
||||
|
||||
/* Unclassified functionality
|
||||
* XXX: Do all of these need to be exported?
|
||||
/*
|
||||
* Standard integers
|
||||
*/
|
||||
|
||||
pixman_private void
|
||||
pixman_region_reset (pixman_region16_t *region, pixman_box16_t *pBox);
|
||||
|
||||
pixman_private void
|
||||
pixman_region_empty (pixman_region16_t *region);
|
||||
|
||||
/* ic.h */
|
||||
|
||||
/* icformat.c */
|
||||
typedef enum pixman_operator {
|
||||
PIXMAN_OPERATOR_CLEAR,
|
||||
PIXMAN_OPERATOR_SRC,
|
||||
PIXMAN_OPERATOR_DST,
|
||||
PIXMAN_OPERATOR_OVER,
|
||||
PIXMAN_OPERATOR_OVER_REVERSE,
|
||||
PIXMAN_OPERATOR_IN,
|
||||
PIXMAN_OPERATOR_IN_REVERSE,
|
||||
PIXMAN_OPERATOR_OUT,
|
||||
PIXMAN_OPERATOR_OUT_REVERSE,
|
||||
PIXMAN_OPERATOR_ATOP,
|
||||
PIXMAN_OPERATOR_ATOP_REVERSE,
|
||||
PIXMAN_OPERATOR_XOR,
|
||||
PIXMAN_OPERATOR_ADD,
|
||||
PIXMAN_OPERATOR_SATURATE
|
||||
} pixman_operator_t;
|
||||
|
||||
typedef enum pixman_format_name {
|
||||
PIXMAN_FORMAT_NAME_ARGB32,
|
||||
PIXMAN_FORMAT_NAME_RGB24,
|
||||
PIXMAN_FORMAT_NAME_A8,
|
||||
PIXMAN_FORMAT_NAME_A1,
|
||||
PIXMAN_FORMAT_NAME_RGB16_565,
|
||||
PIXMAN_FORMAT_NAME_ABGR32,
|
||||
PIXMAN_FORMAT_NAME_BGR24
|
||||
} pixman_format_name_t;
|
||||
|
||||
typedef struct pixman_format pixman_format_t;
|
||||
|
||||
pixman_private pixman_format_t *
|
||||
pixman_format_create (pixman_format_name_t name);
|
||||
|
||||
pixman_private pixman_format_t *
|
||||
pixman_format_create_masks (int bpp,
|
||||
int alpha_mask,
|
||||
int red_mask,
|
||||
int green_mask,
|
||||
int blue_mask);
|
||||
|
||||
pixman_private void
|
||||
pixman_format_destroy (pixman_format_t *format);
|
||||
|
||||
pixman_private void
|
||||
pixman_format_get_masks (pixman_format_t *format,
|
||||
unsigned int *bpp,
|
||||
unsigned int *alpha_mask,
|
||||
unsigned int *red_mask,
|
||||
unsigned int *green_mask,
|
||||
unsigned int *blue_mask);
|
||||
|
||||
/* icimage.c */
|
||||
|
||||
typedef struct pixman_image pixman_image_t;
|
||||
|
||||
pixman_private pixman_image_t *
|
||||
pixman_image_create (pixman_format_t *format,
|
||||
int width,
|
||||
int height);
|
||||
#if defined (__SVR4) && defined (__sun)
|
||||
# include <sys/int_types.h>
|
||||
#elif defined (__OpenBSD__)
|
||||
# include <inttypes.h>
|
||||
#elif defined (_MSC_VER)
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This single define controls the basic size of data manipulated
|
||||
* by this software; it must be log2(sizeof (pixman_bits_t) * 8)
|
||||
* Boolean
|
||||
*/
|
||||
typedef int pixman_bool_t;
|
||||
|
||||
/* We use a 32-bit size on all platforms, (even those with native 64
|
||||
* bit types). This is consistent with the code currently in the X
|
||||
* server, so it goes through much more well-tested code paths, (we
|
||||
* saw rendering bugs when we tried IC_SHIFT==6 and uint64_t for
|
||||
* pixman_bits_t on 64-bit platofrms). In addition, Keith says that
|
||||
* his testing indicates that using 32-bits everywhere is a
|
||||
* performance win in any case, (presumably due to 32-bit datapaths
|
||||
* between the processor and the video card).
|
||||
*/
|
||||
#ifndef IC_SHIFT
|
||||
#define IC_SHIFT 5
|
||||
#define FB_SHIFT IC_SHIFT
|
||||
typedef uint32_t pixman_bits_t;
|
||||
#endif
|
||||
/*
|
||||
* Fixpoint numbers
|
||||
*/
|
||||
typedef int64_t pixman_fixed_32_32_t;
|
||||
typedef pixman_fixed_32_32_t pixman_fixed_48_16_t;
|
||||
typedef uint32_t pixman_fixed_1_31_t;
|
||||
typedef uint32_t pixman_fixed_1_16_t;
|
||||
typedef int32_t pixman_fixed_16_16_t;
|
||||
typedef pixman_fixed_16_16_t pixman_fixed_t;
|
||||
|
||||
pixman_private pixman_image_t *
|
||||
pixman_image_create_for_data (pixman_bits_t *data,
|
||||
pixman_format_t *format,
|
||||
int width, int height,
|
||||
int bpp, int stride);
|
||||
#define pixman_fixed_e ((pixman_fixed_t) 1)
|
||||
#define pixman_fixed_1 (pixman_int_to_fixed(1))
|
||||
#define pixman_fixed_1_minus_e (pixman_fixed_1 - pixman_fixed_e)
|
||||
#define pixman_fixed_to_int(f) ((int) ((f) >> 16))
|
||||
#define pixman_int_to_fixed(i) ((pixman_fixed_t) ((i) << 16))
|
||||
#define pixman_fixed_to_double(f) (double) ((f) / (double) pixman_fixed_1)
|
||||
#define pixman_double_to_fixed(d) ((pixman_fixed_t) ((d) * 65536.0))
|
||||
#define pixman_fixed_frac(f) ((f) & pixman_fixed_1_minus_e)
|
||||
#define pixman_fixed_floor(f) ((f) & ~pixman_fixed_1_minus_e)
|
||||
#define pixman_fixed_ceil(f) pixman_fixed_floor ((f) + pixman_fixed_1_minus_e)
|
||||
#define pixman_fixed_fraction(f) ((f) & pixman_fixed_1_minus_e)
|
||||
#define pixman_fixed_mod_2(f) ((f) & (pixman_fixed1 | pixman_fixed_1_minus_e))
|
||||
#define pixman_max_fixed_48_16 ((pixman_fixed_48_16_t) 0x7fffffff)
|
||||
#define pixman_min_fixed_48_16 (-((pixman_fixed_48_16_t) 1 << 31))
|
||||
|
||||
pixman_private void
|
||||
pixman_image_destroy (pixman_image_t *image);
|
||||
/*
|
||||
* Misc structs
|
||||
*/
|
||||
typedef struct pixman_color pixman_color_t;
|
||||
typedef struct pixman_point_fixed pixman_point_fixed_t;
|
||||
typedef struct pixman_line_fixed pixman_line_fixed_t;
|
||||
typedef struct pixman_vector pixman_vector_t;
|
||||
typedef struct pixman_transform pixman_transform_t;
|
||||
|
||||
pixman_private int
|
||||
pixman_image_set_clip_region (pixman_image_t *image,
|
||||
pixman_region16_t *region);
|
||||
struct pixman_color
|
||||
{
|
||||
uint16_t red;
|
||||
uint16_t green;
|
||||
uint16_t blue;
|
||||
uint16_t alpha;
|
||||
};
|
||||
|
||||
typedef int32_t pixman_fixed16_16_t;
|
||||
struct pixman_point_fixed
|
||||
{
|
||||
pixman_fixed_t x;
|
||||
pixman_fixed_t y;
|
||||
};
|
||||
|
||||
typedef struct pixman_point_fixed {
|
||||
pixman_fixed16_16_t x, y;
|
||||
} pixman_point_fixed_t;
|
||||
|
||||
typedef struct pixman_line_fixed {
|
||||
struct pixman_line_fixed
|
||||
{
|
||||
pixman_point_fixed_t p1, p2;
|
||||
} pixman_line_fixed_t;
|
||||
};
|
||||
|
||||
/* XXX: It's goofy that pixman_rectangle_t has integers while all the other
|
||||
datatypes have fixed-point values. (Though by design,
|
||||
pixman_fill_rectangles is designed to fill only whole pixels) */
|
||||
typedef struct pixman_rectangle {
|
||||
short x, y;
|
||||
unsigned short width, height;
|
||||
} pixman_rectangle_t;
|
||||
struct pixman_vector
|
||||
{
|
||||
pixman_fixed_t vector[3];
|
||||
};
|
||||
|
||||
typedef struct pixman_triangle {
|
||||
pixman_point_fixed_t p1, p2, p3;
|
||||
} pixman_triangle_t;
|
||||
struct pixman_transform
|
||||
{
|
||||
pixman_fixed_t matrix[3][3];
|
||||
};
|
||||
|
||||
typedef struct pixman_trapezoid {
|
||||
pixman_fixed16_16_t top, bottom;
|
||||
pixman_line_fixed_t left, right;
|
||||
} pixman_trapezoid_t;
|
||||
|
||||
typedef struct pixman_vector {
|
||||
pixman_fixed16_16_t vector[3];
|
||||
} pixman_vector_t;
|
||||
|
||||
typedef struct pixman_transform {
|
||||
pixman_fixed16_16_t matrix[3][3];
|
||||
} pixman_transform_t;
|
||||
|
||||
typedef struct pixman_color {
|
||||
unsigned short red;
|
||||
unsigned short green;
|
||||
unsigned short blue;
|
||||
unsigned short alpha;
|
||||
} pixman_color_t;
|
||||
|
||||
typedef struct _pixman_gradient_stop {
|
||||
pixman_fixed16_16_t x;
|
||||
pixman_color_t color;
|
||||
} pixman_gradient_stop_t;
|
||||
|
||||
typedef struct _pixman_circle {
|
||||
pixman_fixed16_16_t x;
|
||||
pixman_fixed16_16_t y;
|
||||
pixman_fixed16_16_t radius;
|
||||
} pixman_circle_t;
|
||||
|
||||
typedef struct pixman_linear_gradient {
|
||||
pixman_point_fixed_t p1;
|
||||
pixman_point_fixed_t p2;
|
||||
} pixman_linear_gradient_t;
|
||||
|
||||
typedef struct pixman_radial_gradient {
|
||||
pixman_circle_t c1;
|
||||
pixman_circle_t c2;
|
||||
} pixman_radial_gradient_t;
|
||||
|
||||
typedef enum {
|
||||
PIXMAN_FILTER_FAST,
|
||||
PIXMAN_FILTER_GOOD,
|
||||
PIXMAN_FILTER_BEST,
|
||||
PIXMAN_FILTER_NEAREST,
|
||||
PIXMAN_FILTER_BILINEAR
|
||||
} pixman_filter_t;
|
||||
|
||||
pixman_private void
|
||||
pixman_image_set_component_alpha (pixman_image_t *image,
|
||||
int component_alpha);
|
||||
|
||||
pixman_private int
|
||||
pixman_image_set_transform (pixman_image_t *image,
|
||||
pixman_transform_t *transform);
|
||||
pixman_bool_t pixman_transform_point_3d (pixman_transform_t *transform,
|
||||
pixman_vector_t *vector);
|
||||
|
||||
/* Don't blame me, blame XRender */
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
PIXMAN_REPEAT_NONE,
|
||||
PIXMAN_REPEAT_NORMAL,
|
||||
PIXMAN_REPEAT_PAD,
|
||||
PIXMAN_REPEAT_REFLECT
|
||||
} pixman_repeat_t;
|
||||
|
||||
pixman_private void
|
||||
pixman_image_set_repeat (pixman_image_t *image,
|
||||
pixman_repeat_t repeat);
|
||||
typedef enum
|
||||
{
|
||||
PIXMAN_FILTER_FAST,
|
||||
PIXMAN_FILTER_GOOD,
|
||||
PIXMAN_FILTER_BEST,
|
||||
PIXMAN_FILTER_NEAREST,
|
||||
PIXMAN_FILTER_BILINEAR,
|
||||
PIXMAN_FILTER_CONVOLUTION
|
||||
} pixman_filter_t;
|
||||
|
||||
pixman_private void
|
||||
pixman_image_set_filter (pixman_image_t *image,
|
||||
pixman_filter_t filter);
|
||||
typedef enum
|
||||
{
|
||||
PIXMAN_OP_CLEAR,
|
||||
PIXMAN_OP_SRC,
|
||||
PIXMAN_OP_DST,
|
||||
PIXMAN_OP_OVER,
|
||||
PIXMAN_OP_OVER_REVERSE,
|
||||
PIXMAN_OP_IN,
|
||||
PIXMAN_OP_IN_REVERSE,
|
||||
PIXMAN_OP_OUT,
|
||||
PIXMAN_OP_OUT_REVERSE,
|
||||
PIXMAN_OP_ATOP,
|
||||
PIXMAN_OP_ATOP_REVERSE,
|
||||
PIXMAN_OP_XOR,
|
||||
PIXMAN_OP_ADD,
|
||||
PIXMAN_OP_SATURATE
|
||||
} pixman_op_t;
|
||||
|
||||
pixman_private int
|
||||
pixman_image_get_width (pixman_image_t *image);
|
||||
/*
|
||||
* Regions
|
||||
*/
|
||||
typedef struct pixman_region16_data pixman_region16_data_t;
|
||||
typedef struct pixman_box16 pixman_box16_t;
|
||||
typedef struct pixman_rectangle16 pixman_rectangle16_t;
|
||||
typedef struct pixman_region16 pixman_region16_t;
|
||||
|
||||
pixman_private int
|
||||
pixman_image_get_height (pixman_image_t *image);
|
||||
struct pixman_region16_data {
|
||||
long size;
|
||||
long numRects;
|
||||
/* pixman_box16_t rects[size]; in memory but not explicitly declared */
|
||||
};
|
||||
|
||||
pixman_private int
|
||||
pixman_image_get_stride (pixman_image_t *image);
|
||||
struct pixman_rectangle16
|
||||
{
|
||||
int16_t x, y;
|
||||
uint16_t width, height;
|
||||
};
|
||||
|
||||
pixman_private int
|
||||
pixman_image_get_depth (pixman_image_t *image);
|
||||
struct pixman_box16
|
||||
{
|
||||
int16_t x1, y1, x2, y2;
|
||||
};
|
||||
|
||||
pixman_private pixman_format_t *
|
||||
pixman_image_get_format (pixman_image_t *image);
|
||||
struct pixman_region16
|
||||
{
|
||||
pixman_box16_t extents;
|
||||
pixman_region16_data_t *data;
|
||||
};
|
||||
|
||||
pixman_private pixman_bits_t *
|
||||
pixman_image_get_data (pixman_image_t *image);
|
||||
typedef enum
|
||||
{
|
||||
PIXMAN_REGION_OUT,
|
||||
PIXMAN_REGION_IN,
|
||||
PIXMAN_REGION_PART
|
||||
} pixman_region_overlap_t;
|
||||
|
||||
pixman_private pixman_image_t *
|
||||
pixman_image_create_linear_gradient (const pixman_linear_gradient_t *gradient,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops);
|
||||
/* This function exists only to make it possible to preserve the X ABI - it should
|
||||
* go away at first opportunity.
|
||||
*/
|
||||
void pixman_region_set_static_pointers (pixman_box16_t *empty_box,
|
||||
pixman_region16_data_t *empty_data,
|
||||
pixman_region16_data_t *broken_data);
|
||||
|
||||
pixman_private pixman_image_t *
|
||||
pixman_image_create_radial_gradient (const pixman_radial_gradient_t *gradient,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops);
|
||||
/* creation/destruction */
|
||||
void pixman_region_init (pixman_region16_t *region);
|
||||
void pixman_region_init_rect (pixman_region16_t *region,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int width,
|
||||
unsigned int height);
|
||||
void pixman_region_init_with_extents (pixman_region16_t *region,
|
||||
pixman_box16_t *extents);
|
||||
void pixman_region_fini (pixman_region16_t *region);
|
||||
|
||||
/* iccolor.c */
|
||||
/* manipulation */
|
||||
void pixman_region_translate (pixman_region16_t *region,
|
||||
int x,
|
||||
int y);
|
||||
pixman_bool_t pixman_region_copy (pixman_region16_t *dest,
|
||||
pixman_region16_t *source);
|
||||
pixman_bool_t pixman_region_intersect (pixman_region16_t *newReg,
|
||||
pixman_region16_t *reg1,
|
||||
pixman_region16_t *reg2);
|
||||
pixman_bool_t pixman_region_union (pixman_region16_t *newReg,
|
||||
pixman_region16_t *reg1,
|
||||
pixman_region16_t *reg2);
|
||||
pixman_bool_t pixman_region_union_rect (pixman_region16_t *dest,
|
||||
pixman_region16_t *source,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int width,
|
||||
unsigned int height);
|
||||
pixman_bool_t pixman_region_subtract (pixman_region16_t *regD,
|
||||
pixman_region16_t *regM,
|
||||
pixman_region16_t *regS);
|
||||
pixman_bool_t pixman_region_inverse (pixman_region16_t *newReg,
|
||||
pixman_region16_t *reg1,
|
||||
pixman_box16_t *invRect);
|
||||
pixman_bool_t pixman_region_contains_point (pixman_region16_t *region, int x, int y, pixman_box16_t *box);
|
||||
pixman_region_overlap_t pixman_region_contains_rectangle (pixman_region16_t *pixman_region16_t, pixman_box16_t *prect);
|
||||
pixman_bool_t pixman_region_not_empty (pixman_region16_t *region);
|
||||
pixman_box16_t * pixman_region_extents (pixman_region16_t *region);
|
||||
int pixman_region_n_rects (pixman_region16_t *region);
|
||||
pixman_box16_t * pixman_region_rectangles (pixman_region16_t *region,
|
||||
int *n_rects);
|
||||
pixman_bool_t pixman_region_equal (pixman_region16_t *region1,
|
||||
pixman_region16_t *region2);
|
||||
pixman_bool_t pixman_region_selfcheck (pixman_region16_t *region);
|
||||
void pixman_region_reset(pixman_region16_t *region, pixman_box16_t *box);
|
||||
pixman_bool_t pixman_region_init_rects (pixman_region16_t *region,
|
||||
pixman_box16_t *boxes, int count);
|
||||
|
||||
pixman_private void
|
||||
pixman_color_to_pixel (const pixman_format_t *format,
|
||||
const pixman_color_t *color,
|
||||
pixman_bits_t *pixel);
|
||||
/* Copy / Fill */
|
||||
pixman_bool_t pixman_blt (uint32_t *src_bits,
|
||||
uint32_t *dst_bits,
|
||||
int src_stride,
|
||||
int dst_stride,
|
||||
int src_bpp,
|
||||
int dst_bpp,
|
||||
int src_x, int src_y,
|
||||
int dst_x, int dst_y,
|
||||
int width, int height);
|
||||
pixman_bool_t pixman_fill (uint32_t *bits,
|
||||
int stride,
|
||||
int bpp,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t xor);
|
||||
/*
|
||||
* Images
|
||||
*/
|
||||
typedef union pixman_image pixman_image_t;
|
||||
typedef struct pixman_indexed pixman_indexed_t;
|
||||
typedef struct pixman_gradient_stop pixman_gradient_stop_t;
|
||||
|
||||
pixman_private void
|
||||
pixman_pixel_to_color (const pixman_format_t *format,
|
||||
pixman_bits_t pixel,
|
||||
pixman_color_t *color);
|
||||
typedef uint32_t (* pixman_read_memory_func_t) (const void *src, int size);
|
||||
typedef void (* pixman_write_memory_func_t) (void *dst, uint32_t value, int size);
|
||||
|
||||
/* icrect.c */
|
||||
struct pixman_gradient_stop {
|
||||
pixman_fixed_t x;
|
||||
pixman_color_t color;
|
||||
};
|
||||
|
||||
pixman_private void
|
||||
pixman_fill_rectangle (pixman_operator_t op,
|
||||
pixman_image_t *dst,
|
||||
const pixman_color_t *color,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int width,
|
||||
unsigned int height);
|
||||
#define PIXMAN_MAX_INDEXED 256 /* XXX depth must be <= 8 */
|
||||
|
||||
pixman_private void
|
||||
pixman_fill_rectangles (pixman_operator_t op,
|
||||
pixman_image_t *dst,
|
||||
const pixman_color_t *color,
|
||||
const pixman_rectangle_t *rects,
|
||||
int nRects);
|
||||
|
||||
/* ictrap.c */
|
||||
|
||||
pixman_private void
|
||||
pixman_composite_trapezoids (pixman_operator_t op,
|
||||
pixman_image_t *src,
|
||||
pixman_image_t *dst,
|
||||
int xSrc,
|
||||
int ySrc,
|
||||
const pixman_trapezoid_t *traps,
|
||||
int ntrap);
|
||||
|
||||
pixman_private void
|
||||
pixman_add_trapezoids (pixman_image_t *dst,
|
||||
int x_off,
|
||||
int y_off,
|
||||
const pixman_trapezoid_t *traps,
|
||||
int ntraps);
|
||||
|
||||
/* ictri.c */
|
||||
|
||||
pixman_private void
|
||||
pixman_composite_triangles (pixman_operator_t op,
|
||||
pixman_image_t *src,
|
||||
pixman_image_t *dst,
|
||||
int xSrc,
|
||||
int ySrc,
|
||||
const pixman_triangle_t *tris,
|
||||
int ntris);
|
||||
|
||||
pixman_private void
|
||||
pixman_composite_tri_strip (pixman_operator_t op,
|
||||
pixman_image_t *src,
|
||||
pixman_image_t *dst,
|
||||
int xSrc,
|
||||
int ySrc,
|
||||
const pixman_point_fixed_t *points,
|
||||
int npoints);
|
||||
|
||||
pixman_private void
|
||||
pixman_composite_tri_fan (pixman_operator_t op,
|
||||
pixman_image_t *src,
|
||||
pixman_image_t *dst,
|
||||
int xSrc,
|
||||
int ySrc,
|
||||
const pixman_point_fixed_t *points,
|
||||
int npoints);
|
||||
|
||||
/* ic.c */
|
||||
|
||||
pixman_private void
|
||||
pixman_composite (pixman_operator_t op,
|
||||
pixman_image_t *iSrc,
|
||||
pixman_image_t *iMask,
|
||||
pixman_image_t *iDst,
|
||||
int xSrc,
|
||||
int ySrc,
|
||||
int xMask,
|
||||
int yMask,
|
||||
int xDst,
|
||||
int yDst,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
}
|
||||
#if PIXMAN_MAX_INDEXED <= 256
|
||||
typedef uint8_t pixman_index_type;
|
||||
#endif
|
||||
|
||||
#endif /* _PIXMAN_H_ */
|
||||
struct pixman_indexed
|
||||
{
|
||||
pixman_bool_t color;
|
||||
uint32_t rgba[PIXMAN_MAX_INDEXED];
|
||||
pixman_index_type ent[32768];
|
||||
};
|
||||
|
||||
/*
|
||||
* 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 PIXMAN_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \
|
||||
((type) << 16) | \
|
||||
((a) << 12) | \
|
||||
((r) << 8) | \
|
||||
((g) << 4) | \
|
||||
((b)))
|
||||
|
||||
#define PIXMAN_FORMAT_BPP(f) (((f) >> 24) )
|
||||
#define PIXMAN_FORMAT_TYPE(f) (((f) >> 16) & 0xff)
|
||||
#define PIXMAN_FORMAT_A(f) (((f) >> 12) & 0x0f)
|
||||
#define PIXMAN_FORMAT_R(f) (((f) >> 8) & 0x0f)
|
||||
#define PIXMAN_FORMAT_G(f) (((f) >> 4) & 0x0f)
|
||||
#define PIXMAN_FORMAT_B(f) (((f) ) & 0x0f)
|
||||
#define PIXMAN_FORMAT_RGB(f) (((f) ) & 0xfff)
|
||||
#define PIXMAN_FORMAT_VIS(f) (((f) ) & 0xffff)
|
||||
#define PIXMAN_FORMAT_DEPTH(f) (PIXMAN_FORMAT_A(f) + \
|
||||
PIXMAN_FORMAT_R(f) + \
|
||||
PIXMAN_FORMAT_G(f) + \
|
||||
PIXMAN_FORMAT_B(f))
|
||||
|
||||
#define PIXMAN_TYPE_OTHER 0
|
||||
#define PIXMAN_TYPE_A 1
|
||||
#define PIXMAN_TYPE_ARGB 2
|
||||
#define PIXMAN_TYPE_ABGR 3
|
||||
#define PIXMAN_TYPE_COLOR 4
|
||||
#define PIXMAN_TYPE_GRAY 5
|
||||
|
||||
#define PIXMAN_FORMAT_COLOR(f) (PIXMAN_FORMAT_TYPE(f) & 2)
|
||||
|
||||
/* 32bpp formats */
|
||||
typedef enum {
|
||||
PIXMAN_a8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8),
|
||||
PIXMAN_x8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8),
|
||||
PIXMAN_a8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8),
|
||||
PIXMAN_x8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8),
|
||||
|
||||
/* 24bpp formats */
|
||||
PIXMAN_r8g8b8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8),
|
||||
PIXMAN_b8g8r8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8),
|
||||
|
||||
/* 16bpp formats */
|
||||
PIXMAN_r5g6b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,6,5),
|
||||
PIXMAN_b5g6r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,6,5),
|
||||
|
||||
PIXMAN_a1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,1,5,5,5),
|
||||
PIXMAN_x1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,5,5),
|
||||
PIXMAN_a1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,1,5,5,5),
|
||||
PIXMAN_x1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,5,5),
|
||||
PIXMAN_a4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,4,4,4,4),
|
||||
PIXMAN_x4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,4,4,4),
|
||||
PIXMAN_a4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,4,4,4,4),
|
||||
PIXMAN_x4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,4,4,4),
|
||||
|
||||
/* 8bpp formats */
|
||||
PIXMAN_a8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0),
|
||||
PIXMAN_r3g3b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,0,3,3,2),
|
||||
PIXMAN_b2g3r3 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,0,3,3,2),
|
||||
PIXMAN_a2r2g2b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,2,2,2,2),
|
||||
PIXMAN_a2b2g2r2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2),
|
||||
|
||||
PIXMAN_c8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0),
|
||||
PIXMAN_g8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0),
|
||||
|
||||
PIXMAN_x4a4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0),
|
||||
|
||||
PIXMAN_x4c4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0),
|
||||
PIXMAN_x4g4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0),
|
||||
|
||||
/* 4bpp formats */
|
||||
PIXMAN_a4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_A,4,0,0,0),
|
||||
PIXMAN_r1g2b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,0,1,2,1),
|
||||
PIXMAN_b1g2r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,0,1,2,1),
|
||||
PIXMAN_a1r1g1b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,1,1,1,1),
|
||||
PIXMAN_a1b1g1r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1),
|
||||
|
||||
PIXMAN_c4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_COLOR,0,0,0,0),
|
||||
PIXMAN_g4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_GRAY,0,0,0,0),
|
||||
|
||||
/* 1bpp formats */
|
||||
PIXMAN_a1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0),
|
||||
|
||||
PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0),
|
||||
} pixman_format_code_t;
|
||||
|
||||
/* Constructors */
|
||||
pixman_image_t *pixman_image_create_solid_fill (pixman_color_t *color);
|
||||
pixman_image_t *pixman_image_create_linear_gradient (pixman_point_fixed_t *p1,
|
||||
pixman_point_fixed_t *p2,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops);
|
||||
pixman_image_t *pixman_image_create_radial_gradient (pixman_point_fixed_t *inner,
|
||||
pixman_point_fixed_t *outer,
|
||||
pixman_fixed_t inner_radius,
|
||||
pixman_fixed_t outer_radius,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops);
|
||||
pixman_image_t *pixman_image_create_conical_gradient (pixman_point_fixed_t *center,
|
||||
pixman_fixed_t angle,
|
||||
const pixman_gradient_stop_t *stops,
|
||||
int n_stops);
|
||||
pixman_image_t *pixman_image_create_bits (pixman_format_code_t format,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t *bits,
|
||||
int rowstride_bytes);
|
||||
|
||||
/* Destructor */
|
||||
pixman_image_t *pixman_image_ref (pixman_image_t *image);
|
||||
void pixman_image_unref (pixman_image_t *image);
|
||||
|
||||
|
||||
/* Set properties */
|
||||
pixman_bool_t pixman_image_set_clip_region (pixman_image_t *image,
|
||||
pixman_region16_t *region);
|
||||
void pixman_image_set_has_client_clip (pixman_image_t *image,
|
||||
pixman_bool_t clien_clip);
|
||||
pixman_bool_t pixman_image_set_transform (pixman_image_t *image,
|
||||
const pixman_transform_t *transform);
|
||||
void pixman_image_set_repeat (pixman_image_t *image,
|
||||
pixman_repeat_t repeat);
|
||||
pixman_bool_t pixman_image_set_filter (pixman_image_t *image,
|
||||
pixman_filter_t filter,
|
||||
const pixman_fixed_t *filter_params,
|
||||
int n_filter_params);
|
||||
void pixman_image_set_filter_params (pixman_image_t *image,
|
||||
pixman_fixed_t *params,
|
||||
int n_params);
|
||||
void pixman_image_set_alpha_map (pixman_image_t *image,
|
||||
pixman_image_t *alpha_map,
|
||||
int16_t x,
|
||||
int16_t y);
|
||||
void pixman_image_set_component_alpha (pixman_image_t *image,
|
||||
pixman_bool_t component_alpha);
|
||||
void pixman_image_set_accessors (pixman_image_t *image,
|
||||
pixman_read_memory_func_t read_func,
|
||||
pixman_write_memory_func_t write_func);
|
||||
void pixman_image_set_indexed (pixman_image_t *image,
|
||||
const pixman_indexed_t *indexed);
|
||||
uint32_t *pixman_image_get_data (pixman_image_t *image);
|
||||
int pixman_image_get_width (pixman_image_t *image);
|
||||
int pixman_image_get_height (pixman_image_t *image);
|
||||
int pixman_image_get_stride (pixman_image_t *image);
|
||||
int pixman_image_get_depth (pixman_image_t *image);
|
||||
pixman_bool_t pixman_image_fill_rectangles (pixman_op_t op,
|
||||
pixman_image_t *image,
|
||||
pixman_color_t *color,
|
||||
int n_rects,
|
||||
const pixman_rectangle16_t *rects);
|
||||
|
||||
/* Composite */
|
||||
pixman_bool_t pixman_compute_composite_region (pixman_region16_t * pRegion,
|
||||
pixman_image_t * pSrc,
|
||||
pixman_image_t * pMask,
|
||||
pixman_image_t * pDst,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t xMask,
|
||||
int16_t yMask,
|
||||
int16_t xDst,
|
||||
int16_t yDst,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
void pixman_image_composite (pixman_op_t op,
|
||||
pixman_image_t *src,
|
||||
pixman_image_t *mask,
|
||||
pixman_image_t *dest,
|
||||
int16_t src_x,
|
||||
int16_t src_y,
|
||||
int16_t mask_x,
|
||||
int16_t mask_y,
|
||||
int16_t dest_x,
|
||||
int16_t dest_y,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
|
||||
/*
|
||||
* Trapezoids
|
||||
*/
|
||||
typedef struct pixman_edge pixman_edge_t;
|
||||
typedef struct pixman_trapezoid pixman_trapezoid_t;
|
||||
typedef struct pixman_trap pixman_trap_t;
|
||||
typedef struct pixman_span_fix pixman_span_fix_t;
|
||||
|
||||
/*
|
||||
* An edge structure. This represents a single polygon edge
|
||||
* and can be quickly stepped across small or large gaps in the
|
||||
* sample grid
|
||||
*/
|
||||
struct pixman_edge
|
||||
{
|
||||
pixman_fixed_t x;
|
||||
pixman_fixed_t e;
|
||||
pixman_fixed_t stepx;
|
||||
pixman_fixed_t signdx;
|
||||
pixman_fixed_t dy;
|
||||
pixman_fixed_t dx;
|
||||
|
||||
pixman_fixed_t stepx_small;
|
||||
pixman_fixed_t stepx_big;
|
||||
pixman_fixed_t dx_small;
|
||||
pixman_fixed_t dx_big;
|
||||
};
|
||||
|
||||
struct pixman_trapezoid
|
||||
{
|
||||
pixman_fixed_t top, bottom;
|
||||
pixman_line_fixed_t left, right;
|
||||
};
|
||||
|
||||
|
||||
/* whether 't' is a well defined not obviously empty trapezoid */
|
||||
#define pixman_trapezoid_valid(t) \
|
||||
((t)->left.p1.y != (t)->left.p2.y && \
|
||||
(t)->right.p1.y != (t)->right.p2.y && \
|
||||
(int) ((t)->bottom - (t)->top) > 0)
|
||||
|
||||
struct pixman_span_fix
|
||||
{
|
||||
pixman_fixed_t l, r, y;
|
||||
};
|
||||
|
||||
struct pixman_trap
|
||||
{
|
||||
pixman_span_fix_t top, bot;
|
||||
};
|
||||
|
||||
pixman_fixed_t pixman_sample_ceil_y (pixman_fixed_t y,
|
||||
int bpp);
|
||||
pixman_fixed_t pixman_sample_floor_y (pixman_fixed_t y,
|
||||
int bpp);
|
||||
void pixman_edge_step (pixman_edge_t *e,
|
||||
int n);
|
||||
void pixman_edge_init (pixman_edge_t *e,
|
||||
int bpp,
|
||||
pixman_fixed_t y_start,
|
||||
pixman_fixed_t x_top,
|
||||
pixman_fixed_t y_top,
|
||||
pixman_fixed_t x_bot,
|
||||
pixman_fixed_t y_bot);
|
||||
void pixman_line_fixed_edge_init (pixman_edge_t *e,
|
||||
int bpp,
|
||||
pixman_fixed_t y,
|
||||
const pixman_line_fixed_t *line,
|
||||
int x_off,
|
||||
int y_off);
|
||||
void pixman_rasterize_edges (pixman_image_t *image,
|
||||
pixman_edge_t *l,
|
||||
pixman_edge_t *r,
|
||||
pixman_fixed_t t,
|
||||
pixman_fixed_t b);
|
||||
void pixman_add_traps (pixman_image_t *image,
|
||||
int16_t x_off,
|
||||
int16_t y_off,
|
||||
int ntrap,
|
||||
pixman_trap_t *traps);
|
||||
void pixman_add_trapezoids (pixman_image_t *image,
|
||||
int16_t x_off,
|
||||
int y_off,
|
||||
int ntraps,
|
||||
const pixman_trapezoid_t *traps);
|
||||
void pixman_rasterize_trapezoid (pixman_image_t *image,
|
||||
const pixman_trapezoid_t *trap,
|
||||
int x_off,
|
||||
int y_off);
|
||||
|
||||
|
||||
#endif /* PIXMAN_H__ */
|
||||
|
|
|
@ -1,80 +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.
|
||||
|
||||
******************************************************************/
|
||||
#ifndef _PIXREGIONINT_H_
|
||||
#define _PIXREGIONINT_H_
|
||||
|
||||
#include "pixman.h"
|
||||
|
||||
typedef struct pixman_region16_data {
|
||||
long size;
|
||||
long numRects;
|
||||
/* XXX: And why, exactly, do we have this bogus struct definition? */
|
||||
/* pixman_box16_t rects[size]; in memory but not explicitly declared */
|
||||
} pixman_region16_data_t;
|
||||
|
||||
struct pixman_region16 {
|
||||
pixman_box16_t extents;
|
||||
pixman_region16_data_t *data;
|
||||
};
|
||||
|
||||
typedef struct pixman_region16_point {
|
||||
int x, y;
|
||||
} pixman_region16_point_t;
|
||||
|
||||
#define PIXREGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
|
||||
/* not a region */
|
||||
#define PIXREGION_NAR(reg) ((reg)->data == &pixman_brokendata)
|
||||
#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 ? (pixman_box16_t *)((reg)->data + 1) \
|
||||
: &(reg)->extents)
|
||||
#define PIXREGION_BOXPTR(reg) ((pixman_box16_t *)((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(pixman_region16_data_t) + ((n) * sizeof(pixman_box16_t)))
|
||||
|
||||
#endif /* _PIXREGIONINT_H_ */
|
|
@ -1,194 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 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 "pixman-xserver-compat.h"
|
||||
|
||||
/*
|
||||
* Compute the smallest value no less than y which is on a
|
||||
* grid row
|
||||
*/
|
||||
|
||||
xFixed
|
||||
RenderSampleCeilY (xFixed y, int n)
|
||||
{
|
||||
xFixed f = xFixedFrac(y);
|
||||
xFixed i = xFixedFloor(y);
|
||||
|
||||
f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
|
||||
if (f > Y_FRAC_LAST(n))
|
||||
{
|
||||
f = Y_FRAC_FIRST(n);
|
||||
i += xFixed1;
|
||||
}
|
||||
return (i | f);
|
||||
}
|
||||
|
||||
#define _div(a,b) ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b)))
|
||||
|
||||
/*
|
||||
* Compute the largest value no greater than y which is on a
|
||||
* grid row
|
||||
*/
|
||||
xFixed
|
||||
RenderSampleFloorY (xFixed y, int n)
|
||||
{
|
||||
xFixed f = xFixedFrac(y);
|
||||
xFixed i = xFixedFloor (y);
|
||||
|
||||
f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
|
||||
if (f < Y_FRAC_FIRST(n))
|
||||
{
|
||||
f = Y_FRAC_LAST(n);
|
||||
i -= xFixed1;
|
||||
}
|
||||
return (i | f);
|
||||
}
|
||||
|
||||
/*
|
||||
* Step an edge by any amount (including negative values)
|
||||
*/
|
||||
void
|
||||
RenderEdgeStep (RenderEdge *e, int n)
|
||||
{
|
||||
xFixed_48_16 ne;
|
||||
|
||||
e->x += n * e->stepx;
|
||||
|
||||
ne = e->e + n * (xFixed_48_16) e->dx;
|
||||
|
||||
if (n >= 0)
|
||||
{
|
||||
if (ne > 0)
|
||||
{
|
||||
int nx = (ne + e->dy - 1) / e->dy;
|
||||
e->e = ne - nx * (xFixed_48_16) e->dy;
|
||||
e->x += nx * e->signdx;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ne <= -e->dy)
|
||||
{
|
||||
int nx = (-ne) / e->dy;
|
||||
e->e = ne + nx * (xFixed_48_16) e->dy;
|
||||
e->x -= nx * e->signdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A private routine to initialize the multi-step
|
||||
* elements of an edge structure
|
||||
*/
|
||||
static void
|
||||
_RenderEdgeMultiInit (RenderEdge *e, int n, xFixed *stepx_p, xFixed *dx_p)
|
||||
{
|
||||
xFixed stepx;
|
||||
xFixed_48_16 ne;
|
||||
|
||||
ne = n * (xFixed_48_16) e->dx;
|
||||
stepx = n * e->stepx;
|
||||
if (ne > 0)
|
||||
{
|
||||
int nx = ne / e->dy;
|
||||
ne -= nx * e->dy;
|
||||
stepx += nx * e->signdx;
|
||||
}
|
||||
*dx_p = ne;
|
||||
*stepx_p = stepx;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize one edge structure given the line endpoints and a
|
||||
* starting y value
|
||||
*/
|
||||
void
|
||||
RenderEdgeInit (RenderEdge *e,
|
||||
int n,
|
||||
xFixed y_start,
|
||||
xFixed x_top,
|
||||
xFixed y_top,
|
||||
xFixed x_bot,
|
||||
xFixed y_bot)
|
||||
{
|
||||
xFixed dx, dy;
|
||||
|
||||
e->x = x_top;
|
||||
e->e = 0;
|
||||
dx = x_bot - x_top;
|
||||
dy = y_bot - y_top;
|
||||
e->dy = dy;
|
||||
if (dy)
|
||||
{
|
||||
if (dx >= 0)
|
||||
{
|
||||
e->signdx = 1;
|
||||
e->stepx = dx / dy;
|
||||
e->dx = dx % dy;
|
||||
e->e = -dy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e->signdx = -1;
|
||||
e->stepx = -(-dx / dy);
|
||||
e->dx = -dx % dy;
|
||||
e->e = 0;
|
||||
}
|
||||
|
||||
_RenderEdgeMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small);
|
||||
_RenderEdgeMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big);
|
||||
}
|
||||
RenderEdgeStep (e, y_start - y_top);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize one edge structure given a line, starting y value
|
||||
* and a pixel offset for the line
|
||||
*/
|
||||
void
|
||||
RenderLineFixedEdgeInit (RenderEdge *e,
|
||||
int n,
|
||||
xFixed y,
|
||||
const xLineFixed *line,
|
||||
int x_off,
|
||||
int y_off)
|
||||
{
|
||||
xFixed x_off_fixed = IntToxFixed(x_off);
|
||||
xFixed y_off_fixed = IntToxFixed(y_off);
|
||||
const xPointFixed *top, *bot;
|
||||
|
||||
if (line->p1.y <= line->p2.y)
|
||||
{
|
||||
top = &line->p1;
|
||||
bot = &line->p2;
|
||||
}
|
||||
else
|
||||
{
|
||||
top = &line->p2;
|
||||
bot = &line->p1;
|
||||
}
|
||||
RenderEdgeInit (e, n, y,
|
||||
top->x + x_off_fixed,
|
||||
top->y + y_off_fixed,
|
||||
bot->x + x_off_fixed,
|
||||
bot->y + y_off_fixed);
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 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 _RENDEREDGE_H_
|
||||
#define _RENDEREDGE_H_
|
||||
|
||||
#include "pixman-xserver-compat.h"
|
||||
|
||||
/* Here is a drawing of the sample grid for the 4-bit alpha case,
|
||||
along with indications of the various defined terms:
|
||||
|
||||
STEP_Y_SMALL
|
||||
┌─────┬─────┬─────┐ ↓
|
||||
│•••••│•••••│•••••│ ─── ⟵── Y_FRAC_FIRST
|
||||
│•••••│•••••│•••••│ ───
|
||||
│•••••│•••••│•••••│ ↑ ⟵── Y_FRAC_LAST
|
||||
├─────┼─────┼─────┤
|
||||
│•••••│•••••│•••••│
|
||||
│•••••│•••••│•••••│ ↓
|
||||
│•••••│•••••│•••••│ ───
|
||||
├─────┼─────┼─────┤ STEP_Y_BIG
|
||||
│•••••│•••••│•••••│ ───
|
||||
│•••••│•••••│•••••│ ↑
|
||||
│•••••│•••••│•••••│
|
||||
└─────┴─────┴─────┘
|
||||
│ │ ││ ⟶│ │⟵STEP_X_BIG
|
||||
│ │⟶││⟵STEP_X_SMALL
|
||||
│ │
|
||||
│ └ X_FRAC_LAST
|
||||
│
|
||||
└ X_FRAC_FIRST
|
||||
|
||||
N = 4 (# of bits of alpha)
|
||||
MAX_ALPHA = 15 (# of samples per pixel)
|
||||
N_X_FRAC = 5 (# of sample columns per pixel)
|
||||
N_Y_FRAC = 3 (# of sample rows per column)
|
||||
STEP_X_SMALL (distance between sample columns within a pixel)
|
||||
STEP_X_BIG (distance between sample columns across pixel boundaries)
|
||||
STEP_Y_SMALL (distance between sample rows within a pixel)
|
||||
STEP_Y_BIG (distance between sample rows across pixel boundaries)
|
||||
X_FRAC_FIRST (sub-pixel position of first sample column in pixel)
|
||||
X_FRAC_LAST (sub-pixel position of last sample column in pixel)
|
||||
Y_FRAC_FIRST (sub-pixel position of first sample row in pixel)
|
||||
Y_FRAC_LAST (sub-pixel position of last sample row pixel)
|
||||
|
||||
*/
|
||||
|
||||
#define MAX_ALPHA(n) ((1 << (n)) - 1)
|
||||
#define N_Y_FRAC(n) ((n) == 1 ? 1 : (1 << ((n)/2)) - 1)
|
||||
#define N_X_FRAC(n) ((1 << ((n)/2)) + 1)
|
||||
|
||||
#define STEP_Y_SMALL(n) (xFixed1 / N_Y_FRAC(n))
|
||||
#define STEP_Y_BIG(n) (xFixed1 - (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n))
|
||||
|
||||
#define Y_FRAC_FIRST(n) (STEP_Y_SMALL(n) / 2)
|
||||
#define Y_FRAC_LAST(n) (Y_FRAC_FIRST(n) + (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n))
|
||||
|
||||
#define STEP_X_SMALL(n) (xFixed1 / N_X_FRAC(n))
|
||||
#define STEP_X_BIG(n) (xFixed1 - (N_X_FRAC(n) - 1) * STEP_X_SMALL(n))
|
||||
|
||||
#define X_FRAC_FIRST(n) (STEP_X_SMALL(n) / 2)
|
||||
#define X_FRAC_LAST(n) (X_FRAC_FIRST(n) + (N_X_FRAC(n) - 1) * STEP_X_SMALL(n))
|
||||
|
||||
#define RenderSamplesX(x,n) ((n) == 1 ? 0 : (xFixedFrac (x) + X_FRAC_FIRST(n)) / STEP_X_SMALL(n))
|
||||
|
||||
/*
|
||||
* An edge structure. This represents a single polygon edge
|
||||
* and can be quickly stepped across small or large gaps in the
|
||||
* sample grid
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
xFixed x;
|
||||
xFixed e;
|
||||
xFixed stepx;
|
||||
xFixed signdx;
|
||||
xFixed dy;
|
||||
xFixed dx;
|
||||
|
||||
xFixed stepx_small;
|
||||
xFixed stepx_big;
|
||||
xFixed dx_small;
|
||||
xFixed dx_big;
|
||||
} RenderEdge;
|
||||
|
||||
/*
|
||||
* Step across a small sample grid gap
|
||||
*/
|
||||
#define RenderEdgeStepSmall(edge) { \
|
||||
(edge)->x += (edge)->stepx_small; \
|
||||
(edge)->e += (edge)->dx_small; \
|
||||
if ((edge)->e > 0) \
|
||||
{ \
|
||||
(edge)->e -= (edge)->dy; \
|
||||
(edge)->x += (edge)->signdx; \
|
||||
} \
|
||||
}
|
||||
|
||||
/*
|
||||
* Step across a large sample grid gap
|
||||
*/
|
||||
#define RenderEdgeStepBig(edge) { \
|
||||
(edge)->x += (edge)->stepx_big; \
|
||||
(edge)->e += (edge)->dx_big; \
|
||||
if ((edge)->e > 0) \
|
||||
{ \
|
||||
(edge)->e -= (edge)->dy; \
|
||||
(edge)->x += (edge)->signdx; \
|
||||
} \
|
||||
}
|
||||
|
||||
pixman_private xFixed
|
||||
RenderSampleCeilY (xFixed y, int bpp);
|
||||
|
||||
pixman_private xFixed
|
||||
RenderSampleFloorY (xFixed y, int bpp);
|
||||
|
||||
pixman_private void
|
||||
RenderEdgeStep (RenderEdge *e, int n);
|
||||
|
||||
pixman_private void
|
||||
RenderEdgeInit (RenderEdge *e,
|
||||
int bpp,
|
||||
xFixed y_start,
|
||||
xFixed x_top,
|
||||
xFixed y_top,
|
||||
xFixed x_bot,
|
||||
xFixed y_bot);
|
||||
|
||||
pixman_private void
|
||||
RenderLineFixedEdgeInit (RenderEdge *e,
|
||||
int bpp,
|
||||
xFixed y,
|
||||
const pixman_line_fixed_t *line,
|
||||
int x_off,
|
||||
int y_off);
|
||||
|
||||
#endif /* _RENDEREDGE_H_ */
|
Загрузка…
Ссылка в новой задаче