Bug 1529698 - Part 1: Make LayerState enum class r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D30837
This commit is contained in:
Miko Mynttinen
2019-05-18 20:11:11 +00:00
parent 8a5644c636
commit ca3f9970ff
10 changed files with 113 additions and 103 deletions

View File

@@ -175,9 +175,9 @@ class nsDisplayCanvasBackgroundColor final : public nsDisplaySolidColorBase {
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override { const ContainerLayerParameters& aParameters) override {
if (ForceActiveLayers()) { if (ForceActiveLayers()) {
return mozilla::LAYER_ACTIVE; return mozilla::LayerState::LAYER_ACTIVE;
} }
return mozilla::LAYER_NONE; return mozilla::LayerState::LAYER_NONE;
} }
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;

View File

@@ -200,14 +200,14 @@ class nsDisplayCanvas final : public nsDisplayItem {
const ContainerLayerParameters& aParameters) override { const ContainerLayerParameters& aParameters) override {
if (HTMLCanvasElement::FromNode(mFrame->GetContent()) if (HTMLCanvasElement::FromNode(mFrame->GetContent())
->ShouldForceInactiveLayer(aManager)) ->ShouldForceInactiveLayer(aManager))
return LAYER_INACTIVE; return LayerState::LAYER_INACTIVE;
// If compositing is cheap, just do that // If compositing is cheap, just do that
if (aManager->IsCompositingCheap() || if (aManager->IsCompositingCheap() ||
ActiveLayerTracker::IsContentActive(mFrame)) ActiveLayerTracker::IsContentActive(mFrame))
return mozilla::LAYER_ACTIVE; return mozilla::LayerState::LAYER_ACTIVE;
return LAYER_INACTIVE; return LayerState::LAYER_INACTIVE;
} }
// FirstContentfulPaint is supposed to ignore "white" canvases. We use // FirstContentfulPaint is supposed to ignore "white" canvases. We use

View File

@@ -1815,7 +1815,7 @@ LayerState nsDisplayImage::GetLayerState(
NS_FAILED(mImage->GetAnimated(&animated)) || !animated) { NS_FAILED(mImage->GetAnimated(&animated)) || !animated) {
if (!aManager->IsCompositingCheap() || if (!aManager->IsCompositingCheap() ||
!nsLayoutUtils::GPUImageScalingEnabled()) { !nsLayoutUtils::GPUImageScalingEnabled()) {
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
} }
@@ -1838,27 +1838,27 @@ LayerState nsDisplayImage::GetLayerState(
// If we are not scaling at all, no point in separating this into a layer. // If we are not scaling at all, no point in separating this into a layer.
if (scale.width == 1.0f && scale.height == 1.0f) { if (scale.width == 1.0f && scale.height == 1.0f) {
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
// If the target size is pretty small, no point in using a layer. // If the target size is pretty small, no point in using a layer.
if (destLayerRect.width * destLayerRect.height < 64 * 64) { if (destLayerRect.width * destLayerRect.height < 64 * 64) {
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
} }
} }
if (!CanOptimizeToImageLayer(aManager, aBuilder)) { if (!CanOptimizeToImageLayer(aManager, aBuilder)) {
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
// Image layer doesn't support draw focus ring for image map. // Image layer doesn't support draw focus ring for image map.
nsImageFrame* f = static_cast<nsImageFrame*>(mFrame); nsImageFrame* f = static_cast<nsImageFrame*>(mFrame);
if (f->HasImageMap()) { if (f->HasImageMap()) {
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
return LAYER_ACTIVE; return LayerState::LAYER_ACTIVE;
} }
/* virtual */ /* virtual */

View File

@@ -851,7 +851,7 @@ class nsDisplayPluginReadback : public nsDisplayItem {
LayerState GetLayerState( LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override { const ContainerLayerParameters& aParameters) override {
return LAYER_ACTIVE; return LayerState::LAYER_ACTIVE;
} }
virtual nsDisplayItemGeometry* AllocateGeometry( virtual nsDisplayItemGeometry* AllocateGeometry(
@@ -1105,10 +1105,11 @@ void nsPluginFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
DisplayItemType::TYPE_PRINT_PLUGIN); DisplayItemType::TYPE_PRINT_PLUGIN);
} else { } else {
LayerState state = GetLayerState(aBuilder, nullptr); LayerState state = GetLayerState(aBuilder, nullptr);
if (state == LAYER_INACTIVE && nsDisplayItem::ForceActiveLayers()) { if (state == LayerState::LAYER_INACTIVE &&
state = LAYER_ACTIVE; nsDisplayItem::ForceActiveLayers()) {
state = LayerState::LAYER_ACTIVE;
} }
if (aBuilder->IsPaintingToWindow() && state == LAYER_ACTIVE && if (aBuilder->IsPaintingToWindow() && state == LayerState::LAYER_ACTIVE &&
IsTransparentMode()) { IsTransparentMode()) {
aLists.Content()->AppendNewToTop<nsDisplayPluginReadback>(aBuilder, this); aLists.Content()->AppendNewToTop<nsDisplayPluginReadback>(aBuilder, this);
} }
@@ -1232,17 +1233,17 @@ nsRect nsPluginFrame::GetPaintedRect(const nsDisplayPlugin* aItem) const {
LayerState nsPluginFrame::GetLayerState(nsDisplayListBuilder* aBuilder, LayerState nsPluginFrame::GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager) { LayerManager* aManager) {
if (!mInstanceOwner) return LAYER_NONE; if (!mInstanceOwner) return LayerState::LAYER_NONE;
if (mInstanceOwner->NeedsScrollImageLayer()) { if (mInstanceOwner->NeedsScrollImageLayer()) {
return LAYER_ACTIVE; return LayerState::LAYER_ACTIVE;
} }
if (!mInstanceOwner->UseAsyncRendering()) { if (!mInstanceOwner->UseAsyncRendering()) {
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
return LAYER_ACTIVE_FORCE; return LayerState::LAYER_ACTIVE_FORCE;
} }
class PluginFrameDidCompositeObserver final : public DidCompositeObserver { class PluginFrameDidCompositeObserver final : public DidCompositeObserver {

View File

@@ -502,11 +502,12 @@ class nsDisplayVideo : public nsDisplayItem {
// managers calling imageContainer->GetCurrentAsSurface can be // managers calling imageContainer->GetCurrentAsSurface can be
// very expensive. So just always be active when compositing is // very expensive. So just always be active when compositing is
// cheap (i.e. hardware accelerated). // cheap (i.e. hardware accelerated).
return LAYER_ACTIVE; return LayerState::LAYER_ACTIVE;
} }
HTMLMediaElement* elem = HTMLMediaElement* elem =
static_cast<HTMLMediaElement*>(mFrame->GetContent()); static_cast<HTMLMediaElement*>(mFrame->GetContent());
return elem->IsPotentiallyPlaying() ? LAYER_ACTIVE_FORCE : LAYER_INACTIVE; return elem->IsPotentiallyPlaying() ? LayerState::LAYER_ACTIVE_FORCE
: LayerState::LAYER_INACTIVE;
} }
}; };

View File

@@ -192,9 +192,9 @@ mozilla::LayerState nsDisplayRemote::GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) { const ContainerLayerParameters& aParameters) {
if (IsTempLayerManager(aManager)) { if (IsTempLayerManager(aManager)) {
return mozilla::LAYER_NONE; return mozilla::LayerState::LAYER_NONE;
} }
return mozilla::LAYER_ACTIVE_FORCE; return mozilla::LayerState::LAYER_ACTIVE_FORCE;
} }
already_AddRefed<Layer> nsDisplayRemote::BuildLayer( already_AddRefed<Layer> nsDisplayRemote::BuildLayer(

View File

@@ -447,22 +447,22 @@ class LayerManagerData : public LayerUserData {
const char* layerState; const char* layerState;
switch (data->mLayerState) { switch (data->mLayerState) {
case LAYER_NONE: case LayerState::LAYER_NONE:
layerState = "LAYER_NONE"; layerState = "LAYER_NONE";
break; break;
case LAYER_INACTIVE: case LayerState::LAYER_INACTIVE:
layerState = "LAYER_INACTIVE"; layerState = "LAYER_INACTIVE";
break; break;
case LAYER_ACTIVE: case LayerState::LAYER_ACTIVE:
layerState = "LAYER_ACTIVE"; layerState = "LAYER_ACTIVE";
break; break;
case LAYER_ACTIVE_FORCE: case LayerState::LAYER_ACTIVE_FORCE:
layerState = "LAYER_ACTIVE_FORCE"; layerState = "LAYER_ACTIVE_FORCE";
break; break;
case LAYER_ACTIVE_EMPTY: case LayerState::LAYER_ACTIVE_EMPTY:
layerState = "LAYER_ACTIVE_EMPTY"; layerState = "LAYER_ACTIVE_EMPTY";
break; break;
case LAYER_SVG_EFFECTS: case LayerState::LAYER_SVG_EFFECTS:
layerState = "LAYER_SVG_EFFECTS"; layerState = "LAYER_SVG_EFFECTS";
break; break;
} }
@@ -822,7 +822,7 @@ struct NewLayerEntry {
mClipChain(nullptr), mClipChain(nullptr),
mScrollMetadataASR(nullptr), mScrollMetadataASR(nullptr),
mLayerContentsVisibleRect(0, 0, -1, -1), mLayerContentsVisibleRect(0, 0, -1, -1),
mLayerState(LAYER_INACTIVE), mLayerState(LayerState::LAYER_INACTIVE),
mHideAllLayersBelow(false), mHideAllLayersBelow(false),
mOpaqueForAnimatedGeometryRootParent(false), mOpaqueForAnimatedGeometryRootParent(false),
mPropagateComponentAlphaFlattening(true), mPropagateComponentAlphaFlattening(true),
@@ -2067,8 +2067,7 @@ DisplayItemData* FrameLayerBuilder::GetDisplayItemData(nsIFrame* aFrame,
for (uint32_t i = 0; i < array.Length(); i++) { for (uint32_t i = 0; i < array.Length(); i++) {
DisplayItemData* item = DisplayItemData* item =
DisplayItemData::AssertDisplayItemData(array.ElementAt(i)); DisplayItemData::AssertDisplayItemData(array.ElementAt(i));
if (item->mDisplayItemKey == aKey && if (item->mDisplayItemKey == aKey && item->FirstFrame() == aFrame &&
item->FirstFrame() == aFrame &&
item->mLayer->Manager() == mRetainingManager) { item->mLayer->Manager() == mRetainingManager) {
return item; return item;
} }
@@ -4441,12 +4440,13 @@ void ContainerState::ProcessDisplayItems(nsDisplayList* aList) {
aList->SetNeedsTransparentSurface(); aList->SetNeedsTransparentSurface();
} }
LayerState layerState = LAYER_NONE; LayerState layerState = LayerState::LAYER_NONE;
if (marker == DisplayItemEntryType::Item) { if (marker == DisplayItemEntryType::Item) {
layerState = item->GetLayerState(mBuilder, mManager, mParameters); layerState = item->GetLayerState(mBuilder, mManager, mParameters);
if (layerState == LAYER_INACTIVE && nsDisplayItem::ForceActiveLayers()) { if (layerState == LayerState::LAYER_INACTIVE &&
layerState = LAYER_ACTIVE; nsDisplayItem::ForceActiveLayers()) {
layerState = LayerState::LAYER_ACTIVE;
} }
} }
@@ -4616,11 +4616,12 @@ void ContainerState::ProcessDisplayItems(nsDisplayList* aList) {
// Assign the item to a layer // Assign the item to a layer
bool treatInactiveItemAsActive = bool treatInactiveItemAsActive =
(layerState == LAYER_INACTIVE && (layerState == LayerState::LAYER_INACTIVE &&
mLayerBuilder->GetContainingPaintedLayerData()); mLayerBuilder->GetContainingPaintedLayerData());
if (layerState == LAYER_ACTIVE_FORCE || treatInactiveItemAsActive || if (layerState == LayerState::LAYER_ACTIVE_FORCE ||
(!forceInactive && treatInactiveItemAsActive ||
(layerState == LAYER_ACTIVE_EMPTY || layerState == LAYER_ACTIVE))) { (!forceInactive && (layerState == LayerState::LAYER_ACTIVE_EMPTY ||
layerState == LayerState::LAYER_ACTIVE))) {
layerCount++; layerCount++;
// Currently we do not support flattening effects within nested inactive // Currently we do not support flattening effects within nested inactive
@@ -4628,11 +4629,12 @@ void ContainerState::ProcessDisplayItems(nsDisplayList* aList) {
MOZ_ASSERT(selectedLayer == nullptr); MOZ_ASSERT(selectedLayer == nullptr);
MOZ_ASSERT(marker == DisplayItemEntryType::Item); MOZ_ASSERT(marker == DisplayItemEntryType::Item);
// LAYER_ACTIVE_EMPTY means the layer is created just for its metadata. // LayerState::LAYER_ACTIVE_EMPTY means the layer is created just for its
// We should never see an empty layer with any visible content! // metadata. We should never see an empty layer with any visible content!
NS_ASSERTION( NS_ASSERTION(
layerState != LAYER_ACTIVE_EMPTY || itemVisibleRect.IsEmpty(), layerState != LayerState::LAYER_ACTIVE_EMPTY ||
"State is LAYER_ACTIVE_EMPTY but visible rect is not."); itemVisibleRect.IsEmpty(),
"State is LayerState::LAYER_ACTIVE_EMPTY but visible rect is not.");
// As long as the new layer isn't going to be a PaintedLayer, // As long as the new layer isn't going to be a PaintedLayer,
// InvalidateForLayerChange doesn't need the new layer pointer. // InvalidateForLayerChange doesn't need the new layer pointer.
@@ -4910,7 +4912,7 @@ void ContainerState::ProcessDisplayItems(nsDisplayList* aList) {
// Don't attempt to flatten compnent alpha layers that are within // Don't attempt to flatten compnent alpha layers that are within
// a forced active layer, or an active transform; // a forced active layer, or an active transform;
if (itemType == DisplayItemType::TYPE_TRANSFORM || if (itemType == DisplayItemType::TYPE_TRANSFORM ||
layerState == LAYER_ACTIVE_FORCE) { layerState == LayerState::LAYER_ACTIVE_FORCE) {
newLayerEntry->mPropagateComponentAlphaFlattening = false; newLayerEntry->mPropagateComponentAlphaFlattening = false;
} }
@@ -5230,7 +5232,8 @@ void FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData) {
// inactive layers, since these types don't implement // inactive layers, since these types don't implement
// ComputeInvalidateRegion (and rely on the ComputeDifferences call in // ComputeInvalidateRegion (and rely on the ComputeDifferences call in
// AddPaintedDisplayItem instead). // AddPaintedDisplayItem instead).
if (!combined.IsEmpty() || aData->mLayerState == LAYER_INACTIVE || if (!combined.IsEmpty() ||
aData->mLayerState == LayerState::LAYER_INACTIVE ||
item->NeedsGeometryUpdates()) { item->NeedsGeometryUpdates()) {
geometry = item->AllocateGeometry(mDisplayListBuilder); geometry = item->AllocateGeometry(mDisplayListBuilder);
} }
@@ -5288,7 +5291,7 @@ void FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData,
layer->GetUserData(&gPaintedDisplayItemLayerUserData)); layer->GetUserData(&gPaintedDisplayItemLayerUserData));
RefPtr<BasicLayerManager> tempManager; RefPtr<BasicLayerManager> tempManager;
nsIntRect intClip; nsIntRect intClip;
if (aItem.mLayerState != LAYER_NONE) { if (aItem.mLayerState != LayerState::LAYER_NONE) {
if (aItem.mDisplayItemData) { if (aItem.mDisplayItemData) {
tempManager = aItem.mDisplayItemData->mInactiveManager; tempManager = aItem.mDisplayItemData->mInactiveManager;
@@ -5391,7 +5394,7 @@ void FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData,
data = data =
layerBuilder->GetDisplayItemDataForManager(aItem.mItem, tempManager); layerBuilder->GetDisplayItemDataForManager(aItem.mItem, tempManager);
data = layerBuilder->StoreDataForFrame(aItem.mItem, tmpLayer, data = layerBuilder->StoreDataForFrame(aItem.mItem, tmpLayer,
LAYER_ACTIVE, data); LayerState::LAYER_ACTIVE, data);
data->mOldTransform = data->mTransform; data->mOldTransform = data->mTransform;
data->mTransform = aItem.mTransform; data->mTransform = aItem.mTransform;
} }
@@ -5422,7 +5425,7 @@ void FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData,
nsRect visible = aItem.mItem->Frame()->GetVisualOverflowRect(); nsRect visible = aItem.mItem->Frame()->GetVisualOverflowRect();
invalid = visible.ToOutsidePixels(paintedData->mAppUnitsPerDevPixel); invalid = visible.ToOutsidePixels(paintedData->mAppUnitsPerDevPixel);
} }
if (aItem.mLayerState == LAYER_SVG_EFFECTS) { if (aItem.mLayerState == LayerState::LAYER_SVG_EFFECTS) {
invalid = nsSVGIntegrationUtils::AdjustInvalidAreaForSVGEffects( invalid = nsSVGIntegrationUtils::AdjustInvalidAreaForSVGEffects(
aItem.mItem->Frame(), aItem.mItem->ToReferenceFrame(), invalid); aItem.mItem->Frame(), aItem.mItem->ToReferenceFrame(), invalid);
} }
@@ -6250,10 +6253,11 @@ already_AddRefed<ContainerLayer> FrameLayerBuilder::BuildContainerLayerFor(
if (aContainerItem) { if (aContainerItem) {
DisplayItemData* data = DisplayItemData* data =
GetDisplayItemDataForManager(aContainerItem, mRetainingManager); GetDisplayItemDataForManager(aContainerItem, mRetainingManager);
StoreDataForFrame(aContainerItem, containerLayer, LAYER_ACTIVE, data); StoreDataForFrame(aContainerItem, containerLayer,
LayerState::LAYER_ACTIVE, data);
} else { } else {
StoreDataForFrame(aContainerFrame, containerDisplayItemKey, StoreDataForFrame(aContainerFrame, containerDisplayItemKey,
containerLayer, LAYER_ACTIVE); containerLayer, LayerState::LAYER_ACTIVE);
} }
} }

View File

@@ -9,7 +9,7 @@
namespace mozilla { namespace mozilla {
enum LayerState { enum class LayerState : uint8_t {
LAYER_NONE, LAYER_NONE,
LAYER_INACTIVE, LAYER_INACTIVE,
LAYER_ACTIVE, LAYER_ACTIVE,

View File

@@ -3400,10 +3400,10 @@ LayerState nsDisplaySolidColor::GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) { const ContainerLayerParameters& aParameters) {
if (ForceActiveLayers()) { if (ForceActiveLayers()) {
return LAYER_ACTIVE; return LayerState::LAYER_ACTIVE;
} }
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
already_AddRefed<Layer> nsDisplaySolidColor::BuildLayer( already_AddRefed<Layer> nsDisplaySolidColor::BuildLayer(
@@ -4082,12 +4082,12 @@ LayerState nsDisplayBackgroundImage::GetLayerState(
if (shouldLayerize == NO_LAYER_NEEDED) { if (shouldLayerize == NO_LAYER_NEEDED) {
// We can skip the call to CanOptimizeToImageLayer if we don't want a // We can skip the call to CanOptimizeToImageLayer if we don't want a
// layer anyway. // layer anyway.
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
if (CanOptimizeToImageLayer(aManager, aBuilder)) { if (CanOptimizeToImageLayer(aManager, aBuilder)) {
if (shouldLayerize == WHENEVER_POSSIBLE) { if (shouldLayerize == WHENEVER_POSSIBLE) {
return LAYER_ACTIVE; return LayerState::LAYER_ACTIVE;
} }
MOZ_ASSERT(shouldLayerize == ONLY_FOR_SCALING, MOZ_ASSERT(shouldLayerize == ONLY_FOR_SCALING,
@@ -4115,11 +4115,11 @@ LayerState nsDisplayBackgroundImage::GetLayerState(
// Separate this image into a layer. // Separate this image into a layer.
// There's no point in doing this if we are not scaling at all or if the // There's no point in doing this if we are not scaling at all or if the
// target size is pretty small. // target size is pretty small.
return LAYER_ACTIVE; return LayerState::LAYER_ACTIVE;
} }
} }
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
already_AddRefed<Layer> nsDisplayBackgroundImage::BuildLayer( already_AddRefed<Layer> nsDisplayBackgroundImage::BuildLayer(
@@ -4702,15 +4702,15 @@ LayerState nsDisplayBackgroundColor::GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) { const ContainerLayerParameters& aParameters) {
if (ForceActiveLayers() && !HasBackgroundClipText()) { if (ForceActiveLayers() && !HasBackgroundClipText()) {
return LAYER_ACTIVE; return LayerState::LAYER_ACTIVE;
} }
if (EffectCompositor::HasAnimationsForCompositor( if (EffectCompositor::HasAnimationsForCompositor(
mFrame, DisplayItemType::TYPE_BACKGROUND_COLOR)) { mFrame, DisplayItemType::TYPE_BACKGROUND_COLOR)) {
return LAYER_ACTIVE_FORCE; return LayerState::LAYER_ACTIVE_FORCE;
} }
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
already_AddRefed<Layer> nsDisplayBackgroundColor::BuildLayer( already_AddRefed<Layer> nsDisplayBackgroundColor::BuildLayer(
@@ -5250,7 +5250,7 @@ void nsDisplayBorder::ComputeInvalidationRegion(
LayerState nsDisplayBorder::GetLayerState( LayerState nsDisplayBorder::GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) { const ContainerLayerParameters& aParameters) {
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
bool nsDisplayBorder::CreateWebRenderCommands( bool nsDisplayBorder::CreateWebRenderCommands(
@@ -5818,42 +5818,44 @@ void nsDisplayWrapList::Paint(nsDisplayListBuilder* aBuilder,
/** /**
* Returns true if all descendant display items can be placed in the same * Returns true if all descendant display items can be placed in the same
* PaintedLayer --- GetLayerState returns LAYER_INACTIVE or LAYER_NONE, * PaintedLayer --- GetLayerState returns LayerState::LAYER_INACTIVE or
* and they all have the expected animated geometry root. * LayerState::LAYER_NONE, and they all have the expected animated geometry
* root.
*/ */
static LayerState RequiredLayerStateForChildren( static LayerState RequiredLayerStateForChildren(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters, const nsDisplayList& aList, const ContainerLayerParameters& aParameters, const nsDisplayList& aList,
AnimatedGeometryRoot* aExpectedAnimatedGeometryRootForChildren) { AnimatedGeometryRoot* aExpectedAnimatedGeometryRootForChildren) {
LayerState result = LAYER_INACTIVE; LayerState result = LayerState::LAYER_INACTIVE;
for (nsDisplayItem* i : aList) { for (nsDisplayItem* i : aList) {
if (result == LAYER_INACTIVE && if (result == LayerState::LAYER_INACTIVE &&
i->GetAnimatedGeometryRoot() != i->GetAnimatedGeometryRoot() !=
aExpectedAnimatedGeometryRootForChildren) { aExpectedAnimatedGeometryRootForChildren) {
result = LAYER_ACTIVE; result = LayerState::LAYER_ACTIVE;
} }
LayerState state = i->GetLayerState(aBuilder, aManager, aParameters); LayerState state = i->GetLayerState(aBuilder, aManager, aParameters);
if (state == LAYER_ACTIVE && if (state == LayerState::LAYER_ACTIVE &&
(i->GetType() == DisplayItemType::TYPE_BLEND_MODE || (i->GetType() == DisplayItemType::TYPE_BLEND_MODE ||
i->GetType() == DisplayItemType::TYPE_TABLE_BLEND_MODE)) { i->GetType() == DisplayItemType::TYPE_TABLE_BLEND_MODE)) {
// nsDisplayBlendMode always returns LAYER_ACTIVE to ensure that the // nsDisplayBlendMode always returns LayerState::LAYER_ACTIVE to ensure
// blending operation happens in the intermediate surface of its parent // that the blending operation happens in the intermediate surface of its
// display item (usually an nsDisplayBlendContainer). But this does not // parent display item (usually an nsDisplayBlendContainer). But this does
// mean that it needs all its ancestor display items to become active. // not mean that it needs all its ancestor display items to become active.
// So we ignore its layer state and look at its children instead. // So we ignore its layer state and look at its children instead.
state = RequiredLayerStateForChildren( state = RequiredLayerStateForChildren(
aBuilder, aManager, aParameters, aBuilder, aManager, aParameters,
*i->GetSameCoordinateSystemChildren(), i->GetAnimatedGeometryRoot()); *i->GetSameCoordinateSystemChildren(), i->GetAnimatedGeometryRoot());
} }
if ((state == LAYER_ACTIVE || state == LAYER_ACTIVE_FORCE) && if ((state == LayerState::LAYER_ACTIVE ||
state == LayerState::LAYER_ACTIVE_FORCE) &&
state > result) { state > result) {
result = state; result = state;
} }
if (state == LAYER_ACTIVE_EMPTY && state > result) { if (state == LayerState::LAYER_ACTIVE_EMPTY && state > result) {
result = LAYER_ACTIVE_FORCE; result = LayerState::LAYER_ACTIVE_FORCE;
} }
if (state == LAYER_NONE) { if (state == LayerState::LAYER_NONE) {
nsDisplayList* list = i->GetSameCoordinateSystemChildren(); nsDisplayList* list = i->GetSameCoordinateSystemChildren();
if (list) { if (list) {
LayerState childState = RequiredLayerStateForChildren( LayerState childState = RequiredLayerStateForChildren(
@@ -6204,13 +6206,13 @@ nsDisplayItem::LayerState nsDisplayOpacity::GetLayerState(
// layerization changes for content that won't ever be painted. // layerization changes for content that won't ever be painted.
if (mForEventsAndPluginsOnly) { if (mForEventsAndPluginsOnly) {
MOZ_ASSERT(mOpacity == 0); MOZ_ASSERT(mOpacity == 0);
return LAYER_INACTIVE; return LayerState::LAYER_INACTIVE;
} }
if (mNeedsActiveLayer) { if (mNeedsActiveLayer) {
// Returns LAYER_ACTIVE_FORCE to avoid flatterning the layer for async // Returns LayerState::LAYER_ACTIVE_FORCE to avoid flatterning the layer for
// animations. // async animations.
return LAYER_ACTIVE_FORCE; return LayerState::LAYER_ACTIVE_FORCE;
} }
return RequiredLayerStateForChildren(aBuilder, aManager, aParameters, mList, return RequiredLayerStateForChildren(aBuilder, aManager, aParameters, mList,
@@ -6293,7 +6295,7 @@ nsRegion nsDisplayBlendMode::GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
LayerState nsDisplayBlendMode::GetLayerState( LayerState nsDisplayBlendMode::GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) { const ContainerLayerParameters& aParameters) {
return LAYER_ACTIVE; return LayerState::LAYER_ACTIVE;
} }
bool nsDisplayBlendMode::CreateWebRenderCommands( bool nsDisplayBlendMode::CreateWebRenderCommands(
@@ -6471,7 +6473,7 @@ LayerState nsDisplayOwnLayer::GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) { const ContainerLayerParameters& aParameters) {
if (mForceActive) { if (mForceActive) {
return mozilla::LAYER_ACTIVE_FORCE; return mozilla::LayerState::LAYER_ACTIVE_FORCE;
} }
return RequiredLayerStateForChildren(aBuilder, aManager, aParameters, mList, return RequiredLayerStateForChildren(aBuilder, aManager, aParameters, mList,
@@ -7373,7 +7375,7 @@ already_AddRefed<Layer> nsDisplayScrollInfoLayer::BuildLayer(
LayerState nsDisplayScrollInfoLayer::GetLayerState( LayerState nsDisplayScrollInfoLayer::GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) { const ContainerLayerParameters& aParameters) {
return LAYER_ACTIVE_EMPTY; return LayerState::LAYER_ACTIVE_EMPTY;
} }
UniquePtr<ScrollMetadata> nsDisplayScrollInfoLayer::ComputeScrollMetadata( UniquePtr<ScrollMetadata> nsDisplayScrollInfoLayer::ComputeScrollMetadata(
@@ -8341,13 +8343,13 @@ nsDisplayItem::LayerState nsDisplayTransform::GetLayerState(
// the transform is 2D. // the transform is 2D.
if (!GetTransform().Is2D() || Combines3DTransformWithAncestors() || if (!GetTransform().Is2D() || Combines3DTransformWithAncestors() ||
mIsTransformSeparator || mFrame->HasPerspective()) { mIsTransformSeparator || mFrame->HasPerspective()) {
return LAYER_ACTIVE_FORCE; return LayerState::LAYER_ACTIVE_FORCE;
} }
if (MayBeAnimated(aBuilder)) { if (MayBeAnimated(aBuilder)) {
// Returns LAYER_ACTIVE_FORCE to avoid flatterning the layer for async // Returns LayerState::LAYER_ACTIVE_FORCE to avoid flatterning the layer for
// animations. // async animations.
return LAYER_ACTIVE_FORCE; return LayerState::LAYER_ACTIVE_FORCE;
} }
// Expect the child display items to have this frame as their animated // Expect the child display items to have this frame as their animated
@@ -8843,7 +8845,7 @@ already_AddRefed<Layer> nsDisplayPerspective::BuildLayer(
LayerState nsDisplayPerspective::GetLayerState( LayerState nsDisplayPerspective::GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) { const ContainerLayerParameters& aParameters) {
return LAYER_ACTIVE_FORCE; return LayerState::LAYER_ACTIVE_FORCE;
} }
nsRegion nsDisplayPerspective::GetOpaqueRegion(nsDisplayListBuilder* aBuilder, nsRegion nsDisplayPerspective::GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
@@ -9446,12 +9448,14 @@ LayerState nsDisplayMasksAndClipPaths::GetLayerState(
// When we're not active, FrameLayerBuilder will call PaintAsLayer() // When we're not active, FrameLayerBuilder will call PaintAsLayer()
// on us during painting. In that case we don't want a mask layer to // on us during painting. In that case we don't want a mask layer to
// be created, because PaintAsLayer() takes care of applying the mask. // be created, because PaintAsLayer() takes care of applying the mask.
// So we return LAYER_SVG_EFFECTS instead of LAYER_INACTIVE so that // So we return LayerState::LAYER_SVG_EFFECTS instead of
// FrameLayerBuilder doesn't set a mask layer on our layer. // LayerState::LAYER_INACTIVE so that FrameLayerBuilder doesn't set a mask
return result == LAYER_INACTIVE ? LAYER_SVG_EFFECTS : result; // layer on our layer.
return result == LayerState::LAYER_INACTIVE ? LayerState::LAYER_SVG_EFFECTS
: result;
} }
return LAYER_SVG_EFFECTS; return LayerState::LAYER_SVG_EFFECTS;
} }
bool nsDisplayMasksAndClipPaths::CanPaintOnMaskLayer(LayerManager* aManager) { bool nsDisplayMasksAndClipPaths::CanPaintOnMaskLayer(LayerManager* aManager) {
@@ -9828,7 +9832,7 @@ already_AddRefed<Layer> nsDisplayFilters::BuildLayer(
LayerState nsDisplayFilters::GetLayerState( LayerState nsDisplayFilters::GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) { const ContainerLayerParameters& aParameters) {
return LAYER_SVG_EFFECTS; return LayerState::LAYER_SVG_EFFECTS;
} }
bool nsDisplayFilters::ComputeVisibility(nsDisplayListBuilder* aBuilder, bool nsDisplayFilters::ComputeVisibility(nsDisplayListBuilder* aBuilder,
@@ -10057,9 +10061,9 @@ LayerState nsDisplaySVGWrapper::GetLayerState(
RefPtr<LayerManager> layerManager = aBuilder->GetWidgetLayerManager(); RefPtr<LayerManager> layerManager = aBuilder->GetWidgetLayerManager();
if (layerManager && if (layerManager &&
layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) { layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) {
return LAYER_ACTIVE_FORCE; return LayerState::LAYER_ACTIVE_FORCE;
} }
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
bool nsDisplaySVGWrapper::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) { bool nsDisplaySVGWrapper::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) {
@@ -10118,9 +10122,9 @@ LayerState nsDisplayForeignObject::GetLayerState(
RefPtr<LayerManager> layerManager = aBuilder->GetWidgetLayerManager(); RefPtr<LayerManager> layerManager = aBuilder->GetWidgetLayerManager();
if (layerManager && if (layerManager &&
layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) { layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) {
return LAYER_ACTIVE_FORCE; return LayerState::LAYER_ACTIVE_FORCE;
} }
return LAYER_NONE; return LayerState::LAYER_NONE;
} }
bool nsDisplayForeignObject::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) { bool nsDisplayForeignObject::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) {

View File

@@ -2720,7 +2720,7 @@ class nsDisplayItem : public nsDisplayItemBase {
virtual LayerState GetLayerState( virtual LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) { const ContainerLayerParameters& aParameters) {
return mozilla::LAYER_NONE; return mozilla::LayerState::LAYER_NONE;
} }
#ifdef MOZ_DUMP_PAINTING #ifdef MOZ_DUMP_PAINTING
@@ -4943,7 +4943,7 @@ class nsDisplayClearBackground : public nsPaintedDisplayItem {
LayerState GetLayerState( LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override { const ContainerLayerParameters& aParameters) override {
return mozilla::LAYER_ACTIVE_FORCE; return mozilla::LayerState::LAYER_ACTIVE_FORCE;
} }
already_AddRefed<Layer> BuildLayer( already_AddRefed<Layer> BuildLayer(
@@ -6037,7 +6037,7 @@ class nsDisplaySubDocument : public nsDisplayOwnLayer {
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override { const ContainerLayerParameters& aParameters) override {
if (mShouldFlatten) { if (mShouldFlatten) {
return mozilla::LAYER_NONE; return mozilla::LayerState::LAYER_NONE;
} }
return nsDisplayOwnLayer::GetLayerState(aBuilder, aManager, aParameters); return nsDisplayOwnLayer::GetLayerState(aBuilder, aManager, aParameters);
} }
@@ -6118,7 +6118,7 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer {
LayerState GetLayerState( LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override { const ContainerLayerParameters& aParameters) override {
return mozilla::LAYER_ACTIVE; return mozilla::LayerState::LAYER_ACTIVE;
} }
bool CreateWebRenderCommands( bool CreateWebRenderCommands(
@@ -6173,7 +6173,7 @@ class nsDisplayFixedPosition : public nsDisplayOwnLayer {
LayerState GetLayerState( LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override { const ContainerLayerParameters& aParameters) override {
return mozilla::LAYER_ACTIVE_FORCE; return mozilla::LayerState::LAYER_ACTIVE_FORCE;
} }
bool ShouldFixToViewport(nsDisplayListBuilder* aBuilder) const override { bool ShouldFixToViewport(nsDisplayListBuilder* aBuilder) const override {
@@ -6345,7 +6345,7 @@ class nsDisplayZoom : public nsDisplaySubDocument {
LayerState GetLayerState( LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override { const ContainerLayerParameters& aParameters) override {
return mozilla::LAYER_ACTIVE; return mozilla::LayerState::LAYER_ACTIVE;
} }
// Get the app units per dev pixel ratio of the child document. // Get the app units per dev pixel ratio of the child document.
@@ -6388,7 +6388,7 @@ class nsDisplayAsyncZoom : public nsDisplayOwnLayer {
virtual LayerState GetLayerState( virtual LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager, nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override { const ContainerLayerParameters& aParameters) override {
return mozilla::LAYER_ACTIVE_FORCE; return mozilla::LayerState::LAYER_ACTIVE_FORCE;
} }
protected: protected: