MCPcopy Create free account
hub / github.com/Snapchat/Valdi / loadImage

Method loadImage

valdi/src/valdi/snap_drawing/ImageLoading/ImageLoader.cpp:89–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void ImageLoader::loadImage(const Ref<ImageLoaderTask>& task) {
90 if (task->wasCanceled()) {
91 return;
92 }
93
94 auto imgResult =
95 _cache.getResizedCachedImage(task->getUrl(), task->getPreferredWidth(), task->getPreferredHeight());
96
97 if (!imgResult) {
98 auto cancelable = task->getRemoteDownloader()->downloadItem(
99 task->getUrl(), [task](const Valdi::Result<Valdi::BytesView>& result) {
100 if (auto strongThis = task->getImageLoader().lock()) {
101 strongThis->handleByteViewLoadResult(task, result);
102 }
103 });
104 task->setCurrentCancelable(cancelable);
105 } else {
106 handleImageLoadResult(task, imgResult.value());
107 }
108}
109
110void ImageLoader::handleImageLoadResult(const Ref<ImageLoaderTask>& task, const Valdi::Result<CachedImage>& result) {
111 if (result) {

Callers 1

loadAssetMethod · 0.45

Calls 10

getResizedCachedImageMethod · 0.80
getUrlMethod · 0.80
setCurrentCancelableMethod · 0.80
valueMethod · 0.65
wasCanceledMethod · 0.45
getPreferredWidthMethod · 0.45
getPreferredHeightMethod · 0.45
downloadItemMethod · 0.45
lockMethod · 0.45

Tested by

no test coverage detected