Added intl and sdl_gfx libraries (thanks to Kurosu)
This commit is contained in:
18
project/jni/sdl_gfx/Android.mk
Normal file
18
project/jni/sdl_gfx/Android.mk
Normal file
@@ -0,0 +1,18 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := sdl_gfx
|
||||
|
||||
LOCAL_CFLAGS := -I$(LOCAL_PATH) -I$(LOCAL_PATH)/.. \
|
||||
-I$(LOCAL_PATH)/../sdl/include -Os
|
||||
|
||||
LOCAL_CPP_EXTENSION := .cpp
|
||||
|
||||
# Note this simple makefile var substitution, you can find even simpler examples in different Android projects
|
||||
LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := sdl
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
458
project/jni/sdl_gfx/COPYING
Normal file
458
project/jni/sdl_gfx/COPYING
Normal file
@@ -0,0 +1,458 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
135
project/jni/sdl_gfx/SDL_framerate.c
Normal file
135
project/jni/sdl_gfx/SDL_framerate.c
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
|
||||
SDL_framerate: framerate manager
|
||||
|
||||
LGPL (c) A. Schiffler
|
||||
|
||||
*/
|
||||
|
||||
#include "SDL_framerate.h"
|
||||
|
||||
/*!
|
||||
\brief Initialize the framerate manager.
|
||||
|
||||
Initialize the framerate manager, set default framerate of 30Hz and
|
||||
reset delay interpolation.
|
||||
|
||||
\param manager Pointer to the framerate manager.
|
||||
*/
|
||||
void SDL_initFramerate(FPSmanager * manager)
|
||||
{
|
||||
/*
|
||||
* Store some sane values
|
||||
*/
|
||||
manager->framecount = 0;
|
||||
manager->rate = FPS_DEFAULT;
|
||||
manager->rateticks = (1000.0f / (float) FPS_DEFAULT);
|
||||
manager->lastticks = SDL_GetTicks();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Set the framerate in Hz
|
||||
|
||||
Sets a new framerate for the manager and reset delay interpolation.
|
||||
Rate values must be between FPS_LOWER_LIMIT and FPS_UPPER_LIMIT inclusive to be accepted.
|
||||
|
||||
\param manager Pointer to the framerate manager.
|
||||
\param rate The new framerate in Hz (frames per second).
|
||||
|
||||
\return 0 for sucess and -1 for error.
|
||||
*/
|
||||
int SDL_setFramerate(FPSmanager * manager, int rate)
|
||||
{
|
||||
if ((rate >= FPS_LOWER_LIMIT) && (rate <= FPS_UPPER_LIMIT)) {
|
||||
manager->framecount = 0;
|
||||
manager->rate = rate;
|
||||
manager->rateticks = (1000.0f / (float) rate);
|
||||
return (0);
|
||||
} else {
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Return the current target framerate in Hz
|
||||
|
||||
Get the currently set framerate of the manager.
|
||||
|
||||
\param manager Pointer to the framerate manager.
|
||||
|
||||
\return Current framerate in Hz or -1 for error.
|
||||
*/
|
||||
int SDL_getFramerate(FPSmanager * manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return (-1);
|
||||
} else {
|
||||
return (manager->rate);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Return the current framecount.
|
||||
|
||||
Get the current framecount from the framerate manager.
|
||||
A frame is counted each time SDL_framerateDelay is called.
|
||||
|
||||
\param manager Pointer to the framerate manager.
|
||||
|
||||
\return Current frame count or -1 for error.
|
||||
*/
|
||||
int SDL_getFramecount(FPSmanager * manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return (-1);
|
||||
} else {
|
||||
return ((Uint32)manager->framecount);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Delay execution to maintain a constant framerate and calculate fps.
|
||||
|
||||
Generate a delay to accomodate currently set framerate. Call once in the
|
||||
graphics/rendering loop. If the computer cannot keep up with the rate (i.e.
|
||||
drawing too slow), the delay is zero and the delay interpolation is reset.
|
||||
|
||||
\param manager Pointer to the framerate manager.
|
||||
*/
|
||||
void SDL_framerateDelay(FPSmanager * manager)
|
||||
{
|
||||
Uint32 current_ticks;
|
||||
Uint32 target_ticks;
|
||||
Uint32 the_delay;
|
||||
|
||||
/*
|
||||
* No manager, no delay
|
||||
*/
|
||||
if (manager == NULL)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Initialize uninitialized manager
|
||||
*/
|
||||
if (manager->lastticks == 0)
|
||||
SDL_initFramerate(manager);
|
||||
|
||||
/*
|
||||
* Next frame
|
||||
*/
|
||||
manager->framecount++;
|
||||
|
||||
/*
|
||||
* Get/calc ticks
|
||||
*/
|
||||
current_ticks = SDL_GetTicks();
|
||||
target_ticks = manager->lastticks + (Uint32) ((float) manager->framecount * manager->rateticks);
|
||||
|
||||
if (current_ticks <= target_ticks) {
|
||||
the_delay = target_ticks - current_ticks;
|
||||
SDL_Delay(the_delay);
|
||||
} else {
|
||||
manager->framecount = 0;
|
||||
manager->lastticks = SDL_GetTicks();
|
||||
}
|
||||
}
|
||||
79
project/jni/sdl_gfx/SDL_framerate.h
Normal file
79
project/jni/sdl_gfx/SDL_framerate.h
Normal file
@@ -0,0 +1,79 @@
|
||||
|
||||
/*
|
||||
|
||||
SDL_framerate: framerate manager
|
||||
|
||||
LGPL (c) A. Schiffler
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _SDL_framerate_h
|
||||
#define _SDL_framerate_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* --- */
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
/* --------- Definitions */
|
||||
|
||||
/*!
|
||||
\brief Highest possible rate supported by framerate controller in Hz (1/s).
|
||||
*/
|
||||
#define FPS_UPPER_LIMIT 200
|
||||
|
||||
/*!
|
||||
\brief Lowest possible rate supported by framerate controller in Hz (1/s).
|
||||
*/
|
||||
#define FPS_LOWER_LIMIT 1
|
||||
|
||||
/*!
|
||||
\brief Default rate of framerate controller in Hz (1/s).
|
||||
*/
|
||||
#define FPS_DEFAULT 30
|
||||
|
||||
/*!
|
||||
\brief Structure holding the state and timing information of the framerate controller.
|
||||
*/
|
||||
typedef struct {
|
||||
Uint32 framecount;
|
||||
float rateticks;
|
||||
Uint32 lastticks;
|
||||
Uint32 rate;
|
||||
} FPSmanager;
|
||||
|
||||
/* --------- Function prototypes */
|
||||
|
||||
#ifdef WIN32
|
||||
# ifdef DLL_EXPORT
|
||||
# define SDL_FRAMERATE_SCOPE __declspec(dllexport)
|
||||
# else
|
||||
# ifdef LIBSDL_GFX_DLL_IMPORT
|
||||
# define SDL_FRAMERATE_SCOPE __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SDL_FRAMERATE_SCOPE
|
||||
# define SDL_FRAMERATE_SCOPE extern
|
||||
#endif
|
||||
|
||||
/* Functions return 0 or value for sucess and -1 for error */
|
||||
|
||||
SDL_FRAMERATE_SCOPE void SDL_initFramerate(FPSmanager * manager);
|
||||
SDL_FRAMERATE_SCOPE int SDL_setFramerate(FPSmanager * manager, int rate);
|
||||
SDL_FRAMERATE_SCOPE int SDL_getFramerate(FPSmanager * manager);
|
||||
SDL_FRAMERATE_SCOPE int SDL_getFramecount(FPSmanager * manager);
|
||||
SDL_FRAMERATE_SCOPE void SDL_framerateDelay(FPSmanager * manager);
|
||||
|
||||
/* --- */
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_framerate_h */
|
||||
576
project/jni/sdl_gfx/SDL_gfxBlitFunc.c
Normal file
576
project/jni/sdl_gfx/SDL_gfxBlitFunc.c
Normal file
@@ -0,0 +1,576 @@
|
||||
/*
|
||||
|
||||
SDL_gfxBlitFunc: custom blitters (part of SDL_gfx library)
|
||||
|
||||
LGPL (c) A. Schiffler
|
||||
|
||||
*/
|
||||
|
||||
#include "SDL_gfxBlitFunc.h"
|
||||
|
||||
/*!
|
||||
\brief Alpha adjustment table for custom blitter.
|
||||
|
||||
The table provides values for a modified, non-linear
|
||||
transfer function which maintain brightness.
|
||||
|
||||
*/
|
||||
static unsigned int GFX_ALPHA_ADJUST_ARRAY[256] = {
|
||||
0, /* 0 */
|
||||
15, /* 1 */
|
||||
22, /* 2 */
|
||||
27, /* 3 */
|
||||
31, /* 4 */
|
||||
35, /* 5 */
|
||||
39, /* 6 */
|
||||
42, /* 7 */
|
||||
45, /* 8 */
|
||||
47, /* 9 */
|
||||
50, /* 10 */
|
||||
52, /* 11 */
|
||||
55, /* 12 */
|
||||
57, /* 13 */
|
||||
59, /* 14 */
|
||||
61, /* 15 */
|
||||
63, /* 16 */
|
||||
65, /* 17 */
|
||||
67, /* 18 */
|
||||
69, /* 19 */
|
||||
71, /* 20 */
|
||||
73, /* 21 */
|
||||
74, /* 22 */
|
||||
76, /* 23 */
|
||||
78, /* 24 */
|
||||
79, /* 25 */
|
||||
81, /* 26 */
|
||||
82, /* 27 */
|
||||
84, /* 28 */
|
||||
85, /* 29 */
|
||||
87, /* 30 */
|
||||
88, /* 31 */
|
||||
90, /* 32 */
|
||||
91, /* 33 */
|
||||
93, /* 34 */
|
||||
94, /* 35 */
|
||||
95, /* 36 */
|
||||
97, /* 37 */
|
||||
98, /* 38 */
|
||||
99, /* 39 */
|
||||
100, /* 40 */
|
||||
102, /* 41 */
|
||||
103, /* 42 */
|
||||
104, /* 43 */
|
||||
105, /* 44 */
|
||||
107, /* 45 */
|
||||
108, /* 46 */
|
||||
109, /* 47 */
|
||||
110, /* 48 */
|
||||
111, /* 49 */
|
||||
112, /* 50 */
|
||||
114, /* 51 */
|
||||
115, /* 52 */
|
||||
116, /* 53 */
|
||||
117, /* 54 */
|
||||
118, /* 55 */
|
||||
119, /* 56 */
|
||||
120, /* 57 */
|
||||
121, /* 58 */
|
||||
122, /* 59 */
|
||||
123, /* 60 */
|
||||
124, /* 61 */
|
||||
125, /* 62 */
|
||||
126, /* 63 */
|
||||
127, /* 64 */
|
||||
128, /* 65 */
|
||||
129, /* 66 */
|
||||
130, /* 67 */
|
||||
131, /* 68 */
|
||||
132, /* 69 */
|
||||
133, /* 70 */
|
||||
134, /* 71 */
|
||||
135, /* 72 */
|
||||
136, /* 73 */
|
||||
137, /* 74 */
|
||||
138, /* 75 */
|
||||
139, /* 76 */
|
||||
140, /* 77 */
|
||||
141, /* 78 */
|
||||
141, /* 79 */
|
||||
142, /* 80 */
|
||||
143, /* 81 */
|
||||
144, /* 82 */
|
||||
145, /* 83 */
|
||||
146, /* 84 */
|
||||
147, /* 85 */
|
||||
148, /* 86 */
|
||||
148, /* 87 */
|
||||
149, /* 88 */
|
||||
150, /* 89 */
|
||||
151, /* 90 */
|
||||
152, /* 91 */
|
||||
153, /* 92 */
|
||||
153, /* 93 */
|
||||
154, /* 94 */
|
||||
155, /* 95 */
|
||||
156, /* 96 */
|
||||
157, /* 97 */
|
||||
158, /* 98 */
|
||||
158, /* 99 */
|
||||
159, /* 100 */
|
||||
160, /* 101 */
|
||||
161, /* 102 */
|
||||
162, /* 103 */
|
||||
162, /* 104 */
|
||||
163, /* 105 */
|
||||
164, /* 106 */
|
||||
165, /* 107 */
|
||||
165, /* 108 */
|
||||
166, /* 109 */
|
||||
167, /* 110 */
|
||||
168, /* 111 */
|
||||
168, /* 112 */
|
||||
169, /* 113 */
|
||||
170, /* 114 */
|
||||
171, /* 115 */
|
||||
171, /* 116 */
|
||||
172, /* 117 */
|
||||
173, /* 118 */
|
||||
174, /* 119 */
|
||||
174, /* 120 */
|
||||
175, /* 121 */
|
||||
176, /* 122 */
|
||||
177, /* 123 */
|
||||
177, /* 124 */
|
||||
178, /* 125 */
|
||||
179, /* 126 */
|
||||
179, /* 127 */
|
||||
180, /* 128 */
|
||||
181, /* 129 */
|
||||
182, /* 130 */
|
||||
182, /* 131 */
|
||||
183, /* 132 */
|
||||
184, /* 133 */
|
||||
184, /* 134 */
|
||||
185, /* 135 */
|
||||
186, /* 136 */
|
||||
186, /* 137 */
|
||||
187, /* 138 */
|
||||
188, /* 139 */
|
||||
188, /* 140 */
|
||||
189, /* 141 */
|
||||
190, /* 142 */
|
||||
190, /* 143 */
|
||||
191, /* 144 */
|
||||
192, /* 145 */
|
||||
192, /* 146 */
|
||||
193, /* 147 */
|
||||
194, /* 148 */
|
||||
194, /* 149 */
|
||||
195, /* 150 */
|
||||
196, /* 151 */
|
||||
196, /* 152 */
|
||||
197, /* 153 */
|
||||
198, /* 154 */
|
||||
198, /* 155 */
|
||||
199, /* 156 */
|
||||
200, /* 157 */
|
||||
200, /* 158 */
|
||||
201, /* 159 */
|
||||
201, /* 160 */
|
||||
202, /* 161 */
|
||||
203, /* 162 */
|
||||
203, /* 163 */
|
||||
204, /* 164 */
|
||||
205, /* 165 */
|
||||
205, /* 166 */
|
||||
206, /* 167 */
|
||||
206, /* 168 */
|
||||
207, /* 169 */
|
||||
208, /* 170 */
|
||||
208, /* 171 */
|
||||
209, /* 172 */
|
||||
210, /* 173 */
|
||||
210, /* 174 */
|
||||
211, /* 175 */
|
||||
211, /* 176 */
|
||||
212, /* 177 */
|
||||
213, /* 178 */
|
||||
213, /* 179 */
|
||||
214, /* 180 */
|
||||
214, /* 181 */
|
||||
215, /* 182 */
|
||||
216, /* 183 */
|
||||
216, /* 184 */
|
||||
217, /* 185 */
|
||||
217, /* 186 */
|
||||
218, /* 187 */
|
||||
218, /* 188 */
|
||||
219, /* 189 */
|
||||
220, /* 190 */
|
||||
220, /* 191 */
|
||||
221, /* 192 */
|
||||
221, /* 193 */
|
||||
222, /* 194 */
|
||||
222, /* 195 */
|
||||
223, /* 196 */
|
||||
224, /* 197 */
|
||||
224, /* 198 */
|
||||
225, /* 199 */
|
||||
225, /* 200 */
|
||||
226, /* 201 */
|
||||
226, /* 202 */
|
||||
227, /* 203 */
|
||||
228, /* 204 */
|
||||
228, /* 205 */
|
||||
229, /* 206 */
|
||||
229, /* 207 */
|
||||
230, /* 208 */
|
||||
230, /* 209 */
|
||||
231, /* 210 */
|
||||
231, /* 211 */
|
||||
232, /* 212 */
|
||||
233, /* 213 */
|
||||
233, /* 214 */
|
||||
234, /* 215 */
|
||||
234, /* 216 */
|
||||
235, /* 217 */
|
||||
235, /* 218 */
|
||||
236, /* 219 */
|
||||
236, /* 220 */
|
||||
237, /* 221 */
|
||||
237, /* 222 */
|
||||
238, /* 223 */
|
||||
238, /* 224 */
|
||||
239, /* 225 */
|
||||
240, /* 226 */
|
||||
240, /* 227 */
|
||||
241, /* 228 */
|
||||
241, /* 229 */
|
||||
242, /* 230 */
|
||||
242, /* 231 */
|
||||
243, /* 232 */
|
||||
243, /* 233 */
|
||||
244, /* 234 */
|
||||
244, /* 235 */
|
||||
245, /* 236 */
|
||||
245, /* 237 */
|
||||
246, /* 238 */
|
||||
246, /* 239 */
|
||||
247, /* 240 */
|
||||
247, /* 241 */
|
||||
248, /* 242 */
|
||||
248, /* 243 */
|
||||
249, /* 244 */
|
||||
249, /* 245 */
|
||||
250, /* 246 */
|
||||
250, /* 247 */
|
||||
251, /* 248 */
|
||||
251, /* 249 */
|
||||
252, /* 250 */
|
||||
252, /* 251 */
|
||||
253, /* 252 */
|
||||
253, /* 253 */
|
||||
254, /* 254 */
|
||||
255 /* 255 */
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Internal blitter using adjusted destination alpha during RGBA->RGBA blits.
|
||||
|
||||
Performs the blit based on the 'info' structure and applies the transfer function
|
||||
to the destination 'a' values.
|
||||
|
||||
\param info The blit info to use.
|
||||
*/
|
||||
void _SDL_gfxBlitBlitterRGBA(SDL_gfxBlitInfo * info)
|
||||
{
|
||||
int width = info->d_width;
|
||||
int height = info->d_height;
|
||||
Uint8 *src = info->s_pixels;
|
||||
int srcskip = info->s_skip;
|
||||
Uint8 *dst = info->d_pixels;
|
||||
int dstskip = info->d_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src;
|
||||
SDL_PixelFormat *dstfmt = info->dst;
|
||||
int srcbpp = srcfmt->BytesPerPixel;
|
||||
int dstbpp = dstfmt->BytesPerPixel;
|
||||
|
||||
while (height--) {
|
||||
GFX_DUFFS_LOOP4( {
|
||||
Uint32 pixel;
|
||||
unsigned sR;
|
||||
unsigned sG;
|
||||
unsigned sB;
|
||||
unsigned sA;
|
||||
unsigned dR;
|
||||
unsigned dG;
|
||||
unsigned dB;
|
||||
unsigned dA;
|
||||
unsigned sAA;
|
||||
GFX_DISEMBLE_RGBA(src, srcbpp, srcfmt, pixel, sR, sG, sB, sA);
|
||||
GFX_DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
|
||||
sAA=GFX_ALPHA_ADJUST_ARRAY[sA & 255];
|
||||
GFX_ALPHA_BLEND(sR, sG, sB, sAA, dR, dG, dB);
|
||||
dA |= sAA;
|
||||
GFX_ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
||||
src += srcbpp; dst += dstbpp;
|
||||
}, width);
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Internal blitter setup wrapper for RGBA->RGBA blits.
|
||||
|
||||
Sets up the blitter info based on the 'src' and 'dst' surfaces and rectangles.
|
||||
|
||||
\param src The source surface.
|
||||
\param srcrect The source rectangle.
|
||||
\param dst The destination surface.
|
||||
\param dstrect The destination rectangle.
|
||||
|
||||
\returns Returns 1 if blit was performed, 0 otherwise.
|
||||
*/
|
||||
int _SDL_gfxBlitRGBACall(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect)
|
||||
{
|
||||
/*
|
||||
* Set up source and destination buffer pointers, then blit
|
||||
*/
|
||||
if (srcrect->w && srcrect->h) {
|
||||
SDL_gfxBlitInfo info;
|
||||
|
||||
/*
|
||||
* Set up the blit information
|
||||
*/
|
||||
#if (SDL_MINOR_VERSION == 3)
|
||||
info.s_pixels = (Uint8 *) src->pixels + (Uint16) srcrect->y * src->pitch + (Uint16) srcrect->x * src->format->BytesPerPixel;
|
||||
#else
|
||||
info.s_pixels = (Uint8 *) src->pixels + src->offset + (Uint16) srcrect->y * src->pitch + (Uint16) srcrect->x * src->format->BytesPerPixel;
|
||||
#endif
|
||||
info.s_width = srcrect->w;
|
||||
info.s_height = srcrect->h;
|
||||
info.s_skip = src->pitch - info.s_width * src->format->BytesPerPixel;
|
||||
#if (SDL_MINOR_VERSION == 3)
|
||||
info.d_pixels = (Uint8 *) dst->pixels + (Uint16) dstrect->y * dst->pitch + (Uint16) dstrect->x * dst->format->BytesPerPixel;
|
||||
#else
|
||||
info.d_pixels = (Uint8 *) dst->pixels + dst->offset + (Uint16) dstrect->y * dst->pitch + (Uint16) dstrect->x * dst->format->BytesPerPixel;
|
||||
#endif
|
||||
info.d_width = dstrect->w;
|
||||
info.d_height = dstrect->h;
|
||||
info.d_skip = dst->pitch - info.d_width * dst->format->BytesPerPixel;
|
||||
info.aux_data = NULL;
|
||||
info.src = src->format;
|
||||
info.table = NULL;
|
||||
info.dst = dst->format;
|
||||
|
||||
/*
|
||||
* Run the actual software blitter
|
||||
*/
|
||||
_SDL_gfxBlitBlitterRGBA(&info);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Blitter for RGBA->RGBA blits with alpha adjustment.
|
||||
|
||||
Verifies the input 'src' and 'dst' surfaces and rectangles and performs blit.
|
||||
The destination clip rectangle is honored.
|
||||
|
||||
\param src The source surface.
|
||||
\param srcrect The source rectangle.
|
||||
\param dst The destination surface.
|
||||
\param dstrect The destination rectangle.
|
||||
|
||||
\returns Returns 1 if blit was performed, 0 otherwise, or -1 if an error occured.
|
||||
*/
|
||||
int SDL_gfxBlitRGBA(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect)
|
||||
{
|
||||
SDL_Rect sr, dr;
|
||||
int srcx, srcy, w, h;
|
||||
|
||||
/*
|
||||
* Make sure the surfaces aren't locked
|
||||
*/
|
||||
if (!src || !dst) {
|
||||
SDL_SetError("SDL_UpperBlit: passed a NULL surface");
|
||||
return (-1);
|
||||
}
|
||||
if (src->locked || dst->locked) {
|
||||
SDL_SetError("Surfaces must not be locked during blit");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the destination rectangle is NULL, use the entire dest surface
|
||||
*/
|
||||
if (dstrect == NULL) {
|
||||
dr.x = dr.y = 0;
|
||||
dr.w = dst->w;
|
||||
dr.h = dst->h;
|
||||
} else {
|
||||
dr = *dstrect;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clip the source rectangle to the source surface
|
||||
*/
|
||||
if (srcrect) {
|
||||
int maxw, maxh;
|
||||
|
||||
srcx = srcrect->x;
|
||||
w = srcrect->w;
|
||||
if (srcx < 0) {
|
||||
w += srcx;
|
||||
dr.x -= srcx;
|
||||
srcx = 0;
|
||||
}
|
||||
maxw = src->w - srcx;
|
||||
if (maxw < w)
|
||||
w = maxw;
|
||||
|
||||
srcy = srcrect->y;
|
||||
h = srcrect->h;
|
||||
if (srcy < 0) {
|
||||
h += srcy;
|
||||
dr.y -= srcy;
|
||||
srcy = 0;
|
||||
}
|
||||
maxh = src->h - srcy;
|
||||
if (maxh < h)
|
||||
h = maxh;
|
||||
|
||||
} else {
|
||||
srcx = srcy = 0;
|
||||
w = src->w;
|
||||
h = src->h;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clip the destination rectangle against the clip rectangle
|
||||
*/
|
||||
{
|
||||
SDL_Rect *clip = &dst->clip_rect;
|
||||
int dx, dy;
|
||||
|
||||
dx = clip->x - dr.x;
|
||||
if (dx > 0) {
|
||||
w -= dx;
|
||||
dr.x += dx;
|
||||
srcx += dx;
|
||||
}
|
||||
dx = dr.x + w - clip->x - clip->w;
|
||||
if (dx > 0)
|
||||
w -= dx;
|
||||
|
||||
dy = clip->y - dr.y;
|
||||
if (dy > 0) {
|
||||
h -= dy;
|
||||
dr.y += dy;
|
||||
srcy += dy;
|
||||
}
|
||||
dy = dr.y + h - clip->y - clip->h;
|
||||
if (dy > 0)
|
||||
h -= dy;
|
||||
}
|
||||
|
||||
if (w > 0 && h > 0) {
|
||||
sr.x = srcx;
|
||||
sr.y = srcy;
|
||||
sr.w = dr.w = w;
|
||||
sr.h = dr.h = h;
|
||||
return (_SDL_gfxBlitRGBACall(src, &sr, dst, &dr));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Sets the alpha channel in a 32 bit surface.
|
||||
|
||||
Helper function that sets the alpha channel in a 32 bit surface
|
||||
to a constant value.
|
||||
Only 32 bit surfaces can be used with this function.
|
||||
|
||||
\param src Pointer to the target surface to change.
|
||||
\param a The alpha value to set.
|
||||
|
||||
\return Returns 1 if alpha was changed, 0 otherwise.
|
||||
*/
|
||||
int SDL_gfxSetAlpha(SDL_Surface *src, Uint8 a)
|
||||
{
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
Uint16 alpha_offset = 0;
|
||||
#else
|
||||
Uint16 alpha_offset = 3;
|
||||
#endif
|
||||
Uint16 i, j;
|
||||
|
||||
/* Check if we have a 32bit surface */
|
||||
if ( (src) && (src->format) && (src->format->BytesPerPixel==4) ) {
|
||||
/* Lock and process */
|
||||
if ( SDL_LockSurface(src) == 0 ) {
|
||||
Uint8 *pixels = (Uint8 *)src->pixels;
|
||||
Uint16 row_skip = (src->pitch - (4*src->w));
|
||||
pixels += alpha_offset;
|
||||
for ( i=0; i<src->h; i++ ) {
|
||||
for ( j=0; j<src->w; j++ ) {
|
||||
*pixels = a;
|
||||
pixels += 4;
|
||||
}
|
||||
pixels += row_skip;
|
||||
}
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Multiply the alpha channel in a 32bit surface.
|
||||
|
||||
Helper function that multiplies the alpha channel in a 32 bit surface
|
||||
with a constant value. The final alpha is always scaled to the range
|
||||
0-255 (i.e. the factor is a/256).
|
||||
Only 32 bit surfaces can be used with this function.
|
||||
|
||||
\param src Pointer to the target surface to change.
|
||||
\param a The alpha value to multiply with.
|
||||
|
||||
\return Returns 1 if alpha was changed, 0 otherwise.
|
||||
*/
|
||||
int SDL_gfxMultiplyAlpha(SDL_Surface *src, Uint8 a)
|
||||
{
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
Uint16 alpha_offset = 0;
|
||||
#else
|
||||
Uint16 alpha_offset = 3;
|
||||
#endif
|
||||
Uint16 i, j;
|
||||
|
||||
/* Check if we have a 32bit surface */
|
||||
if ( (src) && (src->format) && (src->format->BytesPerPixel==4) && (a!=255) ) {
|
||||
/* Lock and process */
|
||||
if ( SDL_LockSurface(src) == 0 ) {
|
||||
Uint8 *pixels = (Uint8 *)src->pixels;
|
||||
Uint16 row_skip = (src->pitch - (4*src->w));
|
||||
pixels += alpha_offset;
|
||||
for ( i=0; i<src->h; i++ ) {
|
||||
for ( j=0; j<src->w; j++ ) {
|
||||
*pixels = (Uint8)(((int)(*pixels)*a)>>8);
|
||||
pixels += 4;
|
||||
}
|
||||
pixels += row_skip;
|
||||
}
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
144
project/jni/sdl_gfx/SDL_gfxBlitFunc.h
Normal file
144
project/jni/sdl_gfx/SDL_gfxBlitFunc.h
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
|
||||
SDL_gfxBlitFunc: custom blitters (part of SDL_gfx library)
|
||||
|
||||
LGPL (c) A. Schiffler
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _SDL_gfxBlitFunc_h
|
||||
#define _SDL_gfxBlitFunc_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_video.h>
|
||||
|
||||
/* -------- Prototypes */
|
||||
|
||||
#ifdef WIN32
|
||||
# ifdef DLL_EXPORT
|
||||
# define SDL_GFXBLITFUNC_SCOPE __declspec(dllexport)
|
||||
# else
|
||||
# ifdef LIBSDL_GFX_DLL_IMPORT
|
||||
# define SDL_GFXBLITFUNC_SCOPE __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SDL_GFXBLITFUNC_SCOPE
|
||||
# define SDL_GFXBLITFUNC_SCOPE extern
|
||||
#endif
|
||||
|
||||
|
||||
SDL_GFXBLITFUNC_SCOPE int SDL_gfxBlitRGBA(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect);
|
||||
|
||||
SDL_GFXBLITFUNC_SCOPE int SDL_gfxSetAlpha(SDL_Surface * src, Uint8 a);
|
||||
|
||||
SDL_GFXBLITFUNC_SCOPE int SDL_gfxMultiplyAlpha(SDL_Surface * src, Uint8 a);
|
||||
|
||||
/* -------- Macros */
|
||||
|
||||
/* Define SDL macros locally as a substitute for an #include "SDL_blit.h", */
|
||||
/* which doesn't work since the include file doesn't get installed. */
|
||||
|
||||
/*!
|
||||
\brief The structure passed to the low level blit functions.
|
||||
*/
|
||||
typedef struct {
|
||||
Uint8 *s_pixels;
|
||||
int s_width;
|
||||
int s_height;
|
||||
int s_skip;
|
||||
Uint8 *d_pixels;
|
||||
int d_width;
|
||||
int d_height;
|
||||
int d_skip;
|
||||
void *aux_data;
|
||||
SDL_PixelFormat *src;
|
||||
Uint8 *table;
|
||||
SDL_PixelFormat *dst;
|
||||
} SDL_gfxBlitInfo;
|
||||
|
||||
/*!
|
||||
\brief Unwrap RGBA values from a pixel using mask, shift and loss for surface.
|
||||
*/
|
||||
#define GFX_RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a) \
|
||||
{ \
|
||||
r = ((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; \
|
||||
g = ((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \
|
||||
b = ((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \
|
||||
a = ((pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss; \
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Disassemble buffer pointer into a pixel and separate RGBA values.
|
||||
*/
|
||||
#define GFX_DISEMBLE_RGBA(buf, bpp, fmt, pixel, r, g, b, a) \
|
||||
do { \
|
||||
pixel = *((Uint32 *)(buf)); \
|
||||
GFX_RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a); \
|
||||
pixel &= ~fmt->Amask; \
|
||||
} while(0)
|
||||
|
||||
/*!
|
||||
\brief Wrap a pixel from RGBA values using mask, shift and loss for surface.
|
||||
*/
|
||||
#define GFX_PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a) \
|
||||
{ \
|
||||
pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
|
||||
((g>>fmt->Gloss)<<fmt->Gshift)| \
|
||||
((b>>fmt->Bloss)<<fmt->Bshift)| \
|
||||
((a<<fmt->Aloss)<<fmt->Ashift); \
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Assemble pixel into buffer pointer from separate RGBA values.
|
||||
*/
|
||||
#define GFX_ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \
|
||||
{ \
|
||||
Uint32 pixel; \
|
||||
\
|
||||
GFX_PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a); \
|
||||
*((Uint32 *)(buf)) = pixel; \
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Blend the RGB values of two pixels based on a source alpha value.
|
||||
*/
|
||||
#define GFX_ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \
|
||||
do { \
|
||||
dR = (((sR-dR)*(A))/255)+dR; \
|
||||
dG = (((sG-dG)*(A))/255)+dG; \
|
||||
dB = (((sB-dB)*(A))/255)+dB; \
|
||||
} while(0)
|
||||
|
||||
/*!
|
||||
\brief 4-times unrolled DUFFs loop.
|
||||
|
||||
This is a very useful loop for optimizing blitters.
|
||||
*/
|
||||
#define GFX_DUFFS_LOOP4(pixel_copy_increment, width) \
|
||||
{ int n = (width+3)/4; \
|
||||
switch (width & 3) { \
|
||||
case 0: do { pixel_copy_increment; \
|
||||
case 3: pixel_copy_increment; \
|
||||
case 2: pixel_copy_increment; \
|
||||
case 1: pixel_copy_increment; \
|
||||
} while ( --n > 0 ); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_gfxBlitFunc_h */
|
||||
5873
project/jni/sdl_gfx/SDL_gfxPrimitives.c
Normal file
5873
project/jni/sdl_gfx/SDL_gfxPrimitives.c
Normal file
File diff suppressed because it is too large
Load Diff
208
project/jni/sdl_gfx/SDL_gfxPrimitives.h
Normal file
208
project/jni/sdl_gfx/SDL_gfxPrimitives.h
Normal file
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
|
||||
SDL_gfxPrimitives: graphics primitives for SDL
|
||||
|
||||
LGPL (c) A. Schiffler
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _SDL_gfxPrimitives_h
|
||||
#define _SDL_gfxPrimitives_h
|
||||
|
||||
#include <math.h>
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ----- Versioning */
|
||||
|
||||
#define SDL_GFXPRIMITIVES_MAJOR 2
|
||||
#define SDL_GFXPRIMITIVES_MINOR 0
|
||||
#define SDL_GFXPRIMITIVES_MICRO 21
|
||||
|
||||
/* ----- W32 DLL interface */
|
||||
|
||||
#ifdef WIN32
|
||||
# ifdef DLL_EXPORT
|
||||
# define SDL_GFXPRIMITIVES_SCOPE __declspec(dllexport)
|
||||
# else
|
||||
# ifdef LIBSDL_GFX_DLL_IMPORT
|
||||
# define SDL_GFXPRIMITIVES_SCOPE __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SDL_GFXPRIMITIVES_SCOPE
|
||||
# define SDL_GFXPRIMITIVES_SCOPE extern
|
||||
#endif
|
||||
|
||||
/* ----- Prototypes */
|
||||
|
||||
/* Note: all ___Color routines expect the color to be in format 0xRRGGBBAA */
|
||||
|
||||
/* Pixel */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int pixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int pixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Horizontal line */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int hlineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Vertical line */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int vlineColor(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int vlineRGBA(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Rectangle */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int rectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int rectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,
|
||||
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled rectangle (Box) */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int boxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int boxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2,
|
||||
Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Line */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int lineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int lineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,
|
||||
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* AA Line */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int aalineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,
|
||||
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Circle */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int circleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int circleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Arc */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int arcColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int arcRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* AA Circle */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int aacircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int aacircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
|
||||
Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled Circle */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledCircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledCircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
|
||||
Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Ellipse */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int ellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int ellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
|
||||
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* AA Ellipse */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int aaellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int aaellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
|
||||
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled Ellipse */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledEllipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledEllipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
|
||||
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Pie */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int pieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,
|
||||
Sint16 start, Sint16 end, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int pieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,
|
||||
Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled Pie */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,
|
||||
Sint16 start, Sint16 end, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,
|
||||
Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Trigon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int trigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int trigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* AA-Trigon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int aatrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int aatrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled Trigon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledTrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledTrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Polygon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int polygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int polygonRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy,
|
||||
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* AA-Polygon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int aapolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int aapolygonRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy,
|
||||
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled Polygon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPolygonRGBA(SDL_Surface * dst, const Sint16 * vx,
|
||||
const Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
SDL_GFXPRIMITIVES_SCOPE int texturedPolygon(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, SDL_Surface * texture,int texture_dx,int texture_dy);
|
||||
|
||||
/* (Note: These MT versions are required for multi-threaded operation.) */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPolygonColorMT(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color, int **polyInts, int *polyAllocated);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPolygonRGBAMT(SDL_Surface * dst, const Sint16 * vx,
|
||||
const Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
|
||||
int **polyInts, int *polyAllocated);
|
||||
SDL_GFXPRIMITIVES_SCOPE int texturedPolygonMT(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, SDL_Surface * texture,int texture_dx,int texture_dy, int **polyInts, int *polyAllocated);
|
||||
|
||||
/* Bezier */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int bezierColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, int s, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int bezierRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy,
|
||||
int n, int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Characters/Strings */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFont(const void *fontdata, Uint32 cw, Uint32 ch);
|
||||
SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFontRotation(Uint32 rotation);
|
||||
SDL_GFXPRIMITIVES_SCOPE int characterColor(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int characterRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
SDL_GFXPRIMITIVES_SCOPE int stringColor(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int stringRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_gfxPrimitives_h */
|
||||
3082
project/jni/sdl_gfx/SDL_gfxPrimitives_font.h
Normal file
3082
project/jni/sdl_gfx/SDL_gfxPrimitives_font.h
Normal file
File diff suppressed because it is too large
Load Diff
7556
project/jni/sdl_gfx/SDL_imageFilter.c
Normal file
7556
project/jni/sdl_gfx/SDL_imageFilter.c
Normal file
File diff suppressed because it is too large
Load Diff
195
project/jni/sdl_gfx/SDL_imageFilter.h
Normal file
195
project/jni/sdl_gfx/SDL_imageFilter.h
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
|
||||
SDL_imageFilter - bytes-image "filter" routines
|
||||
(uses inline x86 MMX optimizations if available)
|
||||
|
||||
LGPL (c) A. Schiffler
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _SDL_imageFilter_h
|
||||
#define _SDL_imageFilter_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ------ Function Prototypes ------ */
|
||||
|
||||
#ifdef WIN32
|
||||
# ifdef DLL_EXPORT
|
||||
# define SDL_IMAGEFILTER_SCOPE __declspec(dllexport)
|
||||
# else
|
||||
# ifdef LIBSDL_GFX_DLL_IMPORT
|
||||
# define SDL_IMAGEFILTER_SCOPE __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SDL_IMAGEFILTER_SCOPE
|
||||
# define SDL_IMAGEFILTER_SCOPE extern
|
||||
#endif
|
||||
|
||||
/* Comments: */
|
||||
/* 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. */
|
||||
/* 2.) Data that is not within an 8 byte boundary is processed using the C routine. */
|
||||
/* 3.) Convolution routines do not have C routines at this time. */
|
||||
|
||||
// Detect MMX capability in CPU
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMMXdetect(void);
|
||||
|
||||
// Force use of MMX off (or turn possible use back on)
|
||||
SDL_IMAGEFILTER_SCOPE void SDL_imageFilterMMXoff(void);
|
||||
SDL_IMAGEFILTER_SCOPE void SDL_imageFilterMMXon(void);
|
||||
|
||||
//
|
||||
// All routines return:
|
||||
// 0 OK
|
||||
// -1 Error (internal error, parameter error)
|
||||
//
|
||||
|
||||
// SDL_imageFilterAdd: D = saturation255(S1 + S2)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAdd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterMean: D = S1/2 + S2/2
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMean(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterSub: D = saturation0(S1 - S2)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSub(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterAbsDiff: D = | S1 - S2 |
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAbsDiff(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterMult: D = saturation(S1 * S2)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMult(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterMultNor: D = S1 * S2 (non-MMX)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultNor(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby2(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest,
|
||||
unsigned int length);
|
||||
|
||||
// SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby4(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest,
|
||||
unsigned int length);
|
||||
|
||||
// SDL_imageFilterBitAnd: D = S1 & S2
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBitAnd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterBitOr: D = S1 | S2
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBitOr(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterDiv: D = S1 / S2 (non-MMX)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterDiv(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterBitNegation: D = !S
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBitNegation(unsigned char *Src1, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterAddByte: D = saturation255(S + C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAddByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
|
||||
|
||||
// SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAddUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int C);
|
||||
|
||||
// SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAddByteToHalf(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char C);
|
||||
|
||||
// SDL_imageFilterSubByte: D = saturation0(S - C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSubByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
|
||||
|
||||
// SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSubUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int C);
|
||||
|
||||
// SDL_imageFilterShiftRight: D = saturation0(S >> N)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRight(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
|
||||
|
||||
// SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
|
||||
|
||||
// SDL_imageFilterMultByByte: D = saturation255(S * C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
|
||||
|
||||
// SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightAndMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char N, unsigned char C);
|
||||
|
||||
// SDL_imageFilterShiftLeftByte: D = (S << N)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftByte(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char N);
|
||||
|
||||
// SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftUint(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char N);
|
||||
|
||||
// SDL_imageFilterShiftLeft: D = saturation255(S << N)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeft(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
|
||||
|
||||
// SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBinarizeUsingThreshold(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char T);
|
||||
|
||||
// SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterClipToRange(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char Tmin, unsigned char Tmax);
|
||||
|
||||
// SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterNormalizeLinear(unsigned char *Src, unsigned char *Dest, unsigned int length, int Cmin,
|
||||
int Cmax, int Nmin, int Nmax);
|
||||
|
||||
/* !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! */
|
||||
|
||||
// SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel3x3Divide(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel, unsigned char Divisor);
|
||||
|
||||
// SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel5x5Divide(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel, unsigned char Divisor);
|
||||
|
||||
// SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel7x7Divide(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel, unsigned char Divisor);
|
||||
|
||||
// SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel9x9Divide(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel, unsigned char Divisor);
|
||||
|
||||
// SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel3x3ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel,
|
||||
unsigned char NRightShift);
|
||||
|
||||
// SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel5x5ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel,
|
||||
unsigned char NRightShift);
|
||||
|
||||
// SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel7x7ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel,
|
||||
unsigned char NRightShift);
|
||||
|
||||
// SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel9x9ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel,
|
||||
unsigned char NRightShift);
|
||||
|
||||
// SDL_imageFilterSobelX: Dij = saturation255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSobelX(unsigned char *Src, unsigned char *Dest, int rows, int columns);
|
||||
|
||||
// SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSobelXShiftRight(unsigned char *Src, unsigned char *Dest, int rows, int columns,
|
||||
unsigned char NRightShift);
|
||||
|
||||
// Align/restore stack to 32 byte boundary -- Functionality untested! --
|
||||
SDL_IMAGEFILTER_SCOPE void SDL_imageFilterAlignStack(void);
|
||||
SDL_IMAGEFILTER_SCOPE void SDL_imageFilterRestoreStack(void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_imageFilter_h */
|
||||
1593
project/jni/sdl_gfx/SDL_rotozoom.c
Normal file
1593
project/jni/sdl_gfx/SDL_rotozoom.c
Normal file
File diff suppressed because it is too large
Load Diff
103
project/jni/sdl_gfx/SDL_rotozoom.h
Normal file
103
project/jni/sdl_gfx/SDL_rotozoom.h
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
/*
|
||||
|
||||
SDL_rotozoom - rotozoomer
|
||||
|
||||
LGPL (c) A. Schiffler
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _SDL_rotozoom_h
|
||||
#define _SDL_rotozoom_h
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.141592654
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
/* ---- Defines */
|
||||
|
||||
/*!
|
||||
\brief Disable anti-aliasing (no smoothing).
|
||||
*/
|
||||
#define SMOOTHING_OFF 0
|
||||
|
||||
/*!
|
||||
\brief Enable anti-aliasing (smoothing).
|
||||
*/
|
||||
#define SMOOTHING_ON 1
|
||||
|
||||
/* ---- Prototypes */
|
||||
|
||||
#ifdef WIN32
|
||||
# ifdef DLL_EXPORT
|
||||
# define SDL_ROTOZOOM_SCOPE __declspec(dllexport)
|
||||
# else
|
||||
# ifdef LIBSDL_GFX_DLL_IMPORT
|
||||
# define SDL_ROTOZOOM_SCOPE __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SDL_ROTOZOOM_SCOPE
|
||||
# define SDL_ROTOZOOM_SCOPE extern
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
Rotozoom functions
|
||||
|
||||
*/
|
||||
|
||||
SDL_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth);
|
||||
|
||||
SDL_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurfaceXY
|
||||
(SDL_Surface * src, double angle, double zoomx, double zoomy, int smooth);
|
||||
|
||||
|
||||
SDL_ROTOZOOM_SCOPE void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth,
|
||||
int *dstheight);
|
||||
|
||||
SDL_ROTOZOOM_SCOPE void rotozoomSurfaceSizeXY
|
||||
(int width, int height, double angle, double zoomx, double zoomy,
|
||||
int *dstwidth, int *dstheight);
|
||||
|
||||
/*
|
||||
|
||||
Zooming functions
|
||||
|
||||
*/
|
||||
|
||||
SDL_ROTOZOOM_SCOPE SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smooth);
|
||||
|
||||
SDL_ROTOZOOM_SCOPE void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight);
|
||||
|
||||
/*
|
||||
|
||||
Shrinking functions
|
||||
|
||||
*/
|
||||
|
||||
SDL_ROTOZOOM_SCOPE SDL_Surface *shrinkSurface(SDL_Surface * src, int factorx, int factory);
|
||||
|
||||
/*
|
||||
|
||||
Specialized rotation functions
|
||||
|
||||
*/
|
||||
|
||||
SDL_ROTOZOOM_SCOPE SDL_Surface* rotateSurface90Degrees(SDL_Surface* src, int numClockwiseTurns);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_rotozoom_h */
|
||||
Reference in New Issue
Block a user