Bug 987005 - Add comments to a condition in PopThebesLayerData(). r=roc

This commit is contained in:
Markus Stange 2014-04-22 16:27:44 +02:00
Родитель 86c9b635a9
Коммит ed33e48d8b
1 изменённых файлов: 25 добавлений и 3 удалений

Просмотреть файл

@ -1843,6 +1843,29 @@ AddTransformedBoundsToRegion(const nsIntRegion& aRegion,
aDest->Or(*aDest, intRect);
}
static bool
CanOptimizeAwayThebesLayer(ThebesLayerData* aData,
FrameLayerBuilder* aLayerBuilder)
{
bool isRetained = aData->mLayer->Manager()->IsWidgetLayerManager();
if (!isRetained) {
return false;
}
// If there's no thebes layer with valid content in it that we can reuse,
// always create a color or image layer (and potentially throw away an
// existing completely invalid thebes layer).
if (aData->mLayer->GetValidRegion().IsEmpty()) {
return true;
}
// There is an existing thebes layer we can reuse. Throwing it away can make
// compositing cheaper (see bug 946952), but it might cause us to re-allocate
// the thebes layer frequently due to an animation. So we only discard it if
// we're in tree compression mode, which is triggered at a low frequency.
return aLayerBuilder->CheckInLayerTreeCompressionMode();
}
void
ContainerState::PopThebesLayerData()
{
@ -1858,9 +1881,8 @@ ContainerState::PopThebesLayerData()
nsRefPtr<Layer> layer;
nsRefPtr<ImageContainer> imageContainer = data->CanOptimizeImageLayer(mBuilder);
bool isRetained = data->mLayer->Manager()->IsWidgetLayerManager();
if (isRetained && (data->mIsSolidColorInVisibleRegion || imageContainer) &&
(data->mLayer->GetValidRegion().IsEmpty() || mLayerBuilder->CheckInLayerTreeCompressionMode())) {
if ((data->mIsSolidColorInVisibleRegion || imageContainer) &&
CanOptimizeAwayThebesLayer(data, mLayerBuilder)) {
NS_ASSERTION(!(data->mIsSolidColorInVisibleRegion && imageContainer),
"Can't be a solid color as well as an image!");
if (imageContainer) {