Bug 1578164. Use async notifications when requesting decode of an image in most places. r=aosmond

Most of things will likely be no real change because they ask for the exact frame they want immediately before.

Differential Revision: https://phabricator.services.mozilla.com/D44359

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Timothy Nikkel 2019-09-03 15:36:23 +00:00
Родитель d0413845a9
Коммит e0a79ba9f2
11 изменённых файлов: 28 добавлений и 17 удалений

Просмотреть файл

@ -7379,7 +7379,8 @@ void nsContentUtils::TransferableToIPCTransferable(
} else if (nsCOMPtr<imgIContainer> image = do_QueryInterface(data)) {
// Images to be placed on the clipboard are imgIContainers.
RefPtr<mozilla::gfx::SourceSurface> surface = image->GetFrame(
imgIContainer::FRAME_CURRENT, imgIContainer::FLAG_SYNC_DECODE);
imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
if (!surface) {
continue;
}

Просмотреть файл

@ -1544,8 +1544,9 @@ CreateImageBitmapFromBlob::OnImageReady(imgIContainer* aImgContainer,
MOZ_ASSERT(aImgContainer);
// Get the surface out.
uint32_t frameFlags =
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_WANT_DATA_SURFACE;
uint32_t frameFlags = imgIContainer::FLAG_SYNC_DECODE |
imgIContainer::FLAG_ASYNC_NOTIFY |
imgIContainer::FLAG_WANT_DATA_SURFACE;
uint32_t whichFrame = imgIContainer::FRAME_FIRST;
RefPtr<SourceSurface> surface =
aImgContainer->GetFrame(whichFrame, frameFlags);

Просмотреть файл

@ -335,7 +335,8 @@ imgTools::EncodeImage(imgIContainer* aContainer, const nsACString& aMimeType,
nsIInputStream** aStream) {
// Use frame 0 from the image container.
RefPtr<SourceSurface> frame = aContainer->GetFrame(
imgIContainer::FRAME_FIRST, imgIContainer::FLAG_SYNC_DECODE);
imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
RefPtr<DataSourceSurface> dataSurface;
@ -380,10 +381,10 @@ imgTools::EncodeScaledImage(imgIContainer* aContainer,
aScaledHeight == 0 ? imageHeight : aScaledHeight);
// Use frame 0 from the image container.
RefPtr<SourceSurface> frame =
aContainer->GetFrameAtSize(scaledSize, imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_HIGH_QUALITY_SCALING |
imgIContainer::FLAG_SYNC_DECODE);
RefPtr<SourceSurface> frame = aContainer->GetFrameAtSize(
scaledSize, imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_HIGH_QUALITY_SCALING |
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
// If the given surface is the right size/format, we can encode it directly.
@ -445,7 +446,8 @@ imgTools::EncodeCroppedImage(imgIContainer* aContainer,
// Use frame 0 from the image container.
RefPtr<SourceSurface> frame = aContainer->GetFrame(
imgIContainer::FRAME_FIRST, imgIContainer::FLAG_SYNC_DECODE);
imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
int32_t frameWidth = frame->GetSize().width;

Просмотреть файл

@ -277,7 +277,7 @@ void nsImageBoxFrame::UpdateImage() {
mIntrinsicSize.SizeTo(0, 0);
} else {
// We don't want discarding or decode-on-draw for xul images.
mImageRequest->StartDecoding(imgIContainer::FLAG_NONE);
mImageRequest->StartDecoding(imgIContainer::FLAG_ASYNC_NOTIFY);
mImageRequest->LockImage();
}

Просмотреть файл

@ -939,7 +939,8 @@ void PuppetWidget::SetCursor(nsCursor aCursor, imgIContainer* aCursorImage,
if (aCursorImage) {
RefPtr<SourceSurface> surface = aCursorImage->GetFrame(
imgIContainer::FRAME_CURRENT, imgIContainer::FLAG_SYNC_DECODE);
imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
if (surface) {
if (RefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface()) {
hasCustomCursor = true;

Просмотреть файл

@ -511,7 +511,8 @@ NSDictionary* nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTran
}
RefPtr<SourceSurface> surface =
image->GetFrame(imgIContainer::FRAME_CURRENT, imgIContainer::FLAG_SYNC_DECODE);
image->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
if (!surface) {
continue;
}

Просмотреть файл

@ -500,7 +500,8 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(imgIContainer* aImage, ui
surface = drawTarget->Snapshot();
} else {
surface = aImage->GetFrame(aWhichFrame, imgIContainer::FLAG_SYNC_DECODE);
surface = aImage->GetFrame(aWhichFrame,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
}
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);

Просмотреть файл

@ -29,7 +29,8 @@ nsImageToPixbuf::ConvertImageToPixbuf(imgIContainer* aImage) {
GdkPixbuf* nsImageToPixbuf::ImageToPixbuf(imgIContainer* aImage) {
RefPtr<SourceSurface> surface = aImage->GetFrame(
imgIContainer::FRAME_CURRENT, imgIContainer::FLAG_SYNC_DECODE);
imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
// If the last call failed, it was probably because our call stack originates
// in an imgINotificationObserver event, meaning that we're not allowed

Просмотреть файл

@ -528,7 +528,8 @@ nsresult ToastNotificationHandler::AsyncSaveImage(imgIRequest* aRequest) {
nsCOMPtr<nsIFile> imageFile(mImageFile);
RefPtr<mozilla::gfx::SourceSurface> surface = imgContainer->GetFrame(
imgIContainer::FRAME_FIRST, imgIContainer::FLAG_SYNC_DECODE);
imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
"ToastNotificationHandler::AsyncWriteBitmap",
[self, imageFile, surface]() -> void {

Просмотреть файл

@ -1637,7 +1637,8 @@ void WinUtils::SetupKeyModifiersSequence(nsTArray<KeyPair>* aArray,
/* static */
nsresult WinUtils::WriteBitmap(nsIFile* aFile, imgIContainer* aImage) {
RefPtr<SourceSurface> surface = aImage->GetFrame(
imgIContainer::FRAME_FIRST, imgIContainer::FLAG_SYNC_DECODE);
imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
return WriteBitmap(aFile, surface);

Просмотреть файл

@ -439,7 +439,8 @@ nsresult nsWindowGfx::CreateIcon(imgIContainer* aContainer, bool aIsCursor,
// Get the image data
RefPtr<SourceSurface> surface = aContainer->GetFrame(
imgIContainer::FRAME_CURRENT, imgIContainer::FLAG_SYNC_DECODE);
imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
NS_ENSURE_TRUE(surface, NS_ERROR_NOT_AVAILABLE);
IntSize frameSize = surface->GetSize();