mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1668840 - P1. Add SharedRGBImage constructor for TextureClientRecycleAllocator. r=mattwoodrow
Differential Revision: https://phabricator.services.mozilla.com/D92361
This commit is contained in:
parent
9e8b4a210f
commit
10c246bc45
@ -236,10 +236,13 @@ RefPtr<PlanarYCbCrImage> ImageContainer::CreatePlanarYCbCrImage() {
|
||||
RefPtr<SharedRGBImage> ImageContainer::CreateSharedRGBImage() {
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
EnsureImageClient();
|
||||
if (!mImageClient || !mImageClient->AsImageClientSingle()) {
|
||||
return nullptr;
|
||||
if (mImageClient && mImageClient->AsImageClientSingle()) {
|
||||
return new SharedRGBImage(mImageClient);
|
||||
}
|
||||
return new SharedRGBImage(mImageClient);
|
||||
if (mRecycleAllocator) {
|
||||
return new SharedRGBImage(mRecycleAllocator);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ImageContainer::SetCurrentImageInternal(
|
||||
|
@ -55,27 +55,41 @@ SharedRGBImage::SharedRGBImage(ImageClient* aCompositable)
|
||||
MOZ_COUNT_CTOR(SharedRGBImage);
|
||||
}
|
||||
|
||||
SharedRGBImage::SharedRGBImage(TextureClientRecycleAllocator* aRecycleAllocator)
|
||||
: Image(nullptr, ImageFormat::SHARED_RGB),
|
||||
mRecycleAllocator(aRecycleAllocator) {
|
||||
MOZ_COUNT_CTOR(SharedRGBImage);
|
||||
}
|
||||
|
||||
SharedRGBImage::~SharedRGBImage() {
|
||||
MOZ_COUNT_DTOR(SharedRGBImage);
|
||||
NS_ReleaseOnMainThread("SharedRGBImage::mSourceSurface",
|
||||
mSourceSurface.forget());
|
||||
}
|
||||
|
||||
bool SharedRGBImage::Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat) {
|
||||
TextureClientRecycleAllocator* SharedRGBImage::RecycleAllocator() {
|
||||
static const uint32_t MAX_POOLED_VIDEO_COUNT = 5;
|
||||
|
||||
if (!mRecycleAllocator && mCompositable) {
|
||||
if (!mCompositable->HasTextureClientRecycler()) {
|
||||
// Initialize TextureClientRecycler
|
||||
mCompositable->GetTextureClientRecycler()->SetMaxPoolSize(
|
||||
MAX_POOLED_VIDEO_COUNT);
|
||||
}
|
||||
mRecycleAllocator = mCompositable->GetTextureClientRecycler();
|
||||
}
|
||||
return mRecycleAllocator;
|
||||
}
|
||||
|
||||
bool SharedRGBImage::Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat) {
|
||||
mSize = aSize;
|
||||
|
||||
if (!mCompositable->HasTextureClientRecycler()) {
|
||||
// Initialize TextureClientRecycler
|
||||
mCompositable->GetTextureClientRecycler()->SetMaxPoolSize(
|
||||
MAX_POOLED_VIDEO_COUNT);
|
||||
}
|
||||
|
||||
TextureFlags flags =
|
||||
mCompositable ? mCompositable->GetTextureFlags() : TextureFlags::DEFAULT;
|
||||
{
|
||||
TextureClientForRawBufferAccessAllocationHelper helper(
|
||||
aFormat, aSize, mCompositable->GetTextureFlags());
|
||||
mTextureClient =
|
||||
mCompositable->GetTextureClientRecycler()->CreateOrRecycle(helper);
|
||||
TextureClientForRawBufferAccessAllocationHelper helper(aFormat, aSize,
|
||||
flags);
|
||||
mTextureClient = RecycleAllocator()->CreateOrRecycle(helper);
|
||||
}
|
||||
|
||||
return !!mTextureClient;
|
||||
|
@ -7,8 +7,9 @@
|
||||
#ifndef SHAREDRGBIMAGE_H_
|
||||
#define SHAREDRGBIMAGE_H_
|
||||
|
||||
#include <stddef.h> // for size_t
|
||||
#include <stdint.h> // for uint8_t
|
||||
#include <stddef.h> // for size_t
|
||||
#include <stdint.h> // for uint8_t
|
||||
|
||||
#include "ImageContainer.h" // for ISharedImage, Image, etc
|
||||
#include "gfxTypes.h"
|
||||
#include "mozilla/Attributes.h" // for override
|
||||
@ -30,6 +31,7 @@ class TextureClient;
|
||||
class SharedRGBImage : public Image {
|
||||
public:
|
||||
explicit SharedRGBImage(ImageClient* aCompositable);
|
||||
explicit SharedRGBImage(TextureClientRecycleAllocator* aRecycleAllocator);
|
||||
|
||||
protected:
|
||||
virtual ~SharedRGBImage();
|
||||
@ -44,9 +46,12 @@ class SharedRGBImage : public Image {
|
||||
bool Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
|
||||
|
||||
private:
|
||||
TextureClientRecycleAllocator* RecycleAllocator();
|
||||
|
||||
gfx::IntSize mSize;
|
||||
RefPtr<ImageClient> mCompositable;
|
||||
RefPtr<TextureClient> mTextureClient;
|
||||
RefPtr<ImageClient> mCompositable;
|
||||
RefPtr<TextureClientRecycleAllocator> mRecycleAllocator;
|
||||
RefPtr<gfx::SourceSurface> mSourceSurface;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user