Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
++
  • Loading branch information
jonahwilliams committed Jan 24, 2024
commit 29ace61aea19e7f36a20940478b3073584273278
29 changes: 16 additions & 13 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ std::optional<Rect> EntityPass::GetBoundsLimit() const {
return bounds_limit_;
}

std::optional<Rect> EntityPass::GetTransformedBoundsLimit() const {
if (bounds_limit_.has_value()) {
return bounds_limit_->TransformBounds(transform_);
}
return std::nullopt;
}

void EntityPass::AddEntity(Entity entity) {
if (entity.GetBlendMode() == BlendMode::kSourceOver &&
entity.GetContents()->IsOpaque()) {
Expand Down Expand Up @@ -192,12 +199,11 @@ std::optional<Rect> EntityPass::GetSubpassCoverage(
return std::nullopt;
}

if (!subpass.bounds_limit_.has_value()) {
auto user_bounds_coverage = subpass.GetTransformedBoundsLimit();
if (!user_bounds_coverage.has_value()) {
return entities_coverage;
}
auto user_bounds_coverage =
subpass.bounds_limit_->TransformBounds(subpass.transform_);
return entities_coverage->Intersection(user_bounds_coverage);
return entities_coverage->Intersection(user_bounds_coverage.value());
}

EntityPass* EntityPass::GetSuperpass() const {
Expand Down Expand Up @@ -494,8 +500,7 @@ bool EntityPass::Render(ContentContext& renderer,
// descriptors can be recycled.
static ISize MaybeRoundUpTextureSize(ISize subpass_size,
ISize root_pass_size,
std::optional<Rect> bounds_limit,
const Matrix& subpass_transform) {
std::optional<Rect> bounds_limit) {
// If the subpass is already bigger than the root pass size,
// return the existing subpass size.
if (subpass_size.width > root_pass_size.width ||
Expand All @@ -507,10 +512,9 @@ static ISize MaybeRoundUpTextureSize(ISize subpass_size,
// return the existing subpass size. This case could be removed if we
// conditionally inserted clips/scissor instead.
if (bounds_limit.has_value()) {
auto user_bounds_size =
bounds_limit->TransformBounds(subpass_transform).GetSize();
if (user_bounds_size.width < root_pass_size.width ||
user_bounds_size.height < root_pass_size.height) {
auto bounds_size = bounds_limit->GetSize();
if (bounds_size.width < root_pass_size.width ||
bounds_size.height < root_pass_size.height) {
return subpass_size;
}
}
Expand Down Expand Up @@ -659,9 +663,8 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
return EntityPass::EntityResult::Skip();
}

subpass_size =
MaybeRoundUpTextureSize(subpass_size, root_pass_size,
subpass->bounds_limit_, subpass->transform_);
subpass_size = MaybeRoundUpTextureSize(
subpass_size, root_pass_size, subpass->GetTransformedBoundsLimit());
auto subpass_target = CreateRenderTarget(
renderer, // renderer
subpass_size, // size
Expand Down
3 changes: 3 additions & 0 deletions impeller/entity/entity_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ class EntityPass {
required_mip_count_ = mip_count;
}

/// @brief Return the local bounds transformed intro screen coordinate space.
std::optional<Rect> GetTransformedBoundsLimit() const;

//----------------------------------------------------------------------------
/// @brief Computes the coverage of a given subpass. This is used to
/// determine the texture size of a given subpass before it's rendered
Expand Down