зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1618429 - Add RecycleAllocator support to ImageContainer for RDD process r=nical
Differential Revision: https://phabricator.services.mozilla.com/D64508 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
10a487cd99
Коммит
2e6730be8d
|
@ -264,10 +264,16 @@ RemoteVideoDecoderParent::RemoteVideoDecoderParent(
|
|||
KnowsCompositorVideo::TryCreateForIdentifier(*aIdentifier);
|
||||
}
|
||||
|
||||
RefPtr<layers::ImageContainer> container = new layers::ImageContainer();
|
||||
if (mKnowsCompositor && XRE_IsRDDProcess()) {
|
||||
// Ensure to allocate recycle allocator
|
||||
container->EnsureRecycleAllocatorForRDD(mKnowsCompositor);
|
||||
}
|
||||
|
||||
CreateDecoderParams params(mVideoInfo);
|
||||
params.mTaskQueue = mDecodeTaskQueue;
|
||||
params.mKnowsCompositor = mKnowsCompositor;
|
||||
params.mImageContainer = new layers::ImageContainer();
|
||||
params.mImageContainer = container;
|
||||
params.mRate = CreateDecoderParams::VideoFrameRate(aFramerate);
|
||||
params.mOptions = aOptions;
|
||||
MediaResult error(NS_OK);
|
||||
|
|
|
@ -228,6 +228,9 @@ RefPtr<PlanarYCbCrImage> ImageContainer::CreatePlanarYCbCrImage() {
|
|||
if (mImageClient && mImageClient->AsImageClientSingle()) {
|
||||
return new SharedPlanarYCbCrImage(mImageClient);
|
||||
}
|
||||
if (mRecycleAllocator) {
|
||||
return new SharedPlanarYCbCrImage(mRecycleAllocator);
|
||||
}
|
||||
return mImageFactory->CreatePlanarYCbCrImage(mScaleHint, mRecycleBin);
|
||||
}
|
||||
|
||||
|
@ -410,6 +413,24 @@ void ImageContainer::NotifyDropped(uint32_t aDropped) {
|
|||
mDroppedImageCount += aDropped;
|
||||
}
|
||||
|
||||
void ImageContainer::EnsureRecycleAllocatorForRDD(
|
||||
KnowsCompositor* aKnowsCompositor) {
|
||||
MOZ_ASSERT(!mIsAsync);
|
||||
MOZ_ASSERT(!mImageClient);
|
||||
MOZ_ASSERT(XRE_IsRDDProcess());
|
||||
|
||||
if (mRecycleAllocator &&
|
||||
aKnowsCompositor == mRecycleAllocator->GetKnowsCompositor()) {
|
||||
return;
|
||||
}
|
||||
|
||||
static const uint32_t MAX_POOLED_VIDEO_COUNT = 5;
|
||||
|
||||
mRecycleAllocator =
|
||||
new layers::TextureClientRecycleAllocator(aKnowsCompositor);
|
||||
mRecycleAllocator->SetMaxPoolSize(MAX_POOLED_VIDEO_COUNT);
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
D3D11YCbCrRecycleAllocator* ImageContainer::GetD3D11YCbCrRecycleAllocator(
|
||||
KnowsCompositor* aKnowsCompositor) {
|
||||
|
|
|
@ -146,6 +146,7 @@ class SharedPlanarYCbCrImage;
|
|||
class SharedSurfacesAnimation;
|
||||
class PlanarYCbCrImage;
|
||||
class TextureClient;
|
||||
class TextureClientRecycleAllocator;
|
||||
class KnowsCompositor;
|
||||
class NVImage;
|
||||
#ifdef XP_WIN
|
||||
|
@ -546,6 +547,8 @@ class ImageContainer final : public SupportsWeakPtr<ImageContainer> {
|
|||
|
||||
ImageFactory* GetImageFactory() const { return mImageFactory; }
|
||||
|
||||
void EnsureRecycleAllocatorForRDD(KnowsCompositor* aKnowsCompositor);
|
||||
|
||||
#ifdef XP_WIN
|
||||
D3D11YCbCrRecycleAllocator* GetD3D11YCbCrRecycleAllocator(
|
||||
KnowsCompositor* aKnowsCompositor);
|
||||
|
@ -630,6 +633,8 @@ class ImageContainer final : public SupportsWeakPtr<ImageContainer> {
|
|||
// image", and any other state which is shared between threads.
|
||||
RecursiveMutex mRecursiveMutex;
|
||||
|
||||
RefPtr<TextureClientRecycleAllocator> mRecycleAllocator;
|
||||
|
||||
#ifdef XP_WIN
|
||||
RefPtr<D3D11YCbCrRecycleAllocator> mD3D11YCbCrRecycleAllocator;
|
||||
#endif
|
||||
|
|
|
@ -35,7 +35,9 @@ SharedPlanarYCbCrImage::SharedPlanarYCbCrImage(ImageClient* aCompositable)
|
|||
|
||||
SharedPlanarYCbCrImage::SharedPlanarYCbCrImage(
|
||||
TextureClientRecycleAllocator* aRecycleAllocator)
|
||||
: mRecycleAllocator(aRecycleAllocator) {}
|
||||
: mRecycleAllocator(aRecycleAllocator) {
|
||||
MOZ_COUNT_CTOR(SharedPlanarYCbCrImage);
|
||||
}
|
||||
|
||||
SharedPlanarYCbCrImage::~SharedPlanarYCbCrImage() {
|
||||
MOZ_COUNT_DTOR(SharedPlanarYCbCrImage);
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include "VideoBridgeParent.h"
|
||||
#include "CompositorThread.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mtransport/runnable_utils.h"
|
||||
#include "SynchronousTask.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -57,6 +59,15 @@ VideoBridgeChild* VideoBridgeChild::GetSingleton() { return sVideoBridge; }
|
|||
bool VideoBridgeChild::AllocUnsafeShmem(
|
||||
size_t aSize, ipc::SharedMemory::SharedMemoryType aType,
|
||||
ipc::Shmem* aShmem) {
|
||||
if (MessageLoop::current() != mMessageLoop) {
|
||||
return DispatchAllocShmemInternal(aSize, aType, aShmem,
|
||||
true); // true: unsafe
|
||||
}
|
||||
|
||||
if (!CanSend()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return PVideoBridgeChild::AllocUnsafeShmem(aSize, aType, aShmem);
|
||||
}
|
||||
|
||||
|
@ -67,8 +78,69 @@ bool VideoBridgeChild::AllocShmem(size_t aSize,
|
|||
return PVideoBridgeChild::AllocShmem(aSize, aType, aShmem);
|
||||
}
|
||||
|
||||
void VideoBridgeChild::ProxyAllocShmemNow(SynchronousTask* aTask, size_t aSize,
|
||||
SharedMemory::SharedMemoryType aType,
|
||||
ipc::Shmem* aShmem, bool aUnsafe,
|
||||
bool* aSuccess) {
|
||||
AutoCompleteTask complete(aTask);
|
||||
|
||||
if (!CanSend()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
if (aUnsafe) {
|
||||
ok = AllocUnsafeShmem(aSize, aType, aShmem);
|
||||
} else {
|
||||
ok = AllocShmem(aSize, aType, aShmem);
|
||||
}
|
||||
*aSuccess = ok;
|
||||
}
|
||||
|
||||
bool VideoBridgeChild::DispatchAllocShmemInternal(
|
||||
size_t aSize, SharedMemory::SharedMemoryType aType, ipc::Shmem* aShmem,
|
||||
bool aUnsafe) {
|
||||
SynchronousTask task("AllocatorProxy alloc");
|
||||
|
||||
bool success = false;
|
||||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
RefPtr<VideoBridgeChild>(this), &VideoBridgeChild::ProxyAllocShmemNow,
|
||||
&task, aSize, aType, aShmem, aUnsafe, &success);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void VideoBridgeChild::ProxyDeallocShmemNow(SynchronousTask* aTask,
|
||||
ipc::Shmem* aShmem, bool* aResult) {
|
||||
AutoCompleteTask complete(aTask);
|
||||
|
||||
if (!CanSend()) {
|
||||
return;
|
||||
}
|
||||
*aResult = DeallocShmem(*aShmem);
|
||||
}
|
||||
|
||||
bool VideoBridgeChild::DeallocShmem(ipc::Shmem& aShmem) {
|
||||
return PVideoBridgeChild::DeallocShmem(aShmem);
|
||||
if (MessageLoop::current() == mMessageLoop) {
|
||||
if (!CanSend()) {
|
||||
return false;
|
||||
}
|
||||
return PVideoBridgeChild::DeallocShmem(aShmem);
|
||||
}
|
||||
|
||||
SynchronousTask task("AllocatorProxy Dealloc");
|
||||
bool result = false;
|
||||
|
||||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
RefPtr<VideoBridgeChild>(this), &VideoBridgeChild::ProxyDeallocShmemNow,
|
||||
&task, &aShmem, &result);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
return result;
|
||||
}
|
||||
|
||||
PTextureChild* VideoBridgeChild::AllocPTextureChild(const SurfaceDescriptor&,
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class SynchronousTask;
|
||||
|
||||
class VideoBridgeChild final : public PVideoBridgeChild,
|
||||
public TextureForwarder {
|
||||
public:
|
||||
|
@ -69,6 +71,15 @@ class VideoBridgeChild final : public PVideoBridgeChild,
|
|||
|
||||
protected:
|
||||
void HandleFatalError(const char* aMsg) const override;
|
||||
bool DispatchAllocShmemInternal(size_t aSize,
|
||||
SharedMemory::SharedMemoryType aType,
|
||||
mozilla::ipc::Shmem* aShmem, bool aUnsafe);
|
||||
void ProxyAllocShmemNow(SynchronousTask* aTask, size_t aSize,
|
||||
SharedMemory::SharedMemoryType aType,
|
||||
mozilla::ipc::Shmem* aShmem, bool aUnsafe,
|
||||
bool* aSuccess);
|
||||
void ProxyDeallocShmemNow(SynchronousTask* aTask, mozilla::ipc::Shmem* aShmem,
|
||||
bool* aResult);
|
||||
|
||||
private:
|
||||
VideoBridgeChild();
|
||||
|
|
Загрузка…
Ссылка в новой задаче