mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out bug 893301 for accidentally disabling gralloc for thebes layers on B2G - no review, bustage fix on a CLOSED TREE
This commit is contained in:
parent
b6317a3287
commit
a08afe9077
@ -64,12 +64,6 @@ const TextureFlags TEXTURE_COPY_PREVIOUS = 1 << 24;
|
||||
// deallocation.
|
||||
// The default behaviour is to deallocate on the host side.
|
||||
const TextureFlags TEXTURE_DEALLOCATE_CLIENT = 1 << 25;
|
||||
// The host side is responsible for deallocation, but that may not happen
|
||||
// immediately after the client side requests it. Exactly when the texture is
|
||||
// deallocated is up to the compositable. The texture must be deallocated by
|
||||
// the time the compositable or texture host is destroyed. A texture may not
|
||||
// have both TEXTURE_DEALLOCATE_CLIENT and TEXTURE_DEALLOCATE_DEFERRED flags.
|
||||
const TextureFlags TEXTURE_DEALLOCATE_DEFERRED = 1 << 26;
|
||||
// After being shared ith the compositor side, an immutable texture is never
|
||||
// modified, it can only be read. It is safe to not Lock/Unlock immutable
|
||||
// textures.
|
||||
@ -82,9 +76,6 @@ const TextureFlags TEXTURE_IMMEDIATE_UPLOAD = 1 << 28;
|
||||
// buffered pair, and so we can guarantee that the producer/consumer
|
||||
// won't be racing to access its contents.
|
||||
const TextureFlags TEXTURE_DOUBLE_BUFFERED = 1 << 29;
|
||||
// We've previously tried a texture and it didn't work for some reason. If there
|
||||
// is a fallback available, try that.
|
||||
const TextureFlags TEXTURE_ALLOC_FALLBACK = 1 << 31;
|
||||
|
||||
// the default flags
|
||||
const TextureFlags TEXTURE_FLAGS_DEFAULT = TEXTURE_FRONT;
|
||||
@ -176,8 +167,6 @@ enum CompositableType
|
||||
BUFFER_TILED, // tiled thebes layer
|
||||
// the new compositable types
|
||||
COMPOSITABLE_IMAGE, // image with single buffering
|
||||
COMPOSITABLE_CONTENT_SINGLE, // thebes layer interface, single buffering
|
||||
COMPOSITABLE_CONTENT_DOUBLE, // thebes layer interface, double buffering
|
||||
BUFFER_COUNT
|
||||
};
|
||||
|
||||
|
@ -281,19 +281,19 @@ RotatedContentBuffer::GetContextForQuadrantUpdate(const nsIntRect& aBounds,
|
||||
gfxContentType
|
||||
RotatedContentBuffer::BufferContentType()
|
||||
{
|
||||
if (mDeprecatedBufferProvider) {
|
||||
return mDeprecatedBufferProvider->GetContentType();
|
||||
if (mBufferProvider) {
|
||||
return mBufferProvider->GetContentType();
|
||||
}
|
||||
if (mBufferProvider || mDTBuffer) {
|
||||
SurfaceFormat format;
|
||||
|
||||
if (mBufferProvider) {
|
||||
format = mBufferProvider->AsTextureClientDrawTarget()->GetFormat();
|
||||
} else if (mDTBuffer) {
|
||||
format = mDTBuffer->GetFormat();
|
||||
if (mDTBuffer) {
|
||||
switch (mDTBuffer->GetFormat()) {
|
||||
case FORMAT_A8:
|
||||
return GFX_CONTENT_ALPHA;
|
||||
case FORMAT_B8G8R8A8:
|
||||
case FORMAT_R8G8B8A8:
|
||||
return GFX_CONTENT_COLOR_ALPHA;
|
||||
default:
|
||||
return GFX_CONTENT_COLOR;
|
||||
}
|
||||
|
||||
return ContentForFormat(format);
|
||||
}
|
||||
return GFX_CONTENT_SENTINEL;
|
||||
}
|
||||
@ -309,12 +309,8 @@ RotatedContentBuffer::BufferSizeOkFor(const nsIntSize& aSize)
|
||||
bool
|
||||
RotatedContentBuffer::EnsureBuffer()
|
||||
{
|
||||
if (!mDTBuffer) {
|
||||
if (mDeprecatedBufferProvider) {
|
||||
mDTBuffer = mDeprecatedBufferProvider->LockDrawTarget();
|
||||
} else if (mBufferProvider) {
|
||||
mDTBuffer = mBufferProvider->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
||||
}
|
||||
if (!mDTBuffer && mBufferProvider) {
|
||||
mDTBuffer = mBufferProvider->LockDrawTarget();
|
||||
}
|
||||
|
||||
NS_WARN_IF_FALSE(mDTBuffer, "no buffer");
|
||||
@ -324,13 +320,8 @@ RotatedContentBuffer::EnsureBuffer()
|
||||
bool
|
||||
RotatedContentBuffer::EnsureBufferOnWhite()
|
||||
{
|
||||
if (!mDTBufferOnWhite) {
|
||||
if (mDeprecatedBufferProviderOnWhite) {
|
||||
mDTBufferOnWhite = mDeprecatedBufferProviderOnWhite->LockDrawTarget();
|
||||
} else if (mBufferProviderOnWhite) {
|
||||
mDTBufferOnWhite =
|
||||
mBufferProviderOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
||||
}
|
||||
if (!mDTBufferOnWhite && mBufferProviderOnWhite) {
|
||||
mDTBufferOnWhite = mBufferProviderOnWhite->LockDrawTarget();
|
||||
}
|
||||
|
||||
NS_WARN_IF_FALSE(mDTBufferOnWhite, "no buffer");
|
||||
@ -340,13 +331,13 @@ RotatedContentBuffer::EnsureBufferOnWhite()
|
||||
bool
|
||||
RotatedContentBuffer::HaveBuffer() const
|
||||
{
|
||||
return mDTBuffer || mDeprecatedBufferProvider || mBufferProvider;
|
||||
return mDTBuffer || mBufferProvider;
|
||||
}
|
||||
|
||||
bool
|
||||
RotatedContentBuffer::HaveBufferOnWhite() const
|
||||
{
|
||||
return mDTBufferOnWhite || mDeprecatedBufferProviderOnWhite || mBufferProviderOnWhite;
|
||||
return mDTBufferOnWhite || mBufferProviderOnWhite;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -33,7 +33,6 @@ class Matrix;
|
||||
namespace layers {
|
||||
|
||||
class DeprecatedTextureClient;
|
||||
class TextureClient;
|
||||
class ThebesLayer;
|
||||
|
||||
/**
|
||||
@ -158,9 +157,7 @@ public:
|
||||
};
|
||||
|
||||
RotatedContentBuffer(BufferSizePolicy aBufferSizePolicy)
|
||||
: mDeprecatedBufferProvider(nullptr)
|
||||
, mDeprecatedBufferProviderOnWhite(nullptr)
|
||||
, mBufferProvider(nullptr)
|
||||
: mBufferProvider(nullptr)
|
||||
, mBufferProviderOnWhite(nullptr)
|
||||
, mBufferSizePolicy(aBufferSizePolicy)
|
||||
{
|
||||
@ -179,8 +176,6 @@ public:
|
||||
{
|
||||
mDTBuffer = nullptr;
|
||||
mDTBufferOnWhite = nullptr;
|
||||
mDeprecatedBufferProvider = nullptr;
|
||||
mDeprecatedBufferProviderOnWhite = nullptr;
|
||||
mBufferProvider = nullptr;
|
||||
mBufferProviderOnWhite = nullptr;
|
||||
mBufferRect.SetEmpty();
|
||||
@ -295,48 +290,23 @@ protected:
|
||||
* unset the provider when inactive, by calling
|
||||
* SetBufferProvider(nullptr).
|
||||
*/
|
||||
void SetDeprecatedBufferProvider(DeprecatedTextureClient* aClient)
|
||||
void SetBufferProvider(DeprecatedTextureClient* aClient)
|
||||
{
|
||||
// Only this buffer provider can give us a buffer. If we
|
||||
// already have one, something has gone wrong.
|
||||
MOZ_ASSERT((!aClient || !mDTBuffer) && !mBufferProvider);
|
||||
|
||||
mDeprecatedBufferProvider = aClient;
|
||||
if (!mDeprecatedBufferProvider) {
|
||||
mDTBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void SetDeprecatedBufferProviderOnWhite(DeprecatedTextureClient* aClient)
|
||||
{
|
||||
// Only this buffer provider can give us a buffer. If we
|
||||
// already have one, something has gone wrong.
|
||||
MOZ_ASSERT((!aClient || !mDTBufferOnWhite) && !mBufferProviderOnWhite);
|
||||
|
||||
mDeprecatedBufferProviderOnWhite = aClient;
|
||||
if (!mDeprecatedBufferProviderOnWhite) {
|
||||
mDTBufferOnWhite = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// new texture client versions
|
||||
void SetBufferProvider(TextureClient* aClient)
|
||||
{
|
||||
// Only this buffer provider can give us a buffer. If we
|
||||
// already have one, something has gone wrong.
|
||||
MOZ_ASSERT((!aClient || !mDTBuffer) && !mDeprecatedBufferProvider);
|
||||
MOZ_ASSERT(!aClient || !mDTBuffer);
|
||||
|
||||
mBufferProvider = aClient;
|
||||
if (!mBufferProvider) {
|
||||
mDTBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetBufferProviderOnWhite(TextureClient* aClient)
|
||||
|
||||
void SetBufferProviderOnWhite(DeprecatedTextureClient* aClient)
|
||||
{
|
||||
// Only this buffer provider can give us a buffer. If we
|
||||
// already have one, something has gone wrong.
|
||||
MOZ_ASSERT((!aClient || !mDTBufferOnWhite) && !mDeprecatedBufferProviderOnWhite);
|
||||
MOZ_ASSERT(!aClient || !mDTBufferOnWhite);
|
||||
|
||||
mBufferProviderOnWhite = aClient;
|
||||
if (!mBufferProviderOnWhite) {
|
||||
@ -379,10 +349,8 @@ protected:
|
||||
* when we're using surfaces that require explicit map/unmap. Only one
|
||||
* may be used at a time.
|
||||
*/
|
||||
DeprecatedTextureClient* mDeprecatedBufferProvider;
|
||||
DeprecatedTextureClient* mDeprecatedBufferProviderOnWhite;
|
||||
TextureClient* mBufferProvider;
|
||||
TextureClient* mBufferProviderOnWhite;
|
||||
DeprecatedTextureClient* mBufferProvider;
|
||||
DeprecatedTextureClient* mBufferProviderOnWhite;
|
||||
|
||||
BufferSizePolicy mBufferSizePolicy;
|
||||
};
|
||||
|
@ -106,18 +106,6 @@ ClientThebesLayer::RenderLayer()
|
||||
mContentClient->BeginPaint();
|
||||
PaintThebes();
|
||||
mContentClient->EndPaint();
|
||||
// It is very important that this is called after EndPaint, because destroying
|
||||
// textures is a three stage process:
|
||||
// 1. We are done with the buffer and move it to ContentClient::mOldTextures,
|
||||
// that happens in DestroyBuffers which is may be called indirectly from
|
||||
// PaintThebes.
|
||||
// 2. The content client calls RemoveTextureClient on the texture clients in
|
||||
// mOldTextures and forgets them. They then become invalid. The compositable
|
||||
// client keeps a record of IDs. This happens in EndPaint.
|
||||
// 3. An IPC message is sent to destroy the corresponding texture host. That
|
||||
// happens from OnTransaction.
|
||||
// It is important that these steps happen in order.
|
||||
mContentClient->OnTransaction();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -15,11 +15,8 @@
|
||||
#include "mozilla/layers/TextureD3D9.h"
|
||||
#include "mozilla/layers/TextureD3D11.h"
|
||||
#include "gfxWindowsPlatform.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
@ -196,8 +193,8 @@ CompositableClient::CreateDeprecatedTextureClient(DeprecatedTextureClientType aD
|
||||
}
|
||||
|
||||
TemporaryRef<BufferTextureClient>
|
||||
CompositableClient::CreateBufferTextureClient(SurfaceFormat aFormat,
|
||||
TextureFlags aTextureFlags)
|
||||
CompositableClient::CreateBufferTextureClient(gfx::SurfaceFormat aFormat,
|
||||
uint32_t aTextureFlags)
|
||||
{
|
||||
// XXX - Once bug 908196 is fixed, we can use gralloc textures here which will
|
||||
// improve performances of videos using SharedPlanarYCbCrImage on b2g.
|
||||
@ -217,56 +214,15 @@ CompositableClient::CreateBufferTextureClient(SurfaceFormat aFormat,
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
TemporaryRef<TextureClient>
|
||||
CompositableClient::CreateTextureClientForDrawing(SurfaceFormat aFormat,
|
||||
TextureFlags aTextureFlags)
|
||||
{
|
||||
RefPtr<TextureClient> result;
|
||||
|
||||
#ifdef XP_WIN
|
||||
LayersBackend parentBackend = GetForwarder()->GetCompositorBackendType();
|
||||
// XXX[nrc] uncomment once we have new texture clients for windows
|
||||
if (parentBackend == LAYERS_D3D11 && gfxWindowsPlatform::GetPlatform()->GetD2DDevice() &&
|
||||
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK)) {
|
||||
//result = new TextureClientD3D11(GetForwarder(), GetTextureInfo());
|
||||
}
|
||||
if (parentBackend == LAYERS_D3D9 &&
|
||||
!GetForwarder()->ForwardsToDifferentProcess() &&
|
||||
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK)) {
|
||||
// non-DIB textures don't work with alpha, see notes in TextureD3D9.
|
||||
if (ContentForFormat(aFormat) == GFX_CONTENT_COLOR_ALPHA) {
|
||||
//result = new TextureClientDIB(GetForwarder(), GetTextureInfo());
|
||||
} else {
|
||||
//result = new TextureClientD3D9(GetForwarder(), GetTextureInfo());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Can't do any better than a buffer texture client.
|
||||
if (!result) {
|
||||
result = CreateBufferTextureClient(aFormat, aTextureFlags);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!result || result->AsTextureClientDrawTarget(),
|
||||
"Not a TextureClientDrawTarget?");
|
||||
return result;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
CompositableClient::NextTextureID()
|
||||
bool
|
||||
CompositableClient::AddTextureClient(TextureClient* aClient)
|
||||
{
|
||||
++mNextTextureID;
|
||||
// 0 is always an invalid ID
|
||||
if (mNextTextureID == 0) {
|
||||
++mNextTextureID;
|
||||
}
|
||||
|
||||
return mNextTextureID;
|
||||
}
|
||||
|
||||
bool
|
||||
CompositableClient::AddTextureClient(TextureClient* aClient)
|
||||
{
|
||||
aClient->SetID(NextTextureID());
|
||||
aClient->SetID(mNextTextureID);
|
||||
return mForwarder->AddTexture(this, aClient);
|
||||
}
|
||||
|
||||
|
@ -88,12 +88,6 @@ public:
|
||||
CreateBufferTextureClient(gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
|
||||
|
||||
// If we return a non-null TextureClient, then AsTextureClientDrawTarget will
|
||||
// always be non-null.
|
||||
TemporaryRef<TextureClient>
|
||||
CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aTextureFlags);
|
||||
|
||||
virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
|
||||
const SurfaceDescriptor& aDescriptor)
|
||||
{
|
||||
@ -174,9 +168,6 @@ public:
|
||||
virtual void OnActorDestroy() = 0;
|
||||
|
||||
protected:
|
||||
// return the next texture ID
|
||||
uint64_t NextTextureID();
|
||||
|
||||
struct TextureIDAndFlags {
|
||||
TextureIDAndFlags(uint64_t aID, TextureFlags aFlags)
|
||||
: mID(aID), mFlags(aFlags) {}
|
||||
|
@ -62,22 +62,15 @@ ContentClient::CreateContentClient(CompositableForwarder* aForwarder)
|
||||
}
|
||||
|
||||
if (useDoubleBuffering || PR_GetEnv("MOZ_FORCE_DOUBLE_BUFFERING")) {
|
||||
if (gfxPlatform::GetPlatform()->UseDeprecatedTextures()) {
|
||||
return new DeprecatedContentClientDoubleBuffered(aForwarder);
|
||||
} else {
|
||||
return new ContentClientDoubleBuffered(aForwarder);
|
||||
}
|
||||
return new ContentClientDoubleBuffered(aForwarder);
|
||||
}
|
||||
#ifdef XP_MACOSX
|
||||
if (backend == LAYERS_OPENGL) {
|
||||
return new ContentClientIncremental(aForwarder);
|
||||
}
|
||||
#endif
|
||||
if (gfxPlatform::GetPlatform()->UseDeprecatedTextures()) {
|
||||
return new DeprecatedContentClientSingleBuffered(aForwarder);
|
||||
} else {
|
||||
return new ContentClientSingleBuffered(aForwarder);
|
||||
}
|
||||
return new ContentClientSingleBuffered(aForwarder);
|
||||
|
||||
}
|
||||
|
||||
// We pass a null pointer for the ContentClient Forwarder argument, which means
|
||||
@ -107,18 +100,17 @@ ContentClientBasic::CreateBuffer(ContentType aType,
|
||||
void
|
||||
ContentClientRemoteBuffer::DestroyBuffers()
|
||||
{
|
||||
if (!mTextureClient) {
|
||||
if (!mDeprecatedTextureClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
mOldTextures.AppendElement(mTextureClient);
|
||||
mTextureClient = nullptr;
|
||||
if (mTextureClientOnWhite) {
|
||||
mOldTextures.AppendElement(mTextureClientOnWhite);
|
||||
mTextureClientOnWhite = nullptr;
|
||||
}
|
||||
MOZ_ASSERT(mDeprecatedTextureClient->GetAccessMode() == DeprecatedTextureClient::ACCESS_READ_WRITE);
|
||||
mDeprecatedTextureClient = nullptr;
|
||||
mDeprecatedTextureClientOnWhite = nullptr;
|
||||
|
||||
DestroyFrontBuffer();
|
||||
|
||||
mForwarder->DestroyThebesBuffer(this);
|
||||
}
|
||||
|
||||
void
|
||||
@ -126,11 +118,11 @@ ContentClientRemoteBuffer::BeginPaint()
|
||||
{
|
||||
// XXX: So we might not have a DeprecatedTextureClient yet.. because it will
|
||||
// only be created by CreateBuffer.. which will deliver a locked surface!.
|
||||
if (mTextureClient) {
|
||||
SetBufferProvider(mTextureClient);
|
||||
if (mDeprecatedTextureClient) {
|
||||
SetBufferProvider(mDeprecatedTextureClient);
|
||||
}
|
||||
if (mTextureClientOnWhite) {
|
||||
SetBufferProviderOnWhite(mTextureClientOnWhite);
|
||||
if (mDeprecatedTextureClientOnWhite) {
|
||||
SetBufferProviderOnWhite(mDeprecatedTextureClientOnWhite);
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,205 +133,6 @@ ContentClientRemoteBuffer::EndPaint()
|
||||
// decided we didn't need one yet because the region to draw was empty.
|
||||
SetBufferProvider(nullptr);
|
||||
SetBufferProviderOnWhite(nullptr);
|
||||
for (size_t i = 0; i < mOldTextures.Length(); ++i) {
|
||||
RemoveTextureClient(mOldTextures[i]);
|
||||
}
|
||||
mOldTextures.Clear();
|
||||
|
||||
if (mTextureClient) {
|
||||
mTextureClient->Unlock();
|
||||
}
|
||||
if (mTextureClientOnWhite) {
|
||||
mTextureClientOnWhite->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ContentClientRemoteBuffer::CreateAndAllocateTextureClient(RefPtr<TextureClient>& aClient,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
aClient = CreateTextureClientForDrawing(mSurfaceFormat,
|
||||
mTextureInfo.mTextureFlags | aFlags);
|
||||
if (!aClient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) {
|
||||
aClient = CreateTextureClientForDrawing(mSurfaceFormat,
|
||||
mTextureInfo.mTextureFlags | TEXTURE_ALLOC_FALLBACK | aFlags);
|
||||
if (!aClient) {
|
||||
return false;
|
||||
}
|
||||
if (!aClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) {
|
||||
NS_WARNING("Could not allocate texture client");
|
||||
aClient = nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
NS_WARN_IF_FALSE(aClient->IsValid(), "Created an invalid texture client");
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientRemoteBuffer::BuildTextureClients(SurfaceFormat aFormat,
|
||||
const nsIntRect& aRect,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
// If we hit this assertion, then it might be due to an empty transaction
|
||||
// followed by a real transaction. Our buffers should be created (but not
|
||||
// painted in the empty transaction) and then painted (but not created) in the
|
||||
// real transaction. That is kind of fragile, and this assert will catch
|
||||
// circumstances where we screw that up, e.g., by unnecessarily recreating our
|
||||
// buffers.
|
||||
NS_ABORT_IF_FALSE(!mIsNewBuffer,
|
||||
"Bad! Did we create a buffer twice without painting?");
|
||||
|
||||
mIsNewBuffer = true;
|
||||
|
||||
DestroyBuffers();
|
||||
|
||||
mSurfaceFormat = aFormat;
|
||||
mSize = gfx::IntSize(aRect.width, aRect.height);
|
||||
mTextureInfo.mTextureFlags = (aFlags & ~TEXTURE_DEALLOCATE_CLIENT) |
|
||||
TEXTURE_DEALLOCATE_DEFERRED;
|
||||
|
||||
if (!CreateAndAllocateTextureClient(mTextureClient, TEXTURE_ON_BLACK) ||
|
||||
!AddTextureClient(mTextureClient)) {
|
||||
AbortTextureClientCreation();
|
||||
return;
|
||||
}
|
||||
|
||||
if (aFlags & BUFFER_COMPONENT_ALPHA) {
|
||||
if (!CreateAndAllocateTextureClient(mTextureClientOnWhite, TEXTURE_ON_WHITE) ||
|
||||
!AddTextureClient(mTextureClientOnWhite)) {
|
||||
AbortTextureClientCreation();
|
||||
return;
|
||||
}
|
||||
mTextureInfo.mTextureFlags |= TEXTURE_COMPONENT_ALPHA;
|
||||
}
|
||||
|
||||
CreateFrontBuffer(aRect);
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientRemoteBuffer::CreateBuffer(ContentType aType,
|
||||
const nsIntRect& aRect,
|
||||
uint32_t aFlags,
|
||||
RefPtr<gfx::DrawTarget>* aBlackDT,
|
||||
RefPtr<gfx::DrawTarget>* aWhiteDT)
|
||||
{
|
||||
BuildTextureClients(gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aType), aRect, aFlags);
|
||||
if (!mTextureClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
*aBlackDT = mTextureClient->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
||||
if (aFlags & BUFFER_COMPONENT_ALPHA) {
|
||||
*aWhiteDT = mTextureClientOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
||||
}
|
||||
}
|
||||
|
||||
nsIntRegion
|
||||
ContentClientRemoteBuffer::GetUpdatedRegion(const nsIntRegion& aRegionToDraw,
|
||||
const nsIntRegion& aVisibleRegion,
|
||||
bool aDidSelfCopy)
|
||||
{
|
||||
nsIntRegion updatedRegion;
|
||||
if (mIsNewBuffer || aDidSelfCopy) {
|
||||
// A buffer reallocation clears both buffers. The front buffer has all the
|
||||
// content by now, but the back buffer is still clear. Here, in effect, we
|
||||
// are saying to copy all of the pixels of the front buffer to the back.
|
||||
// Also when we self-copied in the buffer, the buffer space
|
||||
// changes and some changed buffer content isn't reflected in the
|
||||
// draw or invalidate region (on purpose!). When this happens, we
|
||||
// need to read back the entire buffer too.
|
||||
updatedRegion = aVisibleRegion;
|
||||
mIsNewBuffer = false;
|
||||
} else {
|
||||
updatedRegion = aRegionToDraw;
|
||||
}
|
||||
|
||||
NS_ASSERTION(BufferRect().Contains(aRegionToDraw.GetBounds()),
|
||||
"Update outside of buffer rect!");
|
||||
NS_ABORT_IF_FALSE(mTextureClient, "should have a back buffer by now");
|
||||
|
||||
return updatedRegion;
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientRemoteBuffer::Updated(const nsIntRegion& aRegionToDraw,
|
||||
const nsIntRegion& aVisibleRegion,
|
||||
bool aDidSelfCopy)
|
||||
{
|
||||
nsIntRegion updatedRegion = GetUpdatedRegion(aRegionToDraw,
|
||||
aVisibleRegion,
|
||||
aDidSelfCopy);
|
||||
|
||||
MOZ_ASSERT(mTextureClient);
|
||||
mForwarder->UseTexture(this, mTextureClient);
|
||||
mForwarder->UpdateTextureRegion(this,
|
||||
ThebesBufferData(BufferRect(),
|
||||
BufferRotation()),
|
||||
updatedRegion);
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientRemoteBuffer::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
|
||||
{
|
||||
MOZ_ASSERT(mTextureClient);
|
||||
mFrontAndBackBufferDiffer = true;
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientRemoteBuffer::OnActorDestroy()
|
||||
{
|
||||
if (mTextureClient) {
|
||||
mTextureClient->OnActorDestroy();
|
||||
}
|
||||
if (mTextureClientOnWhite) {
|
||||
mTextureClientOnWhite->OnActorDestroy();
|
||||
}
|
||||
for (size_t i = 0; i < mOldTextures.Length(); ++i) {
|
||||
mOldTextures[i]->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientRemoteBuffer::DestroyBuffers()
|
||||
{
|
||||
if (!mDeprecatedTextureClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
mDeprecatedTextureClient = nullptr;
|
||||
mDeprecatedTextureClientOnWhite = nullptr;
|
||||
|
||||
DestroyFrontBuffer();
|
||||
|
||||
mForwarder->DestroyThebesBuffer(this);
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientRemoteBuffer::BeginPaint()
|
||||
{
|
||||
// XXX: So we might not have a DeprecatedTextureClient yet.. because it will
|
||||
// only be created by CreateBuffer.. which will deliver a locked surface!.
|
||||
if (mDeprecatedTextureClient) {
|
||||
SetDeprecatedBufferProvider(mDeprecatedTextureClient);
|
||||
}
|
||||
if (mDeprecatedTextureClientOnWhite) {
|
||||
SetDeprecatedBufferProviderOnWhite(mDeprecatedTextureClientOnWhite);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientRemoteBuffer::EndPaint()
|
||||
{
|
||||
// XXX: We might still not have a texture client if PaintThebes
|
||||
// decided we didn't need one yet because the region to draw was empty.
|
||||
SetDeprecatedBufferProvider(nullptr);
|
||||
SetDeprecatedBufferProviderOnWhite(nullptr);
|
||||
mOldTextures.Clear();
|
||||
|
||||
if (mDeprecatedTextureClient) {
|
||||
@ -351,7 +144,7 @@ DeprecatedContentClientRemoteBuffer::EndPaint()
|
||||
}
|
||||
|
||||
bool
|
||||
DeprecatedContentClientRemoteBuffer::CreateAndAllocateDeprecatedTextureClient(RefPtr<DeprecatedTextureClient>& aClient)
|
||||
ContentClientRemoteBuffer::CreateAndAllocateDeprecatedTextureClient(RefPtr<DeprecatedTextureClient>& aClient)
|
||||
{
|
||||
aClient = CreateDeprecatedTextureClient(TEXTURE_CONTENT, mContentType);
|
||||
MOZ_ASSERT(aClient, "Failed to create texture client");
|
||||
@ -372,7 +165,7 @@ DeprecatedContentClientRemoteBuffer::CreateAndAllocateDeprecatedTextureClient(Re
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientRemoteBuffer::BuildDeprecatedTextureClients(ContentType aType,
|
||||
ContentClientRemoteBuffer::BuildDeprecatedTextureClients(ContentType aType,
|
||||
const nsIntRect& aRect,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
@ -409,7 +202,7 @@ DeprecatedContentClientRemoteBuffer::BuildDeprecatedTextureClients(ContentType a
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientRemoteBuffer::CreateBuffer(ContentType aType,
|
||||
ContentClientRemoteBuffer::CreateBuffer(ContentType aType,
|
||||
const nsIntRect& aRect,
|
||||
uint32_t aFlags,
|
||||
RefPtr<gfx::DrawTarget>* aBlackDT,
|
||||
@ -429,7 +222,7 @@ DeprecatedContentClientRemoteBuffer::CreateBuffer(ContentType aType,
|
||||
}
|
||||
|
||||
nsIntRegion
|
||||
DeprecatedContentClientRemoteBuffer::GetUpdatedRegion(const nsIntRegion& aRegionToDraw,
|
||||
ContentClientRemoteBuffer::GetUpdatedRegion(const nsIntRegion& aRegionToDraw,
|
||||
const nsIntRegion& aVisibleRegion,
|
||||
bool aDidSelfCopy)
|
||||
{
|
||||
@ -456,7 +249,7 @@ DeprecatedContentClientRemoteBuffer::GetUpdatedRegion(const nsIntRegion& aRegion
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientRemoteBuffer::Updated(const nsIntRegion& aRegionToDraw,
|
||||
ContentClientRemoteBuffer::Updated(const nsIntRegion& aRegionToDraw,
|
||||
const nsIntRegion& aVisibleRegion,
|
||||
bool aDidSelfCopy)
|
||||
{
|
||||
@ -477,7 +270,7 @@ DeprecatedContentClientRemoteBuffer::Updated(const nsIntRegion& aRegionToDraw,
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientRemoteBuffer::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
|
||||
ContentClientRemoteBuffer::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
|
||||
{
|
||||
MOZ_ASSERT(mDeprecatedTextureClient->GetAccessMode() == DeprecatedTextureClient::ACCESS_NONE);
|
||||
MOZ_ASSERT(!mDeprecatedTextureClientOnWhite || mDeprecatedTextureClientOnWhite->GetAccessMode() == DeprecatedTextureClient::ACCESS_NONE);
|
||||
@ -492,7 +285,7 @@ DeprecatedContentClientRemoteBuffer::SwapBuffers(const nsIntRegion& aFrontUpdate
|
||||
|
||||
|
||||
void
|
||||
DeprecatedContentClientRemoteBuffer::OnActorDestroy()
|
||||
ContentClientRemoteBuffer::OnActorDestroy()
|
||||
{
|
||||
if (mDeprecatedTextureClient) {
|
||||
mDeprecatedTextureClient->OnActorDestroy();
|
||||
@ -504,182 +297,8 @@ DeprecatedContentClientRemoteBuffer::OnActorDestroy()
|
||||
mOldTextures[i]->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientDoubleBuffered::CreateFrontBuffer(const nsIntRect& aBufferRect)
|
||||
{
|
||||
if (!CreateAndAllocateTextureClient(mFrontClient, TEXTURE_ON_BLACK) ||
|
||||
!AddTextureClient(mFrontClient)) {
|
||||
AbortTextureClientCreation();
|
||||
return;
|
||||
}
|
||||
if (mTextureInfo.mTextureFlags & TEXTURE_COMPONENT_ALPHA) {
|
||||
if (!CreateAndAllocateTextureClient(mFrontClientOnWhite, TEXTURE_ON_WHITE) ||
|
||||
!AddTextureClient(mFrontClientOnWhite)) {
|
||||
AbortTextureClientCreation();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mFrontBufferRect = aBufferRect;
|
||||
mFrontBufferRotation = nsIntPoint();
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientDoubleBuffered::DestroyFrontBuffer()
|
||||
{
|
||||
MOZ_ASSERT(mFrontClient);
|
||||
|
||||
mOldTextures.AppendElement(mFrontClient);
|
||||
mFrontClient = nullptr;
|
||||
if (mFrontClientOnWhite) {
|
||||
mOldTextures.AppendElement(mFrontClientOnWhite);
|
||||
mFrontClientOnWhite = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientDoubleBuffered::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
|
||||
{
|
||||
mFrontUpdatedRegion = aFrontUpdatedRegion;
|
||||
|
||||
RefPtr<TextureClient> oldBack = mTextureClient;
|
||||
mTextureClient = mFrontClient;
|
||||
mFrontClient = oldBack;
|
||||
|
||||
oldBack = mTextureClientOnWhite;
|
||||
mTextureClientOnWhite = mFrontClientOnWhite;
|
||||
mFrontClientOnWhite = oldBack;
|
||||
|
||||
nsIntRect oldBufferRect = mBufferRect;
|
||||
mBufferRect = mFrontBufferRect;
|
||||
mFrontBufferRect = oldBufferRect;
|
||||
|
||||
nsIntPoint oldBufferRotation = mBufferRotation;
|
||||
mBufferRotation = mFrontBufferRotation;
|
||||
mFrontBufferRotation = oldBufferRotation;
|
||||
|
||||
MOZ_ASSERT(mFrontClient);
|
||||
|
||||
ContentClientRemoteBuffer::SwapBuffers(aFrontUpdatedRegion);
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientDoubleBuffered::SyncFrontBufferToBackBuffer()
|
||||
{
|
||||
if (!mFrontAndBackBufferDiffer) {
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(mFrontClient);
|
||||
|
||||
MOZ_LAYERS_LOG(("BasicShadowableThebes(%p): reading back <x=%d,y=%d,w=%d,h=%d>",
|
||||
this,
|
||||
mFrontUpdatedRegion.GetBounds().x,
|
||||
mFrontUpdatedRegion.GetBounds().y,
|
||||
mFrontUpdatedRegion.GetBounds().width,
|
||||
mFrontUpdatedRegion.GetBounds().height));
|
||||
|
||||
nsIntRegion updateRegion = mFrontUpdatedRegion;
|
||||
|
||||
// This is a tricky trade off, we're going to get stuff out of our
|
||||
// frontbuffer now, but the next PaintThebes might throw it all (or mostly)
|
||||
// away if the visible region has changed. This is why in reality we want
|
||||
// this code integrated with PaintThebes to always do the optimal thing.
|
||||
|
||||
if (mDidSelfCopy) {
|
||||
mDidSelfCopy = false;
|
||||
// We can't easily draw our front buffer into us, since we're going to be
|
||||
// copying stuff around anyway it's easiest if we just move our situation
|
||||
// to non-rotated while we're at it. If this situation occurs we'll have
|
||||
// hit a self-copy path in PaintThebes before as well anyway.
|
||||
mBufferRect.MoveTo(mFrontBufferRect.TopLeft());
|
||||
mBufferRotation = nsIntPoint();
|
||||
updateRegion = mBufferRect;
|
||||
} else {
|
||||
mBufferRect = mFrontBufferRect;
|
||||
mBufferRotation = mFrontBufferRotation;
|
||||
}
|
||||
|
||||
mIsNewBuffer = false;
|
||||
mFrontAndBackBufferDiffer = false;
|
||||
|
||||
// We need to ensure that we lock these two buffers in the same
|
||||
// order as the compositor to prevent deadlocks.
|
||||
if (!mFrontClient->Lock(OPEN_READ_ONLY)) {
|
||||
return;
|
||||
}
|
||||
if (mFrontClientOnWhite &&
|
||||
!mFrontClientOnWhite->Lock(OPEN_READ_ONLY)) {
|
||||
mFrontClient->Unlock();
|
||||
return;
|
||||
}
|
||||
RefPtr<DrawTarget> dt =
|
||||
mFrontClient->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
||||
RefPtr<DrawTarget> dtOnWhite = mFrontClientOnWhite
|
||||
? mFrontClientOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget()
|
||||
: nullptr;
|
||||
RotatedBuffer frontBuffer(dt,
|
||||
dtOnWhite,
|
||||
mFrontBufferRect,
|
||||
mFrontBufferRotation);
|
||||
UpdateDestinationFrom(frontBuffer, updateRegion);
|
||||
mFrontClient->Unlock();
|
||||
if (mFrontClientOnWhite) {
|
||||
mFrontClientOnWhite->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientDoubleBuffered::UpdateDestinationFrom(const RotatedBuffer& aSource,
|
||||
const nsIntRegion& aUpdateRegion)
|
||||
{
|
||||
nsRefPtr<gfxContext> destCtx =
|
||||
GetContextForQuadrantUpdate(aUpdateRegion.GetBounds(), BUFFER_BLACK);
|
||||
destCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
|
||||
bool isClippingCheap = IsClippingCheap(destCtx, aUpdateRegion);
|
||||
if (isClippingCheap) {
|
||||
gfxUtils::ClipToRegion(destCtx, aUpdateRegion);
|
||||
}
|
||||
|
||||
aSource.DrawBufferWithRotation(destCtx->GetDrawTarget(), BUFFER_BLACK, 1.0, OP_SOURCE);
|
||||
|
||||
if (aSource.HaveBufferOnWhite()) {
|
||||
MOZ_ASSERT(HaveBufferOnWhite());
|
||||
nsRefPtr<gfxContext> destCtx =
|
||||
GetContextForQuadrantUpdate(aUpdateRegion.GetBounds(), BUFFER_WHITE);
|
||||
destCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
|
||||
bool isClippingCheap = IsClippingCheap(destCtx, aUpdateRegion);
|
||||
if (isClippingCheap) {
|
||||
gfxUtils::ClipToRegion(destCtx, aUpdateRegion);
|
||||
}
|
||||
|
||||
aSource.DrawBufferWithRotation(destCtx->GetDrawTarget(), BUFFER_WHITE, 1.0, OP_SOURCE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientDoubleBuffered::OnActorDestroy()
|
||||
{
|
||||
if (mTextureClient) {
|
||||
mTextureClient->OnActorDestroy();
|
||||
}
|
||||
if (mTextureClientOnWhite) {
|
||||
mTextureClientOnWhite->OnActorDestroy();
|
||||
}
|
||||
for (size_t i = 0; i < mOldTextures.Length(); ++i) {
|
||||
mOldTextures[i]->OnActorDestroy();
|
||||
}
|
||||
if (mFrontClient) {
|
||||
mFrontClient->OnActorDestroy();
|
||||
}
|
||||
if (mFrontClientOnWhite) {
|
||||
mFrontClientOnWhite->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
DeprecatedContentClientDoubleBuffered::~DeprecatedContentClientDoubleBuffered()
|
||||
ContentClientDoubleBuffered::~ContentClientDoubleBuffered()
|
||||
{
|
||||
if (mDeprecatedTextureClient) {
|
||||
MOZ_ASSERT(mFrontClient);
|
||||
@ -694,7 +313,7 @@ DeprecatedContentClientDoubleBuffered::~DeprecatedContentClientDoubleBuffered()
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientDoubleBuffered::CreateFrontBufferAndNotify(const nsIntRect& aBufferRect)
|
||||
ContentClientDoubleBuffered::CreateFrontBufferAndNotify(const nsIntRect& aBufferRect)
|
||||
{
|
||||
if (!CreateAndAllocateDeprecatedTextureClient(mFrontClient)) {
|
||||
mDeprecatedTextureClient->SetFlags(0);
|
||||
@ -730,7 +349,7 @@ DeprecatedContentClientDoubleBuffered::CreateFrontBufferAndNotify(const nsIntRec
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientDoubleBuffered::DestroyFrontBuffer()
|
||||
ContentClientDoubleBuffered::DestroyFrontBuffer()
|
||||
{
|
||||
MOZ_ASSERT(mFrontClient);
|
||||
MOZ_ASSERT(mFrontClient->GetAccessMode() != DeprecatedTextureClient::ACCESS_NONE);
|
||||
@ -740,7 +359,7 @@ DeprecatedContentClientDoubleBuffered::DestroyFrontBuffer()
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientDoubleBuffered::LockFrontBuffer()
|
||||
ContentClientDoubleBuffered::LockFrontBuffer()
|
||||
{
|
||||
MOZ_ASSERT(mFrontClient);
|
||||
mFrontClient->SetAccessMode(DeprecatedTextureClient::ACCESS_NONE);
|
||||
@ -750,7 +369,7 @@ DeprecatedContentClientDoubleBuffered::LockFrontBuffer()
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientDoubleBuffered::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
|
||||
ContentClientDoubleBuffered::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
|
||||
{
|
||||
mFrontUpdatedRegion = aFrontUpdatedRegion;
|
||||
|
||||
@ -776,11 +395,11 @@ DeprecatedContentClientDoubleBuffered::SwapBuffers(const nsIntRegion& aFrontUpda
|
||||
mFrontClientOnWhite->SetAccessMode(DeprecatedTextureClient::ACCESS_READ_ONLY);
|
||||
}
|
||||
|
||||
DeprecatedContentClientRemoteBuffer::SwapBuffers(aFrontUpdatedRegion);
|
||||
ContentClientRemoteBuffer::SwapBuffers(aFrontUpdatedRegion);
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientDoubleBuffered::OnActorDestroy()
|
||||
ContentClientDoubleBuffered::OnActorDestroy()
|
||||
{
|
||||
if (mDeprecatedTextureClient) {
|
||||
mDeprecatedTextureClient->OnActorDestroy();
|
||||
@ -823,7 +442,7 @@ private:
|
||||
};
|
||||
|
||||
void
|
||||
DeprecatedContentClientDoubleBuffered::SyncFrontBufferToBackBuffer()
|
||||
ContentClientDoubleBuffered::SyncFrontBufferToBackBuffer()
|
||||
{
|
||||
mIsNewBuffer = false;
|
||||
|
||||
@ -879,7 +498,7 @@ DeprecatedContentClientDoubleBuffered::SyncFrontBufferToBackBuffer()
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientDoubleBuffered::UpdateDestinationFrom(const RotatedBuffer& aSource,
|
||||
ContentClientDoubleBuffered::UpdateDestinationFrom(const RotatedBuffer& aSource,
|
||||
const nsIntRegion& aUpdateRegion)
|
||||
{
|
||||
nsRefPtr<gfxContext> destCtx =
|
||||
@ -911,35 +530,7 @@ DeprecatedContentClientDoubleBuffered::UpdateDestinationFrom(const RotatedBuffer
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientSingleBuffered::SyncFrontBufferToBackBuffer()
|
||||
{
|
||||
if (!mFrontAndBackBufferDiffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> backBuffer = GetDTBuffer();
|
||||
if (!backBuffer && mTextureClient) {
|
||||
backBuffer = mTextureClient->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> oldBuffer;
|
||||
oldBuffer = SetDTBuffer(backBuffer,
|
||||
mBufferRect,
|
||||
mBufferRotation);
|
||||
|
||||
backBuffer = GetDTBufferOnWhite();
|
||||
if (!backBuffer && mTextureClientOnWhite) {
|
||||
backBuffer = mTextureClientOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
||||
}
|
||||
|
||||
oldBuffer = SetDTBufferOnWhite(backBuffer);
|
||||
|
||||
mIsNewBuffer = false;
|
||||
mFrontAndBackBufferDiffer = false;
|
||||
}
|
||||
|
||||
DeprecatedContentClientSingleBuffered::~DeprecatedContentClientSingleBuffered()
|
||||
ContentClientSingleBuffered::~ContentClientSingleBuffered()
|
||||
{
|
||||
if (mDeprecatedTextureClient) {
|
||||
mDeprecatedTextureClient->SetDescriptor(SurfaceDescriptor());
|
||||
@ -950,7 +541,7 @@ DeprecatedContentClientSingleBuffered::~DeprecatedContentClientSingleBuffered()
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientSingleBuffered::CreateFrontBufferAndNotify(const nsIntRect& aBufferRect)
|
||||
ContentClientSingleBuffered::CreateFrontBufferAndNotify(const nsIntRect& aBufferRect)
|
||||
{
|
||||
mForwarder->CreatedSingleBuffer(this,
|
||||
*mDeprecatedTextureClient->LockSurfaceDescriptor(),
|
||||
@ -959,7 +550,7 @@ DeprecatedContentClientSingleBuffered::CreateFrontBufferAndNotify(const nsIntRec
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientSingleBuffered::SyncFrontBufferToBackBuffer()
|
||||
ContentClientSingleBuffered::SyncFrontBufferToBackBuffer()
|
||||
{
|
||||
mIsNewBuffer = false;
|
||||
if (!mFrontAndBackBufferDiffer) {
|
||||
|
@ -178,7 +178,6 @@ public:
|
||||
* If the size or type of our buffer(s) change(s), then we simply destroy and
|
||||
* create them.
|
||||
*/
|
||||
// Version using new texture clients
|
||||
class ContentClientRemoteBuffer : public ContentClientRemote
|
||||
, protected RotatedContentBuffer
|
||||
{
|
||||
@ -186,107 +185,6 @@ class ContentClientRemoteBuffer : public ContentClientRemote
|
||||
using RotatedContentBuffer::BufferRotation;
|
||||
public:
|
||||
ContentClientRemoteBuffer(CompositableForwarder* aForwarder)
|
||||
: ContentClientRemote(aForwarder)
|
||||
, RotatedContentBuffer(ContainsVisibleBounds)
|
||||
, mIsNewBuffer(false)
|
||||
, mFrontAndBackBufferDiffer(false)
|
||||
, mSurfaceFormat(gfx::FORMAT_B8G8R8A8)
|
||||
{}
|
||||
|
||||
typedef RotatedContentBuffer::PaintState PaintState;
|
||||
typedef RotatedContentBuffer::ContentType ContentType;
|
||||
|
||||
virtual void Clear() { RotatedContentBuffer::Clear(); }
|
||||
PaintState BeginPaintBuffer(ThebesLayer* aLayer, ContentType aContentType,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
return RotatedContentBuffer::BeginPaint(aLayer, aContentType, aFlags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin/End Paint map a gfxASurface from the texture client
|
||||
* into the buffer of RotatedBuffer. The surface is only
|
||||
* valid when the texture client is locked, so is mapped out
|
||||
* of RotatedContentBuffer when we are done painting.
|
||||
* None of the underlying buffer attributes (rect, rotation)
|
||||
* are affected by mapping/unmapping.
|
||||
*/
|
||||
virtual void BeginPaint() MOZ_OVERRIDE;
|
||||
virtual void EndPaint() MOZ_OVERRIDE;
|
||||
|
||||
virtual void Updated(const nsIntRegion& aRegionToDraw,
|
||||
const nsIntRegion& aVisibleRegion,
|
||||
bool aDidSelfCopy);
|
||||
|
||||
virtual void SwapBuffers(const nsIntRegion& aFrontUpdatedRegion) MOZ_OVERRIDE;
|
||||
|
||||
// Expose these protected methods from the superclass.
|
||||
virtual const nsIntRect& BufferRect() const
|
||||
{
|
||||
return RotatedContentBuffer::BufferRect();
|
||||
}
|
||||
virtual const nsIntPoint& BufferRotation() const
|
||||
{
|
||||
return RotatedContentBuffer::BufferRotation();
|
||||
}
|
||||
|
||||
virtual void CreateBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags,
|
||||
RefPtr<gfx::DrawTarget>* aBlackDT, RefPtr<gfx::DrawTarget>* aWhiteDT) MOZ_OVERRIDE;
|
||||
|
||||
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
|
||||
{
|
||||
return mTextureInfo;
|
||||
}
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
void DestroyBuffers();
|
||||
|
||||
virtual nsIntRegion GetUpdatedRegion(const nsIntRegion& aRegionToDraw,
|
||||
const nsIntRegion& aVisibleRegion,
|
||||
bool aDidSelfCopy);
|
||||
|
||||
void BuildTextureClients(gfx::SurfaceFormat aFormat,
|
||||
const nsIntRect& aRect,
|
||||
uint32_t aFlags);
|
||||
|
||||
// Create the front buffer for the ContentClient/Host pair if necessary
|
||||
// and notify the compositor that we have created the buffer(s).
|
||||
virtual void CreateFrontBuffer(const nsIntRect& aBufferRect) = 0;
|
||||
virtual void DestroyFrontBuffer() {}
|
||||
|
||||
bool CreateAndAllocateTextureClient(RefPtr<TextureClient>& aClient,
|
||||
TextureFlags aFlags = 0);
|
||||
|
||||
virtual void AbortTextureClientCreation()
|
||||
{
|
||||
mTextureClient = nullptr;
|
||||
mTextureClientOnWhite = nullptr;
|
||||
mIsNewBuffer = false;
|
||||
}
|
||||
|
||||
RefPtr<TextureClient> mTextureClient;
|
||||
RefPtr<TextureClient> mTextureClientOnWhite;
|
||||
// keep a record of texture clients we have created and need to keep around
|
||||
// (for RotatedBuffer to access), then unlock and remove them when we are done
|
||||
// painting.
|
||||
nsTArray<RefPtr<TextureClient> > mOldTextures;
|
||||
|
||||
TextureInfo mTextureInfo;
|
||||
bool mIsNewBuffer;
|
||||
bool mFrontAndBackBufferDiffer;
|
||||
gfx::IntSize mSize;
|
||||
gfx::SurfaceFormat mSurfaceFormat;
|
||||
};
|
||||
|
||||
class DeprecatedContentClientRemoteBuffer : public ContentClientRemote
|
||||
, protected RotatedContentBuffer
|
||||
{
|
||||
using RotatedContentBuffer::BufferRect;
|
||||
using RotatedContentBuffer::BufferRotation;
|
||||
public:
|
||||
DeprecatedContentClientRemoteBuffer(CompositableForwarder* aForwarder)
|
||||
: ContentClientRemote(aForwarder)
|
||||
, RotatedContentBuffer(ContainsVisibleBounds)
|
||||
, mDeprecatedTextureClient(nullptr)
|
||||
@ -335,6 +233,8 @@ public:
|
||||
virtual void CreateBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags,
|
||||
RefPtr<gfx::DrawTarget>* aBlackDT, RefPtr<gfx::DrawTarget>* aWhiteDT) MOZ_OVERRIDE;
|
||||
|
||||
void DestroyBuffers();
|
||||
|
||||
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
|
||||
{
|
||||
return mTextureInfo;
|
||||
@ -343,8 +243,6 @@ public:
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
void DestroyBuffers();
|
||||
|
||||
virtual nsIntRegion GetUpdatedRegion(const nsIntRegion& aRegionToDraw,
|
||||
const nsIntRegion& aVisibleRegion,
|
||||
bool aDidSelfCopy);
|
||||
@ -393,61 +291,22 @@ class ContentClientDoubleBuffered : public ContentClientRemoteBuffer
|
||||
public:
|
||||
ContentClientDoubleBuffered(CompositableForwarder* aFwd)
|
||||
: ContentClientRemoteBuffer(aFwd)
|
||||
{
|
||||
mTextureInfo.mCompositableType = COMPOSITABLE_CONTENT_DOUBLE;
|
||||
}
|
||||
virtual ~ContentClientDoubleBuffered() {}
|
||||
|
||||
virtual void SwapBuffers(const nsIntRegion& aFrontUpdatedRegion) MOZ_OVERRIDE;
|
||||
|
||||
virtual void SyncFrontBufferToBackBuffer() MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual void CreateFrontBuffer(const nsIntRect& aBufferRect) MOZ_OVERRIDE;
|
||||
virtual void DestroyFrontBuffer() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
void UpdateDestinationFrom(const RotatedBuffer& aSource,
|
||||
const nsIntRegion& aUpdateRegion);
|
||||
|
||||
virtual void AbortTextureClientCreation() MOZ_OVERRIDE
|
||||
{
|
||||
mTextureClient = nullptr;
|
||||
mTextureClientOnWhite = nullptr;
|
||||
mFrontClient = nullptr;
|
||||
mFrontClientOnWhite = nullptr;
|
||||
}
|
||||
|
||||
RefPtr<TextureClient> mFrontClient;
|
||||
RefPtr<TextureClient> mFrontClientOnWhite;
|
||||
nsIntRegion mFrontUpdatedRegion;
|
||||
nsIntRect mFrontBufferRect;
|
||||
nsIntPoint mFrontBufferRotation;
|
||||
};
|
||||
|
||||
class DeprecatedContentClientDoubleBuffered : public DeprecatedContentClientRemoteBuffer
|
||||
{
|
||||
public:
|
||||
DeprecatedContentClientDoubleBuffered(CompositableForwarder* aFwd)
|
||||
: DeprecatedContentClientRemoteBuffer(aFwd)
|
||||
{
|
||||
mTextureInfo.mCompositableType = BUFFER_CONTENT_DIRECT;
|
||||
}
|
||||
~DeprecatedContentClientDoubleBuffered();
|
||||
~ContentClientDoubleBuffered();
|
||||
|
||||
virtual void SwapBuffers(const nsIntRegion& aFrontUpdatedRegion) MOZ_OVERRIDE;
|
||||
|
||||
virtual void SyncFrontBufferToBackBuffer() MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual void CreateFrontBufferAndNotify(const nsIntRect& aBufferRect) MOZ_OVERRIDE;
|
||||
virtual void DestroyFrontBuffer() MOZ_OVERRIDE;
|
||||
virtual void LockFrontBuffer() MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
void UpdateDestinationFrom(const RotatedBuffer& aSource,
|
||||
const nsIntRegion& aUpdateRegion);
|
||||
@ -472,26 +331,10 @@ class ContentClientSingleBuffered : public ContentClientRemoteBuffer
|
||||
public:
|
||||
ContentClientSingleBuffered(CompositableForwarder* aFwd)
|
||||
: ContentClientRemoteBuffer(aFwd)
|
||||
{
|
||||
mTextureInfo.mCompositableType = COMPOSITABLE_CONTENT_SINGLE;
|
||||
}
|
||||
virtual ~ContentClientSingleBuffered() {}
|
||||
|
||||
virtual void SyncFrontBufferToBackBuffer() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual void CreateFrontBuffer(const nsIntRect& aBufferRect) MOZ_OVERRIDE {}
|
||||
};
|
||||
|
||||
class DeprecatedContentClientSingleBuffered : public DeprecatedContentClientRemoteBuffer
|
||||
{
|
||||
public:
|
||||
DeprecatedContentClientSingleBuffered(CompositableForwarder* aFwd)
|
||||
: DeprecatedContentClientRemoteBuffer(aFwd)
|
||||
{
|
||||
mTextureInfo.mCompositableType = BUFFER_CONTENT;
|
||||
}
|
||||
~DeprecatedContentClientSingleBuffered();
|
||||
~ContentClientSingleBuffered();
|
||||
|
||||
virtual void SyncFrontBufferToBackBuffer() MOZ_OVERRIDE;
|
||||
|
||||
|
@ -305,7 +305,7 @@ BufferTextureClient::GetAsSurface()
|
||||
}
|
||||
|
||||
bool
|
||||
BufferTextureClient::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags)
|
||||
BufferTextureClient::AllocateForSurface(gfx::IntSize aSize)
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
MOZ_ASSERT(mFormat != gfx::FORMAT_YUV, "This textureClient cannot use YCbCr data");
|
||||
@ -315,30 +315,12 @@ BufferTextureClient::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFla
|
||||
if (!Allocate(bufSize)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aFlags & ALLOC_CLEAR_BUFFER) {
|
||||
memset(GetBuffer(), 0, bufSize);
|
||||
}
|
||||
|
||||
ImageDataSerializer serializer(GetBuffer());
|
||||
serializer.InitializeBufferInfo(aSize, mFormat);
|
||||
mSize = aSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
TemporaryRef<gfx::DrawTarget>
|
||||
BufferTextureClient::GetAsDrawTarget()
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
|
||||
ImageDataSerializer serializer(GetBuffer());
|
||||
if (!serializer.IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return serializer.GetAsDrawTarget();
|
||||
}
|
||||
|
||||
bool
|
||||
BufferTextureClient::UpdateYCbCr(const PlanarYCbCrData& aData)
|
||||
{
|
||||
|
@ -48,11 +48,6 @@ class Image;
|
||||
* using AsTextureCLientSurface(), etc.
|
||||
*/
|
||||
|
||||
enum TextureAllocationFlags {
|
||||
ALLOC_DEFAULT = 0,
|
||||
ALLOC_CLEAR_BUFFER = 1
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface for TextureClients that can be updated using a gfxASurface.
|
||||
*/
|
||||
@ -61,34 +56,7 @@ class TextureClientSurface
|
||||
public:
|
||||
virtual bool UpdateSurface(gfxASurface* aSurface) = 0;
|
||||
virtual already_AddRefed<gfxASurface> GetAsSurface() = 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 a DrawTarget.
|
||||
*/
|
||||
class TextureClientDrawTarget
|
||||
{
|
||||
public:
|
||||
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;
|
||||
virtual bool AllocateForSurface(gfx::IntSize aSize) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -156,7 +124,6 @@ public:
|
||||
virtual ~TextureClient();
|
||||
|
||||
virtual TextureClientSurface* AsTextureClientSurface() { return nullptr; }
|
||||
virtual TextureClientDrawTarget* AsTextureClientDrawTarget() { return nullptr; }
|
||||
virtual TextureClientYCbCr* AsTextureClientYCbCr() { return nullptr; }
|
||||
|
||||
/**
|
||||
@ -273,8 +240,7 @@ protected:
|
||||
*/
|
||||
class BufferTextureClient : public TextureClient
|
||||
, public TextureClientSurface
|
||||
, public TextureClientYCbCr
|
||||
, public TextureClientDrawTarget
|
||||
, TextureClientYCbCr
|
||||
{
|
||||
public:
|
||||
BufferTextureClient(CompositableClient* aCompositable, gfx::SurfaceFormat aFormat,
|
||||
@ -298,14 +264,7 @@ public:
|
||||
|
||||
virtual already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
|
||||
|
||||
virtual bool AllocateForSurface(gfx::IntSize aSize,
|
||||
TextureAllocationFlags aFlags = ALLOC_DEFAULT) MOZ_OVERRIDE;
|
||||
|
||||
// TextureClientDrawTarget
|
||||
|
||||
virtual TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; }
|
||||
|
||||
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
|
||||
virtual bool AllocateForSurface(gfx::IntSize aSize) MOZ_OVERRIDE;
|
||||
|
||||
// TextureClientYCbCr
|
||||
|
||||
@ -317,7 +276,7 @@ public:
|
||||
gfx::IntSize aCbCrSize,
|
||||
StereoMode aStereoMode) MOZ_OVERRIDE;
|
||||
|
||||
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
|
||||
gfx::SurfaceFormat GetFormat() const { return mFormat; }
|
||||
|
||||
// XXX - Bug 908196 - Make Allocate(uint32_t) and GetBufferSize() protected.
|
||||
// these two methods should only be called by methods of BufferTextureClient
|
||||
|
@ -59,19 +59,20 @@ CompositableHost::AddTextureHost(TextureHost* aTexture)
|
||||
}
|
||||
|
||||
void
|
||||
CompositableHost::RemoveTextureHost(TextureHost* aTexture)
|
||||
CompositableHost::RemoveTextureHost(uint64_t aTextureID)
|
||||
{
|
||||
uint64_t textureID = aTexture->GetID();
|
||||
if (mFirstTexture && mFirstTexture->GetID() == textureID) {
|
||||
if (mFirstTexture && mFirstTexture->GetID() == aTextureID) {
|
||||
RefPtr<TextureHost> toRemove = mFirstTexture;
|
||||
mFirstTexture = mFirstTexture->GetNextSibling();
|
||||
aTexture->SetNextSibling(nullptr);
|
||||
toRemove->SetNextSibling(nullptr);
|
||||
}
|
||||
RefPtr<TextureHost> it = mFirstTexture;
|
||||
while (it) {
|
||||
if (it->GetNextSibling() &&
|
||||
it->GetNextSibling()->GetID() == textureID) {
|
||||
it->GetNextSibling()->GetID() == aTextureID) {
|
||||
RefPtr<TextureHost> toRemove = it->GetNextSibling();
|
||||
it->SetNextSibling(it->GetNextSibling()->GetNextSibling());
|
||||
aTexture->SetNextSibling(nullptr);
|
||||
toRemove->SetNextSibling(nullptr);
|
||||
}
|
||||
it = it->GetNextSibling();
|
||||
}
|
||||
@ -93,15 +94,6 @@ CompositableHost::GetTextureHost(uint64_t aTextureID)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
CompositableHost::OnActorDestroy()
|
||||
{
|
||||
TextureHost* it = mFirstTexture;
|
||||
while (it) {
|
||||
it->OnActorDestroy();
|
||||
it = it->GetNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CompositableHost::SetCompositor(Compositor* aCompositor)
|
||||
@ -140,7 +132,7 @@ CompositableHost::AddMaskEffect(EffectChain& aEffects,
|
||||
oldHost->Lock();
|
||||
source = oldHost;
|
||||
} else {
|
||||
RefPtr<TextureHost> host = GetAsTextureHost();
|
||||
RefPtr<TextureHost> host = GetTextureHost();
|
||||
if (host) {
|
||||
host->Lock();
|
||||
source = host->GetTextureSources();
|
||||
@ -167,7 +159,7 @@ CompositableHost::RemoveMaskEffect()
|
||||
if (oldHost) {
|
||||
oldHost->Unlock();
|
||||
} else {
|
||||
RefPtr<TextureHost> host = GetAsTextureHost();
|
||||
RefPtr<TextureHost> host = GetTextureHost();
|
||||
if (host) {
|
||||
host->Unlock();
|
||||
}
|
||||
@ -182,36 +174,27 @@ CompositableHost::Create(const TextureInfo& aTextureInfo)
|
||||
{
|
||||
RefPtr<CompositableHost> result;
|
||||
switch (aTextureInfo.mCompositableType) {
|
||||
case BUFFER_IMAGE_SINGLE:
|
||||
result = new DeprecatedImageHostSingle(aTextureInfo);
|
||||
case COMPOSITABLE_IMAGE:
|
||||
result = new ImageHost(aTextureInfo);
|
||||
break;
|
||||
case BUFFER_IMAGE_BUFFERED:
|
||||
result = new DeprecatedImageHostBuffered(aTextureInfo);
|
||||
break;
|
||||
case BUFFER_BRIDGE:
|
||||
MOZ_CRASH("Cannot create an image bridge compositable this way");
|
||||
break;
|
||||
case BUFFER_CONTENT:
|
||||
result = new DeprecatedContentHostSingleBuffered(aTextureInfo);
|
||||
break;
|
||||
case BUFFER_CONTENT_DIRECT:
|
||||
result = new DeprecatedContentHostDoubleBuffered(aTextureInfo);
|
||||
break;
|
||||
case BUFFER_CONTENT_INC:
|
||||
result = new ContentHostIncremental(aTextureInfo);
|
||||
case BUFFER_IMAGE_SINGLE:
|
||||
result = new DeprecatedImageHostSingle(aTextureInfo);
|
||||
break;
|
||||
case BUFFER_TILED:
|
||||
result = new TiledContentHost(aTextureInfo);
|
||||
break;
|
||||
case COMPOSITABLE_IMAGE:
|
||||
result = new ImageHost(aTextureInfo);
|
||||
break;
|
||||
case COMPOSITABLE_CONTENT_SINGLE:
|
||||
case BUFFER_CONTENT:
|
||||
result = new ContentHostSingleBuffered(aTextureInfo);
|
||||
break;
|
||||
case COMPOSITABLE_CONTENT_DOUBLE:
|
||||
case BUFFER_CONTENT_DIRECT:
|
||||
result = new ContentHostDoubleBuffered(aTextureInfo);
|
||||
break;
|
||||
case BUFFER_CONTENT_INC:
|
||||
result = new ContentHostIncremental(aTextureInfo);
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("Unknown CompositableType");
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
* Our IPDL actor is being destroyed, get rid of any shmem resources now and
|
||||
* don't worry about compositing anymore.
|
||||
*/
|
||||
virtual void OnActorDestroy();
|
||||
virtual void OnActorDestroy() = 0;
|
||||
|
||||
// If base class overrides, it should still call the parent implementation
|
||||
virtual void SetCompositor(Compositor* aCompositor);
|
||||
@ -211,7 +211,7 @@ public:
|
||||
/**
|
||||
* Returns the front buffer.
|
||||
*/
|
||||
virtual TextureHost* GetAsTextureHost() { return nullptr; }
|
||||
virtual TextureHost* GetTextureHost() { return nullptr; }
|
||||
|
||||
virtual LayerRenderState GetRenderState() = 0;
|
||||
|
||||
@ -296,13 +296,7 @@ public:
|
||||
|
||||
void AddTextureHost(TextureHost* aTexture);
|
||||
virtual void UseTextureHost(TextureHost* aTexture) {}
|
||||
// If a texture host is flagged for deferred removal, the compositable will
|
||||
// get an option to run any cleanup code early, that is when it would have
|
||||
// been run if the texture host was not marked deferred.
|
||||
// If the compositable does not cleanup the texture host now, it is the
|
||||
// compositable's responsibility to cleanup the texture host before the
|
||||
// texture host dies.
|
||||
virtual void RemoveTextureHost(TextureHost* aTexture);
|
||||
virtual void RemoveTextureHost(uint64_t aTextureID);
|
||||
TextureHost* GetTextureHost(uint64_t aTextureID);
|
||||
|
||||
protected:
|
||||
|
@ -31,339 +31,16 @@ ContentHostBase::ContentHostBase(const TextureInfo& aTextureInfo)
|
||||
{}
|
||||
|
||||
ContentHostBase::~ContentHostBase()
|
||||
{
|
||||
DestroyTextureHost();
|
||||
DestroyTextureHostOnWhite();
|
||||
}
|
||||
|
||||
TextureHost*
|
||||
ContentHostBase::GetAsTextureHost()
|
||||
{
|
||||
return mTextureHost;
|
||||
}
|
||||
|
||||
void
|
||||
ContentHostBase::DestroyTextureHost()
|
||||
{
|
||||
// The third clause in the if statement checks that we are in fact done with
|
||||
// this texture. We don't want to prematurely deallocate a texture we might
|
||||
// use again or double deallocate. Deallocation will happen in
|
||||
// RemoveTextureHost.
|
||||
// Note that GetTextureHost is linear in the number of texture hosts, but as
|
||||
// long as that number is small (I expect a maximum of 6 for now) then it
|
||||
// should be ok.
|
||||
if (mTextureHost &&
|
||||
mTextureHost->GetFlags() & TEXTURE_DEALLOCATE_DEFERRED &&
|
||||
!GetTextureHost(mTextureHost->GetID())) {
|
||||
MOZ_ASSERT(!(mTextureHost->GetFlags() & TEXTURE_DEALLOCATE_CLIENT));
|
||||
mTextureHost->DeallocateSharedData();
|
||||
}
|
||||
mTextureHost = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
ContentHostBase::DestroyTextureHostOnWhite()
|
||||
{
|
||||
if (mTextureHostOnWhite &&
|
||||
mTextureHostOnWhite->GetFlags() & TEXTURE_DEALLOCATE_DEFERRED &&
|
||||
!GetTextureHost(mTextureHostOnWhite->GetID())) {
|
||||
MOZ_ASSERT(!(mTextureHostOnWhite->GetFlags() & TEXTURE_DEALLOCATE_CLIENT));
|
||||
mTextureHostOnWhite->DeallocateSharedData();
|
||||
}
|
||||
mTextureHostOnWhite = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
ContentHostBase::RemoveTextureHost(TextureHost* aTexture)
|
||||
{
|
||||
if ((aTexture->GetFlags() & TEXTURE_DEALLOCATE_DEFERRED) &&
|
||||
!(mTextureHost && mTextureHost == aTexture) &&
|
||||
!(mTextureHostOnWhite && mTextureHostOnWhite == aTexture)) {
|
||||
MOZ_ASSERT(!(aTexture->GetFlags() & TEXTURE_DEALLOCATE_CLIENT));
|
||||
aTexture->DeallocateSharedData();
|
||||
}
|
||||
|
||||
CompositableHost::RemoveTextureHost(aTexture);
|
||||
}
|
||||
|
||||
class MOZ_STACK_CLASS AutoLockTextureHost
|
||||
{
|
||||
public:
|
||||
AutoLockTextureHost(TextureHost* aHost)
|
||||
: mHost(aHost)
|
||||
{
|
||||
mLockSuccess = mHost ? mHost->Lock() : true;
|
||||
}
|
||||
|
||||
~AutoLockTextureHost()
|
||||
{
|
||||
if (mHost) {
|
||||
mHost->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
bool IsValid()
|
||||
{
|
||||
return mLockSuccess;
|
||||
}
|
||||
|
||||
private:
|
||||
TextureHost* mHost;
|
||||
bool mLockSuccess;
|
||||
};
|
||||
|
||||
void
|
||||
ContentHostBase::Composite(EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
const Filter& aFilter,
|
||||
const Rect& aClipRect,
|
||||
const nsIntRegion* aVisibleRegion,
|
||||
TiledLayerProperties* aLayerProperties)
|
||||
{
|
||||
NS_ASSERTION(aVisibleRegion, "Requires a visible region");
|
||||
|
||||
AutoLockTextureHost lock(mTextureHost);
|
||||
AutoLockTextureHost lockOnWhite(mTextureHostOnWhite);
|
||||
|
||||
if (!mTextureHost ||
|
||||
!lock.IsValid() ||
|
||||
!lockOnWhite.IsValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<NewTextureSource> source = mTextureHost->GetTextureSources();
|
||||
RefPtr<NewTextureSource> sourceOnWhite = mTextureHostOnWhite
|
||||
? mTextureHostOnWhite->GetTextureSources()
|
||||
: nullptr;
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
RefPtr<TexturedEffect> effect =
|
||||
CreateTexturedEffect(source, sourceOnWhite, aFilter);
|
||||
|
||||
aEffectChain.mPrimaryEffect = effect;
|
||||
|
||||
nsIntRegion tmpRegion;
|
||||
const nsIntRegion* renderRegion;
|
||||
if (PaintWillResample()) {
|
||||
// If we're resampling, then the texture image will contain exactly the
|
||||
// entire visible region's bounds, and we should draw it all in one quad
|
||||
// to avoid unexpected aliasing.
|
||||
tmpRegion = aVisibleRegion->GetBounds();
|
||||
renderRegion = &tmpRegion;
|
||||
} else {
|
||||
renderRegion = aVisibleRegion;
|
||||
}
|
||||
|
||||
nsIntRegion region(*renderRegion);
|
||||
nsIntPoint origin = GetOriginOffset();
|
||||
// translate into TexImage space, buffer origin might not be at texture (0,0)
|
||||
region.MoveBy(-origin);
|
||||
|
||||
// Figure out the intersecting draw region
|
||||
gfx::IntSize texSize = source->GetSize();
|
||||
nsIntRect textureRect = nsIntRect(0, 0, texSize.width, texSize.height);
|
||||
textureRect.MoveBy(region.GetBounds().TopLeft());
|
||||
nsIntRegion subregion;
|
||||
subregion.And(region, textureRect);
|
||||
if (subregion.IsEmpty()) {
|
||||
// Region is empty, nothing to draw
|
||||
return;
|
||||
}
|
||||
|
||||
nsIntRegion screenRects;
|
||||
nsIntRegion regionRects;
|
||||
|
||||
// Collect texture/screen coordinates for drawing
|
||||
nsIntRegionRectIterator iter(subregion);
|
||||
while (const nsIntRect* iterRect = iter.Next()) {
|
||||
nsIntRect regionRect = *iterRect;
|
||||
nsIntRect screenRect = regionRect;
|
||||
screenRect.MoveBy(origin);
|
||||
|
||||
screenRects.Or(screenRects, screenRect);
|
||||
regionRects.Or(regionRects, regionRect);
|
||||
}
|
||||
|
||||
TileIterator* tileIter = source->AsTileIterator();
|
||||
TileIterator* iterOnWhite = nullptr;
|
||||
if (tileIter) {
|
||||
tileIter->BeginTileIteration();
|
||||
}
|
||||
|
||||
if (mTextureHostOnWhite) {
|
||||
iterOnWhite = sourceOnWhite->AsTileIterator();
|
||||
MOZ_ASSERT(!tileIter || tileIter->GetTileCount() == iterOnWhite->GetTileCount(),
|
||||
"Tile count mismatch on component alpha texture");
|
||||
if (iterOnWhite) {
|
||||
iterOnWhite->BeginTileIteration();
|
||||
}
|
||||
}
|
||||
|
||||
bool usingTiles = (tileIter && tileIter->GetTileCount() > 1);
|
||||
do {
|
||||
if (iterOnWhite) {
|
||||
MOZ_ASSERT(iterOnWhite->GetTileRect() == tileIter->GetTileRect(),
|
||||
"component alpha textures should be the same size.");
|
||||
}
|
||||
|
||||
nsIntRect texRect = tileIter ? tileIter->GetTileRect()
|
||||
: nsIntRect(0, 0,
|
||||
texSize.width,
|
||||
texSize.height);
|
||||
|
||||
// Draw texture. If we're using tiles, we do repeating manually, as texture
|
||||
// repeat would cause each individual tile to repeat instead of the
|
||||
// compound texture as a whole. This involves drawing at most 4 sections,
|
||||
// 2 for each axis that has texture repeat.
|
||||
for (int y = 0; y < (usingTiles ? 2 : 1); y++) {
|
||||
for (int x = 0; x < (usingTiles ? 2 : 1); x++) {
|
||||
nsIntRect currentTileRect(texRect);
|
||||
currentTileRect.MoveBy(x * texSize.width, y * texSize.height);
|
||||
|
||||
nsIntRegionRectIterator screenIter(screenRects);
|
||||
nsIntRegionRectIterator regionIter(regionRects);
|
||||
|
||||
const nsIntRect* screenRect;
|
||||
const nsIntRect* regionRect;
|
||||
while ((screenRect = screenIter.Next()) &&
|
||||
(regionRect = regionIter.Next())) {
|
||||
nsIntRect tileScreenRect(*screenRect);
|
||||
nsIntRect tileRegionRect(*regionRect);
|
||||
|
||||
// When we're using tiles, find the intersection between the tile
|
||||
// rect and this region rect. Tiling is then handled by the
|
||||
// outer for-loops and modifying the tile rect.
|
||||
if (usingTiles) {
|
||||
tileScreenRect.MoveBy(-origin);
|
||||
tileScreenRect = tileScreenRect.Intersect(currentTileRect);
|
||||
tileScreenRect.MoveBy(origin);
|
||||
|
||||
if (tileScreenRect.IsEmpty())
|
||||
continue;
|
||||
|
||||
tileRegionRect = regionRect->Intersect(currentTileRect);
|
||||
tileRegionRect.MoveBy(-currentTileRect.TopLeft());
|
||||
}
|
||||
gfx::Rect rect(tileScreenRect.x, tileScreenRect.y,
|
||||
tileScreenRect.width, tileScreenRect.height);
|
||||
|
||||
effect->mTextureCoords = Rect(Float(tileRegionRect.x) / texRect.width,
|
||||
Float(tileRegionRect.y) / texRect.height,
|
||||
Float(tileRegionRect.width) / texRect.width,
|
||||
Float(tileRegionRect.height) / texRect.height);
|
||||
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain, aOpacity, aTransform);
|
||||
if (usingTiles) {
|
||||
DiagnosticTypes diagnostics = DIAGNOSTIC_CONTENT | DIAGNOSTIC_BIGIMAGE;
|
||||
diagnostics |= iterOnWhite ? DIAGNOSTIC_COMPONENT_ALPHA : 0;
|
||||
GetCompositor()->DrawDiagnostics(diagnostics, rect, aClipRect,
|
||||
aTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iterOnWhite) {
|
||||
iterOnWhite->NextTile();
|
||||
}
|
||||
} while (usingTiles && tileIter->NextTile());
|
||||
|
||||
if (tileIter) {
|
||||
tileIter->EndTileIteration();
|
||||
}
|
||||
if (iterOnWhite) {
|
||||
iterOnWhite->EndTileIteration();
|
||||
}
|
||||
|
||||
DiagnosticTypes diagnostics = DIAGNOSTIC_CONTENT;
|
||||
diagnostics |= iterOnWhite ? DIAGNOSTIC_COMPONENT_ALPHA : 0;
|
||||
GetCompositor()->DrawDiagnostics(diagnostics, *aVisibleRegion, aClipRect, aTransform);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ContentHostBase::UseTextureHost(TextureHost* aTexture)
|
||||
{
|
||||
if (aTexture->GetFlags() & TEXTURE_ON_WHITE) {
|
||||
DestroyTextureHost();
|
||||
mTextureHostOnWhite = aTexture;
|
||||
} else {
|
||||
DestroyTextureHostOnWhite();
|
||||
mTextureHost = aTexture;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContentHostBase::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
CompositableHost::SetCompositor(aCompositor);
|
||||
if (mTextureHost) {
|
||||
mTextureHost->SetCompositor(aCompositor);
|
||||
}
|
||||
if (mTextureHostOnWhite) {
|
||||
mTextureHostOnWhite->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
void
|
||||
ContentHostBase::Dump(FILE* aFile,
|
||||
const char* aPrefix,
|
||||
bool aDumpHtml)
|
||||
{
|
||||
if (!aDumpHtml) {
|
||||
return;
|
||||
}
|
||||
if (!aFile) {
|
||||
aFile = stderr;
|
||||
}
|
||||
fprintf(aFile, "<ul>");
|
||||
if (mTextureHost) {
|
||||
fprintf(aFile, "%s", aPrefix);
|
||||
fprintf(aFile, "<li> <a href=");
|
||||
DumpTextureHost(aFile, mTextureHost);
|
||||
fprintf(aFile, "> Front buffer </a></li> ");
|
||||
}
|
||||
if (mTextureHostOnWhite) {
|
||||
fprintf(aFile, "%s", aPrefix);
|
||||
fprintf(aFile, "<li> <a href=");
|
||||
DumpTextureHost(aFile, mTextureHostOnWhite);
|
||||
fprintf(aFile, "> Front buffer on white </a> </li> ");
|
||||
}
|
||||
fprintf(aFile, "</ul>");
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
ContentHostBase::OnActorDestroy()
|
||||
{
|
||||
if (mTextureHost) {
|
||||
mTextureHost->OnActorDestroy();
|
||||
}
|
||||
if (mTextureHostOnWhite) {
|
||||
mTextureHostOnWhite->OnActorDestroy();
|
||||
}
|
||||
CompositableHost::OnActorDestroy();
|
||||
}
|
||||
|
||||
DeprecatedContentHostBase::DeprecatedContentHostBase(const TextureInfo& aTextureInfo)
|
||||
: ContentHost(aTextureInfo)
|
||||
, mPaintWillResample(false)
|
||||
, mInitialised(false)
|
||||
{}
|
||||
|
||||
DeprecatedContentHostBase::~DeprecatedContentHostBase()
|
||||
{}
|
||||
|
||||
DeprecatedTextureHost*
|
||||
DeprecatedContentHostBase::GetDeprecatedTextureHost()
|
||||
ContentHostBase::GetDeprecatedTextureHost()
|
||||
{
|
||||
return mDeprecatedTextureHost;
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostBase::DestroyFrontHost()
|
||||
ContentHostBase::DestroyFrontHost()
|
||||
{
|
||||
MOZ_ASSERT(!mDeprecatedTextureHost || mDeprecatedTextureHost->GetDeAllocator(),
|
||||
"We won't be able to destroy our SurfaceDescriptor");
|
||||
@ -374,7 +51,7 @@ DeprecatedContentHostBase::DestroyFrontHost()
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostBase::OnActorDestroy()
|
||||
ContentHostBase::OnActorDestroy()
|
||||
{
|
||||
if (mDeprecatedTextureHost) {
|
||||
mDeprecatedTextureHost->OnActorDestroy();
|
||||
@ -391,7 +68,7 @@ DeprecatedContentHostBase::OnActorDestroy()
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostBase::Composite(EffectChain& aEffectChain,
|
||||
ContentHostBase::Composite(EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
const Filter& aFilter,
|
||||
@ -557,7 +234,7 @@ DeprecatedContentHostBase::Composite(EffectChain& aEffectChain,
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostBase::SetCompositor(Compositor* aCompositor)
|
||||
ContentHostBase::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
CompositableHost::SetCompositor(aCompositor);
|
||||
if (mDeprecatedTextureHost) {
|
||||
@ -571,7 +248,7 @@ DeprecatedContentHostBase::SetCompositor(Compositor* aCompositor)
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
|
||||
void
|
||||
DeprecatedContentHostBase::Dump(FILE* aFile,
|
||||
ContentHostBase::Dump(FILE* aFile,
|
||||
const char* aPrefix,
|
||||
bool aDumpHtml)
|
||||
{
|
||||
@ -599,56 +276,14 @@ DeprecatedContentHostBase::Dump(FILE* aFile,
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
ContentHostSingleBuffered::UpdateThebes(const ThebesBufferData& aData,
|
||||
const nsIntRegion& aUpdated,
|
||||
const nsIntRegion& aOldValidRegionBack,
|
||||
nsIntRegion* aUpdatedRegionBack)
|
||||
{
|
||||
aUpdatedRegionBack->SetEmpty();
|
||||
|
||||
if (!mTextureHost) {
|
||||
mInitialised = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// updated is in screen coordinates. Convert it to buffer coordinates.
|
||||
nsIntRegion destRegion(aUpdated);
|
||||
destRegion.MoveBy(-aData.rect().TopLeft());
|
||||
|
||||
// Correct for rotation
|
||||
destRegion.MoveBy(aData.rotation());
|
||||
|
||||
gfxIntSize size = aData.rect().Size();
|
||||
nsIntRect destBounds = destRegion.GetBounds();
|
||||
destRegion.MoveBy((destBounds.x >= size.width) ? -size.width : 0,
|
||||
(destBounds.y >= size.height) ? -size.height : 0);
|
||||
|
||||
// There's code to make sure that updated regions don't cross rotation
|
||||
// boundaries, so assert here that this is the case
|
||||
MOZ_ASSERT((destBounds.x % size.width) + destBounds.width <= size.width,
|
||||
"updated region lies across rotation boundaries!");
|
||||
MOZ_ASSERT((destBounds.y % size.height) + destBounds.height <= size.height,
|
||||
"updated region lies across rotation boundaries!");
|
||||
|
||||
mTextureHost->Updated(&destRegion);
|
||||
if (mTextureHostOnWhite) {
|
||||
mTextureHostOnWhite->Updated(&destRegion);
|
||||
}
|
||||
mInitialised = true;
|
||||
|
||||
mBufferRect = aData.rect();
|
||||
mBufferRotation = aData.rotation();
|
||||
}
|
||||
|
||||
DeprecatedContentHostSingleBuffered::~DeprecatedContentHostSingleBuffered()
|
||||
ContentHostSingleBuffered::~ContentHostSingleBuffered()
|
||||
{
|
||||
DestroyTextures();
|
||||
DestroyFrontHost();
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostSingleBuffered::EnsureDeprecatedTextureHost(TextureIdentifier aTextureId,
|
||||
ContentHostSingleBuffered::EnsureDeprecatedTextureHost(TextureIdentifier aTextureId,
|
||||
const SurfaceDescriptor& aSurface,
|
||||
ISurfaceAllocator* aAllocator,
|
||||
const TextureInfo& aTextureInfo)
|
||||
@ -671,7 +306,7 @@ DeprecatedContentHostSingleBuffered::EnsureDeprecatedTextureHost(TextureIdentifi
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostSingleBuffered::DestroyTextures()
|
||||
ContentHostSingleBuffered::DestroyTextures()
|
||||
{
|
||||
MOZ_ASSERT(!mNewFrontHost || mNewFrontHost->GetDeAllocator(),
|
||||
"We won't be able to destroy our SurfaceDescriptor");
|
||||
@ -684,7 +319,7 @@ DeprecatedContentHostSingleBuffered::DestroyTextures()
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostSingleBuffered::UpdateThebes(const ThebesBufferData& aData,
|
||||
ContentHostSingleBuffered::UpdateThebes(const ThebesBufferData& aData,
|
||||
const nsIntRegion& aUpdated,
|
||||
const nsIntRegion& aOldValidRegionBack,
|
||||
nsIntRegion* aUpdatedRegionBack)
|
||||
@ -738,51 +373,14 @@ DeprecatedContentHostSingleBuffered::UpdateThebes(const ThebesBufferData& aData,
|
||||
mBufferRotation = aData.rotation();
|
||||
}
|
||||
|
||||
void
|
||||
ContentHostDoubleBuffered::UpdateThebes(const ThebesBufferData& aData,
|
||||
const nsIntRegion& aUpdated,
|
||||
const nsIntRegion& aOldValidRegionBack,
|
||||
nsIntRegion* aUpdatedRegionBack)
|
||||
{
|
||||
if (!mTextureHost) {
|
||||
mInitialised = false;
|
||||
|
||||
*aUpdatedRegionBack = aUpdated;
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't need to calculate an update region because we assume that if we
|
||||
// are using double buffering then we have render-to-texture and thus no
|
||||
// upload to do.
|
||||
mTextureHost->Updated();
|
||||
if (mTextureHostOnWhite) {
|
||||
mTextureHostOnWhite->Updated();
|
||||
}
|
||||
mInitialised = true;
|
||||
|
||||
mBufferRect = aData.rect();
|
||||
mBufferRotation = aData.rotation();
|
||||
|
||||
*aUpdatedRegionBack = aUpdated;
|
||||
|
||||
// Save the current valid region of our front buffer, because if
|
||||
// we're double buffering, it's going to be the valid region for the
|
||||
// next back buffer sent back to the renderer.
|
||||
//
|
||||
// NB: we rely here on the fact that mValidRegion is initialized to
|
||||
// empty, and that the first time Swap() is called we don't have a
|
||||
// valid front buffer that we're going to return to content.
|
||||
mValidRegionForNextBackBuffer = aOldValidRegionBack;
|
||||
}
|
||||
|
||||
DeprecatedContentHostDoubleBuffered::~DeprecatedContentHostDoubleBuffered()
|
||||
ContentHostDoubleBuffered::~ContentHostDoubleBuffered()
|
||||
{
|
||||
DestroyTextures();
|
||||
DestroyFrontHost();
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostDoubleBuffered::EnsureDeprecatedTextureHost(TextureIdentifier aTextureId,
|
||||
ContentHostDoubleBuffered::EnsureDeprecatedTextureHost(TextureIdentifier aTextureId,
|
||||
const SurfaceDescriptor& aSurface,
|
||||
ISurfaceAllocator* aAllocator,
|
||||
const TextureInfo& aTextureInfo)
|
||||
@ -822,7 +420,7 @@ DeprecatedContentHostDoubleBuffered::EnsureDeprecatedTextureHost(TextureIdentifi
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostDoubleBuffered::DestroyTextures()
|
||||
ContentHostDoubleBuffered::DestroyTextures()
|
||||
{
|
||||
if (mNewFrontHost) {
|
||||
MOZ_ASSERT(mNewFrontHost->GetDeAllocator(),
|
||||
@ -849,7 +447,7 @@ DeprecatedContentHostDoubleBuffered::DestroyTextures()
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostDoubleBuffered::OnActorDestroy()
|
||||
ContentHostDoubleBuffered::OnActorDestroy()
|
||||
{
|
||||
if (mDeprecatedTextureHost) {
|
||||
mDeprecatedTextureHost->OnActorDestroy();
|
||||
@ -872,7 +470,7 @@ DeprecatedContentHostDoubleBuffered::OnActorDestroy()
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostDoubleBuffered::UpdateThebes(const ThebesBufferData& aData,
|
||||
ContentHostDoubleBuffered::UpdateThebes(const ThebesBufferData& aData,
|
||||
const nsIntRegion& aUpdated,
|
||||
const nsIntRegion& aOldValidRegionBack,
|
||||
nsIntRegion* aUpdatedRegionBack)
|
||||
@ -1157,31 +755,10 @@ ContentHostIncremental::TextureUpdateRequest::Execute(ContentHostIncremental* aH
|
||||
}
|
||||
|
||||
void
|
||||
ContentHostBase::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
ContentHostSingleBuffered::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
{
|
||||
aTo += aPrefix;
|
||||
aTo += nsPrintfCString("ContentHost (0x%p)", this);
|
||||
|
||||
AppendToString(aTo, mBufferRect, " [buffer-rect=", "]");
|
||||
AppendToString(aTo, mBufferRotation, " [buffer-rotation=", "]");
|
||||
if (PaintWillResample()) {
|
||||
aTo += " [paint-will-resample]";
|
||||
}
|
||||
|
||||
nsAutoCString pfx(aPrefix);
|
||||
pfx += " ";
|
||||
|
||||
if (mTextureHost) {
|
||||
aTo += "\n";
|
||||
mTextureHost->PrintInfo(aTo, pfx.get());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostSingleBuffered::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
{
|
||||
aTo += aPrefix;
|
||||
aTo += nsPrintfCString("DeprecatedContentHostSingleBuffered (0x%p)", this);
|
||||
aTo += nsPrintfCString("ContentHostSingleBuffered (0x%p)", this);
|
||||
|
||||
AppendToString(aTo, mBufferRect, " [buffer-rect=", "]");
|
||||
AppendToString(aTo, mBufferRotation, " [buffer-rotation=", "]");
|
||||
@ -1199,10 +776,10 @@ DeprecatedContentHostSingleBuffered::PrintInfo(nsACString& aTo, const char* aPre
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostDoubleBuffered::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
ContentHostDoubleBuffered::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
{
|
||||
aTo += aPrefix;
|
||||
aTo += nsPrintfCString("DeprecatedContentHostDoubleBuffered (0x%p)", this);
|
||||
aTo += nsPrintfCString("ContentHostDoubleBuffered (0x%p)", this);
|
||||
|
||||
AppendToString(aTo, mBufferRect, " [buffer-rect=", "]");
|
||||
AppendToString(aTo, mBufferRotation, " [buffer-rotation=", "]");
|
||||
@ -1226,11 +803,11 @@ DeprecatedContentHostDoubleBuffered::PrintInfo(nsACString& aTo, const char* aPre
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
void
|
||||
DeprecatedContentHostDoubleBuffered::Dump(FILE* aFile,
|
||||
ContentHostDoubleBuffered::Dump(FILE* aFile,
|
||||
const char* aPrefix,
|
||||
bool aDumpHtml)
|
||||
{
|
||||
DeprecatedContentHostBase::Dump(aFile, aPrefix, aDumpHtml);
|
||||
ContentHostBase::Dump(aFile, aPrefix, aDumpHtml);
|
||||
if (!aDumpHtml) {
|
||||
return;
|
||||
}
|
||||
@ -1256,22 +833,6 @@ DeprecatedContentHostDoubleBuffered::Dump(FILE* aFile,
|
||||
|
||||
LayerRenderState
|
||||
ContentHostBase::GetRenderState()
|
||||
{
|
||||
if (!mTextureHost) {
|
||||
return LayerRenderState();
|
||||
}
|
||||
|
||||
LayerRenderState result = mTextureHost->GetRenderState();
|
||||
|
||||
if (mBufferRotation != nsIntPoint()) {
|
||||
result.mFlags |= LAYER_RENDER_STATE_BUFFER_ROTATION;
|
||||
}
|
||||
result.SetOffset(GetOriginOffset());
|
||||
return result;
|
||||
}
|
||||
|
||||
LayerRenderState
|
||||
DeprecatedContentHostBase::GetRenderState()
|
||||
{
|
||||
LayerRenderState result = mDeprecatedTextureHost->GetRenderState();
|
||||
|
||||
@ -1285,16 +846,6 @@ DeprecatedContentHostBase::GetRenderState()
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
TemporaryRef<gfx::DataSourceSurface>
|
||||
ContentHostBase::GetAsSurface()
|
||||
{
|
||||
if (!mTextureHost) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mTextureHost->GetAsSurface();
|
||||
}
|
||||
|
||||
TemporaryRef<gfx::DataSourceSurface>
|
||||
DeprecatedContentHostBase::GetAsSurface()
|
||||
{
|
||||
return mDeprecatedTextureHost->GetAsSurface();
|
||||
}
|
||||
|
@ -89,67 +89,7 @@ public:
|
||||
typedef RotatedContentBuffer::PaintState PaintState;
|
||||
|
||||
ContentHostBase(const TextureInfo& aTextureInfo);
|
||||
virtual ~ContentHostBase();
|
||||
|
||||
virtual void Composite(EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
const gfx::Filter& aFilter,
|
||||
const gfx::Rect& aClipRect,
|
||||
const nsIntRegion* aVisibleRegion = nullptr,
|
||||
TiledLayerProperties* aLayerProperties = nullptr);
|
||||
|
||||
virtual LayerRenderState GetRenderState() MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE;
|
||||
|
||||
virtual void Dump(FILE* aFile=nullptr,
|
||||
const char* aPrefix="",
|
||||
bool aDumpHtml=false) MOZ_OVERRIDE;
|
||||
#endif
|
||||
|
||||
virtual void PrintInfo(nsACString& aTo, const char* aPrefix) MOZ_OVERRIDE;
|
||||
|
||||
virtual TextureHost* GetAsTextureHost() MOZ_OVERRIDE;
|
||||
|
||||
virtual void UseTextureHost(TextureHost* aTexture) MOZ_OVERRIDE;
|
||||
|
||||
virtual void RemoveTextureHost(TextureHost* aTexture) MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetPaintWillResample(bool aResample) { mPaintWillResample = aResample; }
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual nsIntPoint GetOriginOffset()
|
||||
{
|
||||
return mBufferRect.TopLeft() - mBufferRotation;
|
||||
}
|
||||
|
||||
bool PaintWillResample() { return mPaintWillResample; }
|
||||
|
||||
// These must be called before forgetting mTextureHost or mTextureHostOnWhite
|
||||
void DestroyTextureHost();
|
||||
void DestroyTextureHostOnWhite();
|
||||
|
||||
nsIntRect mBufferRect;
|
||||
nsIntPoint mBufferRotation;
|
||||
RefPtr<TextureHost> mTextureHost;
|
||||
RefPtr<TextureHost> mTextureHostOnWhite;
|
||||
bool mPaintWillResample;
|
||||
bool mInitialised;
|
||||
};
|
||||
class DeprecatedContentHostBase : public ContentHost
|
||||
{
|
||||
public:
|
||||
typedef RotatedContentBuffer::ContentType ContentType;
|
||||
typedef RotatedContentBuffer::PaintState PaintState;
|
||||
|
||||
DeprecatedContentHostBase(const TextureInfo& aTextureInfo);
|
||||
~DeprecatedContentHostBase();
|
||||
~ContentHostBase();
|
||||
|
||||
virtual void Composite(EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
@ -213,9 +153,7 @@ protected:
|
||||
};
|
||||
|
||||
/**
|
||||
* Double buffering is implemented by swapping the front and back TextureHosts.
|
||||
* We assume that whenever we use double buffering, then we have
|
||||
* render-to-texture and thus no texture upload to do.
|
||||
* Double buffering is implemented by swapping the front and back DeprecatedTextureHosts.
|
||||
*/
|
||||
class ContentHostDoubleBuffered : public ContentHostBase
|
||||
{
|
||||
@ -224,27 +162,7 @@ public:
|
||||
: ContentHostBase(aTextureInfo)
|
||||
{}
|
||||
|
||||
virtual ~ContentHostDoubleBuffered() {}
|
||||
|
||||
virtual CompositableType GetType() { return COMPOSITABLE_CONTENT_DOUBLE; }
|
||||
|
||||
virtual void UpdateThebes(const ThebesBufferData& aData,
|
||||
const nsIntRegion& aUpdated,
|
||||
const nsIntRegion& aOldValidRegionBack,
|
||||
nsIntRegion* aUpdatedRegionBack);
|
||||
|
||||
protected:
|
||||
nsIntRegion mValidRegionForNextBackBuffer;
|
||||
};
|
||||
|
||||
class DeprecatedContentHostDoubleBuffered : public DeprecatedContentHostBase
|
||||
{
|
||||
public:
|
||||
DeprecatedContentHostDoubleBuffered(const TextureInfo& aTextureInfo)
|
||||
: DeprecatedContentHostBase(aTextureInfo)
|
||||
{}
|
||||
|
||||
~DeprecatedContentHostDoubleBuffered();
|
||||
~ContentHostDoubleBuffered();
|
||||
|
||||
virtual CompositableType GetType() { return BUFFER_CONTENT_DIRECT; }
|
||||
|
||||
@ -287,23 +205,7 @@ public:
|
||||
ContentHostSingleBuffered(const TextureInfo& aTextureInfo)
|
||||
: ContentHostBase(aTextureInfo)
|
||||
{}
|
||||
virtual ~ContentHostSingleBuffered() {}
|
||||
|
||||
virtual CompositableType GetType() { return COMPOSITABLE_CONTENT_SINGLE; }
|
||||
|
||||
virtual void UpdateThebes(const ThebesBufferData& aData,
|
||||
const nsIntRegion& aUpdated,
|
||||
const nsIntRegion& aOldValidRegionBack,
|
||||
nsIntRegion* aUpdatedRegionBack);
|
||||
};
|
||||
|
||||
class DeprecatedContentHostSingleBuffered : public DeprecatedContentHostBase
|
||||
{
|
||||
public:
|
||||
DeprecatedContentHostSingleBuffered(const TextureInfo& aTextureInfo)
|
||||
: DeprecatedContentHostBase(aTextureInfo)
|
||||
{}
|
||||
virtual ~DeprecatedContentHostSingleBuffered();
|
||||
virtual ~ContentHostSingleBuffered();
|
||||
|
||||
virtual CompositableType GetType() { return BUFFER_CONTENT; }
|
||||
|
||||
@ -331,11 +233,11 @@ public:
|
||||
* Delays texture uploads until the next composite to
|
||||
* avoid blocking the main thread.
|
||||
*/
|
||||
class ContentHostIncremental : public DeprecatedContentHostBase
|
||||
class ContentHostIncremental : public ContentHostBase
|
||||
{
|
||||
public:
|
||||
ContentHostIncremental(const TextureInfo& aTextureInfo)
|
||||
: DeprecatedContentHostBase(aTextureInfo)
|
||||
: ContentHostBase(aTextureInfo)
|
||||
, mDeAllocator(nullptr)
|
||||
{}
|
||||
|
||||
@ -377,7 +279,7 @@ public:
|
||||
{
|
||||
ProcessTextureUpdates();
|
||||
|
||||
DeprecatedContentHostBase::Composite(aEffectChain, aOpacity,
|
||||
ContentHostBase::Composite(aEffectChain, aOpacity,
|
||||
aTransform, aFilter,
|
||||
aClipRect, aVisibleRegion,
|
||||
aLayerProperties);
|
||||
|
@ -42,16 +42,16 @@ ImageHost::UseTextureHost(TextureHost* aTexture)
|
||||
}
|
||||
|
||||
void
|
||||
ImageHost::RemoveTextureHost(TextureHost* aTexture)
|
||||
ImageHost::RemoveTextureHost(uint64_t aTextureID)
|
||||
{
|
||||
CompositableHost::RemoveTextureHost(aTexture);
|
||||
if (mFrontBuffer && mFrontBuffer->GetID() == aTexture->GetID()) {
|
||||
CompositableHost::RemoveTextureHost(aTextureID);
|
||||
if (mFrontBuffer && mFrontBuffer->GetID() == aTextureID) {
|
||||
mFrontBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
TextureHost*
|
||||
ImageHost::GetAsTextureHost()
|
||||
ImageHost::GetTextureHost()
|
||||
{
|
||||
return mFrontBuffer;
|
||||
}
|
||||
|
@ -55,9 +55,9 @@ public:
|
||||
|
||||
virtual void UseTextureHost(TextureHost* aTexture) MOZ_OVERRIDE;
|
||||
|
||||
virtual void RemoveTextureHost(TextureHost* aTexture) MOZ_OVERRIDE;
|
||||
virtual void RemoveTextureHost(uint64_t aTextureID) MOZ_OVERRIDE;
|
||||
|
||||
virtual TextureHost* GetAsTextureHost() MOZ_OVERRIDE;
|
||||
virtual TextureHost* GetTextureHost() MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetPictureRect(const nsIntRect& aPictureRect) MOZ_OVERRIDE
|
||||
{
|
||||
|
@ -121,10 +121,10 @@ ImageLayerComposite::ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToS
|
||||
gfxRect sourceRect(0, 0, 0, 0);
|
||||
if (mImageHost &&
|
||||
mImageHost->IsAttached() &&
|
||||
(mImageHost->GetDeprecatedTextureHost() || mImageHost->GetAsTextureHost())) {
|
||||
(mImageHost->GetDeprecatedTextureHost() || mImageHost->GetTextureHost())) {
|
||||
IntSize size =
|
||||
mImageHost->GetAsTextureHost() ? mImageHost->GetAsTextureHost()->GetSize()
|
||||
: mImageHost->GetDeprecatedTextureHost()->GetSize();
|
||||
mImageHost->GetTextureHost() ? mImageHost->GetTextureHost()->GetSize()
|
||||
: mImageHost->GetDeprecatedTextureHost()->GetSize();
|
||||
sourceRect.SizeTo(size.width, size.height);
|
||||
if (mScaleMode != SCALE_NONE &&
|
||||
sourceRect.width != 0.0 && sourceRect.height != 0.0) {
|
||||
|
@ -513,7 +513,6 @@ ShmemTextureHost::DeallocateSharedData()
|
||||
MOZ_ASSERT(mDeallocator,
|
||||
"Shared memory would leak without a ISurfaceAllocator");
|
||||
mDeallocator->DeallocShmem(*mShmem);
|
||||
mShmem = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -552,7 +551,6 @@ MemoryTextureHost::DeallocateSharedData()
|
||||
GfxMemoryImageReporter::WillFree(mBuffer);
|
||||
}
|
||||
delete[] mBuffer;
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
|
||||
uint8_t* MemoryTextureHost::GetBuffer()
|
||||
|
@ -308,7 +308,7 @@ public:
|
||||
* @param aRegion The region that has been changed, if nil, it means that the
|
||||
* entire surface should be updated.
|
||||
*/
|
||||
virtual void Updated(const nsIntRegion* aRegion = nullptr) {}
|
||||
virtual void Updated(const nsIntRegion* aRegion) {}
|
||||
|
||||
/**
|
||||
* Sets this TextureHost's compositor.
|
||||
@ -422,7 +422,7 @@ public:
|
||||
|
||||
virtual uint8_t* GetBuffer() = 0;
|
||||
|
||||
virtual void Updated(const nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
|
||||
virtual void Updated(const nsIntRegion* aRegion) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool Lock() MOZ_OVERRIDE;
|
||||
|
||||
|
@ -98,7 +98,7 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
|
||||
MOZ_LAYERS_LOG(("[ParentSide] Created double buffer"));
|
||||
const OpDestroyThebesBuffer& op = aEdit.get_OpDestroyThebesBuffer();
|
||||
CompositableParent* compositableParent = static_cast<CompositableParent*>(op.compositableParent());
|
||||
DeprecatedContentHostBase* content = static_cast<DeprecatedContentHostBase*>(compositableParent->GetCompositableHost());
|
||||
ContentHostBase* content = static_cast<ContentHostBase*>(compositableParent->GetCompositableHost());
|
||||
content->DestroyTextures();
|
||||
|
||||
break;
|
||||
@ -271,12 +271,11 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
|
||||
|
||||
TextureFlags flags = texture->GetFlags();
|
||||
|
||||
if (!(flags & TEXTURE_DEALLOCATE_CLIENT) &&
|
||||
!(flags & TEXTURE_DEALLOCATE_DEFERRED)) {
|
||||
if (!(flags & TEXTURE_DEALLOCATE_CLIENT)) {
|
||||
texture->DeallocateSharedData();
|
||||
}
|
||||
|
||||
compositable->RemoveTextureHost(texture);
|
||||
compositable->RemoveTextureHost(op.textureID());
|
||||
|
||||
// if it is not the host that deallocates the shared data, then we need
|
||||
// to notfy the client side to tell when it is safe to deallocate or
|
||||
|
@ -186,8 +186,7 @@ GrallocTextureClientOGL::GetBuffer() const
|
||||
}
|
||||
|
||||
bool
|
||||
GrallocTextureClientOGL::AllocateForSurface(gfx::IntSize aSize,
|
||||
TextureAllocationFlags)
|
||||
GrallocTextureClientOGL::AllocateForSurface(gfx::IntSize aSize)
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
MOZ_ASSERT(mCompositable);
|
||||
|
@ -80,8 +80,7 @@ public:
|
||||
|
||||
virtual uint8_t* GetBuffer() const MOZ_OVERRIDE;
|
||||
|
||||
virtual bool AllocateForSurface(gfx::IntSize aSize,
|
||||
TextureAllocationFlags aFlags = ALLOC_DEFAULT) MOZ_OVERRIDE;
|
||||
virtual bool AllocateForSurface(gfx::IntSize aSize) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool AllocateForYCbCr(gfx::IntSize aYSize,
|
||||
gfx::IntSize aCbCrSize,
|
||||
|
Loading…
Reference in New Issue
Block a user