Skip to content

Commit acb8057

Browse files
committed
tweak flow
1 parent 1281c8a commit acb8057

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/renderer/content_renderer.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,11 @@ namespace renderer
379379
}
380380
}
381381

382+
void TrContentRenderer::onBeforeRendering()
383+
{
384+
// TODO(yorkie): implement the before rendering logic.
385+
}
386+
382387
void TrContentRenderer::onOpaquesRenderPass(chrono::time_point<chrono::high_resolution_clock> time)
383388
{
384389
// Check and initialize the graphics contexts on host frame.
@@ -492,6 +497,10 @@ namespace renderer
492497
current_pass_ = ExecutingPassType::kDefaultFrame;
493498
}
494499

500+
void TrContentRenderer::onAfterRendering()
501+
{
502+
}
503+
495504
void TrContentRenderer::onStartFrame()
496505
{
497506
frame_start_time_ = chrono::system_clock::now();

src/renderer/content_renderer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,11 @@ namespace renderer
165165
* @param req The command buffer request to be handled.
166166
*/
167167
void onCommandBufferRequestReceived(TrCommandBufferBase *req);
168+
void onBeforeRendering();
168169
void onOpaquesRenderPass(chrono::time_point<chrono::high_resolution_clock> time);
169170
void onTransparentsRenderPass(chrono::time_point<chrono::high_resolution_clock> time);
170171
void onOffscreenRenderPass();
172+
void onAfterRendering();
171173

172174
void onStartFrame();
173175
void onEndFrame();

src/renderer/renderer.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,23 +148,51 @@ namespace renderer
148148
if (rhi == nullptr) [[unlikely]]
149149
return; // Skip if api is not ready.
150150

151-
// TODO(yorkie): implement the before rendering logic.
151+
shared_lock<shared_mutex> lock(contentRendererMutex);
152+
if (contentRenderers.empty())
153+
return;
154+
155+
glHostContext->recordFromHost();
156+
{
157+
for (auto contentRenderer : contentRenderers)
158+
{
159+
auto content = contentRenderer->getContent();
160+
if (content == nullptr || content->disableRendering) [[unlikely]]
161+
continue;
162+
contentRenderer->onBeforeRendering();
163+
}
164+
}
165+
glHostContext->restore();
152166
}
153167

154168
void TrRenderer::onAfterRendering()
155169
{
156170
if (rhi == nullptr) [[unlikely]]
157171
return; // Skip if api is not ready.
158172

173+
shared_lock<shared_mutex> lock(contentRendererMutex);
174+
if (contentRenderers.empty())
175+
return;
176+
159177
glHostContext->recordFromHost();
160178
{
179+
// First, call onOffscreenRenderPass() for each content renderer.
161180
for (auto contentRenderer : contentRenderers)
162181
{
163182
auto content = contentRenderer->getContent();
164183
if (content == nullptr || content->disableRendering) [[unlikely]]
165184
continue;
166185
contentRenderer->onOffscreenRenderPass();
167186
}
187+
188+
// Then, call onAfterRendering() for each content renderer.
189+
for (auto contentRenderer : contentRenderers)
190+
{
191+
auto content = contentRenderer->getContent();
192+
if (content == nullptr || content->disableRendering) [[unlikely]]
193+
continue;
194+
contentRenderer->onAfterRendering();
195+
}
168196
}
169197
glHostContext->restore();
170198
}

0 commit comments

Comments
 (0)