author Jeff Muizelaar <>
Fri, 01 Dec 2017 22:20:33 -0500
changeset 706825 da64771ef8457997534d1b612388443ae3894c27
parent 699543 24b517065b548f0f4d443d795a972a4485b7e08f
child 706843 42f7090fc804dedbef50d8250f78a1055ee86ac9
permissions -rw-r--r--
Bug 1422414. Remove unused StackingContextHelper::mOrigin. r=mstange Now that ToRelativeLayoutPoint does no math we should be able to eliminate a copy of the glyph buffer. MozReview-Commit-ID: 1o6awTyE95v

/* -*- 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 */


#include "mozilla/Attributes.h"
#include "mozilla/gfx/MatrixFwd.h"
#include "mozilla/webrender/WebRenderAPI.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "Units.h"

class nsDisplayListBuilder;
class nsDisplayItem;
class nsDisplayList;

namespace mozilla {
namespace layers {

 * This is a helper class that pushes/pops a stacking context, and manages
 * some of the coordinate space transformations needed.
class MOZ_RAII StackingContextHelper
  StackingContextHelper(const StackingContextHelper& aParentSC,
                        wr::DisplayListBuilder& aBuilder,
                        const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>(),
                        const gfx::Matrix4x4* aBoundTransform = nullptr,
                        const wr::WrAnimationProperty* aAnimation = nullptr,
                        float* aOpacityPtr = nullptr,
                        gfx::Matrix4x4* aTransformPtr = nullptr,
                        gfx::Matrix4x4* aPerspectivePtr = nullptr,
                        const gfx::CompositionOp& aMixBlendMode = gfx::CompositionOp::OP_OVER,
                        bool aBackfaceVisible = true,
                        bool aIsPreserve3D = false);
  // This version of the constructor should only be used at the root level
  // of the tree, so that we have a StackingContextHelper to pass down into
  // the RenderLayer traversal, but don't actually want it to push a stacking
  // context on the display list builder.

  // Pops the stacking context, if one was pushed during the constructor.

  // When this StackingContextHelper is in scope, this function can be used
  // to convert a rect from the layer system's coordinate space to a LayoutRect
  // that is relative to the stacking context. This is useful because most
  // things that are pushed inside the stacking context need to be relative
  // to the stacking context.
  // We allow passing in a LayoutDeviceRect for convenience because in a lot of
  // cases with WebRender display item generate the layout device space is the
  // same as the layer space. (TODO: try to make this more explicit somehow).
  // We also round the rectangle to ints after transforming since the output
  // is the final destination rect.
  wr::LayoutRect ToRelativeLayoutRect(const LayoutDeviceRect& aRect) const;
  // Same but for points
  wr::LayoutPoint ToRelativeLayoutPoint(const LayoutDevicePoint& aPoint) const
    return wr::ToLayoutPoint(aPoint);

  // Export the inherited scale
  gfx::Size GetInheritedScale() const { return mScale; }

  bool IsBackfaceVisible() const { return mTransform.IsBackfaceVisible(); }

  wr::DisplayListBuilder* mBuilder;
  gfx::Matrix4x4 mTransform;
  gfx::Size mScale;

} // namespace layers
} // namespace mozilla