rsProgramFragment.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2009 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_PROGRAM_FRAGMENT_H
  17. #define ANDROID_RS_PROGRAM_FRAGMENT_H
  18. #include "rsProgram.h"
  19. // ---------------------------------------------------------------------------
  20. namespace android {
  21. namespace renderscript {
  22. class ProgramFragmentState;
  23. class ProgramFragment : public Program {
  24. public:
  25. ProgramFragment(Context *rsc, const char * shaderText, size_t shaderLength,
  26. const char** textureNames, size_t textureNamesCount, const size_t *textureNamesLength,
  27. const uintptr_t * params, size_t paramLength);
  28. virtual ~ProgramFragment();
  29. virtual void setup(Context *, ProgramFragmentState *);
  30. virtual void serialize(Context *rsc, OStream *stream) const;
  31. virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_FRAGMENT; }
  32. static ProgramFragment *createFromStream(Context *rsc, IStream *stream);
  33. void setConstantColor(Context *, float, float, float, float);
  34. protected:
  35. float mConstantColor[4];
  36. int32_t mTextureUniformIndexStart;
  37. };
  38. class ProgramFragmentState {
  39. public:
  40. ProgramFragmentState();
  41. ~ProgramFragmentState();
  42. ProgramFragment *mPF;
  43. void init(Context *rsc);
  44. void deinit(Context *rsc);
  45. ObjectBaseRef<ProgramFragment> mDefault;
  46. std::vector<ProgramFragment *> mPrograms;
  47. ObjectBaseRef<ProgramFragment> mLast;
  48. };
  49. } // namespace renderscript
  50. } // namespace android
  51. #endif