rsApiMesh.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #include "rsMesh.h"
  18. using android::renderscript::Mesh;
  19. void rsaMeshGetVertexBufferCount(RsContext con, RsMesh mv, int32_t *numVtx) {
  20. Mesh *sm = static_cast<Mesh *>(mv);
  21. *numVtx = sm->mHal.state.vertexBuffersCount;
  22. }
  23. void rsaMeshGetIndexCount(RsContext con, RsMesh mv, int32_t *numIdx) {
  24. Mesh *sm = static_cast<Mesh *>(mv);
  25. *numIdx = sm->mHal.state.primitivesCount;
  26. }
  27. void rsaMeshGetVertices(RsContext con, RsMesh mv, RsAllocation *vtxData, uint32_t vtxDataCount) {
  28. Mesh *sm = static_cast<Mesh *>(mv);
  29. rsAssert(vtxDataCount == sm->mHal.state.vertexBuffersCount);
  30. for (uint32_t ct = 0; ct < vtxDataCount; ct ++) {
  31. vtxData[ct] = sm->mHal.state.vertexBuffers[ct];
  32. sm->mHal.state.vertexBuffers[ct]->incUserRef();
  33. }
  34. }
  35. void rsaMeshGetIndices(RsContext con, RsMesh mv, RsAllocation *va, uint32_t *primType, uint32_t idxDataCount) {
  36. Mesh *sm = static_cast<Mesh *>(mv);
  37. rsAssert(idxDataCount == sm->mHal.state.primitivesCount);
  38. for (uint32_t ct = 0; ct < idxDataCount; ct ++) {
  39. va[ct] = sm->mHal.state.indexBuffers[ct];
  40. primType[ct] = sm->mHal.state.primitives[ct];
  41. if (sm->mHal.state.indexBuffers[ct]) {
  42. sm->mHal.state.indexBuffers[ct]->incUserRef();
  43. }
  44. }
  45. }