rsFBOCache.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_FRAME_BUFFER_OBJECT_CACHE_H
  17. #define ANDROID_FRAME_BUFFER_OBJECT_CACHE_H
  18. #include "rsObjectBase.h"
  19. // ---------------------------------------------------------------------------
  20. namespace android {
  21. namespace renderscript {
  22. class Allocation;
  23. class FBOCache {
  24. public:
  25. FBOCache();
  26. ~FBOCache();
  27. void init(Context *rsc);
  28. void deinit(Context *rsc);
  29. void bindColorTarget(Context *rsc, Allocation *a, uint32_t slot);
  30. void bindDepthTarget(Context *, Allocation *a);
  31. void resetAll(Context *);
  32. void setup(Context *);
  33. void updateSize() { mDirty = true; }
  34. struct Hal {
  35. mutable void *drv;
  36. struct State {
  37. Allocation **colorTargets;
  38. uint32_t colorTargetsCount;
  39. Allocation *depthTarget;
  40. };
  41. State state;
  42. };
  43. Hal mHal;
  44. protected:
  45. ObjectBaseRef<Allocation> *mColorTargets;
  46. ObjectBaseRef<Allocation> mDepthTarget;
  47. bool mDirty;
  48. void checkError(Context *);
  49. void setColorAttachment(Context *rsc);
  50. void setDepthAttachment(Context *rsc);
  51. bool renderToFramebuffer();
  52. };
  53. } // namespace renderscript
  54. } // namespace android
  55. #endif //ANDROID_FRAME_BUFFER_OBJECT_CACHE_H