rsProgramStore.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C) 2011 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_STORE_H
  17. #define ANDROID_RS_PROGRAM_FRAGMENT_STORE_H
  18. #include "rsProgramBase.h"
  19. #include "rsStream.h"
  20. #include <vector>
  21. // ---------------------------------------------------------------------------
  22. namespace android {
  23. namespace renderscript {
  24. class ProgramStoreState;
  25. /*****************************************************************************
  26. * CAUTION
  27. *
  28. * Any layout changes for this class may require a corresponding change to be
  29. * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
  30. * a partial copy of the information below.
  31. *
  32. *****************************************************************************/
  33. class ProgramStore : public ProgramBase {
  34. public:
  35. struct Hal {
  36. mutable void *drv;
  37. struct State {
  38. bool ditherEnable;
  39. //bool blendEnable;
  40. bool colorRWriteEnable;
  41. bool colorGWriteEnable;
  42. bool colorBWriteEnable;
  43. bool colorAWriteEnable;
  44. RsBlendSrcFunc blendSrc;
  45. RsBlendDstFunc blendDst;
  46. //bool depthTestEnable;
  47. bool depthWriteEnable;
  48. RsDepthFunc depthFunc;
  49. };
  50. State state;
  51. };
  52. Hal mHal;
  53. virtual void setup(const Context *, ProgramStoreState *);
  54. virtual void serialize(Context *rsc, OStream *stream) const;
  55. virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; }
  56. static ProgramStore *createFromStream(Context *rsc, IStream *stream);
  57. static ObjectBaseRef<ProgramStore> getProgramStore(Context *,
  58. bool colorMaskR, bool colorMaskG,
  59. bool colorMaskB, bool colorMaskA,
  60. bool depthMask, bool ditherEnable,
  61. RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
  62. RsDepthFunc depthFunc);
  63. void init();
  64. protected:
  65. virtual void preDestroy() const;
  66. virtual ~ProgramStore();
  67. private:
  68. ProgramStore(Context *,
  69. bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA,
  70. bool depthMask, bool ditherEnable,
  71. RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
  72. RsDepthFunc depthFunc);
  73. };
  74. class ProgramStoreState {
  75. public:
  76. ProgramStoreState();
  77. ~ProgramStoreState();
  78. void init(Context *rsc);
  79. void deinit(Context *rsc);
  80. ObjectBaseRef<ProgramStore> mDefault;
  81. ObjectBaseRef<ProgramStore> mLast;
  82. // Cache of all existing store programs.
  83. std::vector<ProgramStore *> mStorePrograms;
  84. };
  85. } // namespace renderscript
  86. } // namespace android
  87. #endif