blob: 5d1e57f83429d9ae05f8c1152b7757ce80447b49 [file] [log] [blame]
Yang Ni85d0cb12016-03-18 15:33:52 -07001/*
2 * Copyright (C) 2016 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#include "rsContext.h"
18
Chih-Hung Hsieh11496ac2016-11-15 15:14:05 -080019namespace android {
20namespace renderscript {
Yang Ni85d0cb12016-03-18 15:33:52 -070021
22extern "C" void rsaElementGetNativeData(RsContext con, RsElement elem,
23 uint32_t *elemData, uint32_t elemDataSize) {
24 rsAssert(elemDataSize == 5);
25 // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
26 Element *e = static_cast<Element *>(elem);
27
28 (*elemData++) = (uint32_t)e->getType();
29 (*elemData++) = (uint32_t)e->getKind();
30 (*elemData++) = e->getComponent().getIsNormalized() ? 1 : 0;
31 (*elemData++) = e->getComponent().getVectorSize();
32 (*elemData++) = e->getFieldCount();
33}
34
35extern "C" void rsaElementGetSubElements(RsContext con, RsElement elem, uintptr_t *ids,
36 const char **names, size_t *arraySizes, uint32_t dataSize) {
37 Element *e = static_cast<Element *>(elem);
38 rsAssert(e->getFieldCount() == dataSize);
39
40 for (uint32_t i = 0; i < dataSize; i ++) {
41 e->getField(i)->incUserRef();
42 ids[i] = (uintptr_t)e->getField(i);
43 names[i] = e->getFieldName(i);
44 arraySizes[i] = e->getFieldArraySize(i);
45 }
46}
Chih-Hung Hsieh11496ac2016-11-15 15:14:05 -080047
48} // namespace renderscript
49} // namespace android