5#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_TESTS_FAKES_SCENIC_FAKE_FLATLAND_TYPES_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_TESTS_FAKES_SCENIC_FAKE_FLATLAND_TYPES_H_
8#include <fuchsia/math/cpp/fidl.h>
9#include <fuchsia/ui/composition/cpp/fidl.h>
10#include <fuchsia/ui/composition/cpp/fidl_test_base.h>
11#include <fuchsia/ui/views/cpp/fidl.h>
12#include <lib/fidl/cpp/binding.h>
13#include <lib/fidl/cpp/interface_handle.h>
14#include <lib/fidl/cpp/interface_ptr.h>
15#include <lib/fidl/cpp/interface_request.h>
16#include <zircon/types.h>
22#include <unordered_map>
26#include "flutter/fml/macros.h"
32 const fuchsia::math::SizeU&
b) {
33 return a.width ==
b.width &&
a.height ==
b.height;
37 const fuchsia::math::Inset&
b) {
38 return a.top ==
b.top &&
a.left ==
b.left &&
a.right ==
b.right &&
43 const fuchsia::math::Vec&
b) {
44 return a.
x ==
b.x &&
a.
y ==
b.y;
48 const fuchsia::math::VecF&
b) {
49 return a.
x ==
b.x &&
a.
y ==
b.y;
54 return a.
x ==
b.x &&
a.
y ==
b.y &&
a.width ==
b.width &&
a.height ==
b.height;
58 const fuchsia::math::RectF&
b) {
59 return a.
x ==
b.x &&
a.
y ==
b.y &&
a.width ==
b.width &&
a.height ==
b.height;
62inline bool operator==(
const std::optional<fuchsia::math::Rect>&
a,
63 const std::optional<fuchsia::math::Rect>&
b) {
64 if (
a.has_value() !=
b.has_value()) {
69 return a.value() ==
b.value();
74namespace ui::composition {
76inline bool operator==(
const fuchsia::ui::composition::ContentId&
a,
77 const fuchsia::ui::composition::ContentId&
b) {
78 return a.value ==
b.value;
81inline bool operator==(
const fuchsia::ui::composition::TransformId&
a,
82 const fuchsia::ui::composition::TransformId&
b) {
83 return a.value ==
b.value;
86inline bool operator==(
const fuchsia::ui::composition::ViewportProperties&
a,
87 const fuchsia::ui::composition::ViewportProperties&
b) {
88 if (
a.has_logical_size() !=
b.has_logical_size()) {
92 bool logical_size_equal =
true;
93 if (
a.has_logical_size()) {
94 const fuchsia::math::SizeU& a_logical_size =
a.logical_size();
95 const fuchsia::math::SizeU& b_logical_size =
b.logical_size();
96 logical_size_equal = (a_logical_size.width == b_logical_size.width &&
97 a_logical_size.height == b_logical_size.height);
100 return logical_size_equal;
103inline bool operator==(
const fuchsia::ui::composition::ImageProperties&
a,
104 const fuchsia::ui::composition::ImageProperties&
b) {
105 if (
a.has_size() !=
b.has_size()) {
109 bool size_equal =
true;
111 const fuchsia::math::SizeU& a_size =
a.size();
112 const fuchsia::math::SizeU& b_size =
b.size();
114 (a_size.width == b_size.width && a_size.height == b_size.height);
120inline bool operator==(
const fuchsia::ui::composition::HitRegion&
a,
121 const fuchsia::ui::composition::HitRegion&
b) {
122 return a.region ==
b.region &&
a.hit_test ==
b.hit_test;
125inline bool operator!=(
const fuchsia::ui::composition::HitRegion&
a,
126 const fuchsia::ui::composition::HitRegion&
b) {
131 const std::vector<fuchsia::ui::composition::HitRegion>&
a,
132 const std::vector<fuchsia::ui::composition::HitRegion>&
b) {
133 if (
a.size() !=
b.size())
136 for (
size_t i = 0;
i <
a.size(); ++
i) {
153 .region = {-FLT_MAX, -FLT_MAX, FLT_MAX, FLT_MAX}};
209 fuchsia::ui::composition::BlendMode::SRC_OVER};
231 fuchsia::ui::composition::Orientation::CCW_0_DEGREES};
244 std::vector<std::shared_ptr<FakeTransform>>
children;
258 std::unordered_map<ContentIdKey, std::shared_ptr<FakeContent>>
content_map;
259 std::unordered_map<TransformIdKey, std::shared_ptr<FakeTransform>>
265template <
typename ZX>
266std::pair<zx_koid_t, zx_koid_t>
GetKoids(
const ZX& kobj) {
267 zx_info_handle_basic_t
info;
269 kobj.get_info(ZX_INFO_HANDLE_BASIC, &
info,
sizeof(
info),
271 return status == ZX_OK ? std::make_pair(
info.koid,
info.related_koid)
272 : std::make_pair(zx_koid_t{}, zx_koid_t{});
277 const fidl::InterfaceHandle<F>& interface_handle) {
278 return GetKoids(interface_handle.channel());
283 const fidl::InterfaceRequest<F>& interface_request) {
284 return GetKoids(interface_request.channel());
289 const fidl::InterfacePtr<F>& interface_ptr) {
290 return GetKoids(interface_ptr.channel());
295 const fidl::Binding<F>& interface_binding) {
296 return GetKoids(interface_binding.channel());
300 const fuchsia::ui::views::ViewCreationToken& view_token) {
305 const fuchsia::ui::views::ViewportCreationToken& viewport_token) {
306 return GetKoids(viewport_token.value);
310 const fuchsia::ui::views::ViewRef& view_ref) {
311 return GetKoids(view_ref.reference);
315 const fuchsia::ui::views::ViewRefControl& view_ref_control) {
316 return GetKoids(view_ref_control.reference);
320 const fuchsia::ui::composition::BufferCollectionExportToken&
321 buffer_collection_token) {
322 return GetKoids(buffer_collection_token.value);
326 const fuchsia::ui::composition::BufferCollectionImportToken&
327 buffer_collection_token) {
328 return GetKoids(buffer_collection_token.value);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static constexpr fuchsia::ui::composition::ContentId kInvalidContentId
std::pair< zx_koid_t, zx_koid_t > GetKoids(const ZX &kobj)
static constexpr fuchsia::ui::composition::HitRegion kInfiniteHitRegion
std::variant< FakeViewport, FakeImage > FakeContent
static constexpr fuchsia::ui::composition::TransformId kInvalidTransformId
bool operator==(const fuchsia::math::SizeU &a, const fuchsia::math::SizeU &b)
bool operator!=(const fuchsia::ui::composition::HitRegion &a, const fuchsia::ui::composition::HitRegion &b)
bool operator==(const fuchsia::ui::composition::ContentId &a, const fuchsia::ui::composition::ContentId &b)
static BufferCollectionTokenPair New()
fuchsia::ui::composition::BufferCollectionImportToken import_token
fuchsia::ui::composition::BufferCollectionExportToken export_token
std::optional< FakeView > view
std::unordered_map< ContentIdKey, std::shared_ptr< FakeContent > > content_map
bool operator==(const FakeGraph &other) const
std::shared_ptr< FakeTransform > root_transform
decltype(fuchsia::ui::composition::TransformId::value) TransformIdKey
std::unordered_map< TransformIdKey, std::shared_ptr< FakeTransform > > transform_map
decltype(fuchsia::ui::composition::ContentId::value) ContentIdKey
fuchsia::math::RectF sample_region
static constexpr fuchsia::ui::composition::BlendMode kDefaultBlendMode
bool operator==(const FakeImage &other) const
static constexpr fuchsia::math::RectF kDefaultSampleRegion
static constexpr fuchsia::math::SizeU kDefaultImageSize
fuchsia::math::SizeU destination_size
static constexpr fuchsia::math::SizeU kDefaultDestinationSize
fuchsia::ui::composition::BlendMode blend_mode
fuchsia::ui::composition::ImageProperties image_properties
static constexpr float kDefaultOpacity
bool operator==(const FakeView &other) const
zx_koid_t view_ref_focused
zx_koid_t view_ref_control
zx_koid_t parent_viewport_watcher
fuchsia::ui::composition::ViewportProperties viewport_properties
bool operator==(const FakeViewport &other) const
static constexpr fuchsia::math::Inset kDefaultViewportInset
static constexpr fuchsia::math::SizeU kDefaultViewportLogicalSize
zx_koid_t child_view_watcher
static ViewTokenPair New()
fuchsia::ui::views::ViewCreationToken view_token
fuchsia::ui::views::ViewportCreationToken viewport_token