rsScriptC.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C) 2009-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. #ifndef ANDROID_RS_SCRIPT_C_H
  17. #define ANDROID_RS_SCRIPT_C_H
  18. #include "rsEnv.h"
  19. #include "rsScript.h"
  20. // ---------------------------------------------------------------------------
  21. namespace android {
  22. namespace renderscript {
  23. /** This class represents a script compiled from an .rs file. */
  24. class ScriptC : public Script {
  25. public:
  26. typedef int (*RunScript_t)();
  27. typedef void (*VoidFunc_t)();
  28. explicit ScriptC(Context *);
  29. virtual ~ScriptC();
  30. void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) override;
  31. virtual uint32_t run(Context *);
  32. void runForEach(Context *rsc,
  33. uint32_t slot,
  34. const Allocation ** ains,
  35. size_t inLen,
  36. Allocation * aout,
  37. const void * usr,
  38. size_t usrBytes,
  39. const RsScriptCall *sc = nullptr) override;
  40. void runReduce(Context *rsc, uint32_t slot,
  41. const Allocation ** ains, size_t inLen,
  42. Allocation *aout, const RsScriptCall *sc) override;
  43. virtual void serialize(Context *rsc, OStream *stream) const { }
  44. virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; }
  45. static Type *createFromStream(Context *rsc, IStream *stream) { return nullptr; }
  46. bool runCompiler(Context *rsc, const char *resName, const char *cacheDir,
  47. const uint8_t *bitcode, size_t bitcodeLen);
  48. //protected:
  49. void setupScript(Context *);
  50. void setupGLState(Context *);
  51. #if !defined(RS_COMPATIBILITY_LIB)
  52. static bool createCacheDir(const char *cacheDir);
  53. #endif
  54. };
  55. } // namespace renderscript
  56. } // namespace android
  57. #endif