Bug 732091 - Part 3: Pass on the isFirstPaint flag from the PresShell to the compositor via the layer manager. r=tnikkel,bgirard

This commit is contained in:
Ali Juma 2012-03-12 11:50:15 -04:00
parent cc0282e9e5
commit 06826ece22
12 changed files with 43 additions and 7 deletions

View File

@ -486,6 +486,11 @@ public:
LayerUserData* GetUserData(void* aKey)
{ return mUserData.Get(aKey); }
/**
* Flag the next paint as the first for a document.
*/
virtual void SetIsFirstPaint() {}
// We always declare the following logging symbols, because it's
// extremely tricky to conditionally declare them. However, for
// ifndef MOZ_LAYERS_HAVE_LOG builds, they only have trivial

View File

@ -3504,5 +3504,11 @@ BasicShadowLayerManager::IsCompositingCheap()
LayerManager::IsCompositingCheap(GetParentBackendType());
}
void
BasicShadowLayerManager::SetIsFirstPaint()
{
ShadowLayerForwarder::SetIsFirstPaint();
}
}
}

View File

@ -267,6 +267,8 @@ public:
virtual bool IsCompositingCheap();
virtual bool HasShadowManagerInternal() const { return HasShadowManager(); }
virtual void SetIsFirstPaint() MOZ_OVERRIDE;
private:
/**
* Forward transaction results to the parent context.

View File

@ -58,6 +58,7 @@ CompositorParent::CompositorParent(nsIWidget* aWidget)
: mWidget(aWidget)
, mCurrentCompositeTask(NULL)
, mPaused(false)
, mIsFirstPaint(false)
{
MOZ_COUNT_CTOR(CompositorParent);
}
@ -315,8 +316,9 @@ CompositorParent::RequestViewTransform()
#endif
void
CompositorParent::ShadowLayersUpdated()
CompositorParent::ShadowLayersUpdated(bool isFirstPaint)
{
mIsFirstPaint = mIsFirstPaint || isFirstPaint;
const nsTArray<PLayersParent*>& shadowParents = ManagedPLayersParent();
NS_ABORT_IF_FALSE(shadowParents.Length() <= 1,
"can only support at most 1 ShadowLayersParent");

View File

@ -91,7 +91,7 @@ public:
virtual bool RecvStop() MOZ_OVERRIDE;
virtual void ShadowLayersUpdated() MOZ_OVERRIDE;
virtual void ShadowLayersUpdated(bool isFirstPaint) MOZ_OVERRIDE;
void Destroy();
LayerManager* GetLayerManager() { return mLayerManager; }
@ -144,6 +144,13 @@ private:
float mYScale;
nsIntPoint mScrollOffset;
// When this flag is set, the next composition will be the first for a
// particular document (i.e. the document displayed on the screen will change).
// This happens when loading a new page or switching tabs. We notify the
// front-end (e.g. Java on Android) about this so that it take the new page
// size and zoom into account when providing us with the next view transform.
bool mIsFirstPaint;
DISALLOW_EVIL_CONSTRUCTORS(CompositorParent);
};

View File

@ -128,6 +128,7 @@ struct AutoTxnEnd {
ShadowLayerForwarder::ShadowLayerForwarder()
: mShadowManager(NULL)
, mParentBackend(LayerManager::LAYERS_NONE)
, mIsFirstPaint(false)
{
mTxn = new Transaction();
}
@ -325,11 +326,12 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
MOZ_LAYERS_LOG(("[LayersForwarder] sending transaction..."));
RenderTraceScope rendertrace3("Foward Transaction", "000093");
if (!mShadowManager->SendUpdate(cset, false, aReplies)) {
if (!mShadowManager->SendUpdate(cset, mIsFirstPaint, aReplies)) {
MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
return false;
}
mIsFirstPaint = false;
MOZ_LAYERS_LOG(("[LayersForwarder] ... done"));
return true;
}

View File

@ -308,6 +308,11 @@ public:
*/
bool ShouldDoubleBuffer() { return GetParentBackendType() == LayerManager::LAYERS_BASIC; }
/**
* Flag the next paint as the first for a document.
*/
void SetIsFirstPaint() { mIsFirstPaint = true; }
protected:
ShadowLayerForwarder();
@ -332,6 +337,8 @@ private:
Transaction* mTxn;
LayersBackend mParentBackend;
bool mIsFirstPaint;
};

View File

@ -54,7 +54,7 @@ class ShadowLayersManager
{
public:
virtual void ShadowLayersUpdated() = 0;
virtual void ShadowLayersUpdated(bool isFirstPaint) = 0;
};
} // layers

View File

@ -399,7 +399,7 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
// other's buffer contents.
ShadowLayerManager::PlatformSyncBeforeReplyUpdate();
mShadowLayersManager->ShadowLayersUpdated();
mShadowLayersManager->ShadowLayersUpdated(isFirstPaint);
#ifdef COMPOSITOR_PERFORMANCE_WARNING
printf_stderr("Compositor: Layers update took %i ms (blocking gecko).\n",

View File

@ -5370,6 +5370,11 @@ PresShell::Paint(nsIView* aViewToPaint,
LayerManager* layerManager =
aWidgetToPaint->GetLayerManager(&isRetainingManager);
NS_ASSERTION(layerManager, "Must be in paint event");
if (mIsFirstPaint) {
layerManager->SetIsFirstPaint();
mIsFirstPaint = false;
}
layerManager->BeginTransaction();
if (frame && isRetainingManager) {

View File

@ -516,7 +516,7 @@ RenderFrameParent::ContentViewScaleChanged(nsContentView* aView)
}
void
RenderFrameParent::ShadowLayersUpdated()
RenderFrameParent::ShadowLayersUpdated(bool isFirstPaint)
{
mFrameLoader->SetCurrentRemoteFrame(this);

View File

@ -86,7 +86,7 @@ public:
void ContentViewScaleChanged(nsContentView* aView);
virtual void ShadowLayersUpdated() MOZ_OVERRIDE;
virtual void ShadowLayersUpdated(bool isFirstPaint) MOZ_OVERRIDE;
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsSubDocumentFrame* aFrame,