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