Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 46f0dde

Browse files
committed
Added comments
1 parent 9cf3ed9 commit 46f0dde

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/ui/painting/image_encoding_impeller.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ sk_sp<SkImage> ConvertBufferToSkImage(
7575
return result;
7676
}
7777

78+
/// Same as `DoConvertImageToRasterImpeller` but it will attempt to retry the
79+
/// operation if `DoConvertImageToRasterImpeller` returns kUnavailable when the
80+
/// GPU becomes available again.
7881
void DoConvertImageToRasterImpellerWithRetry(
7982
const sk_sp<DlImage>& dl_image,
8083
std::function<void(fml::StatusOr<sk_sp<SkImage>>)>&& encode_task,
@@ -84,6 +87,8 @@ void DoConvertImageToRasterImpellerWithRetry(
8487
fml::Status status = DoConvertImageToRasterImpeller(
8588
dl_image, encode_task, is_gpu_disabled_sync_switch, impeller_context);
8689
if (!status.ok()) {
90+
// If the conversion failed because of the GPU is unavailable, store the
91+
// task on the Context so it can be executed when the GPU becomes available.
8792
if (status.code() == fml::StatusCode::kUnavailable) {
8893
impeller_context->StoreTaskForGPU(
8994
[dl_image, encode_task = std::move(encode_task),
@@ -95,16 +100,21 @@ void DoConvertImageToRasterImpellerWithRetry(
95100
dl_image, encode_task, is_gpu_disabled_sync_switch,
96101
impeller_context);
97102
if (!retry_status.ok()) {
103+
// The retry failed for some reason, maybe the GPU became
104+
// unavailable again. Don't retry again, just fail in this case.
98105
encode_task(retry_status);
99106
}
100107
};
108+
// If a `retry_runner` is specified, post the retry to it, otherwise
109+
// execute it directly.
101110
if (retry_runner) {
102111
retry_runner->PostTask(retry_task);
103112
} else {
104113
retry_task();
105114
}
106115
});
107116
} else {
117+
// Pass on errors that are not `kUnavailable`.
108118
encode_task(status);
109119
}
110120
}

0 commit comments

Comments
 (0)