Bug 1200595 - Merge TextureClient and ClientTexture back into TextureClient. r=mattwoodrow

This commit is contained in:
Nicolas Silva 2015-11-20 14:25:00 +01:00
parent ea90b51aa6
commit 26515543db
17 changed files with 146 additions and 253 deletions

View File

@ -71,7 +71,7 @@ SharedSurface_Gralloc::Create(GLContext* prodGL,
return Move(ret);
}
RefPtr<TextureClient> grallocTC = new ClientTexture(texData, flags, allocator);
RefPtr<TextureClient> grallocTC = new TextureClient(texData, flags, allocator);
sp<GraphicBuffer> buffer = texData->GetGraphicBuffer();

View File

@ -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:

View File

@ -217,7 +217,7 @@ D3D9RecycleAllocator::Allocate(gfx::SurfaceFormat aFormat,
return nullptr;
}
return MakeAndAddRef<ClientTexture>(data, aTextureFlags, mSurfaceAllocator);
return MakeAndAddRef<TextureClient>(data, aTextureFlags, mSurfaceAllocator);
}
already_AddRefed<TextureClient>

View File

@ -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> graphicBuffer = texData->GetGraphicBuffer();
void* vaddr;

View File

@ -29,7 +29,7 @@ CreateX11TextureClient(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
if (!data) {
return nullptr;
}
return MakeAndAddRef<ClientTexture>(data, aFlags, aAllocator);
return MakeAndAddRef<TextureClient>(data, aFlags, aAllocator);
}
X11TextureData::X11TextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,

View File

@ -225,7 +225,7 @@ CompositableClient::CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat,
bool
CompositableClient::AddTextureClient(TextureClient* aClient)
{
if(!aClient || !aClient->IsAllocated()) {
if(!aClient) {
return false;
}
aClient->SetAddedToCompositableClient();

View File

@ -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<TextureClient>
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<ClientTexture>(data, aFlags, mAllocator);
return MakeAndAddRef<TextureClient>(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<ClientTexture>(data, aTextureFlags, aAllocator);
return MakeAndAddRef<TextureClient>(data, aTextureFlags, aAllocator);
}
}
}
@ -595,7 +586,7 @@ TextureClient::CreateForDrawing(CompositableForwarder* aAllocator,
NS_IsMainThread()) {
TextureData* data = DIBTextureData::Create(aSize, aFormat, aAllocator);
if (data) {
return MakeAndAddRef<ClientTexture>(data, aTextureFlags, aAllocator);
return MakeAndAddRef<TextureClient>(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<ClientTexture>(texData, aTextureFlags, aAllocator);
return MakeAndAddRef<TextureClient>(texData, aTextureFlags, aAllocator);
}
// static
@ -706,7 +683,7 @@ TextureClient::CreateForYCbCr(ISurfaceAllocator* aAllocator,
return nullptr;
}
return MakeAndAddRef<ClientTexture>(data, aTextureFlags, aAllocator);
return MakeAndAddRef<TextureClient>(data, aTextureFlags, aAllocator);
}
// static
@ -727,26 +704,27 @@ TextureClient::CreateWithBufferSize(ISurfaceAllocator* aAllocator,
return nullptr;
}
return MakeAndAddRef<ClientTexture>(data, aTextureFlags, aAllocator);
return MakeAndAddRef<TextureClient>(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<KeepAlive> 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<ClientTexture>(aData, aFlags, aAllocator);
return MakeAndAddRef<TextureClient>(aData, aFlags, aAllocator);
}
bool

View File

@ -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<gfx::DrawTarget> 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<TextureClient>
{
public:
explicit TextureClient(ISurfaceAllocator* aAllocator,
TextureFlags aFlags = TextureFlags::DEFAULT);
explicit TextureClient(TextureData* aData, TextureFlags aFlags, ISurfaceAllocator* aAllocator);
virtual ~TextureClient();
static already_AddRefed<TextureClient>
@ -235,24 +289,9 @@ public:
TextureFlags aTextureFlags);
// Creates and allocates a TextureClient of the same type.
virtual already_AddRefed<TextureClient>
already_AddRefed<TextureClient>
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<gfx::DataSourceSurface> GetAsSurface() {
already_AddRefed<gfx::DataSourceSurface> GetAsSurface() {
Lock(OpenMode::OPEN_READ);
RefPtr<gfx::SourceSurface> surf = BorrowDrawTarget()->Snapshot();
RefPtr<gfx::DataSourceSurface> 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<TextureClient>;
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<TextureChild> mActor;
RefPtr<ISurfaceAllocator> mAllocator;
RefPtr<TextureChild> mActor;
RefPtr<TextureClientRecycleAllocator> mRecycleAllocator;
RefPtr<AsyncTransactionWaiter> mRemoveFromCompositableWaiter;
TextureData* mData;
RefPtr<gfx::DrawTarget> mBorrowedDrawTarget;
TextureFlags mFlags;
FenceHandle mReleaseFenceHandle;
FenceHandle mAcquireFenceHandle;
gl::GfxTextureWasteTracker mWasteTracker;
OpenMode mOpenMode;
DebugOnly<uint32_t> 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<gfx::DrawTarget> 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<TextureClient>
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<gfx::DrawTarget> mBorrowedDrawTarget;
RefPtr<TextureReadbackSink> mReadbackSink;
OpenMode mOpenMode;
DebugOnly<uint32_t> mExpectedDtRefs;
bool mIsLocked;
};
/**
* Task that releases TextureClient pointer on a specified thread.
*/

View File

@ -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<SharedSurfaceTextureClient>

View File

@ -59,7 +59,7 @@ public:
gl::SharedSurface* Surf() const { return mSurf.get(); }
};
class SharedSurfaceTextureClient : public ClientTexture
class SharedSurfaceTextureClient : public TextureClient
{
public:
SharedSurfaceTextureClient(SharedSurfaceTextureData* aData,

View File

@ -442,7 +442,7 @@ CreateDXGITextureClient(IntSize aSize, SurfaceFormat aFormat,
if (!data) {
return nullptr;
}
return MakeAndAddRef<ClientTexture>(data, aTextureFlags, aAllocator);
return MakeAndAddRef<TextureClient>(data, aTextureFlags, aAllocator);
}
@ -497,7 +497,7 @@ CreateD3D11TextureClientWithDevice(IntSize aSize, SurfaceFormat aFormat,
if (!data) {
return nullptr;
}
return MakeAndAddRef<ClientTexture>(data, aTextureFlags, aAllocator);
return MakeAndAddRef<TextureClient>(data, aTextureFlags, aAllocator);
}
TextureData*

View File

@ -360,7 +360,7 @@ CreateGrallocTextureClientForDrawing(gfx::IntSize aSize, gfx::SurfaceFormat aFor
if (IsGrallocRBSwapped(aFormat)) {
aFlags |= TextureFlags::RB_SWAPPED;
}
return MakeAndAddRef<ClientTexture>(data, aFlags, aAllocator);
return MakeAndAddRef<TextureClient>(data, aFlags, aAllocator);
}
// static

View File

@ -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.

View File

@ -268,7 +268,7 @@ TEST(Layers, TextureSerialization) {
);
ASSERT_TRUE(!!texData);
RefPtr<TextureClient> client = new ClientTexture(
RefPtr<TextureClient> client = new TextureClient(
texData, TextureFlags::DEALLOCATE_CLIENT, nullptr
);

View File

@ -431,7 +431,7 @@ status_t GonkBufferQueue::dequeueBuffer(int *outBuf, sp<Fence>* outFence,
ST_LOGE("dequeueBuffer: failed to alloc gralloc buffer");
return -ENOMEM;
}
RefPtr<TextureClient> textureClient = new ClientTexture(texData, TextureFlags::DEALLOCATE_CLIENT, allocator);
RefPtr<TextureClient> textureClient = new TextureClient(texData, TextureFlags::DEALLOCATE_CLIENT, allocator);
sp<GraphicBuffer> graphicBuffer = texData->GetGraphicBuffer();
{ // Scope for the lock

View File

@ -451,7 +451,7 @@ status_t GonkBufferQueue::dequeueBuffer(int *outBuf, sp<Fence>* outFence, bool a
return -ENOMEM;
}
RefPtr<TextureClient> textureClient = new ClientTexture(texData, TextureFlags::DEALLOCATE_CLIENT, allocator);
RefPtr<TextureClient> textureClient = new TextureClient(texData, TextureFlags::DEALLOCATE_CLIENT, allocator);
{ // Scope for the lock
Mutex::Autolock lock(mMutex);

View File

@ -328,7 +328,7 @@ status_t GonkNativeWindow::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
return -ENOMEM;
}
RefPtr<TextureClient> textureClient = new ClientTexture(texData, TextureFlags::DEALLOCATE_CLIENT, allocator);
RefPtr<TextureClient> textureClient = new TextureClient(texData, TextureFlags::DEALLOCATE_CLIENT, allocator);
{ // Scope for the lock
Mutex::Autolock lock(mMutex);