Client.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. Client(const sp<SurfaceFlinger>& flinger);
  33. ~Client();
  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(
  42. const String8& name,
  43. uint32_t w, uint32_t h,PixelFormat format, uint32_t flags,
  44. sp<IBinder>* handle,
  45. sp<IGraphicBufferProducer>* gbp);
  46. virtual status_t destroySurface(const sp<IBinder>& handle);
  47. virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const;
  48. virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const;
  49. virtual status_t onTransact(
  50. uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
  51. // constant
  52. sp<SurfaceFlinger> mFlinger;
  53. // protected by mLock
  54. DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayers;
  55. // thread-safe
  56. mutable Mutex mLock;
  57. };
  58. // ---------------------------------------------------------------------------
  59. }; // namespace android
  60. #endif // ANDROID_SF_CLIENT_H