forked from mirrors/gecko-dev
Bug 1781122 Part 3: Make macOS video layers prevent capture when TextureHost is DRM. r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D155297
This commit is contained in:
parent
62b54b0774
commit
e7afee4bf1
2 changed files with 26 additions and 9 deletions
|
|
@ -362,7 +362,7 @@ class NativeLayerCA : public NativeLayer {
|
||||||
gfx::SamplingFilter aSamplingFilter,
|
gfx::SamplingFilter aSamplingFilter,
|
||||||
bool aSpecializeVideo,
|
bool aSpecializeVideo,
|
||||||
CFTypeRefPtr<IOSurfaceRef> aFrontSurface,
|
CFTypeRefPtr<IOSurfaceRef> aFrontSurface,
|
||||||
CFTypeRefPtr<CGColorRef> aColor);
|
CFTypeRefPtr<CGColorRef> aColor, bool aIsDRM);
|
||||||
|
|
||||||
// Return whether any aspects of this layer representation have been mutated
|
// Return whether any aspects of this layer representation have been mutated
|
||||||
// since the last call to ApplyChanges, i.e. whether ApplyChanges needs to
|
// since the last call to ApplyChanges, i.e. whether ApplyChanges needs to
|
||||||
|
|
@ -390,6 +390,7 @@ class NativeLayerCA : public NativeLayer {
|
||||||
bool mMutatedFrontSurface : 1;
|
bool mMutatedFrontSurface : 1;
|
||||||
bool mMutatedSamplingFilter : 1;
|
bool mMutatedSamplingFilter : 1;
|
||||||
bool mMutatedSpecializeVideo : 1;
|
bool mMutatedSpecializeVideo : 1;
|
||||||
|
bool mMutatedIsDRM : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
Representation& GetRepresentation(WhichRepresentation aRepresentation);
|
Representation& GetRepresentation(WhichRepresentation aRepresentation);
|
||||||
|
|
@ -466,6 +467,7 @@ class NativeLayerCA : public NativeLayer {
|
||||||
bool mRootWindowIsFullscreen = false;
|
bool mRootWindowIsFullscreen = false;
|
||||||
bool mSpecializeVideo = false;
|
bool mSpecializeVideo = false;
|
||||||
bool mHasExtent = false;
|
bool mHasExtent = false;
|
||||||
|
bool mIsDRM = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace layers
|
} // namespace layers
|
||||||
|
|
|
||||||
|
|
@ -823,11 +823,16 @@ void NativeLayerCA::AttachExternalImage(wr::RenderTextureHost* aExternalImage) {
|
||||||
mSpecializeVideo = ShouldSpecializeVideo(lock);
|
mSpecializeVideo = ShouldSpecializeVideo(lock);
|
||||||
bool changedSpecializeVideo = (mSpecializeVideo != oldSpecializeVideo);
|
bool changedSpecializeVideo = (mSpecializeVideo != oldSpecializeVideo);
|
||||||
|
|
||||||
|
bool oldIsDRM = mIsDRM;
|
||||||
|
mIsDRM = aExternalImage->IsFromDRMSource();
|
||||||
|
bool changedIsDRM = (mIsDRM != oldIsDRM);
|
||||||
|
|
||||||
ForAllRepresentations([&](Representation& r) {
|
ForAllRepresentations([&](Representation& r) {
|
||||||
r.mMutatedFrontSurface = true;
|
r.mMutatedFrontSurface = true;
|
||||||
r.mMutatedDisplayRect |= changedSizeAndDisplayRect;
|
r.mMutatedDisplayRect |= changedSizeAndDisplayRect;
|
||||||
r.mMutatedSize |= changedSizeAndDisplayRect;
|
r.mMutatedSize |= changedSizeAndDisplayRect;
|
||||||
r.mMutatedSpecializeVideo |= changedSpecializeVideo;
|
r.mMutatedSpecializeVideo |= changedSpecializeVideo;
|
||||||
|
r.mMutatedIsDRM |= changedIsDRM;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -852,12 +857,14 @@ bool NativeLayerCA::ShouldSpecializeVideo(const MutexAutoLock& aProofOfLock) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Beyond this point, we need to know about the format of the video.
|
|
||||||
|
|
||||||
MOZ_ASSERT(mTextureHost);
|
MOZ_ASSERT(mTextureHost);
|
||||||
if (!mTextureHost) {
|
|
||||||
return false;
|
// DRM video must use a specialized video layer.
|
||||||
|
if (mTextureHost->IsFromDRMSource()) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Beyond this point, we need to know about the format of the video.
|
||||||
MacIOSurface* macIOSurface = mTextureHost->GetSurface();
|
MacIOSurface* macIOSurface = mTextureHost->GetSurface();
|
||||||
if (macIOSurface->GetYUVColorSpace() == gfx::YUVColorSpace::BT2020) {
|
if (macIOSurface->GetYUVColorSpace() == gfx::YUVColorSpace::BT2020) {
|
||||||
// BT2020 is a signifier of HDR color space, whether or not the bit depth
|
// BT2020 is a signifier of HDR color space, whether or not the bit depth
|
||||||
|
|
@ -1120,7 +1127,8 @@ NativeLayerCA::Representation::Representation()
|
||||||
mMutatedSurfaceIsFlipped(true),
|
mMutatedSurfaceIsFlipped(true),
|
||||||
mMutatedFrontSurface(true),
|
mMutatedFrontSurface(true),
|
||||||
mMutatedSamplingFilter(true),
|
mMutatedSamplingFilter(true),
|
||||||
mMutatedSpecializeVideo(true) {}
|
mMutatedSpecializeVideo(true),
|
||||||
|
mMutatedIsDRM(true) {}
|
||||||
|
|
||||||
NativeLayerCA::Representation::~Representation() {
|
NativeLayerCA::Representation::~Representation() {
|
||||||
[mContentCALayer release];
|
[mContentCALayer release];
|
||||||
|
|
@ -1334,7 +1342,7 @@ bool NativeLayerCA::ApplyChanges(WhichRepresentation aRepresentation,
|
||||||
return GetRepresentation(aRepresentation)
|
return GetRepresentation(aRepresentation)
|
||||||
.ApplyChanges(aUpdate, mSize, mIsOpaque, mPosition, mTransform, mDisplayRect, mClipRect,
|
.ApplyChanges(aUpdate, mSize, mIsOpaque, mPosition, mTransform, mDisplayRect, mClipRect,
|
||||||
mBackingScale, mSurfaceIsFlipped, mSamplingFilter, mSpecializeVideo, surface,
|
mBackingScale, mSurfaceIsFlipped, mSamplingFilter, mSpecializeVideo, surface,
|
||||||
mColor);
|
mColor, mIsDRM);
|
||||||
}
|
}
|
||||||
|
|
||||||
CALayer* NativeLayerCA::UnderlyingCALayer(WhichRepresentation aRepresentation) {
|
CALayer* NativeLayerCA::UnderlyingCALayer(WhichRepresentation aRepresentation) {
|
||||||
|
|
@ -1512,7 +1520,7 @@ bool NativeLayerCA::Representation::ApplyChanges(
|
||||||
const IntPoint& aPosition, const Matrix4x4& aTransform, const IntRect& aDisplayRect,
|
const IntPoint& aPosition, const Matrix4x4& aTransform, const IntRect& aDisplayRect,
|
||||||
const Maybe<IntRect>& aClipRect, float aBackingScale, bool aSurfaceIsFlipped,
|
const Maybe<IntRect>& aClipRect, float aBackingScale, bool aSurfaceIsFlipped,
|
||||||
gfx::SamplingFilter aSamplingFilter, bool aSpecializeVideo,
|
gfx::SamplingFilter aSamplingFilter, bool aSpecializeVideo,
|
||||||
CFTypeRefPtr<IOSurfaceRef> aFrontSurface, CFTypeRefPtr<CGColorRef> aColor) {
|
CFTypeRefPtr<IOSurfaceRef> aFrontSurface, CFTypeRefPtr<CGColorRef> aColor, bool aIsDRM) {
|
||||||
// If we have an OnlyVideo update, handle it and early exit.
|
// If we have an OnlyVideo update, handle it and early exit.
|
||||||
if (aUpdate == UpdateType::OnlyVideo) {
|
if (aUpdate == UpdateType::OnlyVideo) {
|
||||||
// If we don't have any updates to do, exit early with success. This is
|
// If we don't have any updates to do, exit early with success. This is
|
||||||
|
|
@ -1602,6 +1610,12 @@ bool NativeLayerCA::Representation::ApplyChanges(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (@available(macOS 10.15, iOS 13.0, *)) {
|
||||||
|
if (aSpecializeVideo && mMutatedIsDRM) {
|
||||||
|
((AVSampleBufferDisplayLayer*)mContentCALayer).preventsCapture = aIsDRM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool shouldTintOpaqueness = StaticPrefs::gfx_core_animation_tint_opaque();
|
bool shouldTintOpaqueness = StaticPrefs::gfx_core_animation_tint_opaque();
|
||||||
if (shouldTintOpaqueness && !mOpaquenessTintLayer) {
|
if (shouldTintOpaqueness && !mOpaquenessTintLayer) {
|
||||||
mOpaquenessTintLayer = [[CALayer layer] retain];
|
mOpaquenessTintLayer = [[CALayer layer] retain];
|
||||||
|
|
@ -1748,6 +1762,7 @@ bool NativeLayerCA::Representation::ApplyChanges(
|
||||||
mMutatedFrontSurface = false;
|
mMutatedFrontSurface = false;
|
||||||
mMutatedSamplingFilter = false;
|
mMutatedSamplingFilter = false;
|
||||||
mMutatedSpecializeVideo = false;
|
mMutatedSpecializeVideo = false;
|
||||||
|
mMutatedIsDRM = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -1761,7 +1776,7 @@ NativeLayerCA::UpdateType NativeLayerCA::Representation::HasUpdate(bool aIsVideo
|
||||||
// if we can attempt an OnlyVideo update.
|
// if we can attempt an OnlyVideo update.
|
||||||
if (mMutatedPosition || mMutatedTransform || mMutatedDisplayRect || mMutatedClipRect ||
|
if (mMutatedPosition || mMutatedTransform || mMutatedDisplayRect || mMutatedClipRect ||
|
||||||
mMutatedBackingScale || mMutatedSize || mMutatedSurfaceIsFlipped || mMutatedSamplingFilter ||
|
mMutatedBackingScale || mMutatedSize || mMutatedSurfaceIsFlipped || mMutatedSamplingFilter ||
|
||||||
mMutatedSpecializeVideo) {
|
mMutatedSpecializeVideo || mMutatedIsDRM) {
|
||||||
return UpdateType::All;
|
return UpdateType::All;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue