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: 411db73f66624e7d151710483dd58e03eed672f064Robert Carr explicit Client(const sp<SurfaceFlinger>& flinger); 421db73f66624e7d151710483dd58e03eed672f064Robert Carr Client(const sp<SurfaceFlinger>& flinger, const sp<Layer>& parentLayer); 431db73f66624e7d151710483dd58e03eed672f064Robert Carr ~Client(); 44db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian 45db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian status_t initCheck() const; 46db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian 47db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian // protected by SurfaceFlinger::mStateLock 4813127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian void attachLayer(const sp<IBinder>& handle, const sp<Layer>& layer); 49db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian 5013127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian void detachLayer(const Layer* layer); 51db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian 5213127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian sp<Layer> getLayerUser(const sp<IBinder>& handle) const; 53db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian 541db73f66624e7d151710483dd58e03eed672f064Robert Carr void setParentLayer(const sp<Layer>& parentLayer); 551db73f66624e7d151710483dd58e03eed672f064Robert Carr 56db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopianprivate: 57db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian // ISurfaceComposerClient interface 584d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian virtual status_t createSurface( 59ac9fa427d4a86745e60a5f7fd8e3ea340c4db907Mathias Agopian const String8& name, 604d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian uint32_t w, uint32_t h,PixelFormat format, uint32_t flags, 61479c60c85c40fd3536b0c88036e838dc1a4c56a0Albert Chaulk const sp<IBinder>& parent, uint32_t windowType, uint32_t ownerUid, 624d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian sp<IBinder>* handle, 634d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian sp<IGraphicBufferProducer>* gbp); 64db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian 65ac9fa427d4a86745e60a5f7fd8e3ea340c4db907Mathias Agopian virtual status_t destroySurface(const sp<IBinder>& handle); 66db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian 67d85084b2b65828442eafaff9b811e9b6c9ca9fadSvetoslav virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const; 68d85084b2b65828442eafaff9b811e9b6c9ca9fadSvetoslav 69d85084b2b65828442eafaff9b811e9b6c9ca9fadSvetoslav virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const; 70d85084b2b65828442eafaff9b811e9b6c9ca9fadSvetoslav 71db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian virtual status_t onTransact( 72db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags); 73db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian 74f456f32e0f9292d71b57b3255cde416b677faac2Chia-I Wu sp<Layer> getParentLayer(bool* outParentDied = nullptr) const; 75f456f32e0f9292d71b57b3255cde416b677faac2Chia-I Wu 76db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian // constant 77db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian sp<SurfaceFlinger> mFlinger; 78db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian 79db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian // protected by mLock 8013127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayers; 811db73f66624e7d151710483dd58e03eed672f064Robert Carr wp<Layer> mParentLayer; 821db73f66624e7d151710483dd58e03eed672f064Robert Carr 83db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian // thread-safe 84db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian mutable Mutex mLock; 85db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian}; 86db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian 87db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian// --------------------------------------------------------------------------- 88db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian}; // namespace android 89db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian 90db403e8ff0d7727015e1a5009bab20eb7ec205bcMathias Agopian#endif // ANDROID_SF_CLIENT_H 91