huangcm
2025-08-30 0269911b91ed7e03c24005924cc6423abf245fb8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
library fuchsia.ui.gfx;
 
// Reports metrics information.
// This event type is only reported for node resources.
const uint32 kMetricsEventMask = 1;
const uint32 kSizeChangeHintEventMask = 2;
 
// These are all of the types of events which can be reported by a |Session|.
// Use |SetEventMaskCmd| to enable event delivery for a resource.
union Event {
  // Events which are controlled by a mask.
  MetricsEvent metrics;
 
  SizeChangeHintEvent size_change_hint;
 
  // Events which are always delivered, regardless of mask.
  ImportUnboundEvent import_unbound;
  ViewConnectedEvent view_connected;
  ViewDisconnectedEvent view_disconnected;
  ViewHolderDisconnectedEvent view_holder_disconnected;
  ViewAttachedToSceneEvent view_attached_to_scene;
  ViewDetachedFromSceneEvent view_detached_from_scene;
  ViewPropertiesChangedEvent view_properties_changed;
  ViewStateChangedEvent view_state_changed;
};
 
// Provides rendering target metrics information about the specified node.
//
// This event is delivered when the following conditions are true:
// - The node is a descendant of a |Scene|.
// - The node has |kMetricsEventMask| set to an enabled state.
// - The node's metrics have changed since they were last delivered, or since
//   |kMetricsEventMask| transitioned from a disabled state to an enabled state.
//
// Subscribe to this event to receive information about the scale factors you
// should apply when generating textures for your nodes.
struct MetricsEvent {
  uint32 node_id;
  Metrics metrics;
};
 
// Delivered in response to a size change hint from a parent node
// (SendSizeChangeHintCmd).
//
// This event is delivered when the following conditions are true:
// - The node has |kSizeChangeEventMask| set to an enabled state.
// - A parent node has sent a SendSizeChangeHintCmd.
//
// Subscribe to this event to receive information about how large textures you
// will need in the near future for your nodes. The canonical use case is to
// pre-allocate memory to avoid repeated re-allocations.
struct SizeChangeHintEvent {
  uint32 node_id;
  float32 width_change_factor;
  float32 height_change_factor;
};
 
// Delivered when the imported resource with the given ID is no longer bound to
// its host resource, or if the imported resource can not be bound because
// the host resource is not available.
struct ImportUnboundEvent {
  uint32 resource_id;
};
 
// Delivered to a ViewHolder's Session when its peer View is connected.
struct ViewConnectedEvent {
  uint32 view_holder_id;
};
 
// Delivered to a ViewHolder's Session when its peer View is disconnected or
// destroyed.
//
// If the View is destroyed before the connection is established, then this
// event will be delivered immediately when the ViewHolder attempts to connect.
struct ViewDisconnectedEvent {
  uint32 view_holder_id;
};
 
// Delivered to a View's Session when its peer ViewHolder is disconnected or
// destroyed.
//
// If the ViewHolder is destroyed before the connection is established, then
// this event will be delivered immediately when the View attempts to connect.
struct ViewHolderDisconnectedEvent {
  uint32 view_id;
};
 
// Delivered to a View's Session when the parent ViewHolder for the given View
// becomes a part of a Scene.
//
// A ViewHolder is considered to be part of a Scene if there is an unbroken
// chain of parent-child relationships between the Scene node and the
// ViewHolder node.
struct ViewAttachedToSceneEvent {
  uint32 view_id;
  ViewProperties properties;
};
 
// Delivered to a View's Session when the parent ViewHolder for the given View
// is no longer part of a scene.
//
// This can happen if the ViewHolder is detached directly from the scene, or
// if one of its parent nodes is.
//
// A ViewHolder is considered to be part of a Scene if there is an unbroken
// chain of parent-child relationships between the Scene node and the
// ViewHolder node.
struct ViewDetachedFromSceneEvent {
  uint32 view_id;
};
 
// Delivered when the parent ViewHolder for the given View makes a change to
// the View's properties.
struct ViewPropertiesChangedEvent {
  uint32 view_id;
  ViewProperties properties;
};
 
// Delivered to a ViewHolder's Session when its peer View's state has changed.
struct ViewStateChangedEvent {
  uint32 view_holder_id;
  ViewState state;
};