@@ -325,23 +325,13 @@ bool EntityPass::Render(ContentContext& renderer,
325
325
Rect::MakeSize (root_render_target.GetRenderTargetSize ()),
326
326
{.readonly = true });
327
327
328
- int32_t required_mip_count = 1 ;
329
- IterateAllElements (
330
- [&required_mip_count, lazy_glyph_atlas = renderer.GetLazyGlyphAtlas ()](
331
- const Element& element) {
332
- if (auto entity = std::get_if<Entity>(&element)) {
333
- if (const auto & contents = entity->GetContents ()) {
334
- contents->PopulateGlyphAtlas (lazy_glyph_atlas,
335
- entity->DeriveTextScale ());
336
- }
337
- }
338
- if (auto subpass = std::get_if<std::unique_ptr<EntityPass>>(&element)) {
339
- const EntityPass* entity_pass = subpass->get ();
340
- required_mip_count =
341
- std::max (required_mip_count, entity_pass->GetRequiredMipCount ());
342
- }
343
- return true ;
344
- });
328
+ IterateAllEntities ([lazy_glyph_atlas =
329
+ renderer.GetLazyGlyphAtlas ()](const Entity& entity) {
330
+ if (const auto & contents = entity.GetContents ()) {
331
+ contents->PopulateGlyphAtlas (lazy_glyph_atlas, entity.DeriveTextScale ());
332
+ }
333
+ return true ;
334
+ });
345
335
346
336
ClipCoverageStack clip_coverage_stack = {ClipCoverageLayer{
347
337
.coverage = Rect::MakeSize (root_render_target.GetRenderTargetSize ()),
@@ -353,7 +343,8 @@ bool EntityPass::Render(ContentContext& renderer,
353
343
// there's no need to set up a stencil attachment on the root render target.
354
344
if (reads_from_onscreen_backdrop) {
355
345
EntityPassTarget offscreen_target = CreateRenderTarget (
356
- renderer, root_render_target.GetRenderTargetSize (), required_mip_count,
346
+ renderer, root_render_target.GetRenderTargetSize (),
347
+ GetChildrenRequiredMipCount (),
357
348
GetClearColorOrDefault (render_target.GetRenderTargetSize ()));
358
349
359
350
if (!OnRender (renderer, // renderer
@@ -615,7 +606,7 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
615
606
auto subpass_target = CreateRenderTarget (
616
607
renderer, // renderer
617
608
subpass_size, // size
618
- /* mip_count= */ 1 ,
609
+ subpass-> GetChildrenRequiredMipCount () ,
619
610
subpass->GetClearColorOrDefault (subpass_size)); // clear_color
620
611
621
612
if (!subpass_target.IsValid ()) {
@@ -1200,6 +1191,16 @@ void EntityPass::SetEnableOffscreenCheckerboard(bool enabled) {
1200
1191
enable_offscreen_debug_checkerboard_ = enabled;
1201
1192
}
1202
1193
1194
+ int32_t EntityPass::GetChildrenRequiredMipCount () const {
1195
+ int32_t result = 1 ;
1196
+ for (auto & element : elements_) {
1197
+ if (auto subpass = std::get_if<std::unique_ptr<EntityPass>>(&element)) {
1198
+ result = std::max (result, subpass->get ()->GetRequiredMipCount ());
1199
+ }
1200
+ }
1201
+ return result;
1202
+ }
1203
+
1203
1204
EntityPassClipRecorder::EntityPassClipRecorder () {}
1204
1205
1205
1206
void EntityPassClipRecorder::RecordEntity (const Entity& entity,
0 commit comments