Client.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (C) 2012 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_CLIENT_H
  17. #define ANDROID_SF_CLIENT_H
  18. #include <stdint.h>
  19. #include <sys/types.h>
  20. #include <utils/Errors.h>
  21. #include <utils/KeyedVector.h>
  22. #include <utils/Mutex.h>
  23. #include <gui/ISurfaceComposerClient.h>
  24. namespace android {
  25. // ---------------------------------------------------------------------------
  26. class Layer;
  27. class SurfaceFlinger;
  28. // ---------------------------------------------------------------------------
  29. class Client : public BnSurfaceComposerClient
  30. {
  31. public:
  32. explicit Client(const sp<SurfaceFlinger>& flinger);
  33. ~Client() = default;
  34. status_t initCheck() const;
  35. // protected by SurfaceFlinger::mStateLock
  36. void attachLayer(const sp<IBinder>& handle, const sp<Layer>& layer);
  37. void detachLayer(const Layer* layer);
  38. sp<Layer> getLayerUser(const sp<IBinder>& handle) const;
  39. private:
  40. // ISurfaceComposerClient interface
  41. virtual status_t createSurface(const String8& name, uint32_t w, uint32_t h, PixelFormat format,
  42. uint32_t flags, const sp<IBinder>& parent,
  43. LayerMetadata metadata, sp<IBinder>* handle,
  44. sp<IGraphicBufferProducer>* gbp);
  45. virtual status_t createSurfaceX(const String8& name, const String8& systemname, uint32_t w, uint32_t h, PixelFormat format,
  46. uint32_t flags, const sp<IBinder>& parent,
  47. LayerMetadata metadata, sp<IBinder>* handle,
  48. sp<IGraphicBufferProducer>* gbp);
  49. virtual status_t createWithSurfaceParent(const String8& name, uint32_t w, uint32_t h,
  50. PixelFormat format, uint32_t flags,
  51. const sp<IGraphicBufferProducer>& parent,
  52. LayerMetadata metadata, sp<IBinder>* handle,
  53. sp<IGraphicBufferProducer>* gbp);
  54. virtual status_t createWithSurfaceParentX(const String8& name, const String8& systemname, uint32_t w, uint32_t h,
  55. PixelFormat format, uint32_t flags,
  56. const sp<IGraphicBufferProducer>& parent,
  57. LayerMetadata metadata, sp<IBinder>* handle,
  58. sp<IGraphicBufferProducer>* gbp);
  59. virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const;
  60. virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const;
  61. // constant
  62. sp<SurfaceFlinger> mFlinger;
  63. // protected by mLock
  64. DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayers;
  65. // thread-safe
  66. mutable Mutex mLock;
  67. };
  68. // ---------------------------------------------------------------------------
  69. }; // namespace android
  70. #endif // ANDROID_SF_CLIENT_H