0

viz/transitions: Remove root render pass snapshot.

With renderer based transitions, the output of the root stacking context
will be generated as an intermediate render pass. Remove the assumption
that it needs to come from the renderer's root render pass.

R=vmpstr@chromium.org

Bug: 1265700
Change-Id: I015532e86991115b92b5064d5b7447d575440551
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3369642
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Commit-Queue: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#956569}
This commit is contained in:
Khushal
2022-01-07 17:54:24 +00:00
committed by Chromium LUCI CQ
parent ab275df5bf
commit 6a61f7dc3a
3 changed files with 23 additions and 31 deletions

@ -82,6 +82,19 @@ bool SurfaceSavedFrame::IsValid() const {
void SurfaceSavedFrame::RequestCopyOfOutput(Surface* surface) {
DCHECK(surface->HasActiveFrame());
if (surface->GetActiveFrame().metadata.has_shared_element_resources) {
// TODO(khushalsagar) : This should be the only mode once renderer based SET
// lands.
copy_root_render_pass_ = false;
CopyUsingOriginalFrame(surface);
} else {
CopyUsingCleanFrame(surface);
}
DCHECK_EQ(copy_request_count_, ExpectedResultCount());
}
void SurfaceSavedFrame::CopyUsingCleanFrame(Surface* surface) {
const auto& root_draw_data = GetRootRenderPassDrawData(surface);
// Bind kRoot and root geometry information to the callback.
auto root_request = std::make_unique<CopyOutputRequest>(
@ -100,20 +113,6 @@ void SurfaceSavedFrame::RequestCopyOfOutput(Surface* surface) {
return;
}
if (surface->GetActiveFrame().metadata.has_shared_element_resources) {
// TODO(khushalsagar) : This should be the only mode once renderer based SET
// lands.
CopyUsingOriginalFrame(surface, std::move(root_request));
} else {
CopyUsingCleanFrame(surface, std::move(root_request));
}
DCHECK_EQ(copy_request_count_, ExpectedResultCount());
}
void SurfaceSavedFrame::CopyUsingCleanFrame(
Surface* surface,
std::unique_ptr<CopyOutputRequest> root_request) {
// If the directive includes shared elements then we need to create a new
// CompositorFrame with render passes that remove these elements. The strategy
// is as follows :
@ -187,9 +186,7 @@ void SurfaceSavedFrame::CopyUsingCleanFrame(
clean_surface_.emplace(surface, std::move(clean_frame));
}
void SurfaceSavedFrame::CopyUsingOriginalFrame(
Surface* surface,
std::unique_ptr<CopyOutputRequest> root_request) {
void SurfaceSavedFrame::CopyUsingOriginalFrame(Surface* surface) {
const auto& active_frame = surface->GetActiveFrame();
for (const auto& render_pass : active_frame.render_pass_list) {
if (auto request = CreateCopyRequestIfNeeded(
@ -199,12 +196,6 @@ void SurfaceSavedFrame::CopyUsingOriginalFrame(
copy_request_count_++;
}
}
// TODO(khushalsagar) : The root element should be an intermediate render pass
// in the renderer's frame. We could optimize it if there are no shared
// elements. See crbug.com/1265700.
surface->RequestCopyOfOutputOnRootRenderPass(std::move(root_request));
copy_request_count_++;
}
std::unique_ptr<CopyOutputRequest> SurfaceSavedFrame::CreateCopyRequestIfNeeded(
@ -288,7 +279,7 @@ bool SurfaceSavedFrame::IsSharedElementRenderPass(
size_t SurfaceSavedFrame::ExpectedResultCount() const {
// Start with 1 for the root render pass.
size_t count = 1;
size_t count = copy_root_render_pass_ ? 1 : 0;
for (auto& shared_element : directive_.shared_elements())
count += !shared_element.render_pass_id.is_null();
return count;

@ -114,14 +114,12 @@ class VIZ_SERVICE_EXPORT SurfaceSavedFrame {
// Queues copy requests by creating a copy of the CompositorFrame as specified
// in ScopedCleanSurface.
void CopyUsingCleanFrame(Surface* surface,
std::unique_ptr<CopyOutputRequest> root_request);
void CopyUsingCleanFrame(Surface* surface);
// Queues copy requests from the original CompositorFrame. This mode is used
// when the frame produced by the renderer already has independent render
// passes for each shared element.
void CopyUsingOriginalFrame(Surface* surface,
std::unique_ptr<CopyOutputRequest> root_request);
void CopyUsingOriginalFrame(Surface* surface);
std::unique_ptr<CopyOutputRequest> CreateCopyRequestIfNeeded(
const CompositorRenderPass& render_pass,
@ -177,6 +175,9 @@ class VIZ_SERVICE_EXPORT SurfaceSavedFrame {
// whether the SurfaceSavedFrame is "valid".
size_t valid_result_count_ = 0;
// Tracks whether the root render pass should be copied.
bool copy_root_render_pass_ = true;
absl::optional<ScopedCleanSurface> clean_surface_;
base::WeakPtrFactory<SurfaceSavedFrame> weak_factory_{this};

@ -1187,11 +1187,11 @@ bool SurfaceAnimationManager::FilterSharedElementsWithRenderPassOrResource(
shared_element_quad.resource_id);
if (texture_it != saved_textures_->element_id_to_resource.end()) {
resource_list->push_back(saved_textures_->element_id_to_resource.at(
shared_element_quad.resource_id));
const auto& transferable_resource = texture_it->second;
resource_list->push_back(transferable_resource);
// GPU textures are flipped but software bitmaps are not.
bool y_flipped = !saved_textures_->root.resource.is_software;
bool y_flipped = !transferable_resource.is_software;
ReplaceSharedElementWithTexture(&copy_pass, shared_element_quad,
y_flipped, resource_list->back().id);
return true;