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
22 #include "output/output-item.h"
26 struct output_item output_item; /* Superclass */
27 cairo_surface_t *image;
30 struct image_item *image_item_create (cairo_surface_t *);
31 struct image_item *image_item_unshare (struct image_item *);
33 /* This boilerplate for image_item, a subclass of output_item, was
34 autogenerated by mk-class-boilerplate. */
37 #include "libpspp/cast.h"
39 extern const struct output_item_class image_item_class;
41 /* Returns true if SUPER is a image_item, otherwise false. */
43 is_image_item (const struct output_item *super)
45 return super->class == &image_item_class;
48 /* Returns SUPER converted to image_item. SUPER must be a image_item, as
49 reported by is_image_item. */
50 static inline struct image_item *
51 to_image_item (const struct output_item *super)
53 assert (is_image_item (super));
54 return UP_CAST (super, struct image_item, output_item);
57 /* Returns INSTANCE converted to output_item. */
58 static inline struct output_item *
59 image_item_super (const struct image_item *instance)
61 return CONST_CAST (struct output_item *, &instance->output_item);
64 /* Increments INSTANCE's reference count and returns INSTANCE. */
65 static inline struct image_item *
66 image_item_ref (const struct image_item *instance)
68 return to_image_item (output_item_ref (&instance->output_item));
71 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
72 the reference count is now zero. */
74 image_item_unref (struct image_item *instance)
76 output_item_unref (&instance->output_item);
79 /* Returns true if INSTANCE's reference count is greater than 1,
82 image_item_is_shared (const struct image_item *instance)
84 return output_item_is_shared (&instance->output_item);
87 void image_item_submit (struct image_item *);
89 #endif /* output/image-item.h */