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 29namespace WTF { 30 31template<> void refIfNotNull(cairo_t* ptr) 32{ 33 if (LIKELY(ptr != 0)) 34 cairo_reference(ptr); 35} 36 37template<> void derefIfNotNull(cairo_t* ptr) 38{ 39 if (LIKELY(ptr != 0)) 40 cairo_destroy(ptr); 41} 42 43template<> void refIfNotNull(cairo_surface_t* ptr) 44{ 45 if (LIKELY(ptr != 0)) 46 cairo_surface_reference(ptr); 47} 48 49template<> void derefIfNotNull(cairo_surface_t* ptr) 50{ 51 if (LIKELY(ptr != 0)) 52 cairo_surface_destroy(ptr); 53} 54 55template<> void refIfNotNull(cairo_font_face_t* ptr) 56{ 57 if (LIKELY(ptr != 0)) 58 cairo_font_face_reference(ptr); 59} 60 61template<> void derefIfNotNull(cairo_font_face_t* ptr) 62{ 63 if (LIKELY(ptr != 0)) 64 cairo_font_face_destroy(ptr); 65} 66 67template<> void refIfNotNull(cairo_scaled_font_t* ptr) 68{ 69 if (LIKELY(ptr != 0)) 70 cairo_scaled_font_reference(ptr); 71} 72 73template<> void derefIfNotNull(cairo_scaled_font_t* ptr) 74{ 75 if (LIKELY(ptr != 0)) 76 cairo_scaled_font_destroy(ptr); 77} 78 79template<> void refIfNotNull(cairo_pattern_t* ptr) 80{ 81 if (LIKELY(ptr != 0)) 82 cairo_pattern_reference(ptr); 83} 84 85template<> void derefIfNotNull(cairo_pattern_t* ptr) 86{ 87 if (LIKELY(ptr != 0)) 88 cairo_pattern_destroy(ptr); 89} 90 91template<> void refIfNotNull(cairo_region_t* ptr) 92{ 93 if (LIKELY(ptr != 0)) 94 cairo_region_reference(ptr); 95} 96 97template<> void derefIfNotNull(cairo_region_t* ptr) 98{ 99 if (LIKELY(ptr != 0)) 100 cairo_region_destroy(ptr); 101} 102 103#if USE(FREETYPE) 104template<> void refIfNotNull(FcPattern* ptr) 105{ 106 if (LIKELY(ptr != 0)) 107 FcPatternReference(ptr); 108} 109 110template<> void derefIfNotNull(FcPattern* ptr) 111{ 112 if (LIKELY(ptr != 0)) 113 FcPatternDestroy(ptr); 114} 115 116#endif 117 118} 119