Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 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 | #include <gui/SurfaceComposerClient.h> |
Vishnu Nair | 8eebba4 | 2022-02-25 07:57:15 -0800 | [diff] [blame] | 18 | #include <ui/Fence.h> |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 19 | #include <ui/Rect.h> |
| 20 | |
| 21 | #include "LayerProtoHelper.h" |
| 22 | #include "TransactionProtoParser.h" |
| 23 | |
| 24 | namespace android::surfaceflinger { |
| 25 | |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 26 | proto::TransactionState TransactionProtoParser::toProto(const TransactionState& t) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 27 | proto::TransactionState proto; |
| 28 | proto.set_pid(t.originPid); |
| 29 | proto.set_uid(t.originUid); |
| 30 | proto.set_vsync_id(t.frameTimelineInfo.vsyncId); |
| 31 | proto.set_input_event_id(t.frameTimelineInfo.inputEventId); |
| 32 | proto.set_post_time(t.postTime); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 33 | proto.set_transaction_id(t.id); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 34 | |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 35 | proto.mutable_layer_changes()->Reserve(static_cast<int32_t>(t.states.size())); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 36 | for (auto& layerState : t.states) { |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 37 | proto.mutable_layer_changes()->Add(std::move(toProto(layerState.state))); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 38 | } |
| 39 | |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 40 | proto.mutable_display_changes()->Reserve(static_cast<int32_t>(t.displays.size())); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 41 | for (auto& displayState : t.displays) { |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 42 | proto.mutable_display_changes()->Add(std::move(toProto(displayState))); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 43 | } |
| 44 | return proto; |
| 45 | } |
| 46 | |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 47 | proto::TransactionState TransactionProtoParser::toProto( |
Greg Kaiser | 2c90985 | 2021-12-07 09:45:29 -0800 | [diff] [blame] | 48 | const std::map<int32_t /* layerId */, TracingLayerState>& states) { |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 49 | proto::TransactionState proto; |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 50 | proto.mutable_layer_changes()->Reserve(static_cast<int32_t>(states.size())); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 51 | for (auto& [layerId, state] : states) { |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 52 | proto::LayerState layerProto = toProto(state); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 53 | if (layerProto.has_buffer_data()) { |
| 54 | proto::LayerState_BufferData* bufferProto = layerProto.mutable_buffer_data(); |
| 55 | bufferProto->set_buffer_id(state.bufferId); |
| 56 | bufferProto->set_width(state.bufferWidth); |
| 57 | bufferProto->set_height(state.bufferHeight); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 58 | bufferProto->set_pixel_format( |
| 59 | static_cast<proto::LayerState_BufferData_PixelFormat>(state.pixelFormat)); |
| 60 | bufferProto->set_usage(state.bufferUsage); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 61 | } |
| 62 | layerProto.set_has_sideband_stream(state.hasSidebandStream); |
| 63 | layerProto.set_layer_id(state.layerId); |
| 64 | layerProto.set_parent_id(state.parentId); |
| 65 | layerProto.set_relative_parent_id(state.relativeParentId); |
| 66 | if (layerProto.has_window_info_handle()) { |
| 67 | layerProto.mutable_window_info_handle()->set_crop_layer_id(state.inputCropId); |
| 68 | } |
| 69 | proto.mutable_layer_changes()->Add(std::move(layerProto)); |
| 70 | } |
| 71 | return proto; |
| 72 | } |
| 73 | |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 74 | proto::LayerState TransactionProtoParser::toProto(const layer_state_t& layer) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 75 | proto::LayerState proto; |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 76 | if (layer.surface) { |
| 77 | proto.set_layer_id(mMapper->getLayerId(layer.surface)); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 78 | } else { |
| 79 | proto.set_layer_id(layer.layerId); |
| 80 | } |
| 81 | |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 82 | proto.set_what(layer.what); |
| 83 | |
| 84 | if (layer.what & layer_state_t::ePositionChanged) { |
| 85 | proto.set_x(layer.x); |
| 86 | proto.set_y(layer.y); |
| 87 | } |
| 88 | if (layer.what & layer_state_t::eLayerChanged) { |
| 89 | proto.set_z(layer.z); |
| 90 | } |
Vishnu Nair | ea04b6f | 2022-08-19 21:28:17 +0000 | [diff] [blame] | 91 | |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 92 | if (layer.what & layer_state_t::eLayerStackChanged) { |
| 93 | proto.set_layer_stack(layer.layerStack.id); |
| 94 | } |
| 95 | if (layer.what & layer_state_t::eFlagsChanged) { |
| 96 | proto.set_flags(layer.flags); |
| 97 | proto.set_mask(layer.mask); |
| 98 | } |
| 99 | if (layer.what & layer_state_t::eMatrixChanged) { |
| 100 | proto::LayerState_Matrix22* matrixProto = proto.mutable_matrix(); |
| 101 | matrixProto->set_dsdx(layer.matrix.dsdx); |
| 102 | matrixProto->set_dsdy(layer.matrix.dsdy); |
| 103 | matrixProto->set_dtdx(layer.matrix.dtdx); |
| 104 | matrixProto->set_dtdy(layer.matrix.dtdy); |
| 105 | } |
| 106 | if (layer.what & layer_state_t::eCornerRadiusChanged) { |
| 107 | proto.set_corner_radius(layer.cornerRadius); |
| 108 | } |
| 109 | if (layer.what & layer_state_t::eBackgroundBlurRadiusChanged) { |
| 110 | proto.set_background_blur_radius(layer.backgroundBlurRadius); |
| 111 | } |
| 112 | |
| 113 | if (layer.what & layer_state_t::eAlphaChanged) { |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame^] | 114 | proto.set_alpha(layer.color.a); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | if (layer.what & layer_state_t::eColorChanged) { |
| 118 | proto::LayerState_Color3* colorProto = proto.mutable_color(); |
| 119 | colorProto->set_r(layer.color.r); |
| 120 | colorProto->set_g(layer.color.g); |
| 121 | colorProto->set_b(layer.color.b); |
| 122 | } |
| 123 | if (layer.what & layer_state_t::eTransparentRegionChanged) { |
| 124 | LayerProtoHelper::writeToProto(layer.transparentRegion, proto.mutable_transparent_region()); |
| 125 | } |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame^] | 126 | if (layer.what & layer_state_t::eBufferTransformChanged) { |
| 127 | proto.set_transform(layer.bufferTransform); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 128 | } |
| 129 | if (layer.what & layer_state_t::eTransformToDisplayInverseChanged) { |
| 130 | proto.set_transform_to_display_inverse(layer.transformToDisplayInverse); |
| 131 | } |
| 132 | if (layer.what & layer_state_t::eCropChanged) { |
| 133 | LayerProtoHelper::writeToProto(layer.crop, proto.mutable_crop()); |
| 134 | } |
| 135 | if (layer.what & layer_state_t::eBufferChanged) { |
| 136 | proto::LayerState_BufferData* bufferProto = proto.mutable_buffer_data(); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 137 | if (layer.bufferData->hasBuffer()) { |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 138 | bufferProto->set_buffer_id(layer.bufferData->getId()); |
| 139 | bufferProto->set_width(layer.bufferData->getWidth()); |
| 140 | bufferProto->set_height(layer.bufferData->getHeight()); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 141 | bufferProto->set_pixel_format(static_cast<proto::LayerState_BufferData_PixelFormat>( |
| 142 | layer.bufferData->getPixelFormat())); |
| 143 | bufferProto->set_usage(layer.bufferData->getUsage()); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 144 | } else { |
| 145 | uint64_t bufferId; |
| 146 | uint32_t width; |
| 147 | uint32_t height; |
| 148 | int32_t pixelFormat; |
| 149 | uint64_t usage; |
| 150 | mMapper->getGraphicBufferPropertiesFromCache(layer.bufferData->cachedBuffer, &bufferId, |
| 151 | &width, &height, &pixelFormat, &usage); |
| 152 | bufferProto->set_buffer_id(bufferId); |
| 153 | bufferProto->set_width(width); |
| 154 | bufferProto->set_height(height); |
| 155 | bufferProto->set_pixel_format( |
| 156 | static_cast<proto::LayerState_BufferData_PixelFormat>(pixelFormat)); |
| 157 | bufferProto->set_usage(usage); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 158 | } |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 159 | bufferProto->set_frame_number(layer.bufferData->frameNumber); |
| 160 | bufferProto->set_flags(layer.bufferData->flags.get()); |
| 161 | bufferProto->set_cached_buffer_id(layer.bufferData->cachedBuffer.id); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 162 | } |
| 163 | if (layer.what & layer_state_t::eSidebandStreamChanged) { |
| 164 | proto.set_has_sideband_stream(layer.sidebandStream != nullptr); |
| 165 | } |
| 166 | |
| 167 | if (layer.what & layer_state_t::eApiChanged) { |
| 168 | proto.set_api(layer.api); |
| 169 | } |
| 170 | |
| 171 | if (layer.what & layer_state_t::eColorTransformChanged) { |
| 172 | LayerProtoHelper::writeToProto(layer.colorTransform, proto.mutable_color_transform()); |
| 173 | } |
| 174 | if (layer.what & layer_state_t::eBlurRegionsChanged) { |
| 175 | for (auto& region : layer.blurRegions) { |
| 176 | LayerProtoHelper::writeToProto(region, proto.add_blur_regions()); |
| 177 | } |
| 178 | } |
| 179 | |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 180 | if (layer.what & layer_state_t::eReparent) { |
Robert Carr | a63d52a | 2022-03-03 08:03:37 -0800 | [diff] [blame] | 181 | int64_t layerId = layer.parentSurfaceControlForChild |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 182 | ? mMapper->getLayerId(layer.parentSurfaceControlForChild->getHandle()) |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 183 | : -1; |
| 184 | proto.set_parent_id(layerId); |
| 185 | } |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 186 | if (layer.what & layer_state_t::eRelativeLayerChanged) { |
Robert Carr | a63d52a | 2022-03-03 08:03:37 -0800 | [diff] [blame] | 187 | int64_t layerId = layer.relativeLayerSurfaceControl |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 188 | ? mMapper->getLayerId(layer.relativeLayerSurfaceControl->getHandle()) |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 189 | : -1; |
| 190 | proto.set_relative_parent_id(layerId); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 191 | proto.set_z(layer.z); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | if (layer.what & layer_state_t::eInputInfoChanged) { |
| 195 | if (layer.windowInfoHandle) { |
| 196 | const gui::WindowInfo* inputInfo = layer.windowInfoHandle->getInfo(); |
| 197 | proto::LayerState_WindowInfo* windowInfoProto = proto.mutable_window_info_handle(); |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 198 | windowInfoProto->set_layout_params_flags(inputInfo->layoutParamsFlags.get()); |
| 199 | windowInfoProto->set_layout_params_type( |
| 200 | static_cast<int32_t>(inputInfo->layoutParamsType)); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 201 | LayerProtoHelper::writeToProto(inputInfo->touchableRegion, |
| 202 | windowInfoProto->mutable_touchable_region()); |
| 203 | windowInfoProto->set_surface_inset(inputInfo->surfaceInset); |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 204 | windowInfoProto->set_focusable( |
| 205 | !inputInfo->inputConfig.test(gui::WindowInfo::InputConfig::NOT_FOCUSABLE)); |
| 206 | windowInfoProto->set_has_wallpaper(inputInfo->inputConfig.test( |
| 207 | gui::WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER)); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 208 | windowInfoProto->set_global_scale_factor(inputInfo->globalScaleFactor); |
| 209 | proto::LayerState_Transform* transformProto = windowInfoProto->mutable_transform(); |
| 210 | transformProto->set_dsdx(inputInfo->transform.dsdx()); |
| 211 | transformProto->set_dtdx(inputInfo->transform.dtdx()); |
| 212 | transformProto->set_dtdy(inputInfo->transform.dtdy()); |
| 213 | transformProto->set_dsdy(inputInfo->transform.dsdy()); |
| 214 | transformProto->set_tx(inputInfo->transform.tx()); |
| 215 | transformProto->set_ty(inputInfo->transform.ty()); |
| 216 | windowInfoProto->set_replace_touchable_region_with_crop( |
| 217 | inputInfo->replaceTouchableRegionWithCrop); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 218 | windowInfoProto->set_crop_layer_id( |
| 219 | mMapper->getLayerId(inputInfo->touchableRegionCropHandle.promote())); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 220 | } |
| 221 | } |
| 222 | if (layer.what & layer_state_t::eBackgroundColorChanged) { |
| 223 | proto.set_bg_color_alpha(layer.bgColorAlpha); |
| 224 | proto.set_bg_color_dataspace(static_cast<int32_t>(layer.bgColorDataspace)); |
| 225 | proto::LayerState_Color3* colorProto = proto.mutable_color(); |
| 226 | colorProto->set_r(layer.color.r); |
| 227 | colorProto->set_g(layer.color.g); |
| 228 | colorProto->set_b(layer.color.b); |
| 229 | } |
| 230 | if (layer.what & layer_state_t::eColorSpaceAgnosticChanged) { |
| 231 | proto.set_color_space_agnostic(layer.colorSpaceAgnostic); |
| 232 | } |
| 233 | if (layer.what & layer_state_t::eShadowRadiusChanged) { |
| 234 | proto.set_shadow_radius(layer.shadowRadius); |
| 235 | } |
| 236 | if (layer.what & layer_state_t::eFrameRateSelectionPriority) { |
| 237 | proto.set_frame_rate_selection_priority(layer.frameRateSelectionPriority); |
| 238 | } |
| 239 | if (layer.what & layer_state_t::eFrameRateChanged) { |
| 240 | proto.set_frame_rate(layer.frameRate); |
| 241 | proto.set_frame_rate_compatibility(layer.frameRateCompatibility); |
| 242 | proto.set_change_frame_rate_strategy(layer.changeFrameRateStrategy); |
| 243 | } |
| 244 | if (layer.what & layer_state_t::eFixedTransformHintChanged) { |
| 245 | proto.set_fixed_transform_hint(layer.fixedTransformHint); |
| 246 | } |
| 247 | if (layer.what & layer_state_t::eAutoRefreshChanged) { |
| 248 | proto.set_auto_refresh(layer.autoRefresh); |
| 249 | } |
| 250 | if (layer.what & layer_state_t::eTrustedOverlayChanged) { |
| 251 | proto.set_is_trusted_overlay(layer.isTrustedOverlay); |
| 252 | } |
| 253 | if (layer.what & layer_state_t::eBufferCropChanged) { |
| 254 | LayerProtoHelper::writeToProto(layer.bufferCrop, proto.mutable_buffer_crop()); |
| 255 | } |
| 256 | if (layer.what & layer_state_t::eDestinationFrameChanged) { |
| 257 | LayerProtoHelper::writeToProto(layer.destinationFrame, proto.mutable_destination_frame()); |
| 258 | } |
| 259 | if (layer.what & layer_state_t::eDropInputModeChanged) { |
| 260 | proto.set_drop_input_mode( |
| 261 | static_cast<proto::LayerState_DropInputMode>(layer.dropInputMode)); |
| 262 | } |
| 263 | return proto; |
| 264 | } |
| 265 | |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 266 | proto::DisplayState TransactionProtoParser::toProto(const DisplayState& display) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 267 | proto::DisplayState proto; |
| 268 | proto.set_what(display.what); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 269 | proto.set_id(mMapper->getDisplayId(display.token)); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 270 | |
| 271 | if (display.what & DisplayState::eLayerStackChanged) { |
| 272 | proto.set_layer_stack(display.layerStack.id); |
| 273 | } |
| 274 | if (display.what & DisplayState::eDisplayProjectionChanged) { |
| 275 | proto.set_orientation(static_cast<uint32_t>(display.orientation)); |
| 276 | LayerProtoHelper::writeToProto(display.orientedDisplaySpaceRect, |
| 277 | proto.mutable_oriented_display_space_rect()); |
| 278 | LayerProtoHelper::writeToProto(display.layerStackSpaceRect, |
| 279 | proto.mutable_layer_stack_space_rect()); |
| 280 | } |
| 281 | if (display.what & DisplayState::eDisplaySizeChanged) { |
| 282 | proto.set_width(display.width); |
| 283 | proto.set_height(display.height); |
| 284 | } |
| 285 | if (display.what & DisplayState::eFlagsChanged) { |
| 286 | proto.set_flags(display.flags); |
| 287 | } |
| 288 | return proto; |
| 289 | } |
| 290 | |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 291 | proto::LayerCreationArgs TransactionProtoParser::toProto(const TracingLayerCreationArgs& args) { |
| 292 | proto::LayerCreationArgs proto; |
| 293 | proto.set_layer_id(args.layerId); |
| 294 | proto.set_name(args.name); |
| 295 | proto.set_flags(args.flags); |
| 296 | proto.set_parent_id(args.parentId); |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 297 | proto.set_mirror_from_id(args.mirrorFromId); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 298 | return proto; |
| 299 | } |
| 300 | |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 301 | TransactionState TransactionProtoParser::fromProto(const proto::TransactionState& proto) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 302 | TransactionState t; |
| 303 | t.originPid = proto.pid(); |
| 304 | t.originUid = proto.uid(); |
| 305 | t.frameTimelineInfo.vsyncId = proto.vsync_id(); |
| 306 | t.frameTimelineInfo.inputEventId = proto.input_event_id(); |
| 307 | t.postTime = proto.post_time(); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 308 | t.id = proto.transaction_id(); |
| 309 | |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 310 | int32_t layerCount = proto.layer_changes_size(); |
| 311 | t.states.reserve(static_cast<size_t>(layerCount)); |
| 312 | for (int i = 0; i < layerCount; i++) { |
| 313 | ComposerState s; |
Vishnu Nair | 7b0f18b | 2022-01-12 16:39:08 -0800 | [diff] [blame] | 314 | s.state.what = 0; |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 315 | fromProto(proto.layer_changes(i), s.state); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 316 | t.states.add(s); |
| 317 | } |
| 318 | |
| 319 | int32_t displayCount = proto.display_changes_size(); |
| 320 | t.displays.reserve(static_cast<size_t>(displayCount)); |
| 321 | for (int i = 0; i < displayCount; i++) { |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 322 | t.displays.add(fromProto(proto.display_changes(i))); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 323 | } |
| 324 | return t; |
| 325 | } |
| 326 | |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 327 | void TransactionProtoParser::fromProto(const proto::LayerCreationArgs& proto, |
| 328 | TracingLayerCreationArgs& outArgs) { |
| 329 | outArgs.layerId = proto.layer_id(); |
| 330 | outArgs.name = proto.name(); |
| 331 | outArgs.flags = proto.flags(); |
| 332 | outArgs.parentId = proto.parent_id(); |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 333 | outArgs.mirrorFromId = proto.mirror_from_id(); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 334 | } |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 335 | |
Vishnu Nair | 7b0f18b | 2022-01-12 16:39:08 -0800 | [diff] [blame] | 336 | void TransactionProtoParser::mergeFromProto(const proto::LayerState& proto, |
Vishnu Nair | 7b0f18b | 2022-01-12 16:39:08 -0800 | [diff] [blame] | 337 | TracingLayerState& outState) { |
| 338 | layer_state_t state; |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 339 | fromProto(proto, state); |
Vishnu Nair | 7b0f18b | 2022-01-12 16:39:08 -0800 | [diff] [blame] | 340 | outState.merge(state); |
| 341 | |
| 342 | if (state.what & layer_state_t::eReparent) { |
Robert Carr | a63d52a | 2022-03-03 08:03:37 -0800 | [diff] [blame] | 343 | outState.parentId = static_cast<int32_t>(proto.parent_id()); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 344 | } |
Vishnu Nair | 7b0f18b | 2022-01-12 16:39:08 -0800 | [diff] [blame] | 345 | if (state.what & layer_state_t::eRelativeLayerChanged) { |
Robert Carr | a63d52a | 2022-03-03 08:03:37 -0800 | [diff] [blame] | 346 | outState.relativeParentId = static_cast<int32_t>(proto.relative_parent_id()); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 347 | } |
Vishnu Nair | 7b0f18b | 2022-01-12 16:39:08 -0800 | [diff] [blame] | 348 | if (state.what & layer_state_t::eInputInfoChanged) { |
Robert Carr | a63d52a | 2022-03-03 08:03:37 -0800 | [diff] [blame] | 349 | outState.inputCropId = static_cast<int32_t>(proto.window_info_handle().crop_layer_id()); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 350 | } |
Vishnu Nair | 7b0f18b | 2022-01-12 16:39:08 -0800 | [diff] [blame] | 351 | if (state.what & layer_state_t::eBufferChanged) { |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 352 | const proto::LayerState_BufferData& bufferProto = proto.buffer_data(); |
| 353 | outState.bufferId = bufferProto.buffer_id(); |
| 354 | outState.bufferWidth = bufferProto.width(); |
| 355 | outState.bufferHeight = bufferProto.height(); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 356 | outState.pixelFormat = bufferProto.pixel_format(); |
| 357 | outState.bufferUsage = bufferProto.usage(); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 358 | } |
Vishnu Nair | 7b0f18b | 2022-01-12 16:39:08 -0800 | [diff] [blame] | 359 | if (state.what & layer_state_t::eSidebandStreamChanged) { |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 360 | outState.hasSidebandStream = proto.has_sideband_stream(); |
| 361 | } |
| 362 | } |
| 363 | |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 364 | void TransactionProtoParser::fromProto(const proto::LayerState& proto, layer_state_t& layer) { |
Robert Carr | a63d52a | 2022-03-03 08:03:37 -0800 | [diff] [blame] | 365 | layer.layerId = (int32_t)proto.layer_id(); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 366 | layer.what |= proto.what(); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 367 | layer.surface = mMapper->getLayerHandle(layer.layerId); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 368 | |
| 369 | if (proto.what() & layer_state_t::ePositionChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 370 | layer.x = proto.x(); |
| 371 | layer.y = proto.y(); |
| 372 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 373 | if (proto.what() & layer_state_t::eLayerChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 374 | layer.z = proto.z(); |
| 375 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 376 | if (proto.what() & layer_state_t::eLayerStackChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 377 | layer.layerStack.id = proto.layer_stack(); |
| 378 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 379 | if (proto.what() & layer_state_t::eFlagsChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 380 | layer.flags = proto.flags(); |
| 381 | layer.mask = proto.mask(); |
| 382 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 383 | if (proto.what() & layer_state_t::eMatrixChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 384 | const proto::LayerState_Matrix22& matrixProto = proto.matrix(); |
| 385 | layer.matrix.dsdx = matrixProto.dsdx(); |
| 386 | layer.matrix.dsdy = matrixProto.dsdy(); |
| 387 | layer.matrix.dtdx = matrixProto.dtdx(); |
| 388 | layer.matrix.dtdy = matrixProto.dtdy(); |
| 389 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 390 | if (proto.what() & layer_state_t::eCornerRadiusChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 391 | layer.cornerRadius = proto.corner_radius(); |
| 392 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 393 | if (proto.what() & layer_state_t::eBackgroundBlurRadiusChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 394 | layer.backgroundBlurRadius = proto.background_blur_radius(); |
| 395 | } |
| 396 | |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 397 | if (proto.what() & layer_state_t::eAlphaChanged) { |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame^] | 398 | layer.color.a = proto.alpha(); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 399 | } |
| 400 | |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 401 | if (proto.what() & layer_state_t::eColorChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 402 | const proto::LayerState_Color3& colorProto = proto.color(); |
| 403 | layer.color.r = colorProto.r(); |
| 404 | layer.color.g = colorProto.g(); |
| 405 | layer.color.b = colorProto.b(); |
| 406 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 407 | if (proto.what() & layer_state_t::eTransparentRegionChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 408 | LayerProtoHelper::readFromProto(proto.transparent_region(), layer.transparentRegion); |
| 409 | } |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame^] | 410 | if (proto.what() & layer_state_t::eBufferTransformChanged) { |
| 411 | layer.bufferTransform = proto.transform(); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 412 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 413 | if (proto.what() & layer_state_t::eTransformToDisplayInverseChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 414 | layer.transformToDisplayInverse = proto.transform_to_display_inverse(); |
| 415 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 416 | if (proto.what() & layer_state_t::eCropChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 417 | LayerProtoHelper::readFromProto(proto.crop(), layer.crop); |
| 418 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 419 | if (proto.what() & layer_state_t::eBufferChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 420 | const proto::LayerState_BufferData& bufferProto = proto.buffer_data(); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 421 | layer.bufferData = |
| 422 | std::move(mMapper->getGraphicData(bufferProto.buffer_id(), bufferProto.width(), |
| 423 | bufferProto.height(), bufferProto.pixel_format(), |
| 424 | bufferProto.usage())); |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 425 | layer.bufferData->frameNumber = bufferProto.frame_number(); |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 426 | layer.bufferData->flags = ftl::Flags<BufferData::BufferDataChange>(bufferProto.flags()); |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 427 | layer.bufferData->cachedBuffer.id = bufferProto.cached_buffer_id(); |
Vishnu Nair | 8eebba4 | 2022-02-25 07:57:15 -0800 | [diff] [blame] | 428 | layer.bufferData->acquireFence = Fence::NO_FENCE; |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 429 | } |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 430 | |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 431 | if (proto.what() & layer_state_t::eApiChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 432 | layer.api = proto.api(); |
| 433 | } |
| 434 | |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 435 | if (proto.what() & layer_state_t::eColorTransformChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 436 | LayerProtoHelper::readFromProto(proto.color_transform(), layer.colorTransform); |
| 437 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 438 | if (proto.what() & layer_state_t::eBlurRegionsChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 439 | layer.blurRegions.reserve(static_cast<size_t>(proto.blur_regions_size())); |
| 440 | for (int i = 0; i < proto.blur_regions_size(); i++) { |
| 441 | android::BlurRegion region; |
| 442 | LayerProtoHelper::readFromProto(proto.blur_regions(i), region); |
| 443 | layer.blurRegions.push_back(region); |
| 444 | } |
| 445 | } |
| 446 | |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 447 | if (proto.what() & layer_state_t::eReparent) { |
Robert Carr | a63d52a | 2022-03-03 08:03:37 -0800 | [diff] [blame] | 448 | int64_t layerId = proto.parent_id(); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 449 | if (layerId == -1) { |
| 450 | layer.parentSurfaceControlForChild = nullptr; |
| 451 | } else { |
| 452 | layer.parentSurfaceControlForChild = |
Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 453 | sp<SurfaceControl>::make(SurfaceComposerClient::getDefault(), |
| 454 | mMapper->getLayerHandle(static_cast<int32_t>(layerId)), |
Patrick Williams | a361de6 | 2022-10-06 20:34:10 +0000 | [diff] [blame] | 455 | static_cast<int32_t>(layerId), ""); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 456 | } |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 457 | } |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 458 | if (proto.what() & layer_state_t::eRelativeLayerChanged) { |
Robert Carr | a63d52a | 2022-03-03 08:03:37 -0800 | [diff] [blame] | 459 | int64_t layerId = proto.relative_parent_id(); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 460 | if (layerId == -1) { |
| 461 | layer.relativeLayerSurfaceControl = nullptr; |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 462 | } else { |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 463 | layer.relativeLayerSurfaceControl = |
Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 464 | sp<SurfaceControl>::make(SurfaceComposerClient::getDefault(), |
| 465 | mMapper->getLayerHandle(static_cast<int32_t>(layerId)), |
Patrick Williams | a361de6 | 2022-10-06 20:34:10 +0000 | [diff] [blame] | 466 | static_cast<int32_t>(layerId), ""); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 467 | } |
| 468 | layer.z = proto.z(); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 469 | } |
| 470 | |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 471 | if ((proto.what() & layer_state_t::eInputInfoChanged) && proto.has_window_info_handle()) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 472 | gui::WindowInfo inputInfo; |
| 473 | const proto::LayerState_WindowInfo& windowInfoProto = proto.window_info_handle(); |
| 474 | |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 475 | inputInfo.layoutParamsFlags = |
| 476 | static_cast<gui::WindowInfo::Flag>(windowInfoProto.layout_params_flags()); |
| 477 | inputInfo.layoutParamsType = |
| 478 | static_cast<gui::WindowInfo::Type>(windowInfoProto.layout_params_type()); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 479 | LayerProtoHelper::readFromProto(windowInfoProto.touchable_region(), |
| 480 | inputInfo.touchableRegion); |
| 481 | inputInfo.surfaceInset = windowInfoProto.surface_inset(); |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 482 | inputInfo.setInputConfig(gui::WindowInfo::InputConfig::NOT_FOCUSABLE, |
| 483 | !windowInfoProto.focusable()); |
| 484 | inputInfo.setInputConfig(gui::WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER, |
| 485 | windowInfoProto.has_wallpaper()); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 486 | inputInfo.globalScaleFactor = windowInfoProto.global_scale_factor(); |
| 487 | const proto::LayerState_Transform& transformProto = windowInfoProto.transform(); |
| 488 | inputInfo.transform.set(transformProto.dsdx(), transformProto.dtdx(), transformProto.dtdy(), |
| 489 | transformProto.dsdy()); |
| 490 | inputInfo.transform.set(transformProto.tx(), transformProto.ty()); |
| 491 | inputInfo.replaceTouchableRegionWithCrop = |
| 492 | windowInfoProto.replace_touchable_region_with_crop(); |
Robert Carr | a63d52a | 2022-03-03 08:03:37 -0800 | [diff] [blame] | 493 | int64_t layerId = windowInfoProto.crop_layer_id(); |
Vishnu Nair | 286f4f9 | 2022-06-08 16:37:39 -0700 | [diff] [blame] | 494 | if (layerId != -1) { |
| 495 | inputInfo.touchableRegionCropHandle = |
| 496 | mMapper->getLayerHandle(static_cast<int32_t>(layerId)); |
| 497 | } else { |
Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 498 | inputInfo.touchableRegionCropHandle = wp<IBinder>(); |
Vishnu Nair | 286f4f9 | 2022-06-08 16:37:39 -0700 | [diff] [blame] | 499 | } |
| 500 | |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 501 | layer.windowInfoHandle = sp<gui::WindowInfoHandle>::make(inputInfo); |
| 502 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 503 | if (proto.what() & layer_state_t::eBackgroundColorChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 504 | layer.bgColorAlpha = proto.bg_color_alpha(); |
| 505 | layer.bgColorDataspace = static_cast<ui::Dataspace>(proto.bg_color_dataspace()); |
| 506 | const proto::LayerState_Color3& colorProto = proto.color(); |
| 507 | layer.color.r = colorProto.r(); |
| 508 | layer.color.g = colorProto.g(); |
| 509 | layer.color.b = colorProto.b(); |
| 510 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 511 | if (proto.what() & layer_state_t::eColorSpaceAgnosticChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 512 | layer.colorSpaceAgnostic = proto.color_space_agnostic(); |
| 513 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 514 | if (proto.what() & layer_state_t::eShadowRadiusChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 515 | layer.shadowRadius = proto.shadow_radius(); |
| 516 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 517 | if (proto.what() & layer_state_t::eFrameRateSelectionPriority) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 518 | layer.frameRateSelectionPriority = proto.frame_rate_selection_priority(); |
| 519 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 520 | if (proto.what() & layer_state_t::eFrameRateChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 521 | layer.frameRate = proto.frame_rate(); |
| 522 | layer.frameRateCompatibility = static_cast<int8_t>(proto.frame_rate_compatibility()); |
| 523 | layer.changeFrameRateStrategy = static_cast<int8_t>(proto.change_frame_rate_strategy()); |
| 524 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 525 | if (proto.what() & layer_state_t::eFixedTransformHintChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 526 | layer.fixedTransformHint = |
| 527 | static_cast<ui::Transform::RotationFlags>(proto.fixed_transform_hint()); |
| 528 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 529 | if (proto.what() & layer_state_t::eAutoRefreshChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 530 | layer.autoRefresh = proto.auto_refresh(); |
| 531 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 532 | if (proto.what() & layer_state_t::eTrustedOverlayChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 533 | layer.isTrustedOverlay = proto.is_trusted_overlay(); |
| 534 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 535 | if (proto.what() & layer_state_t::eBufferCropChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 536 | LayerProtoHelper::readFromProto(proto.buffer_crop(), layer.bufferCrop); |
| 537 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 538 | if (proto.what() & layer_state_t::eDestinationFrameChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 539 | LayerProtoHelper::readFromProto(proto.destination_frame(), layer.destinationFrame); |
| 540 | } |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 541 | if (proto.what() & layer_state_t::eDropInputModeChanged) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 542 | layer.dropInputMode = static_cast<gui::DropInputMode>(proto.drop_input_mode()); |
| 543 | } |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 544 | } |
| 545 | |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 546 | DisplayState TransactionProtoParser::fromProto(const proto::DisplayState& proto) { |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 547 | DisplayState display; |
| 548 | display.what = proto.what(); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 549 | display.token = mMapper->getDisplayHandle(proto.id()); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 550 | |
| 551 | if (display.what & DisplayState::eLayerStackChanged) { |
| 552 | display.layerStack.id = proto.layer_stack(); |
| 553 | } |
| 554 | if (display.what & DisplayState::eDisplayProjectionChanged) { |
| 555 | display.orientation = static_cast<ui::Rotation>(proto.orientation()); |
| 556 | LayerProtoHelper::readFromProto(proto.oriented_display_space_rect(), |
| 557 | display.orientedDisplaySpaceRect); |
| 558 | LayerProtoHelper::readFromProto(proto.layer_stack_space_rect(), |
| 559 | display.layerStackSpaceRect); |
| 560 | } |
| 561 | if (display.what & DisplayState::eDisplaySizeChanged) { |
| 562 | display.width = proto.width(); |
| 563 | display.height = proto.height(); |
| 564 | } |
| 565 | if (display.what & DisplayState::eFlagsChanged) { |
| 566 | display.flags = proto.flags(); |
| 567 | } |
| 568 | return display; |
| 569 | } |
| 570 | |
| 571 | } // namespace android::surfaceflinger |