blob: d0051dee1a9f4a96af950325dc917338b2e34422 [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
31// ---------------------------------------------------------------------------
32
Mathias Agopian13127d82013-03-06 01:47:1133class Layer;
Mathias Agopiandb403e82012-06-18 23:47:5634class SurfaceFlinger;
35
36// ---------------------------------------------------------------------------
37
38class Client : public BnSurfaceComposerClient
39{
40public:
Robert Carr1db73f62016-12-21 20:58:5141 explicit Client(const sp<SurfaceFlinger>& flinger);
Robert Carr6fb1a7e2018-12-11 20:07:2542 ~Client() = default;
Mathias Agopiandb403e82012-06-18 23:47:5643
44 status_t initCheck() const;
45
46 // protected by SurfaceFlinger::mStateLock
Mathias Agopian13127d82013-03-06 01:47:1147 void attachLayer(const sp<IBinder>& handle, const sp<Layer>& layer);
Mathias Agopian13127d82013-03-06 01:47:1148 void detachLayer(const Layer* layer);
Mathias Agopiandb403e82012-06-18 23:47:5649
Mathias Agopian13127d82013-03-06 01:47:1150 sp<Layer> getLayerUser(const sp<IBinder>& handle) const;
Mathias Agopiandb403e82012-06-18 23:47:5651
52private:
53 // ISurfaceComposerClient interface
Mathias Agopian4d9b8222013-03-13 00:11:4854 virtual status_t createSurface(
Mathias Agopianac9fa422013-02-12 00:40:3655 const String8& name,
Mathias Agopian4d9b8222013-03-13 00:11:4856 uint32_t w, uint32_t h,PixelFormat format, uint32_t flags,
rongliuccd34842018-03-14 19:26:2357 const sp<IBinder>& parent, int32_t windowType, int32_t ownerUid,
Mathias Agopian4d9b8222013-03-13 00:11:4858 sp<IBinder>* handle,
59 sp<IGraphicBufferProducer>* gbp);
Mathias Agopiandb403e82012-06-18 23:47:5660
Svetoslavd85084b2014-03-20 17:28:3161 virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const;
62
63 virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const;
64
Mathias Agopiandb403e82012-06-18 23:47:5665 // constant
66 sp<SurfaceFlinger> mFlinger;
67
68 // protected by mLock
Mathias Agopian13127d82013-03-06 01:47:1169 DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayers;
Robert Carr1db73f62016-12-21 20:58:5170
Mathias Agopiandb403e82012-06-18 23:47:5671 // thread-safe
72 mutable Mutex mLock;
73};
74
75// ---------------------------------------------------------------------------
76}; // namespace android
77
78#endif // ANDROID_SF_CLIENT_H