1 /**************************************************************************
2 *
3 * Copyright 2007 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef P_TILE_H
29 #define P_TILE_H
30
31 #include "pipe/p_compiler.h"
32 #include "pipe/p_format.h"
33 #include "pipe/p_state.h"
34
35 struct pipe_context;
36 struct pipe_transfer;
37
38 /**
39 * Clip tile against transfer dims.
40 *
41 * XXX: this only clips width and height!
42 *
43 * \return TRUE if tile is totally clipped, FALSE otherwise
44 */
45 static inline boolean
u_clip_tile(uint x,uint y,uint * w,uint * h,const struct pipe_box * box)46 u_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_box *box)
47 {
48 if ((int) x >= box->width)
49 return TRUE;
50 if ((int) y >= box->height)
51 return TRUE;
52 if ((int) (x + *w) > box->width)
53 *w = box->width - x;
54 if ((int) (y + *h) > box->height)
55 *h = box->height - y;
56 return FALSE;
57 }
58
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62
63 void
64 pipe_get_tile_raw(struct pipe_transfer *pt,
65 const void *src,
66 uint x, uint y, uint w, uint h,
67 void *p, int dst_stride);
68
69 void
70 pipe_put_tile_raw(struct pipe_transfer *pt,
71 void *dst,
72 uint x, uint y, uint w, uint h,
73 const void *p, int src_stride);
74
75
76 void
77 pipe_get_tile_rgba(struct pipe_transfer *pt,
78 const void *src,
79 uint x, uint y, uint w, uint h,
80 float *p);
81
82 void
83 pipe_get_tile_rgba_format(struct pipe_transfer *pt,
84 const void *src,
85 uint x, uint y, uint w, uint h,
86 enum pipe_format format,
87 float *p);
88
89 void
90 pipe_put_tile_rgba(struct pipe_transfer *pt,
91 void *dst,
92 uint x, uint y, uint w, uint h,
93 const float *p);
94
95 void
96 pipe_put_tile_rgba_format(struct pipe_transfer *pt,
97 void *dst,
98 uint x, uint y, uint w, uint h,
99 enum pipe_format format,
100 const float *p);
101
102
103 void
104 pipe_get_tile_z(struct pipe_transfer *pt,
105 const void *src,
106 uint x, uint y, uint w, uint h,
107 uint *z);
108
109 void
110 pipe_put_tile_z(struct pipe_transfer *pt,
111 void *dst,
112 uint x, uint y, uint w, uint h,
113 const uint *z);
114
115 void
116 pipe_tile_raw_to_rgba(enum pipe_format format,
117 const void *src,
118 uint w, uint h,
119 float *dst, unsigned dst_stride);
120
121 void
122 pipe_tile_raw_to_unsigned(enum pipe_format format,
123 const void *src,
124 uint w, uint h,
125 unsigned *dst, unsigned dst_stride);
126
127 void
128 pipe_tile_raw_to_signed(enum pipe_format format,
129 void *src,
130 uint w, uint h,
131 int *dst, unsigned dst_stride);
132
133 void
134 pipe_get_tile_ui_format(struct pipe_transfer *pt,
135 const void *src,
136 uint x, uint y, uint w, uint h,
137 enum pipe_format format,
138 unsigned int *p);
139
140 void
141 pipe_get_tile_i_format(struct pipe_transfer *pt,
142 const void *src,
143 uint x, uint y, uint w, uint h,
144 enum pipe_format format,
145 int *p);
146
147 void
148 pipe_put_tile_ui_format(struct pipe_transfer *pt,
149 void *dst,
150 uint x, uint y, uint w, uint h,
151 enum pipe_format format,
152 const unsigned *p);
153
154 void
155 pipe_put_tile_i_format(struct pipe_transfer *pt,
156 void *dst,
157 uint x, uint y, uint w, uint h,
158 enum pipe_format format,
159 const int *p);
160
161 #ifdef __cplusplus
162 }
163 #endif
164
165 #endif
166