From 8a6532e5346d2c2da519657f9711e7a92d427e84 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Mon, 18 Mar 2013 18:58:58 +0000 Subject: [PATCH] Backed out changeset 7268c16cad16 (bug 829747) for causing B2G test timeouts; CLOSED TREE --- gfx/gl/GLContext.cpp | 4 +- gfx/gl/GLScreenBuffer.cpp | 52 ++++++++-------------- gfx/gl/GLScreenBuffer.h | 4 -- gfx/gl/SurfaceStream.cpp | 60 ++++---------------------- gfx/gl/SurfaceStream.h | 22 ++-------- gfx/gl/SurfaceTypes.h | 1 - gfx/layers/basic/BasicCanvasLayer.cpp | 8 ++-- gfx/layers/basic/BasicLayerManager.cpp | 3 +- gfx/layers/ipc/ShadowLayers.cpp | 10 ----- gfx/layers/ipc/ShadowLayers.h | 3 -- gfx/layers/ipc/ShadowLayersParent.cpp | 9 ++-- gfx/layers/opengl/CanvasLayerOGL.cpp | 1 + 12 files changed, 40 insertions(+), 137 deletions(-) diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp index e6913d0d6b68..f5cfe73e616b 100644 --- a/gfx/gl/GLContext.cpp +++ b/gfx/gl/GLContext.cpp @@ -2879,7 +2879,7 @@ GLContext::CreateScreenBufferImpl(const gfxIntSize& size, const SurfaceCaps& cap if (!newScreen) return false; - if (!newScreen->Resize(size)) { + if (!newScreen->PublishFrame(size)) { delete newScreen; return false; } @@ -2901,7 +2901,7 @@ GLContext::ResizeScreenBuffer(const gfxIntSize& size) if (!IsOffscreenSizeAllowed(size)) return false; - return mScreen->Resize(size); + return mScreen->PublishFrame(size); } diff --git a/gfx/gl/GLScreenBuffer.cpp b/gfx/gl/GLScreenBuffer.cpp index aa6247e6d32c..5f8560095d5b 100644 --- a/gfx/gl/GLScreenBuffer.cpp +++ b/gfx/gl/GLScreenBuffer.cpp @@ -325,12 +325,27 @@ GLScreenBuffer::Morph(SurfaceFactory_GL* newFactory, SurfaceStreamType streamTyp mStream = newStream; } -void -GLScreenBuffer::Attach(SharedSurface* surface, const gfxIntSize& size) +bool +GLScreenBuffer::Swap(const gfxIntSize& size) { ScopedBindFramebuffer autoFB(mGL); - SharedSurface_GL* surf = SharedSurface_GL::Cast(surface); + SharedSurface* nextSurf = mStream->SwapProducer(mFactory, size); + if (!nextSurf) { + SurfaceFactory_GL* basicFactory = + new SurfaceFactory_Basic(mGL, mFactory->Caps()); + nextSurf = mStream->SwapProducer(basicFactory, size); + if (!nextSurf) { + delete basicFactory; + return false; + } + + // Swap out the apparently defective old factory. + delete mFactory; + mFactory = basicFactory; + } + + SharedSurface_GL* surf = SharedSurface_GL::Cast(nextSurf); if (mRead && SharedSurf()) SharedSurf()->UnlockProd(); @@ -361,27 +376,6 @@ GLScreenBuffer::Attach(SharedSurface* surface, const gfxIntSize& size) if (!PreserveBuffer()) { // DiscardFramebuffer here could help perf on some mobile platforms. } -} - -bool -GLScreenBuffer::Swap(const gfxIntSize& size) -{ - SharedSurface* nextSurf = mStream->SwapProducer(mFactory, size); - if (!nextSurf) { - SurfaceFactory_GL* basicFactory = - new SurfaceFactory_Basic(mGL, mFactory->Caps()); - nextSurf = mStream->SwapProducer(basicFactory, size); - if (!nextSurf) { - delete basicFactory; - return false; - } - - // Swap out the apparently defective old factory. - delete mFactory; - mFactory = basicFactory; - } - - Attach(nextSurf, size); return true; } @@ -395,16 +389,6 @@ GLScreenBuffer::PublishFrame(const gfxIntSize& size) return good; } -bool -GLScreenBuffer::Resize(const gfxIntSize& size) -{ - SharedSurface* surface = mStream->Resize(mFactory, size); - if (!surface) - return false; - - Attach(surface, size); - return true; -} DrawBuffer* GLScreenBuffer::CreateDraw(const gfxIntSize& size) diff --git a/gfx/gl/GLScreenBuffer.h b/gfx/gl/GLScreenBuffer.h index 0fd6f27b1c71..8f2268a4bae2 100644 --- a/gfx/gl/GLScreenBuffer.h +++ b/gfx/gl/GLScreenBuffer.h @@ -265,13 +265,9 @@ protected: public: bool PublishFrame(const gfxIntSize& size); - bool Resize(const gfxIntSize& size); - void Readback(SharedSurface_GL* src, gfxImageSurface* dest); protected: - void Attach(SharedSurface* surface, const gfxIntSize& size); - DrawBuffer* CreateDraw(const gfxIntSize& size); ReadBuffer* CreateRead(SharedSurface_GL* surf); diff --git a/gfx/gl/SurfaceStream.cpp b/gfx/gl/SurfaceStream.cpp index 423d948ae1a6..0442093c5e51 100644 --- a/gfx/gl/SurfaceStream.cpp +++ b/gfx/gl/SurfaceStream.cpp @@ -8,7 +8,6 @@ #include "gfxPoint.h" #include "SharedSurface.h" #include "SurfaceFactory.h" -#include "sampler.h" namespace mozilla { namespace gfx { @@ -21,7 +20,7 @@ SurfaceStream::ChooseGLStreamType(SurfaceStream::OMTC omtc, if (preserveBuffer) return SurfaceStreamType::TripleBuffer_Copy; else - return SurfaceStreamType::TripleBuffer_Async; + return SurfaceStreamType::TripleBuffer; } else { if (preserveBuffer) return SurfaceStreamType::SingleBuffer; @@ -38,8 +37,6 @@ SurfaceStream::CreateForType(SurfaceStreamType type, SurfaceStream* prevStream) return new SurfaceStream_SingleBuffer(prevStream); case SurfaceStreamType::TripleBuffer_Copy: return new SurfaceStream_TripleBuffer_Copy(prevStream); - case SurfaceStreamType::TripleBuffer_Async: - return new SurfaceStream_TripleBuffer_Async(prevStream); case SurfaceStreamType::TripleBuffer: return new SurfaceStream_TripleBuffer(prevStream); default: @@ -161,18 +158,7 @@ SurfaceStream::SwapConsumer() return ret; } -SharedSurface* -SurfaceStream::Resize(SurfaceFactory* factory, const gfxIntSize& size) -{ - MonitorAutoLock lock(mMonitor); - if (mProducer) { - Scrap(mProducer); - } - - New(factory, size, mProducer); - return mProducer; -} SurfaceStream_SingleBuffer::SurfaceStream_SingleBuffer(SurfaceStream* prevStream) : SurfaceStream(SurfaceStreamType::SingleBuffer, prevStream) @@ -214,7 +200,7 @@ SharedSurface* SurfaceStream_SingleBuffer::SwapProducer(SurfaceFactory* factory, const gfxIntSize& size) { - MonitorAutoLock lock(mMonitor); + MutexAutoLock lock(mMutex); if (mConsumer) { Recycle(factory, mConsumer); } @@ -252,7 +238,7 @@ SurfaceStream_SingleBuffer::SwapProducer(SurfaceFactory* factory, SharedSurface* SurfaceStream_SingleBuffer::SwapConsumer_NoWait() { - MonitorAutoLock lock(mMonitor); + MutexAutoLock lock(mMutex); // Use Cons, if present. // Otherwise, just use Prod directly. @@ -307,7 +293,7 @@ SharedSurface* SurfaceStream_TripleBuffer_Copy::SwapProducer(SurfaceFactory* factory, const gfxIntSize& size) { - MonitorAutoLock lock(mMonitor); + MutexAutoLock lock(mMutex); RecycleScraps(factory); if (mProducer) { @@ -337,11 +323,10 @@ SurfaceStream_TripleBuffer_Copy::SwapProducer(SurfaceFactory* factory, return mProducer; } - SharedSurface* SurfaceStream_TripleBuffer_Copy::SwapConsumer_NoWait() { - MonitorAutoLock lock(mMonitor); + MutexAutoLock lock(mMutex); if (mStaging) { Scrap(mConsumer); @@ -395,18 +380,13 @@ SharedSurface* SurfaceStream_TripleBuffer::SwapProducer(SurfaceFactory* factory, const gfxIntSize& size) { - SAMPLE_LABEL("SurfaceStream_TripleBuffer", "SwapProducer"); - - MonitorAutoLock lock(mMonitor); + MutexAutoLock lock(mMutex); if (mProducer) { RecycleScraps(factory); - // If WaitForCompositor succeeds, mStaging has moved to mConsumer. - // If it failed, we might have to scrap it. - if (mStaging && !WaitForCompositor()) - Scrap(mStaging); + if (mStaging) + Recycle(factory, mStaging); - MOZ_ASSERT(!mStaging); Move(mProducer, mStaging); mStaging->Fence(); } @@ -420,36 +400,14 @@ SurfaceStream_TripleBuffer::SwapProducer(SurfaceFactory* factory, SharedSurface* SurfaceStream_TripleBuffer::SwapConsumer_NoWait() { - MonitorAutoLock lock(mMonitor); + MutexAutoLock lock(mMutex); if (mStaging) { Scrap(mConsumer); Move(mStaging, mConsumer); - mMonitor.NotifyAll(); } return mConsumer; } -SurfaceStream_TripleBuffer_Async::SurfaceStream_TripleBuffer_Async(SurfaceStream* prevStream) - : SurfaceStream_TripleBuffer(prevStream) -{ -} - -SurfaceStream_TripleBuffer_Async::~SurfaceStream_TripleBuffer_Async() -{ -} - -bool -SurfaceStream_TripleBuffer_Async::WaitForCompositor() -{ - SAMPLE_LABEL("SurfaceStream_TripleBuffer_Async", "WaitForCompositor"); - - // We are assumed to be locked - while (mStaging) - mMonitor.Wait(); - - return true; -} - } /* namespace gfx */ } /* namespace mozilla */ diff --git a/gfx/gl/SurfaceStream.h b/gfx/gl/SurfaceStream.h index ae8666a6b341..ca878f067697 100644 --- a/gfx/gl/SurfaceStream.h +++ b/gfx/gl/SurfaceStream.h @@ -8,7 +8,7 @@ #include #include -#include "mozilla/Monitor.h" +#include "mozilla/Mutex.h" #include "mozilla/Attributes.h" #include "gfxPoint.h" #include "SurfaceTypes.h" @@ -48,7 +48,7 @@ protected: SharedSurface* mProducer; std::set mSurfaces; std::stack mScraps; - mutable Monitor mMonitor; + mutable Mutex mMutex; bool mIsAlive; // |previous| can be null, indicating this is the first one. @@ -56,7 +56,7 @@ protected: SurfaceStream(SurfaceStreamType type, SurfaceStream* prevStream) : mType(type) , mProducer(nullptr) - , mMonitor("SurfaceStream monitor") + , mMutex("SurfaceStream mutex") , mIsAlive(true) { MOZ_ASSERT(!prevStream || mType != prevStream->mType, @@ -107,8 +107,6 @@ public: virtual SharedSurface* SwapProducer(SurfaceFactory* factory, const gfxIntSize& size) = 0; - virtual SharedSurface* Resize(SurfaceFactory* factory, const gfxIntSize& size); - protected: // SwapCons will return the same surface more than once, // if nothing new has been published. @@ -171,9 +169,6 @@ protected: SharedSurface* mStaging; SharedSurface* mConsumer; - // Returns true if we were able to wait, false if not - virtual bool WaitForCompositor() { return false; } - public: SurfaceStream_TripleBuffer(SurfaceStream* prevStream); virtual ~SurfaceStream_TripleBuffer(); @@ -187,17 +182,6 @@ public: virtual void SurrenderSurfaces(SharedSurface*& producer, SharedSurface*& consumer); }; -class SurfaceStream_TripleBuffer_Async - : public SurfaceStream_TripleBuffer -{ -protected: - virtual bool WaitForCompositor(); - -public: - SurfaceStream_TripleBuffer_Async(SurfaceStream* prevStream); - virtual ~SurfaceStream_TripleBuffer_Async(); -}; - } /* namespace gfx */ } /* namespace mozilla */ diff --git a/gfx/gl/SurfaceTypes.h b/gfx/gl/SurfaceTypes.h index d4f588c8fb61..b8c9d3c45a29 100644 --- a/gfx/gl/SurfaceTypes.h +++ b/gfx/gl/SurfaceTypes.h @@ -78,7 +78,6 @@ MOZ_END_ENUM_CLASS(SharedSurfaceType) MOZ_BEGIN_ENUM_CLASS(SurfaceStreamType, uint8_t) SingleBuffer, TripleBuffer_Copy, - TripleBuffer_Async, TripleBuffer, Max MOZ_END_ENUM_CLASS(SurfaceStreamType) diff --git a/gfx/layers/basic/BasicCanvasLayer.cpp b/gfx/layers/basic/BasicCanvasLayer.cpp index 834441b9312e..d3f2911c7a1f 100644 --- a/gfx/layers/basic/BasicCanvasLayer.cpp +++ b/gfx/layers/basic/BasicCanvasLayer.cpp @@ -12,7 +12,6 @@ #include "SurfaceStream.h" #include "SharedSurfaceGL.h" #include "SharedSurfaceEGL.h" -#include "sampler.h" #include "BasicLayersImpl.h" #include "nsXULAppAPI.h" @@ -412,7 +411,6 @@ BasicShadowableCanvasLayer::Initialize(const Data& aData) void BasicShadowableCanvasLayer::Paint(gfxContext* aContext, Layer* aMaskLayer) { - SAMPLE_LABEL("BasicShadowableCanvasLayer", "Paint"); if (!HasShadow()) { BasicCanvasLayer::Paint(aContext, aMaskLayer); return; @@ -438,9 +436,9 @@ BasicShadowableCanvasLayer::Paint(gfxContext* aContext, Layer* aMaskLayer) // Call Painted() to reset our dirty 'bit'. Painted(); FireDidTransactionCallback(); - BasicManager()->PaintedCanvasNoSwap(BasicManager()->Hold(this), - mNeedsYFlip, - mBackBuffer); + BasicManager()->PaintedCanvas(BasicManager()->Hold(this), + mNeedsYFlip, + mBackBuffer); // Move SharedTextureHandle ownership to ShadowLayer mBackBuffer = SurfaceDescriptor(); return; diff --git a/gfx/layers/basic/BasicLayerManager.cpp b/gfx/layers/basic/BasicLayerManager.cpp index 411886812d77..a984708371c2 100644 --- a/gfx/layers/basic/BasicLayerManager.cpp +++ b/gfx/layers/basic/BasicLayerManager.cpp @@ -523,7 +523,7 @@ BasicLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags) { - SAMPLE_LABEL("BasicLayerManager", "EndTransactionInternal"); + SAMPLE_LABEL("BasicLayerManager", "EndTranscationInternal"); #ifdef MOZ_LAYERS_HAVE_LOG MOZ_LAYERS_LOG((" ----- (beginning paint)")); Log(); @@ -871,7 +871,6 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget, void* aCallbackData, ReadbackProcessor* aReadback) { - SAMPLE_LABEL("BasicLayerManager", "PaintLayer"); PaintContext paintContext(aTarget, aLayer, aCallback, aCallbackData, aReadback); // Don't attempt to paint layers with a singular transform, cairo will diff --git a/gfx/layers/ipc/ShadowLayers.cpp b/gfx/layers/ipc/ShadowLayers.cpp index 458e36061528..4d365e3d5734 100644 --- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -297,16 +297,6 @@ ShadowLayerForwarder::PaintedCanvas(ShadowableLayer* aCanvas, aNeedYFlip)); } -void -ShadowLayerForwarder::PaintedCanvasNoSwap(ShadowableLayer* aCanvas, - bool aNeedYFlip, - const SurfaceDescriptor& aNewFrontSurface) -{ - mTxn->AddNoSwapPaint(OpPaintCanvas(NULL, Shadow(aCanvas), - aNewFrontSurface, - aNeedYFlip)); -} - bool ShadowLayerForwarder::EndTransaction(InfallibleTArray* aReplies) { diff --git a/gfx/layers/ipc/ShadowLayers.h b/gfx/layers/ipc/ShadowLayers.h index efefd14a031a..5d59accaa8c7 100644 --- a/gfx/layers/ipc/ShadowLayers.h +++ b/gfx/layers/ipc/ShadowLayers.h @@ -219,9 +219,6 @@ public: void PaintedCanvas(ShadowableLayer* aCanvas, bool aNeedYFlip, const SurfaceDescriptor& aNewFrontSurface); - void PaintedCanvasNoSwap(ShadowableLayer* aCanvas, - bool aNeedYFlip, - const SurfaceDescriptor& aNewFrontSurface); /** * End the current transaction and forward it to ShadowLayerManager. diff --git a/gfx/layers/ipc/ShadowLayersParent.cpp b/gfx/layers/ipc/ShadowLayersParent.cpp index b36f47e76bba..7b5847be608e 100644 --- a/gfx/layers/ipc/ShadowLayersParent.cpp +++ b/gfx/layers/ipc/ShadowLayersParent.cpp @@ -422,14 +422,11 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray& cset, RenderTraceInvalidateStart(canvas, "FF00FF", canvas->GetVisibleRegion().GetBounds()); canvas->SetAllocator(this); - CanvasSurface newBack = CanvasSurface(null_t()); + CanvasSurface newBack; canvas->Swap(op.newFrontBuffer(), op.needYFlip(), &newBack); canvas->Updated(); - - if (newBack.type() != CanvasSurface::Tnull_t) { - replyv.push_back(OpBufferSwap(shadow, NULL, - newBack)); - } + replyv.push_back(OpBufferSwap(shadow, NULL, + newBack)); RenderTraceInvalidateEnd(canvas, "FF00FF"); break; diff --git a/gfx/layers/opengl/CanvasLayerOGL.cpp b/gfx/layers/opengl/CanvasLayerOGL.cpp index d607de57d1e6..0f783c8346ae 100644 --- a/gfx/layers/opengl/CanvasLayerOGL.cpp +++ b/gfx/layers/opengl/CanvasLayerOGL.cpp @@ -444,6 +444,7 @@ ShadowCanvasLayerOGL::Swap(const CanvasSurface& aNewFront, SurfaceStreamHandle handle = (SurfaceStreamHandle)nullptr; mFrontBufferDescriptor = SurfaceStreamDescriptor(handle, false); } + *aNewBack = mFrontBufferDescriptor; mFrontBufferDescriptor = aNewFront; mNeedsYFlip = needYFlip; } else {