☠☠ backed out by 42e88b68a92d ☠ ☠ | |
author | Nicolas Silva <nsilva@mozilla.com> |
Wed, 09 Jul 2014 11:59:49 +0200 | |
changeset 193013 | e072a46f0b6a12bbf3ab3c3c0536da22c903174e |
parent 193012 | 6292743f667ffcb1382f3878f6444ee6e2e47c01 |
child 193014 | ef24cd472cfb517a07ca3b5a38777b5b97e97eb2 |
push id | 45996 |
push user | nsilva@mozilla.com |
push date | Wed, 09 Jul 2014 10:00:05 +0000 |
treeherder | mozilla-inbound@ef24cd472cfb [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | sotaro |
bugs | 1027601 |
milestone | 33.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/layers/ImageContainer.cpp +++ b/gfx/layers/ImageContainer.cpp @@ -632,25 +632,24 @@ CairoImage::GetTextureClient(Compositabl RefPtr<SourceSurface> surface = GetAsSourceSurface(); MOZ_ASSERT(surface); if (!surface) { return nullptr; } // gfx::BackendType::NONE means default to content backend textureClient = aClient->CreateTextureClientForDrawing(surface->GetFormat(), - TextureFlags::DEFAULT, + surface->GetSize(), gfx::BackendType::NONE, - surface->GetSize()); + TextureFlags::DEFAULT); if (!textureClient) { return nullptr; } MOZ_ASSERT(textureClient->CanExposeDrawTarget()); - if (!textureClient->AllocateForSurface(surface->GetSize()) || - !textureClient->Lock(OpenMode::OPEN_WRITE_ONLY)) { + if (!textureClient->Lock(OpenMode::OPEN_WRITE_ONLY)) { return nullptr; } TextureClientAutoUnlock autoUnolck(textureClient); { // We must not keep a reference to the DrawTarget after it has been unlocked. DrawTarget* dt = textureClient->BorrowDrawTarget(); if (!dt) {
--- a/gfx/layers/client/CanvasClient.cpp +++ b/gfx/layers/client/CanvasClient.cpp @@ -69,16 +69,20 @@ CanvasClient2D::Update(gfx::IntSize aSiz = gfxPlatform::GetPlatform()->OptimalFormatForContent(contentType); TextureFlags flags = TextureFlags::DEFAULT; if (mTextureFlags & TextureFlags::NEEDS_Y_FLIP) { flags |= TextureFlags::NEEDS_Y_FLIP; } gfx::SurfaceFormat surfaceFormat = gfx::ImageFormatToSurfaceFormat(format); mBuffer = CreateTextureClientForCanvas(surfaceFormat, aSize, flags, aLayer); + if (!mBuffer) { + NS_WARNING("Failed to allocate the TextureClient"); + return; + } MOZ_ASSERT(mBuffer->CanExposeDrawTarget()); mBuffer->AllocateForSurface(aSize); bufferCreated = true; } if (!mBuffer->Lock(OpenMode::OPEN_WRITE_ONLY)) { mBuffer = nullptr; @@ -113,26 +117,30 @@ CanvasClient2D::CreateTextureClientForCa gfx::IntSize aSize, TextureFlags aFlags, ClientCanvasLayer* aLayer) { if (aLayer->IsGLLayer()) { // We want a cairo backend here as we don't want to be copying into // an accelerated backend and we like LockBits to work. This is currently // the most effective way to make this work. - return CreateBufferTextureClient(aFormat, aFlags, BackendType::CAIRO); + return TextureClient::CreateForRawBufferAccess(GetForwarder(), + aFormat, aSize, BackendType::CAIRO, + mTextureInfo.mTextureFlags | aFlags); } gfx::BackendType backend = gfxPlatform::GetPlatform()->GetPreferredCanvasBackend(); #ifdef XP_WIN - return CreateTextureClientForDrawing(aFormat, aFlags, backend, aSize); + return CreateTextureClientForDrawing(aFormat, aSize, backend, aFlags); #else // XXX - We should use CreateTextureClientForDrawing, but we first need // to use double buffering. - return CreateBufferTextureClient(aFormat, aFlags, backend); + return TextureClient::CreateForRawBufferAccess(GetForwarder(), + aFormat, aSize, BackendType::CAIRO, + mTextureInfo.mTextureFlags | aFlags); #endif } CanvasClientSurfaceStream::CanvasClientSurfaceStream(CompositableForwarder* aLayerForwarder, TextureFlags aFlags) : CanvasClient(aLayerForwarder, aFlags) { }
--- a/gfx/layers/client/CanvasClient.h +++ b/gfx/layers/client/CanvasClient.h @@ -96,20 +96,21 @@ public: } virtual void OnDetach() MOZ_OVERRIDE { mBuffer = nullptr; } private: - TemporaryRef<TextureClient> CreateTextureClientForCanvas(gfx::SurfaceFormat aFormat, - gfx::IntSize aSize, - TextureFlags aFlags, - ClientCanvasLayer* aLayer); + TemporaryRef<TextureClient> + CreateTextureClientForCanvas(gfx::SurfaceFormat aFormat, + gfx::IntSize aSize, + TextureFlags aFlags, + ClientCanvasLayer* aLayer); RefPtr<TextureClient> mBuffer; }; // Used for GL canvases where we don't need to do any readback, i.e., with a // GL backend. class CanvasClientSurfaceStream : public CanvasClient {
--- a/gfx/layers/client/CompositableClient.cpp +++ b/gfx/layers/client/CompositableClient.cpp @@ -186,25 +186,26 @@ CompositableClient::CreateBufferTextureC gfx::BackendType aMoz2DBackend) { return TextureClient::CreateBufferTextureClient(GetForwarder(), aFormat, aTextureFlags | mTextureFlags, aMoz2DBackend); } TemporaryRef<TextureClient> -CompositableClient::CreateTextureClientForDrawing(SurfaceFormat aFormat, +CompositableClient::CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat, + gfx::IntSize aSize, + gfx::BackendType aMoz2DBackend, TextureFlags aTextureFlags, - gfx::BackendType aMoz2DBackend, - const IntSize& aSizeHint) + TextureAllocationFlags aAllocFlags) { - return TextureClient::CreateTextureClientForDrawing(GetForwarder(), aFormat, - aTextureFlags | mTextureFlags, - aMoz2DBackend, - aSizeHint); + return TextureClient::CreateForDrawing(GetForwarder(), + aFormat, aSize, aMoz2DBackend, + aTextureFlags | mTextureFlags, + aAllocFlags); } bool CompositableClient::AddTextureClient(TextureClient* aClient) { if(!aClient || !aClient->IsAllocated()) { return false; }
--- a/gfx/layers/client/CompositableClient.h +++ b/gfx/layers/client/CompositableClient.h @@ -129,19 +129,20 @@ public: TemporaryRef<BufferTextureClient> CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags = TextureFlags::DEFAULT, gfx::BackendType aMoz2dBackend = gfx::BackendType::NONE); TemporaryRef<TextureClient> CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat, + gfx::IntSize aSize, + gfx::BackendType aMoz2DBackend, TextureFlags aTextureFlags, - gfx::BackendType aMoz2dBackend, - const gfx::IntSize& aSizeHint); + TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT); virtual void SetDescriptorFromReply(TextureIdentifier aTextureId, const SurfaceDescriptor& aDescriptor) { MOZ_CRASH("If you want to call this, you should have implemented it"); } /**
--- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -184,43 +184,38 @@ ContentClientRemoteBuffer::EndPaint() } ContentClientRemote::EndPaint(); } bool ContentClientRemoteBuffer::CreateAndAllocateTextureClient(RefPtr<TextureClient>& aClient, TextureFlags aFlags) { - // gfx::BackendType::NONE means fallback to the content backend - aClient = CreateTextureClientForDrawing(mSurfaceFormat, - mTextureInfo.mTextureFlags | aFlags, - gfx::BackendType::NONE, - mSize); - if (!aClient) { - return false; - } - - TextureAllocationFlags flags = TextureAllocationFlags::ALLOC_CLEAR_BUFFER; + TextureAllocationFlags allocFlags = TextureAllocationFlags::ALLOC_CLEAR_BUFFER; if (aFlags & TextureFlags::ON_WHITE) { - flags = TextureAllocationFlags::ALLOC_CLEAR_BUFFER_WHITE; + allocFlags = TextureAllocationFlags::ALLOC_CLEAR_BUFFER_WHITE; } - if (!aClient->AllocateForSurface(mSize, flags)) { - aClient = CreateTextureClientForDrawing(mSurfaceFormat, - mTextureInfo.mTextureFlags | TextureFlags::ALLOC_FALLBACK | aFlags, - gfx::BackendType::NONE, - mSize); - if (!aClient) { - return false; - } - if (!aClient->AllocateForSurface(mSize, flags)) { - NS_WARNING("Could not allocate texture client"); - aClient = nullptr; - return false; - } + // gfx::BackendType::NONE means fallback to the content backend + aClient = CreateTextureClientForDrawing(mSurfaceFormat, mSize, + gfx::BackendType::NONE, + mTextureInfo.mTextureFlags | aFlags, + allocFlags); + if (!aClient) { + // try with ALLOC_FALLBACK + aClient = CreateTextureClientForDrawing(mSurfaceFormat, mSize, + gfx::BackendType::NONE, + mTextureInfo.mTextureFlags + | TextureFlags::ALLOC_FALLBACK + | aFlags, + allocFlags); + } + + if (!aClient) { + return false; } NS_WARN_IF_FALSE(aClient->IsValid(), "Created an invalid texture client"); return true; } void ContentClientRemoteBuffer::BuildTextureClients(SurfaceFormat aFormat,
--- a/gfx/layers/client/ImageClient.cpp +++ b/gfx/layers/client/ImageClient.cpp @@ -271,24 +271,22 @@ ImageClientSingle::UpdateImageInternal(I autoRemoveTexture.mTexture = mFrontBuffer; mFrontBuffer = nullptr; } bool bufferCreated = false; if (!mFrontBuffer) { gfxImageFormat format = gfxPlatform::GetPlatform()->OptimalFormatForContent(gfx::ContentForFormat(surface->GetFormat())); - mFrontBuffer = CreateTextureClientForDrawing(gfx::ImageFormatToSurfaceFormat(format), - mTextureFlags, gfx::BackendType::NONE, size); - MOZ_ASSERT(mFrontBuffer->CanExposeDrawTarget()); - if (!mFrontBuffer->AllocateForSurface(size)) { - mFrontBuffer = nullptr; + mFrontBuffer = CreateTextureClientForDrawing(gfx::ImageFormatToSurfaceFormat(format), size, + gfx::BackendType::NONE, mTextureFlags); + if (!mFrontBuffer) { return false; } - + MOZ_ASSERT(mFrontBuffer->CanExposeDrawTarget()); bufferCreated = true; } if (!mFrontBuffer->Lock(OpenMode::OPEN_WRITE_ONLY)) { mFrontBuffer = nullptr; return false; }
--- a/gfx/layers/client/SimpleTextureClientPool.cpp +++ b/gfx/layers/client/SimpleTextureClientPool.cpp @@ -68,22 +68,22 @@ SimpleTextureClientPool::GetTextureClien mAvailableTextureClients.pop(); RECYCLE_LOG("%s Skip allocate (%i left), returning %p\n", (mFormat == SurfaceFormat::B8G8R8A8?"poolA":"poolX"), mAvailableTextureClients.size(), textureClient.get()); } else { // No unused clients in the pool, create one if (gfxPrefs::ForceShmemTiles()) { textureClient = TextureClient::CreateBufferTextureClient(mSurfaceAllocator, mFormat, TextureFlags::IMMEDIATE_UPLOAD | TextureFlags::RECYCLE, gfx::BackendType::NONE); + if (!textureClient->AllocateForSurface(mSize, ALLOC_DEFAULT)) { + NS_WARNING("TextureClient::AllocateForSurface failed!"); + } } else { - textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator, - mFormat, TextureFlags::DEFAULT | TextureFlags::RECYCLE, gfx::BackendType::NONE, mSize); - } - if (!textureClient->AllocateForSurface(mSize, ALLOC_DEFAULT)) { - NS_WARNING("TextureClient::AllocateForSurface failed!"); + textureClient = TextureClient::CreateForDrawing(mSurfaceAllocator, + mFormat, mSize, gfx::BackendType::NONE, TextureFlags::DEFAULT | TextureFlags::RECYCLE); } RECYCLE_LOG("%s Must allocate (0 left), returning %p\n", (mFormat == SurfaceFormat::B8G8R8A8?"poolA":"poolX"), textureClient.get()); } if (aAutoRecycle) { mOutstandingTextureClients.push_back(textureClient); textureClient->SetRecycleCallback(SimpleTextureClientPool::WaitForCompositorRecycleCallback, this); }
--- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -230,23 +230,23 @@ DisableGralloc(SurfaceFormat aFormat, co return true; } #endif return false; } #endif -// static +static TemporaryRef<TextureClient> -TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator, - SurfaceFormat aFormat, - TextureFlags aTextureFlags, - gfx::BackendType aMoz2DBackend, - const gfx::IntSize& aSizeHint) +CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator, + SurfaceFormat aFormat, + TextureFlags aTextureFlags, + gfx::BackendType aMoz2DBackend, + const gfx::IntSize& aSizeHint) { if (aMoz2DBackend == gfx::BackendType::NONE) { aMoz2DBackend = gfxPlatform::GetPlatform()->GetContentBackend(); } RefPtr<TextureClient> result; #if defined(MOZ_WIDGET_GONK) || defined(XP_WIN) @@ -310,24 +310,65 @@ TextureClient::CreateTextureClientForDra result = new GrallocTextureClientOGL(aAllocator, aFormat, aMoz2DBackend, aTextureFlags); } } #endif // Can't do any better than a buffer texture client. if (!result) { - result = CreateBufferTextureClient(aAllocator, aFormat, aTextureFlags, aMoz2DBackend); + result = TextureClient::CreateBufferTextureClient(aAllocator, aFormat, aTextureFlags, aMoz2DBackend); } MOZ_ASSERT(!result || result->CanExposeDrawTarget(), "texture cannot expose a DrawTarget?"); return result; } // static +TemporaryRef<TextureClient> +TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator, + gfx::SurfaceFormat aFormat, + gfx::IntSize aSize, + gfx::BackendType aMoz2DBackend, + TextureFlags aTextureFlags, + TextureAllocationFlags aAllocFlags) +{ + RefPtr<TextureClient> texture = + CreateTextureClientForDrawing(aAllocator, aFormat, + aTextureFlags, aMoz2DBackend, + aSize); + if (texture) { + if (!texture->AllocateForSurface(aSize, aAllocFlags)) { + return nullptr; + } + } + return texture; +} + +// static +TemporaryRef<BufferTextureClient> +TextureClient::CreateForRawBufferAccess(ISurfaceAllocator* aAllocator, + gfx::SurfaceFormat aFormat, + gfx::IntSize aSize, + gfx::BackendType aMoz2DBackend, + TextureFlags aTextureFlags, + TextureAllocationFlags aAllocFlags) +{ + RefPtr<BufferTextureClient> texture = + CreateBufferTextureClient(aAllocator, aFormat, + aTextureFlags, aMoz2DBackend); + if (texture) { + if (!texture->AllocateForSurface(aSize, aAllocFlags)) { + return nullptr; + } + } + return texture; +} + +// static TemporaryRef<BufferTextureClient> TextureClient::CreateBufferTextureClient(ISurfaceAllocator* aAllocator, SurfaceFormat aFormat, TextureFlags aTextureFlags, gfx::BackendType aMoz2DBackend) { if (aAllocator->IsSameProcess()) { RefPtr<BufferTextureClient> result = new MemoryTextureClient(aAllocator, aFormat,
--- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -115,28 +115,44 @@ public: */ class TextureClient : public AtomicRefCountedWithFinalize<TextureClient> { public: TextureClient(TextureFlags aFlags = TextureFlags::DEFAULT); virtual ~TextureClient(); + // Creates a TextureClient that can be accessed through a raw pointer. + // XXX - this doesn't allocate the texture data. + // Prefer CreateForRawBufferAccess which returns a BufferTextureClient + // only if allocation suceeded. static TemporaryRef<BufferTextureClient> CreateBufferTextureClient(ISurfaceAllocator* aAllocator, gfx::SurfaceFormat aFormat, TextureFlags aTextureFlags, gfx::BackendType aMoz2dBackend); + // Creates and allocates a TextureClient usable with Moz2D. static TemporaryRef<TextureClient> - CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator, - gfx::SurfaceFormat aFormat, - TextureFlags aTextureFlags, - gfx::BackendType aMoz2dBackend, - const gfx::IntSize& aSizeHint); + CreateForDrawing(ISurfaceAllocator* aAllocator, + gfx::SurfaceFormat aFormat, + gfx::IntSize aSize, + gfx::BackendType aMoz2dBackend, + TextureFlags aTextureFlags, + TextureAllocationFlags flags = ALLOC_DEFAULT); + + // Creates and allocates a BufferTextureClient (can beaccessed through raw + // pointers). + static TemporaryRef<BufferTextureClient> + CreateForRawBufferAccess(ISurfaceAllocator* aAllocator, + gfx::SurfaceFormat aFormat, + gfx::IntSize aSize, + gfx::BackendType aMoz2dBackend, + TextureFlags aTextureFlags, + TextureAllocationFlags flags = ALLOC_DEFAULT); virtual TextureClientYCbCr* AsTextureClientYCbCr() { return nullptr; } /** * Locks the shared data, allowing the caller to get access to it. * * Please always lock/unlock when accessing the shared data. * If Lock() returns false, you should not attempt to access the shared data.
--- a/gfx/layers/client/TextureClientPool.cpp +++ b/gfx/layers/client/TextureClientPool.cpp @@ -53,21 +53,21 @@ TextureClientPool::GetTextureClient() // client, we may need to free a deferred-return TextureClient. ShrinkToMaximumSize(); // No unused clients in the pool, create one if (gfxPrefs::ForceShmemTiles()) { // gfx::BackendType::NONE means use the content backend textureClient = TextureClient::CreateBufferTextureClient(mSurfaceAllocator, mFormat, TextureFlags::IMMEDIATE_UPLOAD, gfx::BackendType::NONE); + textureClient->AllocateForSurface(mSize, ALLOC_DEFAULT); } else { - textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator, - mFormat, TextureFlags::IMMEDIATE_UPLOAD, gfx::BackendType::NONE, mSize); + textureClient = TextureClient::CreateForDrawing(mSurfaceAllocator, + mFormat, mSize, gfx::BackendType::NONE, TextureFlags::IMMEDIATE_UPLOAD); } - textureClient->AllocateForSurface(mSize, ALLOC_DEFAULT); return textureClient; } void TextureClientPool::ReturnTextureClient(TextureClient *aClient) { if (!aClient) {