Subversion Repositories Kolibri OS

Rev

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

  1. /* cairo - a vector graphics library with display and print output
  2.  *
  3.  * Copyright © 2002 University of Southern California
  4.  * Copyright © 2005 Red Hat, Inc.
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it either under the terms of the GNU Lesser General Public
  8.  * License version 2.1 as published by the Free Software Foundation
  9.  * (the "LGPL") or, at your option, under the terms of the Mozilla
  10.  * Public License Version 1.1 (the "MPL"). If you do not alter this
  11.  * notice, a recipient may use your version of this file under either
  12.  * the MPL or the LGPL.
  13.  *
  14.  * You should have received a copy of the LGPL along with this library
  15.  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
  16.  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
  17.  * You should have received a copy of the MPL along with this library
  18.  * in the file COPYING-MPL-1.1
  19.  *
  20.  * The contents of this file are subject to the Mozilla Public License
  21.  * Version 1.1 (the "License"); you may not use this file except in
  22.  * compliance with the License. You may obtain a copy of the License at
  23.  * http://www.mozilla.org/MPL/
  24.  *
  25.  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  26.  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  27.  * the specific language governing rights and limitations.
  28.  *
  29.  * The Original Code is the cairo graphics library.
  30.  *
  31.  * The Initial Developer of the Original Code is University of Southern
  32.  * California.
  33.  *
  34.  * Contributor(s):
  35.  *      Carl D. Worth <cworth@cworth.org>
  36.  */
  37.  
  38. #ifndef CAIRO_SCALED_FONT_PRIVATE_H
  39. #define CAIRO_SCALED_FONT_PRIVATE_H
  40.  
  41. #include "cairo.h"
  42.  
  43. #include "cairo-types-private.h"
  44. #include "cairo-list-private.h"
  45. #include "cairo-mutex-type-private.h"
  46. #include "cairo-reference-count-private.h"
  47.  
  48. typedef struct _cairo_scaled_glyph_page cairo_scaled_glyph_page_t;
  49.  
  50. struct _cairo_scaled_font {
  51.     /* For most cairo objects, the rule for multiple threads is that
  52.      * the user is responsible for any locking if the same object is
  53.      * manipulated from multiple threads simultaneously.
  54.      *
  55.      * However, with the caching that cairo does for scaled fonts, a
  56.      * user can easily end up with the same cairo_scaled_font object
  57.      * being manipulated from multiple threads without the user ever
  58.      * being aware of this, (and in fact, unable to control it).
  59.      *
  60.      * So, as a special exception, the cairo implementation takes care
  61.      * of all locking needed for cairo_scaled_font_t. Most of what is
  62.      * in the scaled font is immutable, (which is what allows for the
  63.      * sharing in the first place). The things that are modified and
  64.      * the locks protecting them are as follows:
  65.      *
  66.      * 1. The reference count (scaled_font->ref_count)
  67.      *
  68.      *    Modifications to the reference count are protected by the
  69.      *    _cairo_scaled_font_map_mutex. This is because the reference
  70.      *    count of a scaled font is intimately related with the font
  71.      *    map itself, (and the magic holdovers array).
  72.      *
  73.      * 2. The cache of glyphs (scaled_font->glyphs)
  74.      * 3. The backend private data (scaled_font->surface_backend,
  75.      *                              scaled_font->surface_private)
  76.      *
  77.      *    Modifications to these fields are protected with locks on
  78.      *    scaled_font->mutex in the generic scaled_font code.
  79.      */
  80.  
  81.     cairo_hash_entry_t hash_entry;
  82.  
  83.     /* useful bits for _cairo_scaled_font_nil */
  84.     cairo_status_t status;
  85.     cairo_reference_count_t ref_count;
  86.     cairo_user_data_array_t user_data;
  87.  
  88.     cairo_font_face_t *original_font_face; /* may be NULL */
  89.  
  90.     /* hash key members */
  91.     cairo_font_face_t *font_face; /* may be NULL */
  92.     cairo_matrix_t font_matrix;   /* font space => user space */
  93.     cairo_matrix_t ctm;           /* user space => device space */
  94.     cairo_font_options_t options;
  95.  
  96.     unsigned int placeholder : 1; /*  protected by fontmap mutex */
  97.     unsigned int holdover : 1;
  98.     unsigned int finished : 1;
  99.  
  100.     /* "live" scaled_font members */
  101.     cairo_matrix_t scale;            /* font space => device space */
  102.     cairo_matrix_t scale_inverse;    /* device space => font space */
  103.     double max_scale;                /* maximum x/y expansion of scale */
  104.     cairo_font_extents_t extents;    /* user space */
  105.     cairo_font_extents_t fs_extents; /* font space */
  106.  
  107.     /* The mutex protects modification to all subsequent fields. */
  108.     cairo_mutex_t mutex;
  109.  
  110.     cairo_hash_table_t *glyphs;
  111.     cairo_list_t glyph_pages;
  112.     cairo_bool_t cache_frozen;
  113.     cairo_bool_t global_cache_frozen;
  114.  
  115.     /*
  116.      * One surface backend may store data in each glyph.
  117.      * Whichever surface manages to store its pointer here
  118.      * first gets to store data in each glyph
  119.      */
  120.     const cairo_surface_backend_t *surface_backend;
  121.     void *surface_private;
  122.  
  123.     /* font backend managing this scaled font */
  124.     const cairo_scaled_font_backend_t *backend;
  125.     cairo_list_t link;
  126. };
  127.  
  128. cairo_private void
  129. _cairo_scaled_font_revoke_ownership (cairo_scaled_font_t *scaled_font);
  130.  
  131. #endif /* CAIRO_SCALED_FONT_PRIVATE_H */
  132.