u_tile.h revision 90671fcdda52a83e2bbba581e985d25c6bff961e
1/**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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
35struct pipe_context;
36struct 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 */
45static INLINE boolean
46u_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_box *box)
47{
48   if (x >= box->width)
49      return TRUE;
50   if (y >= box->height)
51      return TRUE;
52   if (x + *w > box->width)
53      *w = box->width - x;
54   if (y + *h > box->height)
55      *h = box->height - y;
56   return FALSE;
57}
58
59#ifdef __cplusplus
60extern "C" {
61#endif
62
63void
64pipe_get_tile_raw(struct pipe_context *pipe,
65                  struct pipe_transfer *pt,
66                  uint x, uint y, uint w, uint h,
67                  void *p, int dst_stride);
68
69void
70pipe_put_tile_raw(struct pipe_context *pipe,
71                  struct pipe_transfer *pt,
72                  uint x, uint y, uint w, uint h,
73                  const void *p, int src_stride);
74
75
76void
77pipe_get_tile_rgba(struct pipe_context *pipe,
78                   struct pipe_transfer *pt,
79                   uint x, uint y, uint w, uint h,
80                   float *p);
81
82void
83pipe_get_tile_rgba_format(struct pipe_context *pipe,
84                          struct pipe_transfer *pt,
85                          uint x, uint y, uint w, uint h,
86                          enum pipe_format format,
87                          float *p);
88
89void
90pipe_put_tile_rgba(struct pipe_context *pipe,
91                   struct pipe_transfer *pt,
92                   uint x, uint y, uint w, uint h,
93                   const float *p);
94
95
96void
97pipe_get_tile_z(struct pipe_context *pipe,
98                struct pipe_transfer *pt,
99                uint x, uint y, uint w, uint h,
100                uint *z);
101
102void
103pipe_put_tile_z(struct pipe_context *pipe,
104                struct pipe_transfer *pt,
105                uint x, uint y, uint w, uint h,
106                const uint *z);
107
108void
109pipe_tile_raw_to_rgba(enum pipe_format format,
110                      void *src,
111                      uint w, uint h,
112                      float *dst, unsigned dst_stride);
113
114
115#ifdef __cplusplus
116}
117#endif
118
119#endif
120