Home | History | Annotate | Download | only in cairo
      1 /*
      2  *  Copyright (C) 2010 Igalia S.L.
      3  *
      4  *  This library is free software; you can redistribute it and/or
      5  *  modify it under the terms of the GNU Lesser General Public
      6  *  License as published by the Free Software Foundation; either
      7  *  version 2 of the License, or (at your option) any later version.
      8  *
      9  *  This library is distributed in the hope that it will be useful,
     10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  *  Lesser General Public License for more details.
     13  *
     14  *  You should have received a copy of the GNU Lesser General Public
     15  *  License along with this library; if not, write to the Free Software
     16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
     17  */
     18 
     19 #include "config.h"
     20 #include "RefPtrCairo.h"
     21 
     22 #include <cairo.h>
     23 
     24 #if USE(FREETYPE)
     25 #include <cairo-ft.h>
     26 #include <fontconfig/fcfreetype.h>
     27 #endif
     28 
     29 namespace WTF {
     30 
     31 template<> void refIfNotNull(cairo_t* ptr)
     32 {
     33     if (LIKELY(ptr != 0))
     34         cairo_reference(ptr);
     35 }
     36 
     37 template<> void derefIfNotNull(cairo_t* ptr)
     38 {
     39     if (LIKELY(ptr != 0))
     40         cairo_destroy(ptr);
     41 }
     42 
     43 template<> void refIfNotNull(cairo_surface_t* ptr)
     44 {
     45     if (LIKELY(ptr != 0))
     46         cairo_surface_reference(ptr);
     47 }
     48 
     49 template<> void derefIfNotNull(cairo_surface_t* ptr)
     50 {
     51     if (LIKELY(ptr != 0))
     52         cairo_surface_destroy(ptr);
     53 }
     54 
     55 template<> void refIfNotNull(cairo_font_face_t* ptr)
     56 {
     57     if (LIKELY(ptr != 0))
     58         cairo_font_face_reference(ptr);
     59 }
     60 
     61 template<> void derefIfNotNull(cairo_font_face_t* ptr)
     62 {
     63     if (LIKELY(ptr != 0))
     64         cairo_font_face_destroy(ptr);
     65 }
     66 
     67 template<> void refIfNotNull(cairo_scaled_font_t* ptr)
     68 {
     69     if (LIKELY(ptr != 0))
     70         cairo_scaled_font_reference(ptr);
     71 }
     72 
     73 template<> void derefIfNotNull(cairo_scaled_font_t* ptr)
     74 {
     75     if (LIKELY(ptr != 0))
     76         cairo_scaled_font_destroy(ptr);
     77 }
     78 
     79 template<> void refIfNotNull(cairo_pattern_t* ptr)
     80 {
     81     if (LIKELY(ptr != 0))
     82         cairo_pattern_reference(ptr);
     83 }
     84 
     85 template<> void derefIfNotNull(cairo_pattern_t* ptr)
     86 {
     87     if (LIKELY(ptr != 0))
     88         cairo_pattern_destroy(ptr);
     89 }
     90 
     91 #if USE(FREETYPE)
     92 template<> void refIfNotNull(FcPattern* ptr)
     93 {
     94     if (LIKELY(ptr != 0))
     95         FcPatternReference(ptr);
     96 }
     97 
     98 template<> void derefIfNotNull(FcPattern* ptr)
     99 {
    100     if (LIKELY(ptr != 0))
    101         FcPatternDestroy(ptr);
    102 }
    103 
    104 #endif
    105 
    106 }
    107