0

[//cc] Have HUDLayerImpl create SI via InUsePoolResource

This CL adds InUsePoolResource::InstallSoftwareBacking(), which creates
a backing for the resource that is itself backed by a software
SharedImage created with the resource's format/size/color space. We
use this new method in HeadsUpDisplayLayerImpl to replace the equivalent
logic that it is currently executing on its side for creating the
SI/backing and installing it in the resource.

This is a step toward folding as much SharedImage creation for
InUsePoolResource as possible inside InUsePoolResource itself to be able
to reason most clearly about the configuration of the SharedImage that
the resource is holding matching the configuration of the resource
itself.

Bug: 40064122
Change-Id: Ic59852a36334256af0c0cfb65a944827895c75a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6268759
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1420958}
This commit is contained in:
Colin Blundell
2025-02-17 00:59:07 -08:00
committed by Chromium LUCI CQ
parent 4e69cd209a
commit c126611f88
3 changed files with 20 additions and 8 deletions

@ -281,14 +281,7 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture(
gfx::ColorSpace());
if (!pool_resource.backing()) {
auto backing = std::make_unique<ResourcePool::Backing>();
backing->shared_image_interface = sii;
backing->set_shared_image(sii->CreateSharedImageForSoftwareCompositor(
{pool_resource.format(), pool_resource.size(),
pool_resource.color_space(), gpu::SHARED_IMAGE_USAGE_CPU_WRITE_ONLY,
"HeadsUpDisplayLayer"}));
CHECK(backing->shared_image());
pool_resource.set_backing(std::move(backing));
pool_resource.InstallSoftwareBacking(sii, "HeadsUpDisplayLayer");
}
}

@ -59,6 +59,19 @@ ResourcePool::Backing::~Backing() {
}
}
void ResourcePool::InUsePoolResource::InstallSoftwareBacking(
scoped_refptr<gpu::SharedImageInterface> sii,
std::string_view debug_label) {
CHECK(!backing());
auto backing = std::make_unique<ResourcePool::Backing>();
backing->shared_image_interface = sii;
backing->set_shared_image(sii->CreateSharedImageForSoftwareCompositor(
{format(), size(), color_space(), gpu::SHARED_IMAGE_USAGE_CPU_WRITE_ONLY,
debug_label}));
CHECK(backing->shared_image());
set_backing(std::move(backing));
}
namespace {
// Process-unique number for each resource pool.

@ -135,6 +135,12 @@ class CC_EXPORT ResourcePool : public base::trace_event::MemoryDumpProvider {
return resource_->set_backing(std::move(backing));
}
// Creates a software SharedImage based on the configuration of this
// resource and installs a backing for this resource that is itself backed
// by that SI.
void InstallSoftwareBacking(scoped_refptr<gpu::SharedImageInterface> sii,
std::string_view debug_label);
size_t memory_usage() const {
DCHECK(resource_);
return resource_->memory_usage();