Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 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 | |
| 17 | #ifndef ANDROID_SF_CLIENT_H |
| 18 | #define ANDROID_SF_CLIENT_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | #include <utils/Errors.h> |
| 24 | #include <utils/KeyedVector.h> |
| 25 | #include <utils/Mutex.h> |
| 26 | |
| 27 | #include <gui/ISurfaceComposerClient.h> |
| 28 | |
| 29 | namespace android { |
| 30 | |
| 31 | // --------------------------------------------------------------------------- |
| 32 | |
| 33 | class LayerBaseClient; |
| 34 | class SurfaceFlinger; |
| 35 | |
| 36 | // --------------------------------------------------------------------------- |
| 37 | |
| 38 | class Client : public BnSurfaceComposerClient |
| 39 | { |
| 40 | public: |
| 41 | Client(const sp<SurfaceFlinger>& flinger); |
| 42 | ~Client(); |
| 43 | |
| 44 | status_t initCheck() const; |
| 45 | |
| 46 | // protected by SurfaceFlinger::mStateLock |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame^] | 47 | void attachLayer(const sp<IBinder>& handle, const sp<LayerBaseClient>& layer); |
Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 48 | |
| 49 | void detachLayer(const LayerBaseClient* layer); |
| 50 | |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame^] | 51 | sp<LayerBaseClient> getLayerUser(const sp<IBinder>& handle) const; |
Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 52 | |
| 53 | private: |
| 54 | // ISurfaceComposerClient interface |
| 55 | virtual sp<ISurface> createSurface( |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame^] | 56 | const String8& name, |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 57 | uint32_t w, uint32_t h,PixelFormat format, |
Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 58 | uint32_t flags); |
| 59 | |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame^] | 60 | virtual status_t destroySurface(const sp<IBinder>& handle); |
Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 61 | |
| 62 | virtual status_t onTransact( |
| 63 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags); |
| 64 | |
| 65 | // constant |
| 66 | sp<SurfaceFlinger> mFlinger; |
| 67 | |
| 68 | // protected by mLock |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame^] | 69 | DefaultKeyedVector< wp<IBinder>, wp<LayerBaseClient> > mLayers; |
Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 70 | |
| 71 | // thread-safe |
| 72 | mutable Mutex mLock; |
| 73 | }; |
| 74 | |
| 75 | // --------------------------------------------------------------------------- |
| 76 | }; // namespace android |
| 77 | |
| 78 | #endif // ANDROID_SF_CLIENT_H |