rsApiElement.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #include "rsContext.h"
  17. namespace android {
  18. namespace renderscript {
  19. extern "C" void rsaElementGetNativeData(RsContext con, RsElement elem,
  20. uint32_t *elemData, uint32_t elemDataSize) {
  21. rsAssert(elemDataSize == 5);
  22. // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
  23. Element *e = static_cast<Element *>(elem);
  24. (*elemData++) = (uint32_t)e->getType();
  25. (*elemData++) = (uint32_t)e->getKind();
  26. (*elemData++) = e->getComponent().getIsNormalized() ? 1 : 0;
  27. (*elemData++) = e->getComponent().getVectorSize();
  28. (*elemData++) = e->getFieldCount();
  29. }
  30. extern "C" void rsaElementGetSubElements(RsContext con, RsElement elem, uintptr_t *ids,
  31. const char **names, size_t *arraySizes, uint32_t dataSize) {
  32. Element *e = static_cast<Element *>(elem);
  33. rsAssert(e->getFieldCount() == dataSize);
  34. for (uint32_t i = 0; i < dataSize; i ++) {
  35. e->getField(i)->incUserRef();
  36. ids[i] = (uintptr_t)e->getField(i);
  37. names[i] = e->getFieldName(i);
  38. arraySizes[i] = e->getFieldArraySize(i);
  39. }
  40. }
  41. } // namespace renderscript
  42. } // namespace android