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 <android/gui/BnSurfaceComposerClient.h>
28 
29 namespace android {
30 
31 class Layer;
32 class SurfaceFlinger;
33 
34 class Client : public gui::BnSurfaceComposerClient {
35 public:
36     explicit Client(const sp<SurfaceFlinger>& flinger);
37     ~Client() = default;
38 
39     status_t initCheck() const;
40 
41 private:
42     // ISurfaceComposerClient interface
43 
44     binder::Status createSurface(const std::string& name, int32_t flags, const sp<IBinder>& parent,
45                                  const gui::LayerMetadata& metadata,
46                                  gui::CreateSurfaceResult* outResult) override;
47 
48     binder::Status clearLayerFrameStats(const sp<IBinder>& handle) override;
49 
50     binder::Status getLayerFrameStats(const sp<IBinder>& handle,
51                                       gui::FrameStats* outStats) override;
52 
53     binder::Status mirrorSurface(const sp<IBinder>& mirrorFromHandle,
54                                  gui::CreateSurfaceResult* outResult) override;
55 
56     binder::Status mirrorDisplay(int64_t displayId, gui::CreateSurfaceResult* outResult) override;
57 
58     binder::Status getSchedulingPolicy(gui::SchedulingPolicy* outPolicy) override;
59 
60     // constant
61     sp<SurfaceFlinger> mFlinger;
62 
63     // thread-safe
64     mutable Mutex mLock;
65 };
66 
67 }; // namespace android
68 
69 #endif // ANDROID_SF_CLIENT_H
70