DisplaySurface.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright 2013 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_DISPLAY_SURFACE_H
  17. #define ANDROID_SF_DISPLAY_SURFACE_H
  18. #include <utils/Errors.h>
  19. #include <utils/RefBase.h>
  20. #include <utils/StrongPointer.h>
  21. // ---------------------------------------------------------------------------
  22. namespace android {
  23. // ---------------------------------------------------------------------------
  24. class IGraphicBufferProducer;
  25. class String8;
  26. class DisplaySurface : public virtual RefBase {
  27. public:
  28. // beginFrame is called at the beginning of the composition loop, before
  29. // the configuration is known. The DisplaySurface should do anything it
  30. // needs to do to enable HWComposer to decide how to compose the frame.
  31. // We pass in mustRecompose so we can keep VirtualDisplaySurface's state
  32. // machine happy without actually queueing a buffer if nothing has changed.
  33. virtual status_t beginFrame(bool mustRecompose) = 0;
  34. // prepareFrame is called after the composition configuration is known but
  35. // before composition takes place. The DisplaySurface can use the
  36. // composition type to decide how to manage the flow of buffers between
  37. // GLES and HWC for this frame.
  38. enum CompositionType {
  39. COMPOSITION_UNKNOWN = 0,
  40. COMPOSITION_GLES = 1,
  41. COMPOSITION_HWC = 2,
  42. COMPOSITION_MIXED = COMPOSITION_GLES | COMPOSITION_HWC
  43. };
  44. virtual status_t prepareFrame(CompositionType compositionType) = 0;
  45. // Should be called when composition rendering is complete for a frame (but
  46. // eglSwapBuffers hasn't necessarily been called). Required by certain
  47. // older drivers for synchronization.
  48. // TODO: Remove this when we drop support for HWC 1.0.
  49. virtual status_t compositionComplete() = 0;
  50. // Inform the surface that GLES composition is complete for this frame, and
  51. // the surface should make sure that HWComposer has the correct buffer for
  52. // this frame. Some implementations may only push a new buffer to
  53. // HWComposer if GLES composition took place, others need to push a new
  54. // buffer on every frame.
  55. //
  56. // advanceFrame must be followed by a call to onFrameCommitted before
  57. // advanceFrame may be called again.
  58. virtual status_t advanceFrame() = 0;
  59. // onFrameCommitted is called after the frame has been committed to the
  60. // hardware composer. The surface collects the release fence for this
  61. // frame's buffer.
  62. virtual void onFrameCommitted() = 0;
  63. virtual void dumpAsString(String8& result) const = 0;
  64. virtual void resizeBuffers(const uint32_t w, const uint32_t h) = 0;
  65. protected:
  66. DisplaySurface() {}
  67. virtual ~DisplaySurface() {}
  68. };
  69. // ---------------------------------------------------------------------------
  70. } // namespace android
  71. // ---------------------------------------------------------------------------
  72. #endif // ANDROID_SF_DISPLAY_SURFACE_H