diff --git a/gfx/gl/SharedSurfaceGralloc.cpp b/gfx/gl/SharedSurfaceGralloc.cpp index 0cb015ce09f..6d920fcb082 100644 --- a/gfx/gl/SharedSurfaceGralloc.cpp +++ b/gfx/gl/SharedSurfaceGralloc.cpp @@ -71,7 +71,7 @@ SharedSurface_Gralloc::Create(GLContext* prodGL, return Move(ret); } - RefPtr grallocTC = new ClientTexture(texData, flags, allocator); + RefPtr grallocTC = new TextureClient(texData, flags, allocator); sp buffer = texData->GetGraphicBuffer(); diff --git a/gfx/layers/BufferTexture.h b/gfx/layers/BufferTexture.h index c3ff425773a..01996777c54 100644 --- a/gfx/layers/BufferTexture.h +++ b/gfx/layers/BufferTexture.h @@ -56,7 +56,7 @@ public: virtual bool HasInternalBuffer() const override { return true; } - // use ClientTexture's default implementation + // use TextureClient's default implementation virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override; protected: diff --git a/gfx/layers/D3D9SurfaceImage.cpp b/gfx/layers/D3D9SurfaceImage.cpp index 279e9dfd8e7..bc49f45261c 100644 --- a/gfx/layers/D3D9SurfaceImage.cpp +++ b/gfx/layers/D3D9SurfaceImage.cpp @@ -217,7 +217,7 @@ D3D9RecycleAllocator::Allocate(gfx::SurfaceFormat aFormat, return nullptr; } - return MakeAndAddRef(data, aTextureFlags, mSurfaceAllocator); + return MakeAndAddRef(data, aTextureFlags, mSurfaceAllocator); } already_AddRefed diff --git a/gfx/layers/GrallocImages.cpp b/gfx/layers/GrallocImages.cpp index 875fbd72256..e149a459729 100644 --- a/gfx/layers/GrallocImages.cpp +++ b/gfx/layers/GrallocImages.cpp @@ -86,7 +86,7 @@ GrallocImage::SetData(const Data& aData) return false; } - mTextureClient = new ClientTexture(texData, TextureFlags::DEFAULT, allocator); + mTextureClient = new TextureClient(texData, TextureFlags::DEFAULT, allocator); sp graphicBuffer = texData->GetGraphicBuffer(); void* vaddr; diff --git a/gfx/layers/basic/TextureClientX11.cpp b/gfx/layers/basic/TextureClientX11.cpp index d87d0fa371d..439363b3b7c 100644 --- a/gfx/layers/basic/TextureClientX11.cpp +++ b/gfx/layers/basic/TextureClientX11.cpp @@ -29,7 +29,7 @@ CreateX11TextureClient(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, if (!data) { return nullptr; } - return MakeAndAddRef(data, aFlags, aAllocator); + return MakeAndAddRef(data, aFlags, aAllocator); } X11TextureData::X11TextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, diff --git a/gfx/layers/client/CompositableClient.cpp b/gfx/layers/client/CompositableClient.cpp index 1c50654213d..dd80834fc05 100644 --- a/gfx/layers/client/CompositableClient.cpp +++ b/gfx/layers/client/CompositableClient.cpp @@ -225,7 +225,7 @@ CompositableClient::CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat, bool CompositableClient::AddTextureClient(TextureClient* aClient) { - if(!aClient || !aClient->IsAllocated()) { + if(!aClient) { return false; } aClient->SetAddedToCompositableClient(); diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 22386137d52..045dd24fd25 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -193,18 +193,9 @@ TextureChild::ActorDestroy(ActorDestroyReason why) mKeep = nullptr; } -ClientTexture::ClientTexture(TextureData* aData, TextureFlags aFlags, ISurfaceAllocator* aAllocator) -: TextureClient(aAllocator, aFlags) -, mData(aData) -, mOpenMode(OpenMode::OPEN_NONE) -#ifdef DEBUG -, mExpectedDtRefs(0) -#endif -, mIsLocked(false) -{} bool -ClientTexture::Lock(OpenMode aMode) +TextureClient::Lock(OpenMode aMode) { MOZ_ASSERT(mValid); MOZ_ASSERT(!mIsLocked); @@ -219,7 +210,7 @@ ClientTexture::Lock(OpenMode aMode) } void -ClientTexture::Unlock() +TextureClient::Unlock() { MOZ_ASSERT(mValid); MOZ_ASSERT(mIsLocked); @@ -248,27 +239,27 @@ ClientTexture::Unlock() } bool -ClientTexture::HasInternalBuffer() const +TextureClient::HasInternalBuffer() const { MOZ_ASSERT(mValid); return mData->HasInternalBuffer(); } gfx::IntSize -ClientTexture::GetSize() const +TextureClient::GetSize() const { MOZ_ASSERT(mValid); return mData->GetSize(); } gfx::SurfaceFormat -ClientTexture::GetFormat() const +TextureClient::GetFormat() const { MOZ_ASSERT(mValid); return mData->GetFormat(); } -ClientTexture::~ClientTexture() +TextureClient::~TextureClient() { if (ShouldDeallocateInDestructor()) { mData->Deallocate(mAllocator); @@ -279,13 +270,13 @@ ClientTexture::~ClientTexture() } void -ClientTexture::FinalizeOnIPDLThread() +TextureClient::FinalizeOnIPDLThread() { mData->FinalizeOnIPDLThread(this); } void -ClientTexture::UpdateFromSurface(gfx::SourceSurface* aSurface) +TextureClient::UpdateFromSurface(gfx::SourceSurface* aSurface) { MOZ_ASSERT(mValid); MOZ_ASSERT(mIsLocked); @@ -310,12 +301,12 @@ ClientTexture::UpdateFromSurface(gfx::SourceSurface* aSurface) return; } } - NS_WARNING("ClientTexture::UpdateFromSurface failed"); + NS_WARNING("TextureClient::UpdateFromSurface failed"); } already_AddRefed -ClientTexture::CreateSimilar(TextureFlags aFlags, TextureAllocationFlags aAllocFlags) const +TextureClient::CreateSimilar(TextureFlags aFlags, TextureAllocationFlags aAllocFlags) const { MOZ_ASSERT(mValid); TextureData* data = mData->CreateSimilar(mAllocator, aFlags, aAllocFlags); @@ -323,11 +314,11 @@ ClientTexture::CreateSimilar(TextureFlags aFlags, TextureAllocationFlags aAllocF return nullptr; } - return MakeAndAddRef(data, aFlags, mAllocator); + return MakeAndAddRef(data, aFlags, mAllocator); } gfx::DrawTarget* -ClientTexture::BorrowDrawTarget() +TextureClient::BorrowDrawTarget() { MOZ_ASSERT(mValid); MOZ_ASSERT(mIsLocked); @@ -355,7 +346,7 @@ ClientTexture::BorrowDrawTarget() } bool -ClientTexture::BorrowMappedData(MappedTextureData& aMap) +TextureClient::BorrowMappedData(MappedTextureData& aMap) { MOZ_ASSERT(mValid); @@ -370,21 +361,21 @@ ClientTexture::BorrowMappedData(MappedTextureData& aMap) } bool -ClientTexture::BorrowMappedYCbCrData(MappedYCbCrTextureData& aMap) +TextureClient::BorrowMappedYCbCrData(MappedYCbCrTextureData& aMap) { MOZ_ASSERT(mValid); return mData->BorrowMappedYCbCrData(aMap); } bool -ClientTexture::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) +TextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) { MOZ_ASSERT(mValid); return mData->Serialize(aOutDescriptor); } void -ClientTexture::WaitForBufferOwnership(bool aWaitReleaseFence) +TextureClient::WaitForBufferOwnership(bool aWaitReleaseFence) { if (mRemoveFromCompositableWaiter) { mRemoveFromCompositableWaiter->WaitComplete(); @@ -584,7 +575,7 @@ TextureClient::CreateForDrawing(CompositableForwarder* aAllocator, if (gfxWindowsPlatform::GetPlatform()->GetD3D9Device()) { TextureData* data = D3D9TextureData::Create(aSize, aFormat, aAllocFlags); if (data) { - return MakeAndAddRef(data, aTextureFlags, aAllocator); + return MakeAndAddRef(data, aTextureFlags, aAllocator); } } } @@ -595,7 +586,7 @@ TextureClient::CreateForDrawing(CompositableForwarder* aAllocator, NS_IsMainThread()) { TextureData* data = DIBTextureData::Create(aSize, aFormat, aAllocator); if (data) { - return MakeAndAddRef(data, aTextureFlags, aAllocator); + return MakeAndAddRef(data, aTextureFlags, aAllocator); } } #endif @@ -635,20 +626,6 @@ TextureClient::CreateForDrawing(CompositableForwarder* aAllocator, } #endif - MOZ_ASSERT(!texture || texture->CanExposeDrawTarget(), "texture cannot expose a DrawTarget?"); - - if (texture && texture->AllocateForSurface(aSize, aAllocFlags)) { - return texture.forget(); - } - - if (aAllocFlags & ALLOC_DISALLOW_BUFFERTEXTURECLIENT) { - return nullptr; - } - - if (texture) { - NS_WARNING("Failed to allocate a TextureClient, falling back to BufferTextureClient."); - } - // Can't do any better than a buffer texture client. return TextureClient::CreateForRawBufferAccess(aAllocator, aFormat, aSize, moz2DBackend, aTextureFlags, aAllocFlags); @@ -679,7 +656,7 @@ TextureClient::CreateForRawBufferAccess(ISurfaceAllocator* aAllocator, return nullptr; } - return MakeAndAddRef(texData, aTextureFlags, aAllocator); + return MakeAndAddRef(texData, aTextureFlags, aAllocator); } // static @@ -706,7 +683,7 @@ TextureClient::CreateForYCbCr(ISurfaceAllocator* aAllocator, return nullptr; } - return MakeAndAddRef(data, aTextureFlags, aAllocator); + return MakeAndAddRef(data, aTextureFlags, aAllocator); } // static @@ -727,26 +704,27 @@ TextureClient::CreateWithBufferSize(ISurfaceAllocator* aAllocator, return nullptr; } - return MakeAndAddRef(data, aTextureFlags, aAllocator); + return MakeAndAddRef(data, aTextureFlags, aAllocator); } -TextureClient::TextureClient(ISurfaceAllocator* aAllocator, TextureFlags aFlags) - : mAllocator(aAllocator) - , mFlags(aFlags) - , mShared(false) - , mValid(true) - , mAddedToCompositableClient(false) +TextureClient::TextureClient(TextureData* aData, TextureFlags aFlags, ISurfaceAllocator* aAllocator) +: mAllocator(aAllocator) +, mActor(nullptr) +, mData(aData) +, mFlags(aFlags) +, mOpenMode(OpenMode::OPEN_NONE) +#ifdef DEBUG +, mExpectedDtRefs(0) +#endif +, mIsLocked(false) +, mShared(false) +, mValid(true) +, mAddedToCompositableClient(false) #ifdef GFX_DEBUG_TRACK_CLIENTS_IN_POOL - , mPoolTracker(nullptr) +, mPoolTracker(nullptr) #endif {} -TextureClient::~TextureClient() -{ - // All the destruction code that may lead to virtual method calls must - // be in Finalize() which is called just before the destructor. -} - void TextureClient::KeepUntilFullDeallocation(UniquePtr aKeep, bool aMainThreadOnly) { @@ -836,10 +814,6 @@ TextureClient::Finalize() bool TextureClient::ShouldDeallocateInDestructor() const { - if (!IsAllocated()) { - return false; - } - // If we're meant to be deallocated by the host, // but we haven't been shared yet or // TextureFlags::DEALLOCATE_CLIENT is set, then we should @@ -940,7 +914,7 @@ TextureClient::CreateWithData(TextureData* aData, TextureFlags aFlags, ISurfaceA if (!aData) { return nullptr; } - return MakeAndAddRef(aData, aFlags, aAllocator); + return MakeAndAddRef(aData, aFlags, aAllocator); } bool diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index 5dd11f806f3..dd8fc6abb90 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -164,6 +164,60 @@ struct MappedYCbCrTextureData { } }; +class TextureData { +public: + TextureData() { MOZ_COUNT_CTOR(TextureData); } + + virtual ~TextureData() { MOZ_COUNT_DTOR(TextureData); } + + virtual gfx::IntSize GetSize() const = 0; + + virtual gfx::SurfaceFormat GetFormat() const = 0; + + virtual bool Lock(OpenMode aMode, FenceHandle* aFence) = 0; + + virtual void Unlock() = 0; + + virtual bool SupportsMoz2D() const { return false; } + + virtual bool CanExposeMappedData() const { return false; } + + virtual bool HasInternalBuffer() const = 0; + + virtual bool HasSynchronization() const { return false; } + + virtual already_AddRefed BorrowDrawTarget() { return nullptr; } + + virtual bool BorrowMappedData(MappedTextureData&) { return false; } + + virtual bool BorrowMappedYCbCrData(MappedYCbCrTextureData&) { return false; } + + virtual void Deallocate(ISurfaceAllocator* aAllocator) = 0; + + /// Depending on the texture's flags either Deallocate or Forget is called. + virtual void Forget(ISurfaceAllocator* aAllocator) {} + + virtual bool Serialize(SurfaceDescriptor& aDescriptor) = 0; + + virtual TextureData* + CreateSimilar(ISurfaceAllocator* aAllocator, + TextureFlags aFlags = TextureFlags::DEFAULT, + TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const { return nullptr; } + + virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) { return false; }; + + virtual bool ReadBack(TextureReadbackSink* aReadbackSink) { return false; } + + /// Ideally this should not be exposed and users of TextureClient would use Lock/Unlock + /// preoperly but that requires a few changes to SharedSurface and maybe gonk video. + virtual void WaitForFence(FenceHandle* aFence) {}; + + virtual void SyncWithObject(SyncObject* aFence) {}; + + /// Needed until the destruction sequence of TextureClient is revamped. + virtual void FinalizeOnIPDLThread(TextureClient*) {} +}; + /** * TextureClient is a thin abstraction over texture data that need to be shared * between the content process and the compositor process. It is the @@ -191,8 +245,8 @@ class TextureClient : public AtomicRefCountedWithFinalize { public: - explicit TextureClient(ISurfaceAllocator* aAllocator, - TextureFlags aFlags = TextureFlags::DEFAULT); + explicit TextureClient(TextureData* aData, TextureFlags aFlags, ISurfaceAllocator* aAllocator); + virtual ~TextureClient(); static already_AddRefed @@ -235,24 +289,9 @@ public: TextureFlags aTextureFlags); // Creates and allocates a TextureClient of the same type. - virtual already_AddRefed + already_AddRefed CreateSimilar(TextureFlags aFlags = TextureFlags::DEFAULT, - TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const = 0; - - /** - * Allocates for a given surface size, taking into account the pixel format - * which is part of the state of the TextureClient. - * - * Does not clear the surface by default, clearing the surface can be done - * by passing the CLEAR_BUFFER flag. - * - * TextureClients that can expose a DrawTarget should override this method. - */ - virtual bool AllocateForSurface(gfx::IntSize aSize, - TextureAllocationFlags flags = ALLOC_DEFAULT) - { - return false; - } + TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const; /** * Locks the shared data, allowing the caller to get access to it. @@ -260,15 +299,15 @@ public: * Please always lock/unlock when accessing the shared data. * If Lock() returns false, you should not attempt to access the shared data. */ - virtual bool Lock(OpenMode aMode) { return IsValid(); } + bool Lock(OpenMode aMode); - virtual void Unlock() {} + void Unlock(); - virtual bool IsLocked() const = 0; + bool IsLocked() const { return mIsLocked; } - virtual bool CanExposeDrawTarget() const { return false; } + bool CanExposeDrawTarget() const { return mData->SupportsMoz2D(); } - virtual bool CanExposeMappedData() const { return false; } + bool CanExposeMappedData() const { return mData->CanExposeMappedData(); } /** * Returns a DrawTarget to draw into the TextureClient. @@ -296,32 +335,28 @@ public: * texture->Unlock(); * */ - virtual gfx::DrawTarget* BorrowDrawTarget() { return nullptr; } + gfx::DrawTarget* BorrowDrawTarget(); /** * Similar to BorrowDrawTarget but provides direct access to the texture's bits * instead of a DrawTarget. */ - virtual bool BorrowMappedData(MappedTextureData&) { return false; } - virtual bool BorrowMappedYCbCrData(MappedYCbCrTextureData&) { return false; } + bool BorrowMappedData(MappedTextureData&); + bool BorrowMappedYCbCrData(MappedYCbCrTextureData&); /** * This function can be used to update the contents of the TextureClient * off the main thread. */ - virtual void UpdateFromSurface(gfx::SourceSurface* aSurface) { MOZ_CRASH(); } + void UpdateFromSurface(gfx::SourceSurface* aSurface); - // TextureClients that can expose a DrawTarget should override this method. - virtual gfx::SurfaceFormat GetFormat() const - { - return gfx::SurfaceFormat::UNKNOWN; - } + virtual gfx::SurfaceFormat GetFormat() const; /** * This method is strictly for debugging. It causes locking and * needless copies. */ - virtual already_AddRefed GetAsSurface() { + already_AddRefed GetAsSurface() { Lock(OpenMode::OPEN_READ); RefPtr surf = BorrowDrawTarget()->Snapshot(); RefPtr data = surf->GetDataSurface(); @@ -336,9 +371,9 @@ public: * It is assumed that the necessary locks are in place; so this should at * least have a read lock and aTarget should at least have a write lock. */ - virtual bool CopyToTextureClient(TextureClient* aTarget, - const gfx::IntRect* aRect, - const gfx::IntPoint* aPoint); + bool CopyToTextureClient(TextureClient* aTarget, + const gfx::IntRect* aRect, + const gfx::IntPoint* aPoint); /** * Returns true if this texture has a synchronization mechanism (mutex, fence, etc.). @@ -347,14 +382,14 @@ public: * Even if a texture does not implement synchronization, Lock and Unlock need * to be used appropriately since the latter are also there to map/numap data. */ - virtual bool HasSynchronization() const { return false; } + bool HasSynchronization() const { return false; } /** * Indicates whether the TextureClient implementation is backed by an * in-memory buffer. The consequence of this is that locking the * TextureClient does not contend with locking the texture on the host side. */ - virtual bool HasInternalBuffer() const = 0; + bool HasInternalBuffer() const; /** * Allocate and deallocate a TextureChild actor. @@ -372,9 +407,7 @@ public: */ static TextureClient* AsTextureClient(PTextureChild* actor); - virtual bool IsAllocated() const = 0; - - virtual gfx::IntSize GetSize() const = 0; + gfx::IntSize GetSize() const; /** * TextureFlags contain important information about various aspects @@ -500,7 +533,7 @@ public: /** * This function waits until the buffer is no longer being used. */ - virtual void WaitForBufferOwnership(bool aWaitReleaseFence = true) {} + virtual void WaitForBufferOwnership(bool aWaitReleaseFence = true); /** * Track how much of this texture is wasted. @@ -519,23 +552,18 @@ public: mReadbackSink = aReadbackSink; } - virtual void SyncWithObject(SyncObject* aSyncObject) { } + void SyncWithObject(SyncObject* aFence) { mData->SyncWithObject(aFence); } - void MarkShared() { - mShared = true; - } + void MarkShared() { mShared = true; } - ISurfaceAllocator* GetAllocator() - { - return mAllocator; - } + ISurfaceAllocator* GetAllocator() { return mAllocator; } TextureClientRecycleAllocator* GetRecycleAllocator() { return mRecycleAllocator; } void SetRecycleAllocator(TextureClientRecycleAllocator* aAllocator); - /// 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; } + /// If you add new code that uses this method, you are probably doing something wrong. + TextureData* GetInternalData() { return mData; } + const TextureData* GetInternalData() const { return mData; } private: static void TextureClientRecycleCallback(TextureClient* aClient, void* aClosure); @@ -553,7 +581,7 @@ private: * Called once during the destruction of the texture on the IPDL thread, if * the texture is shared on the compositor (otherwise it is not called at all). */ - virtual void FinalizeOnIPDLThread() {} + void FinalizeOnIPDLThread(); friend class AtomicRefCountedWithFinalize; friend class gl::SharedSurface_Gralloc; @@ -572,17 +600,26 @@ protected: * or never constructing a TextureHost with aDescriptor may result in a memory * leak (see TextureClientD3D9 for example). */ - virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) = 0; + bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor); + - RefPtr mActor; RefPtr mAllocator; + RefPtr mActor; RefPtr mRecycleAllocator; RefPtr mRemoveFromCompositableWaiter; + TextureData* mData; + RefPtr mBorrowedDrawTarget; + TextureFlags mFlags; FenceHandle mReleaseFenceHandle; FenceHandle mAcquireFenceHandle; gl::GfxTextureWasteTracker mWasteTracker; + + OpenMode mOpenMode; + DebugOnly mExpectedDtRefs; + bool mIsLocked; + bool mShared; bool mValid; bool mAddedToCompositableClient; @@ -601,124 +638,6 @@ public: #endif }; -class TextureData { -public: - TextureData() { MOZ_COUNT_CTOR(TextureData); } - - virtual ~TextureData() { MOZ_COUNT_DTOR(TextureData); } - - virtual gfx::IntSize GetSize() const = 0; - - virtual gfx::SurfaceFormat GetFormat() const = 0; - - virtual bool Lock(OpenMode aMode, FenceHandle* aFence) = 0; - - virtual void Unlock() = 0; - - virtual bool SupportsMoz2D() const { return false; } - - virtual bool CanExposeMappedData() const { return false; } - - virtual bool HasInternalBuffer() const = 0; - - virtual bool HasSynchronization() const { return false; } - - virtual already_AddRefed BorrowDrawTarget() { return nullptr; } - - virtual bool BorrowMappedData(MappedTextureData&) { return false; } - - virtual bool BorrowMappedYCbCrData(MappedYCbCrTextureData&) { return false; } - - virtual void Deallocate(ISurfaceAllocator* aAllocator) = 0; - - /// Depending on the texture's flags either Deallocate or Forget is called. - virtual void Forget(ISurfaceAllocator* aAllocator) {} - - virtual bool Serialize(SurfaceDescriptor& aDescriptor) = 0; - - virtual TextureData* - CreateSimilar(ISurfaceAllocator* aAllocator, - TextureFlags aFlags = TextureFlags::DEFAULT, - TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const { return nullptr; } - - virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) { return false; }; - - virtual bool ReadBack(TextureReadbackSink* aReadbackSink) { return false; } - - /// Ideally this should not be exposed and users of TextureClient would use Lock/Unlock - /// preoperly but that requires a few changes to SharedSurface and maybe gonk video. - virtual void WaitForFence(FenceHandle* aFence) {}; - - virtual void SyncWithObject(SyncObject* aFence) {}; - - /// Needed until the destruction sequence of TextureClient is revamped. - virtual void FinalizeOnIPDLThread(TextureClient*) {} -}; - -/// temporary class that will be merged back into TextureClient when all texture implementations -/// are based on TextureData. -class ClientTexture : public TextureClient { -public: - ClientTexture(TextureData* aData, TextureFlags aFlags, ISurfaceAllocator* aAllocator); - - ~ClientTexture(); - - virtual bool CanExposeDrawTarget() const override { return mData->SupportsMoz2D(); } - - virtual bool CanExposeMappedData() const override { return mData->CanExposeMappedData(); } - - virtual bool HasInternalBuffer() const override; - - virtual bool HasSynchronization() const { return mData->HasSynchronization(); } - - virtual gfx::IntSize GetSize() const override; - - virtual gfx::SurfaceFormat GetFormat() const override; - - virtual bool Lock(OpenMode aMode) override; - - virtual void Unlock() override; - - virtual bool IsLocked() const override { return mIsLocked; } - - virtual gfx::DrawTarget* BorrowDrawTarget() override; - - virtual bool BorrowMappedData(MappedTextureData&) override; - - virtual bool BorrowMappedYCbCrData(MappedYCbCrTextureData&) override; - - virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) override; - - virtual already_AddRefed - CreateSimilar(TextureFlags aFlags = TextureFlags::DEFAULT, - TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override; - - virtual void UpdateFromSurface(gfx::SourceSurface* aSurface) override; - - // TODO - we should be able to make this implicit and not expose the method. - virtual void WaitForBufferOwnership(bool aWaitReleaseFence = true) override; - - virtual void SyncWithObject(SyncObject* aFence) override { mData->SyncWithObject(aFence); } - - // by construction, ClientTexture cannot be created without successful allocation. - virtual bool IsAllocated() const override { return true; } - - /// 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; - -protected: - TextureData* mData; - RefPtr mBorrowedDrawTarget; - RefPtr mReadbackSink; - - OpenMode mOpenMode; - DebugOnly mExpectedDtRefs; - bool mIsLocked; -}; - /** * Task that releases TextureClient pointer on a specified thread. */ diff --git a/gfx/layers/client/TextureClientSharedSurface.cpp b/gfx/layers/client/TextureClientSharedSurface.cpp index 9c462e46449..a954896d111 100644 --- a/gfx/layers/client/TextureClientSharedSurface.cpp +++ b/gfx/layers/client/TextureClientSharedSurface.cpp @@ -51,7 +51,7 @@ SharedSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor) SharedSurfaceTextureClient::SharedSurfaceTextureClient(SharedSurfaceTextureData* aData, TextureFlags aFlags, ISurfaceAllocator* aAllocator) -: ClientTexture(aData, aFlags, aAllocator) +: TextureClient(aData, aFlags, aAllocator) {} already_AddRefed diff --git a/gfx/layers/client/TextureClientSharedSurface.h b/gfx/layers/client/TextureClientSharedSurface.h index 55ba4f73fec..b92101f383b 100644 --- a/gfx/layers/client/TextureClientSharedSurface.h +++ b/gfx/layers/client/TextureClientSharedSurface.h @@ -59,7 +59,7 @@ public: gl::SharedSurface* Surf() const { return mSurf.get(); } }; -class SharedSurfaceTextureClient : public ClientTexture +class SharedSurfaceTextureClient : public TextureClient { public: SharedSurfaceTextureClient(SharedSurfaceTextureData* aData, diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index ff1619ced23..cacc2ec942c 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -442,7 +442,7 @@ CreateDXGITextureClient(IntSize aSize, SurfaceFormat aFormat, if (!data) { return nullptr; } - return MakeAndAddRef(data, aTextureFlags, aAllocator); + return MakeAndAddRef(data, aTextureFlags, aAllocator); } @@ -497,7 +497,7 @@ CreateD3D11TextureClientWithDevice(IntSize aSize, SurfaceFormat aFormat, if (!data) { return nullptr; } - return MakeAndAddRef(data, aTextureFlags, aAllocator); + return MakeAndAddRef(data, aTextureFlags, aAllocator); } TextureData* diff --git a/gfx/layers/opengl/GrallocTextureClient.cpp b/gfx/layers/opengl/GrallocTextureClient.cpp index 63911cafdb6..ff7f2ef0bdf 100644 --- a/gfx/layers/opengl/GrallocTextureClient.cpp +++ b/gfx/layers/opengl/GrallocTextureClient.cpp @@ -360,7 +360,7 @@ CreateGrallocTextureClientForDrawing(gfx::IntSize aSize, gfx::SurfaceFormat aFor if (IsGrallocRBSwapped(aFormat)) { aFlags |= TextureFlags::RB_SWAPPED; } - return MakeAndAddRef(data, aFlags, aAllocator); + return MakeAndAddRef(data, aFlags, aAllocator); } // static diff --git a/gfx/layers/opengl/GrallocTextureClient.h b/gfx/layers/opengl/GrallocTextureClient.h index b390cce1ff0..4ea5d9ade69 100644 --- a/gfx/layers/opengl/GrallocTextureClient.h +++ b/gfx/layers/opengl/GrallocTextureClient.h @@ -89,7 +89,7 @@ public: TextureFlags aFlags = TextureFlags::DEFAULT, TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override; - // use ClientTexture's default implementation + // use TextureClient's default implementation virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override; /// Hold android::MediaBuffer. diff --git a/gfx/tests/gtest/TestTextures.cpp b/gfx/tests/gtest/TestTextures.cpp index 0830712c231..cf97cc6da31 100644 --- a/gfx/tests/gtest/TestTextures.cpp +++ b/gfx/tests/gtest/TestTextures.cpp @@ -268,7 +268,7 @@ TEST(Layers, TextureSerialization) { ); ASSERT_TRUE(!!texData); - RefPtr client = new ClientTexture( + RefPtr client = new TextureClient( texData, TextureFlags::DEALLOCATE_CLIENT, nullptr ); diff --git a/widget/gonk/nativewindow/GonkBufferQueueJB.cpp b/widget/gonk/nativewindow/GonkBufferQueueJB.cpp index 1ab75942687..69d498f3f49 100644 --- a/widget/gonk/nativewindow/GonkBufferQueueJB.cpp +++ b/widget/gonk/nativewindow/GonkBufferQueueJB.cpp @@ -431,7 +431,7 @@ status_t GonkBufferQueue::dequeueBuffer(int *outBuf, sp* outFence, ST_LOGE("dequeueBuffer: failed to alloc gralloc buffer"); return -ENOMEM; } - RefPtr textureClient = new ClientTexture(texData, TextureFlags::DEALLOCATE_CLIENT, allocator); + RefPtr textureClient = new TextureClient(texData, TextureFlags::DEALLOCATE_CLIENT, allocator); sp graphicBuffer = texData->GetGraphicBuffer(); { // Scope for the lock diff --git a/widget/gonk/nativewindow/GonkBufferQueueKK.cpp b/widget/gonk/nativewindow/GonkBufferQueueKK.cpp index 2a3ad5559e0..4f14a1e54e7 100644 --- a/widget/gonk/nativewindow/GonkBufferQueueKK.cpp +++ b/widget/gonk/nativewindow/GonkBufferQueueKK.cpp @@ -451,7 +451,7 @@ status_t GonkBufferQueue::dequeueBuffer(int *outBuf, sp* outFence, bool a return -ENOMEM; } - RefPtr textureClient = new ClientTexture(texData, TextureFlags::DEALLOCATE_CLIENT, allocator); + RefPtr textureClient = new TextureClient(texData, TextureFlags::DEALLOCATE_CLIENT, allocator); { // Scope for the lock Mutex::Autolock lock(mMutex); diff --git a/widget/gonk/nativewindow/GonkNativeWindowICS.cpp b/widget/gonk/nativewindow/GonkNativeWindowICS.cpp index e3d65326ee5..f5be860b861 100644 --- a/widget/gonk/nativewindow/GonkNativeWindowICS.cpp +++ b/widget/gonk/nativewindow/GonkNativeWindowICS.cpp @@ -328,7 +328,7 @@ status_t GonkNativeWindow::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h, return -ENOMEM; } - RefPtr textureClient = new ClientTexture(texData, TextureFlags::DEALLOCATE_CLIENT, allocator); + RefPtr textureClient = new TextureClient(texData, TextureFlags::DEALLOCATE_CLIENT, allocator); { // Scope for the lock Mutex::Autolock lock(mMutex);