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