7#include <lib/fidl/cpp/clone.h>
8#include <lib/zx/channel.h>
9#include <lib/zx/eventpair.h>
11#include "flutter/fml/logging.h"
16using FakeTransformCache =
17 std::unordered_map<const FakeTransform*, std::shared_ptr<FakeTransform>>;
19std::vector<std::shared_ptr<FakeTransform>> CloneFakeTransformVector(
20 const std::vector<std::shared_ptr<FakeTransform>>& transforms,
21 FakeTransformCache& transform_cache);
23std::shared_ptr<FakeContent> CloneFakeContent(
24 const std::shared_ptr<FakeContent>&
content) {
29 if (FakeViewport* viewport = std::get_if<FakeViewport>(
content.get())) {
30 return std::make_shared<FakeContent>(FakeViewport{
32 .viewport_properties = fidl::Clone(viewport->viewport_properties),
33 .viewport_token = viewport->viewport_token,
34 .child_view_watcher = viewport->child_view_watcher,
36 }
else if (FakeImage*
image = std::get_if<FakeImage>(
content.get())) {
37 return std::make_shared<FakeContent>(FakeImage{
39 .image_properties = fidl::Clone(
image->image_properties),
40 .sample_region =
image->sample_region,
41 .destination_size =
image->destination_size,
42 .opacity =
image->opacity,
43 .blend_mode =
image->blend_mode,
44 .import_token =
image->import_token,
45 .vmo_index =
image->vmo_index,
52std::shared_ptr<FakeTransform> CloneFakeTransform(
53 const std::shared_ptr<FakeTransform>&
transform,
54 FakeTransformCache& transform_cache) {
59 auto found_transform = transform_cache.find(
transform.get());
60 if (found_transform != transform_cache.end()) {
61 return found_transform->second;
64 auto [emplaced_transform, success] = transform_cache.emplace(
65 transform.get(), std::make_shared<FakeTransform>(FakeTransform{
67 .translation = transform->translation,
68 .scale = transform->scale,
69 .orientation = transform->orientation,
70 .clip_bounds = transform->clip_bounds,
71 .opacity = transform->opacity,
72 .children = CloneFakeTransformVector(
73 transform->children, transform_cache),
74 .content = CloneFakeContent(transform->content),
75 .hit_regions = transform->hit_regions,
79 return emplaced_transform->second;
82std::vector<std::shared_ptr<FakeTransform>> CloneFakeTransformVector(
83 const std::vector<std::shared_ptr<FakeTransform>>& transforms,
84 FakeTransformCache& transform_cache) {
85 std::vector<std::shared_ptr<FakeTransform>> clones;
87 clones.emplace_back(CloneFakeTransform(
transform, transform_cache));
157 FakeTransformCache transform_cache;
162 CloneFakeTransform(
transform, transform_cache));
169 auto found_transform = transform_cache.find(
root_transform.get());
170 FML_CHECK(found_transform != transform_cache.end());
173 if (
view.has_value()) {
#define FML_CHECK(condition)
#define FML_UNREACHABLE()
union flutter::testing::@2836::KeyboardChange::@76 content
sk_sp< const SkImage > image
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
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
std::unordered_map< TransformIdKey, std::shared_ptr< FakeTransform > > transform_map
fuchsia::math::RectF sample_region
bool operator==(const FakeImage &other) const
fuchsia::math::SizeU destination_size
fuchsia::ui::composition::ContentId id
fuchsia::ui::composition::BlendMode blend_mode
fuchsia::ui::composition::ImageProperties image_properties
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::ContentId id
fuchsia::ui::composition::ViewportProperties viewport_properties
bool operator==(const FakeViewport &other) const
zx_koid_t child_view_watcher
static ViewTokenPair New()
fuchsia::ui::views::ViewCreationToken view_token
fuchsia::ui::views::ViewportCreationToken viewport_token