• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2023 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
17syntax = "proto2";
18
19package perfetto.protos;
20
21import "protos/perfetto/trace/android/surfaceflinger_common.proto";
22import "protos/perfetto/trace/android/graphics/rect.proto";
23
24// Message used by Winscope to process legacy trace files.
25// Represents a file full of surface flinger transactions.
26// Encoded, it should start with 0x54 0x4E 0x58 0x54 0x52 0x41 0x43 0x45
27// (.TNXTRACE), such that they can be easily identified.
28message TransactionTraceFile {
29  // constant; MAGIC_NUMBER = (long) MAGIC_NUMBER_H << 32 |
30  // MagicNumber.MAGIC_NUMBER_L (this is needed because enums have to be 32 bits
31  // and there's no nice way to put 64bit constants into .proto files.
32  enum MagicNumber {
33    INVALID = 0;
34    // TNXT (little-endian ASCII)
35    MAGIC_NUMBER_L = 0x54584E54;
36    // RACE (little-endian ASCII)
37    MAGIC_NUMBER_H = 0x45434152;
38  }
39
40  // Must be the first field, set to value in MagicNumber
41  optional fixed64 magic_number = 1;
42  repeated TransactionTraceEntry entry = 2;
43
44  // offset between real-time clock and elapsed time clock in nanoseconds.
45  // Calculated as: systemTime(SYSTEM_TIME_REALTIME) -
46  // systemTime(SYSTEM_TIME_MONOTONIC)
47  optional fixed64 real_to_elapsed_time_offset_nanos = 3;
48  optional uint32 version = 4;
49}
50
51message TransactionTraceEntry {
52  optional int64 elapsed_realtime_nanos = 1;
53  optional int64 vsync_id = 2;
54  repeated TransactionState transactions = 3;
55  repeated LayerCreationArgs added_layers = 4;
56  repeated uint32 destroyed_layers = 5;
57  repeated DisplayState added_displays = 6;
58  repeated int32 removed_displays = 7;
59  repeated uint32 destroyed_layer_handles = 8;
60  optional bool displays_changed = 9;
61  repeated DisplayInfo displays = 10;
62}
63
64message DisplayInfo {
65  optional uint32 layer_stack = 1;
66  optional int32 display_id = 2;
67  optional int32 logical_width = 3;
68  optional int32 logical_height = 4;
69  optional Transform transform_inverse = 5;
70  optional Transform transform = 6;
71  optional bool receives_input = 7;
72  optional bool is_secure = 8;
73  optional bool is_primary = 9;
74  optional bool is_virtual = 10;
75  optional int32 rotation_flags = 11;
76  optional int32 transform_hint = 12;
77}
78
79message LayerCreationArgs {
80  optional uint32 layer_id = 1;
81  optional string name = 2;
82  optional uint32 flags = 3;
83  optional uint32 parent_id = 4;
84  optional uint32 mirror_from_id = 5;
85  optional bool add_to_root = 6;
86  optional uint32 layer_stack_to_mirror = 7;
87}
88
89message Transform {
90  optional float dsdx = 1;
91  optional float dtdx = 2;
92  optional float dtdy = 3;
93  optional float dsdy = 4;
94  optional float tx = 5;
95  optional float ty = 6;
96}
97
98message TransactionState {
99  optional int32 pid = 1;
100  optional int32 uid = 2;
101  optional int64 vsync_id = 3;
102  optional int32 input_event_id = 4;
103  optional int64 post_time = 5;
104  optional uint64 transaction_id = 6;
105  repeated LayerState layer_changes = 7;
106  repeated DisplayState display_changes = 8;
107  repeated uint64 merged_transaction_ids = 9;
108}
109
110// Keep insync with layer_state_t
111message LayerState {
112  optional uint32 layer_id = 1;
113  // Changes are split into ChangesLsb and ChangesMsb. First 32 bits are in
114  // ChangesLsb and the next 32 bits are in ChangesMsb. This is needed because
115  // enums have to be 32 bits and there's no nice way to put 64bit constants
116  // into .proto files.
117  enum ChangesLsb {
118    eChangesLsbNone = 0;
119    ePositionChanged = 0x00000001;
120    eLayerChanged = 0x00000002;
121    // unused = 0x00000004;
122    eAlphaChanged = 0x00000008;
123
124    eMatrixChanged = 0x00000010;
125    eTransparentRegionChanged = 0x00000020;
126    eFlagsChanged = 0x00000040;
127    eLayerStackChanged = 0x00000080;
128
129    eReleaseBufferListenerChanged = 0x00000400;
130    eShadowRadiusChanged = 0x00000800;
131
132    eBufferCropChanged = 0x00002000;
133    eRelativeLayerChanged = 0x00004000;
134    eReparent = 0x00008000;
135
136    eColorChanged = 0x00010000;
137    eBufferTransformChanged = 0x00040000;
138    eTransformToDisplayInverseChanged = 0x00080000;
139
140    eCropChanged = 0x00100000;
141    eBufferChanged = 0x00200000;
142    eAcquireFenceChanged = 0x00400000;
143    eDataspaceChanged = 0x00800000;
144
145    eHdrMetadataChanged = 0x01000000;
146    eSurfaceDamageRegionChanged = 0x02000000;
147    eApiChanged = 0x04000000;
148    eSidebandStreamChanged = 0x08000000;
149
150    eColorTransformChanged = 0x10000000;
151    eHasListenerCallbacksChanged = 0x20000000;
152    eInputInfoChanged = 0x40000000;
153    // 0x80000000; (proto stores enums as signed int)
154    eCornerRadiusChanged = -2147483648;
155  };
156  enum ChangesMsb {
157    eChangesMsbNone = 0;
158    eDestinationFrameChanged = 0x1;
159    eCachedBufferChanged = 0x2;
160    eBackgroundColorChanged = 0x4;
161    eMetadataChanged = 0x8;
162    eColorSpaceAgnosticChanged = 0x10;
163    eFrameRateSelectionPriority = 0x20;
164    eFrameRateChanged = 0x40;
165    eBackgroundBlurRadiusChanged = 0x80;
166    eProducerDisconnect = 0x100;
167    eFixedTransformHintChanged = 0x200;
168    eFrameNumberChanged = 0x400;
169    eBlurRegionsChanged = 0x800;
170    eAutoRefreshChanged = 0x1000;
171    eStretchChanged = 0x2000;
172    eTrustedOverlayChanged = 0x4000;
173    eDropInputModeChanged = 0x8000;
174  };
175  optional uint64 what = 2;
176  optional float x = 3;
177  optional float y = 4;
178  optional int32 z = 5;
179  optional uint32 w = 6;
180  optional uint32 h = 7;
181  optional uint32 layer_stack = 8;
182
183  enum Flags {
184    eFlagsNone = 0;
185    eLayerHidden = 0x01;
186    eLayerOpaque = 0x02;
187    eLayerSkipScreenshot = 0x40;
188    eLayerSecure = 0x80;
189    eEnableBackpressure = 0x100;
190    eLayerIsDisplayDecoration = 0x200;
191  };
192  optional uint32 flags = 9;
193  optional uint32 mask = 10;
194
195  message Matrix22 {
196    optional float dsdx = 1;
197    optional float dtdx = 2;
198    optional float dtdy = 3;
199    optional float dsdy = 4;
200  };
201  optional Matrix22 matrix = 11;
202  optional float corner_radius = 12;
203  optional uint32 background_blur_radius = 13;
204  optional uint32 parent_id = 14;
205  optional uint32 relative_parent_id = 15;
206
207  optional float alpha = 16;
208  message Color3 {
209    optional float r = 1;
210    optional float g = 2;
211    optional float b = 3;
212  }
213  optional Color3 color = 17;
214  optional RegionProto transparent_region = 18;
215  optional uint32 transform = 19;
216  optional bool transform_to_display_inverse = 20;
217  optional RectProto crop = 21;
218
219  message BufferData {
220    optional uint64 buffer_id = 1;
221    optional uint32 width = 2;
222    optional uint32 height = 3;
223    optional uint64 frame_number = 4;
224
225    enum BufferDataChange {
226      BufferDataChangeNone = 0;
227      fenceChanged = 0x01;
228      frameNumberChanged = 0x02;
229      cachedBufferChanged = 0x04;
230    }
231    optional uint32 flags = 5;
232    optional uint64 cached_buffer_id = 6;
233
234    enum PixelFormat {
235      PIXEL_FORMAT_UNKNOWN = 0;
236      PIXEL_FORMAT_CUSTOM = -4;
237      PIXEL_FORMAT_TRANSLUCENT = -3;
238      PIXEL_FORMAT_TRANSPARENT = -2;
239      PIXEL_FORMAT_OPAQUE = -1;
240      PIXEL_FORMAT_RGBA_8888 = 1;
241      PIXEL_FORMAT_RGBX_8888 = 2;
242      PIXEL_FORMAT_RGB_888 = 3;
243      PIXEL_FORMAT_RGB_565 = 4;
244      PIXEL_FORMAT_BGRA_8888 = 5;
245      PIXEL_FORMAT_RGBA_5551 = 6;
246      PIXEL_FORMAT_RGBA_4444 = 7;
247      PIXEL_FORMAT_RGBA_FP16 = 22;
248      PIXEL_FORMAT_RGBA_1010102 = 43;
249      PIXEL_FORMAT_R_8 = 0x38;
250    }
251    optional PixelFormat pixel_format = 7;
252    optional uint64 usage = 8;
253  }
254  optional BufferData buffer_data = 22;
255  optional int32 api = 23;
256  optional bool has_sideband_stream = 24;
257  optional ColorTransformProto color_transform = 25;
258  repeated BlurRegion blur_regions = 26;
259
260  message WindowInfo {
261    optional uint32 layout_params_flags = 1;
262    optional int32 layout_params_type = 2;
263    optional RegionProto touchable_region = 3;
264    optional int32 surface_inset = 4;
265    // unused
266    optional bool focusable = 5;
267    // unused
268    optional bool has_wallpaper = 6;
269    optional float global_scale_factor = 7;
270    optional uint32 crop_layer_id = 8;
271    optional bool replace_touchable_region_with_crop = 9;
272    optional RectProto touchable_region_crop = 10;
273    optional Transform transform = 11;
274    optional uint32 input_config = 12;
275  }
276  optional WindowInfo window_info_handle = 27;
277  optional float bg_color_alpha = 28;
278  optional int32 bg_color_dataspace = 29;
279  optional bool color_space_agnostic = 30;
280  optional float shadow_radius = 31;
281  optional int32 frame_rate_selection_priority = 32;
282  optional float frame_rate = 33;
283  optional int32 frame_rate_compatibility = 34;
284  optional int32 change_frame_rate_strategy = 35;
285  optional uint32 fixed_transform_hint = 36;
286  optional uint64 frame_number = 37;
287  optional bool auto_refresh = 38;
288  // unused
289  optional bool is_trusted_overlay = 39;
290  optional RectProto buffer_crop = 40;
291  optional RectProto destination_frame = 41;
292
293  enum DropInputMode {
294    NONE = 0;
295    ALL = 1;
296    OBSCURED = 2;
297  };
298  optional DropInputMode drop_input_mode = 42;
299
300  optional TrustedOverlay trusted_overlay = 43;
301}
302
303message DisplayState {
304  enum Changes {
305    eChangesNone = 0;
306    eSurfaceChanged = 0x01;
307    eLayerStackChanged = 0x02;
308    eDisplayProjectionChanged = 0x04;
309    eDisplaySizeChanged = 0x08;
310    eFlagsChanged = 0x10;
311  };
312  optional int32 id = 1;
313  optional uint32 what = 2;
314  optional uint32 flags = 3;
315  optional uint32 layer_stack = 4;
316  optional uint32 orientation = 5;
317  optional RectProto layer_stack_space_rect = 6;
318  optional RectProto oriented_display_space_rect = 7;
319  optional uint32 width = 8;
320  optional uint32 height = 9;
321}
322