| 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 | #if USE(CAIRO) |
| 23 | |
| 24 | #include <cairo.h> |
| 25 | |
| 26 | namespace WTF { |
| 27 | |
| 28 | template<> void refIfNotNull(cairo_t* ptr) |
| 29 | { |
| 30 | if (LIKELY(ptr)) |
| 31 | cairo_reference(ptr); |
| 32 | } |
| 33 | |
| 34 | template<> void derefIfNotNull(cairo_t* ptr) |
| 35 | { |
| 36 | if (LIKELY(ptr)) |
| 37 | cairo_destroy(ptr); |
| 38 | } |
| 39 | |
| 40 | template<> void refIfNotNull(cairo_surface_t* ptr) |
| 41 | { |
| 42 | if (LIKELY(ptr)) |
| 43 | cairo_surface_reference(ptr); |
| 44 | } |
| 45 | |
| 46 | template<> void derefIfNotNull(cairo_surface_t* ptr) |
| 47 | { |
| 48 | if (LIKELY(ptr)) |
| 49 | cairo_surface_destroy(ptr); |
| 50 | } |
| 51 | |
| 52 | template<> void refIfNotNull(cairo_font_face_t* ptr) |
| 53 | { |
| 54 | if (LIKELY(ptr)) |
| 55 | cairo_font_face_reference(ptr); |
| 56 | } |
| 57 | |
| 58 | template<> void derefIfNotNull(cairo_font_face_t* ptr) |
| 59 | { |
| 60 | if (LIKELY(ptr)) |
| 61 | cairo_font_face_destroy(ptr); |
| 62 | } |
| 63 | |
| 64 | template<> void refIfNotNull(cairo_scaled_font_t* ptr) |
| 65 | { |
| 66 | if (LIKELY(ptr)) |
| 67 | cairo_scaled_font_reference(ptr); |
| 68 | } |
| 69 | |
| 70 | template<> void derefIfNotNull(cairo_scaled_font_t* ptr) |
| 71 | { |
| 72 | if (LIKELY(ptr)) |
| 73 | cairo_scaled_font_destroy(ptr); |
| 74 | } |
| 75 | |
| 76 | template<> void refIfNotNull(cairo_pattern_t* ptr) |
| 77 | { |
| 78 | if (LIKELY(ptr)) |
| 79 | cairo_pattern_reference(ptr); |
| 80 | } |
| 81 | |
| 82 | template<> void derefIfNotNull(cairo_pattern_t* ptr) |
| 83 | { |
| 84 | if (LIKELY(ptr)) |
| 85 | cairo_pattern_destroy(ptr); |
| 86 | } |
| 87 | |
| 88 | template<> void refIfNotNull(cairo_region_t* ptr) |
| 89 | { |
| 90 | if (LIKELY(ptr)) |
| 91 | cairo_region_reference(ptr); |
| 92 | } |
| 93 | |
| 94 | template<> void derefIfNotNull(cairo_region_t* ptr) |
| 95 | { |
| 96 | if (LIKELY(ptr)) |
| 97 | cairo_region_destroy(ptr); |
| 98 | } |
| 99 | |
| 100 | } // namespace WTF |
| 101 | |
| 102 | #endif // USE(CAIRO) |
| 103 |