Mathias Agopian | 41f673c | 2011-11-17 17:48:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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_PRIVATE_GUI_COMPOSER_SERVICE_H |
| 18 | #define ANDROID_PRIVATE_GUI_COMPOSER_SERVICE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | #include <utils/Singleton.h> |
| 24 | #include <utils/StrongPointer.h> |
| 25 | |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | // --------------------------------------------------------------------------- |
| 30 | |
| 31 | class IMemoryHeap; |
| 32 | class ISurfaceComposer; |
Mathias Agopian | 41f673c | 2011-11-17 17:48:35 -0800 | [diff] [blame] | 33 | |
| 34 | // --------------------------------------------------------------------------- |
| 35 | |
Andy McFadden | 6652b3e | 2012-09-06 18:45:56 -0700 | [diff] [blame] | 36 | // This holds our connection to the composer service (i.e. SurfaceFlinger). |
| 37 | // If the remote side goes away, we will re-establish the connection. |
| 38 | // Users of this class should not retain the value from |
| 39 | // getComposerService() for an extended period. |
| 40 | // |
| 41 | // (It's not clear that using Singleton is useful here anymore.) |
Mathias Agopian | 41f673c | 2011-11-17 17:48:35 -0800 | [diff] [blame] | 42 | class ComposerService : public Singleton<ComposerService> |
| 43 | { |
Mathias Agopian | 41f673c | 2011-11-17 17:48:35 -0800 | [diff] [blame] | 44 | sp<ISurfaceComposer> mComposerService; |
Andy McFadden | 6652b3e | 2012-09-06 18:45:56 -0700 | [diff] [blame] | 45 | sp<IBinder::DeathRecipient> mDeathObserver; |
| 46 | Mutex mLock; |
| 47 | |
Mathias Agopian | 41f673c | 2011-11-17 17:48:35 -0800 | [diff] [blame] | 48 | ComposerService(); |
Andy McFadden | 6652b3e | 2012-09-06 18:45:56 -0700 | [diff] [blame] | 49 | void connectLocked(); |
| 50 | void composerServiceDied(); |
Mathias Agopian | 41f673c | 2011-11-17 17:48:35 -0800 | [diff] [blame] | 51 | friend class Singleton<ComposerService>; |
| 52 | public: |
Andy McFadden | 6652b3e | 2012-09-06 18:45:56 -0700 | [diff] [blame] | 53 | |
| 54 | // Get a connection to the Composer Service. This will block until |
| 55 | // a connection is established. |
Mathias Agopian | 41f673c | 2011-11-17 17:48:35 -0800 | [diff] [blame] | 56 | static sp<ISurfaceComposer> getComposerService(); |
Mathias Agopian | 41f673c | 2011-11-17 17:48:35 -0800 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | // --------------------------------------------------------------------------- |
| 60 | }; // namespace android |
| 61 | |
| 62 | #endif // ANDROID_PRIVATE_GUI_COMPOSER_SERVICE_H |