blob: 154a09910e5af934bf0a66acf6f528b8d26c099d [file] [log] [blame]
Jason Sams044e2ee2011-08-08 16:52:30 -07001/*
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
Alex Sakhartchouk43253872011-09-28 15:23:18 -070074#if (defined(RS_VERSION) && (RS_VERSION >= 14))
75
Jason Sams044e2ee2011-08-08 16:52:30 -070076/**
77 * Copy part of an allocation from another allocation.
78 *
79 * @param dstAlloc Allocation to copy data into.
80 * @param dstOff The offset of the first element to be copied in
81 * the destination allocation.
82 * @param dstMip Mip level in the destination allocation.
83 * @param count The number of elements to be copied.
84 * @param srcAlloc The source data allocation.
85 * @param srcOff The offset of the first element in data to be
86 * copied in the source allocation.
87 * @param srcMip Mip level in the source allocation.
88 */
89extern void __attribute__((overloadable))
90 rsAllocationCopy1DRange(rs_allocation dstAlloc,
91 uint32_t dstOff, uint32_t dstMip,
92 uint32_t count,
93 rs_allocation srcAlloc,
94 uint32_t srcOff, uint32_t srcMip);
95
96/**
97 * Copy a rectangular region into the allocation from another
98 * allocation.
99 *
100 * @param dstAlloc allocation to copy data into.
101 * @param dstXoff X offset of the region to update in the
102 * destination allocation.
103 * @param dstYoff Y offset of the region to update in the
104 * destination allocation.
105 * @param dstMip Mip level in the destination allocation.
106 * @param dstFace Cubemap face of the destination allocation,
107 * ignored for allocations that aren't cubemaps.
108 * @param width Width of the incoming region to update.
109 * @param height Height of the incoming region to update.
110 * @param srcAlloc The source data allocation.
111 * @param srcXoff X offset in data of the source allocation.
112 * @param srcYoff Y offset in data of the source allocation.
113 * @param srcMip Mip level in the source allocation.
114 * @param srcFace Cubemap face of the source allocation,
115 * ignored for allocations that aren't cubemaps.
116 */
117extern void __attribute__((overloadable))
118 rsAllocationCopy2DRange(rs_allocation dstAlloc,
119 uint32_t dstXoff, uint32_t dstYoff,
120 uint32_t dstMip,
121 rs_allocation_cubemap_face dstFace,
122 uint32_t width, uint32_t height,
123 rs_allocation srcAlloc,
124 uint32_t srcXoff, uint32_t srcYoff,
125 uint32_t srcMip,
126 rs_allocation_cubemap_face srcFace);
127
Alex Sakhartchouk43253872011-09-28 15:23:18 -0700128#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
Jason Sams044e2ee2011-08-08 16:52:30 -0700129
130/**
131 * Extract a single element from an allocation.
132 */
133extern const void * __attribute__((overloadable))
134 rsGetElementAt(rs_allocation, uint32_t x);
135/**
136 * \overload
137 */
138extern const void * __attribute__((overloadable))
139 rsGetElementAt(rs_allocation, uint32_t x, uint32_t y);
140/**
141 * \overload
142 */
143extern const void * __attribute__((overloadable))
144 rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
145
146#endif
147