1db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian/*
2db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian * Copyright (C) 2012 The Android Open Source Project
3db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian *
4db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
5db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian * you may not use this file except in compliance with the License.
6db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian * You may obtain a copy of the License at
7db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian *
8db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
9db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian *
10db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian * Unless required by applicable law or agreed to in writing, software
11db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
12db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian * See the License for the specific language governing permissions and
14db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian * limitations under the License.
15db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian */
16db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
17db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian#ifndef ANDROID_SF_CLIENT_H
18db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian#define ANDROID_SF_CLIENT_H
19db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
20db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian#include <stdint.h>
21db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian#include <sys/types.h>
22db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
23db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian#include <utils/Errors.h>
24db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian#include <utils/KeyedVector.h>
25db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian#include <utils/Mutex.h>
26db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
27db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian#include <gui/ISurfaceComposerClient.h>
28db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
29db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopiannamespace android {
30db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
31db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian// ---------------------------------------------------------------------------
32db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
3313127d8921356dff794250e04208c3ed60b3a3dfMathias Agopianclass Layer;
34db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopianclass SurfaceFlinger;
35db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
36db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian// ---------------------------------------------------------------------------
37db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
38db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopianclass Client : public BnSurfaceComposerClient
39db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian{
40db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopianpublic:
41db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian        Client(const sp<SurfaceFlinger>& flinger);
42db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian        ~Client();
43db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
44db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian    status_t initCheck() const;
45db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
46db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian    // protected by SurfaceFlinger::mStateLock
4713127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian    void attachLayer(const sp<IBinder>& handle, const sp<Layer>& layer);
48db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
4913127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian    void detachLayer(const Layer* layer);
50db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
5113127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian    sp<Layer> getLayerUser(const sp<IBinder>& handle) const;
52db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
53db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopianprivate:
54db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian    // ISurfaceComposerClient interface
554d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian    virtual status_t createSurface(
56ac9fa427d4a86745e60a5f7fd8e3ea340c4db907Mathias Agopian            const String8& name,
574d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian            uint32_t w, uint32_t h,PixelFormat format, uint32_t flags,
584d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian            sp<IBinder>* handle,
594d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian            sp<IGraphicBufferProducer>* gbp);
60db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
61ac9fa427d4a86745e60a5f7fd8e3ea340c4db907Mathias Agopian    virtual status_t destroySurface(const sp<IBinder>& handle);
62db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
63d85084b2b65828442eafaff9b811e9b6c9ca9fadSvetoslav    virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const;
64d85084b2b65828442eafaff9b811e9b6c9ca9fadSvetoslav
65d85084b2b65828442eafaff9b811e9b6c9ca9fadSvetoslav    virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const;
66d85084b2b65828442eafaff9b811e9b6c9ca9fadSvetoslav
67db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian    virtual status_t onTransact(
68db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian        uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
69db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
70db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian    // constant
71db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian    sp<SurfaceFlinger> mFlinger;
72db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
73db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian    // protected by mLock
7413127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian    DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayers;
75db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
76db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian    // thread-safe
77db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian    mutable Mutex mLock;
78db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian};
79db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
80db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian// ---------------------------------------------------------------------------
81db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian}; // namespace android
82db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian
83db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian#endif // ANDROID_SF_CLIENT_H
84