blob: 39c91cdcda63a72a3150e9869853b96405baf116 [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -07001/*
Jason Samsbc0ca6b2013-02-15 18:13:43 -08002 * Copyright (C) 2013 The Android Open Source Project
Jason Sams326e0dd2009-05-22 14:03:28 -07003 *
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#include "rsContext.h"
18
Stephen Hines10f31702013-08-15 17:30:12 -070019#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
Jason Samsbc0ca6b2013-02-15 18:13:43 -080020#include "system/graphics.h"
Tim Murray0b575de2013-03-15 15:56:43 -070021#endif
Jason Samsbc0ca6b2013-02-15 18:13:43 -080022
Stephen Hines10f31702013-08-15 17:30:12 -070023#ifdef RS_COMPATIBILITY_LIB
24#include "rsCompatibilityLib.h"
25#endif
26
Jason Sams326e0dd2009-05-22 14:03:28 -070027using namespace android;
28using namespace android::renderscript;
29
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080030Type::Type(Context *rsc) : ObjectBase(rsc) {
Alex Sakhartchouk246fbee2012-03-08 14:52:36 -080031 memset(&mHal, 0, sizeof(mHal));
32 mDimLOD = false;
Jason Sams326e0dd2009-05-22 14:03:28 -070033}
34
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070035void Type::preDestroy() const {
Chris Wailes93d6bc82014-07-28 16:54:38 -070036 auto &types = mRSC->mStateType.mTypes;
37
38 for (auto typeIter = types.begin(), endIter = types.end();
39 typeIter != endIter; typeIter++) {
40
41 if (this == *typeIter) {
42 types.erase(typeIter);
43 return;
Jason Sams81549542010-02-17 15:38:10 -080044 }
45 }
Jason Sams225afd32010-10-21 14:06:55 -070046}
47
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080048Type::~Type() {
Alex Sakhartchouk246fbee2012-03-08 14:52:36 -080049 clear();
Jason Sams326e0dd2009-05-22 14:03:28 -070050}
51
Tim Murray49a87772014-07-10 10:00:00 -070052void Type::operator delete(void* ptr) {
53 if (ptr) {
54 Type *t = (Type*) ptr;
55 t->getContext()->mHal.funcs.freeRuntimeMem(ptr);
56 }
57}
58
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080059void Type::clear() {
Alex Sakhartchouk246fbee2012-03-08 14:52:36 -080060 if (mHal.state.lodCount) {
61 delete [] mHal.state.lodDimX;
62 delete [] mHal.state.lodDimY;
63 delete [] mHal.state.lodDimZ;
Jason Sams326e0dd2009-05-22 14:03:28 -070064 }
Jason Samsc7968a02014-11-11 16:24:36 -080065 if (mHal.state.arrayCount > 0) {
66 delete [] mHal.state.arrays;
67 }
Jason Sams326e0dd2009-05-22 14:03:28 -070068 mElement.clear();
Alex Sakhartchouk50bfc352011-12-20 12:37:59 -080069 memset(&mHal, 0, sizeof(mHal));
Jason Sams326e0dd2009-05-22 14:03:28 -070070}
71
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080072TypeState::TypeState() {
Jason Sams326e0dd2009-05-22 14:03:28 -070073}
74
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080075TypeState::~TypeState() {
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070076 rsAssert(!mTypes.size());
Jason Sams326e0dd2009-05-22 14:03:28 -070077}
78
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080079void Type::compute() {
Alex Sakhartchouk246fbee2012-03-08 14:52:36 -080080 uint32_t oldLODCount = mHal.state.lodCount;
81 if (mDimLOD) {
Alex Sakhartchouk50bfc352011-12-20 12:37:59 -080082 uint32_t l2x = rsFindHighBit(mHal.state.dimX) + 1;
83 uint32_t l2y = rsFindHighBit(mHal.state.dimY) + 1;
84 uint32_t l2z = rsFindHighBit(mHal.state.dimZ) + 1;
Jason Sams326e0dd2009-05-22 14:03:28 -070085
Alex Sakhartchouk246fbee2012-03-08 14:52:36 -080086 mHal.state.lodCount = rsMax(l2x, l2y);
87 mHal.state.lodCount = rsMax(mHal.state.lodCount, l2z);
Jason Sams326e0dd2009-05-22 14:03:28 -070088 } else {
Jason Samsd06653c2014-08-01 16:18:33 -070089 if (mHal.state.dimYuv) {
90 mHal.state.lodCount = 3;
91 } else {
92 mHal.state.lodCount = 1;
93 }
Jason Sams326e0dd2009-05-22 14:03:28 -070094 }
Alex Sakhartchouk246fbee2012-03-08 14:52:36 -080095 if (mHal.state.lodCount != oldLODCount) {
96 if (oldLODCount) {
97 delete [] mHal.state.lodDimX;
98 delete [] mHal.state.lodDimY;
99 delete [] mHal.state.lodDimZ;
Alex Sakhartchouk417e6a42010-07-15 11:33:03 -0700100 }
Alex Sakhartchouk246fbee2012-03-08 14:52:36 -0800101 mHal.state.lodDimX = new uint32_t[mHal.state.lodCount];
102 mHal.state.lodDimY = new uint32_t[mHal.state.lodCount];
103 mHal.state.lodDimZ = new uint32_t[mHal.state.lodCount];
Jason Sams326e0dd2009-05-22 14:03:28 -0700104 }
105
Alex Sakhartchouk50bfc352011-12-20 12:37:59 -0800106 uint32_t tx = mHal.state.dimX;
107 uint32_t ty = mHal.state.dimY;
108 uint32_t tz = mHal.state.dimZ;
Jason Sams61656a72013-09-03 16:21:18 -0700109 mCellCount = 0;
Jason Samsd06653c2014-08-01 16:18:33 -0700110 if (!mHal.state.dimYuv) {
111 for (uint32_t lod=0; lod < mHal.state.lodCount; lod++) {
112 mHal.state.lodDimX[lod] = tx;
113 mHal.state.lodDimY[lod] = ty;
114 mHal.state.lodDimZ[lod] = tz;
115 mCellCount += tx * rsMax(ty, 1u) * rsMax(tz, 1u);
116 if (tx > 1) tx >>= 1;
117 if (ty > 1) ty >>= 1;
118 if (tz > 1) tz >>= 1;
119 }
Jason Sams326e0dd2009-05-22 14:03:28 -0700120 }
121
Alex Sakhartchouk50bfc352011-12-20 12:37:59 -0800122 if (mHal.state.faces) {
Jason Sams61656a72013-09-03 16:21:18 -0700123 mCellCount *= 6;
Jason Sams326e0dd2009-05-22 14:03:28 -0700124 }
Tim Murray0b575de2013-03-15 15:56:43 -0700125#ifndef RS_SERVER
Jason Samsbc0ca6b2013-02-15 18:13:43 -0800126 // YUV only supports basic 2d
127 // so we can stash the plane pointers in the mipmap levels.
128 if (mHal.state.dimYuv) {
Jason Sams61656a72013-09-03 16:21:18 -0700129 mHal.state.lodDimX[1] = mHal.state.lodDimX[0] / 2;
130 mHal.state.lodDimY[1] = mHal.state.lodDimY[0] / 2;
131 mHal.state.lodDimX[2] = mHal.state.lodDimX[0] / 2;
132 mHal.state.lodDimY[2] = mHal.state.lodDimY[0] / 2;
Jason Samsd06653c2014-08-01 16:18:33 -0700133 mCellCount += mHal.state.lodDimX[0] * mHal.state.lodDimY[0];
Jason Sams61656a72013-09-03 16:21:18 -0700134 mCellCount += mHal.state.lodDimX[1] * mHal.state.lodDimY[1];
135 mCellCount += mHal.state.lodDimX[2] * mHal.state.lodDimY[2];
136
Jason Samsbc0ca6b2013-02-15 18:13:43 -0800137 switch(mHal.state.dimYuv) {
138 case HAL_PIXEL_FORMAT_YV12:
Jason Samsbc0ca6b2013-02-15 18:13:43 -0800139 break;
140 case HAL_PIXEL_FORMAT_YCrCb_420_SP: // NV21
Jason Samsbc0ca6b2013-02-15 18:13:43 -0800141 mHal.state.lodDimX[1] = mHal.state.lodDimX[0];
Jason Samsbc0ca6b2013-02-15 18:13:43 -0800142 break;
Jason Sams61656a72013-09-03 16:21:18 -0700143#ifndef RS_COMPATIBILITY_LIB
144 case HAL_PIXEL_FORMAT_YCbCr_420_888:
145 break;
146#endif
Jason Samsbc0ca6b2013-02-15 18:13:43 -0800147 default:
148 rsAssert(0);
149 }
150 }
Tim Murray0b575de2013-03-15 15:56:43 -0700151#endif
Alex Sakhartchouk50bfc352011-12-20 12:37:59 -0800152 mHal.state.element = mElement.get();
Jason Sams326e0dd2009-05-22 14:03:28 -0700153}
154
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800155void Type::dumpLOGV(const char *prefix) const {
Jason Samse12c1c52009-09-27 17:50:38 -0700156 char buf[1024];
157 ObjectBase::dumpLOGV(prefix);
Alex Sakhartchouk50bfc352011-12-20 12:37:59 -0800158 ALOGV("%s Type: x=%u y=%u z=%u mip=%i face=%i", prefix,
159 mHal.state.dimX,
160 mHal.state.dimY,
161 mHal.state.dimZ,
Alex Sakhartchouk246fbee2012-03-08 14:52:36 -0800162 mHal.state.lodCount,
Alex Sakhartchouk50bfc352011-12-20 12:37:59 -0800163 mHal.state.faces);
Jason Sams87319de2010-11-22 16:20:16 -0800164 snprintf(buf, sizeof(buf), "%s element: ", prefix);
Jason Samse12c1c52009-09-27 17:50:38 -0700165 mElement->dumpLOGV(buf);
166}
167
Jason Samse3150cf2012-07-24 18:10:20 -0700168void Type::serialize(Context *rsc, OStream *stream) const {
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -0700169 // Need to identify ourselves
170 stream->addU32((uint32_t)getClassId());
Jason Sams48ecf6a2013-07-09 15:35:29 -0700171 stream->addString(getName());
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -0700172
Jason Samse3150cf2012-07-24 18:10:20 -0700173 mElement->serialize(rsc, stream);
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -0700174
Alex Sakhartchouk50bfc352011-12-20 12:37:59 -0800175 stream->addU32(mHal.state.dimX);
176 stream->addU32(mHal.state.dimY);
177 stream->addU32(mHal.state.dimZ);
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -0700178
Alex Sakhartchouk246fbee2012-03-08 14:52:36 -0800179 stream->addU8((uint8_t)(mHal.state.lodCount ? 1 : 0));
Alex Sakhartchouk50bfc352011-12-20 12:37:59 -0800180 stream->addU8((uint8_t)(mHal.state.faces ? 1 : 0));
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -0700181}
182
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800183Type *Type::createFromStream(Context *rsc, IStream *stream) {
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -0700184 // First make sure we are reading the correct object
Alex Sakhartchoukb825f672010-06-04 10:06:50 -0700185 RsA3DClassID classID = (RsA3DClassID)stream->loadU32();
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800186 if (classID != RS_A3D_CLASS_ID_TYPE) {
Steve Blockaf12ac62012-01-06 19:20:56 +0000187 ALOGE("type loading skipped due to invalid class id\n");
Chris Wailes44bef6f2014-08-12 13:51:10 -0700188 return nullptr;
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -0700189 }
190
Jason Sams48ecf6a2013-07-09 15:35:29 -0700191 const char *name = stream->loadString();
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -0700192
193 Element *elem = Element::createFromStream(rsc, stream);
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800194 if (!elem) {
Chris Wailes44bef6f2014-08-12 13:51:10 -0700195 return nullptr;
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -0700196 }
197
Jason Samsc7968a02014-11-11 16:24:36 -0800198 RsTypeCreateParams p;
199 memset(&p, 0, sizeof(p));
200 p.dimX = stream->loadU32();
201 p.dimY = stream->loadU32();
202 p.dimZ = stream->loadU32();
203 p.mipmaps = stream->loadU8();
204 p.faces = stream->loadU8();
205 Type *type = Type::getType(rsc, elem, &p, sizeof(p));
Alex Sakhartchoukc700e642011-08-16 13:09:46 -0700206 elem->decUserRef();
Jason Sams48ecf6a2013-07-09 15:35:29 -0700207
208 delete [] name;
Alex Sakhartchoukc700e642011-08-16 13:09:46 -0700209 return type;
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -0700210}
211
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800212bool Type::getIsNp2() const {
Jason Samsef21edc2010-02-22 15:37:51 -0800213 uint32_t x = getDimX();
214 uint32_t y = getDimY();
215 uint32_t z = getDimZ();
216
217 if (x && (x & (x-1))) {
218 return true;
219 }
220 if (y && (y & (y-1))) {
221 return true;
222 }
223 if (z && (z & (z-1))) {
224 return true;
225 }
226 return false;
227}
228
Alex Sakhartchoukc700e642011-08-16 13:09:46 -0700229ObjectBaseRef<Type> Type::getTypeRef(Context *rsc, const Element *e,
Jason Samsc7968a02014-11-11 16:24:36 -0800230 const RsTypeCreateParams *params, size_t len) {
Alex Sakhartchoukc700e642011-08-16 13:09:46 -0700231 ObjectBaseRef<Type> returnRef;
Jason Samse12c1c52009-09-27 17:50:38 -0700232
Jason Sams96abf812010-10-05 13:32:49 -0700233 TypeState * stc = &rsc->mStateType;
Jason Samsf0c1df42010-10-26 13:09:17 -0700234
235 ObjectBase::asyncLock();
Jason Sams96abf812010-10-05 13:32:49 -0700236 for (uint32_t ct=0; ct < stc->mTypes.size(); ct++) {
237 Type *t = stc->mTypes[ct];
Jason Samsf0c1df42010-10-26 13:09:17 -0700238 if (t->getElement() != e) continue;
Jason Samsc7968a02014-11-11 16:24:36 -0800239 if (t->getDimX() != params->dimX) continue;
240 if (t->getDimY() != params->dimY) continue;
241 if (t->getDimZ() != params->dimZ) continue;
242 if (t->getDimLOD() != params->mipmaps) continue;
243 if (t->getDimFaces() != params->faces) continue;
244 if (t->getDimYuv() != params->yuv) continue;
245 if (t->getArray(0) != params->array0) continue;
246 if (t->getArray(1) != params->array1) continue;
247 if (t->getArray(2) != params->array2) continue;
248 if (t->getArray(3) != params->array3) continue;
Alex Sakhartchoukc700e642011-08-16 13:09:46 -0700249 returnRef.set(t);
Jason Samsf0c1df42010-10-26 13:09:17 -0700250 ObjectBase::asyncUnlock();
Alex Sakhartchoukc700e642011-08-16 13:09:46 -0700251 return returnRef;
Jason Sams96abf812010-10-05 13:32:49 -0700252 }
Jason Samsf0c1df42010-10-26 13:09:17 -0700253 ObjectBase::asyncUnlock();
254
Tim Murray665eafe2014-07-01 10:04:48 -0700255 // Type objects must use allocator specified by the driver
256 void* allocMem = rsc->mHal.funcs.allocRuntimeMem(sizeof(Type), 0);
257 if (!allocMem) {
258 rsc->setError(RS_ERROR_FATAL_DRIVER, "Couldn't allocate memory for Type");
Chris Wailes44bef6f2014-08-12 13:51:10 -0700259 return nullptr;
Tim Murray665eafe2014-07-01 10:04:48 -0700260 }
Jason Sams96abf812010-10-05 13:32:49 -0700261
Tim Murray665eafe2014-07-01 10:04:48 -0700262 Type *nt = new (allocMem) Type(rsc);
Tim Murraye3af53b2014-06-10 09:46:51 -0700263
264#ifdef RS_FIND_OFFSETS
265 ALOGE("pointer for type: %p", nt);
266 ALOGE("pointer for type.drv: %p", &nt->mHal.drv);
267#endif
268
Jason Samsc7968a02014-11-11 16:24:36 -0800269 nt->mDimLOD = params->mipmaps;
Alex Sakhartchoukc700e642011-08-16 13:09:46 -0700270 returnRef.set(nt);
Jason Samsf0c1df42010-10-26 13:09:17 -0700271 nt->mElement.set(e);
Jason Samsc7968a02014-11-11 16:24:36 -0800272 nt->mHal.state.dimX = params->dimX;
273 nt->mHal.state.dimY = params->dimY;
274 nt->mHal.state.dimZ = params->dimZ;
275 nt->mHal.state.faces = params->faces;
276 nt->mHal.state.dimYuv = params->yuv;
277
278 nt->mHal.state.arrayCount = 0;
279 if (params->array0 > 0) nt->mHal.state.arrayCount ++;
280 if (params->array1 > 0) nt->mHal.state.arrayCount ++;
281 if (params->array2 > 0) nt->mHal.state.arrayCount ++;
282 if (params->array3 > 0) nt->mHal.state.arrayCount ++;
283 if (nt->mHal.state.arrayCount > 0) {
284 nt->mHal.state.arrays = new uint32_t[nt->mHal.state.arrayCount];
285 if (params->array0 > 0) nt->mHal.state.arrays[0] = params->array0;
286 if (params->array1 > 1) nt->mHal.state.arrays[1] = params->array1;
287 if (params->array2 > 2) nt->mHal.state.arrays[2] = params->array2;
288 if (params->array3 > 3) nt->mHal.state.arrays[3] = params->array3;
289 }
290
Jason Sams96abf812010-10-05 13:32:49 -0700291 nt->compute();
Jason Samsf0c1df42010-10-26 13:09:17 -0700292
293 ObjectBase::asyncLock();
Chris Wailes93d6bc82014-07-28 16:54:38 -0700294 stc->mTypes.push_back(nt);
Jason Samsf0c1df42010-10-26 13:09:17 -0700295 ObjectBase::asyncUnlock();
296
Alex Sakhartchoukc700e642011-08-16 13:09:46 -0700297 return returnRef;
Jason Sams96abf812010-10-05 13:32:49 -0700298}
299
Alex Sakhartchoukc700e642011-08-16 13:09:46 -0700300ObjectBaseRef<Type> Type::cloneAndResize1D(Context *rsc, uint32_t dimX) const {
Jason Samsc7968a02014-11-11 16:24:36 -0800301 RsTypeCreateParams p;
302 memset(&p, 0, sizeof(p));
303 p.dimX = dimX;
304 p.dimY = getDimY();
305 p.dimZ = getDimZ();
306 p.mipmaps = getDimLOD();
307 return getTypeRef(rsc, mElement.get(), &p, sizeof(p));
Jason Samsf0c1df42010-10-26 13:09:17 -0700308}
309
Alex Sakhartchoukc700e642011-08-16 13:09:46 -0700310ObjectBaseRef<Type> Type::cloneAndResize2D(Context *rsc,
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800311 uint32_t dimX,
312 uint32_t dimY) const {
Jason Samsc7968a02014-11-11 16:24:36 -0800313 RsTypeCreateParams p;
314 memset(&p, 0, sizeof(p));
315 p.dimX = dimX;
316 p.dimY = dimY;
317 p.dimZ = getDimZ();
318 p.mipmaps = getDimLOD();
319 p.faces = getDimFaces();
320 p.yuv = getDimYuv();
321 return getTypeRef(rsc, mElement.get(), &p, sizeof(p));
Jason Sams96abf812010-10-05 13:32:49 -0700322}
323
324
Stephen Hines9f70a4e2012-04-02 20:18:48 -0700325void Type::incRefs(const void *ptr, size_t ct, size_t startOff) const {
326 const uint8_t *p = static_cast<const uint8_t *>(ptr);
327 const Element *e = mHal.state.element;
328 uint32_t stride = e->getSizeBytes();
329
330 p += stride * startOff;
331 while (ct > 0) {
332 e->incRefs(p);
333 ct--;
334 p += stride;
335 }
336}
337
338
339void Type::decRefs(const void *ptr, size_t ct, size_t startOff) const {
340 if (!mHal.state.element->getHasReferences()) {
341 return;
342 }
343 const uint8_t *p = static_cast<const uint8_t *>(ptr);
344 const Element *e = mHal.state.element;
345 uint32_t stride = e->getSizeBytes();
346
347 p += stride * startOff;
348 while (ct > 0) {
349 e->decRefs(p);
350 ct--;
351 p += stride;
352 }
353}
354
Jason Samsa36c50a2014-06-17 12:06:06 -0700355void Type::callUpdateCacheObject(const Context *rsc, void *dstObj) const {
Chris Wailes44bef6f2014-08-12 13:51:10 -0700356 if (rsc->mHal.funcs.type.updateCachedObject != nullptr) {
Jason Samsa36c50a2014-06-17 12:06:06 -0700357 rsc->mHal.funcs.type.updateCachedObject(rsc, this, (rs_type *)dstObj);
358 } else {
359 *((const void **)dstObj) = this;
360 }
361}
Stephen Hines9f70a4e2012-04-02 20:18:48 -0700362
Jason Sams326e0dd2009-05-22 14:03:28 -0700363//////////////////////////////////////////////////
Jason Samse5ffb872009-08-09 17:01:55 -0700364//
Jason Sams326e0dd2009-05-22 14:03:28 -0700365namespace android {
366namespace renderscript {
367
Jason Samsc975cf42011-04-28 18:26:48 -0700368RsType rsi_TypeCreate(Context *rsc, RsElement _e, uint32_t dimX,
Stephen Hines8f615d62013-12-20 12:23:32 -0800369 uint32_t dimY, uint32_t dimZ, bool mipmaps, bool faces, uint32_t yuv) {
Jason Sams2353ae32010-10-14 17:48:46 -0700370 Element *e = static_cast<Element *>(_e);
Jason Sams2353ae32010-10-14 17:48:46 -0700371
Jason Samsc7968a02014-11-11 16:24:36 -0800372 RsTypeCreateParams p;
373 memset(&p, 0, sizeof(p));
374 p.dimX = dimX;
375 p.dimY = dimY;
376 p.dimZ = dimZ;
377 p.mipmaps = mipmaps;
378 p.faces = faces;
379 p.yuv = yuv;
380 return Type::getType(rsc, e, &p, sizeof(p));
381}
382
Jason Sams554d08c2015-01-12 16:23:50 -0800383RsType rsi_TypeCreate2(Context *rsc, const RsTypeCreateParams *p, size_t len) {
Jason Samsc7968a02014-11-11 16:24:36 -0800384 Element *e = static_cast<Element *>(p->e);
385 return Type::getType(rsc, e, p, len);
Jason Sams2353ae32010-10-14 17:48:46 -0700386}
387
Jason Samsc975cf42011-04-28 18:26:48 -0700388}
389}
390
Tim Murrayc2ce7072013-07-17 18:38:53 -0700391extern "C" void rsaTypeGetNativeData(RsContext con, RsType type, uintptr_t *typeData, uint32_t typeDataSize) {
Alex Sakhartchoukdc763f32010-10-27 14:10:07 -0700392 rsAssert(typeDataSize == 6);
Alex Sakhartchouk50bfc352011-12-20 12:37:59 -0800393 // Pack the data in the follofing way mHal.state.dimX; mHal.state.dimY; mHal.state.dimZ;
Alex Sakhartchouk246fbee2012-03-08 14:52:36 -0800394 // mHal.state.lodCount; mHal.state.faces; mElement; into typeData
Alex Sakhartchoukdc763f32010-10-27 14:10:07 -0700395 Type *t = static_cast<Type *>(type);
396
397 (*typeData++) = t->getDimX();
398 (*typeData++) = t->getDimY();
399 (*typeData++) = t->getDimZ();
Alex Sakhartchouk246fbee2012-03-08 14:52:36 -0800400 (*typeData++) = t->getDimLOD() ? 1 : 0;
Alex Sakhartchoukdc763f32010-10-27 14:10:07 -0700401 (*typeData++) = t->getDimFaces() ? 1 : 0;
Tim Murray099bc262013-03-20 16:54:03 -0700402 (*typeData++) = (uintptr_t)t->getElement();
Alex Sakhartchoukdc763f32010-10-27 14:10:07 -0700403 t->getElement()->incUserRef();
404}