mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1516834 - Check if CopyData succeeded r=nical
When CopyData failed, an image does not have valid data. It should not be used. Differential Revision: https://phabricator.services.mozilla.com/D19746
This commit is contained in:
parent
e8a5e4dfbc
commit
e7cc92c95a
@ -80,7 +80,7 @@ void VideoFrameContainer::UpdatePrincipalHandleForFrameIDLocked(
|
||||
mFrameIDForPendingPrincipalHandle = aFrameID;
|
||||
}
|
||||
|
||||
static void SetImageToBlackPixel(PlanarYCbCrImage* aImage) {
|
||||
static bool SetImageToBlackPixel(PlanarYCbCrImage* aImage) {
|
||||
uint8_t blackPixel[] = {0x10, 0x80, 0x80};
|
||||
|
||||
PlanarYCbCrData data;
|
||||
@ -89,7 +89,7 @@ static void SetImageToBlackPixel(PlanarYCbCrImage* aImage) {
|
||||
data.mCrChannel = blackPixel + 2;
|
||||
data.mYStride = data.mCbCrStride = 1;
|
||||
data.mPicSize = data.mYSize = data.mCbCrSize = gfx::IntSize(1, 1);
|
||||
aImage->CopyData(data);
|
||||
return aImage->CopyData(data);
|
||||
}
|
||||
|
||||
class VideoFrameContainerInvalidateRunnable : public Runnable {
|
||||
@ -142,11 +142,13 @@ void VideoFrameContainer::SetCurrentFrames(const VideoSegment& aSegment) {
|
||||
|
||||
if (frame->GetForceBlack()) {
|
||||
if (!mBlackImage) {
|
||||
mBlackImage = GetImageContainer()->CreatePlanarYCbCrImage();
|
||||
if (mBlackImage) {
|
||||
RefPtr<Image> blackImage = GetImageContainer()->CreatePlanarYCbCrImage();
|
||||
if (blackImage) {
|
||||
// Sets the image to a single black pixel, which will be scaled to
|
||||
// fill the rendered size.
|
||||
SetImageToBlackPixel(mBlackImage->AsPlanarYCbCrImage());
|
||||
if (SetImageToBlackPixel(blackImage->AsPlanarYCbCrImage())) {
|
||||
mBlackImage = blackImage;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mBlackImage) {
|
||||
|
@ -64,7 +64,8 @@ RefPtr<mozilla::layers::Image> RemoteVideoDecoderChild::DeserializeImage(
|
||||
// images coming from AOMDecoder are RecyclingPlanarYCbCrImages.
|
||||
RefPtr<RecyclingPlanarYCbCrImage> image =
|
||||
new RecyclingPlanarYCbCrImage(mBufferRecycleBin);
|
||||
image->CopyData(pData);
|
||||
bool setData = image->CopyData(pData);
|
||||
MOZ_ASSERT(setData);
|
||||
|
||||
switch (memOrShmem.type()) {
|
||||
case MemoryOrShmem::Tuintptr_t:
|
||||
@ -77,6 +78,10 @@ RefPtr<mozilla::layers::Image> RemoteVideoDecoderChild::DeserializeImage(
|
||||
MOZ_ASSERT(false, "Unknown MemoryOrShmem type");
|
||||
}
|
||||
|
||||
if (!setData) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user