rs_allocation.rsh revision 044e2ee36ffe6520570a7f0207d75a8fce8b8e91
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/** @file rs_allocation.rsh
18 *  \brief Allocation routines
19 *
20 *
21 */
22
23#ifndef __RS_ALLOCATION_RSH__
24#define __RS_ALLOCATION_RSH__
25
26/**
27 * Returns the Allocation for a given pointer.  The pointer should point within
28 * a valid allocation.  The results are undefined if the pointer is not from a
29 * valid allocation.
30 */
31extern rs_allocation __attribute__((overloadable))
32    rsGetAllocation(const void *);
33
34/**
35 * Query the dimension of an allocation.
36 *
37 * @return uint32_t The X dimension of the allocation.
38 */
39extern uint32_t __attribute__((overloadable))
40    rsAllocationGetDimX(rs_allocation);
41
42/**
43 * Query the dimension of an allocation.
44 *
45 * @return uint32_t The Y dimension of the allocation.
46 */
47extern uint32_t __attribute__((overloadable))
48    rsAllocationGetDimY(rs_allocation);
49
50/**
51 * Query the dimension of an allocation.
52 *
53 * @return uint32_t The Z dimension of the allocation.
54 */
55extern uint32_t __attribute__((overloadable))
56    rsAllocationGetDimZ(rs_allocation);
57
58/**
59 * Query an allocation for the presence of more than one LOD.
60 *
61 * @return uint32_t Returns 1 if more than one LOD is present, 0 otherwise.
62 */
63extern uint32_t __attribute__((overloadable))
64    rsAllocationGetDimLOD(rs_allocation);
65
66/**
67 * Query an allocation for the presence of more than one face.
68 *
69 * @return uint32_t Returns 1 if more than one face is present, 0 otherwise.
70 */
71extern uint32_t __attribute__((overloadable))
72    rsAllocationGetDimFaces(rs_allocation);
73
74/**
75 * Copy part of an allocation from another allocation.
76 *
77 * @param dstAlloc Allocation to copy data into.
78 * @param dstOff The offset of the first element to be copied in
79 *               the destination allocation.
80 * @param dstMip Mip level in the destination allocation.
81 * @param count The number of elements to be copied.
82 * @param srcAlloc The source data allocation.
83 * @param srcOff The offset of the first element in data to be
84 *               copied in the source allocation.
85 * @param srcMip Mip level in the source allocation.
86 */
87extern void __attribute__((overloadable))
88    rsAllocationCopy1DRange(rs_allocation dstAlloc,
89                            uint32_t dstOff, uint32_t dstMip,
90                            uint32_t count,
91                            rs_allocation srcAlloc,
92                            uint32_t srcOff, uint32_t srcMip);
93
94/**
95 * Copy a rectangular region into the allocation from another
96 * allocation.
97 *
98 * @param dstAlloc allocation to copy data into.
99 * @param dstXoff X offset of the region to update in the
100 *                destination allocation.
101 * @param dstYoff Y offset of the region to update in the
102 *                destination allocation.
103 * @param dstMip Mip level in the destination allocation.
104 * @param dstFace Cubemap face of the destination allocation,
105 *                ignored for allocations that aren't cubemaps.
106 * @param width Width of the incoming region to update.
107 * @param height Height of the incoming region to update.
108 * @param srcAlloc The source data allocation.
109 * @param srcXoff X offset in data of the source allocation.
110 * @param srcYoff Y offset in data of the source allocation.
111 * @param srcMip Mip level in the source allocation.
112 * @param srcFace Cubemap face of the source allocation,
113 *                ignored for allocations that aren't cubemaps.
114 */
115extern void __attribute__((overloadable))
116    rsAllocationCopy2DRange(rs_allocation dstAlloc,
117                            uint32_t dstXoff, uint32_t dstYoff,
118                            uint32_t dstMip,
119                            rs_allocation_cubemap_face dstFace,
120                            uint32_t width, uint32_t height,
121                            rs_allocation srcAlloc,
122                            uint32_t srcXoff, uint32_t srcYoff,
123                            uint32_t srcMip,
124                            rs_allocation_cubemap_face srcFace);
125
126
127/**
128 * Extract a single element from an allocation.
129 */
130extern const void * __attribute__((overloadable))
131    rsGetElementAt(rs_allocation, uint32_t x);
132/**
133 * \overload
134 */
135extern const void * __attribute__((overloadable))
136    rsGetElementAt(rs_allocation, uint32_t x, uint32_t y);
137/**
138 * \overload
139 */
140extern const void * __attribute__((overloadable))
141    rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
142
143#endif
144
145