MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Tools / OnGetLayout

Method OnGetLayout

cube/fuchsia/flatland_view.cpp:109–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109void FlatlandView::OnGetLayout(fuchsia_ui_composition::LayoutInfo info) {
110 ZX_DEBUG_ASSERT(info.logical_size().has_value());
111 const fuchsia_math::SizeU& logical_size = info.logical_size().value();
112 resize_callback_(logical_size.width(), logical_size.height());
113
114 fuchsia_ui_composition::ViewportProperties properties = {{.logical_size = logical_size}};
115 if (viewport_creation_token_.value().is_valid()) {
116 // The first time that we receive layout information, create a viewport using the token that was stashed during Init().
117 // External code will attach a view to this viewport via the token obtained from TakeChildViewCreationToken().
118 auto [child_view_watcher_client, child_view_watcher_server] =
119 fidl::Endpoints<fuchsia_ui_composition::ChildViewWatcher>::Create();
120 fit::result<fidl::OneWayError> create_viewport_result = flatland_->CreateViewport({{
121 .viewport_id = kViewport,
122 .token = std::move(viewport_creation_token_),
123 .properties = std::move(properties),
124 .child_view_watcher = std::move(child_view_watcher_server),
125 }});
126 if (create_viewport_result.is_error()) {
127 FX_LOGS(ERROR) << "Failed to call CreateViewport(): " << create_viewport_result.error_value().FormatDescription();
128 return;
129 }
130
131 fit::result<fidl::OneWayError> set_content_result = flatland_->SetContent({{
132 .transform_id = kRootTransform,
133 .content_id = kViewport,
134 }});
135 if (set_content_result.is_error()) {
136 FX_LOGS(ERROR) << "Failed to call SetContent(): " << set_content_result.error_value().FormatDescription();
137 return;
138 }
139 } else {
140 auto set_viewport_properties_result = flatland_->SetViewportProperties({{
141 .viewport_id = kViewport,
142 .properties = std::move(properties),
143 }});
144 if (set_viewport_properties_result.is_error()) {
145 FX_LOGS(ERROR) << "Failed to call SetViewportProperties(): "
146 << set_viewport_properties_result.error_value().FormatDescription();
147 return;
148 }
149 }
150
151 Present();
152 parent_viewport_watcher_->GetLayout().Then(
153 [this](fidl::Result<fuchsia_ui_composition::ParentViewportWatcher::GetLayout>& result) {
154 if (result.is_error()) {
155 FX_LOGS(ERROR) << "GetLayout() failed: " << result.error_value().FormatDescription();
156 return;
157 }
158 OnGetLayout(std::move(result.value().info()));
159 });
160}
161
162void FlatlandView::OnError(fidl::Event<fuchsia_ui_composition::Flatland::OnError>& event) {
163 FX_LOGF(ERROR, kTag, "OnFlatlandError: %" PRIu32, static_cast<uint32_t>(event.error()));

Callers

nothing calls this directly

Calls 2

has_valueMethod · 0.80
valueMethod · 0.80

Tested by

no test coverage detected