Bug 1807215 - Simplify intrinsic size handling in VideoFrameContainer by removing the intrinsicSizeChanged flag. r=padenot

Differential Revision: https://phabricator.services.mozilla.com/D174084
This commit is contained in:
Andreas Pehrson 2023-04-03 08:36:39 +00:00
parent 6524982237
commit 0194ff28ce
2 changed files with 16 additions and 22 deletions

View File

@ -133,13 +133,11 @@ void VideoFrameContainer::SetCurrentFramesLocked(
const nsTArray<ImageContainer::NonOwningImage>& aImages) {
mMutex.AssertCurrentThreadOwns();
if (aIntrinsicSize != mIntrinsicSize) {
mIntrinsicSize = aIntrinsicSize;
RefPtr<VideoFrameContainer> self = this;
if (auto size = Some(aIntrinsicSize); size != mIntrinsicSize) {
mIntrinsicSize = size;
mMainThread->Dispatch(NS_NewRunnableFunction(
"IntrinsicSizeChanged", [this, self, aIntrinsicSize]() {
mMainThreadState.mIntrinsicSize = aIntrinsicSize;
mMainThreadState.mIntrinsicSizeChanged = true;
"IntrinsicSizeChanged", [this, self = RefPtr(this), size]() {
mMainThreadState.mNewIntrinsicSize = size;
}));
}
@ -246,14 +244,10 @@ void VideoFrameContainer::InvalidateWithFlags(uint32_t aFlags) {
bool imageSizeChanged = mMainThreadState.mImageSizeChanged;
mMainThreadState.mImageSizeChanged = false;
Maybe<nsIntSize> intrinsicSize;
if (mMainThreadState.mIntrinsicSizeChanged) {
intrinsicSize = Some(mMainThreadState.mIntrinsicSize);
mMainThreadState.mIntrinsicSizeChanged = false;
}
auto newIntrinsicSize = std::move(mMainThreadState.mNewIntrinsicSize);
bool forceInvalidate = aFlags & INVALIDATE_FORCE;
mOwner->Invalidate(imageSizeChanged, intrinsicSize, forceInvalidate);
mOwner->Invalidate(imageSizeChanged, newIntrinsicSize, forceInvalidate);
}
} // namespace mozilla

View File

@ -90,7 +90,7 @@ class VideoFrameContainer {
return mImageContainer->GetDroppedImageCount();
}
gfx::IntSize CurrentIntrinsicSize() {
Maybe<gfx::IntSize> CurrentIntrinsicSize() {
MutexAutoLock lock(mMutex);
return mIntrinsicSize;
}
@ -112,14 +112,14 @@ class VideoFrameContainer {
// frame is fully invalidated instead of just invalidating for the image
// change in the ImageLayer.
bool mImageSizeChanged = false;
// The main thread mirror of the member of the same name below.
gfx::IntSize mIntrinsicSize;
// True when the intrinsic size has been changed by SetCurrentFrame() since
// the last call to Invalidate().
// The next call to Invalidate() will recalculate
// and update the intrinsic size on the element, request a frame reflow and
// then reset this flag.
bool mIntrinsicSizeChanged = false;
// The main thread mirror of the member of the same name below, in case it
// has changed.
// Set to some size when the intrinsic size has been changed by
// SetCurrentFrame() since the last call to Invalidate().
// The next call to Invalidate() will recalculate and update the intrinsic
// size on the element, request a frame reflow and then reset this to
// Nothing.
Maybe<gfx::IntSize> mNewIntrinsicSize;
} mMainThreadState;
Mutex mMutex;
@ -128,7 +128,7 @@ class VideoFrameContainer {
// This can differ from the Image's actual size when the media resource
// specifies that the Image should be stretched to have the correct aspect
// ratio.
gfx::IntSize mIntrinsicSize MOZ_GUARDED_BY(mMutex);
Maybe<gfx::IntSize> mIntrinsicSize MOZ_GUARDED_BY(mMutex);
// We maintain our own mFrameID which is auto-incremented at every
// SetCurrentFrame() or NewFrameID() call.
ImageContainer::FrameID mFrameID;