зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1200595 - SharedSurface TextureData implementation. r=jgilbert
This commit is contained in:
Родитель
16729dbd9c
Коммит
7e5a0d6376
|
@ -355,7 +355,7 @@ SurfaceFactory::NewTexClient(const gfx::IntSize& size)
|
|||
return nullptr;
|
||||
|
||||
RefPtr<layers::SharedSurfaceTextureClient> ret;
|
||||
ret = new layers::SharedSurfaceTextureClient(mAllocator, mFlags, Move(surf), this);
|
||||
ret = layers::SharedSurfaceTextureClient::Create(Move(surf), this, mAllocator, mFlags);
|
||||
|
||||
StartRecycling(ret);
|
||||
|
||||
|
@ -391,7 +391,7 @@ SurfaceFactory::RecycleCallback(layers::TextureClient* rawTC, void* rawFactory)
|
|||
tc = static_cast<layers::SharedSurfaceTextureClient*>(rawTC);
|
||||
SurfaceFactory* factory = static_cast<SurfaceFactory*>(rawFactory);
|
||||
|
||||
if (tc->mSurf->mCanRecycle) {
|
||||
if (tc->Surf()->mCanRecycle) {
|
||||
if (factory->Recycle(tc))
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -535,6 +535,7 @@ public:
|
|||
|
||||
/// If you add new code that uses this funtion, you are probably doing something wrong.
|
||||
virtual TextureData* GetInternalData() { return nullptr; }
|
||||
virtual const TextureData* GetInternalData() const { return nullptr; }
|
||||
|
||||
private:
|
||||
static void TextureClientRecycleCallback(TextureClient* aClient, void* aClosure);
|
||||
|
@ -704,6 +705,7 @@ public:
|
|||
|
||||
/// If you add new code that uses this method, you are probably doing something wrong.
|
||||
virtual TextureData* GetInternalData() override { return mData; }
|
||||
virtual const TextureData* GetInternalData() const override { return mData; }
|
||||
|
||||
virtual void FinalizeOnIPDLThread() override;
|
||||
|
||||
|
|
|
@ -23,40 +23,56 @@ using namespace mozilla::gl;
|
|||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
SharedSurfaceTextureClient::SharedSurfaceTextureClient(ISurfaceAllocator* aAllocator,
|
||||
TextureFlags aFlags,
|
||||
UniquePtr<gl::SharedSurface> surf,
|
||||
gl::SurfaceFactory* factory)
|
||||
: TextureClient(aAllocator,
|
||||
aFlags | TextureFlags::RECYCLE | surf->GetTextureFlags())
|
||||
, mSurf(Move(surf))
|
||||
{
|
||||
}
|
||||
|
||||
SharedSurfaceTextureClient::~SharedSurfaceTextureClient()
|
||||
{
|
||||
// Free the ShSurf implicitly.
|
||||
}
|
||||
SharedSurfaceTextureData::SharedSurfaceTextureData(UniquePtr<gl::SharedSurface> surf)
|
||||
: mSurf(Move(surf))
|
||||
{}
|
||||
|
||||
SharedSurfaceTextureData::~SharedSurfaceTextureData()
|
||||
{}
|
||||
|
||||
void
|
||||
SharedSurfaceTextureData::Deallocate(ISurfaceAllocator*)
|
||||
{}
|
||||
|
||||
gfx::IntSize
|
||||
SharedSurfaceTextureClient::GetSize() const
|
||||
SharedSurfaceTextureData::GetSize() const
|
||||
{
|
||||
return mSurf->mSize;
|
||||
}
|
||||
|
||||
bool
|
||||
SharedSurfaceTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
||||
SharedSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
|
||||
{
|
||||
return mSurf->ToSurfaceDescriptor(&aOutDescriptor);
|
||||
}
|
||||
|
||||
|
||||
SharedSurfaceTextureClient::SharedSurfaceTextureClient(SharedSurfaceTextureData* aData,
|
||||
TextureFlags aFlags,
|
||||
ISurfaceAllocator* aAllocator)
|
||||
: ClientTexture(aData, aFlags, aAllocator)
|
||||
{}
|
||||
|
||||
already_AddRefed<SharedSurfaceTextureClient>
|
||||
SharedSurfaceTextureClient::Create(UniquePtr<gl::SharedSurface> surf, gl::SurfaceFactory* factory,
|
||||
ISurfaceAllocator* aAllocator, TextureFlags aFlags)
|
||||
{
|
||||
if (!surf) {
|
||||
return nullptr;
|
||||
}
|
||||
TextureFlags flags = aFlags | TextureFlags::RECYCLE | surf->GetTextureFlags();
|
||||
SharedSurfaceTextureData* data = new SharedSurfaceTextureData(Move(surf));
|
||||
return MakeAndAddRef<SharedSurfaceTextureClient>(data, flags, aAllocator);
|
||||
}
|
||||
|
||||
void
|
||||
SharedSurfaceTextureClient::SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
gl::SharedSurface_Gralloc* surf = nullptr;
|
||||
if (mSurf->mType == gl::SharedSurfaceType::Gralloc) {
|
||||
surf = gl::SharedSurface_Gralloc::Cast(mSurf.get());
|
||||
if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
|
||||
surf = gl::SharedSurface_Gralloc::Cast(Surf());
|
||||
}
|
||||
if (surf && surf->GetTextureClient()) {
|
||||
surf->GetTextureClient()->SetReleaseFenceHandle(aReleaseFenceHandle);
|
||||
|
@ -71,8 +87,8 @@ SharedSurfaceTextureClient::GetAndResetReleaseFenceHandle()
|
|||
{
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
gl::SharedSurface_Gralloc* surf = nullptr;
|
||||
if (mSurf->mType == gl::SharedSurfaceType::Gralloc) {
|
||||
surf = gl::SharedSurface_Gralloc::Cast(mSurf.get());
|
||||
if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
|
||||
surf = gl::SharedSurface_Gralloc::Cast(Surf());
|
||||
}
|
||||
if (surf && surf->GetTextureClient()) {
|
||||
return surf->GetTextureClient()->GetAndResetReleaseFenceHandle();
|
||||
|
@ -86,8 +102,8 @@ SharedSurfaceTextureClient::SetAcquireFenceHandle(const FenceHandle& aAcquireFen
|
|||
{
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
gl::SharedSurface_Gralloc* surf = nullptr;
|
||||
if (mSurf->mType == gl::SharedSurfaceType::Gralloc) {
|
||||
surf = gl::SharedSurface_Gralloc::Cast(mSurf.get());
|
||||
if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
|
||||
surf = gl::SharedSurface_Gralloc::Cast(Surf());
|
||||
}
|
||||
if (surf && surf->GetTextureClient()) {
|
||||
return surf->GetTextureClient()->SetAcquireFenceHandle(aAcquireFenceHandle);
|
||||
|
@ -101,8 +117,8 @@ SharedSurfaceTextureClient::GetAcquireFenceHandle() const
|
|||
{
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
gl::SharedSurface_Gralloc* surf = nullptr;
|
||||
if (mSurf->mType == gl::SharedSurfaceType::Gralloc) {
|
||||
surf = gl::SharedSurface_Gralloc::Cast(mSurf.get());
|
||||
if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
|
||||
surf = gl::SharedSurface_Gralloc::Cast(Surf());
|
||||
}
|
||||
if (surf && surf->GetTextureClient()) {
|
||||
return surf->GetTextureClient()->GetAcquireFenceHandle();
|
||||
|
|
|
@ -26,51 +26,60 @@ class SurfaceFactory;
|
|||
|
||||
namespace layers {
|
||||
|
||||
class SharedSurfaceTextureClient : public TextureClient
|
||||
class SharedSurfaceTextureClient;
|
||||
|
||||
class SharedSurfaceTextureData : public TextureData
|
||||
{
|
||||
protected:
|
||||
const UniquePtr<gl::SharedSurface> mSurf;
|
||||
|
||||
friend class gl::SurfaceFactory;
|
||||
|
||||
SharedSurfaceTextureClient(ISurfaceAllocator* aAllocator, TextureFlags aFlags,
|
||||
UniquePtr<gl::SharedSurface> surf,
|
||||
gl::SurfaceFactory* factory);
|
||||
|
||||
~SharedSurfaceTextureClient();
|
||||
friend class SharedSurfaceTextureClient;
|
||||
|
||||
explicit SharedSurfaceTextureData(UniquePtr<gl::SharedSurface> surf);
|
||||
public:
|
||||
virtual bool IsAllocated() const override { return true; }
|
||||
virtual bool Lock(OpenMode) override { return false; }
|
||||
virtual bool IsLocked() const override { return false; }
|
||||
|
||||
~SharedSurfaceTextureData();
|
||||
|
||||
virtual bool Lock(OpenMode, FenceHandle*) override { return false; }
|
||||
|
||||
virtual void Unlock() override {}
|
||||
|
||||
virtual bool HasInternalBuffer() const override { return false; }
|
||||
|
||||
virtual gfx::SurfaceFormat GetFormat() const override {
|
||||
return gfx::SurfaceFormat::UNKNOWN;
|
||||
}
|
||||
|
||||
virtual already_AddRefed<TextureClient>
|
||||
CreateSimilar(TextureFlags, TextureAllocationFlags) const override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual bool AllocateForSurface(gfx::IntSize,
|
||||
TextureAllocationFlags) override {
|
||||
MOZ_CRASH("Should never hit this.");
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual gfx::IntSize GetSize() const override;
|
||||
|
||||
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) override;
|
||||
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
|
||||
|
||||
virtual void Deallocate(ISurfaceAllocator*) override;
|
||||
|
||||
gl::SharedSurface* Surf() const { return mSurf.get(); }
|
||||
};
|
||||
|
||||
class SharedSurfaceTextureClient : public ClientTexture
|
||||
{
|
||||
public:
|
||||
SharedSurfaceTextureClient(SharedSurfaceTextureData* aData,
|
||||
TextureFlags aFlags,
|
||||
ISurfaceAllocator* aAllocator);
|
||||
|
||||
static already_AddRefed<SharedSurfaceTextureClient>
|
||||
Create(UniquePtr<gl::SharedSurface> surf, gl::SurfaceFactory* factory,
|
||||
ISurfaceAllocator* aAllocator, TextureFlags aFlags);
|
||||
|
||||
virtual void SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle) override;
|
||||
|
||||
virtual FenceHandle GetAndResetReleaseFenceHandle() override;
|
||||
|
||||
virtual void SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle) override;
|
||||
|
||||
virtual const FenceHandle& GetAcquireFenceHandle() const override;
|
||||
|
||||
gl::SharedSurface* Surf() const {
|
||||
return mSurf.get();
|
||||
return static_cast<const SharedSurfaceTextureData*>(GetInternalData())->Surf();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче