MonitoredProducer.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2014 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_MONITORED_PRODUCER_H
  17. #define ANDROID_MONITORED_PRODUCER_H
  18. #include <gui/IGraphicBufferProducer.h>
  19. namespace android {
  20. class IProducerListener;
  21. class NativeHandle;
  22. class SurfaceFlinger;
  23. // MonitoredProducer wraps an IGraphicBufferProducer so that SurfaceFlinger will
  24. // be notified upon its destruction
  25. class MonitoredProducer : public IGraphicBufferProducer {
  26. public:
  27. MonitoredProducer(const sp<IGraphicBufferProducer>& producer,
  28. const sp<SurfaceFlinger>& flinger);
  29. virtual ~MonitoredProducer();
  30. // From IGraphicBufferProducer
  31. virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
  32. virtual status_t setBufferCount(int bufferCount);
  33. virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async,
  34. uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
  35. virtual status_t detachBuffer(int slot);
  36. virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
  37. sp<Fence>* outFence);
  38. virtual status_t attachBuffer(int* outSlot,
  39. const sp<GraphicBuffer>& buffer);
  40. virtual status_t queueBuffer(int slot, const QueueBufferInput& input,
  41. QueueBufferOutput* output);
  42. virtual void cancelBuffer(int slot, const sp<Fence>& fence);
  43. virtual int query(int what, int* value);
  44. virtual status_t connect(const sp<IProducerListener>& token, int api,
  45. bool producerControlledByApp, QueueBufferOutput* output);
  46. virtual status_t disconnect(int api);
  47. virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
  48. virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
  49. PixelFormat format, uint32_t usage);
  50. virtual status_t allowAllocation(bool allow);
  51. virtual status_t setGenerationNumber(uint32_t generationNumber);
  52. virtual String8 getConsumerName() const override;
  53. virtual IBinder* onAsBinder();
  54. private:
  55. sp<IGraphicBufferProducer> mProducer;
  56. sp<SurfaceFlinger> mFlinger;
  57. };
  58. }; // namespace android
  59. #endif // ANDROID_MONITORED_PRODUCER_H