Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from all commits
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
10 changes: 7 additions & 3 deletions shell/common/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ static sk_sp<SkData> ScreenshotLayerTreeAsImage(
auto snapshot_surface =
CreateSnapshotSurface(surface_context, tree->frame_size());
if (snapshot_surface == nullptr) {
FML_LOG(ERROR) << "Screenshot: unable to create snapshot surface";
return nullptr;
}

Expand All @@ -193,16 +194,18 @@ static sk_sp<SkData> ScreenshotLayerTreeAsImage(
// Prepare an image from the surface, this image may potentially be on th GPU.
auto potentially_gpu_snapshot = snapshot_surface->makeImageSnapshot();
if (!potentially_gpu_snapshot) {
FML_LOG(ERROR) << "Screenshot: unable to make image screenshot";
return nullptr;
}

// Copy the GPU image snapshot into CPU memory.
auto cpu_snapshot = potentially_gpu_snapshot->makeRasterImage();
if (!cpu_snapshot) {
FML_LOG(ERROR) << "Screenshot: unable to make raster image";
return nullptr;
}

// If the caller want the pixels to be compressed, there is a Skia utilitiy to
// If the caller want the pixels to be compressed, there is a Skia utility to
// compress to PNG. Use that.
if (compressed) {
return cpu_snapshot->encodeToData();
Expand All @@ -211,6 +214,7 @@ static sk_sp<SkData> ScreenshotLayerTreeAsImage(
// Copy it into a bitmap and return the same.
SkPixmap pixmap;
if (!cpu_snapshot->peekPixels(&pixmap)) {
FML_LOG(ERROR) << "Screenshot: unable to obtain bitmap pixels";
return nullptr;
}

Expand All @@ -222,7 +226,7 @@ Rasterizer::Screenshot Rasterizer::ScreenshotLastLayerTree(
bool base64_encode) {
auto layer_tree = GetLastLayerTree();
if (layer_tree == nullptr) {
FML_DLOG(INFO) << "Last layer tree was null when screenshotting.";
FML_LOG(ERROR) << "Last layer tree was null when screenshotting.";
return {};
}

Expand All @@ -246,7 +250,7 @@ Rasterizer::Screenshot Rasterizer::ScreenshotLastLayerTree(
}

if (data == nullptr) {
FML_DLOG(INFO) << "Sceenshot data was null.";
FML_LOG(ERROR) << "Screenshot data was null.";
return {};
}

Expand Down