Flutter Engine
The Flutter Engine
embedder_external_view.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_EXTERNAL_VIEW_H_
6#define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_EXTERNAL_VIEW_H_
7
8#include <optional>
9#include <unordered_map>
10#include <unordered_set>
11
12#include "flutter/flow/embedded_views.h"
13#include "flutter/fml/hash_combine.h"
14#include "flutter/fml/macros.h"
15#include "flutter/shell/platform/embedder/embedder_render_target.h"
16
17namespace flutter {
18
20 public:
21 using PlatformViewID = int64_t;
23 std::optional<PlatformViewID> platform_view_id;
24
26
28 : platform_view_id(view_id) {}
29
30 struct Hash {
31 constexpr std::size_t operator()(const ViewIdentifier& desc) const {
32 if (!desc.platform_view_id.has_value()) {
33 return fml::HashCombine();
34 }
35
36 return fml::HashCombine(desc.platform_view_id.value());
37 }
38 };
39
40 struct Equal {
41 constexpr bool operator()(const ViewIdentifier& lhs,
42 const ViewIdentifier& rhs) const {
43 return lhs.platform_view_id == rhs.platform_view_id;
44 }
45 };
46 };
47
50
51 explicit RenderTargetDescriptor(const SkISize& p_surface_size)
52 : surface_size(p_surface_size) {}
53
54 struct Hash {
55 constexpr std::size_t operator()(
56 const RenderTargetDescriptor& desc) const {
57 return fml::HashCombine(desc.surface_size.width(),
58 desc.surface_size.height());
59 }
60 };
61
62 struct Equal {
64 const RenderTargetDescriptor& rhs) const {
65 return lhs.surface_size == rhs.surface_size;
66 }
67 };
68 };
69
70 using ViewIdentifierSet = std::unordered_set<ViewIdentifier,
73
74 using PendingViews = std::unordered_map<ViewIdentifier,
75 std::unique_ptr<EmbedderExternalView>,
78
79 EmbedderExternalView(const SkISize& frame_size,
80 const SkMatrix& surface_transformation);
81
82 EmbedderExternalView(const SkISize& frame_size,
83 const SkMatrix& surface_transformation,
85 std::unique_ptr<EmbeddedViewParams> params);
86
88
89 bool IsRootView() const;
90
91 bool HasPlatformView() const;
92
94
96
98
100
102
104
105 bool Render(const EmbedderRenderTarget& render_target,
106 bool clear_surface = true);
107
108 const DlRegion& GetDlRegion() const;
109
110 private:
111 // End the recording of the slice.
112 // Noop if the slice's recording has already ended.
113 void TryEndRecording() const;
114
115 const SkISize render_surface_size_;
116 const SkMatrix surface_transformation_;
117 ViewIdentifier view_identifier_;
118 std::unique_ptr<EmbeddedViewParams> embedded_view_params_;
119 std::unique_ptr<DisplayListEmbedderViewSlice> slice_;
120 std::optional<bool> has_engine_rendered_contents_;
121
122 FML_DISALLOW_COPY_AND_ASSIGN(EmbedderExternalView);
123};
124
125} // namespace flutter
126
127#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_EXTERNAL_VIEW_H_
Developer-facing API for rendering anything within the engine.
Definition: dl_canvas.h:38
const EmbeddedViewParams * GetEmbeddedViewParams() const
RenderTargetDescriptor CreateRenderTargetDescriptor() const
bool Render(const EmbedderRenderTarget &render_target, bool clear_surface=true)
std::unordered_set< ViewIdentifier, ViewIdentifier::Hash, ViewIdentifier::Equal > ViewIdentifierSet
const DlRegion & GetDlRegion() const
ViewIdentifier GetViewIdentifier() const
EmbedderExternalView(const SkISize &frame_size, const SkMatrix &surface_transformation)
std::unordered_map< ViewIdentifier, std::unique_ptr< EmbedderExternalView >, ViewIdentifier::Hash, ViewIdentifier::Equal > PendingViews
Describes a surface whose backing store is managed by the embedder. The type of surface depends on th...
EmbedderExternalView::ViewIdentifier view_identifier
const EmbeddedViewParams * params
static uint32_t Hash(uint32_t key)
Definition: hashmap_test.cc:65
constexpr std::size_t HashCombine()
Definition: hash_combine.h:25
Definition: SkSize.h:16
bool operator()(const RenderTargetDescriptor &lhs, const RenderTargetDescriptor &rhs) const
constexpr std::size_t operator()(const RenderTargetDescriptor &desc) const
constexpr bool operator()(const ViewIdentifier &lhs, const ViewIdentifier &rhs) const
constexpr std::size_t operator()(const ViewIdentifier &desc) const
std::optional< PlatformViewID > platform_view_id