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