Bug 1414825. Clear mDataWrapper on ImageBitmap::Close because it holds gfx resources alive. r=nical

This commit is contained in:
Timothy Nikkel 2018-02-06 02:53:21 -06:00
Родитель 92db53b861
Коммит ab2056b146
1 изменённых файлов: 21 добавлений и 3 удалений

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

@ -548,6 +548,7 @@ ImageBitmap::Close()
{
mData = nullptr;
mSurface = nullptr;
mDataWrapper = nullptr;
mPictureRect.SetEmpty();
}
@ -1572,7 +1573,10 @@ ImageBitmapFormat
ImageBitmap::FindOptimalFormat(const Optional<Sequence<ImageBitmapFormat>>& aPossibleFormats,
ErrorResult& aRv)
{
MOZ_ASSERT(mDataWrapper, "No ImageBitmapFormatUtils functionalities.");
if (!mDataWrapper) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return ImageBitmapFormat::EndGuard_;
}
ImageBitmapFormat platformFormat = mDataWrapper->GetFormat();
@ -1596,7 +1600,10 @@ ImageBitmap::FindOptimalFormat(const Optional<Sequence<ImageBitmapFormat>>& aPos
int32_t
ImageBitmap::MappedDataLength(ImageBitmapFormat aFormat, ErrorResult& aRv)
{
MOZ_ASSERT(mDataWrapper, "No ImageBitmapFormatUtils functionalities.");
if (!mDataWrapper) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return 0;
}
if (aFormat == mDataWrapper->GetFormat()) {
return mDataWrapper->GetBufferLength();
@ -1632,6 +1639,12 @@ protected:
{
ErrorResult error;
if (!mImageBitmap->mDataWrapper) {
error.ThrowWithCustomCleanup(NS_ERROR_NOT_AVAILABLE);
mPromise->MaybeReject(error);
return;
}
// Prepare destination buffer.
uint8_t* bufferData = nullptr;
uint32_t bufferLength = 0;
@ -1784,7 +1797,6 @@ ImageBitmap::MapDataInto(JSContext* aCx,
const ArrayBufferViewOrArrayBuffer& aBuffer,
int32_t aOffset, ErrorResult& aRv)
{
MOZ_ASSERT(mDataWrapper, "No ImageBitmapFormatUtils functionalities.");
MOZ_ASSERT(aCx, "No JSContext while calling ImageBitmap::MapDataInto().");
RefPtr<Promise> promise = Promise::Create(mParent, aRv);
@ -1793,6 +1805,12 @@ ImageBitmap::MapDataInto(JSContext* aCx,
return nullptr;
}
if (!mDataWrapper) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return promise.forget();
}
// Check for cases that should throws.
// Case 1:
// If image bitmap was cropped to the source rectangle so that it contains any