mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1794360 - Fail to clone ImageBitmap if no data surface available. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D229927
This commit is contained in:
parent
22cb24bd81
commit
96445f317f
@ -950,9 +950,6 @@ UniquePtr<ImageBitmapCloneData> ImageBitmap::ToCloneData() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UniquePtr<ImageBitmapCloneData> result(new ImageBitmapCloneData());
|
||||
result->mPictureRect = mPictureRect;
|
||||
result->mAlphaType = mAlphaType;
|
||||
RefPtr<SourceSurface> surface = mData->GetAsSourceSurface();
|
||||
if (!surface) {
|
||||
// It might just not be possible to get/map the surface. (e.g. from another
|
||||
@ -960,10 +957,18 @@ UniquePtr<ImageBitmapCloneData> ImageBitmap::ToCloneData() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
result->mSurface = surface->GetDataSurface();
|
||||
MOZ_ASSERT(result->mSurface);
|
||||
result->mWriteOnly = mWriteOnly;
|
||||
RefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface();
|
||||
if (NS_WARN_IF(!dataSurface)) {
|
||||
// This can reasonably fail in many cases (e.g. canvas state doesn't allow
|
||||
// reading back the snapshot).
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto result = MakeUnique<ImageBitmapCloneData>();
|
||||
result->mPictureRect = mPictureRect;
|
||||
result->mAlphaType = mAlphaType;
|
||||
result->mSurface = std::move(dataSurface);
|
||||
result->mWriteOnly = mWriteOnly;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user