FramebufferSurface.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 ANDROID_SF_FRAMEBUFFER_SURFACE_H
  17. #define ANDROID_SF_FRAMEBUFFER_SURFACE_H
  18. #include <stdint.h>
  19. #include <sys/types.h>
  20. #include <gui/ConsumerBase.h>
  21. #include "DisplaySurface.h"
  22. // ---------------------------------------------------------------------------
  23. namespace android {
  24. // ---------------------------------------------------------------------------
  25. class Rect;
  26. class String8;
  27. class HWComposer;
  28. // ---------------------------------------------------------------------------
  29. class FramebufferSurface : public ConsumerBase,
  30. public DisplaySurface {
  31. public:
  32. FramebufferSurface(HWComposer& hwc, int disp, const sp<IGraphicBufferConsumer>& consumer);
  33. virtual status_t beginFrame(bool mustRecompose);
  34. virtual status_t prepareFrame(CompositionType compositionType);
  35. virtual status_t compositionComplete();
  36. virtual status_t advanceFrame();
  37. virtual void onFrameCommitted();
  38. virtual void dumpAsString(String8& result) const;
  39. // Cannot resize a buffers in a FramebufferSurface. Only works with virtual
  40. // displays.
  41. virtual void resizeBuffers(const uint32_t /*w*/, const uint32_t /*h*/) { };
  42. private:
  43. virtual ~FramebufferSurface() { }; // this class cannot be overloaded
  44. virtual void onFrameAvailable(const BufferItem& item);
  45. virtual void freeBufferLocked(int slotIndex);
  46. virtual void dumpLocked(String8& result, const char* prefix) const;
  47. // nextBuffer waits for and then latches the next buffer from the
  48. // BufferQueue and releases the previously latched buffer to the
  49. // BufferQueue. The new buffer is returned in the 'buffer' argument.
  50. status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence);
  51. // mDisplayType must match one of the HWC display types
  52. int mDisplayType;
  53. // mCurrentBufferIndex is the slot index of the current buffer or
  54. // INVALID_BUFFER_SLOT to indicate that either there is no current buffer
  55. // or the buffer is not associated with a slot.
  56. int mCurrentBufferSlot;
  57. // mCurrentBuffer is the current buffer or NULL to indicate that there is
  58. // no current buffer.
  59. sp<GraphicBuffer> mCurrentBuffer;
  60. // Hardware composer, owned by SurfaceFlinger.
  61. HWComposer& mHwc;
  62. };
  63. // ---------------------------------------------------------------------------
  64. }; // namespace android
  65. // ---------------------------------------------------------------------------
  66. #endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H