1/**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.  All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 **************************************************************************/
26
27#ifndef IMAGES_H
28#define IMAGES_H
29
30#include "vg_context.h"
31#include "pipe/p_state.h"
32
33struct pipe_resource;
34struct array;
35struct vg_context;
36struct pipe_surface;
37
38struct vg_image {
39   struct vg_object base;
40   VGImageFormat format;
41   VGint x, y;
42   VGint width, height;
43
44   struct vg_image *parent;
45
46   struct pipe_sampler_view *sampler_view;
47   struct pipe_sampler_state sampler;
48
49   struct array *children_array;
50};
51
52struct vg_image *image_create(VGImageFormat format,
53                              VGint width, VGint height);
54void image_destroy(struct vg_image *img);
55
56void image_clear(struct vg_image *img,
57                 VGint x, VGint y, VGint width, VGint height);
58
59void image_sub_data(struct vg_image *image,
60                    const void * data,
61                    VGint dataStride,
62                    VGImageFormat dataFormat,
63                    VGint x, VGint y,
64                    VGint width, VGint height);
65
66void image_get_sub_data(struct vg_image * image,
67                        void * data,
68                        VGint dataStride,
69                        VGImageFormat dataFormat,
70                        VGint x, VGint y,
71                        VGint width, VGint height);
72
73struct vg_image *image_child_image(struct vg_image *parent,
74                                   VGint x, VGint y,
75                                   VGint width, VGint height);
76
77void image_copy(struct vg_image *dst, VGint dx, VGint dy,
78                struct vg_image *src, VGint sx, VGint sy,
79                VGint width, VGint height,
80                VGboolean dither);
81
82void image_draw(struct vg_image *img, struct matrix *matrix);
83
84void image_set_pixels(VGint dx, VGint dy,
85                      struct vg_image *src, VGint sx, VGint sy,
86                      VGint width, VGint height);
87void image_get_pixels(struct vg_image *dst, VGint dx, VGint dy,
88                      VGint sx, VGint sy,
89                      VGint width, VGint height);
90
91VGint image_bind_samplers(struct vg_image *dst, struct pipe_sampler_state **samplers,
92                          struct pipe_sampler_view **sampler_views);
93
94VGboolean vg_image_overlaps(struct vg_image *dst,
95                            struct vg_image *src);
96
97VGint image_sampler_filter(struct vg_context *ctx);
98
99void vg_copy_surface(struct vg_context *ctx,
100                     struct pipe_surface *dst, VGint dx, VGint dy,
101                     struct pipe_surface *src, VGint sx, VGint sy,
102                     VGint width, VGint height);
103
104#endif
105