0

[//cc] Convert pixel_test.cc away from SharedImageMapping

Converts to the functionally-equivalent new API that holds the
SharedMemoryMapping inside the ClientSharedImage and exposes it via
ScopedMapping.

Bug: 40064122
Change-Id: Ic08d55c31cd507ffcd85e745aab6ccb262a9cbeb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6127164
Reviewed-by: Saifuddin Hitawala <hitawala@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1401430}
This commit is contained in:
Colin Blundell
2025-01-02 07:48:04 -08:00
committed by Chromium LUCI CQ
parent 2b8a5902cf
commit f00148bf45

@ -262,19 +262,17 @@ viz::ResourceId PixelTest::AllocateAndFillSoftwareResource(
const SkBitmap& source) {
auto* shared_image_interface = context_provider->SharedImageInterface();
DCHECK(shared_image_interface);
auto shared_image_mapping = shared_image_interface->CreateSharedImage(
{viz::SinglePlaneFormat::kBGRA_8888, size, gfx::ColorSpace(),
gpu::SHARED_IMAGE_USAGE_CPU_WRITE_ONLY, "PixelTestSharedBitmap"});
scoped_refptr<gpu::ClientSharedImage> shared_image =
std::move(shared_image_mapping.shared_image);
base::WritableSharedMemoryMapping mapping =
std::move(shared_image_mapping.mapping);
shared_image_interface->CreateSharedImageForSoftwareCompositor(
{viz::SinglePlaneFormat::kBGRA_8888, size, gfx::ColorSpace(),
gpu::SHARED_IMAGE_USAGE_CPU_WRITE_ONLY, "PixelTestSharedBitmap"});
auto mapping = shared_image->Map();
gpu::SyncToken sync_token = shared_image_interface->GenVerifiedSyncToken();
SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height());
const size_t row_bytes = info.minRowBytes();
base::span<uint8_t> mem(mapping);
base::span<uint8_t> mem = mapping->GetMemoryForPlane(0);
CHECK_GE(mem.size(), info.computeByteSize(row_bytes));
source.readPixels(info, mem.data(), row_bytes, 0, 0);