d042a6018ac225c1dffb4008c33994dbd0dfb4eb
[mesa.git] / src / gallium / auxiliary / util / u_tile.h
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
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 void
103 pipe_get_tile_ui_format(struct pipe_transfer *pt,
104 const void *src,
105 uint x, uint y, uint w, uint h,
106 enum pipe_format format,
107 unsigned int *p);
108
109 void
110 pipe_get_tile_i_format(struct pipe_transfer *pt,
111 const void *src,
112 uint x, uint y, uint w, uint h,
113 enum pipe_format format,
114 int *p);
115
116 void
117 pipe_put_tile_ui_format(struct pipe_transfer *pt,
118 void *dst,
119 uint x, uint y, uint w, uint h,
120 enum pipe_format format,
121 const unsigned *p);
122
123 void
124 pipe_put_tile_i_format(struct pipe_transfer *pt,
125 void *dst,
126 uint x, uint y, uint w, uint h,
127 enum pipe_format format,
128 const int *p);
129
130 #ifdef __cplusplus
131 }
132 #endif
133
134 #endif