@@ -342,7 +342,8 @@ bool EntityPass::Render(ContentContext& renderer,
342
342
if (reads_from_onscreen_backdrop) {
343
343
auto offscreen_target =
344
344
CreateRenderTarget (renderer, root_render_target.GetRenderTargetSize (),
345
- GetClearColor (render_target.GetRenderTargetSize ()));
345
+ GetClearColor (render_target.GetRenderTargetSize ())
346
+ .value_or (Color::BlackTransparent ()));
346
347
347
348
if (!OnRender (renderer, // renderer
348
349
capture, // capture
@@ -447,7 +448,8 @@ bool EntityPass::Render(ContentContext& renderer,
447
448
}
448
449
449
450
// Set up the clear color of the root pass.
450
- color0.clear_color = GetClearColor (render_target.GetRenderTargetSize ());
451
+ color0.clear_color = GetClearColor (render_target.GetRenderTargetSize ())
452
+ .value_or (Color::BlackTransparent ());
451
453
root_render_target.SetColorAttachment (color0, 0 );
452
454
453
455
EntityPassTarget pass_target (
@@ -600,9 +602,10 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
600
602
}
601
603
602
604
auto subpass_target = CreateRenderTarget (
603
- renderer, // renderer
604
- subpass_size, // size
605
- subpass->GetClearColor (subpass_size)); // clear_color
605
+ renderer, // renderer
606
+ subpass_size, // size
607
+ subpass->GetClearColor (subpass_size)
608
+ .value_or (Color::BlackTransparent ())); // clear_color
606
609
607
610
if (!subpass_target.IsValid ()) {
608
611
VALIDATION_LOG << " Subpass render target is invalid." ;
@@ -845,8 +848,7 @@ bool EntityPass::OnRender(
845
848
}
846
849
auto clear_color_size = pass_target.GetRenderTarget ().GetRenderTargetSize ();
847
850
848
- if (!collapsed_parent_pass &&
849
- !GetClearColor (clear_color_size).IsTransparent ()) {
851
+ if (!collapsed_parent_pass && GetClearColor (clear_color_size).has_value ()) {
850
852
// Force the pass context to create at least one new pass if the clear color
851
853
// is present.
852
854
pass_context.GetRenderPass (pass_depth);
@@ -1139,21 +1141,25 @@ void EntityPass::SetBlendMode(BlendMode blend_mode) {
1139
1141
flood_clip_ = Entity::IsBlendModeDestructive (blend_mode);
1140
1142
}
1141
1143
1142
- Color EntityPass::GetClearColor (ISize target_size) const {
1143
- Color result = Color::BlackTransparent ();
1144
+ std::optional<Color> EntityPass::GetClearColor (ISize target_size) const {
1144
1145
if (backdrop_filter_proc_) {
1145
- return result ;
1146
+ return std::nullopt ;
1146
1147
}
1147
1148
1149
+ std::optional<Color> result = std::nullopt;
1148
1150
for (const Element& element : elements_) {
1149
1151
auto [entity_color, blend_mode] =
1150
1152
ElementAsBackgroundColor (element, target_size);
1151
1153
if (!entity_color.has_value ()) {
1152
1154
break ;
1153
1155
}
1154
- result = result.Blend (entity_color.value (), blend_mode);
1156
+ result = result.value_or (Color::BlackTransparent ())
1157
+ .Blend (entity_color.value (), blend_mode);
1158
+ }
1159
+ if (result.has_value ()) {
1160
+ return result->Premultiply ();
1155
1161
}
1156
- return result. Premultiply () ;
1162
+ return result;
1157
1163
}
1158
1164
1159
1165
void EntityPass::SetBackdropFilter (BackdropFilterProc proc) {
0 commit comments