Home | History | Annotate | Download | only in rs
      1 /*
      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 
     19 namespace android {
     20 namespace renderscript {
     21 
     22 extern "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 
     35 extern "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 }
     47 
     48 } // namespace renderscript
     49 } // namespace android
     50