Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 | */ |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 16 | #undef LOG_TAG |
| 17 | #define LOG_TAG "SurfaceInterceptor" |
| 18 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 19 | |
| 20 | #include "Layer.h" |
| 21 | #include "SurfaceFlinger.h" |
| 22 | #include "SurfaceInterceptor.h" |
Colin Cross | 6354938 | 2016-10-26 12:52:53 -0700 | [diff] [blame] | 23 | |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 24 | #include <fstream> |
| 25 | |
Mark Salyzyn | 4dad9ce | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 26 | #include <android-base/file.h> |
| 27 | #include <log/log.h> |
| 28 | #include <utils/Trace.h> |
| 29 | |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 30 | namespace android { |
| 31 | |
| 32 | // ---------------------------------------------------------------------------- |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 33 | // TODO(marissaw): add new layer state values to SurfaceInterceptor |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 34 | |
Lloyd Pique | 4dccc41 | 2018-01-22 17:21:36 -0800 | [diff] [blame] | 35 | SurfaceInterceptor::~SurfaceInterceptor() = default; |
| 36 | |
| 37 | namespace impl { |
| 38 | |
Robert Carr | 0d48072 | 2017-01-10 16:42:54 -0800 | [diff] [blame] | 39 | SurfaceInterceptor::SurfaceInterceptor(SurfaceFlinger* flinger) |
| 40 | : mFlinger(flinger) |
| 41 | { |
| 42 | } |
| 43 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 44 | void SurfaceInterceptor::enable(const SortedVector<sp<Layer>>& layers, |
| 45 | const DefaultKeyedVector< wp<IBinder>, DisplayDeviceState>& displays) |
| 46 | { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 47 | if (mEnabled) { |
| 48 | return; |
| 49 | } |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 50 | ATRACE_CALL(); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 51 | mEnabled = true; |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 52 | std::lock_guard<std::mutex> protoGuard(mTraceMutex); |
| 53 | saveExistingDisplaysLocked(displays); |
| 54 | saveExistingSurfacesLocked(layers); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | void SurfaceInterceptor::disable() { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 58 | if (!mEnabled) { |
| 59 | return; |
| 60 | } |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 61 | ATRACE_CALL(); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 62 | std::lock_guard<std::mutex> protoGuard(mTraceMutex); |
| 63 | mEnabled = false; |
| 64 | status_t err(writeProtoFileLocked()); |
| 65 | ALOGE_IF(err == PERMISSION_DENIED, "Could not save the proto file! Permission denied"); |
| 66 | ALOGE_IF(err == NOT_ENOUGH_DATA, "Could not save the proto file! There are missing fields"); |
| 67 | mTrace.Clear(); |
| 68 | } |
| 69 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 70 | bool SurfaceInterceptor::isEnabled() { |
| 71 | return mEnabled; |
| 72 | } |
| 73 | |
| 74 | void SurfaceInterceptor::saveExistingDisplaysLocked( |
| 75 | const DefaultKeyedVector< wp<IBinder>, DisplayDeviceState>& displays) |
| 76 | { |
| 77 | // Caveat: The initial snapshot does not capture the power mode of the existing displays |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 78 | ATRACE_CALL(); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 79 | for (size_t i = 0 ; i < displays.size() ; i++) { |
| 80 | addDisplayCreationLocked(createTraceIncrementLocked(), displays[i]); |
| 81 | addInitialDisplayStateLocked(createTraceIncrementLocked(), displays[i]); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 82 | } |
| 83 | } |
| 84 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 85 | void SurfaceInterceptor::saveExistingSurfacesLocked(const SortedVector<sp<Layer>>& layers) { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 86 | ATRACE_CALL(); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 87 | for (const auto& l : layers) { |
Dan Stoza | 412903f | 2017-04-27 13:42:17 -0700 | [diff] [blame] | 88 | l->traverseInZOrder(LayerVector::StateSet::Drawing, [this](Layer* layer) { |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 89 | addSurfaceCreationLocked(createTraceIncrementLocked(), layer); |
| 90 | addInitialSurfaceStateLocked(createTraceIncrementLocked(), layer); |
| 91 | }); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 92 | } |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | void SurfaceInterceptor::addInitialSurfaceStateLocked(Increment* increment, |
| 96 | const sp<const Layer>& layer) |
| 97 | { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 98 | Transaction* transaction(increment->mutable_transaction()); |
Lloyd Pique | f1c675b | 2018-09-12 20:45:39 -0700 | [diff] [blame] | 99 | const uint32_t layerFlags = layer->getTransactionFlags(); |
| 100 | transaction->set_synchronous(layerFlags & BnSurfaceComposer::eSynchronous); |
| 101 | transaction->set_animation(layerFlags & BnSurfaceComposer::eAnimation); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 102 | |
| 103 | const int32_t layerId(getLayerId(layer)); |
Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 104 | addPositionLocked(transaction, layerId, layer->mCurrentState.active_legacy.transform.tx(), |
| 105 | layer->mCurrentState.active_legacy.transform.ty()); |
| 106 | addDepthLocked(transaction, layerId, layer->mCurrentState.z); |
| 107 | addAlphaLocked(transaction, layerId, layer->mCurrentState.color.a); |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 108 | addTransparentRegionLocked(transaction, layerId, |
Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 109 | layer->mCurrentState.activeTransparentRegion_legacy); |
| 110 | addLayerStackLocked(transaction, layerId, layer->mCurrentState.layerStack); |
| 111 | addCropLocked(transaction, layerId, layer->mCurrentState.crop_legacy); |
| 112 | addCornerRadiusLocked(transaction, layerId, layer->mCurrentState.cornerRadius); |
| 113 | if (layer->mCurrentState.barrierLayer_legacy != nullptr) { |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 114 | addDeferTransactionLocked(transaction, layerId, |
Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 115 | layer->mCurrentState.barrierLayer_legacy.promote(), |
| 116 | layer->mCurrentState.frameNumber_legacy); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 117 | } |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 118 | addOverrideScalingModeLocked(transaction, layerId, layer->getEffectiveScalingMode()); |
Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 119 | addFlagsLocked(transaction, layerId, layer->mCurrentState.flags); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 122 | void SurfaceInterceptor::addInitialDisplayStateLocked(Increment* increment, |
| 123 | const DisplayDeviceState& display) |
| 124 | { |
| 125 | Transaction* transaction(increment->mutable_transaction()); |
| 126 | transaction->set_synchronous(false); |
| 127 | transaction->set_animation(false); |
| 128 | |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 129 | addDisplaySurfaceLocked(transaction, display.sequenceId, display.surface); |
| 130 | addDisplayLayerStackLocked(transaction, display.sequenceId, display.layerStack); |
| 131 | addDisplaySizeLocked(transaction, display.sequenceId, display.width, display.height); |
| 132 | addDisplayProjectionLocked(transaction, display.sequenceId, display.orientation, |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 133 | display.viewport, display.frame); |
| 134 | } |
| 135 | |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 136 | status_t SurfaceInterceptor::writeProtoFileLocked() { |
| 137 | ATRACE_CALL(); |
Colin Cross | 6354938 | 2016-10-26 12:52:53 -0700 | [diff] [blame] | 138 | std::string output; |
| 139 | |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 140 | if (!mTrace.IsInitialized()) { |
| 141 | return NOT_ENOUGH_DATA; |
| 142 | } |
Colin Cross | 6354938 | 2016-10-26 12:52:53 -0700 | [diff] [blame] | 143 | if (!mTrace.SerializeToString(&output)) { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 144 | return PERMISSION_DENIED; |
| 145 | } |
Colin Cross | 6354938 | 2016-10-26 12:52:53 -0700 | [diff] [blame] | 146 | if (!android::base::WriteStringToFile(output, mOutputFileName, true)) { |
| 147 | return PERMISSION_DENIED; |
| 148 | } |
| 149 | |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 150 | return NO_ERROR; |
| 151 | } |
| 152 | |
Irvel | 3017c61 | 2016-08-09 16:50:06 -0700 | [diff] [blame] | 153 | const sp<const Layer> SurfaceInterceptor::getLayer(const wp<const IBinder>& weakHandle) { |
| 154 | const sp<const IBinder>& handle(weakHandle.promote()); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 155 | const auto layerHandle(static_cast<const Layer::Handle*>(handle.get())); |
| 156 | const sp<const Layer> layer(layerHandle->owner.promote()); |
| 157 | // layer could be a nullptr at this point |
| 158 | return layer; |
| 159 | } |
| 160 | |
| 161 | const std::string SurfaceInterceptor::getLayerName(const sp<const Layer>& layer) { |
| 162 | return layer->getName().string(); |
| 163 | } |
| 164 | |
| 165 | int32_t SurfaceInterceptor::getLayerId(const sp<const Layer>& layer) { |
| 166 | return layer->sequence; |
| 167 | } |
| 168 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 169 | Increment* SurfaceInterceptor::createTraceIncrementLocked() { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 170 | Increment* increment(mTrace.add_increment()); |
| 171 | increment->set_time_stamp(systemTime()); |
| 172 | return increment; |
| 173 | } |
| 174 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 175 | SurfaceChange* SurfaceInterceptor::createSurfaceChangeLocked(Transaction* transaction, |
| 176 | int32_t layerId) |
| 177 | { |
| 178 | SurfaceChange* change(transaction->add_surface_change()); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 179 | change->set_id(layerId); |
| 180 | return change; |
| 181 | } |
| 182 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 183 | DisplayChange* SurfaceInterceptor::createDisplayChangeLocked(Transaction* transaction, |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 184 | int32_t sequenceId) |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 185 | { |
| 186 | DisplayChange* dispChange(transaction->add_display_change()); |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 187 | dispChange->set_id(sequenceId); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 188 | return dispChange; |
| 189 | } |
| 190 | |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 191 | void SurfaceInterceptor::setProtoRectLocked(Rectangle* protoRect, const Rect& rect) { |
| 192 | protoRect->set_left(rect.left); |
| 193 | protoRect->set_top(rect.top); |
| 194 | protoRect->set_right(rect.right); |
| 195 | protoRect->set_bottom(rect.bottom); |
| 196 | } |
| 197 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 198 | void SurfaceInterceptor::addPositionLocked(Transaction* transaction, int32_t layerId, |
| 199 | float x, float y) |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 200 | { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 201 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 202 | PositionChange* posChange(change->mutable_position()); |
| 203 | posChange->set_x(x); |
| 204 | posChange->set_y(y); |
| 205 | } |
| 206 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 207 | void SurfaceInterceptor::addDepthLocked(Transaction* transaction, int32_t layerId, |
| 208 | uint32_t z) |
| 209 | { |
| 210 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 211 | LayerChange* depthChange(change->mutable_layer()); |
| 212 | depthChange->set_layer(z); |
| 213 | } |
| 214 | |
| 215 | void SurfaceInterceptor::addSizeLocked(Transaction* transaction, int32_t layerId, uint32_t w, |
| 216 | uint32_t h) |
| 217 | { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 218 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 219 | SizeChange* sizeChange(change->mutable_size()); |
| 220 | sizeChange->set_w(w); |
| 221 | sizeChange->set_h(h); |
| 222 | } |
| 223 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 224 | void SurfaceInterceptor::addAlphaLocked(Transaction* transaction, int32_t layerId, |
| 225 | float alpha) |
| 226 | { |
| 227 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 228 | AlphaChange* alphaChange(change->mutable_alpha()); |
| 229 | alphaChange->set_alpha(alpha); |
| 230 | } |
| 231 | |
| 232 | void SurfaceInterceptor::addMatrixLocked(Transaction* transaction, int32_t layerId, |
| 233 | const layer_state_t::matrix22_t& matrix) |
| 234 | { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 235 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 236 | MatrixChange* matrixChange(change->mutable_matrix()); |
| 237 | matrixChange->set_dsdx(matrix.dsdx); |
| 238 | matrixChange->set_dtdx(matrix.dtdx); |
| 239 | matrixChange->set_dsdy(matrix.dsdy); |
| 240 | matrixChange->set_dtdy(matrix.dtdy); |
| 241 | } |
| 242 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 243 | void SurfaceInterceptor::addTransparentRegionLocked(Transaction* transaction, |
| 244 | int32_t layerId, const Region& transRegion) |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 245 | { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 246 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 247 | TransparentRegionHintChange* transparentChange(change->mutable_transparent_region_hint()); |
| 248 | |
| 249 | for (const auto& rect : transRegion) { |
| 250 | Rectangle* protoRect(transparentChange->add_region()); |
| 251 | setProtoRectLocked(protoRect, rect); |
| 252 | } |
| 253 | } |
| 254 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 255 | void SurfaceInterceptor::addFlagsLocked(Transaction* transaction, int32_t layerId, |
| 256 | uint8_t flags) |
| 257 | { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 258 | // There can be multiple flags changed |
| 259 | if (flags & layer_state_t::eLayerHidden) { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 260 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 261 | HiddenFlagChange* flagChange(change->mutable_hidden_flag()); |
| 262 | flagChange->set_hidden_flag(true); |
| 263 | } |
| 264 | if (flags & layer_state_t::eLayerOpaque) { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 265 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 266 | OpaqueFlagChange* flagChange(change->mutable_opaque_flag()); |
| 267 | flagChange->set_opaque_flag(true); |
| 268 | } |
| 269 | if (flags & layer_state_t::eLayerSecure) { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 270 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 271 | SecureFlagChange* flagChange(change->mutable_secure_flag()); |
| 272 | flagChange->set_secure_flag(true); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | void SurfaceInterceptor::addLayerStackLocked(Transaction* transaction, int32_t layerId, |
| 277 | uint32_t layerStack) |
| 278 | { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 279 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 280 | LayerStackChange* layerStackChange(change->mutable_layer_stack()); |
| 281 | layerStackChange->set_layer_stack(layerStack); |
| 282 | } |
| 283 | |
| 284 | void SurfaceInterceptor::addCropLocked(Transaction* transaction, int32_t layerId, |
| 285 | const Rect& rect) |
| 286 | { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 287 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 288 | CropChange* cropChange(change->mutable_crop()); |
| 289 | Rectangle* protoRect(cropChange->mutable_rectangle()); |
| 290 | setProtoRectLocked(protoRect, rect); |
| 291 | } |
| 292 | |
Lucas Dupin | 1b6531c | 2018-07-05 17:18:21 -0700 | [diff] [blame] | 293 | void SurfaceInterceptor::addCornerRadiusLocked(Transaction* transaction, int32_t layerId, |
| 294 | float cornerRadius) |
| 295 | { |
| 296 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
| 297 | CornerRadiusChange* cornerRadiusChange(change->mutable_corner_radius()); |
| 298 | cornerRadiusChange->set_corner_radius(cornerRadius); |
| 299 | } |
| 300 | |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 301 | void SurfaceInterceptor::addDeferTransactionLocked(Transaction* transaction, int32_t layerId, |
Robert Carr | 0d48072 | 2017-01-10 16:42:54 -0800 | [diff] [blame] | 302 | const sp<const Layer>& layer, uint64_t frameNumber) |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 303 | { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 304 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 305 | if (layer == nullptr) { |
| 306 | ALOGE("An existing layer could not be retrieved with the handle" |
| 307 | " for the deferred transaction"); |
| 308 | return; |
| 309 | } |
| 310 | DeferredTransactionChange* deferTransaction(change->mutable_deferred_transaction()); |
| 311 | deferTransaction->set_layer_id(getLayerId(layer)); |
| 312 | deferTransaction->set_frame_number(frameNumber); |
| 313 | } |
| 314 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 315 | void SurfaceInterceptor::addOverrideScalingModeLocked(Transaction* transaction, |
| 316 | int32_t layerId, int32_t overrideScalingMode) |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 317 | { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 318 | SurfaceChange* change(createSurfaceChangeLocked(transaction, layerId)); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 319 | OverrideScalingModeChange* overrideChange(change->mutable_override_scaling_mode()); |
| 320 | overrideChange->set_override_scaling_mode(overrideScalingMode); |
| 321 | } |
| 322 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 323 | void SurfaceInterceptor::addSurfaceChangesLocked(Transaction* transaction, |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 324 | const layer_state_t& state) |
| 325 | { |
| 326 | const sp<const Layer> layer(getLayer(state.surface)); |
| 327 | if (layer == nullptr) { |
| 328 | ALOGE("An existing layer could not be retrieved with the surface " |
| 329 | "from the layer_state_t surface in the update transaction"); |
| 330 | return; |
| 331 | } |
| 332 | |
| 333 | const int32_t layerId(getLayerId(layer)); |
| 334 | |
| 335 | if (state.what & layer_state_t::ePositionChanged) { |
| 336 | addPositionLocked(transaction, layerId, state.x, state.y); |
| 337 | } |
| 338 | if (state.what & layer_state_t::eLayerChanged) { |
| 339 | addDepthLocked(transaction, layerId, state.z); |
| 340 | } |
| 341 | if (state.what & layer_state_t::eSizeChanged) { |
| 342 | addSizeLocked(transaction, layerId, state.w, state.h); |
| 343 | } |
| 344 | if (state.what & layer_state_t::eAlphaChanged) { |
| 345 | addAlphaLocked(transaction, layerId, state.alpha); |
| 346 | } |
| 347 | if (state.what & layer_state_t::eMatrixChanged) { |
| 348 | addMatrixLocked(transaction, layerId, state.matrix); |
| 349 | } |
| 350 | if (state.what & layer_state_t::eTransparentRegionChanged) { |
| 351 | addTransparentRegionLocked(transaction, layerId, state.transparentRegion); |
| 352 | } |
| 353 | if (state.what & layer_state_t::eFlagsChanged) { |
| 354 | addFlagsLocked(transaction, layerId, state.flags); |
| 355 | } |
| 356 | if (state.what & layer_state_t::eLayerStackChanged) { |
| 357 | addLayerStackLocked(transaction, layerId, state.layerStack); |
| 358 | } |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 359 | if (state.what & layer_state_t::eCropChanged_legacy) { |
| 360 | addCropLocked(transaction, layerId, state.crop_legacy); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 361 | } |
Lucas Dupin | 1b6531c | 2018-07-05 17:18:21 -0700 | [diff] [blame] | 362 | if (state.what & layer_state_t::eCornerRadiusChanged) { |
| 363 | addCornerRadiusLocked(transaction, layerId, state.cornerRadius); |
| 364 | } |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 365 | if (state.what & layer_state_t::eDeferTransaction_legacy) { |
Robert Carr | 0d48072 | 2017-01-10 16:42:54 -0800 | [diff] [blame] | 366 | sp<Layer> otherLayer = nullptr; |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 367 | if (state.barrierHandle_legacy != nullptr) { |
| 368 | otherLayer = |
| 369 | static_cast<Layer::Handle*>(state.barrierHandle_legacy.get())->owner.promote(); |
| 370 | } else if (state.barrierGbp_legacy != nullptr) { |
| 371 | auto const& gbp = state.barrierGbp_legacy; |
Robert Carr | 0d48072 | 2017-01-10 16:42:54 -0800 | [diff] [blame] | 372 | if (mFlinger->authenticateSurfaceTextureLocked(gbp)) { |
| 373 | otherLayer = (static_cast<MonitoredProducer*>(gbp.get()))->getLayer(); |
| 374 | } else { |
| 375 | ALOGE("Attempt to defer transaction to to an unrecognized GraphicBufferProducer"); |
| 376 | } |
| 377 | } |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 378 | addDeferTransactionLocked(transaction, layerId, otherLayer, state.frameNumber_legacy); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 379 | } |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 380 | if (state.what & layer_state_t::eOverrideScalingModeChanged) { |
| 381 | addOverrideScalingModeLocked(transaction, layerId, state.overrideScalingMode); |
| 382 | } |
| 383 | } |
| 384 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 385 | void SurfaceInterceptor::addDisplayChangesLocked(Transaction* transaction, |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 386 | const DisplayState& state, int32_t sequenceId) |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 387 | { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 388 | if (state.what & DisplayState::eSurfaceChanged) { |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 389 | addDisplaySurfaceLocked(transaction, sequenceId, state.surface); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 390 | } |
| 391 | if (state.what & DisplayState::eLayerStackChanged) { |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 392 | addDisplayLayerStackLocked(transaction, sequenceId, state.layerStack); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 393 | } |
| 394 | if (state.what & DisplayState::eDisplaySizeChanged) { |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 395 | addDisplaySizeLocked(transaction, sequenceId, state.width, state.height); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 396 | } |
| 397 | if (state.what & DisplayState::eDisplayProjectionChanged) { |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 398 | addDisplayProjectionLocked(transaction, sequenceId, state.orientation, state.viewport, |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 399 | state.frame); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 400 | } |
| 401 | } |
| 402 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 403 | void SurfaceInterceptor::addTransactionLocked(Increment* increment, |
| 404 | const Vector<ComposerState>& stateUpdates, |
| 405 | const DefaultKeyedVector< wp<IBinder>, DisplayDeviceState>& displays, |
| 406 | const Vector<DisplayState>& changedDisplays, uint32_t transactionFlags) |
| 407 | { |
| 408 | Transaction* transaction(increment->mutable_transaction()); |
| 409 | transaction->set_synchronous(transactionFlags & BnSurfaceComposer::eSynchronous); |
| 410 | transaction->set_animation(transactionFlags & BnSurfaceComposer::eAnimation); |
| 411 | for (const auto& compState: stateUpdates) { |
| 412 | addSurfaceChangesLocked(transaction, compState.state); |
| 413 | } |
| 414 | for (const auto& disp: changedDisplays) { |
| 415 | ssize_t dpyIdx = displays.indexOfKey(disp.token); |
| 416 | if (dpyIdx >= 0) { |
| 417 | const DisplayDeviceState& dispState(displays.valueAt(dpyIdx)); |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 418 | addDisplayChangesLocked(transaction, disp, dispState.sequenceId); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 419 | } |
| 420 | } |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 421 | } |
| 422 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 423 | void SurfaceInterceptor::addSurfaceCreationLocked(Increment* increment, |
| 424 | const sp<const Layer>& layer) |
| 425 | { |
| 426 | SurfaceCreation* creation(increment->mutable_surface_creation()); |
| 427 | creation->set_id(getLayerId(layer)); |
| 428 | creation->set_name(getLayerName(layer)); |
Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 429 | creation->set_w(layer->mCurrentState.active_legacy.w); |
| 430 | creation->set_h(layer->mCurrentState.active_legacy.h); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 431 | } |
| 432 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 433 | void SurfaceInterceptor::addSurfaceDeletionLocked(Increment* increment, |
| 434 | const sp<const Layer>& layer) |
| 435 | { |
| 436 | SurfaceDeletion* deletion(increment->mutable_surface_deletion()); |
| 437 | deletion->set_id(getLayerId(layer)); |
| 438 | } |
| 439 | |
| 440 | void SurfaceInterceptor::addBufferUpdateLocked(Increment* increment, const sp<const Layer>& layer, |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 441 | uint32_t width, uint32_t height, uint64_t frameNumber) |
| 442 | { |
| 443 | BufferUpdate* update(increment->mutable_buffer_update()); |
| 444 | update->set_id(getLayerId(layer)); |
| 445 | update->set_w(width); |
| 446 | update->set_h(height); |
| 447 | update->set_frame_number(frameNumber); |
| 448 | } |
| 449 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 450 | void SurfaceInterceptor::addVSyncUpdateLocked(Increment* increment, nsecs_t timestamp) { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 451 | VSyncEvent* event(increment->mutable_vsync_event()); |
| 452 | event->set_when(timestamp); |
| 453 | } |
| 454 | |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 455 | void SurfaceInterceptor::addDisplaySurfaceLocked(Transaction* transaction, int32_t sequenceId, |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 456 | const sp<const IGraphicBufferProducer>& surface) |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 457 | { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 458 | if (surface == nullptr) { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 459 | return; |
| 460 | } |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 461 | uint64_t bufferQueueId = 0; |
| 462 | status_t err(surface->getUniqueId(&bufferQueueId)); |
| 463 | if (err == NO_ERROR) { |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 464 | DisplayChange* dispChange(createDisplayChangeLocked(transaction, sequenceId)); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 465 | DispSurfaceChange* surfaceChange(dispChange->mutable_surface()); |
| 466 | surfaceChange->set_buffer_queue_id(bufferQueueId); |
| 467 | surfaceChange->set_buffer_queue_name(surface->getConsumerName().string()); |
| 468 | } |
| 469 | else { |
| 470 | ALOGE("invalid graphic buffer producer received while tracing a display change (%s)", |
| 471 | strerror(-err)); |
| 472 | } |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 473 | } |
| 474 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 475 | void SurfaceInterceptor::addDisplayLayerStackLocked(Transaction* transaction, |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 476 | int32_t sequenceId, uint32_t layerStack) |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 477 | { |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 478 | DisplayChange* dispChange(createDisplayChangeLocked(transaction, sequenceId)); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 479 | LayerStackChange* layerStackChange(dispChange->mutable_layer_stack()); |
| 480 | layerStackChange->set_layer_stack(layerStack); |
| 481 | } |
| 482 | |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 483 | void SurfaceInterceptor::addDisplaySizeLocked(Transaction* transaction, int32_t sequenceId, |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 484 | uint32_t w, uint32_t h) |
| 485 | { |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 486 | DisplayChange* dispChange(createDisplayChangeLocked(transaction, sequenceId)); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 487 | SizeChange* sizeChange(dispChange->mutable_size()); |
| 488 | sizeChange->set_w(w); |
| 489 | sizeChange->set_h(h); |
| 490 | } |
| 491 | |
| 492 | void SurfaceInterceptor::addDisplayProjectionLocked(Transaction* transaction, |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 493 | int32_t sequenceId, int32_t orientation, const Rect& viewport, const Rect& frame) |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 494 | { |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 495 | DisplayChange* dispChange(createDisplayChangeLocked(transaction, sequenceId)); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 496 | ProjectionChange* projectionChange(dispChange->mutable_projection()); |
| 497 | projectionChange->set_orientation(orientation); |
| 498 | Rectangle* viewportRect(projectionChange->mutable_viewport()); |
| 499 | setProtoRectLocked(viewportRect, viewport); |
| 500 | Rectangle* frameRect(projectionChange->mutable_frame()); |
| 501 | setProtoRectLocked(frameRect, frame); |
| 502 | } |
| 503 | |
| 504 | void SurfaceInterceptor::addDisplayCreationLocked(Increment* increment, |
| 505 | const DisplayDeviceState& info) |
| 506 | { |
| 507 | DisplayCreation* creation(increment->mutable_display_creation()); |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 508 | creation->set_id(info.sequenceId); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 509 | creation->set_name(info.displayName); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 510 | creation->set_is_secure(info.isSecure); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 511 | if (info.displayId) { |
Dominik Laskowski | 3415776 | 2018-10-31 13:07:19 -0700 | [diff] [blame] | 512 | creation->set_display_id(info.displayId->value); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 513 | } |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 514 | } |
| 515 | |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 516 | void SurfaceInterceptor::addDisplayDeletionLocked(Increment* increment, int32_t sequenceId) { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 517 | DisplayDeletion* deletion(increment->mutable_display_deletion()); |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 518 | deletion->set_id(sequenceId); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 519 | } |
| 520 | |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 521 | void SurfaceInterceptor::addPowerModeUpdateLocked(Increment* increment, int32_t sequenceId, |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 522 | int32_t mode) |
| 523 | { |
| 524 | PowerModeUpdate* powerModeUpdate(increment->mutable_power_mode_update()); |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 525 | powerModeUpdate->set_id(sequenceId); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 526 | powerModeUpdate->set_mode(mode); |
| 527 | } |
| 528 | |
| 529 | void SurfaceInterceptor::saveTransaction(const Vector<ComposerState>& stateUpdates, |
| 530 | const DefaultKeyedVector< wp<IBinder>, DisplayDeviceState>& displays, |
| 531 | const Vector<DisplayState>& changedDisplays, uint32_t flags) |
| 532 | { |
| 533 | if (!mEnabled || (stateUpdates.size() <= 0 && changedDisplays.size() <= 0)) { |
| 534 | return; |
| 535 | } |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 536 | ATRACE_CALL(); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 537 | std::lock_guard<std::mutex> protoGuard(mTraceMutex); |
| 538 | addTransactionLocked(createTraceIncrementLocked(), stateUpdates, displays, changedDisplays, |
| 539 | flags); |
| 540 | } |
| 541 | |
| 542 | void SurfaceInterceptor::saveSurfaceCreation(const sp<const Layer>& layer) { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 543 | if (!mEnabled || layer == nullptr) { |
| 544 | return; |
| 545 | } |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 546 | ATRACE_CALL(); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 547 | std::lock_guard<std::mutex> protoGuard(mTraceMutex); |
| 548 | addSurfaceCreationLocked(createTraceIncrementLocked(), layer); |
| 549 | } |
| 550 | |
| 551 | void SurfaceInterceptor::saveSurfaceDeletion(const sp<const Layer>& layer) { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 552 | if (!mEnabled || layer == nullptr) { |
| 553 | return; |
| 554 | } |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 555 | ATRACE_CALL(); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 556 | std::lock_guard<std::mutex> protoGuard(mTraceMutex); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 557 | addSurfaceDeletionLocked(createTraceIncrementLocked(), layer); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | void SurfaceInterceptor::saveBufferUpdate(const sp<const Layer>& layer, uint32_t width, |
| 561 | uint32_t height, uint64_t frameNumber) |
| 562 | { |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 563 | if (!mEnabled || layer == nullptr) { |
| 564 | return; |
| 565 | } |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 566 | ATRACE_CALL(); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 567 | std::lock_guard<std::mutex> protoGuard(mTraceMutex); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 568 | addBufferUpdateLocked(createTraceIncrementLocked(), layer, width, height, frameNumber); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | void SurfaceInterceptor::saveVSyncEvent(nsecs_t timestamp) { |
| 572 | if (!mEnabled) { |
| 573 | return; |
| 574 | } |
| 575 | std::lock_guard<std::mutex> protoGuard(mTraceMutex); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 576 | addVSyncUpdateLocked(createTraceIncrementLocked(), timestamp); |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 577 | } |
| 578 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 579 | void SurfaceInterceptor::saveDisplayCreation(const DisplayDeviceState& info) { |
| 580 | if (!mEnabled) { |
| 581 | return; |
| 582 | } |
| 583 | ATRACE_CALL(); |
| 584 | std::lock_guard<std::mutex> protoGuard(mTraceMutex); |
| 585 | addDisplayCreationLocked(createTraceIncrementLocked(), info); |
| 586 | } |
| 587 | |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 588 | void SurfaceInterceptor::saveDisplayDeletion(int32_t sequenceId) { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 589 | if (!mEnabled) { |
| 590 | return; |
| 591 | } |
| 592 | ATRACE_CALL(); |
| 593 | std::lock_guard<std::mutex> protoGuard(mTraceMutex); |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 594 | addDisplayDeletionLocked(createTraceIncrementLocked(), sequenceId); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 595 | } |
| 596 | |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 597 | void SurfaceInterceptor::savePowerModeUpdate(int32_t sequenceId, int32_t mode) { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 598 | if (!mEnabled) { |
| 599 | return; |
| 600 | } |
| 601 | ATRACE_CALL(); |
| 602 | std::lock_guard<std::mutex> protoGuard(mTraceMutex); |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 603 | addPowerModeUpdateLocked(createTraceIncrementLocked(), sequenceId, mode); |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 604 | } |
| 605 | |
Lloyd Pique | 4dccc41 | 2018-01-22 17:21:36 -0800 | [diff] [blame] | 606 | } // namespace impl |
Irvel | c274c63 | 2016-06-13 16:44:08 -0700 | [diff] [blame] | 607 | } // namespace android |