The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 17 | #ifndef ANDROID_SF_SURFACE_COMPOSER_CLIENT_H |
| 18 | #define ANDROID_SF_SURFACE_COMPOSER_CLIENT_H |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Mathias Agopian | dd3423c | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 23 | #include <binder/IBinder.h> |
| 24 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | #include <utils/SortedVector.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | #include <utils/RefBase.h> |
| 27 | #include <utils/threads.h> |
| 28 | |
| 29 | #include <ui/PixelFormat.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | #include <ui/Region.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 31 | |
| 32 | #include <surfaceflinger/Surface.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | |
| 34 | namespace android { |
| 35 | |
| 36 | // --------------------------------------------------------------------------- |
| 37 | |
| 38 | class Region; |
Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 39 | class SharedClient; |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 40 | class ISurfaceComposer; |
| 41 | class DisplayInfo; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | |
| 43 | class SurfaceComposerClient : virtual public RefBase |
| 44 | { |
| 45 | public: |
| 46 | SurfaceComposerClient(); |
| 47 | virtual ~SurfaceComposerClient(); |
| 48 | |
| 49 | // Always make sure we could initialize |
| 50 | status_t initCheck() const; |
| 51 | |
| 52 | // Return the connection of this client |
| 53 | sp<IBinder> connection() const; |
| 54 | |
| 55 | // Retrieve a client for an existing connection. |
| 56 | static sp<SurfaceComposerClient> |
| 57 | clientForConnection(const sp<IBinder>& conn); |
| 58 | |
| 59 | // Forcibly remove connection before all references have gone away. |
| 60 | void dispose(); |
| 61 | |
| 62 | // ------------------------------------------------------------------------ |
| 63 | // surface creation / destruction |
| 64 | |
| 65 | //! Create a surface |
Mathias Agopian | 01b7668 | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 66 | sp<SurfaceControl> createSurface( |
Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 67 | int pid, // pid of the process the surface is for |
| 68 | DisplayID display, // Display to create this surface on |
| 69 | uint32_t w, // width in pixel |
| 70 | uint32_t h, // height in pixel |
| 71 | PixelFormat format, // pixel-format desired |
| 72 | uint32_t flags = 0 // usage flags |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | ); |
| 74 | |
| 75 | // ------------------------------------------------------------------------ |
| 76 | // Composer parameters |
| 77 | // All composer parameters must be changed within a transaction |
| 78 | // several surfaces can be updated in one transaction, all changes are |
| 79 | // committed at once when the transaction is closed. |
| 80 | // CloseTransaction() usually requires an IPC with the server. |
| 81 | |
| 82 | //! Open a composer transaction |
| 83 | status_t openTransaction(); |
| 84 | |
| 85 | //! commit the transaction |
| 86 | status_t closeTransaction(); |
| 87 | |
| 88 | //! Open a composer transaction on all active SurfaceComposerClients. |
| 89 | static void openGlobalTransaction(); |
| 90 | |
| 91 | //! Close a composer transaction on all active SurfaceComposerClients. |
| 92 | static void closeGlobalTransaction(); |
| 93 | |
| 94 | //! Freeze the specified display but not transactions. |
| 95 | static status_t freezeDisplay(DisplayID dpy, uint32_t flags = 0); |
| 96 | |
| 97 | //! Resume updates on the specified display. |
| 98 | static status_t unfreezeDisplay(DisplayID dpy, uint32_t flags = 0); |
| 99 | |
| 100 | //! Set the orientation of the given display |
Mathias Agopian | c08731e | 2009-03-27 18:11:38 -0700 | [diff] [blame] | 101 | static int setOrientation(DisplayID dpy, int orientation, uint32_t flags); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | |
| 103 | // Query the number of displays |
| 104 | static ssize_t getNumberOfDisplays(); |
| 105 | |
| 106 | // Get information about a display |
| 107 | static status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info); |
| 108 | static ssize_t getDisplayWidth(DisplayID dpy); |
| 109 | static ssize_t getDisplayHeight(DisplayID dpy); |
| 110 | static ssize_t getDisplayOrientation(DisplayID dpy); |
| 111 | |
Mathias Agopian | dd3423c | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 112 | status_t linkToComposerDeath(const sp<IBinder::DeathRecipient>& recipient, |
| 113 | void* cookie = NULL, uint32_t flags = 0); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | |
| 115 | private: |
| 116 | friend class Surface; |
Mathias Agopian | 62185b7 | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 117 | friend class SurfaceControl; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 118 | |
| 119 | SurfaceComposerClient(const sp<ISurfaceComposer>& sm, |
| 120 | const sp<IBinder>& conn); |
| 121 | |
Mathias Agopian | 62185b7 | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 122 | status_t hide(SurfaceID id); |
| 123 | status_t show(SurfaceID id, int32_t layer = -1); |
| 124 | status_t freeze(SurfaceID id); |
| 125 | status_t unfreeze(SurfaceID id); |
| 126 | status_t setFlags(SurfaceID id, uint32_t flags, uint32_t mask); |
| 127 | status_t setTransparentRegionHint(SurfaceID id, const Region& transparent); |
| 128 | status_t setLayer(SurfaceID id, int32_t layer); |
| 129 | status_t setAlpha(SurfaceID id, float alpha=1.0f); |
| 130 | status_t setFreezeTint(SurfaceID id, uint32_t tint); |
| 131 | status_t setMatrix(SurfaceID id, float dsdx, float dtdx, float dsdy, float dtdy); |
| 132 | status_t setPosition(SurfaceID id, int32_t x, int32_t y); |
| 133 | status_t setSize(SurfaceID id, uint32_t w, uint32_t h); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 134 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 135 | void signalServer(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 136 | |
| 137 | status_t destroySurface(SurfaceID sid); |
| 138 | |
| 139 | void _init(const sp<ISurfaceComposer>& sm, |
| 140 | const sp<ISurfaceFlingerClient>& conn); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 141 | |
Mathias Agopian | 62185b7 | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 142 | inline layer_state_t* _get_state_l(SurfaceID id); |
| 143 | layer_state_t* _lockLayerState(SurfaceID id); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 144 | inline void _unlockLayerState(); |
| 145 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 146 | mutable Mutex mLock; |
| 147 | layer_state_t* mPrebuiltLayerState; |
| 148 | SortedVector<layer_state_t> mStates; |
| 149 | int32_t mTransactionOpen; |
| 150 | |
| 151 | // these don't need to be protected because they never change |
| 152 | // after assignment |
| 153 | status_t mStatus; |
Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 154 | SharedClient* mControl; |
Mathias Agopian | 7303c6b | 2009-07-02 18:11:53 -0700 | [diff] [blame] | 155 | sp<IMemoryHeap> mControlMemory; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 156 | sp<ISurfaceFlingerClient> mClient; |
Mathias Agopian | e700501 | 2009-10-07 16:44:10 -0700 | [diff] [blame] | 157 | sp<ISurfaceComposer> mSignalServer; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | }; // namespace android |
| 161 | |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 162 | #endif // ANDROID_SF_SURFACE_COMPOSER_CLIENT_H |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 163 | |