Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
  2. /* cairo - a vector graphics library with display and print output
  3.  *
  4.  * Copyright © 2002 University of Southern California
  5.  * Copyright © 2005 Red Hat, Inc.
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it either under the terms of the GNU Lesser General Public
  9.  * License version 2.1 as published by the Free Software Foundation
  10.  * (the "LGPL") or, at your option, under the terms of the Mozilla
  11.  * Public License Version 1.1 (the "MPL"). If you do not alter this
  12.  * notice, a recipient may use your version of this file under either
  13.  * the MPL or the LGPL.
  14.  *
  15.  * You should have received a copy of the LGPL along with this library
  16.  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
  17.  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
  18.  * You should have received a copy of the MPL along with this library
  19.  * in the file COPYING-MPL-1.1
  20.  *
  21.  * The contents of this file are subject to the Mozilla Public License
  22.  * Version 1.1 (the "License"); you may not use this file except in
  23.  * compliance with the License. You may obtain a copy of the License at
  24.  * http://www.mozilla.org/MPL/
  25.  *
  26.  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  27.  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  28.  * the specific language governing rights and limitations.
  29.  *
  30.  * The Original Code is the cairo graphics library.
  31.  *
  32.  * The Initial Developer of the Original Code is University of Southern
  33.  * California.
  34.  *
  35.  * Contributor(s):
  36.  *      Carl D. Worth <cworth@cworth.org>
  37.  */
  38.  
  39. #ifndef CAIRO_TYPES_PRIVATE_H
  40. #define CAIRO_TYPES_PRIVATE_H
  41.  
  42. #include "cairo.h"
  43. #include "cairo-fixed-type-private.h"
  44. #include "cairo-list-private.h"
  45. #include "cairo-reference-count-private.h"
  46.  
  47. /**
  48.  * SECTION:cairo-types
  49.  * @Title: Types
  50.  * @Short_Description: Generic data types
  51.  *
  52.  * This section lists generic data types used in the cairo API.
  53.  */
  54.  
  55. typedef struct _cairo_array cairo_array_t;
  56. typedef struct _cairo_backend cairo_backend_t;
  57. typedef struct _cairo_boxes_t cairo_boxes_t;
  58. typedef struct _cairo_cache cairo_cache_t;
  59. typedef struct _cairo_composite_rectangles cairo_composite_rectangles_t;
  60. typedef struct _cairo_clip cairo_clip_t;
  61. typedef struct _cairo_clip_path cairo_clip_path_t;
  62. typedef struct _cairo_color cairo_color_t;
  63. typedef struct _cairo_color_stop cairo_color_stop_t;
  64. typedef struct _cairo_device_backend cairo_device_backend_t;
  65. typedef struct _cairo_font_face_backend     cairo_font_face_backend_t;
  66. typedef struct _cairo_gstate cairo_gstate_t;
  67. typedef struct _cairo_hash_entry cairo_hash_entry_t;
  68. typedef struct _cairo_hash_table cairo_hash_table_t;
  69. typedef struct _cairo_image_surface cairo_image_surface_t;
  70. typedef struct _cairo_mime_data cairo_mime_data_t;
  71. typedef struct _cairo_observer cairo_observer_t;
  72. typedef struct _cairo_output_stream cairo_output_stream_t;
  73. typedef struct _cairo_paginated_surface_backend cairo_paginated_surface_backend_t;
  74. typedef struct _cairo_path_fixed cairo_path_fixed_t;
  75. typedef struct _cairo_rectangle_int16 cairo_glyph_size_t;
  76. typedef struct _cairo_scaled_font_backend   cairo_scaled_font_backend_t;
  77. typedef struct _cairo_scaled_font_subsets cairo_scaled_font_subsets_t;
  78. typedef struct _cairo_solid_pattern cairo_solid_pattern_t;
  79. typedef struct _cairo_surface_backend cairo_surface_backend_t;
  80. typedef struct _cairo_surface_snapshot cairo_surface_snapshot_t;
  81. typedef struct _cairo_surface_subsurface cairo_surface_subsurface_t;
  82. typedef struct _cairo_surface_wrapper cairo_surface_wrapper_t;
  83. typedef struct _cairo_unscaled_font_backend cairo_unscaled_font_backend_t;
  84. typedef struct _cairo_xlib_screen_info cairo_xlib_screen_info_t;
  85.  
  86. typedef cairo_array_t cairo_user_data_array_t;
  87.  
  88. struct _cairo_observer {
  89.     cairo_list_t link;
  90.     void (*callback) (cairo_observer_t *self, void *arg);
  91. };
  92.  
  93. /**
  94.  * cairo_hash_entry_t:
  95.  *
  96.  * A #cairo_hash_entry_t contains both a key and a value for
  97.  * #cairo_hash_table_t. User-derived types for #cairo_hash_entry_t must
  98.  * be type-compatible with this structure (eg. they must have an
  99.  * unsigned long as the first parameter. The easiest way to get this
  100.  * is to use:
  101.  *
  102.  *      typedef _my_entry {
  103.  *          cairo_hash_entry_t base;
  104.  *          ... Remainder of key and value fields here ..
  105.  *      } my_entry_t;
  106.  *
  107.  * which then allows a pointer to my_entry_t to be passed to any of
  108.  * the #cairo_hash_table_t functions as follows without requiring a cast:
  109.  *
  110.  *      _cairo_hash_table_insert (hash_table, &my_entry->base);
  111.  *
  112.  * IMPORTANT: The caller is reponsible for initializing
  113.  * my_entry->base.hash with a hash code derived from the key. The
  114.  * essential property of the hash code is that keys_equal must never
  115.  * return %TRUE for two keys that have different hashes. The best hash
  116.  * code will reduce the frequency of two keys with the same code for
  117.  * which keys_equal returns %FALSE.
  118.  *
  119.  * Which parts of the entry make up the "key" and which part make up
  120.  * the value are entirely up to the caller, (as determined by the
  121.  * computation going into base.hash as well as the keys_equal
  122.  * function). A few of the #cairo_hash_table_t functions accept an entry
  123.  * which will be used exclusively as a "key", (indicated by a
  124.  * parameter name of key). In these cases, the value-related fields of
  125.  * the entry need not be initialized if so desired.
  126.  **/
  127. struct _cairo_hash_entry {
  128.     unsigned long hash;
  129. };
  130.  
  131. struct _cairo_array {
  132.     unsigned int size;
  133.     unsigned int num_elements;
  134.     unsigned int element_size;
  135.     char **elements;
  136.  
  137.     cairo_bool_t is_snapshot;
  138. };
  139.  
  140. /**
  141.  * cairo_lcd_filter_t:
  142.  * @CAIRO_LCD_FILTER_DEFAULT: Use the default LCD filter for
  143.  *   font backend and target device
  144.  * @CAIRO_LCD_FILTER_NONE: Do not perform LCD filtering
  145.  * @CAIRO_LCD_FILTER_INTRA_PIXEL: Intra-pixel filter
  146.  * @CAIRO_LCD_FILTER_FIR3: FIR filter with a 3x3 kernel
  147.  * @CAIRO_LCD_FILTER_FIR5: FIR filter with a 5x5 kernel
  148.  *
  149.  * The LCD filter specifies the low-pass filter applied to LCD-optimized
  150.  * bitmaps generated with an antialiasing mode of %CAIRO_ANTIALIAS_SUBPIXEL.
  151.  *
  152.  * Note: This API was temporarily made available in the public
  153.  * interface during the 1.7.x development series, but was made private
  154.  * before 1.8.
  155.  **/
  156. typedef enum _cairo_lcd_filter {
  157.     CAIRO_LCD_FILTER_DEFAULT,
  158.     CAIRO_LCD_FILTER_NONE,
  159.     CAIRO_LCD_FILTER_INTRA_PIXEL,
  160.     CAIRO_LCD_FILTER_FIR3,
  161.     CAIRO_LCD_FILTER_FIR5
  162. } cairo_lcd_filter_t;
  163.  
  164. struct _cairo_font_options {
  165.     cairo_antialias_t antialias;
  166.     cairo_subpixel_order_t subpixel_order;
  167.     cairo_lcd_filter_t lcd_filter;
  168.     cairo_hint_style_t hint_style;
  169.     cairo_hint_metrics_t hint_metrics;
  170. };
  171.  
  172. /* XXX: Right now, the _cairo_color structure puts unpremultiplied
  173.    color in the doubles and premultiplied color in the shorts. Yes,
  174.    this is crazy insane, (but at least we don't export this
  175.    madness). I'm still working on a cleaner API, but in the meantime,
  176.    at least this does prevent precision loss in color when changing
  177.    alpha. */
  178. struct _cairo_color {
  179.     double red;
  180.     double green;
  181.     double blue;
  182.     double alpha;
  183.  
  184.     unsigned short red_short;
  185.     unsigned short green_short;
  186.     unsigned short blue_short;
  187.     unsigned short alpha_short;
  188. };
  189.  
  190. struct _cairo_color_stop {
  191.     /* unpremultiplied */
  192.     double red;
  193.     double green;
  194.     double blue;
  195.     double alpha;
  196.  
  197.     /* unpremultipled, for convenience */
  198.     uint16_t red_short;
  199.     uint16_t green_short;
  200.     uint16_t blue_short;
  201.     uint16_t alpha_short;
  202. };
  203.  
  204. typedef enum _cairo_paginated_mode {
  205.     CAIRO_PAGINATED_MODE_ANALYZE,       /* analyze page regions */
  206.     CAIRO_PAGINATED_MODE_RENDER,        /* render page contents */
  207.     CAIRO_PAGINATED_MODE_FALLBACK       /* paint fallback images */
  208. } cairo_paginated_mode_t;
  209.  
  210. /* Sure wish C had a real enum type so that this would be distinct
  211.  * from #cairo_status_t. Oh well, without that, I'll use this bogus 100
  212.  * offset.  We want to keep it fit in int8_t as the compiler may choose
  213.  * that for #cairo_status_t */
  214. typedef enum _cairo_int_status {
  215.     CAIRO_INT_STATUS_UNSUPPORTED = 100,
  216.     CAIRO_INT_STATUS_DEGENERATE,
  217.     CAIRO_INT_STATUS_NOTHING_TO_DO,
  218.     CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY,
  219.     CAIRO_INT_STATUS_IMAGE_FALLBACK,
  220.     CAIRO_INT_STATUS_ANALYZE_RECORDING_SURFACE_PATTERN,
  221.  
  222.     CAIRO_INT_STATUS_LAST_STATUS
  223. } cairo_int_status_t;
  224.  
  225. typedef enum _cairo_internal_surface_type {
  226.     CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT = 0x1000,
  227.     CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED,
  228.     CAIRO_INTERNAL_SURFACE_TYPE_ANALYSIS,
  229.     CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
  230.     CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED,
  231.     CAIRO_INTERNAL_SURFACE_TYPE_TEST_WRAPPING,
  232.     CAIRO_INTERNAL_SURFACE_TYPE_NULL,
  233.     CAIRO_INTERNAL_SURFACE_TYPE_TYPE3_GLYPH
  234. } cairo_internal_surface_type_t;
  235.  
  236. #define CAIRO_HAS_TEST_PAGINATED_SURFACE 1
  237. #define CAIRO_HAS_TEST_NULL_SURFACE 1
  238. #define CAIRO_HAS_TEST_WRAPPING_SURFACE 1
  239.  
  240. typedef struct _cairo_slope {
  241.     cairo_fixed_t dx;
  242.     cairo_fixed_t dy;
  243. } cairo_slope_t, cairo_distance_t;
  244.  
  245. typedef struct _cairo_point_double {
  246.     double x;
  247.     double y;
  248. } cairo_point_double_t;
  249.  
  250. typedef struct _cairo_distance_double {
  251.     double dx;
  252.     double dy;
  253. } cairo_distance_double_t;
  254.  
  255. typedef struct _cairo_line {
  256.     cairo_point_t p1;
  257.     cairo_point_t p2;
  258. } cairo_line_t, cairo_box_t;
  259.  
  260. typedef struct _cairo_trapezoid {
  261.     cairo_fixed_t top, bottom;
  262.     cairo_line_t left, right;
  263. } cairo_trapezoid_t;
  264.  
  265. typedef struct _cairo_point_int {
  266.     int x, y;
  267. } cairo_point_int_t;
  268.  
  269. #define CAIRO_RECT_INT_MIN (INT_MIN >> CAIRO_FIXED_FRAC_BITS)
  270. #define CAIRO_RECT_INT_MAX (INT_MAX >> CAIRO_FIXED_FRAC_BITS)
  271.  
  272. typedef enum _cairo_direction {
  273.     CAIRO_DIRECTION_FORWARD,
  274.     CAIRO_DIRECTION_REVERSE
  275. } cairo_direction_t;
  276.  
  277. typedef struct _cairo_edge {
  278.     cairo_line_t line;
  279.     int top, bottom;
  280.     int dir;
  281. } cairo_edge_t;
  282.  
  283. typedef struct _cairo_polygon {
  284.     cairo_status_t status;
  285.  
  286.     cairo_point_t first_point;
  287.     cairo_point_t last_point;
  288.     cairo_point_t current_point;
  289.     cairo_slope_t current_edge;
  290.     cairo_bool_t has_current_point;
  291.     cairo_bool_t has_current_edge;
  292.  
  293.     cairo_box_t extents;
  294.     cairo_box_t limit;
  295.     const cairo_box_t *limits;
  296.     int num_limits;
  297.  
  298.     int num_edges;
  299.     int edges_size;
  300.     cairo_edge_t *edges;
  301.     cairo_edge_t  edges_embedded[32];
  302. } cairo_polygon_t;
  303.  
  304. typedef cairo_warn cairo_status_t
  305. (*cairo_spline_add_point_func_t) (void *closure,
  306.                                   const cairo_point_t *point);
  307.  
  308. typedef struct _cairo_spline_knots {
  309.     cairo_point_t a, b, c, d;
  310. } cairo_spline_knots_t;
  311.  
  312. typedef struct _cairo_spline {
  313.     cairo_spline_add_point_func_t add_point_func;
  314.     void *closure;
  315.  
  316.     cairo_spline_knots_t knots;
  317.  
  318.     cairo_slope_t initial_slope;
  319.     cairo_slope_t final_slope;
  320.  
  321.     cairo_bool_t has_point;
  322.     cairo_point_t last_point;
  323. } cairo_spline_t;
  324.  
  325. typedef struct _cairo_pen_vertex {
  326.     cairo_point_t point;
  327.  
  328.     cairo_slope_t slope_ccw;
  329.     cairo_slope_t slope_cw;
  330. } cairo_pen_vertex_t;
  331.  
  332. typedef struct _cairo_pen {
  333.     double radius;
  334.     double tolerance;
  335.  
  336.     int num_vertices;
  337.     cairo_pen_vertex_t *vertices;
  338.     cairo_pen_vertex_t  vertices_embedded[32];
  339. } cairo_pen_t;
  340.  
  341. typedef struct _cairo_stroke_style {
  342.     double               line_width;
  343.     cairo_line_cap_t     line_cap;
  344.     cairo_line_join_t    line_join;
  345.     double               miter_limit;
  346.     double              *dash;
  347.     unsigned int         num_dashes;
  348.     double               dash_offset;
  349. } cairo_stroke_style_t;
  350.  
  351. typedef struct _cairo_format_masks {
  352.     int bpp;
  353.     unsigned long alpha_mask;
  354.     unsigned long red_mask;
  355.     unsigned long green_mask;
  356.     unsigned long blue_mask;
  357. } cairo_format_masks_t;
  358.  
  359. typedef enum {
  360.     CAIRO_STOCK_WHITE,
  361.     CAIRO_STOCK_BLACK,
  362.     CAIRO_STOCK_TRANSPARENT,
  363.     CAIRO_STOCK_NUM_COLORS,
  364. } cairo_stock_t;
  365.  
  366. typedef enum _cairo_image_transparency {
  367.     CAIRO_IMAGE_IS_OPAQUE,
  368.     CAIRO_IMAGE_HAS_BILEVEL_ALPHA,
  369.     CAIRO_IMAGE_HAS_ALPHA,
  370.     CAIRO_IMAGE_UNKNOWN
  371. } cairo_image_transparency_t;
  372.  
  373. struct _cairo_mime_data {
  374.     cairo_reference_count_t ref_count;
  375.     unsigned char *data;
  376.     unsigned long length;
  377.     cairo_destroy_func_t destroy;
  378.     void *closure;
  379. };
  380.  
  381. struct _cairo_pattern {
  382.     cairo_pattern_type_t        type;
  383.     cairo_reference_count_t     ref_count;
  384.     cairo_status_t              status;
  385.     cairo_user_data_array_t     user_data;
  386.  
  387.     cairo_matrix_t              matrix;
  388.     cairo_filter_t              filter;
  389.     cairo_extend_t              extend;
  390.  
  391.     cairo_bool_t                has_component_alpha;
  392. };
  393.  
  394. struct _cairo_solid_pattern {
  395.     cairo_pattern_t base;
  396.     cairo_color_t color;
  397. };
  398.  
  399. typedef struct _cairo_surface_pattern {
  400.     cairo_pattern_t base;
  401.  
  402.     cairo_surface_t *surface;
  403. } cairo_surface_pattern_t;
  404.  
  405. typedef struct _cairo_gradient_stop {
  406.     double offset;
  407.     cairo_color_stop_t color;
  408. } cairo_gradient_stop_t;
  409.  
  410. typedef struct _cairo_gradient_pattern {
  411.     cairo_pattern_t base;
  412.  
  413.     unsigned int            n_stops;
  414.     unsigned int            stops_size;
  415.     cairo_gradient_stop_t  *stops;
  416.     cairo_gradient_stop_t   stops_embedded[2];
  417. } cairo_gradient_pattern_t;
  418.  
  419. typedef struct _cairo_linear_pattern {
  420.     cairo_gradient_pattern_t base;
  421.  
  422.     cairo_point_t p1;
  423.     cairo_point_t p2;
  424. } cairo_linear_pattern_t;
  425.  
  426. typedef struct _cairo_radial_pattern {
  427.     cairo_gradient_pattern_t base;
  428.  
  429.     cairo_point_t c1;
  430.     cairo_fixed_t r1;
  431.     cairo_point_t c2;
  432.     cairo_fixed_t r2;
  433. } cairo_radial_pattern_t;
  434.  
  435. typedef union {
  436.     cairo_gradient_pattern_t base;
  437.  
  438.     cairo_linear_pattern_t linear;
  439.     cairo_radial_pattern_t radial;
  440. } cairo_gradient_pattern_union_t;
  441.  
  442. typedef union {
  443.     cairo_pattern_type_t            type;
  444.     cairo_pattern_t                 base;
  445.  
  446.     cairo_solid_pattern_t           solid;
  447.     cairo_surface_pattern_t         surface;
  448.     cairo_gradient_pattern_union_t  gradient;
  449. } cairo_pattern_union_t;
  450.  
  451. /*
  452.  * A #cairo_unscaled_font_t is just an opaque handle we use in the
  453.  * glyph cache.
  454.  */
  455. typedef struct _cairo_unscaled_font {
  456.     cairo_hash_entry_t                   hash_entry;
  457.     cairo_reference_count_t              ref_count;
  458.     const cairo_unscaled_font_backend_t *backend;
  459. } cairo_unscaled_font_t;
  460.  
  461. typedef struct _cairo_scaled_glyph {
  462.     cairo_hash_entry_t hash_entry;
  463.  
  464.     cairo_text_extents_t    metrics;            /* user-space metrics */
  465.     cairo_text_extents_t    fs_metrics;         /* font-space metrics */
  466.     cairo_box_t             bbox;               /* device-space bounds */
  467.     int16_t                 x_advance;          /* device-space rounded X advance */
  468.     int16_t                 y_advance;          /* device-space rounded Y advance */
  469.  
  470.     unsigned int            has_info;
  471.     cairo_image_surface_t   *surface;           /* device-space image */
  472.     cairo_path_fixed_t      *path;              /* device-space outline */
  473.     cairo_surface_t         *recording_surface; /* device-space recording-surface */
  474.  
  475.     void                    *surface_private;   /* for the surface backend */
  476. } cairo_scaled_glyph_t;
  477. #endif /* CAIRO_TYPES_PRIVATE_H */
  478.