Bug 539356 - Add HasRetainedDataFor. r=roc

This commit is contained in:
Matt Woodrow 2012-08-29 17:48:45 +12:00
parent f061f5d0a9
commit 8c72ac3baa
3 changed files with 82 additions and 16 deletions

View File

@ -1018,21 +1018,19 @@ GetDefaultLayerManagerDataForFrame(nsIFrame* aFrame)
return static_cast<LayerManagerData*>(props.Get(FrameLayerBuilder::LayerManagerDataProperty()));
}
/* static */ FrameLayerBuilder::DisplayItemData*
FrameLayerBuilder::GetDisplayItemDataForManager(nsIFrame* aFrame, uint32_t aDisplayItemKey, LayerManager* aManager)
static LayerManagerData*
GetSecondaryLayerManagerDataForFrame(nsIFrame* aFrame)
{
LayerManagerData *data;
if (!aManager) {
data = GetDefaultLayerManagerDataForFrame(aFrame);
} else {
data = static_cast<LayerManagerData*>(aManager->GetUserData(&gLayerManagerUserData));
}
if (!data) {
return nullptr;
}
FrameProperties props = aFrame->Properties();
return static_cast<LayerManagerData*>(props.Get(FrameLayerBuilder::LayerManagerSecondaryDataProperty()));
}
DisplayItemDataEntry *entry = data->mFramesWithLayers.GetEntry(aFrame);
/* static */ FrameLayerBuilder::DisplayItemData*
FrameLayerBuilder::GetDisplayItemDataForManager(nsIFrame* aFrame,
uint32_t aDisplayItemKey,
LayerManagerData* aData)
{
DisplayItemDataEntry *entry = aData->mFramesWithLayers.GetEntry(aFrame);
if (!entry) {
return nullptr;
}
@ -1047,7 +1045,23 @@ FrameLayerBuilder::GetDisplayItemDataForManager(nsIFrame* aFrame, uint32_t aDisp
}
/* static */ FrameLayerBuilder::DisplayItemData*
FrameLayerBuilder::GetDisplayItemDataForManager(nsDisplayItem* aItem, LayerManager* aManager)
FrameLayerBuilder::GetDisplayItemDataForManager(nsIFrame* aFrame,
uint32_t aDisplayItemKey,
LayerManager* aManager)
{
LayerManagerData *data =
static_cast<LayerManagerData*>(aManager->GetUserData(&gLayerManagerUserData));
if (!data) {
return nullptr;
}
return GetDisplayItemDataForManager(aFrame, aDisplayItemKey, data);
}
/* static */ FrameLayerBuilder::DisplayItemData*
FrameLayerBuilder::GetDisplayItemDataForManager(nsDisplayItem* aItem,
LayerManager* aManager)
{
DisplayItemData* data =
GetDisplayItemDataForManager(aItem->GetUnderlyingFrame(),
@ -1071,6 +1085,19 @@ FrameLayerBuilder::GetDisplayItemDataForManager(nsDisplayItem* aItem, LayerManag
return nullptr;
}
/* static */ FrameLayerBuilder::DisplayItemData*
FrameLayerBuilder::GetDisplayItemDataForManager(nsIFrame* aFrame,
uint32_t aDisplayItemKey)
{
LayerManagerData *data = GetDefaultLayerManagerDataForFrame(aFrame);
if (!data) {
return nullptr;
}
return GetDisplayItemDataForManager(aFrame, aDisplayItemKey, data);
}
bool
FrameLayerBuilder::HasRetainedLayerFor(nsIFrame* aFrame, uint32_t aDisplayItemKey, LayerManager* aManager)
{
@ -1085,6 +1112,20 @@ FrameLayerBuilder::HasRetainedLayerFor(nsIFrame* aFrame, uint32_t aDisplayItemKe
return false;
}
bool
FrameLayerBuilder::HasRetainedDataFor(nsIFrame* aFrame, uint32_t aDisplayItemKey)
{
LayerManagerData* data = GetDefaultLayerManagerDataForFrame(aFrame);
if (data && GetDisplayItemDataForManager(aFrame, aDisplayItemKey, data)) {
return true;
}
data = GetSecondaryLayerManagerDataForFrame(aFrame);
if (data && GetDisplayItemDataForManager(aFrame, aDisplayItemKey, data)) {
return true;
}
return false;
}
FrameLayerBuilder::DisplayItemData*
FrameLayerBuilder::GetOldLayerForFrame(nsIFrame* aFrame, uint32_t aDisplayItemKey)
{
@ -2915,6 +2956,19 @@ FrameLayerBuilder::InvalidateAllLayers(LayerManager* aManager)
}
}
/* static */ void
FrameLayerBuilder::InvalidateAllLayersForFrame(nsIFrame *aFrame)
{
LayerManagerData* data = GetDefaultLayerManagerDataForFrame(aFrame);
if (data) {
data->mInvalidateAllLayers = true;
}
data = GetSecondaryLayerManagerDataForFrame(aFrame);
if (data) {
data->mInvalidateAllLayers = true;
}
}
/* static */
Layer*
FrameLayerBuilder::GetDedicatedLayer(nsIFrame* aFrame, uint32_t aDisplayItemKey)
@ -2923,7 +2977,7 @@ FrameLayerBuilder::GetDedicatedLayer(nsIFrame* aFrame, uint32_t aDisplayItemKey)
// in the normal widget manager, and as a different layer (or no layer)
// in the secondary manager
DisplayItemData *data = GetDisplayItemDataForManager(aFrame, aDisplayItemKey, nullptr);
DisplayItemData *data = GetDisplayItemDataForManager(aFrame, aDisplayItemKey);
if (!data) {
return nullptr;
}

View File

@ -224,6 +224,7 @@ public:
* the next paint.
*/
static void InvalidateAllLayers(LayerManager* aManager);
static void InvalidateAllLayersForFrame(nsIFrame *aFrame);
/**
* Call this to determine if a frame has a dedicated (non-Thebes) layer
@ -381,6 +382,12 @@ public:
*/
static bool HasRetainedLayerFor(nsIFrame* aFrame, uint32_t aDisplayItemKey, LayerManager* aManager);
/**
* Returns true if the given display item was rendered during the previous
* paint. Returns false otherwise.
*/
static bool HasRetainedDataFor(nsIFrame* aFrame, uint32_t aDisplayItemKey);
/**
* Save transform that was in aLayer when we last painted, and the position
* of the active scrolled root frame. It must be an integer
@ -613,7 +620,12 @@ protected:
static DisplayItemData* GetDisplayItemDataForManager(nsIFrame* aFrame,
uint32_t aDisplayItemKey,
LayerManager* aManager);
static DisplayItemData* GetDisplayItemDataForManager(nsIFrame* aFrame,
uint32_t aDisplayItemKey);
static DisplayItemData* GetDisplayItemDataForManager(nsDisplayItem* aItem, LayerManager* aManager);
static DisplayItemData* GetDisplayItemDataForManager(nsIFrame* aFrame,
uint32_t aDisplayItemKey,
LayerManagerData* aData);
/**
* A useful hashtable iteration function that removes the

View File

@ -3970,7 +3970,7 @@ PresShell::DocumentStatesChanged(nsIDocument* aDocument,
if (aStateMask.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
nsIFrame* root = mFrameConstructor->GetRootFrame();
if (root) {
root->InvalidateFrameSubtree();
FrameLayerBuilder::InvalidateAllLayersForFrame(root);
if (root->HasView()) {
root->GetView()->SetForcedRepaint(true);
}