📄 cairoint.h
字号:
/* cairo - a vector graphics library with display and print output * * Copyright © 2002 University of Southern California * Copyright © 2005 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public * License version 2.1 as published by the Free Software Foundation * (the "LGPL") or, at your option, under the terms of the Mozilla * Public License Version 1.1 (the "MPL"). If you do not alter this * notice, a recipient may use your version of this file under either * the MPL or the LGPL. * * You should have received a copy of the LGPL along with this library * in the file COPYING-LGPL-2.1; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * You should have received a copy of the MPL along with this library * in the file COPYING-MPL-1.1 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY * OF ANY KIND, either express or implied. See the LGPL or the MPL for * the specific language governing rights and limitations. * * The Original Code is the cairo graphics library. * * The Initial Developer of the Original Code is University of Southern * California. * * Contributor(s): * Carl D. Worth <cworth@cworth.org> *//* * These definitions are solely for use by the implementation of cairo * and constitute no kind of standard. If you need any of these * functions, please drop me a note. Either the library needs new * functionality, or there's a way to do what you need using the * existing published interfaces. cworth@cworth.org */#ifndef _CAIROINT_H_#define _CAIROINT_H_#if HAVE_CONFIG_H#include "config.h"#endif#include <assert.h>#include <stdlib.h>#include <string.h>#include <stdarg.h>#ifdef _MSC_VER#define _USE_MATH_DEFINES#endif#include <math.h>#include <limits.h>#include <stdio.h>#include "cairo.h"#include <pixman.h>CAIRO_BEGIN_DECLS#if __GNUC__ >= 3 && defined(__ELF__)# define slim_hidden_proto(name) slim_hidden_proto1(name, INT_##name)# define slim_hidden_def(name) slim_hidden_def1(name, INT_##name)# define slim_hidden_proto1(name, internal) \ extern __typeof (name) name \ __asm__ (slim_hidden_asmname (internal)) \ cairo_private;# define slim_hidden_def1(name, internal) \ extern __typeof (name) EXT_##name __asm__(slim_hidden_asmname(name)) \ __attribute__((__alias__(slim_hidden_asmname(internal))))# define slim_hidden_ulp slim_hidden_ulp1(__USER_LABEL_PREFIX__)# define slim_hidden_ulp1(x) slim_hidden_ulp2(x)# define slim_hidden_ulp2(x) #x# define slim_hidden_asmname(name) slim_hidden_asmname1(name)# define slim_hidden_asmname1(name) slim_hidden_ulp #name#else# define slim_hidden_proto(name)# define slim_hidden_def(name)#endif#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/* slim_internal.h */#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__)#define cairo_private __attribute__((__visibility__("hidden")))#else#define cairo_private#endif/* This macro allow us to deprecate a function by providing an alias for the old function name to the new function name. With this macro, binary compatibility is preserved. The macro only works on some platforms --- tough. Meanwhile, new definitions in the public header file break the source code so that it will no longer link against the old symbols. Instead it will give a descriptive error message indicating that the old function has been deprecated by the new function.*/#if __GNUC__ >= 2 && defined(__ELF__)# define CAIRO_FUNCTION_ALIAS(old, new) \ extern __typeof (new) old \ __asm__ ("" #old) \ __attribute__((__alias__("" #new)))#else# define CAIRO_FUNCTION_ALIAS(old, new)#endif#ifndef __GNUC__#define __attribute__(x)#endif#if defined(__GNUC__)#define INLINE __inline__#else#define INLINE#endif#if HAVE_PTHREAD_H# include <pthread.h># define CAIRO_MUTEX_DECLARE(name) static pthread_mutex_t name = PTHREAD_MUTEX_INITIALIZER#define CAIRO_MUTEX_DECLARE_GLOBAL(name) pthread_mutex_t name = PTHREAD_MUTEX_INITIALIZER# define CAIRO_MUTEX_LOCK(name) pthread_mutex_lock (&name)# define CAIRO_MUTEX_UNLOCK(name) pthread_mutex_unlock (&name)#endif#if !defined(CAIRO_MUTEX_DECLARE) && defined CAIRO_HAS_WIN32_SURFACE# define WIN32_LEAN_AND_MEAN# include <windows.h> /* the real initialization must take place in DllMain */# define CAIRO_MUTEX_DECLARE(name) extern CRITICAL_SECTION name;# define CAIRO_MUTEX_DECLARE_GLOBAL(name) extern LPCRITICAL_SECTION name;# define CAIRO_MUTEX_LOCK(name) EnterCriticalSection (&name)# define CAIRO_MUTEX_UNLOCK(name) LeaveCriticalSection (&name)#endif#if !defined(CAIRO_MUTEX_DECLARE) && defined CAIRO_HAS_BEOS_SURFACEcairo_private void _cairo_beos_lock(void*);cairo_private void _cairo_beos_unlock(void*); /* the real initialization takes place in a global constructor */# define CAIRO_MUTEX_DECLARE(name) extern void* name;# define CAIRO_MUTEX_DECLARE_GLOBAL(name) extern void* name;# define CAIRO_MUTEX_LOCK(name) _cairo_beos_lock (&name)# define CAIRO_MUTEX_UNLOCK(name) _cairo_beos_unlock (&name)#endif#ifndef CAIRO_MUTEX_DECLARE# error "No mutex declarations. Cairo will not work with multiple threads." \ "(Remove this #error directive to acknowledge & accept this limitation)."# define CAIRO_MUTEX_DECLARE(name)# define CAIRO_MUTEX_DECLARE_GLOBAL(name)# define CAIRO_MUTEX_LOCK(name)# define CAIRO_MUTEX_UNLOCK(name)#endif#undef MIN#define MIN(a, b) ((a) < (b) ? (a) : (b))#undef MAX#define MAX(a, b) ((a) > (b) ? (a) : (b))#ifndef FALSE#define FALSE 0#endif#ifndef TRUE#define TRUE 1#endif#ifndef M_PI#define M_PI 3.14159265358979323846#endif#define ASSERT_NOT_REACHED \do { \ static const int NOT_REACHED = 0; \ assert (NOT_REACHED); \} while (0)#include "cairo-wideint-private.h"typedef int32_t cairo_fixed_16_16_t;typedef cairo_int64_t cairo_fixed_32_32_t;typedef cairo_int64_t cairo_fixed_48_16_t;typedef cairo_int128_t cairo_fixed_64_64_t;typedef cairo_int128_t cairo_fixed_96_32_t;/* The common 16.16 format gets a shorter name */typedef cairo_fixed_16_16_t cairo_fixed_t;#define CAIRO_ALPHA_IS_OPAQUE(alpha) ((alpha) >= ((double)0xff00 / (double)0xffff))#define CAIRO_ALPHA_IS_ZERO(alpha) ((alpha) <= 0.0)/* 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)#ifdef WORDS_BIGENDIAN#define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) (c)#else#define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) CAIRO_BITSWAP8(c)#endif#include "cairo-hash-private.h"#include "cairo-cache-private.h"typedef struct _cairo_point { cairo_fixed_t x; cairo_fixed_t y;} cairo_point_t;typedef struct _cairo_slope{ cairo_fixed_t dx; cairo_fixed_t dy;} cairo_slope_t, cairo_distance_t;typedef struct _cairo_point_double { double x; double y;} cairo_point_double_t;typedef struct _cairo_distance_double { double dx; double dy;} cairo_distance_double_t;typedef struct _cairo_line { cairo_point_t p1; cairo_point_t p2;} cairo_line_t, cairo_box_t;typedef struct _cairo_trapezoid { cairo_fixed_t top, bottom; cairo_line_t left, right;} cairo_trapezoid_t;typedef struct _cairo_rectangle_int16 { int16_t x, y; uint16_t width, height;} cairo_rectangle_int16_t, cairo_glyph_size_t;/* Sure wish C had a real enum type so that this would be distinct from cairo_status_t. Oh well, without that, I'll use this bogus 1000 offset */typedef enum cairo_int_status { CAIRO_INT_STATUS_DEGENERATE = 1000, CAIRO_INT_STATUS_UNSUPPORTED, CAIRO_INT_STATUS_NOTHING_TO_DO, CAIRO_INT_STATUS_CACHE_EMPTY} cairo_int_status_t;typedef enum cairo_internal_surface_type { CAIRO_INTERNAL_SURFACE_TYPE_META = 0x1000, CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED, CAIRO_INTERNAL_SURFACE_TYPE_ANALYSIS, CAIRO_INTERNAL_SURFACE_TYPE_TEST_META, CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK, CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED} cairo_internal_surface_type_t;typedef enum cairo_direction { CAIRO_DIRECTION_FORWARD, CAIRO_DIRECTION_REVERSE} cairo_direction_t;typedef struct _cairo_path_fixed cairo_path_fixed_t;typedef enum _cairo_clip_mode { CAIRO_CLIP_MODE_PATH, CAIRO_CLIP_MODE_REGION, CAIRO_CLIP_MODE_MASK} cairo_clip_mode_t;typedef struct _cairo_clip_path cairo_clip_path_t;typedef struct _cairo_clip cairo_clip_t;typedef struct _cairo_edge { cairo_line_t edge; int clockWise; cairo_fixed_16_16_t current_x;} cairo_edge_t;typedef struct _cairo_polygon { int num_edges; int edges_size; cairo_edge_t *edges; cairo_point_t first_point; cairo_point_t current_point; int has_current_point; int closed;} cairo_polygon_t;typedef struct _cairo_spline { cairo_point_t a, b, c, d; cairo_slope_t initial_slope; cairo_slope_t final_slope; int num_points; int points_size; cairo_point_t *points;} cairo_spline_t;typedef struct _cairo_pen_vertex { cairo_point_t point; cairo_slope_t slope_ccw; cairo_slope_t slope_cw;} cairo_pen_vertex_t;typedef struct _cairo_pen { double radius; double tolerance; cairo_pen_vertex_t *vertices; int num_vertices;} cairo_pen_t;typedef struct _cairo_color cairo_color_t;typedef struct _cairo_image_surface cairo_image_surface_t;typedef struct _cairo_surface_backend cairo_surface_backend_t;cairo_private void_cairo_box_round_to_rectangle (cairo_box_t *box, cairo_rectangle_int16_t *rectangle);cairo_private void_cairo_rectangle_intersect (cairo_rectangle_int16_t *dest, cairo_rectangle_int16_t *src);/* cairo_array.c structures and functions */typedef struct _cairo_array cairo_array_t;struct _cairo_array { int size; int num_elements; int element_size; char **elements; cairo_bool_t is_snapshot;};cairo_private void_cairo_array_init (cairo_array_t *array, int element_size);cairo_private void_cairo_array_init_snapshot (cairo_array_t *array, const cairo_array_t *other);cairo_private void_cairo_array_fini (cairo_array_t *array);cairo_private cairo_status_t_cairo_array_grow_by (cairo_array_t *array, int additional);cairo_private void_cairo_array_truncate (cairo_array_t *array, int length);cairo_private cairo_status_t_cairo_array_append (cairo_array_t *array, const void *element);cairo_private cairo_status_t_cairo_array_append_multiple (cairo_array_t *array, const void *elements, int num_elements);cairo_private cairo_status_t_cairo_array_allocate (cairo_array_t *array, int num_elements, void **elements);cairo_private void *_cairo_array_index (cairo_array_t *array, int index);cairo_private void_cairo_array_copy_element (cairo_array_t *array, int index, void *dst);cairo_private int_cairo_array_num_elements (cairo_array_t *array);typedef cairo_array_t cairo_user_data_array_t;cairo_private void_cairo_user_data_array_init (cairo_user_data_array_t *array);cairo_private void_cairo_user_data_array_fini (cairo_user_data_array_t *array);cairo_private void *_cairo_user_data_array_get_data (cairo_user_data_array_t *array, const cairo_user_data_key_t *key);cairo_private cairo_status_t_cairo_user_data_array_set_data (cairo_user_data_array_t *array, const cairo_user_data_key_t *key, void *user_data, cairo_destroy_func_t destroy);cairo_private unsigned long_cairo_hash_string (const char *c);typedef struct _cairo_unscaled_font_backend cairo_unscaled_font_backend_t;typedef struct _cairo_scaled_font_backend cairo_scaled_font_backend_t;typedef struct _cairo_font_face_backend cairo_font_face_backend_t;/* * A cairo_unscaled_font_t is just an opaque handle we use in the * glyph cache. */typedef struct _cairo_unscaled_font { cairo_hash_entry_t hash_entry; int ref_count; const cairo_unscaled_font_backend_t *backend;} cairo_unscaled_font_t;struct _cairo_font_options { cairo_antialias_t antialias; cairo_subpixel_order_t subpixel_order; cairo_hint_style_t hint_style; cairo_hint_metrics_t hint_metrics;};typedef struct _cairo_scaled_glyph {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -