blob: b5f98b8a6f6f7a4025fdf0d2eba4440554edbacc [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);
42 Client(const sp<SurfaceFlinger>& flinger, const sp<Layer>& parentLayer);
43 ~Client();
Mathias Agopiandb403e82012-06-18 16:47:56 -070044
45 status_t initCheck() const;
46
47 // protected by SurfaceFlinger::mStateLock
Mathias Agopian13127d82013-03-05 17:47:11 -080048 void attachLayer(const sp<IBinder>& handle, const sp<Layer>& layer);
Mathias Agopiandb403e82012-06-18 16:47:56 -070049
Mathias Agopian13127d82013-03-05 17:47:11 -080050 void detachLayer(const Layer* layer);
Mathias Agopiandb403e82012-06-18 16:47:56 -070051
Mathias Agopian13127d82013-03-05 17:47:11 -080052 sp<Layer> getLayerUser(const sp<IBinder>& handle) const;
Mathias Agopiandb403e82012-06-18 16:47:56 -070053
Robert Carr1db73f62016-12-21 12:58:51 -080054 void setParentLayer(const sp<Layer>& parentLayer);
55
Mathias Agopiandb403e82012-06-18 16:47:56 -070056private:
57 // ISurfaceComposerClient interface
Mathias Agopian4d9b8222013-03-12 17:11:48 -070058 virtual status_t createSurface(
Mathias Agopianac9fa422013-02-11 16:40:36 -080059 const String8& name,
Mathias Agopian4d9b8222013-03-12 17:11:48 -070060 uint32_t w, uint32_t h,PixelFormat format, uint32_t flags,
Albert Chaulk479c60c2017-01-27 14:21:34 -050061 const sp<IBinder>& parent, uint32_t windowType, uint32_t ownerUid,
Mathias Agopian4d9b8222013-03-12 17:11:48 -070062 sp<IBinder>* handle,
63 sp<IGraphicBufferProducer>* gbp);
Mathias Agopiandb403e82012-06-18 16:47:56 -070064
Mathias Agopianac9fa422013-02-11 16:40:36 -080065 virtual status_t destroySurface(const sp<IBinder>& handle);
Mathias Agopiandb403e82012-06-18 16:47:56 -070066
Svetoslavd85084b2014-03-20 10:28:31 -070067 virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const;
68
69 virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const;
70
Mathias Agopiandb403e82012-06-18 16:47:56 -070071 virtual status_t onTransact(
72 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
73
74 // constant
75 sp<SurfaceFlinger> mFlinger;
76
77 // protected by mLock
Mathias Agopian13127d82013-03-05 17:47:11 -080078 DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayers;
Mathias Agopiandb403e82012-06-18 16:47:56 -070079
Robert Carr1db73f62016-12-21 12:58:51 -080080 wp<Layer> mParentLayer;
81
Mathias Agopiandb403e82012-06-18 16:47:56 -070082 // thread-safe
83 mutable Mutex mLock;
84};
85
86// ---------------------------------------------------------------------------
87}; // namespace android
88
89#endif // ANDROID_SF_CLIENT_H