| 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 | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 17 | #ifndef ANDROID_GUI_SURFACE_COMPOSER_CLIENT_H |
| 18 | #define ANDROID_GUI_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> |
| chaviw | 8e3fe5d | 2018-02-22 10:55:42 -0800 | [diff] [blame] | 22 | #include <unordered_map> |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | |
| Mathias Agopian | dd3423c | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 24 | #include <binder/IBinder.h> |
| 25 | |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | #include <utils/RefBase.h> |
| Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 27 | #include <utils/Singleton.h> |
| 28 | #include <utils/SortedVector.h> |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | #include <utils/threads.h> |
| 30 | |
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 31 | #include <ui/FrameStats.h> |
| Peiyong Lin | 9f03447 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 32 | #include <ui/GraphicTypes.h> |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | #include <ui/PixelFormat.h> |
| Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 34 | |
| Mathias Agopian | abe815d | 2013-03-19 22:22:21 -0700 | [diff] [blame] | 35 | #include <gui/CpuConsumer.h> |
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 36 | #include <gui/SurfaceControl.h> |
| chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 37 | #include <math/vec3.h> |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 38 | #include <gui/LayerState.h> |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | |
| 40 | namespace android { |
| 41 | |
| 42 | // --------------------------------------------------------------------------- |
| 43 | |
| Colin Cross | a2362b4 | 2016-09-26 13:48:25 -0700 | [diff] [blame] | 44 | struct DisplayInfo; |
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 45 | class HdrCapabilities; |
| Mathias Agopian | 41f673c | 2011-11-17 17:48:35 -0800 | [diff] [blame] | 46 | class ISurfaceComposerClient; |
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 47 | class IGraphicBufferProducer; |
| Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 48 | class Region; |
| Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 49 | |
| 50 | // --------------------------------------------------------------------------- |
| 51 | |
| Mathias Agopian | d4784a3 | 2010-05-27 19:41:15 -0700 | [diff] [blame] | 52 | class SurfaceComposerClient : public RefBase |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | { |
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 54 | friend class Composer; |
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 55 | public: |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | SurfaceComposerClient(); |
| Jorim Jaggi | f3cf4bc | 2017-11-30 14:19:23 +0100 | [diff] [blame] | 57 | SurfaceComposerClient(const sp<ISurfaceComposerClient>& client); |
| Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 58 | SurfaceComposerClient(const sp<IGraphicBufferProducer>& parent); |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | virtual ~SurfaceComposerClient(); |
| 60 | |
| 61 | // Always make sure we could initialize |
| 62 | status_t initCheck() const; |
| 63 | |
| 64 | // Return the connection of this client |
| 65 | sp<IBinder> connection() const; |
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 66 | |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | // Forcibly remove connection before all references have gone away. |
| 68 | void dispose(); |
| 69 | |
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 70 | // callback when the composer is dies |
| 71 | status_t linkToComposerDeath(const sp<IBinder::DeathRecipient>& recipient, |
| Yi Kong | a03e044 | 2018-07-17 11:16:57 -0700 | [diff] [blame] | 72 | void* cookie = nullptr, uint32_t flags = 0); |
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 73 | |
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 74 | // Get a list of supported configurations for a given display |
| 75 | static status_t getDisplayConfigs(const sp<IBinder>& display, |
| 76 | Vector<DisplayInfo>* configs); |
| 77 | |
| 78 | // Get the DisplayInfo for the currently-active configuration |
| 79 | static status_t getDisplayInfo(const sp<IBinder>& display, |
| 80 | DisplayInfo* info); |
| 81 | |
| 82 | // Get the index of the current active configuration (relative to the list |
| 83 | // returned by getDisplayInfo) |
| 84 | static int getActiveConfig(const sp<IBinder>& display); |
| 85 | |
| 86 | // Set a new active configuration using an index relative to the list |
| 87 | // returned by getDisplayInfo |
| 88 | static status_t setActiveConfig(const sp<IBinder>& display, int id); |
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 89 | |
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 90 | // Gets the list of supported color modes for the given display |
| 91 | static status_t getDisplayColorModes(const sp<IBinder>& display, |
| Peiyong Lin | 9f03447 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 92 | Vector<ui::ColorMode>* outColorModes); |
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 93 | |
| 94 | // Gets the active color mode for the given display |
| Peiyong Lin | 9f03447 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 95 | static ui::ColorMode getActiveColorMode(const sp<IBinder>& display); |
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 96 | |
| 97 | // Sets the active color mode for the given display |
| Peiyong Lin | 9f03447 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 98 | static status_t setActiveColorMode(const sp<IBinder>& display, |
| 99 | ui::ColorMode colorMode); |
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 100 | |
| Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 101 | /* Triggers screen on/off or low power mode and waits for it to complete */ |
| 102 | static void setDisplayPowerMode(const sp<IBinder>& display, int mode); |
| Jeff Brown | 2a09bb3 | 2012-10-08 19:13:57 -0700 | [diff] [blame] | 103 | |
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame^] | 104 | // |
| 105 | static status_t getCompositionPreference(ui::Dataspace* dataSpace, |
| 106 | ui::PixelFormat* pixelFormat); |
| 107 | |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 108 | // ------------------------------------------------------------------------ |
| 109 | // surface creation / destruction |
| 110 | |
| 111 | //! Create a surface |
| Mathias Agopian | 01b7668 | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 112 | sp<SurfaceControl> createSurface( |
| Mathias Agopian | 285dbde | 2010-03-01 16:09:43 -0800 | [diff] [blame] | 113 | const String8& name,// name of the surface |
| Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 114 | uint32_t w, // width in pixel |
| 115 | uint32_t h, // height in pixel |
| 116 | PixelFormat format, // pixel-format desired |
| Albert Chaulk | 479c60c | 2017-01-27 14:21:34 -0500 | [diff] [blame] | 117 | uint32_t flags = 0, // usage flags |
| 118 | SurfaceControl* parent = nullptr, // parent |
| rongliu | cfb187b | 2018-03-14 12:26:23 -0700 | [diff] [blame] | 119 | int32_t windowType = -1, // from WindowManager.java (STATUS_BAR, INPUT_METHOD, etc.) |
| 120 | int32_t ownerUid = -1 // UID of the task |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 121 | ); |
| 122 | |
| Robert Carr | 3b382ed | 2018-03-14 13:49:41 -0700 | [diff] [blame] | 123 | status_t createSurfaceChecked( |
| 124 | const String8& name,// name of the surface |
| 125 | uint32_t w, // width in pixel |
| 126 | uint32_t h, // height in pixel |
| 127 | PixelFormat format, // pixel-format desired |
| 128 | sp<SurfaceControl>* outSurface, |
| 129 | uint32_t flags = 0, // usage flags |
| 130 | SurfaceControl* parent = nullptr, // parent |
| rongliu | cfb187b | 2018-03-14 12:26:23 -0700 | [diff] [blame] | 131 | int32_t windowType = -1, // from WindowManager.java (STATUS_BAR, INPUT_METHOD, etc.) |
| 132 | int32_t ownerUid = -1 // UID of the task |
| Robert Carr | 3b382ed | 2018-03-14 13:49:41 -0700 | [diff] [blame] | 133 | ); |
| 134 | |
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 135 | //! Create a virtual display |
| Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 136 | static sp<IBinder> createDisplay(const String8& displayName, bool secure); |
| Mathias Agopian | 285dbde | 2010-03-01 16:09:43 -0800 | [diff] [blame] | 137 | |
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 138 | //! Destroy a virtual display |
| 139 | static void destroyDisplay(const sp<IBinder>& display); |
| 140 | |
| Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 141 | //! Get the token for the existing default displays. |
| 142 | //! Possible values for id are eDisplayIdMain and eDisplayIdHdmi. |
| 143 | static sp<IBinder> getBuiltInDisplay(int32_t id); |
| 144 | |
| Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 145 | static status_t enableVSyncInjections(bool enable); |
| 146 | |
| 147 | static status_t injectVSync(nsecs_t when); |
| 148 | |
| chaviw | 8e3fe5d | 2018-02-22 10:55:42 -0800 | [diff] [blame] | 149 | struct SCHash { |
| 150 | std::size_t operator()(const sp<SurfaceControl>& sc) const { |
| 151 | return std::hash<SurfaceControl *>{}(sc.get()); |
| 152 | } |
| 153 | }; |
| 154 | |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 155 | class Transaction { |
| chaviw | 8e3fe5d | 2018-02-22 10:55:42 -0800 | [diff] [blame] | 156 | std::unordered_map<sp<SurfaceControl>, ComposerState, SCHash> mComposerStates; |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 157 | SortedVector<DisplayState > mDisplayStates; |
| 158 | uint32_t mForceSynchronous = 0; |
| 159 | uint32_t mTransactionNestCount = 0; |
| 160 | bool mAnimation = false; |
| Dan Stoza | 84d619e | 2018-03-28 17:07:36 -0700 | [diff] [blame] | 161 | bool mEarlyWakeup = false; |
| Jamie Gennis | 2d5e230 | 2012-10-15 18:24:43 -0700 | [diff] [blame] | 162 | |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 163 | int mStatus = NO_ERROR; |
| 164 | |
| chaviw | 763ef57 | 2018-02-22 16:04:57 -0800 | [diff] [blame] | 165 | layer_state_t* getLayerState(const sp<SurfaceControl>& sc); |
| 166 | DisplayState& getDisplayState(const sp<IBinder>& token); |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 167 | |
| 168 | public: |
| 169 | Transaction() = default; |
| 170 | virtual ~Transaction() = default; |
| 171 | Transaction(Transaction const& other); |
| 172 | |
| 173 | status_t apply(bool synchronous = false); |
| Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 174 | // Merge another transaction in to this one, clearing other |
| 175 | // as if it had been applied. |
| 176 | Transaction& merge(Transaction&& other); |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 177 | Transaction& show(const sp<SurfaceControl>& sc); |
| 178 | Transaction& hide(const sp<SurfaceControl>& sc); |
| 179 | Transaction& setPosition(const sp<SurfaceControl>& sc, |
| 180 | float x, float y); |
| 181 | Transaction& setSize(const sp<SurfaceControl>& sc, |
| 182 | uint32_t w, uint32_t h); |
| 183 | Transaction& setLayer(const sp<SurfaceControl>& sc, |
| 184 | int32_t z); |
| 185 | |
| 186 | // Sets a Z order relative to the Surface specified by "relativeTo" but |
| 187 | // without becoming a full child of the relative. Z-ordering works exactly |
| 188 | // as if it were a child however. |
| 189 | // |
| 190 | // As a nod to sanity, only non-child surfaces may have a relative Z-order. |
| 191 | // |
| 192 | // This overrides any previous call and is overriden by any future calls |
| 193 | // to setLayer. |
| 194 | // |
| 195 | // If the relative is removed, the Surface will have no layer and be |
| 196 | // invisible, until the next time set(Relative)Layer is called. |
| 197 | Transaction& setRelativeLayer(const sp<SurfaceControl>& sc, |
| 198 | const sp<IBinder>& relativeTo, int32_t z); |
| 199 | Transaction& setFlags(const sp<SurfaceControl>& sc, |
| 200 | uint32_t flags, uint32_t mask); |
| 201 | Transaction& setTransparentRegionHint(const sp<SurfaceControl>& sc, |
| 202 | const Region& transparentRegion); |
| 203 | Transaction& setAlpha(const sp<SurfaceControl>& sc, |
| 204 | float alpha); |
| 205 | Transaction& setMatrix(const sp<SurfaceControl>& sc, |
| 206 | float dsdx, float dtdx, float dtdy, float dsdy); |
| Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 207 | Transaction& setCrop_legacy(const sp<SurfaceControl>& sc, const Rect& crop); |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 208 | Transaction& setLayerStack(const sp<SurfaceControl>& sc, uint32_t layerStack); |
| 209 | // Defers applying any changes made in this transaction until the Layer |
| 210 | // identified by handle reaches the given frameNumber. If the Layer identified |
| 211 | // by handle is removed, then we will apply this transaction regardless of |
| 212 | // what frame number has been reached. |
| Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 213 | Transaction& deferTransactionUntil_legacy(const sp<SurfaceControl>& sc, |
| 214 | const sp<IBinder>& handle, uint64_t frameNumber); |
| 215 | // A variant of deferTransactionUntil_legacy which identifies the Layer we wait for by |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 216 | // Surface instead of Handle. Useful for clients which may not have the |
| 217 | // SurfaceControl for some of their Surfaces. Otherwise behaves identically. |
| Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 218 | Transaction& deferTransactionUntil_legacy(const sp<SurfaceControl>& sc, |
| 219 | const sp<Surface>& barrierSurface, |
| 220 | uint64_t frameNumber); |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 221 | // Reparents all children of this layer to the new parent handle. |
| 222 | Transaction& reparentChildren(const sp<SurfaceControl>& sc, |
| 223 | const sp<IBinder>& newParentHandle); |
| 224 | |
| 225 | /// Reparents the current layer to the new parent handle. The new parent must not be null. |
| 226 | // This can be used instead of reparentChildren if the caller wants to |
| 227 | // only re-parent a specific child. |
| 228 | Transaction& reparent(const sp<SurfaceControl>& sc, |
| 229 | const sp<IBinder>& newParentHandle); |
| 230 | |
| 231 | Transaction& setColor(const sp<SurfaceControl>& sc, const half3& color); |
| 232 | |
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 233 | Transaction& setTransform(const sp<SurfaceControl>& sc, uint32_t transform); |
| 234 | Transaction& setTransformToDisplayInverse(const sp<SurfaceControl>& sc, |
| 235 | bool transformToDisplayInverse); |
| 236 | Transaction& setCrop(const sp<SurfaceControl>& sc, const Rect& crop); |
| 237 | Transaction& setBuffer(const sp<SurfaceControl>& sc, const sp<GraphicBuffer>& buffer); |
| 238 | Transaction& setAcquireFence(const sp<SurfaceControl>& sc, const sp<Fence>& fence); |
| 239 | Transaction& setDataspace(const sp<SurfaceControl>& sc, ui::Dataspace dataspace); |
| 240 | Transaction& setHdrMetadata(const sp<SurfaceControl>& sc, const HdrMetadata& hdrMetadata); |
| 241 | Transaction& setSurfaceDamageRegion(const sp<SurfaceControl>& sc, |
| 242 | const Region& surfaceDamageRegion); |
| 243 | Transaction& setApi(const sp<SurfaceControl>& sc, int32_t api); |
| 244 | Transaction& setSidebandStream(const sp<SurfaceControl>& sc, |
| 245 | const sp<NativeHandle>& sidebandStream); |
| 246 | |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 247 | // Detaches all child surfaces (and their children recursively) |
| 248 | // from their SurfaceControl. |
| 249 | // The child SurfaceControls will not throw exceptions or return errors, |
| 250 | // but transactions will have no effect. |
| 251 | // The child surfaces will continue to follow their parent surfaces, |
| 252 | // and remain eligible for rendering, but their relative state will be |
| 253 | // frozen. We use this in the WindowManager, in app shutdown/relaunch |
| 254 | // scenarios, where the app would otherwise clean up its child Surfaces. |
| 255 | // Sometimes the WindowManager needs to extend their lifetime slightly |
| 256 | // in order to perform an exit animation or prevent flicker. |
| 257 | Transaction& detachChildren(const sp<SurfaceControl>& sc); |
| 258 | // Set an override scaling mode as documented in <system/window.h> |
| 259 | // the override scaling mode will take precedence over any client |
| 260 | // specified scaling mode. -1 will clear the override scaling mode. |
| 261 | Transaction& setOverrideScalingMode(const sp<SurfaceControl>& sc, |
| 262 | int32_t overrideScalingMode); |
| 263 | |
| 264 | // If the size changes in this transaction, all geometry updates specified |
| 265 | // in this transaction will not complete until a buffer of the new size |
| 266 | // arrives. As some elements normally apply immediately, this enables |
| 267 | // freezing the total geometry of a surface until a resize is completed. |
| 268 | Transaction& setGeometryAppliesWithResize(const sp<SurfaceControl>& sc); |
| 269 | |
| chaviw | ca27f25 | 2018-02-06 16:46:39 -0800 | [diff] [blame] | 270 | Transaction& destroySurface(const sp<SurfaceControl>& sc); |
| 271 | |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 272 | status_t setDisplaySurface(const sp<IBinder>& token, |
| 273 | const sp<IGraphicBufferProducer>& bufferProducer); |
| 274 | |
| 275 | void setDisplayLayerStack(const sp<IBinder>& token, uint32_t layerStack); |
| 276 | |
| 277 | /* setDisplayProjection() defines the projection of layer stacks |
| 278 | * to a given display. |
| 279 | * |
| 280 | * - orientation defines the display's orientation. |
| 281 | * - layerStackRect defines which area of the window manager coordinate |
| 282 | * space will be used. |
| 283 | * - displayRect defines where on the display will layerStackRect be |
| 284 | * mapped to. displayRect is specified post-orientation, that is |
| 285 | * it uses the orientation seen by the end-user. |
| 286 | */ |
| 287 | void setDisplayProjection(const sp<IBinder>& token, |
| 288 | uint32_t orientation, |
| 289 | const Rect& layerStackRect, |
| 290 | const Rect& displayRect); |
| 291 | void setDisplaySize(const sp<IBinder>& token, uint32_t width, uint32_t height); |
| 292 | void setAnimationTransaction(); |
| Dan Stoza | 84d619e | 2018-03-28 17:07:36 -0700 | [diff] [blame] | 293 | void setEarlyWakeup(); |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 294 | }; |
| Robert Carr | 82364e3 | 2016-05-15 11:27:47 -0700 | [diff] [blame] | 295 | |
| Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 296 | status_t destroySurface(const sp<IBinder>& id); |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 297 | |
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 298 | status_t clearLayerFrameStats(const sp<IBinder>& token) const; |
| 299 | status_t getLayerFrameStats(const sp<IBinder>& token, FrameStats* outStats) const; |
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 300 | static status_t clearAnimationFrameStats(); |
| 301 | static status_t getAnimationFrameStats(FrameStats* outStats); |
| 302 | |
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 303 | static status_t getHdrCapabilities(const sp<IBinder>& display, |
| 304 | HdrCapabilities* outCapabilities); |
| 305 | |
| Mathias Agopian | 00e8c7a | 2012-09-04 19:30:46 -0700 | [diff] [blame] | 306 | static void setDisplayProjection(const sp<IBinder>& token, |
| 307 | uint32_t orientation, |
| 308 | const Rect& layerStackRect, |
| 309 | const Rect& displayRect); |
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 310 | |
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 311 | inline sp<ISurfaceComposerClient> getClient() { return mClient; } |
| 312 | |
| Mathias Agopian | 631f358 | 2010-05-25 17:51:34 -0700 | [diff] [blame] | 313 | private: |
| Mathias Agopian | d4784a3 | 2010-05-27 19:41:15 -0700 | [diff] [blame] | 314 | virtual void onFirstRef(); |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 315 | |
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 316 | mutable Mutex mLock; |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 317 | status_t mStatus; |
| Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 318 | sp<ISurfaceComposerClient> mClient; |
| Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 319 | wp<IGraphicBufferProducer> mParent; |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 320 | }; |
| 321 | |
| Mathias Agopian | d4784a3 | 2010-05-27 19:41:15 -0700 | [diff] [blame] | 322 | // --------------------------------------------------------------------------- |
| Mathias Agopian | 74c40c0 | 2010-09-29 13:02:36 -0700 | [diff] [blame] | 323 | |
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 324 | class ScreenshotClient { |
| Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 325 | public: |
| Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 326 | // if cropping isn't required, callers may pass in a default Rect, e.g.: |
| 327 | // capture(display, producer, Rect(), reqWidth, ...); |
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 328 | static status_t capture(const sp<IBinder>& display, Rect sourceCrop, uint32_t reqWidth, |
| 329 | uint32_t reqHeight, int32_t minLayerZ, int32_t maxLayerZ, |
| 330 | bool useIdentityTransform, uint32_t rotation, |
| 331 | sp<GraphicBuffer>* outBuffer); |
| Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 332 | static status_t captureLayers(const sp<IBinder>& layerHandle, Rect sourceCrop, float frameScale, |
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 333 | sp<GraphicBuffer>* outBuffer); |
| Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 334 | static status_t captureChildLayers(const sp<IBinder>& layerHandle, Rect sourceCrop, |
| 335 | float frameScale, sp<GraphicBuffer>* outBuffer); |
| Mathias Agopian | 74c40c0 | 2010-09-29 13:02:36 -0700 | [diff] [blame] | 336 | }; |
| 337 | |
| 338 | // --------------------------------------------------------------------------- |
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 339 | }; // namespace android |
| 340 | |
| Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 341 | #endif // ANDROID_GUI_SURFACE_COMPOSER_CLIENT_H |