1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2020 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program 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
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #ifndef OUTPUT_IMAGE_ITEM_H
18 #define OUTPUT_IMAGE_ITEM_H 1
24 #include "output/output-item.h"
28 struct output_item output_item; /* Superclass */
30 cairo_surface_t *image;
35 struct image_item *image_item_create (cairo_surface_t *);
38 struct image_item *image_item_unshare (struct image_item *);
40 /* This boilerplate for image_item, a subclass of output_item, was
41 autogenerated by mk-class-boilerplate. */
44 #include "libpspp/cast.h"
46 extern const struct output_item_class image_item_class;
48 /* Returns true if SUPER is a image_item, otherwise false. */
50 is_image_item (const struct output_item *super)
52 return super->class == &image_item_class;
55 /* Returns SUPER converted to image_item. SUPER must be a image_item, as
56 reported by is_image_item. */
57 static inline struct image_item *
58 to_image_item (const struct output_item *super)
60 assert (is_image_item (super));
61 return UP_CAST (super, struct image_item, output_item);
64 /* Returns INSTANCE converted to output_item. */
65 static inline struct output_item *
66 image_item_super (const struct image_item *instance)
68 return CONST_CAST (struct output_item *, &instance->output_item);
71 /* Increments INSTANCE's reference count and returns INSTANCE. */
72 static inline struct image_item *
73 image_item_ref (const struct image_item *instance)
75 return to_image_item (output_item_ref (&instance->output_item));
78 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
79 the reference count is now zero. */
81 image_item_unref (struct image_item *instance)
83 output_item_unref (&instance->output_item);
86 /* Returns true if INSTANCE's reference count is greater than 1,
89 image_item_is_shared (const struct image_item *instance)
91 return output_item_is_shared (&instance->output_item);
94 void image_item_submit (struct image_item *);
96 #endif /* output/image-item.h */