1 /**************************************************************************
3 * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #ifndef INTEL_REGIONS_H
29 #define INTEL_REGIONS_H
32 #include "bufmgr.h" /* for DBG! */
35 /* A layer on top of the bufmgr buffers that adds a few useful things:
37 * - Refcounting for local buffer references.
38 * - Refcounting for buffer maps
39 * - Buffer dimensions - pitch and height.
40 * - Blitter commands for copying 2D regions between buffers.
43 struct buffer
*buffer
;
53 /* Allocate a refcounted region. Pointers to regions should only be
54 * copied by calling intel_reference_region().
56 * No support for dynamically allocating tiled regions at this point.
58 struct intel_region
*intel_region_alloc( struct intel_context
*intel
,
63 void intel_region_reference( struct intel_region
**dst
,
64 struct intel_region
*src
);
66 void intel_region_release(struct intel_context
*intel
,
67 struct intel_region
**ib
);
69 /* Static regions may be tiled. The assumption is that the X server
70 * has set up fence registers to define tiled zones in agp and these
71 * buffers are within those zones. Tiling regions without fence
72 * registers is more work.
74 struct intel_region
*intel_region_create_static( struct intel_context
*intel
,
84 /* Map/unmap regions. This is refcounted also:
86 GLubyte
*intel_region_map(struct intel_context
*intel
,
87 struct intel_region
*ib
);
89 void intel_region_unmap(struct intel_context
*intel
,
90 struct intel_region
*ib
);
93 /* Upload data to a rectangular sub-region
95 GLboolean
intel_region_data(struct intel_context
*intel
,
96 struct intel_region
*dest
,
98 GLuint destx
, GLuint desty
,
99 const void *src
, GLuint src_stride
,
100 GLuint srcx
, GLuint srcy
,
101 GLuint width
, GLuint height
);
103 /* Copy rectangular sub-regions
105 void intel_region_copy( struct intel_context
*intel
,
106 struct intel_region
*dest
,
108 GLuint destx
, GLuint desty
,
109 struct intel_region
*src
,
111 GLuint srcx
, GLuint srcy
,
112 GLuint width
, GLuint height
);
114 /* Fill a rectangular sub-region
116 void intel_region_fill( struct intel_context
*intel
,
117 struct intel_region
*dest
,
119 GLuint destx
, GLuint desty
,
120 GLuint width
, GLuint height
,
124 /***********************************************************************
125 * Misc utilities: move to somewhere generic
127 void _mesa_copy_rect( GLubyte
*dst
,