Bug 1832479 use types for decoder owner Invalidate() boolean parameters r=pehrsons

for safety and readability.

Differential Revision: https://phabricator.services.mozilla.com/D177983
This commit is contained in:
Karl Tomlinson 2023-05-16 21:30:29 +00:00
parent 01a3ef4ecb
commit fb0873a1d5
6 changed files with 22 additions and 17 deletions

View File

@ -2336,7 +2336,7 @@ void HTMLMediaElement::AbortExistingLoads() {
if (IsVideo() && hadVideo) {
// Ensure we render transparent black after resetting video resolution.
Maybe<nsIntSize> size = Some(nsIntSize(0, 0));
Invalidate(true, size, false);
Invalidate(ImageSizeChanged::Yes, size, ForceInvalidate::No);
}
// As aborting current load would stop current playback, so we have no need to
@ -6339,9 +6339,9 @@ void HTMLMediaElement::NotifyDecoderPrincipalChanged() {
mDecoder->SetOutputTracksPrincipal(principal);
}
void HTMLMediaElement::Invalidate(bool aImageSizeChanged,
void HTMLMediaElement::Invalidate(ImageSizeChanged aImageSizeChanged,
const Maybe<nsIntSize>& aNewIntrinsicSize,
bool aForceInvalidate) {
ForceInvalidate aForceInvalidate) {
nsIFrame* frame = GetPrimaryFrame();
if (aNewIntrinsicSize) {
UpdateMediaSize(aNewIntrinsicSize.value());
@ -6355,10 +6355,10 @@ void HTMLMediaElement::Invalidate(bool aImageSizeChanged,
}
RefPtr<ImageContainer> imageContainer = GetImageContainer();
bool asyncInvalidate =
imageContainer && imageContainer->IsAsync() && !aForceInvalidate;
bool asyncInvalidate = imageContainer && imageContainer->IsAsync() &&
aForceInvalidate == ForceInvalidate::No;
if (frame) {
if (aImageSizeChanged) {
if (aImageSizeChanged == ImageSizeChanged::Yes) {
frame->InvalidateFrame();
} else {
frame->InvalidateLayer(DisplayItemType::TYPE_VIDEO, nullptr, nullptr,

View File

@ -372,9 +372,9 @@ class HTMLMediaElement : public nsGenericHTMLElement,
// main thread when/if the size changes.
virtual void UpdateMediaSize(const nsIntSize& aSize);
void Invalidate(bool aImageSizeChanged,
void Invalidate(ImageSizeChanged aImageSizeChanged,
const Maybe<nsIntSize>& aNewIntrinsicSize,
bool aForceInvalidate) override;
ForceInvalidate aForceInvalidate) override;
// Returns the CanPlayStatus indicating if we can handle the
// full MIME type including the optional codecs parameter.

View File

@ -108,7 +108,8 @@ void HTMLVideoElement::UpdateMediaSize(const nsIntSize& aSize) {
// If we have a clone target, we should update its size as well.
if (mVisualCloneTarget) {
Maybe<nsIntSize> newSize = Some(aSize);
mVisualCloneTarget->Invalidate(true, newSize, true);
mVisualCloneTarget->Invalidate(ImageSizeChanged::Yes, newSize,
ForceInvalidate::Yes);
}
}
@ -140,9 +141,9 @@ Maybe<CSSIntSize> HTMLVideoElement::GetVideoSize() const {
return Some(size);
}
void HTMLVideoElement::Invalidate(bool aImageSizeChanged,
void HTMLVideoElement::Invalidate(ImageSizeChanged aImageSizeChanged,
const Maybe<nsIntSize>& aNewIntrinsicSize,
bool aForceInvalidate) {
ForceInvalidate aForceInvalidate) {
HTMLMediaElement::Invalidate(aImageSizeChanged, aNewIntrinsicSize,
aForceInvalidate);
if (mVisualCloneTarget) {

View File

@ -36,9 +36,9 @@ class HTMLVideoElement final : public HTMLMediaElement {
using HTMLMediaElement::GetPaused;
void Invalidate(bool aImageSizeChanged,
void Invalidate(ImageSizeChanged aImageSizeChanged,
const Maybe<nsIntSize>& aNewIntrinsicSize,
bool aForceInvalidate) override;
ForceInvalidate aForceInvalidate) override;
virtual bool IsVideo() const override { return true; }

View File

@ -165,9 +165,11 @@ class MediaDecoderOwner {
// Called by the frame container to notify the layout engine that the
// size of the image has changed, or the video needs to be be repainted
// for some other reason.
virtual void Invalidate(bool aImageSizeChanged,
enum class ImageSizeChanged { No, Yes };
enum class ForceInvalidate { No, Yes };
virtual void Invalidate(ImageSizeChanged aImageSizeChanged,
const Maybe<nsIntSize>& aNewIntrinsicSize,
bool aForceInvalidate) {}
ForceInvalidate aForceInvalidate) {}
// Called after the MediaStream we're playing rendered a frame to aContainer
// with a different principalHandle than the previous frame.

View File

@ -241,12 +241,14 @@ void VideoFrameContainer::InvalidateWithFlags(uint32_t aFlags) {
return;
}
bool imageSizeChanged = mMainThreadState.mImageSizeChanged;
MediaDecoderOwner::ImageSizeChanged imageSizeChanged{
mMainThreadState.mImageSizeChanged};
mMainThreadState.mImageSizeChanged = false;
auto newIntrinsicSize = std::move(mMainThreadState.mNewIntrinsicSize);
bool forceInvalidate = aFlags & INVALIDATE_FORCE;
MediaDecoderOwner::ForceInvalidate forceInvalidate{
(aFlags & INVALIDATE_FORCE) != 0};
mOwner->Invalidate(imageSizeChanged, newIntrinsicSize, forceInvalidate);
}