rsProgramRaster.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (C) 2009-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_RASTER_H
  17. #define ANDROID_RS_PROGRAM_RASTER_H
  18. #include "rsProgramBase.h"
  19. #include <vector>
  20. // ---------------------------------------------------------------------------
  21. namespace android {
  22. namespace renderscript {
  23. class ProgramRasterState;
  24. /*****************************************************************************
  25. * CAUTION
  26. *
  27. * Any layout changes for this class may require a corresponding change to be
  28. * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
  29. * a partial copy of the information below.
  30. *
  31. *****************************************************************************/
  32. class ProgramRaster : public ProgramBase {
  33. public:
  34. struct Hal {
  35. mutable void *drv;
  36. struct State {
  37. bool pointSprite;
  38. RsCullMode cull;
  39. };
  40. State state;
  41. };
  42. Hal mHal;
  43. virtual void setup(const Context *, ProgramRasterState *);
  44. virtual void serialize(Context *rsc, OStream *stream) const;
  45. virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_RASTER; }
  46. static ProgramRaster *createFromStream(Context *rsc, IStream *stream);
  47. static ObjectBaseRef<ProgramRaster> getProgramRaster(Context *rsc,
  48. bool pointSprite,
  49. RsCullMode cull);
  50. protected:
  51. virtual void preDestroy() const;
  52. virtual ~ProgramRaster();
  53. private:
  54. ProgramRaster(Context *rsc,
  55. bool pointSprite,
  56. RsCullMode cull);
  57. };
  58. class ProgramRasterState {
  59. public:
  60. ProgramRasterState();
  61. ~ProgramRasterState();
  62. void init(Context *rsc);
  63. void deinit(Context *rsc);
  64. ObjectBaseRef<ProgramRaster> mDefault;
  65. ObjectBaseRef<ProgramRaster> mLast;
  66. // Cache of all existing raster programs.
  67. std::vector<ProgramRaster *> mRasterPrograms;
  68. };
  69. } // namespace renderscript
  70. } // namespace android
  71. #endif