forked from mirrors/gecko-dev
Bug 1757637 - Use the ImageContainer to determine video{Width,Height} instead of passing through the state machine. r=alwu
This means there is significantly less chance of desynchronization between the actual size of the image and the reported size of the image. Differential Revision: https://phabricator.services.mozilla.com/D149150
This commit is contained in:
parent
a57d022de1
commit
3037980689
2 changed files with 44 additions and 22 deletions
|
|
@ -215,6 +215,44 @@ bool HTMLVideoElement::IsInteractiveHTMLContent() const {
|
||||||
HTMLMediaElement::IsInteractiveHTMLContent();
|
HTMLMediaElement::IsInteractiveHTMLContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfx::IntSize HTMLVideoElement::GetVideoIntrinsicDimensions() {
|
||||||
|
layers::ImageContainer* container = GetImageContainer();
|
||||||
|
// Prefer the size of the container as it's more up to date.
|
||||||
|
if (container && container->GetCurrentSize().width != 0) {
|
||||||
|
// But adjust to the aspect ratio of the container.
|
||||||
|
float dar = static_cast<float>(mMediaInfo.mVideo.mDisplay.width) /
|
||||||
|
mMediaInfo.mVideo.mDisplay.height;
|
||||||
|
gfx::IntSize size = container->GetCurrentSize();
|
||||||
|
float imageDar = static_cast<float>(size.width) / size.height;
|
||||||
|
return gfx::IntSize(int(size.width * (dar / imageDar)), size.height);
|
||||||
|
}
|
||||||
|
return mMediaInfo.mVideo.mDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t HTMLVideoElement::VideoWidth() {
|
||||||
|
if (!mMediaInfo.HasVideo()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
gfx::IntSize size = GetVideoIntrinsicDimensions();
|
||||||
|
if (mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_90 ||
|
||||||
|
mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_270) {
|
||||||
|
return size.height;
|
||||||
|
}
|
||||||
|
return size.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t HTMLVideoElement::VideoHeight() {
|
||||||
|
if (!mMediaInfo.HasVideo()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
gfx::IntSize size = GetVideoIntrinsicDimensions();
|
||||||
|
if (mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_90 ||
|
||||||
|
mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_270) {
|
||||||
|
return size.width;
|
||||||
|
}
|
||||||
|
return size.height;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t HTMLVideoElement::MozParsedFrames() const {
|
uint32_t HTMLVideoElement::MozParsedFrames() const {
|
||||||
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
||||||
if (!IsVideoStatsEnabled()) {
|
if (!IsVideoStatsEnabled()) {
|
||||||
|
|
@ -241,7 +279,7 @@ uint32_t HTMLVideoElement::MozDecodedFrames() const {
|
||||||
return mDecoder ? mDecoder->GetFrameStatistics().GetDecodedFrames() : 0;
|
return mDecoder ? mDecoder->GetFrameStatistics().GetDecodedFrames() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t HTMLVideoElement::MozPresentedFrames() const {
|
uint32_t HTMLVideoElement::MozPresentedFrames() {
|
||||||
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
||||||
if (!IsVideoStatsEnabled()) {
|
if (!IsVideoStatsEnabled()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -81,27 +81,9 @@ class HTMLVideoElement final : public HTMLMediaElement {
|
||||||
SetUnsignedIntAttr(nsGkAtoms::height, aValue, 0, aRv);
|
SetUnsignedIntAttr(nsGkAtoms::height, aValue, 0, aRv);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t VideoWidth() const {
|
uint32_t VideoWidth();
|
||||||
if (mMediaInfo.HasVideo()) {
|
|
||||||
if (mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_90 ||
|
|
||||||
mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_270) {
|
|
||||||
return mMediaInfo.mVideo.mDisplay.height;
|
|
||||||
}
|
|
||||||
return mMediaInfo.mVideo.mDisplay.width;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t VideoHeight() const {
|
uint32_t VideoHeight();
|
||||||
if (mMediaInfo.HasVideo()) {
|
|
||||||
if (mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_90 ||
|
|
||||||
mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_270) {
|
|
||||||
return mMediaInfo.mVideo.mDisplay.width;
|
|
||||||
}
|
|
||||||
return mMediaInfo.mVideo.mDisplay.height;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoInfo::Rotation RotationDegrees() const {
|
VideoInfo::Rotation RotationDegrees() const {
|
||||||
return mMediaInfo.mVideo.mRotation;
|
return mMediaInfo.mVideo.mRotation;
|
||||||
|
|
@ -120,7 +102,7 @@ class HTMLVideoElement final : public HTMLMediaElement {
|
||||||
|
|
||||||
uint32_t MozDecodedFrames() const;
|
uint32_t MozDecodedFrames() const;
|
||||||
|
|
||||||
uint32_t MozPresentedFrames() const;
|
uint32_t MozPresentedFrames();
|
||||||
|
|
||||||
uint32_t MozPaintedFrames();
|
uint32_t MozPaintedFrames();
|
||||||
|
|
||||||
|
|
@ -169,6 +151,8 @@ class HTMLVideoElement final : public HTMLMediaElement {
|
||||||
void CreateVideoWakeLockIfNeeded();
|
void CreateVideoWakeLockIfNeeded();
|
||||||
void ReleaseVideoWakeLockIfExists();
|
void ReleaseVideoWakeLockIfExists();
|
||||||
|
|
||||||
|
gfx::IntSize GetVideoIntrinsicDimensions();
|
||||||
|
|
||||||
RefPtr<WakeLock> mScreenWakeLock;
|
RefPtr<WakeLock> mScreenWakeLock;
|
||||||
|
|
||||||
bool mIsOrientationLocked;
|
bool mIsOrientationLocked;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue