| 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 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 31 | class Layer; | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 32 | class SurfaceFlinger; | 
|  | 33 |  | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 34 | class Client : public BnSurfaceComposerClient | 
|  | 35 | { | 
|  | 36 | public: | 
| Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 37 | explicit Client(const sp<SurfaceFlinger>& flinger); | 
| Robert Carr | 6fb1a7e | 2018-12-11 12:07:25 -0800 | [diff] [blame] | 38 | ~Client() = default; | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 39 |  | 
|  | 40 | status_t initCheck() const; | 
|  | 41 |  | 
|  | 42 | // protected by SurfaceFlinger::mStateLock | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 43 | void attachLayer(const sp<IBinder>& handle, const sp<Layer>& layer); | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 44 | void detachLayer(const Layer* layer); | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 45 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 46 | sp<Layer> getLayerUser(const sp<IBinder>& handle) const; | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 47 |  | 
|  | 48 | private: | 
|  | 49 | // ISurfaceComposerClient interface | 
| Evan Rosky | 1f6d6d5 | 2018-12-06 10:47:26 -0800 | [diff] [blame] | 50 | virtual status_t createSurface(const String8& name, uint32_t w, uint32_t h, PixelFormat format, | 
|  | 51 | uint32_t flags, const sp<IBinder>& parent, | 
|  | 52 | LayerMetadata metadata, sp<IBinder>* handle, | 
| Ady Abraham | 9f0a400 | 2020-10-05 15:47:26 -0700 | [diff] [blame] | 53 | sp<IGraphicBufferProducer>* gbp, int32_t* outLayerId, | 
| Valerie Hau | 1acd696 | 2019-10-28 16:35:48 -0700 | [diff] [blame] | 54 | uint32_t* outTransformHint = nullptr); | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 55 |  | 
| Marissa Wall | 35187b3 | 2019-01-08 10:08:52 -0800 | [diff] [blame] | 56 | virtual status_t createWithSurfaceParent(const String8& name, uint32_t w, uint32_t h, | 
|  | 57 | PixelFormat format, uint32_t flags, | 
|  | 58 | const sp<IGraphicBufferProducer>& parent, | 
| Evan Rosky | 1f6d6d5 | 2018-12-06 10:47:26 -0800 | [diff] [blame] | 59 | LayerMetadata metadata, sp<IBinder>* handle, | 
| Ady Abraham | 9f0a400 | 2020-10-05 15:47:26 -0700 | [diff] [blame] | 60 | sp<IGraphicBufferProducer>* gbp, int32_t* outLayerId, | 
| Valerie Hau | 1acd696 | 2019-10-28 16:35:48 -0700 | [diff] [blame] | 61 | uint32_t* outTransformHint = nullptr); | 
| Marissa Wall | 35187b3 | 2019-01-08 10:08:52 -0800 | [diff] [blame] | 62 |  | 
| Pablo Gamito | 2ec1f7b | 2020-09-01 14:18:49 +0000 | [diff] [blame] | 63 | status_t mirrorSurface(const sp<IBinder>& mirrorFromHandle, sp<IBinder>* handle, | 
| Ady Abraham | 9f0a400 | 2020-10-05 15:47:26 -0700 | [diff] [blame] | 64 | int32_t* outLayerId); | 
| chaviw | fe94a22 | 2019-08-21 13:52:59 -0700 | [diff] [blame] | 65 |  | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 66 | virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const; | 
|  | 67 |  | 
|  | 68 | virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const; | 
|  | 69 |  | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 70 | // constant | 
|  | 71 | sp<SurfaceFlinger> mFlinger; | 
|  | 72 |  | 
|  | 73 | // protected by mLock | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 74 | DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayers; | 
| Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 75 |  | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 76 | // thread-safe | 
|  | 77 | mutable Mutex mLock; | 
|  | 78 | }; | 
|  | 79 |  | 
| Mathias Agopian | db403e8 | 2012-06-18 16:47:56 -0700 | [diff] [blame] | 80 | }; // namespace android | 
|  | 81 |  | 
|  | 82 | #endif // ANDROID_SF_CLIENT_H |