-
Notifications
You must be signed in to change notification settings - Fork 102
/
root_presenter.txt
207 lines (158 loc) · 12.7 KB
/
root_presenter.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
root_presenter::App app(command_line);
====
App::PresentView
InitializeServices();
连接view manager
连接scenic
scenic->CreateSession 创建session
DisplayCompositor::DisplayCompositor(Session* session) : Resource(session)
session->Enqueue(NewCreateDisplayCompositorCmd(id()));
SessionHandler::DispatchCommand
buffered_commands_.emplace_back
只是放入队列
compositor_->SetLayerStack(*layer_stack_.get());
session()->Enqueue(NewSetLayerStackCmd(id(), layer_stack_id));
session_->Present(0, [](fuchsia::images::PresentationInfo info) {});
Flush();
session_->Enqueue(std::move(commands_));
====> scenic
Session::Enqueue
SessionHandler::DispatchCommand
buffered_commands_.emplace_back(std::move(command.gfx()));
session_->Present(presentation_time, std::move(acquire_fences_),std::move(release_fences_), std::move(callback));
====> scenic
SessionHandler::Present(presentation_time, std::move(acquire_fences), std::move(release_fences), std::move(callback));
Session::ScheduleUpdate(presentation_time, std::move(buffered_commands_), std::move(acquire_fences), std::move(release_fences), std::move(callback))
FrameScheduler::ComputeTargetPresentationAndWakeupTimes(requested_presentation_time);
PredictRequiredFrameRenderTime()
engine()->display_manager()->default_display()->GetVsyncInterval();
====> async
等齐所有的acquire fence之后,调用:
SessionManager::ScheduleUpdateForSession
updatable_sessions_.insert
Engine::ScheduleUpdate
FrameScheduler::RequestFrame
如果安排了更早的一帧会把这帧丢掉?
ScheduleFrame();
计算出target和wakeup time.
====> async
在wakeup time启动
FrameScheduler::MaybeRenderFrame(presentation_time, wakeup_time);
把队列里时间早于这一帧的(包括自己)都弹出去
delegate_是Engine
Engine::RenderFrame
把所有的资源操作都做完
SessionManager::ApplyScheduledSessionUpdates
Session::ApplyScheduledUpdates
ApplyUpdate(std::move(scheduled_updates_.front().commands))
ApplyCommand(std::move(command))
ApplyCreateResourceCmd
ApplyCreateDisplayCompositor
CreateDisplayCompositor
Engine::CreateDisplaySwapchain
DisplaySwapchain::DisplaySwapchain
InitializeFramebuffers(escher->resource_recycler())
这里创建vkimage
display_manager_->SetImageConfig(width_in_px, height_in_px, ZX_PIXEL_FORMAT_ARGB_8888);
DisplayManager::SetImageConfig(int32_t width, int32_t height, zx_pixel_format_t format)
vulkan_proc_addresses_.getMemoryFuchsiaHandleKHR
display_manager_->ImportImage(buffer.vmo);
把image内存导入display manager, 得到framebuffer id
swapchain_buffers_.push_back
display_manager_->EnableVsync
DisplayCompositor::DisplayCompositor
add to engine
Session::CreateLayerStack
添加到resources_里面
ApplySetLayerStackCmd
compositor->SetLayerStack
UpdateAndDeliverMetrics(presentation_time);
compositor->CollectScenes(&scenes);
layer->CollectScenes(scenes_out);
最多有一个scene
更新scale
for (auto scene : scenes) {
UpdateMetrics(scene, metrics, &updated_nodes);
}
//for each compositor: 一个compositor负责一个Display
compositor->DrawFrame(timings, paper_renderer_.get(), shadow_renderer_.get());
Compositor::DrawFrame(const FrameTimingsPtr& frame_timings, escher::PaperRenderer* escher_renderer, escher::ShadowMapRenderer* shadow_renderer)
GetDrawableLayers();
有scene的
escher()->NewFrame("Scenic Compositor", frame_timings->frame_number());
frame_manager_->NewFrame
new Frame
command_buffer_ = CommandBuffer::NewForType(escher(), command_buffer_type_);
DrawOverlaysToModel(drawable_layers, frame, frame_timings, escher_renderer, shadow_renderer);
for all drawable layers, 除了第0个layer
GetLayerFramebufferImage
escher()->image_cache()->NewImage(info);
image_utils::CreateVkImage(vk_device(), info);
创建新的vkImage
DrawLayer(frame, frame_timings, escher_renderer, shadow_renderer, drawable_layers[i], texture->image(), nullptr);
InitEscherStage(&stage, layer->GetViewingVolume(), scene->ambient_lights(), scene->directional_lights());
viewing volume z=[0,1000]
Renderer::CreateDisplayList
scene->Accept(&v);
DisplayList是escher::Object
escher_renderer->DrawFrame(frame, stage, model, camera, output_image, shadow_map, overlay_model);
PaperRenderer::DrawFrame
UpdateRenderPasses(color_image_out->format(), color_image_out->format());
若没创建,创建一堆renderpass
ModelDepthPass::ModelDepthPass
ModelRenderPass::ModelRenderPass
PaperRenderer::DrawFrameWithNoShadows
把color_image_out的wait semaphore加到command buffer的wait semaphore里 ??
framebuffer = fxl::MakeRefCounted<Framebuffer>
DrawLightingPass(
command_buffer->BeginRenderPass
command_buffer->EndRenderPass();
swapchain_->DrawAndPresentFrame(cb)
draw_callback(buffer.escher_image, escher::SemaphorePtr(),frame_record->render_finished_escher_semaphore);
DrawLayer(frame, frame_timings, escher_renderer, shadow_renderer,bottom_layer, output_image, overlay);
display_manager_->Flip(display_, buffer.fb_id, frame_record->render_finished_event_id,fuchsia::display::invalidId /* frame_signal_event_id */);
display_controller_->SetLayerImage
display_controller_->ApplyConfig();
frame->EndFrame(frame_done_semaphore, nullptr);
========
scheduled_updates_.push(
Update{requested_presentation_time, std::move(commands),
std::move(acquire_fence_set), std::move(release_events),
std::move(callback)});
Presentation2::Presentation2
创建一个layer及其相关的东西
presentation->PresentView(std::move(presentation_request), GetYieldCallback(), GetShutdownCallback(presentation.get()));
监听presentation request, hello_base_view传过来的是nullptr
callback:
weak->InitializeDisplayModel(std::move(display_info));
ApplyDisplayModelChanges(true, false);
weak->PresentScene();
session_->Present
====> Scenic:
SessionHandler::Present
AddPresentation(std::move(presentation));
SwitchToPresentation(presentations_.size() - 1);
layer_stack_->RemoveAllLayers();
layer_stack_->AddLayer(presentations_[presentation_idx]->layer());
session_->Present(0, [](fuchsia::images::PresentationInfo info) {});
root presenter没有自己进入循环
====
input:
input设备是由input_reader发送给inputdeviceregistry这个接口的实现者获得的
AddPresentation
Presentation1::OnDeviceAdded
state_ptr->OnRegistered();
KeyboardState::SendEvent
device_state_->callback()(std::move(ev));
Presentation1::OnAccessibilityEvent
若没注册,注册view tree:
a11y_input_connection_->RegisterPresentation(std::move(clone_token));
对touch事件,发送给ally
a11y_input_connection_->SendInputEvent(std::move(event));
====> ally touch dispatcher:
A11yTouchDispatcherImpl::SendInputEvent
若注册了view tree token 发送事件给touch dispatcher的订阅者,目前没有
Presentation1::OnEvent
event.is_keyboard()
input_dispatcher_->DispatchEvent(std::move(event));
view tree是inputdispatcher服务的提供者