Commit 5c99a197 authored by Matt Woodrow's avatar Matt Woodrow
Browse files

Bug 1727683 - Remove LayerTreeInvalidation. r=jrmuizel

Depends on D123881

Differential Revision: https://phabricator.services.mozilla.com/D123882
parent 7960f3b1
Loading
Loading
Loading
Loading
+0 −755

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −79
Original line number Diff line number Diff line
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef GFX_LAYER_TREE_INVALIDATION_H
#define GFX_LAYER_TREE_INVALIDATION_H

#include "nsRegion.h"           // for nsIntRegion
#include "mozilla/UniquePtr.h"  // for UniquePtr
#include "mozilla/gfx/Point.h"

namespace mozilla {
namespace layers {

class Layer;
class ContainerLayer;

/**
 * Callback for ContainerLayer invalidations.
 *
 * @param aContainer ContainerLayer being invalidated.
 * @param aRegion Invalidated region in the ContainerLayer's coordinate
 * space. If null, then the entire region must be invalidated.
 */
typedef void (*NotifySubDocInvalidationFunc)(ContainerLayer* aLayer,
                                             const nsIntRegion* aRegion);

/**
 * A set of cached layer properties (including those of child layers),
 * used for comparing differences in layer trees.
 */
struct LayerProperties {
 protected:
  LayerProperties() = default;

  LayerProperties(const LayerProperties& a) = delete;
  LayerProperties& operator=(const LayerProperties& a) = delete;

 public:
  virtual ~LayerProperties() = default;

  /**
   * Copies the current layer tree properties into
   * a new LayerProperties object.
   *
   * @param Layer tree to copy, or nullptr if we have no
   * initial layer tree.
   */
  static UniquePtr<LayerProperties> CloneFrom(Layer* aRoot);

  /**
   * Clear all invalidation status from this layer tree.
   */
  static void ClearInvalidations(Layer* aRoot);

  /**
   * Compares a set of existing layer tree properties to the current layer
   * tree and generates the changed rectangle.
   *
   * @param aRoot Root layer of the layer tree to compare against.
   * @param aOutRegion Outparam that will contain the painted area changed by
   * the layer tree changes.
   * @param aCallback If specified, callback to call when ContainerLayers
   * are invalidated.
   * @return True on success, false if a calculation overflowed and the entire
   *         layer tree area should be considered invalidated.
   */
  virtual bool ComputeDifferences(Layer* aRoot, nsIntRegion& aOutRegion,
                                  NotifySubDocInvalidationFunc aCallback) = 0;

  virtual void MoveBy(const gfx::IntPoint& aOffset) = 0;
};

}  // namespace layers
}  // namespace mozilla

#endif /* GFX_LAYER_TREE_INVALIDATON_H */
+0 −2
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ EXPORTS += [
    "Layers.h",
    "LayerScope.h",
    "LayersTypes.h",
    "LayerTreeInvalidation.h",
    "LayerUserData.h",
    "opengl/OGLShaderConfig.h",
    "opengl/OGLShaderProgram.h",
@@ -433,7 +432,6 @@ UNIFIED_SOURCES += [
    "LayerScope.cpp",
    "LayersHelpers.cpp",
    "LayersTypes.cpp",
    "LayerTreeInvalidation.cpp",
    "MemoryPressureObserver.cpp",
    "opengl/CompositingRenderTargetOGL.cpp",
    "opengl/CompositorOGL.cpp",
+0 −1
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@
#include "nsLayoutUtils.h"
#include "nsTHashSet.h"
#include "WebRenderCanvasRenderer.h"
#include "LayerTreeInvalidation.h"

namespace mozilla {
namespace layers {
+8 −66
Original line number Diff line number Diff line
@@ -163,7 +163,6 @@
#include "mozilla/layers/CompositorBridgeChild.h"
#include "gfxPlatform.h"
#include "Layers.h"
#include "LayerTreeInvalidation.h"
#include "mozilla/css/ImageLoader.h"
#include "mozilla/dom/DocumentTimeline.h"
#include "mozilla/dom/ScriptSettings.h"
@@ -6358,22 +6357,6 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
    if (!(aFlags & PaintFlags::PaintSyncDecodeImages) &&
        !frame->HasAnyStateBits(NS_FRAME_UPDATE_LAYER_TREE) &&
        !mNextPaintCompressed) {
      NotifySubDocInvalidationFunc computeInvalidFunc =
          presContext->MayHavePaintEventListenerInSubDocument()
              ? nsPresContext::NotifySubDocInvalidation
              : 0;
      bool computeInvalidRect =
          computeInvalidFunc ||
          (renderer->GetBackendType() == LayersBackend::LAYERS_BASIC);

      UniquePtr<LayerProperties> props;
      // For WR, the layermanager has no root layer. We want to avoid
      // calling ComputeDifferences in that case because it assumes non-null
      // and crashes.
      if (computeInvalidRect && layerManager && layerManager->GetRoot()) {
        props = LayerProperties::CloneFrom(layerManager->GetRoot());
      }

      if (layerManager) {
        MaybeSetupTransactionIdAllocator(layerManager, presContext);
      }
@@ -6381,31 +6364,7 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
      if (renderer->EndEmptyTransaction((aFlags & PaintFlags::PaintComposite)
                                            ? LayerManager::END_DEFAULT
                                            : LayerManager::END_NO_COMPOSITE)) {
        nsIntRegion invalid;
        bool areaOverflowed = false;
        if (props) {
          if (!props->ComputeDifferences(layerManager->GetRoot(), invalid,
                                         computeInvalidFunc)) {
            areaOverflowed = true;
          }
        } else if (layerManager) {
          LayerProperties::ClearInvalidations(layerManager->GetRoot());
        }
        if (props && !areaOverflowed) {
          if (!invalid.IsEmpty()) {
            nsIntRect bounds = invalid.GetBounds();
            nsRect rect(presContext->DevPixelsToAppUnits(bounds.x),
                        presContext->DevPixelsToAppUnits(bounds.y),
                        presContext->DevPixelsToAppUnits(bounds.width),
                        presContext->DevPixelsToAppUnits(bounds.height));
        if (shouldInvalidate) {
              aViewToPaint->GetViewManager()->InvalidateViewNoSuppression(
                  aViewToPaint, rect);
            }
            presContext->NotifyInvalidation(
                layerManager->GetLastTransactionId(), bounds);
          }
        } else if (shouldInvalidate) {
          aViewToPaint->GetViewManager()->InvalidateView(aViewToPaint);
        }

@@ -6448,19 +6407,7 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,

  bgcolor = NS_ComposeColors(bgcolor, mCanvasBackgroundColor);

  if (!layerManager) {
    FallbackRenderer* fallback = renderer->AsFallback();
    MOZ_ASSERT(fallback);

    if (aFlags & PaintFlags::PaintComposite) {
      nsIntRect bounds = presContext->GetVisibleArea().ToOutsidePixels(
          presContext->AppUnitsPerDevPixel());
      fallback->EndTransactionWithColor(bounds, ToDeviceColor(bgcolor));
    }
    return;
  }

  if (layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) {
  if (renderer->GetBackendType() == layers::LayersBackend::LAYERS_WR) {
    LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
        presContext->GetVisibleArea(), presContext->AppUnitsPerDevPixel());
    WebRenderBackgroundData data(wr::ToLayoutRect(bounds),
@@ -6473,19 +6420,14 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
    return;
  }

  RefPtr<ColorLayer> root = layerManager->CreateColorLayer();
  if (root) {
  FallbackRenderer* fallback = renderer->AsFallback();
  MOZ_ASSERT(fallback);

  if (aFlags & PaintFlags::PaintComposite) {
    nsIntRect bounds = presContext->GetVisibleArea().ToOutsidePixels(
        presContext->AppUnitsPerDevPixel());
    root->SetColor(ToDeviceColor(bgcolor));
    root->SetVisibleRegion(LayerIntRegion::FromUnknownRegion(bounds));
    layerManager->SetRoot(root);
    fallback->EndTransactionWithColor(bounds, ToDeviceColor(bgcolor));
  }
  MaybeSetupTransactionIdAllocator(layerManager, presContext);
  layerManager->EndTransaction(nullptr, nullptr,
                               (aFlags & PaintFlags::PaintComposite)
                                   ? LayerManager::END_DEFAULT
                                   : LayerManager::END_NO_COMPOSITE);
}

// static
Loading