blob: e9063e5bb618f865650deed02ee99a2275a199d4 [file] [log] [blame]
Mathias Agopiandb403e82012-06-18 16:47:56 -07001/*
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
31// ---------------------------------------------------------------------------
32
Mathias Agopian13127d82013-03-05 17:47:11 -080033class Layer;
Mathias Agopiandb403e82012-06-18 16:47:56 -070034class SurfaceFlinger;
35
36// ---------------------------------------------------------------------------
37
38class Client : public BnSurfaceComposerClient
39{
40public:
Robert Carr1db73f62016-12-21 12:58:51 -080041 explicit Client(const sp<SurfaceFlinger>& flinger);
Robert Carr6fb1a7e2018-12-11 12:07:25 -080042 ~Client() = default;
Mathias Agopiandb403e82012-06-18 16:47:56 -070043
44 status_t initCheck() const;
45
46 // protected by SurfaceFlinger::mStateLock
Mathias Agopian13127d82013-03-05 17:47:11 -080047 void attachLayer(const sp<IBinder>& handle, const sp<Layer>& layer);
Mathias Agopian13127d82013-03-05 17:47:11 -080048 void detachLayer(const Layer* layer);
Mathias Agopiandb403e82012-06-18 16:47:56 -070049
Mathias Agopian13127d82013-03-05 17:47:11 -080050 sp<Layer> getLayerUser(const sp<IBinder>& handle) const;
Mathias Agopiandb403e82012-06-18 16:47:56 -070051
52private:
53 // ISurfaceComposerClient interface
Evan Rosky1f6d6d52018-12-06 10:47:26 -080054 virtual status_t createSurface(const String8& name, uint32_t w, uint32_t h, PixelFormat format,
55 uint32_t flags, const sp<IBinder>& parent,
56 LayerMetadata metadata, sp<IBinder>* handle,
Valerie Hau1acd6962019-10-28 16:35:48 -070057 sp<IGraphicBufferProducer>* gbp,
58 uint32_t* outTransformHint = nullptr);
Mathias Agopiandb403e82012-06-18 16:47:56 -070059
Marissa Wall35187b32019-01-08 10:08:52 -080060 virtual status_t createWithSurfaceParent(const String8& name, uint32_t w, uint32_t h,
61 PixelFormat format, uint32_t flags,
62 const sp<IGraphicBufferProducer>& parent,
Evan Rosky1f6d6d52018-12-06 10:47:26 -080063 LayerMetadata metadata, sp<IBinder>* handle,
Valerie Hau1acd6962019-10-28 16:35:48 -070064 sp<IGraphicBufferProducer>* gbp,
65 uint32_t* outTransformHint = nullptr);
Marissa Wall35187b32019-01-08 10:08:52 -080066
chaviwfe94a222019-08-21 13:52:59 -070067 status_t mirrorSurface(const sp<IBinder>& mirrorFromHandle, sp<IBinder>* handle);
68
Svetoslavd85084b2014-03-20 10:28:31 -070069 virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const;
70
71 virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const;
72
Mathias Agopiandb403e82012-06-18 16:47:56 -070073 // constant
74 sp<SurfaceFlinger> mFlinger;
75
76 // protected by mLock
Mathias Agopian13127d82013-03-05 17:47:11 -080077 DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayers;
Robert Carr1db73f62016-12-21 12:58:51 -080078
Mathias Agopiandb403e82012-06-18 16:47:56 -070079 // thread-safe
80 mutable Mutex mLock;
81};
82
83// ---------------------------------------------------------------------------
84}; // namespace android
85
86#endif // ANDROID_SF_CLIENT_H