| 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 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 33 | class Layer; | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 34 | class SurfaceFlinger; | 
|  | 35 |  | 
|  | 36 | // --------------------------------------------------------------------------- | 
|  | 37 |  | 
|  | 38 | class Client : public BnSurfaceComposerClient | 
|  | 39 | { | 
|  | 40 | public: | 
| Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 41 | explicit Client(const sp<SurfaceFlinger>& flinger); | 
|  | 42 | Client(const sp<SurfaceFlinger>& flinger, const sp<Layer>& parentLayer); | 
|  | 43 | ~Client(); | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 44 |  | 
|  | 45 | status_t initCheck() const; | 
|  | 46 |  | 
|  | 47 | // protected by SurfaceFlinger::mStateLock | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 48 | void attachLayer(const sp<IBinder>& handle, const sp<Layer>& layer); | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 49 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 50 | void detachLayer(const Layer* layer); | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 51 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 52 | sp<Layer> getLayerUser(const sp<IBinder>& handle) const; | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 53 |  | 
| Robert Carr | 94c7d3d | 2018-04-24 12:30:47 -0700 | [diff] [blame] | 54 | void updateParent(const sp<Layer>& parentLayer); | 
| Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 55 |  | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 56 | private: | 
|  | 57 | // ISurfaceComposerClient interface | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 58 | virtual status_t createSurface( | 
| Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 59 | const String8& name, | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 60 | uint32_t w, uint32_t h,PixelFormat format, uint32_t flags, | 
| rongliu | ccd3484 | 2018-03-14 12:26:23 -0700 | [diff] [blame] | 61 | const sp<IBinder>& parent, int32_t windowType, int32_t ownerUid, | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 62 | sp<IBinder>* handle, | 
|  | 63 | sp<IGraphicBufferProducer>* gbp); | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 64 |  | 
| Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 65 | virtual status_t destroySurface(const sp<IBinder>& handle); | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 66 |  | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 67 | virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const; | 
|  | 68 |  | 
|  | 69 | virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const; | 
|  | 70 |  | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 71 | virtual status_t onTransact( | 
|  | 72 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags); | 
|  | 73 |  | 
| Chia-I Wu | f456f32 | 2017-06-15 14:01:18 -0700 | [diff] [blame] | 74 | sp<Layer> getParentLayer(bool* outParentDied = nullptr) const; | 
|  | 75 |  | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 76 | // constant | 
|  | 77 | sp<SurfaceFlinger> mFlinger; | 
|  | 78 |  | 
|  | 79 | // protected by mLock | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 80 | DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayers; | 
| Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 81 | wp<Layer> mParentLayer; | 
|  | 82 |  | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 83 | // thread-safe | 
|  | 84 | mutable Mutex mLock; | 
|  | 85 | }; | 
|  | 86 |  | 
|  | 87 | // --------------------------------------------------------------------------- | 
|  | 88 | }; // namespace android | 
|  | 89 |  | 
|  | 90 | #endif // ANDROID_SF_CLIENT_H |