Bug 1562616 - Don't fail to create a GPUVideoTextureHost if the dependent texture isn't available, since that crashes the compositor. r=sotaro
Depends on D37781 Differential Revision: https://phabricator.services.mozilla.com/D37782
This commit is contained in:
@@ -12,9 +12,9 @@
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
GPUVideoTextureHost::GPUVideoTextureHost(TextureFlags aFlags,
|
||||
TextureHost* aWrappedTextureHost)
|
||||
: TextureHost(aFlags), mWrappedTextureHost(aWrappedTextureHost) {
|
||||
GPUVideoTextureHost::GPUVideoTextureHost(
|
||||
TextureFlags aFlags, const SurfaceDescriptorGPUVideo& aDescriptor)
|
||||
: TextureHost(aFlags), mDescriptor(aDescriptor) {
|
||||
MOZ_COUNT_CTOR(GPUVideoTextureHost);
|
||||
}
|
||||
|
||||
@@ -24,52 +24,57 @@ GPUVideoTextureHost::~GPUVideoTextureHost() {
|
||||
|
||||
GPUVideoTextureHost* GPUVideoTextureHost::CreateFromDescriptor(
|
||||
TextureFlags aFlags, const SurfaceDescriptorGPUVideo& aDescriptor) {
|
||||
return new GPUVideoTextureHost(aFlags, aDescriptor);
|
||||
}
|
||||
|
||||
TextureHost* GPUVideoTextureHost::EnsureWrappedTextureHost() {
|
||||
if (mWrappedTextureHost) {
|
||||
return mWrappedTextureHost;
|
||||
}
|
||||
|
||||
// In the future when the RDD process has a PVideoBridge connection,
|
||||
// then there might be two VideoBridgeParents (one within the GPU process,
|
||||
// one from RDD). We'll need to flag which one to use to lookup our
|
||||
// descriptor, or just try both.
|
||||
TextureHost* wrappedTextureHost =
|
||||
VideoBridgeParent::GetSingleton()->LookupTexture(aDescriptor.handle());
|
||||
if (!wrappedTextureHost) {
|
||||
return nullptr;
|
||||
}
|
||||
return new GPUVideoTextureHost(aFlags, wrappedTextureHost);
|
||||
mWrappedTextureHost =
|
||||
VideoBridgeParent::GetSingleton()->LookupTexture(mDescriptor.handle());
|
||||
return mWrappedTextureHost;
|
||||
}
|
||||
|
||||
bool GPUVideoTextureHost::Lock() {
|
||||
if (!mWrappedTextureHost) {
|
||||
if (!EnsureWrappedTextureHost()) {
|
||||
return false;
|
||||
}
|
||||
return mWrappedTextureHost->Lock();
|
||||
return EnsureWrappedTextureHost()->Lock();
|
||||
}
|
||||
|
||||
void GPUVideoTextureHost::Unlock() {
|
||||
if (!mWrappedTextureHost) {
|
||||
if (!EnsureWrappedTextureHost()) {
|
||||
return;
|
||||
}
|
||||
mWrappedTextureHost->Unlock();
|
||||
EnsureWrappedTextureHost()->Unlock();
|
||||
}
|
||||
|
||||
bool GPUVideoTextureHost::BindTextureSource(
|
||||
CompositableTextureSourceRef& aTexture) {
|
||||
if (!mWrappedTextureHost) {
|
||||
if (!EnsureWrappedTextureHost()) {
|
||||
return false;
|
||||
}
|
||||
return mWrappedTextureHost->BindTextureSource(aTexture);
|
||||
return EnsureWrappedTextureHost()->BindTextureSource(aTexture);
|
||||
}
|
||||
|
||||
bool GPUVideoTextureHost::AcquireTextureSource(
|
||||
CompositableTextureSourceRef& aTexture) {
|
||||
if (!mWrappedTextureHost) {
|
||||
if (!EnsureWrappedTextureHost()) {
|
||||
return false;
|
||||
}
|
||||
return mWrappedTextureHost->AcquireTextureSource(aTexture);
|
||||
return EnsureWrappedTextureHost()->AcquireTextureSource(aTexture);
|
||||
}
|
||||
|
||||
void GPUVideoTextureHost::SetTextureSourceProvider(
|
||||
TextureSourceProvider* aProvider) {
|
||||
if (mWrappedTextureHost) {
|
||||
mWrappedTextureHost->SetTextureSourceProvider(aProvider);
|
||||
if (EnsureWrappedTextureHost()) {
|
||||
EnsureWrappedTextureHost()->SetTextureSourceProvider(aProvider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,43 +101,62 @@ gfx::SurfaceFormat GPUVideoTextureHost::GetFormat() const {
|
||||
|
||||
bool GPUVideoTextureHost::HasIntermediateBuffer() const {
|
||||
MOZ_ASSERT(mWrappedTextureHost);
|
||||
if (!mWrappedTextureHost) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mWrappedTextureHost->HasIntermediateBuffer();
|
||||
}
|
||||
|
||||
void GPUVideoTextureHost::CreateRenderTexture(
|
||||
const wr::ExternalImageId& aExternalImageId) {
|
||||
MOZ_ASSERT(mWrappedTextureHost);
|
||||
MOZ_ASSERT(EnsureWrappedTextureHost());
|
||||
if (!EnsureWrappedTextureHost()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mWrappedTextureHost->CreateRenderTexture(aExternalImageId);
|
||||
EnsureWrappedTextureHost()->CreateRenderTexture(aExternalImageId);
|
||||
}
|
||||
|
||||
uint32_t GPUVideoTextureHost::NumSubTextures() const {
|
||||
MOZ_ASSERT(mWrappedTextureHost);
|
||||
if (!mWrappedTextureHost) {
|
||||
return 0;
|
||||
}
|
||||
return mWrappedTextureHost->NumSubTextures();
|
||||
}
|
||||
|
||||
void GPUVideoTextureHost::PushResourceUpdates(
|
||||
wr::TransactionBuilder& aResources, ResourceUpdateOp aOp,
|
||||
const Range<wr::ImageKey>& aImageKeys, const wr::ExternalImageId& aExtID) {
|
||||
MOZ_ASSERT(mWrappedTextureHost);
|
||||
mWrappedTextureHost->PushResourceUpdates(aResources, aOp, aImageKeys, aExtID);
|
||||
MOZ_ASSERT(EnsureWrappedTextureHost());
|
||||
if (!EnsureWrappedTextureHost()) {
|
||||
return;
|
||||
}
|
||||
EnsureWrappedTextureHost()->PushResourceUpdates(aResources, aOp, aImageKeys,
|
||||
aExtID);
|
||||
}
|
||||
|
||||
void GPUVideoTextureHost::PushDisplayItems(
|
||||
wr::DisplayListBuilder& aBuilder, const wr::LayoutRect& aBounds,
|
||||
const wr::LayoutRect& aClip, wr::ImageRendering aFilter,
|
||||
const Range<wr::ImageKey>& aImageKeys) {
|
||||
MOZ_ASSERT(mWrappedTextureHost);
|
||||
MOZ_ASSERT(EnsureWrappedTextureHost());
|
||||
MOZ_ASSERT(aImageKeys.length() > 0);
|
||||
if (!EnsureWrappedTextureHost()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mWrappedTextureHost->PushDisplayItems(aBuilder, aBounds, aClip, aFilter,
|
||||
aImageKeys);
|
||||
EnsureWrappedTextureHost()->PushDisplayItems(aBuilder, aBounds, aClip,
|
||||
aFilter, aImageKeys);
|
||||
}
|
||||
|
||||
bool GPUVideoTextureHost::SupportsWrNativeTexture() {
|
||||
MOZ_ASSERT(mWrappedTextureHost);
|
||||
return mWrappedTextureHost->SupportsWrNativeTexture();
|
||||
MOZ_ASSERT(EnsureWrappedTextureHost());
|
||||
if (!EnsureWrappedTextureHost()) {
|
||||
return false;
|
||||
}
|
||||
return EnsureWrappedTextureHost()->SupportsWrNativeTexture();
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
|
||||
Reference in New Issue
Block a user