rsScriptIntrinsic.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (C) 2012 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 "rsScriptIntrinsic.h"
  18. #include <time.h>
  19. namespace android {
  20. namespace renderscript {
  21. ScriptIntrinsic::ScriptIntrinsic(Context *rsc) : Script(rsc) {
  22. mIntrinsicID = 0;
  23. }
  24. ScriptIntrinsic::~ScriptIntrinsic() {
  25. if (mIntrinsicID != 0) {
  26. mRSC->mHal.funcs.script.destroy(mRSC, this);
  27. }
  28. }
  29. bool ScriptIntrinsic::init(Context *rsc, RsScriptIntrinsicID iid, Element *e) {
  30. mIntrinsicID = iid;
  31. mElement.set(e);
  32. mSlots = new ObjectBaseRef<Allocation>[2];
  33. mTypes = new ObjectBaseRef<const Type>[2];
  34. rsc->mHal.funcs.script.initIntrinsic(rsc, this, iid, e);
  35. return true;
  36. }
  37. bool ScriptIntrinsic::freeChildren() {
  38. return false;
  39. }
  40. void ScriptIntrinsic::setupScript(Context *rsc) {
  41. }
  42. uint32_t ScriptIntrinsic::run(Context *rsc) {
  43. rsAssert(!"ScriptIntrinsic::run - should not happen");
  44. return 0;
  45. }
  46. void ScriptIntrinsic::runForEach(Context* rsc,
  47. uint32_t slot,
  48. const Allocation** ains,
  49. size_t inLen,
  50. Allocation* aout,
  51. const void* usr,
  52. size_t usrBytes,
  53. const RsScriptCall* sc) {
  54. rsc->mHal.funcs.script.invokeForEachMulti(rsc, this, slot, ains, inLen,
  55. aout, usr, usrBytes, sc);
  56. }
  57. void ScriptIntrinsic::runReduce(Context *rsc, uint32_t slot,
  58. const Allocation ** ains, size_t inLen,
  59. Allocation *aout, const RsScriptCall *sc) {
  60. }
  61. void ScriptIntrinsic::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) {
  62. }
  63. void ScriptIntrinsic::serialize(Context *rsc, OStream *stream) const {
  64. }
  65. RsA3DClassID ScriptIntrinsic::getClassId() const {
  66. return (RsA3DClassID)0;
  67. }
  68. RsScript rsi_ScriptIntrinsicCreate(Context *rsc, uint32_t id, RsElement ve) {
  69. ScriptIntrinsic *si = new ScriptIntrinsic(rsc);
  70. if (!si->init(rsc, (RsScriptIntrinsicID)id, (Element *)ve)) {
  71. delete si;
  72. return nullptr;
  73. }
  74. si->incUserRef();
  75. return si;
  76. }
  77. } // namespace renderscript
  78. } // namespace android