зеркало из https://github.com/mozilla/gecko-dev.git
Bug 990871 - Move TextureClientDrawTarget into TextureClient. r=mattwoodrow
This commit is contained in:
Родитель
190cf6a2a2
Коммит
8e5bb9bcd2
|
@ -628,15 +628,15 @@ CairoImage::GetTextureClient(CompositableClient *aClient)
|
||||||
TEXTURE_FLAGS_DEFAULT,
|
TEXTURE_FLAGS_DEFAULT,
|
||||||
gfx::BackendType::NONE,
|
gfx::BackendType::NONE,
|
||||||
surface->GetSize());
|
surface->GetSize());
|
||||||
MOZ_ASSERT(textureClient->AsTextureClientDrawTarget());
|
MOZ_ASSERT(textureClient->CanExposeDrawTarget());
|
||||||
if (!textureClient->AsTextureClientDrawTarget()->AllocateForSurface(surface->GetSize()) ||
|
if (!textureClient->AllocateForSurface(surface->GetSize()) ||
|
||||||
!textureClient->Lock(OPEN_WRITE_ONLY)) {
|
!textureClient->Lock(OPEN_WRITE_ONLY)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// We must not keep a reference to the DrawTarget after it has been unlocked.
|
// We must not keep a reference to the DrawTarget after it has been unlocked.
|
||||||
RefPtr<DrawTarget> dt = textureClient->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
RefPtr<DrawTarget> dt = textureClient->GetAsDrawTarget();
|
||||||
dt->CopySurface(surface, IntRect(IntPoint(), surface->GetSize()), IntPoint());
|
dt->CopySurface(surface, IntRect(IntPoint(), surface->GetSize()), IntPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -307,7 +307,7 @@ RotatedContentBuffer::BufferContentType()
|
||||||
SurfaceFormat format;
|
SurfaceFormat format;
|
||||||
|
|
||||||
if (mBufferProvider) {
|
if (mBufferProvider) {
|
||||||
format = mBufferProvider->AsTextureClientDrawTarget()->GetFormat();
|
format = mBufferProvider->GetFormat();
|
||||||
} else if (mDTBuffer) {
|
} else if (mDTBuffer) {
|
||||||
format = mDTBuffer->GetFormat();
|
format = mDTBuffer->GetFormat();
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ RotatedContentBuffer::EnsureBuffer()
|
||||||
NS_ASSERTION(!mLoanedDrawTarget, "Loaned draw target must be returned");
|
NS_ASSERTION(!mLoanedDrawTarget, "Loaned draw target must be returned");
|
||||||
if (!mDTBuffer) {
|
if (!mDTBuffer) {
|
||||||
if (mBufferProvider) {
|
if (mBufferProvider) {
|
||||||
mDTBuffer = mBufferProvider->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
mDTBuffer = mBufferProvider->GetAsDrawTarget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ RotatedContentBuffer::EnsureBufferOnWhite()
|
||||||
if (!mDTBufferOnWhite) {
|
if (!mDTBufferOnWhite) {
|
||||||
if (mBufferProviderOnWhite) {
|
if (mBufferProviderOnWhite) {
|
||||||
mDTBufferOnWhite =
|
mDTBufferOnWhite =
|
||||||
mBufferProviderOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
mBufferProviderOnWhite->GetAsDrawTarget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,7 @@ namespace layers {
|
||||||
*/
|
*/
|
||||||
class TextureClientX11
|
class TextureClientX11
|
||||||
: public TextureClient,
|
: public TextureClient,
|
||||||
public TextureClientSurface,
|
public TextureClientSurface
|
||||||
public TextureClientDrawTarget
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextureClientX11(gfx::SurfaceFormat format, TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
|
TextureClientX11(gfx::SurfaceFormat format, TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
|
||||||
|
@ -28,7 +27,6 @@ class TextureClientX11
|
||||||
// TextureClient
|
// TextureClient
|
||||||
|
|
||||||
TextureClientSurface* AsTextureClientSurface() MOZ_OVERRIDE { return this; }
|
TextureClientSurface* AsTextureClientSurface() MOZ_OVERRIDE { return this; }
|
||||||
TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; }
|
|
||||||
|
|
||||||
bool IsAllocated() const MOZ_OVERRIDE;
|
bool IsAllocated() const MOZ_OVERRIDE;
|
||||||
bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
|
bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
|
||||||
|
@ -47,8 +45,6 @@ class TextureClientX11
|
||||||
already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
|
already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
|
||||||
bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags flags) MOZ_OVERRIDE;
|
bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags flags) MOZ_OVERRIDE;
|
||||||
|
|
||||||
// TextureClientDrawTarget
|
|
||||||
|
|
||||||
TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
|
TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
|
||||||
gfx::SurfaceFormat GetFormat() const {
|
gfx::SurfaceFormat GetFormat() const {
|
||||||
return mFormat;
|
return mFormat;
|
||||||
|
|
|
@ -88,7 +88,7 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
||||||
{
|
{
|
||||||
// Restrict drawTarget to a scope so that terminates before Unlock.
|
// Restrict drawTarget to a scope so that terminates before Unlock.
|
||||||
RefPtr<DrawTarget> target =
|
RefPtr<DrawTarget> target =
|
||||||
mBuffer->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
mBuffer->GetAsDrawTarget();
|
||||||
if (target) {
|
if (target) {
|
||||||
aLayer->UpdateTarget(target);
|
aLayer->UpdateTarget(target);
|
||||||
updated = true;
|
updated = true;
|
||||||
|
|
|
@ -195,7 +195,7 @@ ContentClientRemoteBuffer::CreateAndAllocateTextureClient(RefPtr<TextureClient>&
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) {
|
if (!aClient->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) {
|
||||||
aClient = CreateTextureClientForDrawing(mSurfaceFormat,
|
aClient = CreateTextureClientForDrawing(mSurfaceFormat,
|
||||||
mTextureInfo.mTextureFlags | TEXTURE_ALLOC_FALLBACK | aFlags,
|
mTextureInfo.mTextureFlags | TEXTURE_ALLOC_FALLBACK | aFlags,
|
||||||
gfx::BackendType::NONE,
|
gfx::BackendType::NONE,
|
||||||
|
@ -203,7 +203,7 @@ ContentClientRemoteBuffer::CreateAndAllocateTextureClient(RefPtr<TextureClient>&
|
||||||
if (!aClient) {
|
if (!aClient) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!aClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) {
|
if (!aClient->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) {
|
||||||
NS_WARNING("Could not allocate texture client");
|
NS_WARNING("Could not allocate texture client");
|
||||||
aClient = nullptr;
|
aClient = nullptr;
|
||||||
return false;
|
return false;
|
||||||
|
@ -271,12 +271,12 @@ ContentClientRemoteBuffer::CreateBuffer(ContentType aType,
|
||||||
DebugOnly<bool> locked = mTextureClient->Lock(OPEN_READ_WRITE);
|
DebugOnly<bool> locked = mTextureClient->Lock(OPEN_READ_WRITE);
|
||||||
MOZ_ASSERT(locked, "Could not lock the TextureClient");
|
MOZ_ASSERT(locked, "Could not lock the TextureClient");
|
||||||
|
|
||||||
*aBlackDT = mTextureClient->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
*aBlackDT = mTextureClient->GetAsDrawTarget();
|
||||||
if (aFlags & BUFFER_COMPONENT_ALPHA) {
|
if (aFlags & BUFFER_COMPONENT_ALPHA) {
|
||||||
locked = mTextureClientOnWhite->Lock(OPEN_READ_WRITE);
|
locked = mTextureClientOnWhite->Lock(OPEN_READ_WRITE);
|
||||||
MOZ_ASSERT(locked, "Could not lock the second TextureClient for component alpha");
|
MOZ_ASSERT(locked, "Could not lock the second TextureClient for component alpha");
|
||||||
|
|
||||||
*aWhiteDT = mTextureClientOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
*aWhiteDT = mTextureClientOnWhite->GetAsDrawTarget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,10 +477,9 @@ ContentClientDoubleBuffered::FinalizeFrame(const nsIntRegion& aRegionToDraw)
|
||||||
// Restrict the DrawTargets and frontBuffer to a scope to make
|
// Restrict the DrawTargets and frontBuffer to a scope to make
|
||||||
// sure there is no more external references to the DrawTargets
|
// sure there is no more external references to the DrawTargets
|
||||||
// when we Unlock the TextureClients.
|
// when we Unlock the TextureClients.
|
||||||
RefPtr<DrawTarget> dt =
|
RefPtr<DrawTarget> dt = mFrontClient->GetAsDrawTarget();
|
||||||
mFrontClient->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
|
||||||
RefPtr<DrawTarget> dtOnWhite = mFrontClientOnWhite
|
RefPtr<DrawTarget> dtOnWhite = mFrontClientOnWhite
|
||||||
? mFrontClientOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget()
|
? mFrontClientOnWhite->GetAsDrawTarget()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
RotatedBuffer frontBuffer(dt,
|
RotatedBuffer frontBuffer(dt,
|
||||||
dtOnWhite,
|
dtOnWhite,
|
||||||
|
|
|
@ -233,8 +233,8 @@ ImageClientSingle::UpdateImageInternal(ImageContainer* aContainer,
|
||||||
= gfxPlatform::GetPlatform()->OptimalFormatForContent(gfx::ContentForFormat(surface->GetFormat()));
|
= gfxPlatform::GetPlatform()->OptimalFormatForContent(gfx::ContentForFormat(surface->GetFormat()));
|
||||||
mFrontBuffer = CreateTextureClientForDrawing(gfx::ImageFormatToSurfaceFormat(format),
|
mFrontBuffer = CreateTextureClientForDrawing(gfx::ImageFormatToSurfaceFormat(format),
|
||||||
mTextureFlags, gfx::BackendType::NONE, size);
|
mTextureFlags, gfx::BackendType::NONE, size);
|
||||||
MOZ_ASSERT(mFrontBuffer->AsTextureClientDrawTarget());
|
MOZ_ASSERT(mFrontBuffer->CanExposeDrawTarget());
|
||||||
if (!mFrontBuffer->AsTextureClientDrawTarget()->AllocateForSurface(size)) {
|
if (!mFrontBuffer->AllocateForSurface(size)) {
|
||||||
mFrontBuffer = nullptr;
|
mFrontBuffer = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ ImageClientSingle::UpdateImageInternal(ImageContainer* aContainer,
|
||||||
|
|
||||||
{
|
{
|
||||||
// We must not keep a reference to the DrawTarget after it has been unlocked.
|
// We must not keep a reference to the DrawTarget after it has been unlocked.
|
||||||
RefPtr<DrawTarget> dt = mFrontBuffer->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
RefPtr<DrawTarget> dt = mFrontBuffer->GetAsDrawTarget();
|
||||||
MOZ_ASSERT(surface.get());
|
MOZ_ASSERT(surface.get());
|
||||||
dt->CopySurface(surface, IntRect(IntPoint(), surface->GetSize()), IntPoint());
|
dt->CopySurface(surface, IntRect(IntPoint(), surface->GetSize()), IntPoint());
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ SimpleTextureClientPool::GetTextureClient(bool aAutoRecycle)
|
||||||
textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator,
|
textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator,
|
||||||
mFormat, TEXTURE_FLAGS_DEFAULT | TEXTURE_RECYCLE, gfx::BackendType::NONE, mSize);
|
mFormat, TEXTURE_FLAGS_DEFAULT | TEXTURE_RECYCLE, gfx::BackendType::NONE, mSize);
|
||||||
}
|
}
|
||||||
if (!textureClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_DEFAULT)) {
|
if (!textureClient->AllocateForSurface(mSize, ALLOC_DEFAULT)) {
|
||||||
NS_WARNING("TextureClient::AllocateForSurface failed!");
|
NS_WARNING("TextureClient::AllocateForSurface failed!");
|
||||||
}
|
}
|
||||||
RECYCLE_LOG("%s Must allocate (0 left), returning %p\n", (mFormat == SurfaceFormat::B8G8R8A8?"poolA":"poolX"), textureClient.get());
|
RECYCLE_LOG("%s Must allocate (0 left), returning %p\n", (mFormat == SurfaceFormat::B8G8R8A8?"poolA":"poolX"), textureClient.get());
|
||||||
|
|
|
@ -147,7 +147,7 @@ SimpleTiledLayerBuffer::ValidateTile(SimpleTiledLayerTile aTile,
|
||||||
|
|
||||||
// this might get set above if we couldn't extract out a buffer
|
// this might get set above if we couldn't extract out a buffer
|
||||||
if (!doBufferedDrawing) {
|
if (!doBufferedDrawing) {
|
||||||
drawTarget = textureClient->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
drawTarget = textureClient->GetAsDrawTarget();
|
||||||
|
|
||||||
fullPaint = true;
|
fullPaint = true;
|
||||||
drawBounds = nsIntRect(aTileOrigin.x, aTileOrigin.y, GetScaledTileSize().width, GetScaledTileSize().height);
|
drawBounds = nsIntRect(aTileOrigin.x, aTileOrigin.y, GetScaledTileSize().width, GetScaledTileSize().height);
|
||||||
|
|
|
@ -356,8 +356,7 @@ TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
|
||||||
result = CreateBufferTextureClient(aAllocator, aFormat, aTextureFlags, aMoz2DBackend);
|
result = CreateBufferTextureClient(aAllocator, aFormat, aTextureFlags, aMoz2DBackend);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(!result || result->AsTextureClientDrawTarget(),
|
MOZ_ASSERT(!result || result->CanExposeDrawTarget(), "texture cannot expose a DrawTarget?");
|
||||||
"Not a TextureClientDrawTarget?");
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,12 +490,12 @@ bool TextureClient::CopyToTextureClient(TextureClient* aTarget,
|
||||||
MOZ_ASSERT(IsLocked());
|
MOZ_ASSERT(IsLocked());
|
||||||
MOZ_ASSERT(aTarget->IsLocked());
|
MOZ_ASSERT(aTarget->IsLocked());
|
||||||
|
|
||||||
if (!aTarget->AsTextureClientDrawTarget() || !AsTextureClientDrawTarget()) {
|
if (!aTarget->CanExposeDrawTarget() || !CanExposeDrawTarget()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<DrawTarget> destinationTarget = aTarget->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
RefPtr<DrawTarget> destinationTarget = aTarget->GetAsDrawTarget();
|
||||||
RefPtr<DrawTarget> sourceTarget = AsTextureClientDrawTarget()->GetAsDrawTarget();
|
RefPtr<DrawTarget> sourceTarget = GetAsDrawTarget();
|
||||||
RefPtr<gfx::SourceSurface> source = sourceTarget->Snapshot();
|
RefPtr<gfx::SourceSurface> source = sourceTarget->Snapshot();
|
||||||
destinationTarget->CopySurface(source,
|
destinationTarget->CopySurface(source,
|
||||||
aRect ? *aRect : gfx::IntRect(gfx::IntPoint(0, 0), GetSize()),
|
aRect ? *aRect : gfx::IntRect(gfx::IntPoint(0, 0), GetSize()),
|
||||||
|
@ -796,7 +795,7 @@ BufferTextureClient::Unlock()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// see the comment on TextureClientDrawTarget::GetAsDrawTarget.
|
// see the comment on TextureClient::GetAsDrawTarget.
|
||||||
// This DrawTarget is internal to the TextureClient and is only exposed to the
|
// This DrawTarget is internal to the TextureClient and is only exposed to the
|
||||||
// outside world between Lock() and Unlock(). This assertion checks that no outside
|
// outside world between Lock() and Unlock(). This assertion checks that no outside
|
||||||
// reference remains by the time Unlock() is called.
|
// reference remains by the time Unlock() is called.
|
||||||
|
|
|
@ -79,50 +79,6 @@ public:
|
||||||
TextureAllocationFlags flags = ALLOC_DEFAULT) = 0;
|
TextureAllocationFlags flags = ALLOC_DEFAULT) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for TextureClients that can be updated using a DrawTarget.
|
|
||||||
*/
|
|
||||||
class TextureClientDrawTarget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Returns a DrawTarget to draw into the TextureClient.
|
|
||||||
*
|
|
||||||
* This must never be called on a TextureClient that is not sucessfully locked.
|
|
||||||
* When called several times within one Lock/Unlock pair, this method should
|
|
||||||
* return the same DrawTarget.
|
|
||||||
* The DrawTarget is automatically flushed by the TextureClient when the latter
|
|
||||||
* is unlocked, and the DrawTarget that will be returned within the next
|
|
||||||
* lock/unlock pair may or may not be the same object.
|
|
||||||
* Do not keep references to the DrawTarget outside of the lock/unlock pair.
|
|
||||||
*
|
|
||||||
* This is typically used as follows:
|
|
||||||
*
|
|
||||||
* if (!texture->Lock(OPEN_READ_WRITE)) {
|
|
||||||
* return false;
|
|
||||||
* }
|
|
||||||
* {
|
|
||||||
* // Restrict this code's scope to ensure all references to dt are gone
|
|
||||||
* // when Unlock is called.
|
|
||||||
* RefPtr<DrawTarget> dt = texture->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
|
||||||
* // use the draw target ...
|
|
||||||
* }
|
|
||||||
* texture->Unlock();
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() = 0;
|
|
||||||
virtual gfx::SurfaceFormat GetFormat() 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.
|
|
||||||
*/
|
|
||||||
virtual bool AllocateForSurface(gfx::IntSize aSize,
|
|
||||||
TextureAllocationFlags flags = ALLOC_DEFAULT) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for TextureClients that can be updated using YCbCr data.
|
* Interface for TextureClients that can be updated using YCbCr data.
|
||||||
*/
|
*/
|
||||||
|
@ -214,7 +170,6 @@ public:
|
||||||
const gfx::IntSize& aSizeHint);
|
const gfx::IntSize& aSizeHint);
|
||||||
|
|
||||||
virtual TextureClientSurface* AsTextureClientSurface() { return nullptr; }
|
virtual TextureClientSurface* AsTextureClientSurface() { return nullptr; }
|
||||||
virtual TextureClientDrawTarget* AsTextureClientDrawTarget() { return nullptr; }
|
|
||||||
virtual TextureClientYCbCr* AsTextureClientYCbCr() { return nullptr; }
|
virtual TextureClientYCbCr* AsTextureClientYCbCr() { return nullptr; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -229,6 +184,56 @@ public:
|
||||||
|
|
||||||
virtual bool IsLocked() const = 0;
|
virtual bool IsLocked() const = 0;
|
||||||
|
|
||||||
|
virtual bool CanExposeDrawTarget() const { return false; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a DrawTarget to draw into the TextureClient.
|
||||||
|
*
|
||||||
|
* This must never be called on a TextureClient that is not sucessfully locked.
|
||||||
|
* When called several times within one Lock/Unlock pair, this method should
|
||||||
|
* return the same DrawTarget.
|
||||||
|
* The DrawTarget is automatically flushed by the TextureClient when the latter
|
||||||
|
* is unlocked, and the DrawTarget that will be returned within the next
|
||||||
|
* lock/unlock pair may or may not be the same object.
|
||||||
|
* Do not keep references to the DrawTarget outside of the lock/unlock pair.
|
||||||
|
*
|
||||||
|
* This is typically used as follows:
|
||||||
|
*
|
||||||
|
* if (!texture->Lock(OPEN_READ_WRITE)) {
|
||||||
|
* return false;
|
||||||
|
* }
|
||||||
|
* {
|
||||||
|
* // Restrict this code's scope to ensure all references to dt are gone
|
||||||
|
* // when Unlock is called.
|
||||||
|
* RefPtr<DrawTarget> dt = texture->GetAsDrawTarget();
|
||||||
|
* // use the draw target ...
|
||||||
|
* }
|
||||||
|
* texture->Unlock();
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() { return nullptr; }
|
||||||
|
|
||||||
|
// TextureClients that can expose a DrawTarget should override this method.
|
||||||
|
virtual gfx::SurfaceFormat GetFormat() const
|
||||||
|
{
|
||||||
|
return gfx::SurfaceFormat::UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies a rectangle from this texture client to a position in aTarget.
|
* Copies a rectangle from this texture client to a position in aTarget.
|
||||||
* It is assumed that the necessary locks are in place; so this should at
|
* It is assumed that the necessary locks are in place; so this should at
|
||||||
|
@ -409,7 +414,6 @@ protected:
|
||||||
class BufferTextureClient : public TextureClient
|
class BufferTextureClient : public TextureClient
|
||||||
, public TextureClientSurface
|
, public TextureClientSurface
|
||||||
, public TextureClientYCbCr
|
, public TextureClientYCbCr
|
||||||
, public TextureClientDrawTarget
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BufferTextureClient(ISurfaceAllocator* aAllocator, gfx::SurfaceFormat aFormat,
|
BufferTextureClient(ISurfaceAllocator* aAllocator, gfx::SurfaceFormat aFormat,
|
||||||
|
@ -429,6 +433,10 @@ public:
|
||||||
|
|
||||||
virtual bool IsLocked() const MOZ_OVERRIDE { return mLocked; }
|
virtual bool IsLocked() const MOZ_OVERRIDE { return mLocked; }
|
||||||
|
|
||||||
|
virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; }
|
||||||
|
|
||||||
|
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
|
||||||
|
|
||||||
// TextureClientSurface
|
// TextureClientSurface
|
||||||
|
|
||||||
virtual TextureClientSurface* AsTextureClientSurface() MOZ_OVERRIDE { return this; }
|
virtual TextureClientSurface* AsTextureClientSurface() MOZ_OVERRIDE { return this; }
|
||||||
|
@ -440,12 +448,6 @@ public:
|
||||||
virtual bool AllocateForSurface(gfx::IntSize aSize,
|
virtual bool AllocateForSurface(gfx::IntSize aSize,
|
||||||
TextureAllocationFlags aFlags = ALLOC_DEFAULT) MOZ_OVERRIDE;
|
TextureAllocationFlags aFlags = ALLOC_DEFAULT) MOZ_OVERRIDE;
|
||||||
|
|
||||||
// TextureClientDrawTarget
|
|
||||||
|
|
||||||
virtual TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; }
|
|
||||||
|
|
||||||
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
|
|
||||||
|
|
||||||
// TextureClientYCbCr
|
// TextureClientYCbCr
|
||||||
|
|
||||||
virtual TextureClientYCbCr* AsTextureClientYCbCr() MOZ_OVERRIDE { return this; }
|
virtual TextureClientYCbCr* AsTextureClientYCbCr() MOZ_OVERRIDE { return this; }
|
||||||
|
|
|
@ -62,7 +62,7 @@ TextureClientPool::GetTextureClient()
|
||||||
textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator,
|
textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator,
|
||||||
mFormat, TEXTURE_IMMEDIATE_UPLOAD, gfx::BackendType::NONE, mSize);
|
mFormat, TEXTURE_IMMEDIATE_UPLOAD, gfx::BackendType::NONE, mSize);
|
||||||
}
|
}
|
||||||
textureClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_DEFAULT);
|
textureClient->AllocateForSurface(mSize, ALLOC_DEFAULT);
|
||||||
|
|
||||||
return textureClient;
|
return textureClient;
|
||||||
}
|
}
|
||||||
|
|
|
@ -473,7 +473,7 @@ TileClient::DiscardFrontBuffer()
|
||||||
{
|
{
|
||||||
if (mFrontBuffer) {
|
if (mFrontBuffer) {
|
||||||
MOZ_ASSERT(mFrontLock);
|
MOZ_ASSERT(mFrontLock);
|
||||||
mManager->GetTexturePool(mFrontBuffer->AsTextureClientDrawTarget()->GetFormat())->ReturnTextureClientDeferred(mFrontBuffer);
|
mManager->GetTexturePool(mFrontBuffer->GetFormat())->ReturnTextureClientDeferred(mFrontBuffer);
|
||||||
mFrontLock->ReadUnlock();
|
mFrontLock->ReadUnlock();
|
||||||
mFrontBuffer = nullptr;
|
mFrontBuffer = nullptr;
|
||||||
mFrontLock = nullptr;
|
mFrontLock = nullptr;
|
||||||
|
@ -485,7 +485,7 @@ TileClient::DiscardBackBuffer()
|
||||||
{
|
{
|
||||||
if (mBackBuffer) {
|
if (mBackBuffer) {
|
||||||
MOZ_ASSERT(mBackLock);
|
MOZ_ASSERT(mBackLock);
|
||||||
mManager->GetTexturePool(mBackBuffer->AsTextureClientDrawTarget()->GetFormat())->ReturnTextureClient(mBackBuffer);
|
mManager->GetTexturePool(mBackBuffer->GetFormat())->ReturnTextureClient(mBackBuffer);
|
||||||
mBackLock->ReadUnlock();
|
mBackLock->ReadUnlock();
|
||||||
mBackBuffer = nullptr;
|
mBackBuffer = nullptr;
|
||||||
mBackLock = nullptr;
|
mBackLock = nullptr;
|
||||||
|
@ -751,7 +751,7 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
|
||||||
// We must not keep a reference to the DrawTarget after it has been unlocked,
|
// We must not keep a reference to the DrawTarget after it has been unlocked,
|
||||||
// make sure these are null'd before unlocking as destruction of the context
|
// make sure these are null'd before unlocking as destruction of the context
|
||||||
// may cause the target to be flushed.
|
// may cause the target to be flushed.
|
||||||
RefPtr<DrawTarget> drawTarget = backBuffer->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
RefPtr<DrawTarget> drawTarget = backBuffer->GetAsDrawTarget();
|
||||||
drawTarget->SetTransform(Matrix());
|
drawTarget->SetTransform(Matrix());
|
||||||
|
|
||||||
RefPtr<gfxContext> ctxt = new gfxContext(drawTarget);
|
RefPtr<gfxContext> ctxt = new gfxContext(drawTarget);
|
||||||
|
|
|
@ -25,8 +25,7 @@ class CompositorD3D11;
|
||||||
* A TextureClient to share a D3D10 texture with the compositor thread.
|
* A TextureClient to share a D3D10 texture with the compositor thread.
|
||||||
* The corresponding TextureHost is DXGITextureHostD3D11
|
* The corresponding TextureHost is DXGITextureHostD3D11
|
||||||
*/
|
*/
|
||||||
class TextureClientD3D11 : public TextureClient,
|
class TextureClientD3D11 : public TextureClient
|
||||||
public TextureClientDrawTarget
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextureClientD3D11(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
|
TextureClientD3D11(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
|
||||||
|
@ -53,11 +52,9 @@ public:
|
||||||
|
|
||||||
virtual TextureClientData* DropTextureData() MOZ_OVERRIDE { return nullptr; }
|
virtual TextureClientData* DropTextureData() MOZ_OVERRIDE { return nullptr; }
|
||||||
|
|
||||||
// TextureClientDrawTarget
|
|
||||||
|
|
||||||
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
|
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
|
||||||
|
|
||||||
virtual TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; }
|
virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; }
|
||||||
|
|
||||||
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
|
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,6 @@ protected:
|
||||||
* The corresponding TextureHost is TextureHostD3D9.
|
* The corresponding TextureHost is TextureHostD3D9.
|
||||||
*/
|
*/
|
||||||
class CairoTextureClientD3D9 : public TextureClient
|
class CairoTextureClientD3D9 : public TextureClient
|
||||||
, public TextureClientDrawTarget
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CairoTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
|
CairoTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
|
||||||
|
@ -210,10 +209,6 @@ public:
|
||||||
|
|
||||||
virtual TextureClientData* DropTextureData() MOZ_OVERRIDE;
|
virtual TextureClientData* DropTextureData() MOZ_OVERRIDE;
|
||||||
|
|
||||||
// TextureClientDrawTarget
|
|
||||||
|
|
||||||
virtual TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; }
|
|
||||||
|
|
||||||
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
|
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
|
||||||
|
|
||||||
virtual bool AllocateForSurface(gfx::IntSize aSize,
|
virtual bool AllocateForSurface(gfx::IntSize aSize,
|
||||||
|
@ -239,7 +234,6 @@ private:
|
||||||
* The coresponding TextureHost is DIBTextureHostD3D9.
|
* The coresponding TextureHost is DIBTextureHostD3D9.
|
||||||
*/
|
*/
|
||||||
class DIBTextureClientD3D9 : public TextureClient
|
class DIBTextureClientD3D9 : public TextureClient
|
||||||
, public TextureClientDrawTarget
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DIBTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
|
DIBTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
|
||||||
|
@ -264,9 +258,7 @@ public:
|
||||||
|
|
||||||
virtual TextureClientData* DropTextureData() MOZ_OVERRIDE;
|
virtual TextureClientData* DropTextureData() MOZ_OVERRIDE;
|
||||||
|
|
||||||
// TextureClientDrawTarget
|
virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; }
|
||||||
|
|
||||||
virtual TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; }
|
|
||||||
|
|
||||||
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
|
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
@ -395,6 +387,8 @@ public:
|
||||||
|
|
||||||
virtual void Updated(const nsIntRegion* aRegion = nullptr);
|
virtual void Updated(const nsIntRegion* aRegion = nullptr);
|
||||||
|
|
||||||
|
virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; }
|
||||||
|
|
||||||
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE
|
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE
|
||||||
{
|
{
|
||||||
return nullptr; // TODO: cf bug 872568
|
return nullptr; // TODO: cf bug 872568
|
||||||
|
|
|
@ -64,6 +64,16 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE
|
||||||
|
{
|
||||||
|
return gfx::SurfaceFormat::UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) MOZ_OVERRIDE
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
gl::SharedTextureHandle mHandle;
|
gl::SharedTextureHandle mHandle;
|
||||||
gfx::IntSize mSize;
|
gfx::IntSize mSize;
|
||||||
|
@ -100,6 +110,16 @@ public:
|
||||||
|
|
||||||
virtual gfx::IntSize GetSize() const { return gfx::IntSize(); }
|
virtual gfx::IntSize GetSize() const { return gfx::IntSize(); }
|
||||||
|
|
||||||
|
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE
|
||||||
|
{
|
||||||
|
return gfx::SurfaceFormat::UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) MOZ_OVERRIDE
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool mIsLocked;
|
bool mIsLocked;
|
||||||
RefPtr<gfx::SurfaceStream> mStream;
|
RefPtr<gfx::SurfaceStream> mStream;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче