Bug 539356 - Part 2 - Add new API to BasicLayers. r=roc

This commit is contained in:
Matt Woodrow 2012-06-30 15:06:09 +12:00
parent eb7d17c374
commit 8487f7b12f
4 changed files with 12 additions and 20 deletions

View File

@ -229,6 +229,12 @@ public:
virtual ShadowLayerManager* AsShadowManager()
{ return nsnull; }
/**
* Returns true if this LayerManager is owned by an nsIWidget,
* and is used for drawing into the widget.
*/
virtual bool IsWidgetLayerManager() { return true; }
/**
* Start a new transaction. Nested transactions are not allowed so
* there must be no transaction currently in progress.

View File

@ -93,9 +93,7 @@ ToInsideIntRect(const gfxRect& aRect)
}
BasicLayerManager::BasicLayerManager(nsIWidget* aWidget) :
#ifdef DEBUG
mPhase(PHASE_NONE),
#endif
mWidget(aWidget)
, mDoubleBuffering(BUFFER_NONE), mUsingDefaultTarget(false)
, mCachedSurfaceInUse(false)
@ -106,9 +104,7 @@ BasicLayerManager::BasicLayerManager(nsIWidget* aWidget) :
}
BasicLayerManager::BasicLayerManager() :
#ifdef DEBUG
mPhase(PHASE_NONE),
#endif
mWidget(nsnull)
, mDoubleBuffering(BUFFER_NONE), mUsingDefaultTarget(false)
, mCachedSurfaceInUse(false)
@ -199,9 +195,7 @@ BasicLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
#endif
NS_ASSERTION(!InTransaction(), "Nested transactions not allowed");
#ifdef DEBUG
mPhase = PHASE_CONSTRUCTION;
#endif
mTarget = aTarget;
}
@ -394,9 +388,7 @@ BasicLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback,
#endif
NS_ASSERTION(InConstruction(), "Should be in construction phase");
#ifdef DEBUG
mPhase = PHASE_DRAWING;
#endif
Layer* aLayer = GetRoot();
RenderTraceLayers(aLayer, "FF00");
@ -445,11 +437,9 @@ BasicLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback,
MOZ_LAYERS_LOG(("]----- EndTransaction"));
#endif
#ifdef DEBUG
// Go back to the construction phase if the transaction isn't complete.
// Layout will update the layer tree and call EndTransaction().
mPhase = mTransactionIncomplete ? PHASE_CONSTRUCTION : PHASE_NONE;
#endif
if (!mTransactionIncomplete) {
// This is still valid if the transaction was incomplete.
@ -995,9 +985,7 @@ void
BasicShadowLayerManager::ForwardTransaction()
{
RenderTraceScope rendertrace("Foward Transaction", "000090");
#ifdef DEBUG
mPhase = PHASE_FORWARD;
#endif
// forward this transaction's changeset to our ShadowLayerManager
AutoInfallibleTArray<EditReply, 10> replies;
@ -1062,9 +1050,7 @@ BasicShadowLayerManager::ForwardTransaction()
NS_WARNING("failed to forward Layers transaction");
}
#ifdef DEBUG
mPhase = PHASE_NONE;
#endif
// this may result in Layers being deleted, which results in
// PLayer::Send__delete__() and DeallocShmem()

View File

@ -86,6 +86,8 @@ public:
nsIWidget* GetRetainerWidget() { return mWidget; }
void ClearRetainerWidget() { mWidget = nsnull; }
virtual bool IsWidgetLayerManager() { return mWidget != nsnull; }
virtual void BeginTransaction();
virtual void BeginTransactionWithTarget(gfxContext* aTarget);
virtual bool EndEmptyTransaction();
@ -121,9 +123,11 @@ public:
bool InConstruction() { return mPhase == PHASE_CONSTRUCTION; }
bool InDrawing() { return mPhase == PHASE_DRAWING; }
bool InForward() { return mPhase == PHASE_FORWARD; }
bool InTransaction() { return mPhase != PHASE_NONE; }
#endif
bool InTransaction() { return mPhase != PHASE_NONE; }
gfxContext* GetTarget() { return mTarget; }
void SetTarget(gfxContext* aTarget) { mUsingDefaultTarget = false; mTarget = aTarget; }
bool IsRetained() { return mWidget != nsnull; }
#ifdef MOZ_LAYERS_HAVE_LOG
@ -149,12 +153,10 @@ public:
virtual PRInt32 GetMaxTextureSize() const { return PR_INT32_MAX; }
protected:
#ifdef DEBUG
enum TransactionPhase {
PHASE_NONE, PHASE_CONSTRUCTION, PHASE_DRAWING, PHASE_FORWARD
};
TransactionPhase mPhase;
#endif
// Paints aLayer to mTarget.
void PaintLayer(gfxContext* aTarget,

View File

@ -27,9 +27,7 @@ BasicThebesLayer::CreateBuffer(Buffer::ContentType aType, const nsIntSize& aSize
referenceSurface = defaultTarget->CurrentSurface();
} else {
nsIWidget* widget = BasicManager()->GetRetainerWidget();
if (widget) {
referenceSurface = widget->GetThebesSurface();
} else {
if (!widget || !(referenceSurface = widget->GetThebesSurface())) {
referenceSurface = BasicManager()->GetTarget()->CurrentSurface();
}
}