rsComponent.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_COMPONENT_H
  17. #define ANDROID_COMPONENT_H
  18. #include "rsUtils.h"
  19. #include "rsDefines.h"
  20. #include "rsStream.h"
  21. // ---------------------------------------------------------------------------
  22. namespace android {
  23. namespace renderscript {
  24. // An element is a group of Components that occupies one cell in a structure.
  25. class Component {
  26. public:
  27. Component();
  28. ~Component();
  29. void set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize=1);
  30. void dumpLOGV(const char *prefix) const;
  31. RsDataType getType() const {return mType;}
  32. RsDataKind getKind() const {return mKind;}
  33. bool getIsNormalized() const {return mNormalized;}
  34. uint32_t getVectorSize() const {return mVectorSize;}
  35. bool getIsFloat() const {return mIsFloat;}
  36. bool getIsSigned() const {return mIsSigned;}
  37. uint32_t getBits() const {return mBits;}
  38. uint32_t getBitsUnpadded() const {return mBitsUnpadded;}
  39. // Helpers for reading / writing this class out
  40. void serialize(OStream *stream) const;
  41. void loadFromStream(IStream *stream);
  42. bool isReference() const;
  43. protected:
  44. RsDataType mType;
  45. RsDataKind mKind;
  46. bool mNormalized;
  47. uint32_t mVectorSize;
  48. // derived
  49. uint32_t mBits;
  50. uint32_t mBitsUnpadded;
  51. uint32_t mTypeBits;
  52. bool mIsFloat;
  53. bool mIsSigned;
  54. bool mIsPixel;
  55. };
  56. } // namespace renderscript
  57. } // namespace android
  58. #endif