diff options
Diffstat (limited to 'libs/cairo-1.16.0/util/cairo-trace')
-rw-r--r-- | libs/cairo-1.16.0/util/cairo-trace/COPYING | 5 | ||||
-rw-r--r-- | libs/cairo-1.16.0/util/cairo-trace/COPYING-GPL-3 | 674 | ||||
-rw-r--r-- | libs/cairo-1.16.0/util/cairo-trace/Makefile.am | 40 | ||||
-rw-r--r-- | libs/cairo-1.16.0/util/cairo-trace/Makefile.in | 859 | ||||
-rw-r--r-- | libs/cairo-1.16.0/util/cairo-trace/cairo-trace.in | 136 | ||||
-rw-r--r-- | libs/cairo-1.16.0/util/cairo-trace/lookup-symbol.c | 331 | ||||
-rw-r--r-- | libs/cairo-1.16.0/util/cairo-trace/lookup-symbol.h | 24 | ||||
-rw-r--r-- | libs/cairo-1.16.0/util/cairo-trace/trace.c | 5587 |
8 files changed, 7656 insertions, 0 deletions
diff --git a/libs/cairo-1.16.0/util/cairo-trace/COPYING b/libs/cairo-1.16.0/util/cairo-trace/COPYING new file mode 100644 index 0000000..37aeee0 --- /dev/null +++ b/libs/cairo-1.16.0/util/cairo-trace/COPYING @@ -0,0 +1,5 @@ +Cairo is free software. + +cairo-trace is released under the terms of the GNU General Public License +(GPL) version 3. Please see COPYING-GPL-3 for the precise terms and +conditions. diff --git a/libs/cairo-1.16.0/util/cairo-trace/COPYING-GPL-3 b/libs/cairo-1.16.0/util/cairo-trace/COPYING-GPL-3 new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/libs/cairo-1.16.0/util/cairo-trace/COPYING-GPL-3 @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If 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 convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/libs/cairo-1.16.0/util/cairo-trace/Makefile.am b/libs/cairo-1.16.0/util/cairo-trace/Makefile.am new file mode 100644 index 0000000..a0091f8 --- /dev/null +++ b/libs/cairo-1.16.0/util/cairo-trace/Makefile.am @@ -0,0 +1,40 @@ +cairolibdir = $(libdir)/cairo +cairooutdir = $(localstatedir)/lib/cairo-trace + +bin_SCRIPTS = cairo-trace +cairolib_LTLIBRARIES = libcairo-trace.la + +AM_CPPFLAGS = -I$(top_srcdir)/src \ + -I$(top_builddir)/src + +libcairo_trace_la_SOURCES = trace.c +libcairo_trace_la_CPPFLAGS = -DCAIRO_TRACE_OUTDIR="\"$(cairooutdir)\"" \ + $(AM_CPPFLAGS) +libcairo_trace_la_CFLAGS = $(CAIRO_CFLAGS) $(real_pthread_CFLAGS) +libcairo_trace_la_LDFLAGS = -module -no-undefined -avoid-version + +libcairo_trace_la_LIBADD = $(real_pthread_LIBS) -lz +if CAIRO_HAS_DL +libcairo_trace_la_LIBADD += -ldl +endif + +if CAIRO_HAS_SYMBOL_LOOKUP +libcairo_trace_la_SOURCES += \ + lookup-symbol.c \ + lookup-symbol.h +libcairo_trace_la_LIBADD += $(BFD_LIBS) +endif + + +system-install: install + -mkdir -p $(cairooutdir) + -chmod 01777 $(cairooutdir) + grep -sq $(cairolibdir)/libcairo-trace.so /etc/ld.so.preload || echo $(cairolibdir)/libcairo-trace.so >> /etc/ld.so.preload + +system-uninstall: uninstall + sed -e '/libcairo-trace.so/d' < /etc/ld.so.preload > /tmp/ld.so.preload && mv /tmp/ld.so.preload /etc/ld.so.preload; + +EXTRA_DIST = \ + COPYING \ + COPYING-GPL-3 \ + cairo-trace.in diff --git a/libs/cairo-1.16.0/util/cairo-trace/Makefile.in b/libs/cairo-1.16.0/util/cairo-trace/Makefile.in new file mode 100644 index 0000000..40643c1 --- /dev/null +++ b/libs/cairo-1.16.0/util/cairo-trace/Makefile.in @@ -0,0 +1,859 @@ +# Makefile.in generated by automake 1.15.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@CAIRO_HAS_DL_TRUE@am__append_1 = -ldl +@CAIRO_HAS_SYMBOL_LOOKUP_TRUE@am__append_2 = \ +@CAIRO_HAS_SYMBOL_LOOKUP_TRUE@ lookup-symbol.c \ +@CAIRO_HAS_SYMBOL_LOOKUP_TRUE@ lookup-symbol.h + +@CAIRO_HAS_SYMBOL_LOOKUP_TRUE@am__append_3 = $(BFD_LIBS) +subdir = util/cairo-trace +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/build/aclocal.cairo.m4 \ + $(top_srcdir)/build/aclocal.compare.m4 \ + $(top_srcdir)/build/aclocal.enable.m4 \ + $(top_srcdir)/build/aclocal.float.m4 \ + $(top_srcdir)/build/aclocal.makefile.m4 \ + $(top_srcdir)/build/aclocal.pkg.m4 \ + $(top_srcdir)/build/gtk-doc.m4 $(top_srcdir)/build/libtool.m4 \ + $(top_srcdir)/build/ltoptions.m4 \ + $(top_srcdir)/build/ltsugar.m4 \ + $(top_srcdir)/build/ltversion.m4 \ + $(top_srcdir)/build/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/cairo-version.h \ + $(top_srcdir)/build/configure.ac.version \ + $(top_srcdir)/build/configure.ac.tools \ + $(top_srcdir)/build/configure.ac.features \ + $(top_srcdir)/build/configure.ac.warnings \ + $(top_srcdir)/build/configure.ac.system \ + $(top_srcdir)/build/configure.ac.analysis \ + $(top_srcdir)/build/configure.ac.noversion \ + $(top_srcdir)/build/configure.ac.pthread \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = cairo-trace +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(cairolibdir)" "$(DESTDIR)$(bindir)" +LTLIBRARIES = $(cairolib_LTLIBRARIES) +am__DEPENDENCIES_1 = +@CAIRO_HAS_SYMBOL_LOOKUP_TRUE@am__DEPENDENCIES_2 = \ +@CAIRO_HAS_SYMBOL_LOOKUP_TRUE@ $(am__DEPENDENCIES_1) +libcairo_trace_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +am__libcairo_trace_la_SOURCES_DIST = trace.c lookup-symbol.c \ + lookup-symbol.h +@CAIRO_HAS_SYMBOL_LOOKUP_TRUE@am__objects_1 = libcairo_trace_la-lookup-symbol.lo +am_libcairo_trace_la_OBJECTS = libcairo_trace_la-trace.lo \ + $(am__objects_1) +libcairo_trace_la_OBJECTS = $(am_libcairo_trace_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +libcairo_trace_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(libcairo_trace_la_CFLAGS) $(CFLAGS) \ + $(libcairo_trace_la_LDFLAGS) $(LDFLAGS) -o $@ +SCRIPTS = $(bin_SCRIPTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/build/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libcairo_trace_la_SOURCES) +DIST_SOURCES = $(am__libcairo_trace_la_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/cairo-trace.in \ + $(top_srcdir)/build/depcomp COPYING +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAIROBOILERPLATE_LIBS = @CAIROBOILERPLATE_LIBS@ +CAIRO_CFLAGS = @CAIRO_CFLAGS@ +CAIRO_LDFLAGS = @CAIRO_LDFLAGS@ +CAIRO_LIBS = @CAIRO_LIBS@ +CAIRO_LIBTOOL_VERSION_INFO = @CAIRO_LIBTOOL_VERSION_INFO@ +CAIRO_NONPKGCONFIG_CFLAGS = @CAIRO_NONPKGCONFIG_CFLAGS@ +CAIRO_NONPKGCONFIG_LIBS = @CAIRO_NONPKGCONFIG_LIBS@ +CAIRO_RELEASE_STATUS = @CAIRO_RELEASE_STATUS@ +CAIRO_REQUIRES = @CAIRO_REQUIRES@ +CAIRO_TEST_MODE = @CAIRO_TEST_MODE@ +CAIRO_TEST_UNDEFINED_LDFLAGS = @CAIRO_TEST_UNDEFINED_LDFLAGS@ +CAIRO_VERSION_MAJOR = @CAIRO_VERSION_MAJOR@ +CAIRO_VERSION_MICRO = @CAIRO_VERSION_MICRO@ +CAIRO_VERSION_MINOR = @CAIRO_VERSION_MINOR@ +CAIRO_VERSION_SONUM = @CAIRO_VERSION_SONUM@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FIND = @FIND@ +FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ +FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_CONFIG = @FREETYPE_CONFIG@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ +GOBJECT_LIBS = @GOBJECT_LIBS@ +GREP = @GREP@ +GS = @GS@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBM = @LIBM@ +LIBOBJS = @LIBOBJS@ +LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@ +LIBRSVG_LIBS = @LIBRSVG_LIBS@ +LIBS = @LIBS@ +LIBSPECTRE_CFLAGS = @LIBSPECTRE_CFLAGS@ +LIBSPECTRE_LIBS = @LIBSPECTRE_LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LTP = @LTP@ +LTP_GENHTML = @LTP_GENHTML@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@ +PKG_CONFIG = @PKG_CONFIG@ +POPPLER_CFLAGS = @POPPLER_CFLAGS@ +POPPLER_LIBS = @POPPLER_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SHLIB_EXT = @SHLIB_EXT@ +SHM_LIBS = @SHM_LIBS@ +SHTOOL = @SHTOOL@ +STRIP = @STRIP@ +VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ +VALGRIND_LIBS = @VALGRIND_LIBS@ +VERSION = @VERSION@ +XARGS = @XARGS@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +cogl_CFLAGS = @cogl_CFLAGS@ +cogl_LIBS = @cogl_LIBS@ +datadir = @datadir@ +datarootdir = @datarootdir@ +directfb_CFLAGS = @directfb_CFLAGS@ +directfb_LIBS = @directfb_LIBS@ +docdir = @docdir@ +drm_CFLAGS = @drm_CFLAGS@ +drm_LIBS = @drm_LIBS@ +dvidir = @dvidir@ +egl_CFLAGS = @egl_CFLAGS@ +egl_LIBS = @egl_LIBS@ +exec_prefix = @exec_prefix@ +gallium_DIR = @gallium_DIR@ +gl_CFLAGS = @gl_CFLAGS@ +gl_LIBS = @gl_LIBS@ +glesv2_CFLAGS = @glesv2_CFLAGS@ +glesv2_LIBS = @glesv2_LIBS@ +glesv3_CFLAGS = @glesv3_CFLAGS@ +glesv3_LIBS = @glesv3_LIBS@ +glib_CFLAGS = @glib_CFLAGS@ +glib_LIBS = @glib_LIBS@ +gtk_CFLAGS = @gtk_CFLAGS@ +gtk_LIBS = @gtk_LIBS@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lzo_LIBS = @lzo_LIBS@ +mandir = @mandir@ +mesa_DIR = @mesa_DIR@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pixman_CFLAGS = @pixman_CFLAGS@ +pixman_LIBS = @pixman_LIBS@ +png_CFLAGS = @png_CFLAGS@ +png_LIBS = @png_LIBS@ +png_REQUIRES = @png_REQUIRES@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pthread_CFLAGS = @pthread_CFLAGS@ +pthread_LIBS = @pthread_LIBS@ +qt_CFLAGS = @qt_CFLAGS@ +qt_LIBS = @qt_LIBS@ +real_pthread_CFLAGS = @real_pthread_CFLAGS@ +real_pthread_LIBS = @real_pthread_LIBS@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +shm_LIBS = @shm_LIBS@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xcb_CFLAGS = @xcb_CFLAGS@ +xcb_LIBS = @xcb_LIBS@ +xcb_shm_CFLAGS = @xcb_shm_CFLAGS@ +xcb_shm_LIBS = @xcb_shm_LIBS@ +xlib_CFLAGS = @xlib_CFLAGS@ +xlib_LIBS = @xlib_LIBS@ +xlib_xcb_CFLAGS = @xlib_xcb_CFLAGS@ +xlib_xcb_LIBS = @xlib_xcb_LIBS@ +xlib_xrender_CFLAGS = @xlib_xrender_CFLAGS@ +xlib_xrender_LIBS = @xlib_xrender_LIBS@ +cairolibdir = $(libdir)/cairo +cairooutdir = $(localstatedir)/lib/cairo-trace +bin_SCRIPTS = cairo-trace +cairolib_LTLIBRARIES = libcairo-trace.la +AM_CPPFLAGS = -I$(top_srcdir)/src \ + -I$(top_builddir)/src + +libcairo_trace_la_SOURCES = trace.c $(am__append_2) +libcairo_trace_la_CPPFLAGS = -DCAIRO_TRACE_OUTDIR="\"$(cairooutdir)\"" \ + $(AM_CPPFLAGS) + +libcairo_trace_la_CFLAGS = $(CAIRO_CFLAGS) $(real_pthread_CFLAGS) +libcairo_trace_la_LDFLAGS = -module -no-undefined -avoid-version +libcairo_trace_la_LIBADD = $(real_pthread_LIBS) -lz $(am__append_1) \ + $(am__append_3) +EXTRA_DIST = \ + COPYING \ + COPYING-GPL-3 \ + cairo-trace.in + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign util/cairo-trace/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign util/cairo-trace/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +cairo-trace: $(top_builddir)/config.status $(srcdir)/cairo-trace.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +install-cairolibLTLIBRARIES: $(cairolib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(cairolib_LTLIBRARIES)'; test -n "$(cairolibdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(cairolibdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(cairolibdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(cairolibdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(cairolibdir)"; \ + } + +uninstall-cairolibLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(cairolib_LTLIBRARIES)'; test -n "$(cairolibdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(cairolibdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(cairolibdir)/$$f"; \ + done + +clean-cairolibLTLIBRARIES: + -test -z "$(cairolib_LTLIBRARIES)" || rm -f $(cairolib_LTLIBRARIES) + @list='$(cairolib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libcairo-trace.la: $(libcairo_trace_la_OBJECTS) $(libcairo_trace_la_DEPENDENCIES) $(EXTRA_libcairo_trace_la_DEPENDENCIES) + $(AM_V_CCLD)$(libcairo_trace_la_LINK) -rpath $(cairolibdir) $(libcairo_trace_la_OBJECTS) $(libcairo_trace_la_LIBADD) $(LIBS) +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcairo_trace_la-lookup-symbol.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcairo_trace_la-trace.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +libcairo_trace_la-trace.lo: trace.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcairo_trace_la_CPPFLAGS) $(CPPFLAGS) $(libcairo_trace_la_CFLAGS) $(CFLAGS) -MT libcairo_trace_la-trace.lo -MD -MP -MF $(DEPDIR)/libcairo_trace_la-trace.Tpo -c -o libcairo_trace_la-trace.lo `test -f 'trace.c' || echo '$(srcdir)/'`trace.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcairo_trace_la-trace.Tpo $(DEPDIR)/libcairo_trace_la-trace.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='trace.c' object='libcairo_trace_la-trace.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcairo_trace_la_CPPFLAGS) $(CPPFLAGS) $(libcairo_trace_la_CFLAGS) $(CFLAGS) -c -o libcairo_trace_la-trace.lo `test -f 'trace.c' || echo '$(srcdir)/'`trace.c + +libcairo_trace_la-lookup-symbol.lo: lookup-symbol.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcairo_trace_la_CPPFLAGS) $(CPPFLAGS) $(libcairo_trace_la_CFLAGS) $(CFLAGS) -MT libcairo_trace_la-lookup-symbol.lo -MD -MP -MF $(DEPDIR)/libcairo_trace_la-lookup-symbol.Tpo -c -o libcairo_trace_la-lookup-symbol.lo `test -f 'lookup-symbol.c' || echo '$(srcdir)/'`lookup-symbol.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcairo_trace_la-lookup-symbol.Tpo $(DEPDIR)/libcairo_trace_la-lookup-symbol.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lookup-symbol.c' object='libcairo_trace_la-lookup-symbol.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcairo_trace_la_CPPFLAGS) $(CPPFLAGS) $(libcairo_trace_la_CFLAGS) $(CFLAGS) -c -o libcairo_trace_la-lookup-symbol.lo `test -f 'lookup-symbol.c' || echo '$(srcdir)/'`lookup-symbol.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(SCRIPTS) +installdirs: + for dir in "$(DESTDIR)$(cairolibdir)" "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-cairolibLTLIBRARIES clean-generic clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-cairolibLTLIBRARIES + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binSCRIPTS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binSCRIPTS uninstall-cairolibLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ + clean-cairolibLTLIBRARIES clean-generic clean-libtool \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binSCRIPTS install-cairolibLTLIBRARIES install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am uninstall-binSCRIPTS \ + uninstall-cairolibLTLIBRARIES + +.PRECIOUS: Makefile + + +system-install: install + -mkdir -p $(cairooutdir) + -chmod 01777 $(cairooutdir) + grep -sq $(cairolibdir)/libcairo-trace.so /etc/ld.so.preload || echo $(cairolibdir)/libcairo-trace.so >> /etc/ld.so.preload + +system-uninstall: uninstall + sed -e '/libcairo-trace.so/d' < /etc/ld.so.preload > /tmp/ld.so.preload && mv /tmp/ld.so.preload /etc/ld.so.preload; + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libs/cairo-1.16.0/util/cairo-trace/cairo-trace.in b/libs/cairo-1.16.0/util/cairo-trace/cairo-trace.in new file mode 100644 index 0000000..ece90d3 --- /dev/null +++ b/libs/cairo-1.16.0/util/cairo-trace/cairo-trace.in @@ -0,0 +1,136 @@ +#!/bin/sh + +prefix=@prefix@ +exec_prefix=@exec_prefix@ + +nofile= +flush= +nocallers= +nomarkdirty= +compress= + +usage() { +cat << EOF +usage: cairo-trace [--no-file] command +cairo-trace will generate a log of all calls made by command to +cairo. This log will be stored in a file in the local directory +called command.pid.trace. +Whatever else happens is driven by its argument: + --flush - Flush the output trace after every call. + --no-file - Disable the creation of an output file. Outputs to the + terminal instead. + --no-callers - Do not lookup the caller address/symbol/line whilst tracing. + --mark-dirty - Record image data for cairo_mark_dirty() [default] + --no-mark-dirty - Do not record image data for cairo_mark_dirty() + --compress - Compress the output with LZMA + --profile - Combine --no-callers and --no-mark-dirty and --compress + +Environment variables understood by cairo-trace: + CAIRO_TRACE_FLUSH - flush the output after every function call. + CAIRO_TRACE_LINE_INFO - emit line information for most function calls. +EOF +exit +} + +skip=1 +while test $skip -eq 1; do + skip=0 + case $1 in + --flush) + skip=1 + flush=1 + ;; + --no-file) + skip=1 + nofile=1 + ;; + --no-callers) + skip=1 + nocallers=1 + ;; + --mark-dirty) + skip=1 + nomarkdirty= + ;; + --no-mark-dirty) + skip=1 + nomarkdirty=1 + ;; + --compress) + skip=1 + compress=1 + nofile=1 + ;; + --profile) + skip=1 + compress=1 + nomarkdirty=1 + nocallers=1 + nofile=1 + ;; + --version) + echo "cairo-trace, version @CAIRO_VERSION_MAJOR@.@CAIRO_VERSION_MINOR@.@CAIRO_VERSION_MICRO@." + exit + ;; + --help) + usage + ;; + esac + if test $skip -eq 1; then + shift + fi +done + +if test $# -eq 0; then + usage +fi + +CAIRO_TRACE_PROG_NAME="$1" +export CAIRO_TRACE_PROG_NAME + +if test "x$CAIRO_TRACE_SO" = "x"; then + CAIRO_TRACE_SO="" + for lib in @libdir@/cairo/libcairo-trace.@SHLIB_EXT@ @libdir@/cairo/libcairo-trace.@SHLIB_EXT@* @libdir@/cairo/libcairo-trace.*.@SHLIB_EXT@ ; do + if test -h "$lib" -o -f "$lib"; then + CAIRO_TRACE_SO="$lib" + break + fi + done +fi +if test "x$CAIRO_TRACE_SO" = "x"; then + echo "Could not find the cairo-trace shared library in @libdir@/cairo/." >&2 + echo "Set the CAIRO_TRACE_SO environment variable to the full path of the library." >&2 + exit 15 +fi + +LD_PRELOAD="$CAIRO_TRACE_SO" +DYLD_INSERT_LIBRARIES="$CAIRO_TRACE_SO" +DYLD_FORCE_FLAT_NAMESPACE=1 +export LD_PRELOAD +export DYLD_INSERT_LIBRARIES +export DYLD_FORCE_FLAT_NAMESPACE + +if test -n "$nocallers"; then + CAIRO_TRACE_LINE_INFO=0 + export CAIRO_TRACE_LINE_INFO +fi + +if test -n "$nomarkdirty"; then + CAIRO_TRACE_MARK_DIRTY=0 + export CAIRO_TRACE_MARK_DIRTY +fi + +if test -n "$flush"; then + CAIRO_TRACE_FLUSH=1 + export CAIRO_TRACE_FLUSH +fi + +if test -z "$nofile"; then + CAIRO_TRACE_OUTDIR=`pwd` "$@" +elif test -n "$compress"; then + name=`basename $1` + echo Generating compressed trace file $name.$$.lzma + CAIRO_TRACE_FD=3 "$@" 3>&1 >/dev/null | lzma -cz9 > $name.$$.lzma +else + CAIRO_TRACE_FD=3 "$@" 3>&1 >/dev/null +fi diff --git a/libs/cairo-1.16.0/util/cairo-trace/lookup-symbol.c b/libs/cairo-1.16.0/util/cairo-trace/lookup-symbol.c new file mode 100644 index 0000000..f9665b3 --- /dev/null +++ b/libs/cairo-1.16.0/util/cairo-trace/lookup-symbol.c @@ -0,0 +1,331 @@ +/* cairo-trace - a utility to record and replay calls to the Cairo library. + * + * Copyright © 2008 Chris Wilson + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* + * A less hacky utility to lookup the debug strings for a particular + * .text address. + * Derived from backtrace-symbols.c in cairo by Chris Wilson. + */ + +/* + A hacky replacement for backtrace_symbols in glibc + + backtrace_symbols in glibc looks up symbols using dladdr which is limited + in the symbols that it sees. libbacktracesymbols opens the executable and + shared libraries using libbfd and will look up backtrace information using + the symbol table and the dwarf line information. + + It may make more sense for this program to use libelf instead of libbfd. + However, I have not investigated that yet. + + Derived from addr2line.c from GNU Binutils by Jeff Muizelaar + + Copyright 2007 Jeff Muizelaar + */ + +/* addr2line.c -- convert addresses to line number and function name + Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Contributed by Ulrich Lauther <Ulrich.Lauther@mchp.siemens.de> + + This file was part of GNU Binutils. + */ + +#define _GNU_SOURCE + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define true 1 +#define false 0 + +#include "lookup-symbol.h" + +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <link.h> +#include <string.h> +#include <pthread.h> + +#if HAVE_BFD +#include <bfd.h> +#include <libiberty.h> + +struct symtab { + bfd *bfd; + asymbol **syms; +}; + +struct symbol { + int found; + bfd_vma pc; + struct symtab *symtab; + const char *filename; + const char *functionname; + unsigned int line; +}; + + +static void +_symtab_fini (struct symtab *symtab) +{ + free (symtab->syms); + if (symtab->bfd != NULL) + bfd_close (symtab->bfd); +} + +/* Read in the symbol table. */ +static int +_symtab_init (struct symtab *symtab, const char *filename) +{ + char **matching; + long symcount; + unsigned int size; + + symtab->bfd = NULL; + symtab->syms = NULL; + + symtab->bfd = bfd_openr (filename, NULL); + if (symtab->bfd == NULL) + goto BAIL; + + if (bfd_check_format (symtab->bfd, bfd_archive)) + goto BAIL; + + if (! bfd_check_format_matches (symtab->bfd, bfd_object, &matching)) + goto BAIL; + + symcount = bfd_read_minisymbols (symtab->bfd, false, (PTR) &symtab->syms, &size); + if (symcount == 0) { + symcount = bfd_read_minisymbols (symtab->bfd, true /* dynamic */ , + (PTR) &symtab->syms, &size); + } + if (symcount < 0) + goto BAIL; + + if ((bfd_get_file_flags (symtab->bfd) & HAS_SYMS) == 0) + goto BAIL; + + return 1; + +BAIL: + _symtab_fini (symtab); + return 0; +} + +/* Look for an address in a section. + * This is called via bfd_map_over_sections. + */ +static void +find_address_in_section (bfd *abfd, + asection *section, + void *data) +{ + bfd_vma vma; + bfd_size_type size; + struct symbol *symbol = data; + struct symtab *symtab = symbol->symtab; + + if (symbol->found) + return; + + if ((bfd_get_section_flags (symtab->bfd, section) & SEC_ALLOC) == 0) + return; + + vma = bfd_get_section_vma (symtab->bfd, section); + if (symbol->pc < vma) + return; + + size = bfd_section_size (symtab->bfd, section); + if (symbol->pc >= vma + size) + return; + + symbol->found = bfd_find_nearest_line (symtab->bfd, section, + symtab->syms, + symbol->pc - vma, + &symbol->filename, + &symbol->functionname, + &symbol->line); +} + +static void +_symbol_fini (struct symbol *symbol) +{ +} + +static void +_symbol_init (struct symbol *symbol, struct symtab *symtab, bfd_vma addr) +{ + symbol->found = false; + symbol->symtab = symtab; + symbol->pc = addr; +} + +static void +_symbol_print (struct symbol *symbol, char *buf, int buflen, const char *filename) +{ + const char *name, *h; + char path[1024]; + + if (! symbol->found) + return; + + name = symbol->functionname; + if (name == NULL || *name == '\0') + name = "??"; + + if (symbol->filename != NULL) + filename = symbol->filename; + if (strcmp (filename, "/proc/self/exe") == 0) { + int len = readlink ("/proc/self/exe", path, sizeof (path) - 1); + if (len != -1) { + path[len] = '\0'; + filename = path; + } + } + h = strrchr (filename, '/'); + if (h != NULL) + filename = h + 1; + + if (symbol->line) { + snprintf (buf, buflen, "%s() [%s:%u]", + name, filename, symbol->line); + } else { + snprintf (buf, buflen, "%s() [%s]", name, filename); + } +} +#endif + +struct file_match { + const char *file; + ElfW(Addr) address; + ElfW(Addr) base; + void *hdr; +}; + +static int +find_matching_file (struct dl_phdr_info *info, size_t size, void *data) +{ + struct file_match *match = data; + /* This code is modeled from Gfind_proc_info-lsb.c:callback() from libunwind */ + long n; + const ElfW(Phdr) *phdr; + ElfW(Addr) load_base = info->dlpi_addr; + + phdr = info->dlpi_phdr; + for (n = info->dlpi_phnum; --n >= 0; phdr++) { + if (phdr->p_type == PT_LOAD) { + ElfW(Addr) vaddr = phdr->p_vaddr + load_base; + if (match->address >= vaddr && + match->address < vaddr + phdr->p_memsz) + { + /* we found a match */ + match->file = info->dlpi_name; + match->base = info->dlpi_addr; + return 1; + } + } + } + + return 0; +} + +struct symbol_cache_entry { + const void *ptr; + struct symbol_cache_entry *hash_prev, *hash_next; + char name[0]; +}; + +static struct symbol_cache_entry *symbol_cache_hash[13477]; +static pthread_mutex_t symbol_cache_mutex = PTHREAD_MUTEX_INITIALIZER; + +char * +lookup_symbol (char *buf, int buflen, const void *ptr) +{ + struct file_match match; +#if HAVE_BFD + struct symtab symtab; + struct symbol symbol; +#endif + struct symbol_cache_entry *cache; + int bucket; + int len; + + bucket = (unsigned long) ptr % (sizeof (symbol_cache_hash) / sizeof (symbol_cache_hash[0])); + pthread_mutex_lock (&symbol_cache_mutex); + for (cache = symbol_cache_hash[bucket]; + cache != NULL; + cache = cache->hash_next) + { + if (cache->ptr == ptr) { + if (cache->hash_prev != NULL) { + cache->hash_prev->hash_next = cache->hash_next; + if (cache->hash_next != NULL) + cache->hash_next->hash_prev = cache->hash_prev; + cache->hash_prev = NULL; + cache->hash_next = symbol_cache_hash[bucket]; + symbol_cache_hash[bucket]->hash_prev = cache; + symbol_cache_hash[bucket] = cache; + } + + pthread_mutex_unlock (&symbol_cache_mutex); + return cache->name; + } + } + pthread_mutex_unlock (&symbol_cache_mutex); + + match.file = NULL; + match.address = (ElfW(Addr)) ptr; + dl_iterate_phdr (find_matching_file, &match); + + snprintf (buf, buflen, "0x%llx", + (long long unsigned int) match.address); + + if (match.file == NULL || *match.file == '\0') + match.file = "/proc/self/exe"; + +#if HAVE_BFD + if (_symtab_init (&symtab, match.file)) { + _symbol_init (&symbol, &symtab, match.address - match.base); + bfd_map_over_sections (symtab.bfd, find_address_in_section, &symbol); + if (symbol.found) + _symbol_print (&symbol, buf, buflen, match.file); + _symbol_fini (&symbol); + + _symtab_fini (&symtab); + } +#endif + + len = strlen (buf); + cache = malloc (sizeof (struct symbol_cache_entry) + len + 1); + if (cache != NULL) { + cache->ptr = ptr; + memcpy (cache->name, buf, len + 1); + + pthread_mutex_lock (&symbol_cache_mutex); + cache->hash_prev = NULL; + cache->hash_next = symbol_cache_hash[bucket]; + if (symbol_cache_hash[bucket] != NULL) + symbol_cache_hash[bucket]->hash_prev = cache; + symbol_cache_hash[bucket] = cache; + pthread_mutex_unlock (&symbol_cache_mutex); + } + + return buf; +} diff --git a/libs/cairo-1.16.0/util/cairo-trace/lookup-symbol.h b/libs/cairo-1.16.0/util/cairo-trace/lookup-symbol.h new file mode 100644 index 0000000..83817ed --- /dev/null +++ b/libs/cairo-1.16.0/util/cairo-trace/lookup-symbol.h @@ -0,0 +1,24 @@ +/* cairo-trace - a utility to record and replay calls to the Cairo library. + * + * Copyright © 2008 Chris Wilson + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef LOOKUP_SYMBOLS_H + +char * +lookup_symbol (char *buf, int len, const void *ptr); + +#endif /*LOOKUP_SYMBOLS_H */ diff --git a/libs/cairo-1.16.0/util/cairo-trace/trace.c b/libs/cairo-1.16.0/util/cairo-trace/trace.c new file mode 100644 index 0000000..1fe130b --- /dev/null +++ b/libs/cairo-1.16.0/util/cairo-trace/trace.c @@ -0,0 +1,5587 @@ +/* cairo-trace - a utility to record and replay calls to the Cairo library. + * + * Copyright © 2008 Chris Wilson + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#define _GNU_SOURCE + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* The autoconf on OpenBSD 4.5 produces the malformed constant name + * SIZEOF_VOID__ rather than SIZEOF_VOID_P. Work around that here. */ +#if !defined(SIZEOF_VOID_P) && defined(SIZEOF_VOID__) +# define SIZEOF_VOID_P SIZEOF_VOID__ +#endif + +#include <dlfcn.h> +#include <stdint.h> +#include <stdbool.h> +#include <stdio.h> +#include <string.h> +#include <sys/types.h> +#include <unistd.h> +#include <errno.h> +#include <pthread.h> +#include <zlib.h> +#include <math.h> +#include <locale.h> /* for locale independent %f printing */ +#include <ctype.h> +#include <assert.h> +#include <stdlib.h> +#include <limits.h> +#include <stdarg.h> + +#include <cairo.h> +#if CAIRO_HAS_FT_FONT +# include <cairo-ft.h> +#endif + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +#ifndef CAIRO_TRACE_OUTDIR +#define CAIRO_TRACE_OUTDIR "." +#endif + +#define DEBUG_STACK 0 + +#if HAVE_BYTESWAP_H +# include <byteswap.h> +#endif +#ifndef bswap_16 +# define bswap_16(p) \ + (((((uint16_t)(p)) & 0x00ff) << 8) | \ + (((uint16_t)(p)) >> 8)) +#endif +#ifndef bswap_32 +# define bswap_32(p) \ + (((((uint32_t)(p)) & 0x000000ff) << 24) | \ + ((((uint32_t)(p)) & 0x0000ff00) << 8) | \ + ((((uint32_t)(p)) & 0x00ff0000) >> 8) | \ + ((((uint32_t)(p))) >> 24)) +#endif + +#if WORDS_BIGENDIAN +#define le16(x) bswap_16 (x) +#define le32(x) bswap_32 (x) +#define be16(x) x +#define be32(x) x +#define to_be32(x) x +#else +#define le16(x) x +#define le32(x) x +#define be16(x) bswap_16 (x) +#define be32(x) bswap_32 (x) +#define to_be32(x) bswap_32 (x) +#endif + +#if CAIRO_HAS_SYMBOL_LOOKUP +#include "lookup-symbol.h" +#endif + +/* Reverse the bits in a byte with 7 operations (no 64-bit): + * Devised by Sean Anderson, July 13, 2001. + * Source: http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits + */ +#define CAIRO_BITSWAP8(c) ((((c) * 0x0802LU & 0x22110LU) | ((c) * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16) + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#define CAIRO_PRINTF_FORMAT(fmt_index, va_index) \ + __attribute__((__format__(__printf__, fmt_index, va_index))) +#else +#define CAIRO_PRINTF_FORMAT(fmt_index, va_index) +#endif + +/* XXX implement manual vprintf so that the user can control precision of + * printed numbers. + */ + +static void *_dlhandle = RTLD_NEXT; +#define DLCALL(name, args...) ({ \ + static typeof (&name) name##_real; \ + if (name##_real == NULL) { \ + name##_real = (typeof (&name))(dlsym (_dlhandle, #name)); \ + if (name##_real == NULL && _dlhandle == RTLD_NEXT) { \ + _dlhandle = dlopen ("libcairo." SHARED_LIB_EXT, RTLD_LAZY); \ + name##_real = (typeof (&name))(dlsym (_dlhandle, #name)); \ + assert (name##_real != NULL); \ + } \ + } \ + (*name##_real) (args); \ +}) + +#ifndef ARRAY_LENGTH +#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0]))) +#endif + +#if SIZEOF_VOID_P == 4 +#define PTR_SHIFT 2 +#elif SIZEOF_VOID_P == 8 +#define PTR_SHIFT 3 +#else +#error Unexpected pointer size +#endif +#define BUCKET(b, ptr) (((unsigned long) (ptr) >> PTR_SHIFT) % ARRAY_LENGTH (b)) + +#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) +#define _BOOLEAN_EXPR(expr) \ + __extension__ ({ \ + int _boolean_var_; \ + if (expr) \ + _boolean_var_ = 1; \ + else \ + _boolean_var_ = 0; \ + _boolean_var_; \ +}) +#define LIKELY(expr) (__builtin_expect (_BOOLEAN_EXPR(expr), 1)) +#define UNLIKELY(expr) (__builtin_expect (_BOOLEAN_EXPR(expr), 0)) +#else +#define LIKELY(expr) (expr) +#define UNLIKELY(expr) (expr) +#endif + +typedef struct _object Object; +typedef struct _type Type; + +struct _object { + const void *addr; + Type *type; + unsigned long int token; + int width, height; + cairo_bool_t foreign; + cairo_bool_t defined; + cairo_bool_t unknown; + int operand; + void *data; + void (*destroy)(void *); + Object *next, *prev; +}; + +struct _type { + const char *name; + + enum operand_type { + NONE, + SURFACE, + CONTEXT, + FONT_FACE, + PATTERN, + SCALED_FONT, + _N_OP_TYPES + } op_type; + const char *op_code; + + pthread_mutex_t mutex; + struct _bitmap { + unsigned long int min; + unsigned long int count; + unsigned int map[64]; + struct _bitmap *next; + } map; + Object *objects[607]; + Type *next; +}; + +static struct _type_table { + pthread_mutex_t mutex; + Type *op_types[_N_OP_TYPES]; +} Types; + +static FILE *logfile; +static cairo_bool_t _flush; +static cairo_bool_t _error; +static cairo_bool_t _line_info; +static cairo_bool_t _mark_dirty; +static const cairo_user_data_key_t destroy_key; +static pthread_once_t once_control = PTHREAD_ONCE_INIT; +static pthread_key_t counter_key; + +static void _init_trace (void); + +#define INIT_TRACE_ONCE() pthread_once (&once_control, _init_trace) + +#if __GNUC__ >= 3 && defined(__ELF__) && !defined(__sun) +# define _enter_trace() INIT_TRACE_ONCE () +# define _exit_trace() do { } while (0) +# define _should_trace() 1 +# define USE_ENTER_EXIT 0 +#else +static void _enter_trace (void); +static void _exit_trace (void); +static cairo_bool_t _should_trace (void); +# define USE_ENTER_EXIT 1 +#endif + +#if HAVE_BUILTIN_RETURN_ADDRESS && CAIRO_HAS_SYMBOL_LOOKUP +#define _emit_line_info() do { \ + if (_line_info && _write_lock ()) { \ + void *addr = __builtin_return_address(0); \ + char caller[1024]; \ + _trace_printf ("%% %s() called by %s\n", __FUNCTION__, \ + lookup_symbol (caller, sizeof (caller), addr)); \ + _write_unlock (); \ + } \ +} while (0) +#else +#define _emit_line_info() +#endif + +static void +_type_release_token (Type *t, unsigned long int token) +{ + struct _bitmap *b, **prev = NULL; + + b = &t->map; + while (b != NULL) { + if (token < b->min + sizeof (b->map) * CHAR_BIT) { + unsigned int bit, elem; + + token -= b->min; + elem = token / (sizeof (b->map[0]) * CHAR_BIT); + bit = token % (sizeof (b->map[0]) * CHAR_BIT); + b->map[elem] &= ~(1 << bit); + if (! --b->count && prev) { + *prev = b->next; + free (b); + } + return; + } + prev = &b->next; + b = b->next; + } +} + +static unsigned long int +_type_next_token (Type *t) +{ + struct _bitmap *b, *bb, **prev = NULL; + unsigned long int min = 0; + + b = &t->map; + while (b != NULL) { + if (b->min != min) + break; + + if (b->count < sizeof (b->map) * CHAR_BIT) { + unsigned int n, m, bit; + for (n = 0; n < ARRAY_LENGTH (b->map); n++) { + if (b->map[n] == (unsigned int) -1) + continue; + + for (m=0, bit=1; m<sizeof (b->map[0])*CHAR_BIT; m++, bit<<=1) { + if ((b->map[n] & bit) == 0) { + b->map[n] |= bit; + b->count++; + return n * sizeof (b->map[0])*CHAR_BIT + m + b->min; + } + } + } + } + min += sizeof (b->map) * CHAR_BIT; + + prev = &b->next; + b = b->next; + } + assert (prev != NULL); + + bb = malloc (sizeof (struct _bitmap)); + + *prev = bb; + bb->next = b; + bb->min = min; + bb->count = 1; + bb->map[0] = 0x1; + memset (bb->map + 1, 0, sizeof (bb->map) - sizeof (bb->map[0])); + + return min; +} + +static void +_object_destroy (Object *obj) +{ + int bucket; + + pthread_mutex_lock (&obj->type->mutex); + bucket = BUCKET (obj->type->objects, obj->addr); + _type_release_token (obj->type, obj->token); + + if (obj->prev != NULL) + obj->prev->next = obj->next; + else + obj->type->objects[bucket] = obj->next; + + if (obj->next != NULL) + obj->next->prev = obj->prev; + pthread_mutex_unlock (&obj->type->mutex); + + if (obj->data != NULL && obj->destroy != NULL) + obj->destroy (obj->data); + + free (obj); +} + +static void +_type_create (const char *typename, + enum operand_type op_type, + const char *op_code) +{ + Type *t; + + pthread_mutex_lock (&Types.mutex); + + t = malloc (sizeof (Type)); + t->name = typename; + t->op_type = op_type; + t->op_code = op_code; + + pthread_mutex_init (&t->mutex, NULL); + + t->map.min = 0; + t->map.count = 0; + memset (t->map.map, 0, sizeof (t->map.map)); + t->map.next = NULL; + + memset (t->objects, 0, sizeof (t->objects)); + + t->next = NULL; + + Types.op_types[op_type] = t; + pthread_mutex_unlock (&Types.mutex); +} + +static Type * +_get_type (enum operand_type type) +{ + return Types.op_types[type]; +} + +static void +_type_destroy (Type *t) +{ + int n; + struct _bitmap *b; + + for (n = 0; n < ARRAY_LENGTH (t->objects); n++) { + Object *obj = t->objects[n]; + while (obj != NULL) { + Object *next = obj->next; + _object_destroy (obj); + obj = next; + } + } + + b = t->map.next; + while (b != NULL) { + struct _bitmap *next = b->next; + free (b); + b = next; + } + + pthread_mutex_destroy (&t->mutex); + free (t); +} + +static Object * +_type_get_object (Type *type, const void *ptr) +{ + Object *obj; + int bucket = BUCKET (type->objects, ptr); + + for (obj = type->objects[bucket]; obj != NULL; obj = obj->next) { + if (obj->addr == ptr) { + if (obj->prev != NULL) { /* mru */ + obj->prev->next = obj->next; + if (obj->next != NULL) + obj->next->prev = obj->prev; + obj->prev = NULL; + type->objects[bucket]->prev = obj; + obj->next = type->objects[bucket]; + type->objects[bucket] = obj; + } + return obj; + } + } + + return NULL; +} + +static Object * +_object_create (Type *type, const void *ptr) +{ + Object *obj; + int bucket = BUCKET (type->objects, ptr); + + obj = malloc (sizeof (Object)); + obj->unknown = TRUE; + obj->defined = FALSE; + obj->foreign = FALSE; + obj->operand = -1; + obj->type = type; + obj->addr = ptr; + obj->token = _type_next_token (type); + obj->data = NULL; + obj->destroy = NULL; + obj->prev = NULL; + obj->next = type->objects[bucket]; + if (type->objects[bucket] != NULL) + type->objects[bucket]->prev = obj; + type->objects[bucket] = obj; + + return obj; +} + +#if USE_ENTER_EXIT +static int * +_get_counter (void) +{ + int *counter = pthread_getspecific (counter_key); + if (counter == NULL) { + counter = calloc(1, sizeof(int)); + pthread_setspecific (counter_key, counter); + } + return counter; +} + +static void +_enter_trace (void) +{ + INIT_TRACE_ONCE (); + _get_counter ()[0]++; +} + +static void +_exit_trace (void) +{ + _get_counter ()[0]--; +} + +static cairo_bool_t +_should_trace (void) +{ + return _get_counter ()[0] <= 1; +} +#endif /* USE_ENTER_EXIT */ + +static void +_init_trace (void) +{ + pthread_mutex_init (&Types.mutex, NULL); + pthread_key_create (&counter_key, free); + + _type_create ("unclassed", NONE, ""); + _type_create ("cairo_t", CONTEXT, "c"); + _type_create ("cairo_font_face_t", FONT_FACE, "f"); + _type_create ("cairo_pattern_t", PATTERN, "p"); + _type_create ("cairo_scaled_font_t", SCALED_FONT, "sf"); + _type_create ("cairo_surface_t", SURFACE, "s"); +} + +static void +_close_trace (void) +{ + if (logfile != NULL) { + fclose (logfile); + logfile = NULL; + } +} + +static void __attribute__ ((destructor)) +_fini_trace (void) +{ + int n; + + _close_trace (); + + for (n = 0; n < ARRAY_LENGTH (Types.op_types); n++) { + if (Types.op_types[n]) { + _type_destroy (Types.op_types[n]); + Types.op_types[n] = NULL; + } + } + + pthread_mutex_destroy (&Types.mutex); +} + +/* Format a double in a locale independent way and trim trailing + * zeros. Based on code from Alex Larson <alexl@redhat.com>. + * https://mail.gnome.org/archives/gtk-devel-list/2001-October/msg00087.html + * + * The code in the patch is copyright Red Hat, Inc under the LGPL. + */ +#define SIGNIFICANT_DIGITS_AFTER_DECIMAL 6 +static void +_trace_dtostr (char *buffer, size_t size, double d) +{ + struct lconv *locale_data; + const char *decimal_point; + int decimal_point_len; + char *p; + int decimal_len; + int num_zeros, decimal_digits; + + /* Omit the minus sign from negative zero. */ + if (d == 0.0) + d = 0.0; + + locale_data = localeconv (); + decimal_point = locale_data->decimal_point; + decimal_point_len = strlen (decimal_point); + + /* Using "%f" to print numbers less than 0.1 will result in + * reduced precision due to the default 6 digits after the + * decimal point. + * + * For numbers is < 0.1, we print with maximum precision and count + * the number of zeros between the decimal point and the first + * significant digit. We then print the number again with the + * number of decimal places that gives us the required number of + * significant digits. This ensures the number is correctly + * rounded. + */ + if (fabs (d) >= 0.1) { + snprintf (buffer, size, "%f", d); + } else { + snprintf (buffer, size, "%.18f", d); + p = buffer; + + if (*p == '+' || *p == '-') + p++; + + while (isdigit (*p)) + p++; + + if (strncmp (p, decimal_point, decimal_point_len) == 0) + p += decimal_point_len; + + num_zeros = 0; + while (*p++ == '0') + num_zeros++; + + decimal_digits = num_zeros + SIGNIFICANT_DIGITS_AFTER_DECIMAL; + + if (decimal_digits < 18) + snprintf (buffer, size, "%.*f", decimal_digits, d); + } + p = buffer; + + if (*p == '+' || *p == '-') + p++; + + while (isdigit (*p)) + p++; + + if (strncmp (p, decimal_point, decimal_point_len) == 0) { + *p = '.'; + decimal_len = strlen (p + decimal_point_len); + memmove (p + 1, p + decimal_point_len, decimal_len); + p[1 + decimal_len] = 0; + + /* Remove trailing zeros and decimal point if possible. */ + for (p = p + decimal_len; *p == '0'; p--) + *p = 0; + + if (*p == '.') { + *p = 0; + p--; + } + } +} + +enum { + LENGTH_MODIFIER_LONG = 0x100 +}; + +/* Here's a limited reimplementation of printf. The reason for doing + * this is primarily to special case handling of doubles. We want + * locale independent formatting of doubles and we want to trim + * trailing zeros. This is handled by dtostr() above, and the code + * below handles everything else by calling snprintf() to do the + * formatting. This functionality is only for internal use and we + * only implement the formats we actually use. + */ +static void CAIRO_PRINTF_FORMAT(1, 0) +_trace_vprintf (const char *fmt, va_list ap) +{ +#define SINGLE_FMT_BUFFER_SIZE 32 + char buffer[512], single_fmt[SINGLE_FMT_BUFFER_SIZE]; + int single_fmt_length; + char *p; + const char *f, *start; + int length_modifier, width; + cairo_bool_t var_width; + int ret_ignored; + + assert (_should_trace ()); + + f = fmt; + p = buffer; + while (*f != '\0') { + if (*f != '%') { + *p++ = *f++; + continue; + } + + start = f; + f++; + + if (*f == '0') + f++; + + var_width = 0; + if (*f == '*') { + var_width = 1; + f++; + } + + while (isdigit (*f)) + f++; + + length_modifier = 0; + if (*f == 'l') { + length_modifier = LENGTH_MODIFIER_LONG; + f++; + } + + /* The only format strings exist in the cairo implementation + * itself. So there's an internal consistency problem if any + * of them is larger than our format buffer size. */ + single_fmt_length = f - start + 1; + + /* Reuse the format string for this conversion. */ + memcpy (single_fmt, start, single_fmt_length); + single_fmt[single_fmt_length] = '\0'; + + /* Flush contents of buffer before snprintf()'ing into it. */ + ret_ignored = fwrite (buffer, 1, p-buffer, logfile); + + /* We group signed and unsigned together in this switch, the + * only thing that matters here is the size of the arguments, + * since we're just passing the data through to sprintf(). */ + switch (*f | length_modifier) { + case '%': + buffer[0] = *f; + buffer[1] = 0; + break; + case 'd': + case 'u': + case 'o': + case 'x': + case 'X': + if (var_width) { + width = va_arg (ap, int); + snprintf (buffer, sizeof buffer, + single_fmt, width, va_arg (ap, int)); + } else { + snprintf (buffer, sizeof buffer, single_fmt, va_arg (ap, int)); + } + break; + case 'd' | LENGTH_MODIFIER_LONG: + case 'u' | LENGTH_MODIFIER_LONG: + case 'o' | LENGTH_MODIFIER_LONG: + case 'x' | LENGTH_MODIFIER_LONG: + case 'X' | LENGTH_MODIFIER_LONG: + if (var_width) { + width = va_arg (ap, int); + snprintf (buffer, sizeof buffer, + single_fmt, width, va_arg (ap, long int)); + } else { + snprintf (buffer, sizeof buffer, + single_fmt, va_arg (ap, long int)); + } + break; + case 's': + snprintf (buffer, sizeof buffer, + single_fmt, va_arg (ap, const char *)); + break; + case 'f': + case 'g': + _trace_dtostr (buffer, sizeof buffer, va_arg (ap, double)); + break; + case 'c': + buffer[0] = va_arg (ap, int); + buffer[1] = 0; + break; + default: + break; + } + p = buffer + strlen (buffer); + f++; + } + + ret_ignored = fwrite (buffer, 1, p-buffer, logfile); + (void)ret_ignored; +} + +static void CAIRO_PRINTF_FORMAT(1, 2) +_trace_printf (const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + _trace_vprintf (fmt, ap); + va_end (ap); +} + +static void +get_prog_name (char *buf, int length) +{ + char *slash; + FILE *file; + + memset (buf, 0, length); + if (length == 0) + return; + + file = fopen ("/proc/self/cmdline", "rb"); + if (file != NULL) { + slash = fgets (buf, length, file); + fclose (file); + + if (slash == NULL) + return; + } else { + char const *name = getenv ("CAIRO_TRACE_PROG_NAME"); + if (name != NULL) { + strncpy (buf, name, length-1); + } + } + + slash = strrchr (buf, '/'); + if (slash != NULL) { + size_t len = strlen (slash+1); + memmove (buf, slash+1, len+1); + } +} + +static void +_emit_header (void) +{ + char name[4096] = ""; + + get_prog_name (name, sizeof (name)); + + _trace_printf ("%%!CairoScript - %s\n", name); +} + +static cairo_bool_t +_init_logfile (void) +{ + static cairo_bool_t initialized; + char buf[4096]; + const char *filename; + const char *env; + + if (initialized) + return logfile != NULL; + + initialized = TRUE; + + env = getenv ("CAIRO_TRACE_FLUSH"); + if (env != NULL) + _flush = atoi (env); + + _line_info = TRUE; + env = getenv ("CAIRO_TRACE_LINE_INFO"); + if (env != NULL) + _line_info = atoi (env); + + _mark_dirty = TRUE; + env = getenv ("CAIRO_TRACE_MARK_DIRTY"); + if (env != NULL) + _mark_dirty = atoi (env); + + filename = getenv ("CAIRO_TRACE_FD"); + if (filename != NULL) { + int fd = atoi (filename); + if (fd == -1) + return FALSE; + + logfile = fdopen (fd, "w"); + if (logfile == NULL) { + fprintf (stderr, "Failed to open trace file descriptor '%s': %s\n", + filename, strerror (errno)); + return FALSE; + } + + setenv ("CAIRO_TRACE_FD", "-1", 1); + goto done; + } + + filename = getenv ("CAIRO_TRACE_OUTFILE_EXACT"); + if (filename == NULL) { + char name[4096] = ""; + + filename = getenv ("CAIRO_TRACE_OUTDIR"); + if (filename == NULL) + filename = CAIRO_TRACE_OUTDIR; + + get_prog_name (name, sizeof (name)); + if (*name == '\0') + strcpy (name, "cairo-trace.dat"); + + snprintf (buf, sizeof (buf), "%s/%s.%d.trace", + filename, name, getpid()); + + filename = buf; + } else { + setenv ("CAIRO_TRACE_FD", "-1", 1); + } + + logfile = fopen (filename, "wb"); + if (logfile == NULL) { + fprintf (stderr, "Failed to open trace file '%s': %s\n", + filename, strerror (errno)); + return FALSE; + } + + fprintf (stderr, "cairo-trace: Recording cairo trace data to %s\n", + filename); + +done: + atexit (_close_trace); + _emit_header (); + return TRUE; +} + +static cairo_bool_t +_write_lock (void) +{ + if (_error) + return FALSE; + + if (! _should_trace ()) + return FALSE; + + if (! _init_logfile ()) + return FALSE; + +#if HAVE_FLOCKFILE && HAVE_FUNLOCKFILE + flockfile (logfile); +#endif + return TRUE; +} + +static void +_write_unlock (void) +{ + if (logfile == NULL) + return; + +#if HAVE_FLOCKFILE && HAVE_FUNLOCKFILE + funlockfile (logfile); +#endif + + if (_flush) + fflush (logfile); +} + + +static Object * +_type_object_create (enum operand_type op_type, const void *ptr) +{ + Type *type; + Object *obj; + + type = _get_type (op_type); + + pthread_mutex_lock (&type->mutex); + obj = _object_create (type, ptr); + pthread_mutex_unlock (&type->mutex); + + return obj; +} + +static Object * +_get_object (enum operand_type op_type, const void *ptr) +{ + Type *type; + Object *obj; + + type = _get_type (op_type); + pthread_mutex_lock (&type->mutex); + obj = _type_get_object (type, ptr); + pthread_mutex_unlock (&type->mutex); + + return obj; +} + +static Object *current_object[2048]; /* XXX limit operand stack */ +static int current_stack_depth; + +static void +dump_stack(const char *func) +{ +#if DEBUG_STACK + int n; + + _trace_printf ("%% %s: stack[%d] = [", func, current_stack_depth); + fflush (logfile); + for (n = 0; n < current_stack_depth; n++) { + Object *obj = current_object[n]; + assert(obj && obj->type); + _trace_printf (" %s%s%ld", + obj->defined ? "" : "*", + obj->type->op_code, obj->token); + fflush (logfile); + } + _trace_printf (" ]\n"); + fflush (logfile); +#endif +} + +static void +ensure_operands (int num_operands) +{ + if (current_stack_depth < num_operands) { + int n; + + fprintf (stderr, "Operand stack underflow!\n"); + for (n = 0; n < current_stack_depth; n++) { + Object *obj = current_object[n]; + + fprintf (stderr, " [%3d] = %s%ld\n", + n, obj->type->op_code, obj->token); + } + + abort (); + } +} + +static void +_consume_operand (bool discard) +{ + Object *obj; + + ensure_operands (1); + obj = current_object[--current_stack_depth]; + if (!discard && ! obj->defined) { + _trace_printf ("dup /%s%ld exch def\n", + obj->type->op_code, + obj->token); + obj->defined = TRUE; + } + obj->operand = -1; +} + +static void +_exch_operands (void) +{ + Object *tmp; + + ensure_operands (2); + tmp = current_object[current_stack_depth-1]; + tmp->operand--; + current_object[current_stack_depth-1] = current_object[current_stack_depth-2]; + current_object[current_stack_depth-2] = tmp; + tmp = current_object[current_stack_depth-1]; + tmp->operand++; +} + +static cairo_bool_t +_pop_operands_to_depth (int depth) +{ + if (depth < 0) + return FALSE; + + assert(current_stack_depth >= depth); + if (current_stack_depth == depth) + return TRUE; + + while (current_stack_depth > depth + 1) { + Object *c_obj; + + ensure_operands (1); + c_obj = current_object[--current_stack_depth]; + + assert(c_obj); + assert(c_obj->type); + + if (! c_obj->defined) { + current_stack_depth++; + return FALSE; + } + + _trace_printf ("pop %% %s%ld\n", + c_obj->type->op_code, c_obj->token); + c_obj->operand = -1; + } + + _exch_operands (); + _trace_printf ("exch\n"); + + dump_stack(__func__); + return TRUE; +} + +static cairo_bool_t +_pop_operands_to_object (Object *obj) +{ + if (!obj) + return FALSE; + + if (obj->operand == -1) + return FALSE; + + if (obj->operand == current_stack_depth - 1) + return TRUE; + + if (obj->operand == current_stack_depth - 2) { + _exch_operands (); + _trace_printf ("exch "); + return TRUE; + } + + return _pop_operands_to_depth (obj->operand + 1); +} + +static cairo_bool_t +_pop_operands_to (enum operand_type t, const void *ptr) +{ + return _pop_operands_to_object (_get_object (t, ptr)); +} + +static cairo_bool_t +_is_current_object (Object *obj, int depth) +{ + if (current_stack_depth <= depth) + return FALSE; + return current_object[current_stack_depth-depth-1] == obj; +} + +static cairo_bool_t +_is_current (enum operand_type type, const void *ptr, int depth) +{ + return _is_current_object (_get_object (type, ptr), depth); +} + +static void +_push_object(Object *obj) +{ + assert(obj->operand == -1); + + if (current_stack_depth == ARRAY_LENGTH (current_object)) { + int n; + + fprintf (stderr, "Operand stack overflow!\n"); + for (n = 0; n < current_stack_depth; n++) { + obj = current_object[n]; + + fprintf (stderr, " [%3d] = %s%ld\n", + n, obj->type->op_code, obj->token); + } + + abort (); + } + + obj->operand = current_stack_depth; + current_object[current_stack_depth++] = obj; +} + +static void +_push_operand (enum operand_type t, const void *ptr) +{ + _push_object(_get_object(t, ptr)); +} + +static void +_object_remove (Object *obj) +{ + if (obj->operand != -1) { + ensure_operands (1); + if (obj->operand == current_stack_depth - 1) { + _trace_printf ("pop %% %s%ld destroyed\n", + obj->type->op_code, obj->token); + } else if (obj->operand == current_stack_depth - 2) { + _exch_operands (); + _trace_printf ("exch pop %% %s%ld destroyed\n", + obj->type->op_code, obj->token); + } else { + int n; + + _trace_printf ("%d -1 roll pop %% %s%ld destroyed\n", + current_stack_depth - obj->operand, + obj->type->op_code, obj->token); + + for (n = obj->operand; n < current_stack_depth - 1; n++) { + current_object[n] = current_object[n+1]; + current_object[n]->operand = n; + } + } + obj->operand = -1; + + current_stack_depth--; + dump_stack(__func__); + } +} + +static void +_object_undef (void *ptr) +{ + Object *obj = ptr; + + if (_write_lock ()) { + _object_remove (obj); + + if (obj->defined) { + _trace_printf ("/%s%ld undef\n", + obj->type->op_code, obj->token); + } + + _write_unlock (); + } + + _object_destroy (obj); +} + +static long +_create_context_id (cairo_t *cr) +{ + Object *obj; + + obj = _get_object (CONTEXT, cr); + if (obj == NULL) { + obj = _type_object_create (CONTEXT, cr); + DLCALL (cairo_set_user_data, + cr, &destroy_key, obj, _object_undef); + } + + return obj->token; +} + +static long +_get_id (enum operand_type op_type, const void *ptr) +{ + Object *obj; + + obj = _get_object (op_type, ptr); + if (obj == NULL) { + if (logfile != NULL) { + _trace_printf ("%% Unknown object of type %s, trace is incomplete.", + _get_type (op_type)->name); + } + _error = TRUE; + return -1; + } + + return obj->token; +} + +static cairo_bool_t +_has_id (enum operand_type op_type, const void *ptr) +{ + return _get_object (op_type, ptr) != NULL; +} + +static long +_create_font_face_id (cairo_font_face_t *font_face) +{ + Object *obj; + + obj = _get_object (FONT_FACE, font_face); + if (obj == NULL) { + obj = _type_object_create (FONT_FACE, font_face); + DLCALL (cairo_font_face_set_user_data, + font_face, &destroy_key, obj, _object_undef); + } + + return obj->token; +} + +static long +_get_font_face_id (cairo_font_face_t *font_face) +{ + return _get_id (FONT_FACE, font_face); +} + +static void +_emit_font_face_id (cairo_font_face_t *font_face) +{ + Object *obj = _get_object (FONT_FACE, font_face); + if (obj == NULL) { + _trace_printf ("null "); + } else { + if (obj->defined) { + _trace_printf ("f%ld ", obj->token); + } else { + _trace_printf ("%d index ", current_stack_depth - obj->operand - 1); + } + } +} + +static cairo_bool_t +_has_pattern_id (cairo_pattern_t *pattern) +{ + return _has_id (PATTERN, pattern); +} + +static long +_create_pattern_id (cairo_pattern_t *pattern) +{ + Object *obj; + + obj = _get_object (PATTERN, pattern); + if (obj == NULL) { + obj = _type_object_create (PATTERN, pattern); + DLCALL (cairo_pattern_set_user_data, + pattern, &destroy_key, obj, _object_undef); + } + + return obj->token; +} + +static void +_emit_pattern_id (cairo_pattern_t *pattern) +{ + Object *obj = _get_object (PATTERN, pattern); + if (obj == NULL) { + _trace_printf ("null "); + } else { + if (obj->defined) { + _trace_printf ("p%ld ", obj->token); + } else { + _trace_printf ("%d index ", + current_stack_depth - obj->operand - 1); + } + } +} + +static void +_emit_scaled_font_id (const cairo_scaled_font_t *scaled_font) +{ + Object *obj = _get_object (SCALED_FONT, scaled_font); + if (obj == NULL) { + _trace_printf ("null "); + } else { + if (obj->defined) { + _trace_printf ("sf%ld ", obj->token); + } else { + _trace_printf ("%d index ", + current_stack_depth - obj->operand - 1); + } + } +} + +static long +_create_scaled_font_id (cairo_scaled_font_t *font) +{ + Object *obj; + + assert(_get_object (SCALED_FONT, font) == NULL); + obj = _type_object_create (SCALED_FONT, font); + DLCALL (cairo_scaled_font_set_user_data, + font, &destroy_key, obj, _object_undef); + + return obj->token; +} + +static cairo_bool_t +_has_scaled_font_id (const cairo_scaled_font_t *font) +{ + return _has_id (SCALED_FONT, font); +} + +static Object * +_create_surface (cairo_surface_t *surface) +{ + Object *obj; + + obj = _get_object (SURFACE, surface); + if (obj == NULL) { + obj = _type_object_create (SURFACE, surface); + DLCALL (cairo_surface_set_user_data, + surface, &destroy_key, obj, _object_undef); + } + + return obj; +} + +static long +_get_surface_id (cairo_surface_t *surface) +{ + return _get_id (SURFACE, surface); +} + +static cairo_bool_t +_matrix_is_identity (const cairo_matrix_t *m) +{ + return m->xx == 1. && m->yx == 0. && + m->xy == 0. && m->yy == 1. && + m->x0 == 0. && m->y0 == 0.; +} + +#define BUFFER_SIZE 16384 +struct _data_stream { + z_stream zlib_stream; + unsigned char zin_buf[BUFFER_SIZE]; + unsigned char zout_buf[BUFFER_SIZE]; + unsigned char four_tuple[4]; + int base85_pending; +}; + +static void +_write_zlib_data_start (struct _data_stream *stream) +{ + stream->zlib_stream.zalloc = Z_NULL; + stream->zlib_stream.zfree = Z_NULL; + stream->zlib_stream.opaque = Z_NULL; + + deflateInit (&stream->zlib_stream, Z_DEFAULT_COMPRESSION); + + stream->zlib_stream.next_in = stream->zin_buf; + stream->zlib_stream.avail_in = 0; + stream->zlib_stream.next_out = stream->zout_buf; + stream->zlib_stream.avail_out = BUFFER_SIZE; +} + +static void +_write_base85_data_start (struct _data_stream *stream) +{ + stream->base85_pending = 0; +} + +static cairo_bool_t +_expand_four_tuple_to_five (unsigned char four_tuple[4], + unsigned char five_tuple[5]) +{ + uint32_t value; + int digit, i; + cairo_bool_t all_zero = TRUE; + + value = four_tuple[0] << 24 | + four_tuple[1] << 16 | + four_tuple[2] << 8 | + four_tuple[3] << 0; + for (i = 0; i < 5; i++) { + digit = value % 85; + if (digit != 0 && all_zero) + all_zero = FALSE; + five_tuple[4-i] = digit + 33; + value = value / 85; + } + + return all_zero; +} + +static void +_write_base85_data (struct _data_stream *stream, + const unsigned char *data, + unsigned long length) +{ + unsigned char five_tuple[5]; + int ret; + + assert (_should_trace ()); + + while (length--) { + stream->four_tuple[stream->base85_pending++] = *data++; + if (stream->base85_pending == 4) { + if (_expand_four_tuple_to_five (stream->four_tuple, five_tuple)) + ret = fwrite ("z", 1, 1, logfile); + else + ret = fwrite (five_tuple, 5, 1, logfile); + (void)ret; + stream->base85_pending = 0; + } + } +} + +static void +_write_zlib_data (struct _data_stream *stream, cairo_bool_t flush) +{ + cairo_bool_t finished; + + do { + int ret = deflate (&stream->zlib_stream, flush ? Z_FINISH : Z_NO_FLUSH); + if (flush || stream->zlib_stream.avail_out == 0) { + _write_base85_data (stream, + stream->zout_buf, + BUFFER_SIZE - stream->zlib_stream.avail_out); + stream->zlib_stream.next_out = stream->zout_buf; + stream->zlib_stream.avail_out = BUFFER_SIZE; + } + + finished = TRUE; + if (stream->zlib_stream.avail_in != 0) + finished = FALSE; + if (flush && ret != Z_STREAM_END) + finished = FALSE; + } while (! finished); + + stream->zlib_stream.next_in = stream->zin_buf; +} + +static void +_write_data_start (struct _data_stream *stream, uint32_t len) +{ + _write_zlib_data_start (stream); + _write_base85_data_start (stream); + + _trace_printf ("<|"); + len = to_be32 (len); + _write_base85_data (stream, (unsigned char *) &len, sizeof (len)); +} + +static void +_write_data (struct _data_stream *stream, + const void *data, + unsigned int length) +{ + unsigned int count; + const unsigned char *p = data; + + while (length) { + count = length; + if (count > BUFFER_SIZE - stream->zlib_stream.avail_in) + count = BUFFER_SIZE - stream->zlib_stream.avail_in; + memcpy (stream->zin_buf + stream->zlib_stream.avail_in, p, count); + p += count; + stream->zlib_stream.avail_in += count; + length -= count; + + if (stream->zlib_stream.avail_in == BUFFER_SIZE) + _write_zlib_data (stream, FALSE); + } +} + +static void +_write_zlib_data_end (struct _data_stream *stream) +{ + _write_zlib_data (stream, TRUE); + deflateEnd (&stream->zlib_stream); + +} + +static void +_write_base85_data_end (struct _data_stream *stream) +{ + unsigned char five_tuple[5]; + int ret; + + assert (_should_trace ()); + + if (stream->base85_pending) { + memset (stream->four_tuple + stream->base85_pending, + 0, 4 - stream->base85_pending); + _expand_four_tuple_to_five (stream->four_tuple, five_tuple); + ret = fwrite (five_tuple, stream->base85_pending+1, 1, logfile); + (void) ret; + } +} + +static void +_write_data_end (struct _data_stream *stream) +{ + _write_zlib_data_end (stream); + _write_base85_data_end (stream); + + _trace_printf ("~>"); +} + +static void +_emit_data (const void *data, unsigned int length) +{ + struct _data_stream stream; + + _write_data_start (&stream, length); + _write_data (&stream, data, length); + _write_data_end (&stream); +} + +static const char * +_format_to_string (cairo_format_t format) +{ +#define f(name) case CAIRO_FORMAT_ ## name: return #name + switch (format) { + f(INVALID); + f(ARGB32); + f(RGB30); + f(RGB24); + f(RGB16_565); + f(A8); + f(A1); + } +#undef f + return "UNKNOWN_FORMAT"; +} + +static const char * +_format_to_content_string (cairo_format_t format) +{ + switch (format) { + case CAIRO_FORMAT_INVALID: + return "INVALID"; + case CAIRO_FORMAT_ARGB32: + return "COLOR_ALPHA"; + case CAIRO_FORMAT_RGB30: + case CAIRO_FORMAT_RGB24: + case CAIRO_FORMAT_RGB16_565: + return "COLOR"; + case CAIRO_FORMAT_A8: + case CAIRO_FORMAT_A1: + return "ALPHA"; + } + return "UNKNOWN"; +} + +static const char * +_status_to_string (cairo_status_t status) +{ +#define f(name) case CAIRO_STATUS_ ## name: return "STATUS_" #name + switch (status) { + f(SUCCESS); + f(NO_MEMORY); + f(INVALID_RESTORE); + f(INVALID_POP_GROUP); + f(NO_CURRENT_POINT); + f(INVALID_MATRIX); + f(INVALID_STATUS); + f(NULL_POINTER); + f(INVALID_STRING); + f(INVALID_PATH_DATA); + f(READ_ERROR); + f(WRITE_ERROR); + f(SURFACE_FINISHED); + f(SURFACE_TYPE_MISMATCH); + f(PATTERN_TYPE_MISMATCH); + f(INVALID_CONTENT); + f(INVALID_FORMAT); + f(INVALID_VISUAL); + f(FILE_NOT_FOUND); + f(INVALID_DASH); + f(INVALID_DSC_COMMENT); + f(INVALID_INDEX); + f(CLIP_NOT_REPRESENTABLE); + f(TEMP_FILE_ERROR); + f(INVALID_STRIDE); + f(FONT_TYPE_MISMATCH); + f(USER_FONT_IMMUTABLE); + f(USER_FONT_ERROR); + f(NEGATIVE_COUNT); + f(INVALID_CLUSTERS); + f(INVALID_SLANT); + f(INVALID_WEIGHT); + f(INVALID_SIZE); + f(USER_FONT_NOT_IMPLEMENTED); + f(DEVICE_TYPE_MISMATCH); + f(DEVICE_ERROR); + f(INVALID_MESH_CONSTRUCTION); + f(DEVICE_FINISHED); + f(JBIG2_GLOBAL_MISSING); + f(PNG_ERROR); + f(FREETYPE_ERROR); + f(WIN32_GDI_ERROR); + f(TAG_ERROR); + case CAIRO_STATUS_LAST_STATUS: + break; + } + return "UNKNOWN_STATUS"; +#undef f +} + +static void CAIRO_PRINTF_FORMAT(2, 3) +_emit_image (cairo_surface_t *image, + const char *info, + ...) +{ + int stride, row, width, height; + uint32_t len; + cairo_format_t format; + uint8_t row_stack[BUFFER_SIZE]; + uint8_t *rowdata; + uint8_t *data; + struct _data_stream stream; + cairo_status_t status; + + status = DLCALL (cairo_surface_status, image); + if (status) { + _trace_printf ("<< /status //%s >> image", + _status_to_string (status)); + return; + } + + width = DLCALL (cairo_image_surface_get_width, image); + height = DLCALL (cairo_image_surface_get_height, image); + stride = DLCALL (cairo_image_surface_get_stride, image); + format = DLCALL (cairo_image_surface_get_format, image); + data = DLCALL (cairo_image_surface_get_data, image); + + _trace_printf ("dict\n" + " /width %d set\n" + " /height %d set\n" + " /format //%s set\n", + width, height, + _format_to_string (format)); + if (info != NULL) { + va_list ap; + + va_start (ap, info); + _trace_vprintf (info, ap); + va_end (ap); + } + + if (DLCALL (cairo_version) >= CAIRO_VERSION_ENCODE (1, 9, 0)) { + const char *mime_types[] = { + CAIRO_MIME_TYPE_JPEG, + CAIRO_MIME_TYPE_JP2, + CAIRO_MIME_TYPE_PNG, + NULL + }, **mime_type; + + for (mime_type = mime_types; *mime_type; mime_type++) { + const unsigned char *mime_data; + unsigned long mime_length; + + DLCALL (cairo_surface_get_mime_data, + image, *mime_type, &mime_data, &mime_length); + if (mime_data != NULL) { + _trace_printf (" /mime-type (%s) set\n" + " /source <~", + *mime_type); + _write_base85_data_start (&stream); + _write_base85_data (&stream, mime_data, mime_length); + _write_base85_data_end (&stream); + _trace_printf ("~> set\n" + " image"); + return; + } + } + } + + switch (format) { + case CAIRO_FORMAT_A1: len = (width + 7)/8; break; + case CAIRO_FORMAT_A8: len = width; break; + case CAIRO_FORMAT_RGB16_565: len = 2*width; break; + case CAIRO_FORMAT_RGB24: len = 3*width; break; + default: + case CAIRO_FORMAT_RGB30: + case CAIRO_FORMAT_INVALID: + case CAIRO_FORMAT_ARGB32: len = 4*width; break; + } + + _trace_printf (" /source "); + _write_data_start (&stream, len * height); + +#ifdef WORDS_BIGENDIAN + switch (format) { + case CAIRO_FORMAT_A1: + for (row = height; row--; ) { + _write_data (&stream, data, (width+7)/8); + data += stride; + } + break; + case CAIRO_FORMAT_A8: + for (row = height; row--; ) { + _write_data (&stream, data, width); + data += stride; + } + break; + case CAIRO_FORMAT_RGB16_565: + for (row = height; row--; ) { + _write_data (&stream, data, 2*width); + data += stride; + } + break; + case CAIRO_FORMAT_RGB24: + for (row = height; row--; ) { + int col; + rowdata = data; + for (col = width; col--; ) { + _write_data (&stream, rowdata, 3); + rowdata+=4; + } + data += stride; + } + break; + case CAIRO_FORMAT_RGB30: + case CAIRO_FORMAT_ARGB32: + for (row = height; row--; ) { + _write_data (&stream, data, 4*width); + data += stride; + } + break; + case CAIRO_FORMAT_INVALID: + default: + break; + } +#else + if (stride > ARRAY_LENGTH (row_stack)) { + rowdata = malloc (stride); + if (rowdata == NULL) + goto BAIL; + } else + rowdata = row_stack; + + switch (format) { + case CAIRO_FORMAT_A1: + for (row = height; row--; ) { + int col; + for (col = 0; col < (width + 7)/8; col++) + rowdata[col] = CAIRO_BITSWAP8 (data[col]); + _write_data (&stream, rowdata, (width+7)/8); + data += stride; + } + break; + case CAIRO_FORMAT_A8: + for (row = height; row--; ) { + _write_data (&stream, rowdata, width); + data += stride; + } + break; + case CAIRO_FORMAT_RGB16_565: /* XXX endianness */ + for (row = height; row--; ) { + uint16_t *src = (uint16_t *) data; + uint16_t *dst = (uint16_t *)rowdata; + int col; + for (col = 0; col < width; col++) + dst[col] = bswap_16 (src[col]); + _write_data (&stream, rowdata, 2*width); + data += stride; + } + break; + case CAIRO_FORMAT_RGB24: + for (row = height; row--; ) { + uint8_t *src = data; + int col; + for (col = 0; col < width; col++) { + rowdata[3*col+2] = *src++; + rowdata[3*col+1] = *src++; + rowdata[3*col+0] = *src++; + src++; + } + _write_data (&stream, rowdata, 3*width); + data += stride; + } + break; + case CAIRO_FORMAT_RGB30: + case CAIRO_FORMAT_ARGB32: + for (row = height; row--; ) { + uint32_t *src = (uint32_t *) data; + uint32_t *dst = (uint32_t *) rowdata; + int col; + for (col = 0; col < width; col++) + dst[col] = bswap_32 (src[col]); + _write_data (&stream, rowdata, 4*width); + data += stride; + } + break; + case CAIRO_FORMAT_INVALID: + default: + break; + } + if (rowdata != row_stack) + free (rowdata); + +BAIL: + _write_data_end (&stream); +#endif + _trace_printf (" set\n image"); +} + +static void +_encode_string_literal (char *out, int max, + const char *utf8, int len) +{ + char c; + const char *end; + + *out++ = '('; + max--; + + if (utf8 == NULL) + goto DONE; + + if (len < 0) + len = strlen (utf8); + end = utf8 + len; + + while (utf8 < end) { + if (max < 5) + break; + + switch ((c = *utf8++)) { + case '\n': + *out++ = '\\'; + *out++ = 'n'; + max -= 2; + break; + case '\r': + *out++ = '\\'; + *out++ = 'r'; + max -= 2; + case '\t': + *out++ = '\\'; + *out++ = 't'; + max -= 2; + break; + case '\b': + *out++ = '\\'; + *out++ = 'b'; + max -= 2; + break; + case '\f': + *out++ = '\\'; + *out++ = 'f'; + max -= 2; + break; + case '\\': + case '(': + case ')': + *out++ = '\\'; + *out++ = c; + max -= 2; + break; + default: + if (isprint (c) || isspace (c)) { + *out++ = c; + } else { + int octal = 0; + while (c) { + octal *= 10; + octal += c&7; + c /= 8; + } + octal = snprintf (out, max, "\\%03d", octal); + out += octal; + max -= octal; + } + break; + } + } +DONE: + *out++ = ')'; + *out = '\0'; +} + +static void +to_octal (int value, char *buf, size_t size) +{ + do { + buf[--size] = '0' + (value & 7); + value >>= 3; + } while (size); +} + +static void +_emit_string_literal (const char *utf8, int len) +{ + char c; + const char *end; + + if (utf8 == NULL) { + _trace_printf ("()"); + return; + } + + if (len < 0) + len = strlen (utf8); + end = utf8 + len; + + _trace_printf ("("); + while (utf8 < end) { + switch ((c = *utf8++)) { + case '\n': + c = 'n'; + goto ESCAPED_CHAR; + case '\r': + c = 'r'; + goto ESCAPED_CHAR; + case '\t': + c = 't'; + goto ESCAPED_CHAR; + case '\b': + c = 'b'; + goto ESCAPED_CHAR; + case '\f': + c = 'f'; + goto ESCAPED_CHAR; + case '\\': + case '(': + case ')': +ESCAPED_CHAR: + _trace_printf ("\\%c", c); + break; + default: + if (isprint (c) || isspace (c)) { + _trace_printf ("%c", c); + } else { + char buf[4] = { '\\' }; + int ret_ignored; + + to_octal (c, buf+1, 3); + ret_ignored = fwrite (buf, 4, 1, logfile); + (void)ret_ignored; + } + break; + } + } + _trace_printf (")"); +} + +static void +_emit_current (Object *obj) +{ + if (obj != NULL && ! _pop_operands_to_object (obj)) { + if (obj->operand != -1) { + int n; + + _trace_printf ("%d -1 roll %% %s%ld\n", + current_stack_depth - obj->operand, + obj->type->op_code, obj->token); + + for (n = obj->operand; n < current_stack_depth - 1; n++) { + current_object[n] = current_object[n+1]; + current_object[n]->operand = n; + } + obj->operand = -1; + current_stack_depth--; + } else { + assert(obj->defined); + _trace_printf ("%s%ld\n", obj->type->op_code, obj->token); + } + + _push_object (obj); + dump_stack(__func__); + } +} + +static void +_emit_context (cairo_t *cr) +{ + _emit_current (_get_object (CONTEXT, cr)); +} + +static void +_emit_pattern (cairo_pattern_t *pattern) +{ + _emit_current (_get_object (PATTERN, pattern)); +} + +static void +_emit_surface (cairo_surface_t *surface) +{ + _emit_current (_get_object (SURFACE, surface)); +} + +static void CAIRO_PRINTF_FORMAT(2, 3) +_emit_cairo_op (cairo_t *cr, const char *fmt, ...) +{ + va_list ap; + + if (cr == NULL || ! _write_lock ()) + return; + + _emit_context (cr); + + va_start (ap, fmt); + _trace_vprintf ( fmt, ap); + va_end (ap); + + _write_unlock (); +} + +cairo_t * +cairo_create (cairo_surface_t *target) +{ + cairo_t *ret; + long surface_id; + long context_id; + + _enter_trace (); + + ret = DLCALL (cairo_create, target); + context_id = _create_context_id (ret); + + _emit_line_info (); + if (target != NULL && _write_lock ()) { + surface_id = _get_surface_id (target); + if (surface_id != -1) { + _get_object (SURFACE, target)->foreign = FALSE; + + /* we presume that we will continue to use the context */ + if (_pop_operands_to (SURFACE, target)){ + _consume_operand (false); + } else { + _trace_printf ("s%ld ", surface_id); + } + _trace_printf ("context %% c%ld\n", context_id); + _push_operand (CONTEXT, ret); + dump_stack(__func__); + } + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +void +cairo_save (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "save\n"); + DLCALL (cairo_save, cr); + _exit_trace (); +} + +void +cairo_restore (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "restore\n"); + DLCALL (cairo_restore, cr); + _exit_trace (); +} + +void +cairo_push_group (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "//COLOR_ALPHA push-group\n"); + DLCALL (cairo_push_group, cr); + _exit_trace (); +} + +static const char * +_content_to_string (cairo_content_t content) +{ + switch (content) { + case CAIRO_CONTENT_ALPHA: return "ALPHA"; + case CAIRO_CONTENT_COLOR: return "COLOR"; + default: + case CAIRO_CONTENT_COLOR_ALPHA: return "COLOR_ALPHA"; + } +} + +void +cairo_push_group_with_content (cairo_t *cr, cairo_content_t content) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "//%s push-group\n", _content_to_string (content)); + DLCALL (cairo_push_group_with_content, cr, content); + _exit_trace (); +} + +cairo_pattern_t * +cairo_pop_group (cairo_t *cr) +{ + cairo_pattern_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_pop_group, cr); + + _emit_line_info (); + _emit_cairo_op (cr, "pop-group %% p%ld\n", _create_pattern_id (ret)); + _push_operand (PATTERN, ret); + dump_stack(__func__); + + _exit_trace (); + return ret; +} + +void +cairo_pop_group_to_source (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "pop-group set-source\n"); + DLCALL (cairo_pop_group_to_source, cr); + _exit_trace (); +} + +static const char * +_operator_to_string (cairo_operator_t op) +{ +#define f(name) case CAIRO_OPERATOR_ ## name: return #name + switch (op) { + f(OVER); + f(SOURCE); + f(CLEAR); + f(IN); + f(OUT); + f(ATOP); + f(DEST); + f(DEST_OVER); + f(DEST_IN); + f(DEST_OUT); + f(DEST_ATOP); + f(XOR); + f(ADD); + f(SATURATE); + f(MULTIPLY); + f(SCREEN); + f(OVERLAY); + f(DARKEN); + f(LIGHTEN); + case CAIRO_OPERATOR_COLOR_DODGE: return "DODGE"; + case CAIRO_OPERATOR_COLOR_BURN: return "BURN"; + f(HARD_LIGHT); + f(SOFT_LIGHT); + f(DIFFERENCE); + f(EXCLUSION); + f(HSL_HUE); + f(HSL_SATURATION); + f(HSL_COLOR); + f(HSL_LUMINOSITY); + } +#undef f + return "UNKNOWN_OPERATOR"; +} + +void +cairo_set_operator (cairo_t *cr, cairo_operator_t op) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "//%s set-operator\n", _operator_to_string (op)); + DLCALL (cairo_set_operator, cr, op); + _exit_trace (); +} + +void +cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g %g %g set-source-rgb\n", red, green, blue); + DLCALL (cairo_set_source_rgb, cr, red, green, blue); + _exit_trace (); +} + +void +cairo_set_source_rgba (cairo_t *cr, double red, double green, double blue, double alpha) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g %g %g %g set-source-rgba\n", + red, green, blue, alpha); + DLCALL (cairo_set_source_rgba, cr, red, green, blue, alpha); + _exit_trace (); +} + +static void +_emit_source_image (cairo_surface_t *surface) +{ + Object *obj; + cairo_surface_t *image; + cairo_t *cr; + + obj = _get_object (SURFACE, surface); + if (obj == NULL) + return; + + image = DLCALL (cairo_image_surface_create, + CAIRO_FORMAT_ARGB32, + obj->width, + obj->height); + cr = DLCALL (cairo_create, image); + DLCALL (cairo_set_source_surface, cr, surface, 0, 0); + DLCALL (cairo_paint, cr); + DLCALL (cairo_destroy, cr); + + _emit_image (image, NULL); + _trace_printf (" set-source-image "); + DLCALL (cairo_surface_destroy, image); + + obj->foreign = FALSE; +} + +static void +_emit_source_image_rectangle (cairo_surface_t *surface, + int x, int y, + int width, int height) +{ + Object *obj; + cairo_surface_t *image; + cairo_t *cr; + + obj = _get_object (SURFACE, surface); + if (obj == NULL) + return; + + if (obj->foreign) { + _emit_source_image (surface); + return; + } + + image = DLCALL (cairo_image_surface_create, + CAIRO_FORMAT_ARGB32, + width, + height); + cr = DLCALL (cairo_create, image); + DLCALL (cairo_set_source_surface, cr, surface, x, y); + DLCALL (cairo_paint, cr); + DLCALL (cairo_destroy, cr); + + _emit_image (image, NULL); + _trace_printf (" %d %d set-device-offset set-source-image ", + x, y); + DLCALL (cairo_surface_destroy, image); +} + +void +cairo_set_source_surface (cairo_t *cr, cairo_surface_t *surface, double x, double y) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && surface != NULL && _write_lock ()) { + Object *obj = _get_object (SURFACE, surface); + + if (_is_current (SURFACE, surface, 0) && + _is_current (CONTEXT, cr, 1)) + { + _consume_operand (false); + } + else if (_is_current (SURFACE, surface, 1) && + _is_current (CONTEXT, cr, 0) && + obj->defined) + { + _trace_printf ("exch "); + _exch_operands (); + _consume_operand (false); + } else if (obj->defined) { + _emit_context (cr); + _trace_printf ("s%ld ", obj->token); + } else { + _emit_context (cr); + _trace_printf ("%d index ", + current_stack_depth - obj->operand - 1); + } + + if (obj->foreign) + _emit_source_image (surface); + + _trace_printf ("pattern"); + if (x != 0. || y != 0.) + _trace_printf (" %g %g translate", -x, -y); + + _trace_printf (" set-source\n"); + _write_unlock (); + } + + DLCALL (cairo_set_source_surface, cr, surface, x, y); + _exit_trace (); +} + +void +cairo_set_source (cairo_t *cr, cairo_pattern_t *source) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && source != NULL && _write_lock ()) { + Object *obj = _get_object (PATTERN, source); + cairo_bool_t need_context_and_pattern = TRUE; + + if (_is_current (PATTERN, source, 0) && + _is_current (CONTEXT, cr, 1)) + { + if (obj->defined) { + _consume_operand (false); + } else { + _trace_printf ("exch 1 index "); + _exch_operands (); + } + need_context_and_pattern = FALSE; + } + else if (_is_current (PATTERN, source, 1) && + _is_current (CONTEXT, cr, 0)) + { + if (obj->defined) { + _trace_printf ("exch "); + _exch_operands (); + _consume_operand (false); + need_context_and_pattern = FALSE; + } + } + + if (need_context_and_pattern) { + _emit_context (cr); + _emit_pattern_id (source); + } + + _trace_printf ("set-source %% p%ld\n", obj->token); + _write_unlock (); + } + + DLCALL (cairo_set_source, cr, source); + _exit_trace (); +} + +cairo_pattern_t * +cairo_get_source (cairo_t *cr) +{ + cairo_pattern_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_get_source, cr); + + if (! _has_pattern_id (ret)) { + _emit_cairo_op (cr, "/source get /p%ld exch def\n", + _create_pattern_id (ret)); + _get_object (PATTERN, ret)->defined = TRUE; + } + + _exit_trace (); + return ret; +} + +void +cairo_set_tolerance (cairo_t *cr, double tolerance) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g set-tolerance\n", tolerance); + DLCALL (cairo_set_tolerance, cr, tolerance); + _exit_trace (); +} + +static const char * +_antialias_to_string (cairo_antialias_t antialias) +{ +#define f(name) case CAIRO_ANTIALIAS_ ## name: return "ANTIALIAS_" #name + switch (antialias) { + f(DEFAULT); + + f(NONE); + f(GRAY); + f(SUBPIXEL); + + f(FAST); + f(GOOD); + f(BEST); + }; +#undef f + return "UNKNOWN_ANTIALIAS"; +} + +void +cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, + "//%s set-antialias\n", _antialias_to_string (antialias)); + DLCALL (cairo_set_antialias, cr, antialias); + _exit_trace (); +} + +static const char * +_fill_rule_to_string (cairo_fill_rule_t rule) +{ +#define f(name) case CAIRO_FILL_RULE_ ## name: return #name + switch (rule) { + f(WINDING); + f(EVEN_ODD); + }; +#undef f + return "UNKNOWN_FILL_RULE"; +} + +void +cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, + "//%s set-fill-rule\n", _fill_rule_to_string (fill_rule)); + DLCALL (cairo_set_fill_rule, cr, fill_rule); + _exit_trace (); +} + +void +cairo_set_line_width (cairo_t *cr, double width) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g set-line-width\n", width); + DLCALL (cairo_set_line_width, cr, width); + _exit_trace (); +} + +static const char * +_line_cap_to_string (cairo_line_cap_t line_cap) +{ +#define f(name) case CAIRO_LINE_CAP_ ## name: return "LINE_CAP_" #name + switch (line_cap) { + f(BUTT); + f(ROUND); + f(SQUARE); + }; +#undef f + return "UNKNOWN_LINE_CAP"; +} + +void +cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "//%s set-line-cap\n", _line_cap_to_string (line_cap)); + DLCALL (cairo_set_line_cap, cr, line_cap); + _exit_trace (); +} + +static const char * +_line_join_to_string (cairo_line_join_t line_join) +{ +#define f(name) case CAIRO_LINE_JOIN_ ## name: return "LINE_JOIN_" #name + switch (line_join) { + f(MITER); + f(ROUND); + f(BEVEL); + }; +#undef f + return "UNKNOWN_LINE_JOIN"; +} + +void +cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, + "//%s set-line-join\n", _line_join_to_string (line_join)); + DLCALL (cairo_set_line_join, cr, line_join); + _exit_trace (); +} + +void +cairo_set_dash (cairo_t *cr, const double *dashes, int num_dashes, double offset) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && _write_lock ()) { + int n; + + _emit_context (cr); + + _trace_printf ("["); + for (n = 0; n < num_dashes; n++) { + if (n != 0) + _trace_printf (" "); + _trace_printf ("%g", dashes[n]); + } + _trace_printf ("] %g set-dash\n", offset); + + _write_unlock (); + } + + DLCALL (cairo_set_dash, cr, dashes, num_dashes, offset); + _exit_trace (); +} + +void +cairo_set_miter_limit (cairo_t *cr, double limit) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g set-miter-limit\n", limit); + DLCALL (cairo_set_miter_limit, cr, limit); + _exit_trace (); +} + +void +cairo_translate (cairo_t *cr, double tx, double ty) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g %g translate\n", tx, ty); + DLCALL (cairo_translate, cr, tx, ty); + _exit_trace (); +} + +void +cairo_scale (cairo_t *cr, double sx, double sy) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g %g scale\n", sx, sy); + DLCALL (cairo_scale, cr, sx, sy); + _exit_trace (); +} + +void +cairo_rotate (cairo_t *cr, double angle) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g rotate\n", angle); + DLCALL (cairo_rotate, cr, angle); + _exit_trace (); +} + +void +cairo_transform (cairo_t *cr, const cairo_matrix_t *matrix) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g %g %g %g %g %g matrix transform\n", + matrix->xx, matrix->yx, + matrix->xy, matrix->yy, + matrix->x0, matrix->y0); + DLCALL (cairo_transform, cr, matrix); + _exit_trace (); +} + +void +cairo_set_matrix (cairo_t *cr, const cairo_matrix_t *matrix) +{ + _enter_trace (); + _emit_line_info (); + if (_matrix_is_identity (matrix)) { + _emit_cairo_op (cr, "identity set-matrix\n"); + } else { + _emit_cairo_op (cr, "%g %g %g %g %g %g matrix set-matrix\n", + matrix->xx, matrix->yx, + matrix->xy, matrix->yy, + matrix->x0, matrix->y0); + } + DLCALL (cairo_set_matrix, cr, matrix); + _exit_trace (); +} + +cairo_surface_t * +cairo_get_target (cairo_t *cr) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_get_target, cr); + if (cr != NULL) { + Object *obj = _create_surface (ret); + + if (! obj->defined) { + _emit_cairo_op (cr, + "/target get /s%ld exch def\n", + obj->token); + obj->defined = TRUE; + } + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_get_group_target (cairo_t *cr) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_get_group_target, cr); + if (cr != NULL) { + Object *obj = _create_surface (ret); + + if (! obj->defined) { + _emit_cairo_op (cr, + "/group-target get /s%ld exch def\n", + obj->token); + obj->defined = TRUE; + } + } + + _exit_trace (); + return ret; +} + +void +cairo_identity_matrix (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "identity set-matrix\n"); + DLCALL (cairo_identity_matrix, cr); + _exit_trace (); +} + +void +cairo_new_path (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "n "); + DLCALL (cairo_new_path, cr); + _exit_trace (); +} + +void +cairo_move_to (cairo_t *cr, double x, double y) +{ + _enter_trace (); + _emit_cairo_op (cr, "%g %g m ", x, y); + DLCALL (cairo_move_to, cr, x, y); + _exit_trace (); +} + +void +cairo_new_sub_path (cairo_t *cr) +{ + _enter_trace (); + _emit_cairo_op (cr, "N "); + DLCALL (cairo_new_sub_path, cr); + _exit_trace (); +} + +void +cairo_line_to (cairo_t *cr, double x, double y) +{ + _enter_trace (); + _emit_cairo_op (cr, "%g %g l ", x, y); + DLCALL (cairo_line_to, cr, x, y); + _exit_trace (); +} + +void +cairo_curve_to (cairo_t *cr, double x1, double y1, double x2, double y2, double x3, double y3) +{ + _enter_trace (); + _emit_cairo_op (cr, "%g %g %g %g %g %g c ", x1, y1, x2, y2, x3, y3); + DLCALL (cairo_curve_to, cr, x1, y1, x2, y2, x3, y3); + _exit_trace (); +} + +void +cairo_arc (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2) +{ + _enter_trace (); + _emit_cairo_op (cr, "%g %g %g %g %g arc\n", xc, yc, radius, angle1, angle2); + DLCALL (cairo_arc, cr, xc, yc, radius, angle1, angle2); + _exit_trace (); +} + +void +cairo_arc_negative (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2) +{ + _enter_trace (); + _emit_cairo_op (cr, "%g %g %g %g %g arc-\n", + xc, yc, radius, angle1, angle2); + DLCALL (cairo_arc_negative, cr, xc, yc, radius, angle1, angle2); + _exit_trace (); +} + +void +cairo_rel_move_to (cairo_t *cr, double dx, double dy) +{ + _enter_trace (); + _emit_cairo_op (cr, "%g %g M ", dx, dy); + DLCALL (cairo_rel_move_to, cr, dx, dy); + _exit_trace (); +} + +void +cairo_rel_line_to (cairo_t *cr, double dx, double dy) +{ + _enter_trace (); + _emit_cairo_op (cr, "%g %g L ", dx, dy); + DLCALL (cairo_rel_line_to, cr, dx, dy); + _exit_trace (); +} + +void +cairo_rel_curve_to (cairo_t *cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3) +{ + _enter_trace (); + _emit_cairo_op (cr, "%g %g %g %g %g %g C ", + dx1, dy1, dx2, dy2, dx3, dy3); + DLCALL (cairo_rel_curve_to, cr, dx1, dy1, dx2, dy2, dx3, dy3); + _exit_trace (); +} + +void +cairo_rectangle (cairo_t *cr, double x, double y, double width, double height) +{ + _enter_trace (); + _emit_cairo_op (cr, "%g %g %g %g rectangle\n", x, y, width, height); + DLCALL (cairo_rectangle, cr, x, y, width, height); + _exit_trace (); +} + +void +cairo_close_path (cairo_t *cr) +{ + _enter_trace (); + _emit_cairo_op (cr, "h\n"); + DLCALL (cairo_close_path, cr); + _exit_trace (); +} + +void +cairo_paint (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "paint\n"); + DLCALL (cairo_paint, cr); + _exit_trace (); +} + +void +cairo_paint_with_alpha (cairo_t *cr, double alpha) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g paint-with-alpha\n", alpha); + DLCALL (cairo_paint_with_alpha, cr, alpha); + _exit_trace (); +} + +void +cairo_mask (cairo_t *cr, cairo_pattern_t *pattern) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && pattern != NULL && _write_lock ()) { + Object *obj = _get_object (PATTERN, pattern); + cairo_bool_t need_context_and_pattern = TRUE; + + if (_is_current (PATTERN, pattern, 0) && + _is_current (CONTEXT, cr, 1)) + { + if (obj->defined) { + _consume_operand (false); + need_context_and_pattern = FALSE; + } + } + else if (_is_current (PATTERN, pattern, 1) && + _is_current (CONTEXT, cr, 0)) + { + if (obj->defined) { + _trace_printf ("exch "); + _exch_operands (); + _consume_operand (false); + need_context_and_pattern = FALSE; + } + } + + if (need_context_and_pattern) { + _emit_context (cr); + _emit_pattern_id (pattern); + } + + _trace_printf (" mask\n"); + _write_unlock (); + } + DLCALL (cairo_mask, cr, pattern); + _exit_trace (); +} + +void +cairo_mask_surface (cairo_t *cr, cairo_surface_t *surface, double x, double y) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && surface != NULL && _write_lock ()) { + Object *obj = _get_object (SURFACE, surface); + if (_is_current (SURFACE, surface, 0) && + _is_current (CONTEXT, cr, 1)) + { + _consume_operand (false); + } + else if (_is_current (SURFACE, surface, 1) && + _is_current (CONTEXT, cr, 0)) + { + _trace_printf ("exch "); + _exch_operands (); + _consume_operand (false); + } else if (obj->defined){ + _emit_context (cr); + _trace_printf ("s%ld ", obj->token); + } else { + _emit_context (cr); + _trace_printf ("%d index ", + current_stack_depth - obj->operand - 1); + } + _trace_printf ("pattern"); + + if (x != 0. || y != 0.) + _trace_printf (" %g %g translate", -x, -y); + + _trace_printf (" mask\n"); + _write_unlock (); + } + + DLCALL (cairo_mask_surface, cr, surface, x, y); + _exit_trace (); +} + +void +cairo_stroke (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "stroke\n"); + DLCALL (cairo_stroke, cr); + _exit_trace (); +} + +void +cairo_stroke_preserve (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "stroke+\n"); + DLCALL (cairo_stroke_preserve, cr); + _exit_trace (); +} + +void +cairo_fill (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "fill\n"); + DLCALL (cairo_fill, cr); + _exit_trace (); +} + +void +cairo_fill_preserve (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "fill+\n"); + DLCALL (cairo_fill_preserve, cr); + _exit_trace (); +} + +void +cairo_copy_page (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "copy-page\n"); + DLCALL (cairo_copy_page, cr); + _exit_trace (); +} + +void +cairo_show_page (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "show-page\n"); + DLCALL (cairo_show_page, cr); + _exit_trace (); +} + +void +cairo_clip (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "clip\n"); + DLCALL (cairo_clip, cr); + _exit_trace (); +} + +void +cairo_clip_preserve (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "clip+\n"); + DLCALL (cairo_clip_preserve, cr); + _exit_trace (); +} + +void +cairo_reset_clip (cairo_t *cr) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "reset-clip\n"); + DLCALL (cairo_reset_clip, cr); + _exit_trace (); +} + + +static const char * +_slant_to_string (cairo_font_slant_t font_slant) +{ +#define f(name) case CAIRO_FONT_SLANT_ ## name: return "SLANT_" #name + switch (font_slant) { + f(NORMAL); + f(ITALIC); + f(OBLIQUE); + }; +#undef f + return "UNKNOWN_SLANT"; +} + +static const char * +_weight_to_string (cairo_font_weight_t font_weight) +{ +#define f(name) case CAIRO_FONT_WEIGHT_ ## name: return "WEIGHT_" #name + switch (font_weight) { + f(NORMAL); + f(BOLD); + }; +#undef f + return "UNKNOWN_WEIGHT"; +} + +void +cairo_select_font_face (cairo_t *cr, const char *family, cairo_font_slant_t slant, cairo_font_weight_t weight) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && _write_lock ()) { + _emit_context (cr); + _emit_string_literal (family, -1); + _trace_printf (" //%s //%s select-font-face\n", + _slant_to_string (slant), + _weight_to_string (weight)); + _write_unlock (); + } + DLCALL (cairo_select_font_face, cr, family, slant, weight); + _exit_trace (); +} + +cairo_font_face_t * +cairo_get_font_face (cairo_t *cr) +{ + cairo_font_face_t *ret; + long font_face_id; + + _enter_trace (); + + ret = DLCALL (cairo_get_font_face, cr); + font_face_id = _create_font_face_id (ret); + + _emit_cairo_op (cr, "/font-face get %% f%ld\n", font_face_id); + _push_operand (FONT_FACE, ret); + dump_stack(__func__); + + _exit_trace (); + return ret; +} + +void +cairo_set_font_face (cairo_t *cr, cairo_font_face_t *font_face) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && font_face != NULL && _write_lock ()) { + if (_is_current (FONT_FACE, font_face, 0) && + _is_current (CONTEXT, cr, 1)) + { + _consume_operand (false); + } + else if (_is_current (FONT_FACE, font_face, 1) && + _is_current (CONTEXT, cr, 0)) + { + _trace_printf ("exch "); + _exch_operands (); + _consume_operand (false); + } + else + { + _emit_context (cr); + _emit_font_face_id (font_face); + } + + _trace_printf ("set-font-face\n"); + _write_unlock (); + } + + DLCALL (cairo_set_font_face, cr, font_face); + _exit_trace (); +} + +void +cairo_set_font_size (cairo_t *cr, double size) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g set-font-size\n", size); + DLCALL (cairo_set_font_size, cr, size); + _exit_trace (); +} + +void +cairo_set_font_matrix (cairo_t *cr, const cairo_matrix_t *matrix) +{ + _enter_trace (); + _emit_line_info (); + _emit_cairo_op (cr, "%g %g %g %g %g %g matrix set-font-matrix\n", + matrix->xx, matrix->yx, + matrix->xy, matrix->yy, + matrix->x0, matrix->y0); + DLCALL (cairo_set_font_matrix, cr, matrix); + _exit_trace (); +} + +static const char * +_subpixel_order_to_string (cairo_subpixel_order_t subpixel_order) +{ +#define f(name) case CAIRO_SUBPIXEL_ORDER_ ## name: return "SUBPIXEL_ORDER_" #name + switch (subpixel_order) { + f(DEFAULT); + f(RGB); + f(BGR); + f(VRGB); + f(VBGR); + }; +#undef f + return "UNKNOWN_SUBPIXEL_ORDER"; +} + +static const char * +_hint_style_to_string (cairo_hint_style_t hint_style) +{ +#define f(name) case CAIRO_HINT_STYLE_ ## name: return "HINT_STYLE_" #name + switch (hint_style) { + f(DEFAULT); + f(NONE); + f(SLIGHT); + f(MEDIUM); + f(FULL); + }; +#undef f + return "UNKNOWN_HINT_STYLE"; +} + +static const char * +_hint_metrics_to_string (cairo_hint_metrics_t hint_metrics) +{ +#define f(name) case CAIRO_HINT_METRICS_ ## name: return "HINT_METRICS_" #name + switch (hint_metrics) { + f(DEFAULT); + f(OFF); + f(ON); + }; +#undef f + return "UNKNOWN_HINT_METRICS"; +} + +static void +_emit_font_options (const cairo_font_options_t *options) +{ + cairo_antialias_t antialias; + cairo_subpixel_order_t subpixel_order; + cairo_hint_style_t hint_style; + cairo_hint_metrics_t hint_metrics; + + _trace_printf ("<<"); + + antialias = DLCALL (cairo_font_options_get_antialias, options); + if (antialias != CAIRO_ANTIALIAS_DEFAULT) { + _trace_printf (" /antialias //%s", + _antialias_to_string (antialias)); + } + + subpixel_order = DLCALL (cairo_font_options_get_subpixel_order, options); + if (subpixel_order != CAIRO_SUBPIXEL_ORDER_DEFAULT) { + _trace_printf (" /subpixel-order //%s", + _subpixel_order_to_string (subpixel_order)); + } + + hint_style = DLCALL (cairo_font_options_get_hint_style, options); + if (hint_style != CAIRO_HINT_STYLE_DEFAULT) { + _trace_printf (" /hint-style //%s", + _hint_style_to_string (hint_style)); + } + + hint_metrics = DLCALL (cairo_font_options_get_hint_metrics, options); + if (hint_metrics != CAIRO_HINT_METRICS_DEFAULT) { + _trace_printf (" /hint-metrics //%s", + _hint_metrics_to_string (hint_metrics)); + } + + _trace_printf (" >>"); +} + +void +cairo_set_font_options (cairo_t *cr, const cairo_font_options_t *options) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && options != NULL && _write_lock ()) { + _emit_context (cr); + _emit_font_options (options); + _trace_printf (" set-font-options\n"); + _write_unlock (); + } + + DLCALL (cairo_set_font_options, cr, options); + _exit_trace (); +} + +cairo_scaled_font_t * +cairo_get_scaled_font (cairo_t *cr) +{ + cairo_scaled_font_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_get_scaled_font, cr); + + if (cr != NULL && ! _has_scaled_font_id (ret)) { + _emit_cairo_op (cr, "/scaled-font get /sf%ld exch def\n", + _create_scaled_font_id (ret)); + _get_object (SCALED_FONT, ret)->defined = TRUE; + } + + _exit_trace (); + return ret; +} + +void +cairo_set_scaled_font (cairo_t *cr, const cairo_scaled_font_t *scaled_font) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && scaled_font != NULL && _write_lock ()) { + Object *obj = _get_object (SCALED_FONT, scaled_font); + cairo_bool_t need_context_and_font = TRUE; + + if (_is_current (SCALED_FONT, scaled_font, 0) && + _is_current (CONTEXT, cr, 1)) + { + if (obj->defined) { + _consume_operand (false); + } else { + _trace_printf ("exch 1 index "); + _exch_operands (); + } + need_context_and_font = FALSE; + } + else if (_is_current (SCALED_FONT, scaled_font, 1) && + _is_current (CONTEXT, cr, 0)) + { + if (obj->defined) { + _trace_printf ("exch "); + _exch_operands (); + _consume_operand (false); + need_context_and_font = FALSE; + } + } + + if (need_context_and_font) { + _emit_context (cr); + _emit_scaled_font_id (scaled_font); + } + + _trace_printf ("set-scaled-font\n"); + + _write_unlock (); + } + DLCALL (cairo_set_scaled_font, cr, scaled_font); + _exit_trace (); +} + +static void +_emit_matrix (const cairo_matrix_t *m) +{ + if (_matrix_is_identity(m)) + { + _trace_printf ("identity"); + } + else + { + _trace_printf ("%g %g %g %g %g %g matrix", + m->xx, m->yx, + m->xy, m->yy, + m->x0, m->y0); + } +} + +cairo_scaled_font_t * +cairo_scaled_font_create (cairo_font_face_t *font_face, + const cairo_matrix_t *font_matrix, + const cairo_matrix_t *ctm, + const cairo_font_options_t *options) +{ + cairo_scaled_font_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_scaled_font_create, font_face, font_matrix, ctm, options); + if (_has_scaled_font_id (ret)) + goto out; + + _emit_line_info (); + if (font_face != NULL && + font_matrix != NULL && + ctm != NULL && + options != NULL + && _write_lock ()) + { + Object *obj; + + obj = _type_object_create (SCALED_FONT, ret); + DLCALL (cairo_scaled_font_set_user_data, + ret, &destroy_key, obj, _object_undef); + + if (_pop_operands_to (FONT_FACE, font_face)) + _consume_operand (false); + else + _trace_printf ("f%ld ", _get_font_face_id (font_face)); + + _emit_matrix (font_matrix); + _trace_printf (" "); + + _emit_matrix (ctm); + _trace_printf (" "); + + _emit_font_options (options); + + _trace_printf (" scaled-font /sf%ld exch def\n", + obj->token); + obj->defined = TRUE; + + _write_unlock (); + } + +out: + _exit_trace (); + return ret; +} + +void +cairo_show_text (cairo_t *cr, const char *utf8) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && _write_lock ()) { + _emit_context (cr); + _emit_string_literal (utf8, -1); + _trace_printf (" show-text\n"); + _write_unlock (); + } + DLCALL (cairo_show_text, cr, utf8); + _exit_trace (); +} + +static void +_glyph_advance (cairo_scaled_font_t *font, + const cairo_glyph_t *glyph, + double *x, double *y) +{ + cairo_text_extents_t extents; + + DLCALL (cairo_scaled_font_glyph_extents, font, glyph, 1, &extents); + *x += extents.x_advance; + *y += extents.y_advance; +} + +#define TOLERANCE 1e-5 +static void +_emit_glyphs (cairo_scaled_font_t *font, + const cairo_glyph_t *glyphs, + int num_glyphs) +{ + double x,y; + int n; + + if (num_glyphs == 0) { + _trace_printf ("[]"); + return; + } + + for (n = 0; n < num_glyphs; n++) { + if (glyphs[n].index > 255) + break; + } + + x = glyphs->x; + y = glyphs->y; + if (n < num_glyphs) { /* need full glyph range */ + cairo_bool_t first; + + _trace_printf ("[%g %g [", x, y); + first = TRUE; + while (num_glyphs--) { + if (fabs (glyphs->x - x) > TOLERANCE || + fabs (glyphs->y - y) > TOLERANCE) + { + x = glyphs->x; + y = glyphs->y; + _trace_printf ("] %g %g [", x, y); + first = TRUE; + } + + if (! first) + _trace_printf (" "); + _trace_printf ("%lu", glyphs->index); + first = FALSE; + + _glyph_advance (font, glyphs, &x, &y); + glyphs++; + } + _trace_printf ("]]"); + } else { + struct _data_stream stream; + + if (num_glyphs == 1) { + _trace_printf ("[%g %g <%02lx>]", x, y, glyphs->index); + } else { + _trace_printf ("[%g %g <~", x, y); + _write_base85_data_start (&stream); + while (num_glyphs--) { + unsigned char c; + + if (fabs (glyphs->x - x) > TOLERANCE || + fabs (glyphs->y - y) > TOLERANCE) + { + x = glyphs->x; + y = glyphs->y; + _write_base85_data_end (&stream); + _trace_printf ("~> %g %g <~", x, y); + _write_base85_data_start (&stream); + } + + c = glyphs->index; + _write_base85_data (&stream, &c, 1); + + _glyph_advance (font, glyphs, &x, &y); + glyphs++; + } + _write_base85_data_end (&stream); + _trace_printf ("~>]"); + } + } +} + +void +cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && glyphs != NULL && _write_lock ()) { + cairo_scaled_font_t *font; + + _emit_context (cr); + font = DLCALL (cairo_get_scaled_font, cr); + + _emit_glyphs (font, glyphs, num_glyphs); + _trace_printf (" show-glyphs\n"); + _write_unlock (); + } + + DLCALL (cairo_show_glyphs, cr, glyphs, num_glyphs); + _exit_trace (); +} + +static const char * +_direction_to_string (cairo_bool_t backward) +{ + const char *names[] = { + "FORWARD", + "BACKWARD" + }; + return names[!!backward]; +} + +void +cairo_show_text_glyphs (cairo_t *cr, + const char *utf8, + int utf8_len, + const cairo_glyph_t *glyphs, + int num_glyphs, + const cairo_text_cluster_t *clusters, + int num_clusters, + cairo_text_cluster_flags_t backward) +{ + cairo_scaled_font_t *font; + + _enter_trace (); + + font = DLCALL (cairo_get_scaled_font, cr); + + _emit_line_info (); + if (cr != NULL && glyphs != NULL && clusters != NULL && _write_lock ()) { + int n; + + _emit_context (cr); + + _emit_string_literal (utf8, utf8_len); + + _emit_glyphs (font, glyphs, num_glyphs); + _trace_printf (" ["); + for (n = 0; n < num_clusters; n++) { + _trace_printf (" %d %d", + clusters[n].num_bytes, + clusters[n].num_glyphs); + } + _trace_printf (" ] //%s show-text-glyphs\n", + _direction_to_string (backward)); + + _write_unlock (); + } + + DLCALL (cairo_show_text_glyphs, cr, + utf8, utf8_len, + glyphs, num_glyphs, + clusters, num_clusters, + backward); + _exit_trace (); +} + +void +cairo_text_path (cairo_t *cr, const char *utf8) +{ + _enter_trace (); + _emit_line_info (); + if (cr != NULL && _write_lock ()) { + _emit_context (cr); + _emit_string_literal (utf8, -1); + _trace_printf (" text-path\n"); + _write_unlock (); + } + DLCALL (cairo_text_path, cr, utf8); + _exit_trace (); +} + +void +cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) +{ + cairo_scaled_font_t *font; + + _enter_trace (); + + font = DLCALL (cairo_get_scaled_font, cr); + + _emit_line_info (); + if (cr != NULL && glyphs != NULL && _write_lock ()) { + _emit_context (cr); + _emit_glyphs (font, glyphs, num_glyphs); + _trace_printf (" glyph-path\n"); + + _write_unlock (); + } + + DLCALL (cairo_glyph_path, cr, glyphs, num_glyphs); + _exit_trace (); +} + +void +cairo_append_path (cairo_t *cr, const cairo_path_t *path) +{ + /* XXX no support for named paths, so manually reconstruct */ + int i; + cairo_path_data_t *p; + + _enter_trace (); + + _emit_line_info (); + if (cr == NULL || path == NULL) { + DLCALL (cairo_append_path, cr, path); + _exit_trace (); + return; + } + + for (i=0; i < path->num_data; i += path->data[i].header.length) { + p = &path->data[i]; + switch (p->header.type) { + case CAIRO_PATH_MOVE_TO: + if (p->header.length >= 2) + cairo_move_to (cr, p[1].point.x, p[1].point.y); + break; + case CAIRO_PATH_LINE_TO: + if (p->header.length >= 2) + cairo_line_to (cr, p[1].point.x, p[1].point.y); + break; + case CAIRO_PATH_CURVE_TO: + if (p->header.length >= 4) + cairo_curve_to (cr, + p[1].point.x, p[1].point.y, + p[2].point.x, p[2].point.y, + p[3].point.x, p[3].point.y); + break; + case CAIRO_PATH_CLOSE_PATH: + if (p->header.length >= 1) + cairo_close_path (cr); + break; + default: + break; + } + } + _exit_trace (); +} + +cairo_surface_t * +cairo_image_surface_create (cairo_format_t format, int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_image_surface_create, format, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + const char *format_str = _format_to_string (format); + const char *content_str = _format_to_content_string (format); + + _trace_printf ("dict\n" + " /width %d set\n" + " /height %d set\n" + " /format //%s set\n" + " /content //%s set\n" + " image dup /s%ld exch def\n", + width, height, format_str, content_str, obj->token); + obj->width = width; + obj->height = height; + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_image_surface_create_for_data (unsigned char *data, cairo_format_t format, int width, int height, int stride) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_image_surface_create_for_data, data, format, width, height, stride); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + /* cairo_image_surface_create_for_data() is both used to supply + * foreign pixel data to cairo and in order to read pixels back. + * Defer grabbing the pixel contents until we have to, but only for + * "large" images, for small images the overhead of embedding pixels + * is negligible. + * + * Choose 32x32 as that captures most icons which thanks to GdkPixbuf + * are frequently reloaded. + */ + if (width * height < 32*32) { + _emit_image (ret, NULL); + _trace_printf (" dup /s%ld exch def\n", + obj->token); + } else { + _trace_printf ("dict\n" + " /width %d set\n" + " /height %d set\n" + " /format //%s set\n" + " image dup /s%ld exch def\n", + width, height, + _format_to_string (format), + obj->token); + + obj->foreign = TRUE; + } + + obj->width = width; + obj->height = height; + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +unsigned char * +cairo_image_surface_get_data (cairo_surface_t *surface) +{ + unsigned char *ptr; + + /* Just leave some breadcrumbs */ + _enter_trace (); + _emit_line_info (); + if (surface != NULL && _write_lock ()) { + _trace_printf ("%% s%ld get-data\n", _get_surface_id (surface)); + _write_unlock (); + } + ptr = DLCALL (cairo_image_surface_get_data, surface); + _exit_trace (); + + return ptr; +} + +cairo_pattern_t * +cairo_pattern_create_raster_source (void *data, cairo_content_t content, int width, int height) +{ + cairo_pattern_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_pattern_create_raster_source, data, content, width, height); + + _emit_line_info (); + if (_write_lock ()) { + long pattern_id = _create_pattern_id (ret); + cairo_format_t format; + cairo_surface_t *image; + cairo_t *cr; + + /* Impossible to accurately record the interaction with this custom + * pattern so just suck all the data into an image upfront */ + switch (content) { + case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break; + case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break; + default: + case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break; + } + + _trace_printf ("%% raster-source\n"); + + image = DLCALL (cairo_image_surface_create, format, width, height); + cr = DLCALL (cairo_create, image); + DLCALL (cairo_set_source, cr, ret); + DLCALL (cairo_paint, cr); + DLCALL (cairo_destroy, cr); + + _emit_image (image, NULL); + DLCALL (cairo_surface_destroy, image); + _trace_printf (" pattern dup /s%ld exch def\n", + pattern_id); + + _push_operand (PATTERN, ret); + _get_object (PATTERN, ret)->defined = TRUE; + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_surface_create_similar (cairo_surface_t *other, + cairo_content_t content, + int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_surface_create_similar, other, content, width, height); + + _emit_line_info (); + if (other != NULL && _write_lock ()) { + Object *other_obj = _get_object(SURFACE, other); + Object *new_obj = _create_surface (ret); + + if (other_obj->operand != -1) { + if (current_stack_depth == other_obj->operand + 1) + _trace_printf ("dup "); + else + _trace_printf ("%d index ", + current_stack_depth - other_obj->operand - 1); + } else { + assert(other_obj->defined); + _trace_printf ("s%ld ", other_obj->token); + } + + _trace_printf ("%d %d //%s similar dup /s%ld exch def\n", + width, height, + _content_to_string (content), + new_obj->token); + + new_obj->width = width; + new_obj->height = height; + new_obj->defined = TRUE; + + _push_object (new_obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_surface_create_similar_image (cairo_surface_t *other, + cairo_format_t format, + int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_surface_create_similar_image, + other, format, width, height); + + _emit_line_info (); + if (other != NULL && _write_lock ()) { + Object *other_obj = _get_object(SURFACE, other); + Object *new_obj = _create_surface (ret); + + if (other_obj->defined) + _trace_printf ("s%ld ", other_obj->token); + else if (current_stack_depth == other_obj->operand + 1) + _trace_printf ("dup "); + else + _trace_printf ("%d index ", + current_stack_depth - other_obj->operand - 1); + _trace_printf ("//%s %d %d similar-image %% s%ld\n", + _format_to_string (format), + width, height, + new_obj->token); + new_obj->width = width; + new_obj->height = height; + + _push_object (new_obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_surface_map_to_image (cairo_surface_t *surface, + const cairo_rectangle_int_t *extents) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_surface_map_to_image, surface, extents); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _emit_surface (surface); + if (extents) { + _trace_printf ("[%d %d %d %d] map-to-image %% s%ld\n", + extents->x, extents->y, + extents->width, extents->height, + obj->token); + obj->width = extents->width; + obj->height = extents->height; + } else { + _trace_printf ("[ ] map-to-image %% s%ld\n", obj->token); + } + + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +void +cairo_surface_unmap_image (cairo_surface_t *surface, + cairo_surface_t *image) +{ + _enter_trace (); + + _emit_line_info (); + if (_write_lock ()) { + Object *s = _get_object (SURFACE, surface); + Object *i = _get_object (SURFACE, image); + if (!(s->operand == current_stack_depth - 2 && + i->operand == current_stack_depth - 1)) { + if (i->operand != s->operand + 1 || ! _pop_operands_to_depth (i->operand + 1)) { + _emit_surface (surface); + _emit_surface (image); + } + } + _trace_printf ("unmap-image\n"); + _consume_operand (true); + _write_unlock (); + } + + DLCALL (cairo_surface_unmap_image, surface, image); + + _exit_trace (); +} + +cairo_surface_t * +cairo_surface_create_for_rectangle (cairo_surface_t *target, + double x, double y, + double width, double height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_surface_create_for_rectangle, target, x, y, width, height); + + _emit_line_info (); + if (target != NULL && _write_lock ()) { + Object *target_obj = _get_object (SURFACE, target); + Object *child_obj = _create_surface (ret); + + if (target_obj->defined) + _trace_printf ("s%ld ", target_obj->token); + else if (current_stack_depth == target_obj->operand + 1) + _trace_printf ("dup "); + else + _trace_printf ("%d index ", current_stack_depth - target_obj->operand - 1); + _trace_printf ("%f %f %f %f subsurface %% s%ld\n", + x, y, width, height, + child_obj->token); + + _push_object (child_obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +static void CAIRO_PRINTF_FORMAT(2, 3) +_emit_surface_op (cairo_surface_t *surface, const char *fmt, ...) +{ + va_list ap; + + if (surface == NULL || ! _write_lock ()) + return; + + _emit_surface (surface); + + va_start (ap, fmt); + _trace_vprintf ( fmt, ap); + va_end (ap); + + _write_unlock (); +} + +void +cairo_surface_finish (cairo_surface_t *surface) +{ + _enter_trace (); + _emit_line_info (); + DLCALL (cairo_surface_finish, surface); + _exit_trace (); +} + +void +cairo_surface_flush (cairo_surface_t *surface) +{ + _enter_trace (); + _emit_line_info (); + if (surface != NULL && _write_lock ()) { + _trace_printf ("%% s%ld flush\n", _get_surface_id (surface)); + _write_unlock (); + } + DLCALL (cairo_surface_flush, surface); + _exit_trace (); +} + +void +cairo_surface_mark_dirty (cairo_surface_t *surface) +{ + _enter_trace (); + _emit_line_info (); + + /* Call cairo before emitting the trace since _emit_surface() might cause + * snapshots to be creates while mark_dirty assert()s that there are none. + */ + DLCALL (cairo_surface_mark_dirty, surface); + + if (surface != NULL && _write_lock ()) { + if (_mark_dirty) { + _emit_surface (surface); + _trace_printf ("%% mark-dirty\n"); + _emit_source_image (surface); + } else + _trace_printf ("%% s%ld mark-dirty\n", _get_surface_id (surface)); + _write_unlock (); + } + _exit_trace (); +} + +void +cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface, + int x, int y, int width, int height) +{ + _enter_trace (); + + /* Call cairo before emitting the trace since _emit_surface() might cause + * snapshots to be creates while mark_dirty assert()s that there are none. + */ + DLCALL (cairo_surface_mark_dirty_rectangle, surface, x, y, width, height); + + _emit_line_info (); + if (surface != NULL && _write_lock ()) { + if (_mark_dirty) { + _emit_surface (surface); + _trace_printf ("%% %d %d %d %d mark-dirty-rectangle\n", + x, y, width, height); + _emit_source_image_rectangle (surface, x,y, width, height); + } else + _trace_printf ("%% s%ld %d %d %d %d mark-dirty-rectangle\n", + _get_surface_id (surface), x, y, width, height); + _write_unlock (); + } + _exit_trace (); +} + +void +cairo_surface_set_device_offset (cairo_surface_t *surface, double x_offset, double y_offset) +{ + _enter_trace (); + _emit_line_info (); + _emit_surface_op (surface, "%g %g set-device-offset\n", + x_offset, y_offset); + DLCALL (cairo_surface_set_device_offset, surface, x_offset, y_offset); + _exit_trace (); +} + +void +cairo_surface_set_device_scale (cairo_surface_t *surface, double x_offset, double y_offset) +{ + _enter_trace (); + _emit_line_info (); + _emit_surface_op (surface, "%g %g set-device-scale\n", + x_offset, y_offset); + DLCALL (cairo_surface_set_device_scale, surface, x_offset, y_offset); + _exit_trace (); +} + + +void +cairo_surface_set_fallback_resolution (cairo_surface_t *surface, double x_pixels_per_inch, double y_pixels_per_inch) +{ + _enter_trace (); + _emit_line_info (); + _emit_surface_op (surface, "%g %g set-fallback-resolution\n", + x_pixels_per_inch, y_pixels_per_inch); + DLCALL (cairo_surface_set_fallback_resolution, surface, x_pixels_per_inch, y_pixels_per_inch); + _exit_trace (); +} + +void +cairo_surface_copy_page (cairo_surface_t *surface) +{ + _enter_trace (); + _emit_line_info (); + _emit_surface_op (surface, "copy-page\n"); + DLCALL (cairo_surface_copy_page, surface); + _exit_trace (); +} + +void +cairo_surface_show_page (cairo_surface_t *surface) +{ + _enter_trace (); + _emit_line_info (); + _emit_surface_op (surface, "show-page\n"); + DLCALL (cairo_surface_show_page, surface); + _exit_trace (); +} + +cairo_status_t +cairo_surface_set_mime_data (cairo_surface_t *surface, + const char *mime_type, + const unsigned char *data, + unsigned long length, + cairo_destroy_func_t destroy, + void *closure) +{ + cairo_status_t ret; + _enter_trace (); + _emit_line_info (); + if (surface != NULL && _write_lock ()) { + _emit_surface (surface); + _emit_string_literal (mime_type, -1); + _trace_printf (" "); + _emit_data (data, length); + _trace_printf (" /deflate filter set-mime-data\n"); + + _write_unlock (); + } + + ret = DLCALL (cairo_surface_set_mime_data, + surface, + mime_type, + data, length, + destroy, + closure); + _exit_trace (); + return ret; +} + +#if CAIRO_HAS_PNG_FUNCTIONS +cairo_status_t +cairo_surface_write_to_png (cairo_surface_t *surface, const char *filename) +{ + cairo_status_t ret; + _enter_trace (); + _emit_line_info (); + if (surface != NULL && _write_lock ()) { + _trace_printf ("%% s%ld ", _get_surface_id (surface)); + _emit_string_literal (filename, -1); + _trace_printf (" write-to-png pop\n"); + _write_unlock (); + } + ret = DLCALL (cairo_surface_write_to_png, surface, filename); + _exit_trace (); + return ret; +} + +cairo_status_t +cairo_surface_write_to_png_stream (cairo_surface_t *surface, + cairo_write_func_t write_func, + void *data) +{ + cairo_status_t ret; + _enter_trace (); + _emit_line_info (); + if (surface != NULL && _write_lock ()) { + char symbol[1024]; + + _trace_printf ("%% s%ld ", _get_surface_id (surface)); +#if CAIRO_HAS_SYMBOL_LOOKUP + lookup_symbol (symbol, sizeof (symbol), write_func); +#else + symbol[0] = '\0'; +#endif + _emit_string_literal (symbol, -1); + _trace_printf (" write-to-png-stream pop\n"); + _write_unlock (); + } + ret = DLCALL (cairo_surface_write_to_png_stream, + surface, write_func, data); + _exit_trace (); + return ret; +} +#endif + +static void CAIRO_PRINTF_FORMAT(2, 3) +_emit_pattern_op (cairo_pattern_t *pattern, const char *fmt, ...) +{ + va_list ap; + + if (pattern == NULL || ! _write_lock ()) + return; + + _emit_pattern (pattern); + + va_start (ap, fmt); + _trace_vprintf (fmt, ap); + va_end (ap); + + _write_unlock (); +} + +cairo_pattern_t * +cairo_pattern_create_rgb (double red, double green, double blue) +{ + cairo_pattern_t *ret; + long pattern_id; + + _enter_trace (); + + ret = DLCALL (cairo_pattern_create_rgb, red, green, blue); + pattern_id = _create_pattern_id (ret); + + _emit_line_info (); + if (_write_lock ()) { + _trace_printf ("/p%ld %g %g %g rgb def\n", + pattern_id, red, green, blue); + _get_object (PATTERN, ret)->defined = TRUE; + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_pattern_t * +cairo_pattern_create_rgba (double red, double green, double blue, double alpha) +{ + cairo_pattern_t *ret; + long pattern_id; + + _enter_trace (); + + ret = DLCALL (cairo_pattern_create_rgba, red, green, blue, alpha); + pattern_id = _create_pattern_id (ret); + + _emit_line_info (); + if (_write_lock ()) { + _trace_printf ("/p%ld %g %g %g %g rgba def\n", + pattern_id, red, green, blue, alpha); + _get_object (PATTERN, ret)->defined = TRUE; + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_pattern_t * +cairo_pattern_create_for_surface (cairo_surface_t *surface) +{ + cairo_pattern_t *ret; + long pattern_id; + long surface_id; + + _enter_trace (); + + ret = DLCALL (cairo_pattern_create_for_surface, surface); + pattern_id = _create_pattern_id (ret); + + _emit_line_info (); + if (surface != NULL && _write_lock ()) { + surface_id = _get_surface_id (surface); + + if (_pop_operands_to (SURFACE, surface)) { + _consume_operand (false); + } else { + _trace_printf ("s%ld ", surface_id); + } + + if (_get_object (SURFACE, surface)->foreign) + _emit_source_image (surface); + + _trace_printf ("pattern %% p%ld\n", pattern_id); + _push_operand (PATTERN, ret); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_pattern_t * +cairo_pattern_create_linear (double x0, double y0, double x1, double y1) +{ + cairo_pattern_t *ret; + long pattern_id; + + _enter_trace (); + + ret = DLCALL (cairo_pattern_create_linear, x0, y0, x1, y1); + pattern_id = _create_pattern_id (ret); + + _emit_line_info (); + if (_write_lock ()) { + _trace_printf ("%g %g %g %g linear %% p%ld\n", + x0, y0, x1, y1, pattern_id); + _push_operand (PATTERN, ret); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_pattern_t * +cairo_pattern_create_radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1) +{ + cairo_pattern_t *ret; + long pattern_id; + + _enter_trace (); + + ret = DLCALL (cairo_pattern_create_radial, + cx0, cy0, radius0, + cx1, cy1, radius1); + pattern_id = _create_pattern_id (ret); + + _emit_line_info (); + if (_write_lock ()) { + _trace_printf ("%g %g %g %g %g %g radial %% p%ld\n", + cx0, cy0, radius0, cx1, cy1, radius1, + pattern_id); + _push_operand (PATTERN, ret); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +void +cairo_pattern_add_color_stop_rgb (cairo_pattern_t *pattern, double offset, double red, double green, double blue) +{ + _enter_trace (); + _emit_line_info (); + _emit_pattern_op (pattern, + "%g %g %g %g 1 add-color-stop\n", + offset, red, green, blue); + DLCALL (cairo_pattern_add_color_stop_rgb, pattern, offset, red, green, blue); + _exit_trace (); +} + +void +cairo_pattern_add_color_stop_rgba (cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha) +{ + _enter_trace (); + _emit_line_info (); + _emit_pattern_op (pattern, + "%g %g %g %g %g add-color-stop\n", + offset, red, green, blue, alpha); + DLCALL (cairo_pattern_add_color_stop_rgba, pattern, offset, red, green, blue, alpha); + _exit_trace (); +} + +void +cairo_pattern_set_matrix (cairo_pattern_t *pattern, const cairo_matrix_t *matrix) +{ + _enter_trace (); + _emit_line_info (); + if (_matrix_is_identity (matrix)) { + _emit_pattern_op (pattern, "identity set-matrix\n"); + } else { + _emit_pattern_op (pattern, + "%g %g %g %g %g %g matrix set-matrix\n", + matrix->xx, matrix->yx, + matrix->xy, matrix->yy, + matrix->x0, matrix->y0); + } + DLCALL (cairo_pattern_set_matrix, pattern, matrix); + _exit_trace (); +} + +static const char * +_filter_to_string (cairo_filter_t filter) +{ +#define f(name) case CAIRO_FILTER_ ## name: return "FILTER_" #name + switch (filter) { + f(FAST); + f(GOOD); + f(BEST); + f(NEAREST); + f(BILINEAR); + f(GAUSSIAN); + }; +#undef f + return "UNKNOWN_FILTER"; +} + +void +cairo_pattern_set_filter (cairo_pattern_t *pattern, cairo_filter_t filter) +{ + _enter_trace (); + _emit_line_info (); + _emit_pattern_op (pattern, "//%s set-filter\n", _filter_to_string (filter)); + DLCALL (cairo_pattern_set_filter, pattern, filter); + _exit_trace (); +} + +static const char * +_extend_to_string (cairo_extend_t extend) +{ +#define f(name) case CAIRO_EXTEND_ ## name: return "EXTEND_" #name + switch (extend) { + f(NONE); + f(REPEAT); + f(REFLECT); + f(PAD); + }; +#undef f + return "UNKNOWN_EXTEND"; +} + +void +cairo_pattern_set_extend (cairo_pattern_t *pattern, cairo_extend_t extend) +{ + _enter_trace (); + _emit_line_info (); + _emit_pattern_op (pattern, "//%s set-extend\n", _extend_to_string (extend)); + DLCALL (cairo_pattern_set_extend, pattern, extend); + _exit_trace (); +} + +#if CAIRO_HAS_FT_FONT +#if CAIRO_HAS_FC_FONT +cairo_font_face_t * +cairo_ft_font_face_create_for_pattern (FcPattern *pattern) +{ + cairo_font_face_t *ret; + long font_face_id; + + _enter_trace (); + + ret = DLCALL (cairo_ft_font_face_create_for_pattern, pattern); + font_face_id = _create_font_face_id (ret); + + _emit_line_info (); + if (pattern != NULL && _write_lock ()) { + Object *obj; + + obj = _get_object (FONT_FACE, ret); + if (obj->unknown) { + FcPattern *copy; + FcChar8 *unparsed; + + copy = DLCALL (FcPatternDuplicate, pattern); + if (copy) + { + DLCALL (FcPatternDel, copy, FC_LANG); + DLCALL (FcPatternDel, copy, FC_CHARSET); + DLCALL (FcPatternDel, copy, FC_CAPABILITY); + } + else + copy = pattern; + + unparsed = DLCALL (FcNameUnparse, copy); + _trace_printf ("dict\n" + " /type 42 set\n" + " /pattern "); + _emit_string_literal ((char *) unparsed, -1); + _trace_printf (" set\n" + " font %% f%ld\n", + font_face_id); + obj->unknown = FALSE; + _push_operand (FONT_FACE, ret); + dump_stack(__func__); + + if (copy != pattern) + DLCALL (FcPatternDestroy, copy); + free (unparsed); + } + _write_unlock (); + } + + _exit_trace (); + return ret; +} +#endif /* CAIRO_HAS_FC_FONT*/ + +typedef struct _ft_face_data { + unsigned long index; + unsigned long size; + void *data; +} FtFaceData; + +static void +_ft_face_data_destroy (void *arg) +{ + FtFaceData *data = arg; + free (data->data); + free (data); +} + +cairo_font_face_t * +cairo_ft_font_face_create_for_ft_face (FT_Face face, int load_flags) +{ + cairo_font_face_t *ret; + Object *obj; + FtFaceData *data; + long font_face_id; + + _enter_trace (); + + ret = DLCALL (cairo_ft_font_face_create_for_ft_face, face, load_flags); + font_face_id = _create_font_face_id (ret); + + if (face == NULL) { + _exit_trace (); + return ret; + } + + obj = _get_object (NONE, face); + data = obj->data; + if (data == NULL) { + _exit_trace (); + return ret; + } + + _emit_line_info (); + if (_write_lock ()) { + obj = _get_object (FONT_FACE, ret); + if (obj->operand != -1) + _object_remove (obj); + + _trace_printf ("<< /type 42 /source "); + _emit_data (data->data, data->size); + _trace_printf (" /index %lu /flags %d >> font %% f%ld\n", + data->index, load_flags, font_face_id); + _push_operand (FONT_FACE, ret); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +static cairo_bool_t +_ft_read_file (FtFaceData *data, const char *path) +{ + char buf[8192]; + FILE *file; + + file = fopen (path, "rb"); + if (file != NULL) { + size_t ret; + unsigned long int allocated = sizeof (buf); + data->data = malloc (allocated); + do { + ret = fread (buf, 1, sizeof (buf), file); + if (ret == 0) + break; + memcpy ((char *) data->data + data->size, buf, ret); + data->size += ret; + if (ret != sizeof (buf)) + break; + + if (data->size == allocated) { + allocated *= 2; + data->data = realloc (data->data, allocated); + } + } while (TRUE); + fclose (file); + } + + return file != NULL; +} + +FT_Error +FT_New_Face (FT_Library library, const char *pathname, FT_Long index, FT_Face *face) +{ + FT_Error ret; + + _enter_trace (); + + ret = DLCALL (FT_New_Face, library, pathname, index, face); + if (ret == 0) { + Object *obj = _type_object_create (NONE, *face); + FtFaceData *data = malloc (sizeof (FtFaceData)); + data->index = index; + data->size = 0; + data->data = NULL; + _ft_read_file (data, pathname); + obj->data = data; + obj->destroy = _ft_face_data_destroy; + } + + _exit_trace (); + return ret; +} + +FT_Error +FT_New_Memory_Face (FT_Library library, const FT_Byte *mem, FT_Long size, FT_Long index, FT_Face *face) +{ + FT_Error ret; + + _enter_trace (); + + ret = DLCALL (FT_New_Memory_Face, library, mem, size, index, face); + if (ret == 0) { + Object *obj = _type_object_create (NONE, *face); + FtFaceData *data = malloc (sizeof (FtFaceData)); + data->index = index; + data->size = size; + data->data = malloc (size); + memcpy (data->data, mem, size); + obj->data = data; + obj->destroy = _ft_face_data_destroy; + } + + _exit_trace (); + return ret; +} + +/* XXX + * FT_New_Memory_Face() and FT_New_Face() appear to wrap FT_Open_Face() so we + * get a redundant call to FT_Open_Face() from those paths (no PLT hiding + * within FT, naughty library!) but we do not intercept a direct call to + * FT_Open_Face(). So far this has not caused any issues, but it will one + * day... + */ +FT_Error +FT_Open_Face (FT_Library library, const FT_Open_Args *args, FT_Long index, FT_Face *face) +{ + FT_Error ret; + + _enter_trace (); + + ret = DLCALL (FT_Open_Face, library, args, index, face); + if (ret == 0) { + Object *obj = _get_object (NONE, *face); + if (obj == NULL) { + FtFaceData *data; + + data = malloc (sizeof (FtFaceData)); + data->index = index; + if (args->flags & FT_OPEN_MEMORY) { + data->size = args->memory_size; + data->data = malloc (args->memory_size); + memcpy (data->data, args->memory_base, args->memory_size); + } else if (args->flags & FT_OPEN_STREAM) { + fprintf (stderr, "FT_Open_Face (stream, %ld) = %p\n", + index, *face); + abort (); + } else if (args->flags & FT_OPEN_PATHNAME) { + data->size = 0; + data->data = NULL; + _ft_read_file (data, args->pathname); + } + + obj = _type_object_create (NONE, *face); + obj->data = data; + obj->destroy = _ft_face_data_destroy; + } + } + + _exit_trace (); + return ret; +} + +FT_Error +FT_Done_Face (FT_Face face) +{ + FT_Error ret; + _enter_trace (); + + _object_destroy (_get_object (NONE, face)); + + ret = DLCALL (FT_Done_Face, face); + _exit_trace (); + return ret; +} +#endif + +static void +_surface_object_set_size (cairo_surface_t *surface, int width, int height) +{ + Object *obj; + + obj = _get_object (SURFACE, surface); + obj->width = width; + obj->height = height; +} + +static void +_surface_object_set_size_from_surface (cairo_surface_t *surface) +{ + _surface_object_set_size (surface, + DLCALL (cairo_image_surface_get_width, surface), + DLCALL (cairo_image_surface_get_height, surface)); +} + +#if CAIRO_HAS_PS_SURFACE +#include<cairo-ps.h> + +cairo_surface_t * +cairo_ps_surface_create (const char *filename, double width_in_points, double height_in_points) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_ps_surface_create, filename, width_in_points, height_in_points); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /PS set\n" + " /filename "); + _emit_string_literal (filename, -1); + _trace_printf (" set\n" + " /width %g set\n" + " /height %g set\n" + " surface %% s%ld\n", + width_in_points, + height_in_points, + obj->token); + obj->width = width_in_points; + obj->height = height_in_points; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_ps_surface_create_for_stream (cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_ps_surface_create_for_stream, write_func, closure, width_in_points, height_in_points); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /PS set\n" + " /width %g set\n" + " /height %g set\n" + " surface %% s%ld\n", + width_in_points, + height_in_points, + obj->token); + obj->width = width_in_points; + obj->height = height_in_points; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +void +cairo_ps_surface_set_size (cairo_surface_t *surface, double width_in_points, double height_in_points) +{ + _enter_trace (); + _emit_line_info (); + DLCALL (cairo_ps_surface_set_size, surface, width_in_points, height_in_points); + _exit_trace (); +} + +#endif + +#if CAIRO_HAS_PDF_SURFACE +#include <cairo-pdf.h> + +cairo_surface_t * +cairo_pdf_surface_create (const char *filename, double width_in_points, double height_in_points) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_pdf_surface_create, filename, width_in_points, height_in_points); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /PDF set\n" + " /filename "); + _emit_string_literal (filename, -1); + _trace_printf (" set\n" + " /width %g set\n" + " /height %g set\n" + " surface %% s%ld\n", + width_in_points, + height_in_points, + obj->token); + obj->width = width_in_points; + obj->height = height_in_points; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_pdf_surface_create_for_stream (cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_pdf_surface_create_for_stream, write_func, closure, width_in_points, height_in_points); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /PDF set\n" + " /width %g set\n" + " /height %g set\n" + " surface %% s%ld\n", + width_in_points, + height_in_points, + obj->token); + obj->width = width_in_points; + obj->height = height_in_points; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + _exit_trace (); + return ret; +} + +void +cairo_pdf_surface_set_size (cairo_surface_t *surface, double width_in_points, double height_in_points) +{ + _enter_trace (); + _emit_line_info (); + DLCALL (cairo_pdf_surface_set_size, surface, width_in_points, height_in_points); + _exit_trace (); +} +#endif + +#if CAIRO_HAS_SVG_SURFACE +#include <cairo-svg.h> + +cairo_surface_t * +cairo_svg_surface_create (const char *filename, double width, double height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_svg_surface_create, filename, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /SVG set\n" + " /filename "); + _emit_string_literal (filename, -1); + _trace_printf (" set\n" + " /width %g set\n" + " /height %g set\n" + " surface %% s%ld\n", + width, + height, + obj->token); + obj->width = width; + obj->height = height; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_svg_surface_create_for_stream (cairo_write_func_t write_func, void *closure, double width, double height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_svg_surface_create_for_stream, write_func, closure, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /SVG set\n" + " /width %g set\n" + " /height %g set\n" + " surface %% s%ld\n", + width, + height, + obj->token); + obj->width = width; + obj->height = height; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +#endif + +#if CAIRO_HAS_PNG_FUNCTIONS +cairo_surface_t * +cairo_image_surface_create_from_png (const char *filename) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_image_surface_create_from_png, filename); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + char filename_string[4096]; + + _encode_string_literal (filename_string, sizeof (filename_string), + filename, -1); + _emit_image (ret, " /filename %s set\n", filename_string); + _trace_printf (" dup /s%ld exch def\n", obj->token); + _surface_object_set_size_from_surface (ret); + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_image_surface_create_from_png_stream (cairo_read_func_t read_func, void *closure) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_image_surface_create_from_png_stream, read_func, closure); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _emit_image (ret, NULL); + _trace_printf (" dup /s%ld exch def\n", + obj->token); + + _surface_object_set_size_from_surface (ret); + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} +#endif + +static const char * +_content_from_surface (cairo_surface_t *surface) +{ + return _content_to_string (DLCALL (cairo_surface_get_content, surface)); +} + +#if CAIRO_HAS_TEE_SURFACE +#include <cairo-tee.h> + +cairo_surface_t * +cairo_tee_surface_create (cairo_surface_t *master) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_tee_surface_create, master); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /tee set\n" + " /master s%ld set\n" + " surface dup /s%ld exch def\n", + _get_object (SURFACE, master)->token, + obj->token); + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +#endif + +#if CAIRO_HAS_XLIB_SURFACE +#include <cairo-xlib.h> + +cairo_surface_t * +cairo_xlib_surface_create (Display *dpy, + Drawable drawable, + Visual *visual, + int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_xlib_surface_create, + dpy, drawable, visual, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /xlib set\n" + " /drawable 16!%lx set\n" + " /content //%s set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + drawable, + _content_from_surface (ret), + width, height, + obj->token); + obj->defined = TRUE; + obj->width = width; + obj->height = height; + obj->foreign = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_xlib_surface_create_for_bitmap (Display *dpy, + Pixmap bitmap, + Screen *screen, + int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_xlib_surface_create_for_bitmap, + dpy, bitmap, screen, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /xlib set\n" + " /drawable 16!%lx set\n" + " /content //%s set\n" + " /width %d set\n" + " /height %d set\n" + " /depth 1 set\n" + " surface dup /s%ld exch def\n", + bitmap, + _content_from_surface (ret), + width, height, + obj->token); + obj->defined = TRUE; + obj->width = width; + obj->height = height; + obj->foreign = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +#if CAIRO_HAS_XLIB_XRENDER_SURFACE +#include <cairo-xlib-xrender.h> +cairo_surface_t * +cairo_xlib_surface_create_with_xrender_format (Display *dpy, + Drawable drawable, + Screen *screen, + XRenderPictFormat *format, + int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_xlib_surface_create_with_xrender_format, + dpy, drawable, screen, format, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /xrender set\n" + " /drawable 16!%lx set\n" + " /content //%s set\n" + " /width %d set\n" + " /height %d set\n" + " /depth %d set\n" + " surface dup /s%ld exch def\n", + drawable, + _content_from_surface (ret), + width, height, + format->depth, + obj->token); + obj->defined = TRUE; + obj->width = width; + obj->height = height; + obj->foreign = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} +#endif +#endif + +#if CAIRO_HAS_SCRIPT_SURFACE +#include <cairo-script.h> +cairo_surface_t * +cairo_script_surface_create (cairo_device_t *device, + cairo_content_t content, + double width, + double height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_script_surface_create, device, content, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /script set\n" + " /content %s set\n" + " /width %g set\n" + " /height %g set\n" + " surface dup /s%ld exch def\n", + _content_to_string (content), + width, height, + obj->token); + obj->width = width; + obj->height = height; + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_script_surface_create_for_target (cairo_device_t *device, + cairo_surface_t *target) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_script_surface_create_for_target, device, target); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /script set\n" + " surface dup /s%ld exch def\n", + obj->token); + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} +#endif + +#if CAIRO_HAS_TEST_SURFACES +#include <test-paginated-surface.h> +cairo_surface_t * +_cairo_test_paginated_surface_create (cairo_surface_t *surface) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (_cairo_test_paginated_surface_create, surface); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + /* XXX store initial data? */ + _trace_printf ("dict\n" + " /type /test-paginated set\n" + " /target s%ld set\n" + " surface dup /s%ld exch def\n", + _get_surface_id (surface), + obj->token); + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +#include <test-compositor-surface.h> + +cairo_surface_t * +_cairo_test_fallback_compositor_surface_create (cairo_content_t content, int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (_cairo_test_fallback_compositor_surface_create, content, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /test-fallback-compositor set\n" + " /content //%s set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + _content_to_string (content), + width, height, + obj->token); + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +_cairo_test_mask_compositor_surface_create (cairo_content_t content, int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (_cairo_test_mask_compositor_surface_create, content, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /test-mask-compositor set\n" + " /content //%s set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + _content_to_string (content), + width, height, + obj->token); + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +_cairo_test_spans_compositor_surface_create (cairo_content_t content, int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (_cairo_test_spans_compositor_surface_create, content, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /test-spans-compositor set\n" + " /content //%s set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + _content_to_string (content), + width, height, + obj->token); + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +_cairo_test_traps_compositor_surface_create (cairo_content_t content, int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (_cairo_test_traps_compositor_surface_create, content, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /test-traps-compositor set\n" + " /content //%s set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + _content_to_string (content), + width, height, + obj->token); + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +#endif + +cairo_surface_t * +cairo_recording_surface_create (cairo_content_t content, + const cairo_rectangle_t *extents) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_recording_surface_create, content, extents); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + if (extents) { + _trace_printf ("//%s [ %f %f %f %f ] record dup /s%ld exch def\n", + _content_to_string (content), + extents->x, extents->y, + extents->width, extents->height, + obj->token); + obj->width = extents->width; + obj->height = extents->height; + } else { + _trace_printf ("//%s [ ] record dup /s%ld exch def\n", + _content_to_string (content), + obj->token); + } + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +#if CAIRO_HAS_VG_SURFACE +#include <cairo-vg.h> +cairo_surface_t * +cairo_vg_surface_create (cairo_vg_context_t *context, + cairo_content_t content, + int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_vg_surface_create, context, content, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /vg set\n" + " /content //%s set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + _content_to_string (content), + width, height, + obj->token); + obj->width = width; + obj->height = height; + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_vg_surface_create_for_image (cairo_vg_context_t *context, + VGImage image, + VGImageFormat format, + int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_vg_surface_create_for_image, + context, image, format, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + cairo_content_t content; + + content = DLCALL (cairo_surface_get_content, ret); + _trace_printf ("dict\n" + " /type /vg set\n" + " /content //%s set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + _content_to_string (content), + width, height, + obj->token); + obj->width = width; + obj->height = height; + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} +#endif + +#if CAIRO_HAS_GL_SURFACE || CAIRO_HAS_GLESV2_SURFACE +#include <cairo-gl.h> +cairo_surface_t * +cairo_gl_surface_create (cairo_device_t *abstract_device, + cairo_content_t content, + int width, + int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_gl_surface_create, abstract_device, content, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /gl set\n" + " /content //%s set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + _content_to_string (content), + width, height, + obj->token); + obj->width = width; + obj->height = height; + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * +cairo_gl_surface_create_for_texture (cairo_device_t *abstract_device, + cairo_content_t content, + unsigned int tex, + int width, + int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_gl_surface_create_for_texture, abstract_device, content, tex, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /gl set\n" + " /content //%s set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + _content_to_string (content), + width, height, + obj->token); + obj->width = width; + obj->height = height; + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +#if CAIRO_HAS_GLX_FUNCTIONS +cairo_surface_t * +cairo_gl_surface_create_for_window (cairo_device_t *device, + Window win, + int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_gl_surface_create_for_window, device, win, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /gl set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + width, height, + obj->token); + obj->width = width; + obj->height = height; + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} +#endif + +#if CAIRO_HAS_WGL_FUNCTIONS +cairo_surface_t * +cairo_gl_surface_create_for_dc (cairo_device_t *device, + HDC dc, + int width, + int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_gl_surface_create_for_dc, device, dc, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /gl set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + width, height, + obj->token); + obj->width = width; + obj->height = height; + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} +#endif + +#if CAIRO_HAS_EGL_FUNCTIONS +cairo_surface_t * +cairo_gl_surface_create_for_egl (cairo_device_t *device, + EGLSurface egl, + int width, + int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_gl_surface_create_for_egl, device, egl, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + + _trace_printf ("dict\n" + " /type /gl set\n" + " /width %d set\n" + " /height %d set\n" + " surface dup /s%ld exch def\n", + width, height, + obj->token); + obj->width = width; + obj->height = height; + obj->defined = TRUE; + _push_object (obj); + dump_stack(__func__); + _write_unlock (); + } + + _exit_trace (); + return ret; +} +#endif +#endif |