FramebufferNativeWindow.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (C) 2007 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 INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP
  17. #warning "FramebufferNativeWindow is deprecated"
  18. #endif
  19. #ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
  20. #define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
  21. #include <stdint.h>
  22. #include <sys/types.h>
  23. #include <EGL/egl.h>
  24. #include <utils/threads.h>
  25. #include <utils/String8.h>
  26. #include <ui/ANativeObjectBase.h>
  27. #include <ui/Rect.h>
  28. #define MIN_NUM_FRAME_BUFFERS 2
  29. #define MAX_NUM_FRAME_BUFFERS 3
  30. extern "C" EGLNativeWindowType android_createDisplaySurface(void);
  31. // ---------------------------------------------------------------------------
  32. namespace android {
  33. // ---------------------------------------------------------------------------
  34. class Surface;
  35. class NativeBuffer;
  36. // ---------------------------------------------------------------------------
  37. class FramebufferNativeWindow
  38. : public ANativeObjectBase<
  39. ANativeWindow,
  40. FramebufferNativeWindow,
  41. LightRefBase<FramebufferNativeWindow> >
  42. {
  43. public:
  44. FramebufferNativeWindow();
  45. framebuffer_device_t const * getDevice() const { return fbDev; }
  46. bool isUpdateOnDemand() const { return mUpdateOnDemand; }
  47. status_t setUpdateRectangle(const Rect& updateRect);
  48. status_t compositionComplete();
  49. void dump(String8& result);
  50. // for debugging only
  51. int getCurrentBufferIndex() const;
  52. private:
  53. friend class LightRefBase<FramebufferNativeWindow>;
  54. ~FramebufferNativeWindow(); // this class cannot be overloaded
  55. static int setSwapInterval(ANativeWindow* window, int interval);
  56. static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd);
  57. static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd);
  58. static int query(const ANativeWindow* window, int what, int* value);
  59. static int perform(ANativeWindow* window, int operation, ...);
  60. static int dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer);
  61. static int queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer);
  62. static int lockBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer);
  63. framebuffer_device_t* fbDev;
  64. alloc_device_t* grDev;
  65. sp<NativeBuffer> buffers[MAX_NUM_FRAME_BUFFERS];
  66. sp<NativeBuffer> front;
  67. mutable Mutex mutex;
  68. Condition mCondition;
  69. int32_t mNumBuffers;
  70. int32_t mNumFreeBuffers;
  71. int32_t mBufferHead;
  72. int32_t mCurrentBufferIndex;
  73. bool mUpdateOnDemand;
  74. };
  75. // ---------------------------------------------------------------------------
  76. }; // namespace android
  77. // ---------------------------------------------------------------------------
  78. #endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H