blob: 15cd763822e1a2c0b2ac6aeab9d57850d73fe11f [file] [log] [blame]
Mathias Agopiandb403e82012-06-18 23:47:561/*
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
29namespace android {
30
Mathias Agopian13127d82013-03-06 01:47:1131class Layer;
Mathias Agopiandb403e82012-06-18 23:47:5632class SurfaceFlinger;
33
Mathias Agopiandb403e82012-06-18 23:47:5634class Client : public BnSurfaceComposerClient
35{
36public:
Robert Carr1db73f62016-12-21 20:58:5137 explicit Client(const sp<SurfaceFlinger>& flinger);
Robert Carr6fb1a7e2018-12-11 20:07:2538 ~Client() = default;
Mathias Agopiandb403e82012-06-18 23:47:5639
40 status_t initCheck() const;
41
42 // protected by SurfaceFlinger::mStateLock
Mathias Agopian13127d82013-03-06 01:47:1143 void attachLayer(const sp<IBinder>& handle, const sp<Layer>& layer);
Mathias Agopian13127d82013-03-06 01:47:1144 void detachLayer(const Layer* layer);
Mathias Agopiandb403e82012-06-18 23:47:5645
Mathias Agopian13127d82013-03-06 01:47:1146 sp<Layer> getLayerUser(const sp<IBinder>& handle) const;
Mathias Agopiandb403e82012-06-18 23:47:5647
48private:
49 // ISurfaceComposerClient interface
Evan Rosky1f6d6d52018-12-06 18:47:2650 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 Abraham9f0a4002020-10-05 22:47:2653 sp<IGraphicBufferProducer>* gbp, int32_t* outLayerId,
Valerie Hau1acd6962019-10-28 23:35:4854 uint32_t* outTransformHint = nullptr);
Mathias Agopiandb403e82012-06-18 23:47:5655
Marissa Wall35187b32019-01-08 18:08:5256 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 Rosky1f6d6d52018-12-06 18:47:2659 LayerMetadata metadata, sp<IBinder>* handle,
Ady Abraham9f0a4002020-10-05 22:47:2660 sp<IGraphicBufferProducer>* gbp, int32_t* outLayerId,
Valerie Hau1acd6962019-10-28 23:35:4861 uint32_t* outTransformHint = nullptr);
Marissa Wall35187b32019-01-08 18:08:5262
Pablo Gamito2ec1f7b2020-09-01 14:18:4963 status_t mirrorSurface(const sp<IBinder>& mirrorFromHandle, sp<IBinder>* handle,
Ady Abraham9f0a4002020-10-05 22:47:2664 int32_t* outLayerId);
chaviwfe94a222019-08-21 20:52:5965
Svetoslavd85084b2014-03-20 17:28:3166 virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const;
67
68 virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const;
69
Mathias Agopiandb403e82012-06-18 23:47:5670 // constant
71 sp<SurfaceFlinger> mFlinger;
72
73 // protected by mLock
Mathias Agopian13127d82013-03-06 01:47:1174 DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayers;
Robert Carr1db73f62016-12-21 20:58:5175
Mathias Agopiandb403e82012-06-18 23:47:5676 // thread-safe
77 mutable Mutex mLock;
78};
79
Mathias Agopiandb403e82012-06-18 23:47:5680}; // namespace android
81
82#endif // ANDROID_SF_CLIENT_H