Commit dc67315f authored by Matt Woodrow's avatar Matt Woodrow
Browse files

Bug 939607 - Part 3: Try fold nsDisplayOpacity items opacity value into their children. r=roc

parent 4fa53e45
Loading
Loading
Loading
Loading
+32 −6
Original line number Diff line number Diff line
@@ -3021,19 +3021,45 @@ IsItemTooSmallForActiveLayer(nsDisplayItem* aItem)
    nsIntSize(MIN_ACTIVE_LAYER_SIZE_DEV_PIXELS, MIN_ACTIVE_LAYER_SIZE_DEV_PIXELS);
}

nsDisplayItem::LayerState
nsDisplayOpacity::GetLayerState(nsDisplayListBuilder* aBuilder,
                                LayerManager* aManager,
                                const ContainerLayerParameters& aParameters) {
bool
nsDisplayOpacity::NeedsActiveLayer()
{
  if (ActiveLayerTracker::IsStyleAnimated(mFrame, eCSSProperty_opacity) &&
      !IsItemTooSmallForActiveLayer(this))
    return LAYER_ACTIVE;
    return true;
  if (mFrame->GetContent()) {
    if (nsLayoutUtils::HasAnimationsForCompositor(mFrame->GetContent(),
                                                  eCSSProperty_opacity)) {
      return LAYER_ACTIVE;
      return true;
    }
  }
  return false;
}

bool
nsDisplayOpacity::ShouldFlattenAway(nsDisplayListBuilder* aBuilder)
{
  if (NeedsActiveLayer())
    return false;

  nsDisplayItem* child = mList.GetBottom();
  // Only try folding our opacity down if we have a single
  // child. We could potentially do this also if we had multiple
  // children as long as they don't overlap.
  if (!child || child->GetAbove()) {
    return false;
  }

  return child->ApplyOpacity(mFrame->StyleDisplay()->mOpacity);
}

nsDisplayItem::LayerState
nsDisplayOpacity::GetLayerState(nsDisplayListBuilder* aBuilder,
                                LayerManager* aManager,
                                const ContainerLayerParameters& aParameters) {
  if (NeedsActiveLayer())
    return LAYER_ACTIVE;

  return RequiredLayerStateForChildren(aBuilder, aManager, aParameters, mList, mFrame);
}

+2 −0
Original line number Diff line number Diff line
@@ -2484,6 +2484,8 @@ public:
  {
    // We don't need to compute an invalidation region since we have LayerTreeInvalidation
  }
  virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
  bool NeedsActiveLayer();
  NS_DISPLAY_DECL_NAME("Opacity", TYPE_OPACITY)
#ifdef MOZ_DUMP_PAINTING
  virtual void WriteDebugInfo(FILE *aOutput) MOZ_OVERRIDE {