blob: f00b5924f24e4277353afa2f7abd7c530c009705 [file] [log] [blame]
// Copyright 2020 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.
#include "src/ui/scenic/lib/utils/helpers.h"
#include <lib/syslog/cpp/macros.h>
namespace utils {
zx::event CopyEvent(const zx::event& event) {
zx::event event_copy;
if (event.duplicate(ZX_RIGHT_SAME_RIGHTS, &event_copy) != ZX_OK)
FX_LOGS(ERROR) << "Copying zx::event failed.";
return event_copy;
}
fuchsia::ui::scenic::Present2Args CreatePresent2Args(zx_time_t requested_presentation_time,
std::vector<zx::event> acquire_fences,
std::vector<zx::event> release_fences,
zx_duration_t requested_prediction_span) {
fuchsia::ui::scenic::Present2Args args;
args.set_requested_presentation_time(requested_presentation_time);
args.set_acquire_fences(std::move(acquire_fences));
args.set_release_fences(std::move(release_fences));
args.set_requested_prediction_span(requested_prediction_span);
return args;
}
zx_koid_t ExtractKoid(const fuchsia::ui::views::ViewRef& view_ref) {
zx_info_handle_basic_t info{};
if (view_ref.reference.get_info(ZX_INFO_HANDLE_BASIC, &info, sizeof(info), nullptr, nullptr) !=
ZX_OK) {
return ZX_KOID_INVALID; // no info
}
return info.koid;
}
} // namespace utils