2012-08-29 09:47:18 +04:00
|
|
|
/*-*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#include "LayerTreeInvalidation.h"
|
2015-06-07 12:27:06 +03:00
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <stdint.h> // for uint32_t
|
|
|
|
#include "ImageContainer.h" // for ImageContainer
|
|
|
|
#include "ImageLayers.h" // for ImageLayer, etc
|
|
|
|
#include "Layers.h" // for Layer, ContainerLayer, etc
|
2015-04-12 05:03:00 +03:00
|
|
|
#include "Units.h" // for ParentLayerIntRect
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxRect.h" // for gfxRect
|
|
|
|
#include "gfxUtils.h" // for gfxUtils
|
|
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
2013-12-20 20:46:29 +04:00
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/mozalloc.h" // for operator new, etc
|
|
|
|
#include "nsDataHashtable.h" // for nsDataHashtable
|
|
|
|
#include "nsDebug.h" // for NS_ASSERTION
|
|
|
|
#include "nsHashKeys.h" // for nsPtrHashKey
|
|
|
|
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
|
2015-04-21 18:04:57 +03:00
|
|
|
#include "nsRect.h" // for IntRect
|
2016-02-02 18:36:30 +03:00
|
|
|
#include "nsTArray.h" // for AutoTArray, nsTArray_Impl
|
2016-04-28 01:57:44 +03:00
|
|
|
#include "mozilla/Poison.h"
|
2015-06-07 12:27:06 +03:00
|
|
|
#include "mozilla/layers/ImageHost.h"
|
|
|
|
#include "mozilla/layers/LayerManagerComposite.h"
|
2016-03-10 12:20:40 +03:00
|
|
|
#include "TreeTraversal.h" // for ForEachNode
|
2016-12-13 23:56:26 +03:00
|
|
|
#include "LayersLogging.h"
|
|
|
|
|
|
|
|
// LayerTreeInvalidation debugging
|
|
|
|
#define LTI_DEBUG 0
|
|
|
|
|
|
|
|
#if LTI_DEBUG
|
|
|
|
# define LTI_DEEPER(aPrefix) nsPrintfCString("%s ", aPrefix).get()
|
|
|
|
# define LTI_DUMP(rgn, label) if (!(rgn).IsEmpty()) printf_stderr("%s%p: " label " portion is %s\n", aPrefix, mLayer.get(), Stringify(rgn).c_str());
|
|
|
|
# define LTI_LOG(...) printf_stderr(__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
# define LTI_DEEPER(aPrefix) nullptr
|
|
|
|
# define LTI_DUMP(rgn, label)
|
|
|
|
# define LTI_LOG(...)
|
|
|
|
#endif
|
2012-08-29 09:47:18 +04:00
|
|
|
|
2014-08-01 16:31:47 +04:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2012-08-29 09:47:18 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
struct LayerPropertiesBase;
|
2016-03-25 06:49:00 +03:00
|
|
|
UniquePtr<LayerPropertiesBase> CloneLayerTreePropertiesInternal(Layer* aRoot, bool aIsMask = false);
|
2012-08-29 09:47:18 +04:00
|
|
|
|
2015-11-02 20:28:00 +03:00
|
|
|
/**
|
|
|
|
* Get accumulated transform of from the context creating layer to the
|
|
|
|
* given layer.
|
|
|
|
*/
|
|
|
|
static Matrix4x4
|
|
|
|
GetTransformIn3DContext(Layer* aLayer) {
|
|
|
|
Matrix4x4 transform = aLayer->GetLocalTransform();
|
|
|
|
for (Layer* layer = aLayer->GetParent();
|
|
|
|
layer && layer->Extend3DContext();
|
|
|
|
layer = layer->GetParent()) {
|
|
|
|
transform = transform * layer->GetLocalTransform();
|
|
|
|
}
|
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a transform for the given layer depending on extending 3D
|
|
|
|
* context.
|
|
|
|
*
|
|
|
|
* @return local transform for layers not participating 3D rendering
|
|
|
|
* context, or the accmulated transform in the context for else.
|
|
|
|
*/
|
|
|
|
static Matrix4x4
|
|
|
|
GetTransformForInvalidation(Layer* aLayer) {
|
|
|
|
return (!aLayer->Is3DContextLeaf() && !aLayer->Extend3DContext() ?
|
|
|
|
aLayer->GetLocalTransform() : GetTransformIn3DContext(aLayer));
|
|
|
|
}
|
|
|
|
|
2015-04-21 18:04:57 +03:00
|
|
|
static IntRect
|
|
|
|
TransformRect(const IntRect& aRect, const Matrix4x4& aTransform)
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
|
|
|
if (aRect.IsEmpty()) {
|
2015-04-21 18:04:57 +03:00
|
|
|
return IntRect();
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2014-08-01 16:31:47 +04:00
|
|
|
Rect rect(aRect.x, aRect.y, aRect.width, aRect.height);
|
2015-08-07 03:26:09 +03:00
|
|
|
rect = aTransform.TransformAndClipBounds(rect, Rect::MaxIntRect());
|
2012-08-29 09:47:18 +04:00
|
|
|
rect.RoundOut();
|
|
|
|
|
2015-04-21 18:04:57 +03:00
|
|
|
IntRect intRect;
|
2014-08-01 16:31:47 +04:00
|
|
|
if (!gfxUtils::GfxRectToIntRect(ThebesRect(rect), &intRect)) {
|
2015-04-21 18:04:57 +03:00
|
|
|
return IntRect();
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return intRect;
|
|
|
|
}
|
|
|
|
|
2012-11-12 22:31:15 +04:00
|
|
|
static void
|
2014-08-01 16:31:47 +04:00
|
|
|
AddTransformedRegion(nsIntRegion& aDest, const nsIntRegion& aSource, const Matrix4x4& aTransform)
|
2012-11-12 22:31:15 +04:00
|
|
|
{
|
2016-01-19 04:20:58 +03:00
|
|
|
for (auto iter = aSource.RectIter(); !iter.Done(); iter.Next()) {
|
|
|
|
aDest.Or(aDest, TransformRect(iter.Get(), aTransform));
|
2012-11-12 22:31:15 +04:00
|
|
|
}
|
2014-04-28 08:17:31 +04:00
|
|
|
aDest.SimplifyOutward(20);
|
2012-11-12 22:31:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
AddRegion(nsIntRegion& aDest, const nsIntRegion& aSource)
|
|
|
|
{
|
|
|
|
aDest.Or(aDest, aSource);
|
2014-04-28 08:17:31 +04:00
|
|
|
aDest.SimplifyOutward(20);
|
2012-11-12 22:31:15 +04:00
|
|
|
}
|
|
|
|
|
2012-08-29 09:47:18 +04:00
|
|
|
/**
|
|
|
|
* Walks over this layer, and all descendant layers.
|
|
|
|
* If any of these are a ContainerLayer that reports invalidations to a PresShell,
|
|
|
|
* then report that the entire bounds have changed.
|
|
|
|
*/
|
|
|
|
static void
|
2016-03-10 12:20:40 +03:00
|
|
|
NotifySubdocumentInvalidation(Layer* aLayer, NotifySubDocInvalidationFunc aCallback)
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
2016-03-10 12:20:40 +03:00
|
|
|
ForEachNode<ForwardIterator>(
|
|
|
|
aLayer,
|
|
|
|
[aCallback] (Layer* layer)
|
|
|
|
{
|
2017-06-20 11:17:21 +03:00
|
|
|
layer->ClearInvalidRegion();
|
2016-03-10 12:20:40 +03:00
|
|
|
if (layer->GetMaskLayer()) {
|
|
|
|
NotifySubdocumentInvalidation(layer->GetMaskLayer(), aCallback);
|
|
|
|
}
|
|
|
|
for (size_t i = 0; i < layer->GetAncestorMaskLayerCount(); i++) {
|
|
|
|
Layer* maskLayer = layer->GetAncestorMaskLayerAt(i);
|
|
|
|
NotifySubdocumentInvalidation(maskLayer, aCallback);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
[aCallback] (Layer* layer)
|
|
|
|
{
|
|
|
|
ContainerLayer* container = layer->AsContainerLayer();
|
|
|
|
if (container) {
|
|
|
|
aCallback(container, container->GetLocalVisibleRegion().ToUnknownRegion());
|
|
|
|
}
|
|
|
|
});
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct LayerPropertiesBase : public LayerProperties
|
|
|
|
{
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit LayerPropertiesBase(Layer* aLayer)
|
2012-08-29 09:47:18 +04:00
|
|
|
: mLayer(aLayer)
|
|
|
|
, mMaskLayer(nullptr)
|
2016-02-14 03:50:51 +03:00
|
|
|
, mVisibleRegion(mLayer->GetLocalVisibleRegion().ToUnknownRegion())
|
2014-05-12 23:37:20 +04:00
|
|
|
, mPostXScale(aLayer->GetPostXScale())
|
|
|
|
, mPostYScale(aLayer->GetPostYScale())
|
2014-04-04 05:59:13 +04:00
|
|
|
, mOpacity(aLayer->GetLocalOpacity())
|
2016-05-02 18:27:35 +03:00
|
|
|
, mUseClipRect(!!aLayer->GetLocalClipRect())
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(LayerPropertiesBase);
|
|
|
|
if (aLayer->GetMaskLayer()) {
|
2016-03-25 06:49:00 +03:00
|
|
|
mMaskLayer = CloneLayerTreePropertiesInternal(aLayer->GetMaskLayer(), true);
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
2015-06-21 19:27:31 +03:00
|
|
|
for (size_t i = 0; i < aLayer->GetAncestorMaskLayerCount(); i++) {
|
|
|
|
Layer* maskLayer = aLayer->GetAncestorMaskLayerAt(i);
|
2016-03-25 06:49:00 +03:00
|
|
|
mAncestorMaskLayers.AppendElement(CloneLayerTreePropertiesInternal(maskLayer, true));
|
2015-06-21 19:27:31 +03:00
|
|
|
}
|
2012-08-29 09:47:18 +04:00
|
|
|
if (mUseClipRect) {
|
2016-05-02 18:27:35 +03:00
|
|
|
mClipRect = *aLayer->GetLocalClipRect();
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
2015-11-02 20:28:00 +03:00
|
|
|
mTransform = GetTransformForInvalidation(aLayer);
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
LayerPropertiesBase()
|
|
|
|
: mLayer(nullptr)
|
|
|
|
, mMaskLayer(nullptr)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(LayerPropertiesBase);
|
|
|
|
}
|
2016-11-15 12:16:29 +03:00
|
|
|
~LayerPropertiesBase() override
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(LayerPropertiesBase);
|
|
|
|
}
|
2015-04-21 18:04:57 +03:00
|
|
|
|
2016-09-07 22:21:20 +03:00
|
|
|
protected:
|
|
|
|
LayerPropertiesBase(const LayerPropertiesBase& a) = delete;
|
|
|
|
LayerPropertiesBase& operator=(const LayerPropertiesBase& a) = delete;
|
|
|
|
|
|
|
|
public:
|
2017-08-04 07:22:48 +03:00
|
|
|
bool ComputeDifferences(Layer* aRoot,
|
|
|
|
nsIntRegion& aOutRegion,
|
|
|
|
NotifySubDocInvalidationFunc aCallback) override;
|
2012-08-29 09:47:18 +04:00
|
|
|
|
2016-11-15 12:16:29 +03:00
|
|
|
void MoveBy(const IntPoint& aOffset) override;
|
2012-09-17 02:57:22 +04:00
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
bool ComputeChange(const char* aPrefix,
|
|
|
|
nsIntRegion& aOutRegion,
|
|
|
|
NotifySubDocInvalidationFunc aCallback)
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
2016-08-04 00:08:40 +03:00
|
|
|
// Bug 1251615: This canary is sometimes hit. We're still not sure why.
|
2016-04-28 01:57:44 +03:00
|
|
|
mCanary.Check();
|
2016-03-21 23:16:52 +03:00
|
|
|
bool transformChanged = !mTransform.FuzzyEqual(GetTransformForInvalidation(mLayer)) ||
|
2015-11-02 20:28:00 +03:00
|
|
|
mLayer->GetPostXScale() != mPostXScale ||
|
|
|
|
mLayer->GetPostYScale() != mPostYScale;
|
2016-05-02 18:27:35 +03:00
|
|
|
const Maybe<ParentLayerIntRect>& otherClip = mLayer->GetLocalClipRect();
|
2012-11-12 22:31:15 +04:00
|
|
|
nsIntRegion result;
|
2015-06-21 19:27:31 +03:00
|
|
|
|
|
|
|
bool ancestorMaskChanged = mAncestorMaskLayers.Length() != mLayer->GetAncestorMaskLayerCount();
|
|
|
|
if (!ancestorMaskChanged) {
|
|
|
|
for (size_t i = 0; i < mAncestorMaskLayers.Length(); i++) {
|
|
|
|
if (mLayer->GetAncestorMaskLayerAt(i) != mAncestorMaskLayers[i]->mLayer) {
|
|
|
|
ancestorMaskChanged = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
bool areaOverflowed = false;
|
|
|
|
|
2015-06-21 19:27:31 +03:00
|
|
|
Layer* otherMask = mLayer->GetMaskLayer();
|
2012-08-29 09:47:18 +04:00
|
|
|
if ((mMaskLayer ? mMaskLayer->mLayer : nullptr) != otherMask ||
|
2015-06-21 19:27:31 +03:00
|
|
|
ancestorMaskChanged ||
|
2012-08-29 09:47:18 +04:00
|
|
|
(mUseClipRect != !!otherClip) ||
|
2014-04-04 05:59:13 +04:00
|
|
|
mLayer->GetLocalOpacity() != mOpacity ||
|
2016-05-02 18:27:35 +03:00
|
|
|
transformChanged)
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
|
|
|
result = OldTransformedBounds();
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(result, "oldtransform");
|
|
|
|
LTI_DUMP(NewTransformedBounds(), "newtransform");
|
2014-06-11 01:46:42 +04:00
|
|
|
AddRegion(result, NewTransformedBounds());
|
2016-03-25 06:49:00 +03:00
|
|
|
|
2014-11-19 01:33:36 +03:00
|
|
|
// We can't bail out early because we need to update mChildrenChanged.
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
nsIntRegion internal;
|
2017-08-04 07:22:48 +03:00
|
|
|
if (!ComputeChangeInternal(aPrefix, internal, aCallback)) {
|
|
|
|
areaOverflowed = true;
|
|
|
|
}
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(internal, "internal");
|
|
|
|
AddRegion(result, internal);
|
|
|
|
LTI_DUMP(mLayer->GetInvalidRegion().GetRegion(), "invalid");
|
2016-04-18 20:49:14 +03:00
|
|
|
AddTransformedRegion(result, mLayer->GetInvalidRegion().GetRegion(), mTransform);
|
2012-08-29 09:47:18 +04:00
|
|
|
|
|
|
|
if (mMaskLayer && otherMask) {
|
2017-08-04 07:22:48 +03:00
|
|
|
nsIntRegion mask;
|
|
|
|
if (!mMaskLayer->ComputeChange(aPrefix, mask, aCallback)) {
|
|
|
|
areaOverflowed = true;
|
|
|
|
}
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(mask, "mask");
|
|
|
|
AddTransformedRegion(result, mask, mTransform);
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2015-06-21 19:27:31 +03:00
|
|
|
for (size_t i = 0;
|
|
|
|
i < std::min(mAncestorMaskLayers.Length(), mLayer->GetAncestorMaskLayerCount());
|
|
|
|
i++)
|
|
|
|
{
|
2017-08-04 07:22:48 +03:00
|
|
|
nsIntRegion mask;
|
|
|
|
if (!mAncestorMaskLayers[i]->ComputeChange(aPrefix, mask, aCallback)) {
|
|
|
|
areaOverflowed = true;
|
|
|
|
}
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(mask, "ancestormask");
|
|
|
|
AddTransformedRegion(result, mask, mTransform);
|
2015-06-21 19:27:31 +03:00
|
|
|
}
|
|
|
|
|
2012-08-29 09:47:18 +04:00
|
|
|
if (mUseClipRect && otherClip) {
|
|
|
|
if (!mClipRect.IsEqualInterior(*otherClip)) {
|
2016-05-02 18:27:35 +03:00
|
|
|
nsIntRegion tmp;
|
2015-11-07 06:13:40 +03:00
|
|
|
tmp.Xor(mClipRect.ToUnknownRect(), otherClip->ToUnknownRect());
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(tmp, "clip");
|
2012-11-12 22:31:15 +04:00
|
|
|
AddRegion(result, tmp);
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-20 11:17:21 +03:00
|
|
|
mLayer->ClearInvalidRegion();
|
2017-08-04 07:22:48 +03:00
|
|
|
|
|
|
|
if (areaOverflowed) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
aOutRegion = Move(result);
|
|
|
|
return true;
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2016-08-04 00:08:40 +03:00
|
|
|
void CheckCanary()
|
|
|
|
{
|
|
|
|
mCanary.Check();
|
|
|
|
mLayer->CheckCanary();
|
|
|
|
}
|
|
|
|
|
2016-02-12 01:35:35 +03:00
|
|
|
virtual IntRect NewTransformedBounds()
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
2016-02-13 04:24:38 +03:00
|
|
|
return TransformRect(mLayer->GetLocalVisibleRegion().ToUnknownRegion().GetBounds(),
|
2015-11-02 20:28:00 +03:00
|
|
|
GetTransformForInvalidation(mLayer));
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2016-02-12 01:35:35 +03:00
|
|
|
virtual IntRect OldTransformedBounds()
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
2015-11-29 10:07:55 +03:00
|
|
|
return TransformRect(mVisibleRegion.ToUnknownRegion().GetBounds(), mTransform);
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
virtual bool ComputeChangeInternal(const char* aPrefix,
|
|
|
|
nsIntRegion& aOutRegion,
|
|
|
|
NotifySubDocInvalidationFunc aCallback)
|
2014-04-04 05:59:13 +04:00
|
|
|
{
|
2017-08-04 07:22:48 +03:00
|
|
|
return true;
|
2014-04-04 05:59:13 +04:00
|
|
|
}
|
2012-08-29 09:47:18 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Layer> mLayer;
|
2014-08-25 19:09:39 +04:00
|
|
|
UniquePtr<LayerPropertiesBase> mMaskLayer;
|
2015-06-21 19:27:31 +03:00
|
|
|
nsTArray<UniquePtr<LayerPropertiesBase>> mAncestorMaskLayers;
|
2012-10-01 07:38:46 +04:00
|
|
|
nsIntRegion mVisibleRegion;
|
2014-08-01 16:31:47 +04:00
|
|
|
Matrix4x4 mTransform;
|
2014-05-12 23:37:20 +04:00
|
|
|
float mPostXScale;
|
|
|
|
float mPostYScale;
|
2012-08-29 09:47:18 +04:00
|
|
|
float mOpacity;
|
2015-04-12 05:03:00 +03:00
|
|
|
ParentLayerIntRect mClipRect;
|
2012-08-29 09:47:18 +04:00
|
|
|
bool mUseClipRect;
|
2016-04-28 01:57:44 +03:00
|
|
|
mozilla::CorruptionCanary mCanary;
|
2012-08-29 09:47:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ContainerLayerProperties : public LayerPropertiesBase
|
|
|
|
{
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit ContainerLayerProperties(ContainerLayer* aLayer)
|
2012-08-29 09:47:18 +04:00
|
|
|
: LayerPropertiesBase(aLayer)
|
2014-05-12 23:37:20 +04:00
|
|
|
, mPreXScale(aLayer->GetPreXScale())
|
|
|
|
, mPreYScale(aLayer->GetPreYScale())
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
|
|
|
for (Layer* child = aLayer->GetFirstChild(); child; child = child->GetNextSibling()) {
|
2016-04-28 01:57:44 +03:00
|
|
|
child->CheckCanary();
|
2014-08-25 19:09:39 +04:00
|
|
|
mChildren.AppendElement(Move(CloneLayerTreePropertiesInternal(child)));
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-07 22:21:20 +03:00
|
|
|
protected:
|
|
|
|
ContainerLayerProperties(const ContainerLayerProperties& a) = delete;
|
|
|
|
ContainerLayerProperties& operator=(const ContainerLayerProperties& a) = delete;
|
|
|
|
|
|
|
|
public:
|
2017-08-04 07:22:48 +03:00
|
|
|
bool ComputeChangeInternal(const char *aPrefix,
|
|
|
|
nsIntRegion& aOutRegion,
|
|
|
|
NotifySubDocInvalidationFunc aCallback) override
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
2016-08-04 00:08:40 +03:00
|
|
|
// Make sure we got our virtual call right
|
|
|
|
mSubtypeCanary.Check();
|
2012-08-29 09:47:18 +04:00
|
|
|
ContainerLayer* container = mLayer->AsContainerLayer();
|
2015-11-02 20:28:00 +03:00
|
|
|
nsIntRegion invalidOfLayer; // Invalid regions of this layer.
|
|
|
|
nsIntRegion result; // Invliad regions for children only.
|
2012-08-29 09:47:18 +04:00
|
|
|
|
2016-04-28 01:57:44 +03:00
|
|
|
container->CheckCanary();
|
|
|
|
|
2014-11-19 01:33:36 +03:00
|
|
|
bool childrenChanged = false;
|
2017-06-20 11:17:21 +03:00
|
|
|
bool invalidateWholeLayer = false;
|
2014-05-12 23:37:20 +04:00
|
|
|
if (mPreXScale != container->GetPreXScale() ||
|
|
|
|
mPreYScale != container->GetPreYScale()) {
|
2015-11-02 20:28:00 +03:00
|
|
|
invalidOfLayer = OldTransformedBounds();
|
|
|
|
AddRegion(invalidOfLayer, NewTransformedBounds());
|
2014-11-19 01:33:36 +03:00
|
|
|
childrenChanged = true;
|
2017-06-20 11:17:21 +03:00
|
|
|
invalidateWholeLayer = true;
|
2014-05-12 23:37:20 +04:00
|
|
|
|
2014-11-19 01:33:36 +03:00
|
|
|
// Can't bail out early, we need to update the child container layers
|
2014-05-12 23:37:20 +04:00
|
|
|
}
|
|
|
|
|
2012-11-21 06:23:57 +04:00
|
|
|
// A low frame rate is especially visible to users when scrolling, so we
|
|
|
|
// particularly want to avoid unnecessary invalidation at that time. For us
|
|
|
|
// here, that means avoiding unnecessary invalidation of child items when
|
|
|
|
// other children are added to or removed from our container layer, since
|
|
|
|
// that may be caused by children being scrolled in or out of view. We are
|
|
|
|
// less concerned with children changing order.
|
|
|
|
// TODO: Consider how we could avoid unnecessary invalidation when children
|
|
|
|
// change order, and whether the overhead would be worth it.
|
|
|
|
|
2013-09-02 12:41:57 +04:00
|
|
|
nsDataHashtable<nsPtrHashKey<Layer>, uint32_t> oldIndexMap(mChildren.Length());
|
2012-11-21 06:23:57 +04:00
|
|
|
for (uint32_t i = 0; i < mChildren.Length(); ++i) {
|
2016-08-04 00:08:40 +03:00
|
|
|
mChildren[i]->CheckCanary();
|
2012-11-21 06:23:57 +04:00
|
|
|
oldIndexMap.Put(mChildren[i]->mLayer, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t i = 0; // cursor into the old child list mChildren
|
2012-08-29 09:47:18 +04:00
|
|
|
for (Layer* child = container->GetFirstChild(); child; child = child->GetNextSibling()) {
|
2012-11-21 06:23:57 +04:00
|
|
|
bool invalidateChildsCurrentArea = false;
|
|
|
|
if (i < mChildren.Length()) {
|
|
|
|
uint32_t childsOldIndex;
|
|
|
|
if (oldIndexMap.Get(child, &childsOldIndex)) {
|
|
|
|
if (childsOldIndex >= i) {
|
|
|
|
// Invalidate the old areas of layers that used to be between the
|
|
|
|
// current |child| and the previous |child| that was also in the
|
|
|
|
// old list mChildren (if any of those children have been reordered
|
|
|
|
// rather than removed, we will invalidate their new area when we
|
|
|
|
// encounter them in the new list):
|
|
|
|
for (uint32_t j = i; j < childsOldIndex; ++j) {
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(mChildren[j]->OldTransformedBounds(), "reordered child");
|
2012-11-21 06:23:57 +04:00
|
|
|
AddRegion(result, mChildren[j]->OldTransformedBounds());
|
2014-11-19 01:33:36 +03:00
|
|
|
childrenChanged |= true;
|
2012-11-21 06:23:57 +04:00
|
|
|
}
|
2016-08-04 00:08:40 +03:00
|
|
|
if (childsOldIndex >= mChildren.Length()) {
|
|
|
|
MOZ_CRASH("Out of bounds");
|
|
|
|
}
|
2014-11-19 01:33:36 +03:00
|
|
|
// Invalidate any regions of the child that have changed:
|
2017-08-04 07:22:48 +03:00
|
|
|
nsIntRegion region;
|
|
|
|
mChildren[childsOldIndex]->ComputeChange(LTI_DEEPER(aPrefix), region, aCallback);
|
2012-11-21 06:23:57 +04:00
|
|
|
i = childsOldIndex + 1;
|
2014-11-19 01:33:36 +03:00
|
|
|
if (!region.IsEmpty()) {
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_LOG("%s%p: child %p produced %s\n", aPrefix, mLayer.get(),
|
|
|
|
mChildren[childsOldIndex]->mLayer.get(), Stringify(region).c_str());
|
2014-11-19 01:33:36 +03:00
|
|
|
AddRegion(result, region);
|
|
|
|
childrenChanged |= true;
|
|
|
|
}
|
2012-11-21 06:23:57 +04:00
|
|
|
} else {
|
|
|
|
// We've already seen this child in mChildren (which means it must
|
2014-11-19 01:33:36 +03:00
|
|
|
// have been reordered) and invalidated its old area. We need to
|
2012-11-21 06:23:57 +04:00
|
|
|
// invalidate its new area too:
|
|
|
|
invalidateChildsCurrentArea = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// |child| is new
|
|
|
|
invalidateChildsCurrentArea = true;
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
2012-11-21 06:23:57 +04:00
|
|
|
} else {
|
|
|
|
// |child| is new, or was reordered to a higher index
|
|
|
|
invalidateChildsCurrentArea = true;
|
|
|
|
}
|
|
|
|
if (invalidateChildsCurrentArea) {
|
2017-08-04 07:22:48 +03:00
|
|
|
LTI_DUMP(child->GetLocalVisibleRegion().ToUnknownRegion(), "invalidateChildsCurrentArea");
|
2016-02-13 04:24:38 +03:00
|
|
|
AddTransformedRegion(result, child->GetLocalVisibleRegion().ToUnknownRegion(),
|
2015-11-02 20:28:00 +03:00
|
|
|
GetTransformForInvalidation(child));
|
2012-08-29 09:47:18 +04:00
|
|
|
if (aCallback) {
|
2016-03-10 12:20:40 +03:00
|
|
|
NotifySubdocumentInvalidation(child, aCallback);
|
2012-08-29 09:47:18 +04:00
|
|
|
} else {
|
|
|
|
ClearInvalidations(child);
|
|
|
|
}
|
|
|
|
}
|
2014-11-19 01:33:36 +03:00
|
|
|
childrenChanged |= invalidateChildsCurrentArea;
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Process remaining removed children.
|
|
|
|
while (i < mChildren.Length()) {
|
2014-11-19 01:33:36 +03:00
|
|
|
childrenChanged |= true;
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(mChildren[i]->OldTransformedBounds(), "removed child");
|
2012-11-12 22:31:15 +04:00
|
|
|
AddRegion(result, mChildren[i]->OldTransformedBounds());
|
2012-08-29 09:47:18 +04:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aCallback) {
|
|
|
|
aCallback(container, result);
|
|
|
|
}
|
|
|
|
|
2014-11-19 01:33:36 +03:00
|
|
|
if (childrenChanged) {
|
|
|
|
container->SetChildrenChanged(true);
|
|
|
|
}
|
|
|
|
|
2017-06-20 11:17:21 +03:00
|
|
|
if (container->UseIntermediateSurface()) {
|
2017-07-31 22:29:18 +03:00
|
|
|
Maybe<IntRect> bounds;
|
|
|
|
|
|
|
|
if (!invalidateWholeLayer) {
|
|
|
|
bounds = Some(result.GetBounds());
|
|
|
|
|
|
|
|
// Process changes in the visible region.
|
|
|
|
IntRegion newVisible = mLayer->GetLocalVisibleRegion().ToUnknownRegion();
|
|
|
|
if (!newVisible.IsEqual(mVisibleRegion)) {
|
|
|
|
newVisible.XorWith(mVisibleRegion);
|
|
|
|
bounds = bounds->SafeUnion(newVisible.GetBounds());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!bounds) {
|
|
|
|
bounds = Some(mLayer->GetLocalVisibleRegion().GetBounds().ToUnknownRect());
|
|
|
|
}
|
|
|
|
container->SetInvalidCompositeRect(bounds.value());
|
2017-06-20 11:17:21 +03:00
|
|
|
}
|
|
|
|
|
2015-11-02 20:28:00 +03:00
|
|
|
if (!mLayer->Extend3DContext()) {
|
|
|
|
// |result| contains invalid regions only of children.
|
|
|
|
result.Transform(GetTransformForInvalidation(mLayer));
|
|
|
|
}
|
|
|
|
// else, effective transforms have applied on children.
|
|
|
|
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(invalidOfLayer, "invalidOfLayer");
|
2015-11-02 20:28:00 +03:00
|
|
|
result.OrWith(invalidOfLayer);
|
2017-08-04 07:22:48 +03:00
|
|
|
|
|
|
|
aOutRegion = Move(result);
|
|
|
|
return true;
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2016-02-12 01:35:35 +03:00
|
|
|
IntRect NewTransformedBounds() override
|
|
|
|
{
|
|
|
|
if (mLayer->Extend3DContext()) {
|
|
|
|
IntRect result;
|
|
|
|
for (UniquePtr<LayerPropertiesBase>& child : mChildren) {
|
|
|
|
result = result.Union(child->NewTransformedBounds());
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LayerPropertiesBase::NewTransformedBounds();
|
|
|
|
}
|
|
|
|
|
|
|
|
IntRect OldTransformedBounds() override
|
|
|
|
{
|
|
|
|
if (mLayer->Extend3DContext()) {
|
|
|
|
IntRect result;
|
|
|
|
for (UniquePtr<LayerPropertiesBase>& child : mChildren) {
|
|
|
|
result = result.Union(child->OldTransformedBounds());
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return LayerPropertiesBase::OldTransformedBounds();
|
|
|
|
}
|
|
|
|
|
2012-11-21 06:23:57 +04:00
|
|
|
// The old list of children:
|
2016-08-04 00:08:40 +03:00
|
|
|
mozilla::CorruptionCanary mSubtypeCanary;
|
|
|
|
nsTArray<UniquePtr<LayerPropertiesBase>> mChildren;
|
2014-05-12 23:37:20 +04:00
|
|
|
float mPreXScale;
|
|
|
|
float mPreYScale;
|
2012-08-29 09:47:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ColorLayerProperties : public LayerPropertiesBase
|
|
|
|
{
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit ColorLayerProperties(ColorLayer *aLayer)
|
2012-08-29 09:47:18 +04:00
|
|
|
: LayerPropertiesBase(aLayer)
|
|
|
|
, mColor(aLayer->GetColor())
|
2014-09-24 01:47:36 +04:00
|
|
|
, mBounds(aLayer->GetBounds())
|
2012-08-29 09:47:18 +04:00
|
|
|
{ }
|
|
|
|
|
2016-09-07 22:21:20 +03:00
|
|
|
protected:
|
|
|
|
ColorLayerProperties(const ColorLayerProperties& a) = delete;
|
|
|
|
ColorLayerProperties& operator=(const ColorLayerProperties& a) = delete;
|
|
|
|
|
|
|
|
public:
|
2017-08-04 07:22:48 +03:00
|
|
|
bool ComputeChangeInternal(const char* aPrefix,
|
|
|
|
nsIntRegion& aOutRegion,
|
|
|
|
NotifySubDocInvalidationFunc aCallback) override
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
|
|
|
ColorLayer* color = static_cast<ColorLayer*>(mLayer.get());
|
|
|
|
|
|
|
|
if (mColor != color->GetColor()) {
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(NewTransformedBounds(), "color");
|
2017-08-04 07:22:48 +03:00
|
|
|
aOutRegion = NewTransformedBounds();
|
|
|
|
return true;
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-24 01:47:36 +04:00
|
|
|
nsIntRegion boundsDiff;
|
|
|
|
boundsDiff.Xor(mBounds, color->GetBounds());
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(boundsDiff, "colorbounds");
|
2014-09-24 01:47:36 +04:00
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
AddTransformedRegion(aOutRegion, boundsDiff, mTransform);
|
|
|
|
return true;
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2015-09-25 04:16:45 +03:00
|
|
|
Color mColor;
|
2015-04-21 18:04:57 +03:00
|
|
|
IntRect mBounds;
|
2012-08-29 09:47:18 +04:00
|
|
|
};
|
|
|
|
|
2017-01-18 16:48:00 +03:00
|
|
|
struct BorderLayerProperties : public LayerPropertiesBase
|
|
|
|
{
|
|
|
|
explicit BorderLayerProperties(BorderLayer *aLayer)
|
|
|
|
: LayerPropertiesBase(aLayer)
|
|
|
|
, mColors(aLayer->GetColors())
|
|
|
|
, mRect(aLayer->GetRect())
|
|
|
|
, mCorners(aLayer->GetCorners())
|
|
|
|
, mWidths(aLayer->GetWidths())
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BorderLayerProperties(const BorderLayerProperties& a) = delete;
|
|
|
|
BorderLayerProperties& operator=(const BorderLayerProperties& a) = delete;
|
|
|
|
|
|
|
|
public:
|
2017-08-04 07:22:48 +03:00
|
|
|
bool ComputeChangeInternal(const char* aPrefix,
|
|
|
|
nsIntRegion& aOutRegion,
|
|
|
|
NotifySubDocInvalidationFunc aCallback) override
|
2017-01-18 16:48:00 +03:00
|
|
|
{
|
|
|
|
BorderLayer* border = static_cast<BorderLayer*>(mLayer.get());
|
|
|
|
|
|
|
|
if (!border->GetLocalVisibleRegion().ToUnknownRegion().IsEqual(mVisibleRegion)) {
|
|
|
|
IntRect result = NewTransformedBounds();
|
|
|
|
result = result.Union(OldTransformedBounds());
|
2017-08-04 07:22:48 +03:00
|
|
|
aOutRegion = result;
|
|
|
|
return true;
|
2017-01-18 16:48:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!PodEqual(&mColors[0], &border->GetColors()[0], 4) ||
|
|
|
|
!PodEqual(&mWidths[0], &border->GetWidths()[0], 4) ||
|
|
|
|
!PodEqual(&mCorners[0], &border->GetCorners()[0], 4) ||
|
|
|
|
!mRect.IsEqualEdges(border->GetRect())) {
|
|
|
|
LTI_DUMP(NewTransformedBounds(), "bounds");
|
2017-08-04 07:22:48 +03:00
|
|
|
aOutRegion = NewTransformedBounds();
|
|
|
|
return true;
|
2017-01-18 16:48:00 +03:00
|
|
|
}
|
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
return true;
|
2017-01-18 16:48:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
BorderColors mColors;
|
|
|
|
LayerRect mRect;
|
|
|
|
BorderCorners mCorners;
|
|
|
|
BorderWidths mWidths;
|
|
|
|
};
|
|
|
|
|
2017-01-23 03:57:00 +03:00
|
|
|
struct TextLayerProperties : public LayerPropertiesBase
|
|
|
|
{
|
|
|
|
explicit TextLayerProperties(TextLayer *aLayer)
|
|
|
|
: LayerPropertiesBase(aLayer)
|
|
|
|
, mBounds(aLayer->GetBounds())
|
|
|
|
, mGlyphs(aLayer->GetGlyphs())
|
|
|
|
, mFont(aLayer->GetScaledFont())
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
TextLayerProperties(const TextLayerProperties& a) = delete;
|
|
|
|
TextLayerProperties& operator=(const TextLayerProperties& a) = delete;
|
|
|
|
|
|
|
|
public:
|
2017-08-04 07:22:48 +03:00
|
|
|
bool ComputeChangeInternal(const char* aPrefix,
|
|
|
|
nsIntRegion& aOutRegion,
|
|
|
|
NotifySubDocInvalidationFunc aCallback) override
|
2017-01-23 03:57:00 +03:00
|
|
|
{
|
|
|
|
TextLayer* text = static_cast<TextLayer*>(mLayer.get());
|
|
|
|
|
|
|
|
if (!text->GetLocalVisibleRegion().ToUnknownRegion().IsEqual(mVisibleRegion)) {
|
|
|
|
IntRect result = NewTransformedBounds();
|
|
|
|
result = result.Union(OldTransformedBounds());
|
2017-08-04 07:22:48 +03:00
|
|
|
aOutRegion = result;
|
|
|
|
return true;
|
2017-01-23 03:57:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!mBounds.IsEqualEdges(text->GetBounds()) ||
|
|
|
|
mGlyphs != text->GetGlyphs() ||
|
|
|
|
mFont != text->GetScaledFont()) {
|
|
|
|
LTI_DUMP(NewTransformedBounds(), "bounds");
|
2017-08-04 07:22:48 +03:00
|
|
|
aOutRegion = NewTransformedBounds();
|
|
|
|
return true;
|
2017-01-23 03:57:00 +03:00
|
|
|
}
|
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
return true;
|
2017-01-23 03:57:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
gfx::IntRect mBounds;
|
|
|
|
nsTArray<GlyphArray> mGlyphs;
|
|
|
|
gfx::ScaledFont* mFont;
|
|
|
|
};
|
|
|
|
|
2015-10-12 06:21:03 +03:00
|
|
|
static ImageHost* GetImageHost(Layer* aLayer)
|
2015-06-07 12:27:06 +03:00
|
|
|
{
|
2016-11-24 08:11:27 +03:00
|
|
|
HostLayer* compositor = aLayer->AsHostLayer();
|
|
|
|
if (compositor) {
|
|
|
|
return static_cast<ImageHost*>(compositor->GetCompositableHost());
|
2015-06-07 12:27:06 +03:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-08-29 09:47:18 +04:00
|
|
|
struct ImageLayerProperties : public LayerPropertiesBase
|
|
|
|
{
|
2016-03-25 06:49:00 +03:00
|
|
|
explicit ImageLayerProperties(ImageLayer* aImage, bool aIsMask)
|
2012-08-29 09:47:18 +04:00
|
|
|
: LayerPropertiesBase(aImage)
|
|
|
|
, mContainer(aImage->GetContainer())
|
2015-06-07 12:27:06 +03:00
|
|
|
, mImageHost(GetImageHost(aImage))
|
2016-05-25 19:01:18 +03:00
|
|
|
, mSamplingFilter(aImage->GetSamplingFilter())
|
2012-08-29 09:47:18 +04:00
|
|
|
, mScaleToSize(aImage->GetScaleToSize())
|
|
|
|
, mScaleMode(aImage->GetScaleMode())
|
2015-08-03 20:36:06 +03:00
|
|
|
, mLastProducerID(-1)
|
|
|
|
, mLastFrameID(-1)
|
2016-03-25 06:49:00 +03:00
|
|
|
, mIsMask(aIsMask)
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
2015-08-03 20:36:06 +03:00
|
|
|
if (mImageHost) {
|
|
|
|
mLastProducerID = mImageHost->GetLastProducerID();
|
|
|
|
mLastFrameID = mImageHost->GetLastFrameID();
|
|
|
|
}
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
bool ComputeChangeInternal(const char* aPrefix,
|
|
|
|
nsIntRegion& aOutRegion,
|
|
|
|
NotifySubDocInvalidationFunc aCallback) override
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
|
|
|
ImageLayer* imageLayer = static_cast<ImageLayer*>(mLayer.get());
|
2016-05-02 18:27:35 +03:00
|
|
|
|
2016-02-13 04:24:38 +03:00
|
|
|
if (!imageLayer->GetLocalVisibleRegion().ToUnknownRegion().IsEqual(mVisibleRegion)) {
|
2015-04-21 18:04:57 +03:00
|
|
|
IntRect result = NewTransformedBounds();
|
2012-08-29 09:47:18 +04:00
|
|
|
result = result.Union(OldTransformedBounds());
|
2017-08-04 07:22:48 +03:00
|
|
|
aOutRegion = result;
|
|
|
|
return true;
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2015-02-04 00:39:59 +03:00
|
|
|
ImageContainer* container = imageLayer->GetContainer();
|
2015-06-07 12:27:06 +03:00
|
|
|
ImageHost* host = GetImageHost(imageLayer);
|
2015-02-04 00:39:59 +03:00
|
|
|
if (mContainer != container ||
|
2016-05-25 19:01:18 +03:00
|
|
|
mSamplingFilter != imageLayer->GetSamplingFilter() ||
|
2012-08-29 09:47:18 +04:00
|
|
|
mScaleToSize != imageLayer->GetScaleToSize() ||
|
2015-06-07 12:27:06 +03:00
|
|
|
mScaleMode != imageLayer->GetScaleMode() ||
|
|
|
|
host != mImageHost ||
|
2015-08-03 20:36:06 +03:00
|
|
|
(host && host->GetProducerID() != mLastProducerID) ||
|
|
|
|
(host && host->GetFrameID() != mLastFrameID)) {
|
2015-02-04 00:39:59 +03:00
|
|
|
|
2016-03-25 06:49:00 +03:00
|
|
|
if (mIsMask) {
|
|
|
|
// Mask layers have an empty visible region, so we have to
|
|
|
|
// use the image size instead.
|
|
|
|
IntSize size;
|
|
|
|
if (container) {
|
|
|
|
size = container->GetCurrentSize();
|
|
|
|
}
|
|
|
|
if (host) {
|
|
|
|
size = host->GetImageSize();
|
|
|
|
}
|
|
|
|
IntRect rect(0, 0, size.width, size.height);
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(rect, "mask");
|
2017-08-04 07:22:48 +03:00
|
|
|
aOutRegion = TransformRect(rect, GetTransformForInvalidation(mLayer));
|
|
|
|
return true;
|
2016-03-25 06:49:00 +03:00
|
|
|
}
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(NewTransformedBounds(), "bounds");
|
2017-08-04 07:22:48 +03:00
|
|
|
aOutRegion = NewTransformedBounds();
|
|
|
|
return true;
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
return true;
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ImageContainer> mContainer;
|
|
|
|
RefPtr<ImageHost> mImageHost;
|
2016-05-25 19:01:18 +03:00
|
|
|
SamplingFilter mSamplingFilter;
|
2013-12-20 20:46:29 +04:00
|
|
|
gfx::IntSize mScaleToSize;
|
2013-08-20 23:45:30 +04:00
|
|
|
ScaleMode mScaleMode;
|
2015-08-03 20:36:06 +03:00
|
|
|
int32_t mLastProducerID;
|
|
|
|
int32_t mLastFrameID;
|
2016-03-25 06:49:00 +03:00
|
|
|
bool mIsMask;
|
2012-08-29 09:47:18 +04:00
|
|
|
};
|
|
|
|
|
2015-10-12 06:21:03 +03:00
|
|
|
struct CanvasLayerProperties : public LayerPropertiesBase
|
|
|
|
{
|
|
|
|
explicit CanvasLayerProperties(CanvasLayer* aCanvas)
|
|
|
|
: LayerPropertiesBase(aCanvas)
|
|
|
|
, mImageHost(GetImageHost(aCanvas))
|
|
|
|
{
|
|
|
|
mFrameID = mImageHost ? mImageHost->GetFrameID() : -1;
|
|
|
|
}
|
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
bool ComputeChangeInternal(const char* aPrefix,
|
|
|
|
nsIntRegion& aOutRegion,
|
|
|
|
NotifySubDocInvalidationFunc aCallback) override
|
2015-10-12 06:21:03 +03:00
|
|
|
{
|
|
|
|
CanvasLayer* canvasLayer = static_cast<CanvasLayer*>(mLayer.get());
|
|
|
|
|
|
|
|
ImageHost* host = GetImageHost(canvasLayer);
|
|
|
|
if (host && host->GetFrameID() != mFrameID) {
|
2016-12-13 23:56:26 +03:00
|
|
|
LTI_DUMP(NewTransformedBounds(), "frameId");
|
2017-08-04 07:22:48 +03:00
|
|
|
aOutRegion = NewTransformedBounds();
|
|
|
|
return true;
|
2015-10-12 06:21:03 +03:00
|
|
|
}
|
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
return true;
|
2015-10-12 06:21:03 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ImageHost> mImageHost;
|
2015-10-12 06:21:03 +03:00
|
|
|
int32_t mFrameID;
|
|
|
|
};
|
|
|
|
|
2014-08-25 19:09:39 +04:00
|
|
|
UniquePtr<LayerPropertiesBase>
|
2016-03-25 06:49:00 +03:00
|
|
|
CloneLayerTreePropertiesInternal(Layer* aRoot, bool aIsMask /* = false */)
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
|
|
|
if (!aRoot) {
|
2014-08-25 19:09:39 +04:00
|
|
|
return MakeUnique<LayerPropertiesBase>();
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2016-03-25 06:49:00 +03:00
|
|
|
MOZ_ASSERT(!aIsMask || aRoot->GetType() == Layer::TYPE_IMAGE);
|
|
|
|
|
2016-04-28 01:57:44 +03:00
|
|
|
aRoot->CheckCanary();
|
|
|
|
|
2012-08-29 09:47:18 +04:00
|
|
|
switch (aRoot->GetType()) {
|
2014-02-11 08:00:46 +04:00
|
|
|
case Layer::TYPE_CONTAINER:
|
|
|
|
case Layer::TYPE_REF:
|
2014-08-25 19:09:39 +04:00
|
|
|
return MakeUnique<ContainerLayerProperties>(aRoot->AsContainerLayer());
|
2014-02-11 08:00:46 +04:00
|
|
|
case Layer::TYPE_COLOR:
|
2014-08-25 19:09:39 +04:00
|
|
|
return MakeUnique<ColorLayerProperties>(static_cast<ColorLayer*>(aRoot));
|
2014-02-11 08:00:46 +04:00
|
|
|
case Layer::TYPE_IMAGE:
|
2016-03-25 06:49:00 +03:00
|
|
|
return MakeUnique<ImageLayerProperties>(static_cast<ImageLayer*>(aRoot), aIsMask);
|
2015-06-04 09:13:42 +03:00
|
|
|
case Layer::TYPE_CANVAS:
|
2015-10-12 06:21:03 +03:00
|
|
|
return MakeUnique<CanvasLayerProperties>(static_cast<CanvasLayer*>(aRoot));
|
2017-01-23 03:57:00 +03:00
|
|
|
case Layer::TYPE_BORDER:
|
2017-01-18 16:48:00 +03:00
|
|
|
return MakeUnique<BorderLayerProperties>(static_cast<BorderLayer*>(aRoot));
|
2017-01-23 03:57:00 +03:00
|
|
|
case Layer::TYPE_TEXT:
|
|
|
|
return MakeUnique<TextLayerProperties>(static_cast<TextLayer*>(aRoot));
|
2017-02-15 00:49:27 +03:00
|
|
|
case Layer::TYPE_DISPLAYITEM:
|
2015-06-04 09:13:42 +03:00
|
|
|
case Layer::TYPE_READBACK:
|
|
|
|
case Layer::TYPE_SHADOW:
|
|
|
|
case Layer::TYPE_PAINTED:
|
2014-08-25 19:09:39 +04:00
|
|
|
return MakeUnique<LayerPropertiesBase>(aRoot);
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 09:13:42 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("Unexpected root layer type");
|
|
|
|
return MakeUnique<LayerPropertiesBase>(aRoot);
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2014-08-25 19:09:39 +04:00
|
|
|
/* static */ UniquePtr<LayerProperties>
|
2012-08-29 09:47:18 +04:00
|
|
|
LayerProperties::CloneFrom(Layer* aRoot)
|
|
|
|
{
|
|
|
|
return CloneLayerTreePropertiesInternal(aRoot);
|
|
|
|
}
|
|
|
|
|
2016-05-02 18:27:35 +03:00
|
|
|
/* static */ void
|
2012-08-29 09:47:18 +04:00
|
|
|
LayerProperties::ClearInvalidations(Layer *aLayer)
|
|
|
|
{
|
2016-03-10 12:20:40 +03:00
|
|
|
ForEachNode<ForwardIterator>(
|
|
|
|
aLayer,
|
|
|
|
[] (Layer* layer)
|
|
|
|
{
|
2017-06-20 11:17:21 +03:00
|
|
|
layer->ClearInvalidRegion();
|
2016-03-10 12:20:40 +03:00
|
|
|
if (layer->GetMaskLayer()) {
|
|
|
|
ClearInvalidations(layer->GetMaskLayer());
|
|
|
|
}
|
|
|
|
for (size_t i = 0; i < layer->GetAncestorMaskLayerCount(); i++) {
|
|
|
|
ClearInvalidations(layer->GetAncestorMaskLayerAt(i));
|
|
|
|
}
|
2012-08-29 09:47:18 +04:00
|
|
|
|
2016-03-10 12:20:40 +03:00
|
|
|
}
|
|
|
|
);
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
|
|
|
|
2017-08-04 07:22:48 +03:00
|
|
|
bool
|
|
|
|
LayerPropertiesBase::ComputeDifferences(Layer* aRoot, nsIntRegion& aOutRegion, NotifySubDocInvalidationFunc aCallback)
|
2012-08-29 09:47:18 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aRoot, "Must have a layer tree to compare against!");
|
|
|
|
if (mLayer != aRoot) {
|
|
|
|
if (aCallback) {
|
2016-03-10 12:20:40 +03:00
|
|
|
NotifySubdocumentInvalidation(aRoot, aCallback);
|
2012-08-29 09:47:18 +04:00
|
|
|
} else {
|
|
|
|
ClearInvalidations(aRoot);
|
|
|
|
}
|
2017-02-09 15:39:27 +03:00
|
|
|
IntRect result = TransformRect(
|
|
|
|
aRoot->GetLocalVisibleRegion().ToUnknownRegion().GetBounds(),
|
|
|
|
aRoot->GetLocalTransform());
|
2012-08-29 09:47:18 +04:00
|
|
|
result = result.Union(OldTransformedBounds());
|
2017-08-04 07:22:48 +03:00
|
|
|
aOutRegion = result;
|
|
|
|
return true;
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
2017-08-04 07:22:48 +03:00
|
|
|
return ComputeChange(" ", aOutRegion, aCallback);
|
2012-08-29 09:47:18 +04:00
|
|
|
}
|
2014-08-01 16:31:47 +04:00
|
|
|
|
|
|
|
void
|
2015-04-21 18:04:57 +03:00
|
|
|
LayerPropertiesBase::MoveBy(const IntPoint& aOffset)
|
2012-09-17 02:57:22 +04:00
|
|
|
{
|
2014-10-16 13:51:12 +04:00
|
|
|
mTransform.PostTranslate(aOffset.x, aOffset.y, 0);
|
2012-09-17 02:57:22 +04:00
|
|
|
}
|
2012-08-29 09:47:18 +04:00
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|