2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2010-09-04 00:10:45 +04:00
|
|
|
#include "Layers.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <algorithm> // for max, min
|
2014-10-16 17:23:52 +04:00
|
|
|
#include "apz/src/AsyncPanZoomController.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "CompositableHost.h" // for CompositableHost
|
|
|
|
#include "ImageContainer.h" // for ImageContainer, etc
|
|
|
|
#include "ImageLayers.h" // for ImageLayer
|
|
|
|
#include "LayerSorter.h" // for SortLayersBy3DZOrder
|
|
|
|
#include "LayersLogging.h" // for AppendToString
|
2016-09-04 10:34:21 +03:00
|
|
|
#include "LayerUserData.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "ReadbackLayer.h" // for ReadbackLayer
|
2015-04-12 05:03:00 +03:00
|
|
|
#include "UnitTransforms.h" // for ViewAs
|
2015-10-28 16:31:00 +03:00
|
|
|
#include "gfxEnv.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
2014-07-28 00:32:00 +04:00
|
|
|
#include "gfxPrefs.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxUtils.h" // for gfxUtils, etc
|
2013-12-13 21:31:53 +04:00
|
|
|
#include "gfx2DGlue.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/DebugOnly.h" // for DebugOnly
|
2016-12-14 19:32:21 +03:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/Telemetry.h" // for Accumulate
|
2016-09-04 10:34:21 +03:00
|
|
|
#include "mozilla/ToString.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/gfx/2D.h" // for DrawTarget
|
|
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
2014-01-25 05:49:19 +04:00
|
|
|
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
2016-12-07 02:39:01 +03:00
|
|
|
#include "mozilla/gfx/Polygon.h" // for Polygon
|
2015-10-12 06:21:02 +03:00
|
|
|
#include "mozilla/layers/AsyncCanvasRenderer.h"
|
2016-12-07 02:39:01 +03:00
|
|
|
#include "mozilla/layers/BSPTree.h" // for BSPTree
|
2015-09-29 00:06:35 +03:00
|
|
|
#include "mozilla/layers/CompositableClient.h" // for CompositableClient
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/layers/Compositor.h" // for Compositor
|
|
|
|
#include "mozilla/layers/CompositorTypes.h"
|
|
|
|
#include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite
|
2014-08-28 06:13:41 +04:00
|
|
|
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
|
2013-09-06 19:41:00 +04:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for TransformFunction, etc
|
2015-09-29 00:06:35 +03:00
|
|
|
#include "mozilla/layers/LayersTypes.h" // for TextureDumpMode
|
2015-06-19 02:07:21 +03:00
|
|
|
#include "mozilla/layers/PersistentBufferProvider.h"
|
2015-09-29 00:06:35 +03:00
|
|
|
#include "mozilla/layers/ShadowLayers.h" // for ShadowableLayer
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsAString.h"
|
|
|
|
#include "nsCSSValue.h" // for nsCSSValue::Array, etc
|
2017-02-15 00:49:27 +03:00
|
|
|
#include "nsDisplayList.h" // for nsDisplayItem
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsPrintfCString.h" // for nsPrintfCString
|
2014-07-28 00:32:00 +04:00
|
|
|
#include "protobuf/LayerScopePacket.pb.h"
|
2015-08-03 09:11:00 +03:00
|
|
|
#include "mozilla/Compression.h"
|
2016-03-10 12:20:40 +03:00
|
|
|
#include "TreeTraversal.h" // for ForEachNode
|
2010-09-04 00:10:45 +04:00
|
|
|
|
2017-04-10 17:35:56 +03:00
|
|
|
#include <list>
|
2016-12-07 02:39:01 +03:00
|
|
|
#include <set>
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t gLayerManagerLayerBuilder;
|
2012-08-21 08:06:46 +04:00
|
|
|
|
2014-05-22 14:11:45 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
FILE*
|
|
|
|
FILEOrDefault(FILE* aFile)
|
|
|
|
{
|
|
|
|
return aFile ? aFile : stderr;
|
|
|
|
}
|
|
|
|
|
2014-05-22 14:11:45 +04:00
|
|
|
typedef FrameMetrics::ViewID ViewID;
|
|
|
|
|
|
|
|
using namespace mozilla::gfx;
|
2015-08-03 09:11:00 +03:00
|
|
|
using namespace mozilla::Compression;
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2010-09-08 07:27:29 +04:00
|
|
|
//--------------------------------------------------
|
|
|
|
// LayerManager
|
2015-10-30 01:44:31 +03:00
|
|
|
|
|
|
|
/* static */ mozilla::LogModule*
|
|
|
|
LayerManager::GetLog()
|
|
|
|
{
|
|
|
|
static LazyLogModule sLog("Layers");
|
|
|
|
return sLog;
|
|
|
|
}
|
|
|
|
|
2014-08-28 06:13:41 +04:00
|
|
|
FrameMetrics::ViewID
|
|
|
|
LayerManager::GetRootScrollableLayerId()
|
2012-09-27 00:41:56 +04:00
|
|
|
{
|
|
|
|
if (!mRoot) {
|
2014-08-28 06:13:41 +04:00
|
|
|
return FrameMetrics::NULL_SCROLL_ID;
|
2012-09-27 00:41:56 +04:00
|
|
|
}
|
|
|
|
|
2016-09-22 19:31:26 +03:00
|
|
|
LayerMetricsWrapper layerMetricsRoot = LayerMetricsWrapper(mRoot);
|
|
|
|
|
|
|
|
LayerMetricsWrapper rootScrollableLayerMetrics =
|
|
|
|
BreadthFirstSearch<ForwardIterator>(
|
|
|
|
layerMetricsRoot,
|
|
|
|
[](LayerMetricsWrapper aLayerMetrics)
|
|
|
|
{
|
|
|
|
return aLayerMetrics.Metrics().IsScrollable();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
return rootScrollableLayerMetrics.IsValid() ?
|
|
|
|
rootScrollableLayerMetrics.Metrics().GetScrollId() :
|
|
|
|
FrameMetrics::NULL_SCROLL_ID;
|
2014-08-28 06:13:41 +04:00
|
|
|
}
|
|
|
|
|
2016-08-18 02:35:25 +03:00
|
|
|
LayerMetricsWrapper
|
|
|
|
LayerManager::GetRootContentLayer()
|
|
|
|
{
|
|
|
|
if (!mRoot) {
|
|
|
|
return LayerMetricsWrapper();
|
|
|
|
}
|
|
|
|
|
2016-09-22 19:31:26 +03:00
|
|
|
LayerMetricsWrapper root(mRoot);
|
2016-08-18 02:35:25 +03:00
|
|
|
|
2016-09-22 19:31:26 +03:00
|
|
|
return BreadthFirstSearch<ForwardIterator>(root,
|
|
|
|
[](LayerMetricsWrapper aLayerMetrics)
|
|
|
|
{
|
|
|
|
return aLayerMetrics.Metrics().IsRootContent();
|
2016-08-18 02:35:25 +03:00
|
|
|
}
|
2016-09-22 19:31:26 +03:00
|
|
|
);
|
2016-08-18 02:35:25 +03:00
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<DrawTarget>
|
2014-04-10 12:49:49 +04:00
|
|
|
LayerManager::CreateOptimalDrawTarget(const gfx::IntSize &aSize,
|
|
|
|
SurfaceFormat aFormat)
|
2010-09-08 07:27:29 +04:00
|
|
|
{
|
2014-04-10 12:49:49 +04:00
|
|
|
return gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(aSize,
|
|
|
|
aFormat);
|
2010-09-08 07:27:29 +04:00
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<DrawTarget>
|
2014-04-10 12:49:49 +04:00
|
|
|
LayerManager::CreateOptimalMaskDrawTarget(const gfx::IntSize &aSize)
|
2012-06-26 06:43:31 +04:00
|
|
|
{
|
2014-04-10 12:49:49 +04:00
|
|
|
return CreateOptimalDrawTarget(aSize, SurfaceFormat::A8);
|
2012-06-26 06:43:31 +04:00
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<DrawTarget>
|
2011-06-24 21:41:18 +04:00
|
|
|
LayerManager::CreateDrawTarget(const IntSize &aSize,
|
|
|
|
SurfaceFormat aFormat)
|
|
|
|
{
|
2011-11-02 23:55:03 +04:00
|
|
|
return gfxPlatform::GetPlatform()->
|
2013-08-23 10:13:55 +04:00
|
|
|
CreateOffscreenCanvasDrawTarget(aSize, aFormat);
|
2011-06-24 21:41:18 +04:00
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<PersistentBufferProvider>
|
2015-06-19 02:07:21 +03:00
|
|
|
LayerManager::CreatePersistentBufferProvider(const mozilla::gfx::IntSize &aSize,
|
2016-09-16 19:55:44 +03:00
|
|
|
mozilla::gfx::SurfaceFormat aFormat)
|
2015-06-19 02:07:21 +03:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PersistentBufferProviderBasic> bufferProvider =
|
2016-07-01 11:58:06 +03:00
|
|
|
PersistentBufferProviderBasic::Create(aSize, aFormat,
|
2016-09-16 19:55:44 +03:00
|
|
|
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend());
|
2015-06-19 02:07:21 +03:00
|
|
|
|
2016-07-01 11:58:06 +03:00
|
|
|
if (!bufferProvider) {
|
|
|
|
bufferProvider = PersistentBufferProviderBasic::Create(aSize, aFormat,
|
2016-09-16 19:55:44 +03:00
|
|
|
gfxPlatform::GetPlatform()->GetFallbackCanvasBackend());
|
2015-06-19 02:07:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return bufferProvider.forget();
|
|
|
|
}
|
|
|
|
|
2012-02-01 06:18:30 +04:00
|
|
|
already_AddRefed<ImageContainer>
|
2015-05-28 02:35:00 +03:00
|
|
|
LayerManager::CreateImageContainer(ImageContainer::Mode flag)
|
2012-02-01 06:18:30 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ImageContainer> container = new ImageContainer(flag);
|
2012-02-01 06:18:30 +04:00
|
|
|
return container.forget();
|
|
|
|
}
|
|
|
|
|
2014-07-18 10:48:23 +04:00
|
|
|
bool
|
|
|
|
LayerManager::AreComponentAlphaLayersEnabled()
|
|
|
|
{
|
|
|
|
return gfxPrefs::ComponentAlphaEnabled();
|
|
|
|
}
|
|
|
|
|
2015-10-22 22:39:30 +03:00
|
|
|
/*static*/ void
|
|
|
|
LayerManager::LayerUserDataDestroy(void* data)
|
|
|
|
{
|
|
|
|
delete static_cast<LayerUserData*>(data);
|
|
|
|
}
|
|
|
|
|
2016-05-25 01:17:27 +03:00
|
|
|
UniquePtr<LayerUserData>
|
2015-10-22 23:57:29 +03:00
|
|
|
LayerManager::RemoveUserData(void* aKey)
|
|
|
|
{
|
2016-05-25 01:17:27 +03:00
|
|
|
UniquePtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
|
2015-10-22 23:57:29 +03:00
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
//--------------------------------------------------
|
|
|
|
// Layer
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2017-07-21 09:21:47 +03:00
|
|
|
Layer::Layer(LayerManager* aManager, void* aImplData)
|
|
|
|
: mManager(aManager)
|
|
|
|
, mParent(nullptr)
|
|
|
|
, mNextSibling(nullptr)
|
|
|
|
, mPrevSibling(nullptr)
|
|
|
|
, mImplData(aImplData)
|
|
|
|
, mAnimationInfo(aManager)
|
|
|
|
, mUseTileSourceRect(false)
|
2016-02-26 18:52:07 +03:00
|
|
|
#ifdef DEBUG
|
2017-07-21 09:21:47 +03:00
|
|
|
, mDebugColorIndex(0)
|
2016-02-26 18:52:07 +03:00
|
|
|
#endif
|
2015-07-29 18:57:03 +03:00
|
|
|
{
|
|
|
|
}
|
2012-07-31 21:28:20 +04:00
|
|
|
|
|
|
|
Layer::~Layer()
|
2015-07-29 18:57:03 +03:00
|
|
|
{
|
|
|
|
}
|
2012-07-31 21:28:20 +04:00
|
|
|
|
|
|
|
void
|
2017-02-08 22:31:45 +03:00
|
|
|
Layer::SetCompositorAnimations(const CompositorAnimations& aCompositorAnimations)
|
2012-07-31 21:28:20 +04:00
|
|
|
{
|
2017-02-08 22:31:45 +03:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(
|
2017-07-21 09:21:47 +03:00
|
|
|
this, ("Layer::Mutated(%p) SetCompositorAnimations with id=%" PRIu64, this, mAnimationInfo.GetCompositorAnimationsId()));
|
2013-03-22 06:17:28 +04:00
|
|
|
|
2017-07-21 09:21:47 +03:00
|
|
|
mAnimationInfo.SetCompositorAnimations(aCompositorAnimations);
|
2012-07-31 21:28:20 +04:00
|
|
|
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2018-04-24 03:27:54 +03:00
|
|
|
void
|
|
|
|
Layer::ClearCompositorAnimations()
|
|
|
|
{
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(
|
|
|
|
this, ("Layer::Mutated(%p) ClearCompositorAnimations with id=%" PRIu64, this, mAnimationInfo.GetCompositorAnimationsId()));
|
|
|
|
|
|
|
|
mAnimationInfo.ClearAnimations();
|
|
|
|
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2014-12-22 03:35:41 +03:00
|
|
|
void
|
|
|
|
Layer::StartPendingAnimations(const TimeStamp& aReadyTime)
|
|
|
|
{
|
2016-03-10 12:20:40 +03:00
|
|
|
ForEachNode<ForwardIterator>(
|
|
|
|
this,
|
|
|
|
[&aReadyTime](Layer *layer)
|
|
|
|
{
|
2017-07-21 09:21:47 +03:00
|
|
|
if (layer->mAnimationInfo.StartPendingAnimations(aReadyTime)) {
|
2016-03-10 12:20:40 +03:00
|
|
|
layer->Mutated();
|
|
|
|
}
|
|
|
|
});
|
2014-12-22 03:35:41 +03:00
|
|
|
}
|
|
|
|
|
2013-04-18 01:39:13 +04:00
|
|
|
void
|
2014-08-28 06:13:40 +04:00
|
|
|
Layer::SetAsyncPanZoomController(uint32_t aIndex, AsyncPanZoomController *controller)
|
2013-04-18 01:39:13 +04:00
|
|
|
{
|
2016-03-29 02:14:52 +03:00
|
|
|
MOZ_ASSERT(aIndex < GetScrollMetadataCount());
|
2018-03-12 23:06:37 +03:00
|
|
|
// We should never be setting an APZC on a non-scrollable layer
|
|
|
|
MOZ_ASSERT(!controller || GetFrameMetrics(aIndex).IsScrollable());
|
2014-08-28 06:13:40 +04:00
|
|
|
mApzcs[aIndex] = controller;
|
2013-04-18 01:39:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
AsyncPanZoomController*
|
2014-08-28 06:13:40 +04:00
|
|
|
Layer::GetAsyncPanZoomController(uint32_t aIndex) const
|
2013-04-18 01:39:13 +04:00
|
|
|
{
|
2016-03-29 02:14:52 +03:00
|
|
|
MOZ_ASSERT(aIndex < GetScrollMetadataCount());
|
2013-07-02 20:01:46 +04:00
|
|
|
#ifdef DEBUG
|
2014-08-28 06:13:40 +04:00
|
|
|
if (mApzcs[aIndex]) {
|
|
|
|
MOZ_ASSERT(GetFrameMetrics(aIndex).IsScrollable());
|
2013-04-18 01:39:13 +04:00
|
|
|
}
|
2013-07-02 20:01:46 +04:00
|
|
|
#endif
|
2014-08-28 06:13:40 +04:00
|
|
|
return mApzcs[aIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-03-29 02:14:52 +03:00
|
|
|
Layer::ScrollMetadataChanged()
|
2014-08-28 06:13:40 +04:00
|
|
|
{
|
2016-03-29 02:14:52 +03:00
|
|
|
mApzcs.SetLength(GetScrollMetadataCount());
|
2013-04-18 01:39:13 +04:00
|
|
|
}
|
|
|
|
|
2012-10-03 09:55:50 +04:00
|
|
|
void
|
|
|
|
Layer::ApplyPendingUpdatesToSubtree()
|
|
|
|
{
|
2016-03-10 12:20:40 +03:00
|
|
|
ForEachNode<ForwardIterator>(
|
|
|
|
this,
|
|
|
|
[] (Layer *layer)
|
|
|
|
{
|
|
|
|
layer->ApplyPendingUpdatesForThisTransaction();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Once we're done recursing through the whole tree, clear the pending
|
|
|
|
// updates from the manager.
|
|
|
|
Manager()->ClearPendingScrollInfoUpdate();
|
2012-10-03 09:55:50 +04:00
|
|
|
}
|
|
|
|
|
2015-09-30 10:02:00 +03:00
|
|
|
bool
|
|
|
|
Layer::IsOpaqueForVisibility()
|
|
|
|
{
|
2016-05-10 03:42:57 +03:00
|
|
|
return GetEffectiveOpacity() == 1.0f &&
|
2015-09-30 10:02:00 +03:00
|
|
|
GetEffectiveMixBlendMode() == CompositionOp::OP_OVER;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-07-21 22:06:33 +04:00
|
|
|
Layer::CanUseOpaqueSurface()
|
|
|
|
{
|
|
|
|
// If the visible content in the layer is opaque, there is no need
|
|
|
|
// for an alpha channel.
|
2010-09-02 13:18:40 +04:00
|
|
|
if (GetContentFlags() & CONTENT_OPAQUE)
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-07-21 22:06:33 +04:00
|
|
|
// Also, if this layer is the bottommost layer in a container which
|
|
|
|
// doesn't need an alpha channel, we can use an opaque surface for this
|
|
|
|
// layer too. Any transparent areas must be covered by something else
|
|
|
|
// in the container.
|
|
|
|
ContainerLayer* parent = GetParent();
|
|
|
|
return parent && parent->GetFirstChild() == this &&
|
|
|
|
parent->CanUseOpaqueSurface();
|
|
|
|
}
|
|
|
|
|
2010-10-14 02:55:45 +04:00
|
|
|
// NB: eventually these methods will be defined unconditionally, and
|
|
|
|
// can be moved into Layers.h
|
2015-04-12 05:03:00 +03:00
|
|
|
const Maybe<ParentLayerIntRect>&
|
2016-05-02 18:27:35 +03:00
|
|
|
Layer::GetLocalClipRect()
|
2010-10-14 02:55:45 +04:00
|
|
|
{
|
2016-11-24 08:11:27 +03:00
|
|
|
if (HostLayer* shadow = AsHostLayer()) {
|
2010-10-14 02:55:45 +04:00
|
|
|
return shadow->GetShadowClipRect();
|
|
|
|
}
|
|
|
|
return GetClipRect();
|
|
|
|
}
|
|
|
|
|
2015-11-29 10:07:55 +03:00
|
|
|
const LayerIntRegion&
|
2016-02-14 03:50:51 +03:00
|
|
|
Layer::GetLocalVisibleRegion()
|
2010-10-14 02:55:45 +04:00
|
|
|
{
|
2016-11-24 08:11:27 +03:00
|
|
|
if (HostLayer* shadow = AsHostLayer()) {
|
2010-10-14 02:55:45 +04:00
|
|
|
return shadow->GetShadowVisibleRegion();
|
|
|
|
}
|
|
|
|
return GetVisibleRegion();
|
|
|
|
}
|
|
|
|
|
2014-01-27 19:27:20 +04:00
|
|
|
Matrix4x4
|
|
|
|
Layer::SnapTransformTranslation(const Matrix4x4& aTransform,
|
|
|
|
Matrix* aResidualTransform)
|
2012-12-07 03:58:13 +04:00
|
|
|
{
|
|
|
|
if (aResidualTransform) {
|
2014-01-27 19:27:20 +04:00
|
|
|
*aResidualTransform = Matrix();
|
2012-12-07 03:58:13 +04:00
|
|
|
}
|
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
if (!mManager->IsSnappingEffectiveTransforms()) {
|
|
|
|
return aTransform;
|
|
|
|
}
|
|
|
|
|
2014-01-27 19:27:20 +04:00
|
|
|
Matrix matrix2D;
|
2016-04-06 06:29:32 +03:00
|
|
|
if (aTransform.CanDraw2D(&matrix2D) &&
|
2012-12-07 03:58:13 +04:00
|
|
|
!matrix2D.HasNonTranslation() &&
|
|
|
|
matrix2D.HasNonIntegerTranslation()) {
|
2016-07-26 17:48:34 +03:00
|
|
|
auto snappedTranslation = IntPoint::Round(matrix2D.GetTranslation());
|
2014-03-22 03:56:11 +04:00
|
|
|
Matrix snappedMatrix = Matrix::Translation(snappedTranslation.x,
|
|
|
|
snappedTranslation.y);
|
2016-11-07 09:45:00 +03:00
|
|
|
Matrix4x4 result = Matrix4x4::From2D(snappedMatrix);
|
2012-12-07 03:58:13 +04:00
|
|
|
if (aResidualTransform) {
|
|
|
|
// set aResidualTransform so that aResidual * snappedMatrix == matrix2D.
|
|
|
|
// (I.e., appying snappedMatrix after aResidualTransform gives the
|
|
|
|
// ideal transform.)
|
|
|
|
*aResidualTransform =
|
2014-03-22 03:56:11 +04:00
|
|
|
Matrix::Translation(matrix2D._31 - snappedTranslation.x,
|
|
|
|
matrix2D._32 - snappedTranslation.y);
|
2012-12-07 03:58:13 +04:00
|
|
|
}
|
2015-09-17 04:31:00 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-11-07 09:45:00 +03:00
|
|
|
return SnapTransformTranslation3D(aTransform, aResidualTransform);
|
|
|
|
}
|
|
|
|
|
|
|
|
Matrix4x4
|
|
|
|
Layer::SnapTransformTranslation3D(const Matrix4x4& aTransform,
|
|
|
|
Matrix* aResidualTransform)
|
|
|
|
{
|
2015-09-17 04:31:00 +03:00
|
|
|
if(aTransform.IsSingular() ||
|
2015-10-26 05:05:00 +03:00
|
|
|
aTransform.HasPerspectiveComponent() ||
|
|
|
|
aTransform.HasNonTranslation() ||
|
|
|
|
!aTransform.HasNonIntegerTranslation()) {
|
2015-09-17 04:31:00 +03:00
|
|
|
// For a singular transform, there is no reversed matrix, so we
|
|
|
|
// don't snap it.
|
|
|
|
// For a perspective transform, the content is transformed in
|
|
|
|
// non-linear, so we don't snap it too.
|
|
|
|
return aTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Snap for 3D Transforms
|
|
|
|
|
2016-09-08 19:26:03 +03:00
|
|
|
Point3D transformedOrigin = aTransform.TransformPoint(Point3D());
|
2015-09-17 04:31:00 +03:00
|
|
|
|
|
|
|
// Compute the transformed snap by rounding the values of
|
|
|
|
// transformed origin.
|
2016-07-26 17:48:34 +03:00
|
|
|
auto transformedSnapXY = IntPoint::Round(transformedOrigin.x, transformedOrigin.y);
|
2015-09-17 04:31:00 +03:00
|
|
|
Matrix4x4 inverse = aTransform;
|
|
|
|
inverse.Invert();
|
|
|
|
// see Matrix4x4::ProjectPoint()
|
|
|
|
Float transformedSnapZ =
|
|
|
|
inverse._33 == 0 ? 0 : (-(transformedSnapXY.x * inverse._13 +
|
|
|
|
transformedSnapXY.y * inverse._23 +
|
|
|
|
inverse._43) / inverse._33);
|
|
|
|
Point3D transformedSnap =
|
|
|
|
Point3D(transformedSnapXY.x, transformedSnapXY.y, transformedSnapZ);
|
|
|
|
if (transformedOrigin == transformedSnap) {
|
|
|
|
return aTransform;
|
2015-09-17 04:31:00 +03:00
|
|
|
}
|
2015-09-17 04:31:00 +03:00
|
|
|
|
|
|
|
// Compute the snap from the transformed snap.
|
2016-09-08 19:26:03 +03:00
|
|
|
Point3D snap = inverse.TransformPoint(transformedSnap);
|
2015-09-17 04:31:00 +03:00
|
|
|
if (snap.z > 0.001 || snap.z < -0.001) {
|
|
|
|
// Allow some level of accumulated computation error.
|
|
|
|
MOZ_ASSERT(inverse._33 == 0.0);
|
|
|
|
return aTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The difference between the origin and snap is the residual transform.
|
|
|
|
if (aResidualTransform) {
|
|
|
|
// The residual transform is to translate the snap to the origin
|
|
|
|
// of the content buffer.
|
|
|
|
*aResidualTransform = Matrix::Translation(-snap.x, -snap.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Translate transformed origin to transformed snap since the
|
|
|
|
// residual transform would trnslate the snap to the origin.
|
|
|
|
Point3D transformedShift = transformedSnap - transformedOrigin;
|
2016-11-07 09:45:00 +03:00
|
|
|
Matrix4x4 result = aTransform;
|
2015-09-17 04:31:00 +03:00
|
|
|
result.PostTranslate(transformedShift.x,
|
|
|
|
transformedShift.y,
|
|
|
|
transformedShift.z);
|
|
|
|
|
|
|
|
// For non-2d transform, residual translation could be more than
|
|
|
|
// 0.5 pixels for every axis.
|
|
|
|
|
2012-12-07 03:58:13 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-01-27 19:27:20 +04:00
|
|
|
Matrix4x4
|
|
|
|
Layer::SnapTransform(const Matrix4x4& aTransform,
|
2010-11-08 12:06:15 +03:00
|
|
|
const gfxRect& aSnapRect,
|
2014-01-27 19:27:20 +04:00
|
|
|
Matrix* aResidualTransform)
|
2010-11-08 12:06:15 +03:00
|
|
|
{
|
2012-12-07 16:37:36 +04:00
|
|
|
if (aResidualTransform) {
|
2014-01-27 19:27:20 +04:00
|
|
|
*aResidualTransform = Matrix();
|
2012-12-07 16:37:36 +04:00
|
|
|
}
|
|
|
|
|
2014-01-27 19:27:20 +04:00
|
|
|
Matrix matrix2D;
|
|
|
|
Matrix4x4 result;
|
2013-06-10 04:13:10 +04:00
|
|
|
if (mManager->IsSnappingEffectiveTransforms() &&
|
2010-11-08 12:06:15 +03:00
|
|
|
aTransform.Is2D(&matrix2D) &&
|
2015-11-09 08:04:42 +03:00
|
|
|
gfxSize(1.0, 1.0) <= aSnapRect.Size() &&
|
2012-12-07 03:58:13 +04:00
|
|
|
matrix2D.PreservesAxisAlignedRectangles()) {
|
2016-09-08 19:26:03 +03:00
|
|
|
auto transformedTopLeft = IntPoint::Round(matrix2D.TransformPoint(ToPoint(aSnapRect.TopLeft())));
|
|
|
|
auto transformedTopRight = IntPoint::Round(matrix2D.TransformPoint(ToPoint(aSnapRect.TopRight())));
|
|
|
|
auto transformedBottomRight = IntPoint::Round(matrix2D.TransformPoint(ToPoint(aSnapRect.BottomRight())));
|
2014-01-27 19:27:20 +04:00
|
|
|
|
|
|
|
Matrix snappedMatrix = gfxUtils::TransformRectToRect(aSnapRect,
|
2012-12-07 03:58:13 +04:00
|
|
|
transformedTopLeft, transformedTopRight, transformedBottomRight);
|
|
|
|
|
2014-01-27 19:27:20 +04:00
|
|
|
result = Matrix4x4::From2D(snappedMatrix);
|
2010-11-08 12:06:15 +03:00
|
|
|
if (aResidualTransform && !snappedMatrix.IsSingular()) {
|
|
|
|
// set aResidualTransform so that aResidual * snappedMatrix == matrix2D.
|
|
|
|
// (i.e., appying snappedMatrix after aResidualTransform gives the
|
|
|
|
// ideal transform.
|
2014-01-27 19:27:20 +04:00
|
|
|
Matrix snappedMatrixInverse = snappedMatrix;
|
2010-11-08 12:06:15 +03:00
|
|
|
snappedMatrixInverse.Invert();
|
|
|
|
*aResidualTransform = matrix2D * snappedMatrixInverse;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
result = aTransform;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-12-12 09:21:23 +04:00
|
|
|
static bool
|
|
|
|
AncestorLayerMayChangeTransform(Layer* aLayer)
|
|
|
|
{
|
|
|
|
for (Layer* l = aLayer; l; l = l->GetParent()) {
|
|
|
|
if (l->GetContentFlags() & Layer::CONTENT_MAY_CHANGE_TRANSFORM) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-05-08 00:07:06 +03:00
|
|
|
|
|
|
|
if (l->GetParent() && l->GetParent()->AsRefLayer()) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-12-12 09:21:23 +04:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Layer::MayResample()
|
|
|
|
{
|
2014-01-27 19:29:06 +04:00
|
|
|
Matrix transform2d;
|
|
|
|
return !GetEffectiveTransform().Is2D(&transform2d) ||
|
|
|
|
ThebesMatrix(transform2d).HasNonIntegerTranslation() ||
|
2012-12-12 09:21:23 +04:00
|
|
|
AncestorLayerMayChangeTransform(this);
|
|
|
|
}
|
|
|
|
|
2014-07-30 22:36:15 +04:00
|
|
|
RenderTargetIntRect
|
2014-09-10 23:59:00 +04:00
|
|
|
Layer::CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect)
|
2011-02-25 10:44:22 +03:00
|
|
|
{
|
2011-05-23 04:27:03 +04:00
|
|
|
ContainerLayer* container = GetParent();
|
2015-09-17 04:31:00 +03:00
|
|
|
ContainerLayer* containerChild = nullptr;
|
|
|
|
NS_ASSERTION(GetParent(), "This can't be called on the root!");
|
|
|
|
|
|
|
|
// Find the layer creating the 3D context.
|
2015-09-28 10:43:00 +03:00
|
|
|
while (container->Extend3DContext() &&
|
|
|
|
!container->UseIntermediateSurface()) {
|
2015-09-17 04:31:00 +03:00
|
|
|
containerChild = container;
|
|
|
|
container = container->GetParent();
|
|
|
|
MOZ_ASSERT(container);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the nearest layer with a clip, or this layer.
|
|
|
|
// ContainerState::SetupScrollingMetadata() may install a clip on
|
|
|
|
// the layer.
|
|
|
|
Layer *clipLayer =
|
2016-05-02 18:27:35 +03:00
|
|
|
containerChild && containerChild->GetLocalClipRect() ?
|
2015-09-17 04:31:00 +03:00
|
|
|
containerChild : this;
|
2011-05-23 04:27:03 +04:00
|
|
|
|
|
|
|
// Establish initial clip rect: it's either the one passed in, or
|
|
|
|
// if the parent has an intermediate surface, it's the extents of that surface.
|
2014-07-30 22:36:15 +04:00
|
|
|
RenderTargetIntRect currentClip;
|
2011-05-23 04:27:03 +04:00
|
|
|
if (container->UseIntermediateSurface()) {
|
|
|
|
currentClip.SizeTo(container->GetIntermediateSurfaceRect().Size());
|
|
|
|
} else {
|
|
|
|
currentClip = aCurrentScissorRect;
|
|
|
|
}
|
2011-02-25 10:44:22 +03:00
|
|
|
|
2016-05-02 18:27:35 +03:00
|
|
|
if (!clipLayer->GetLocalClipRect()) {
|
2011-05-23 04:27:03 +04:00
|
|
|
return currentClip;
|
2014-07-30 22:36:15 +04:00
|
|
|
}
|
2011-02-25 10:44:22 +03:00
|
|
|
|
2017-04-21 05:02:15 +03:00
|
|
|
if (GetLocalVisibleRegion().IsEmpty()) {
|
2015-09-14 19:26:10 +03:00
|
|
|
// When our visible region is empty, our parent may not have created the
|
|
|
|
// intermediate surface that we would require for correct clipping; however,
|
|
|
|
// this does not matter since we are invisible.
|
2016-06-09 07:36:12 +03:00
|
|
|
// Make sure we still compute a clip rect if we want to draw checkboarding
|
|
|
|
// for this layer, since we want to do this even if the layer is invisible.
|
2015-09-14 19:26:10 +03:00
|
|
|
return RenderTargetIntRect(currentClip.TopLeft(), RenderTargetIntSize(0, 0));
|
|
|
|
}
|
|
|
|
|
2015-04-12 05:03:00 +03:00
|
|
|
const RenderTargetIntRect clipRect =
|
2016-05-02 18:27:35 +03:00
|
|
|
ViewAs<RenderTargetPixel>(*clipLayer->GetLocalClipRect(),
|
2015-04-12 05:03:00 +03:00
|
|
|
PixelCastJustification::RenderTargetIsParentLayerForRoot);
|
2014-07-30 22:36:15 +04:00
|
|
|
if (clipRect.IsEmpty()) {
|
2011-05-23 04:27:03 +04:00
|
|
|
// We might have a non-translation transform in the container so we can't
|
|
|
|
// use the code path below.
|
2014-07-30 22:36:15 +04:00
|
|
|
return RenderTargetIntRect(currentClip.TopLeft(), RenderTargetIntSize(0, 0));
|
2011-02-25 10:44:22 +03:00
|
|
|
}
|
|
|
|
|
2014-07-30 22:36:15 +04:00
|
|
|
RenderTargetIntRect scissor = clipRect;
|
2011-05-23 04:27:03 +04:00
|
|
|
if (!container->UseIntermediateSurface()) {
|
2014-01-28 00:25:19 +04:00
|
|
|
gfx::Matrix matrix;
|
|
|
|
DebugOnly<bool> is2D = container->GetEffectiveTransform().Is2D(&matrix);
|
2011-05-23 04:27:03 +04:00
|
|
|
// See DefaultComputeEffectiveTransforms below
|
2011-06-16 14:51:05 +04:00
|
|
|
NS_ASSERTION(is2D && matrix.PreservesAxisAlignedRectangles(),
|
|
|
|
"Non preserves axis aligned transform with clipped child should have forced intermediate surface");
|
2017-12-19 23:48:39 +03:00
|
|
|
gfx::Rect r(scissor.X(), scissor.Y(), scissor.Width(), scissor.Height());
|
2014-01-28 00:25:19 +04:00
|
|
|
gfxRect trScissor = gfx::ThebesRect(matrix.TransformBounds(r));
|
2011-06-16 14:51:05 +04:00
|
|
|
trScissor.Round();
|
2015-05-07 12:07:53 +03:00
|
|
|
IntRect tmp;
|
2014-07-30 22:36:15 +04:00
|
|
|
if (!gfxUtils::GfxRectToIntRect(trScissor, &tmp)) {
|
|
|
|
return RenderTargetIntRect(currentClip.TopLeft(), RenderTargetIntSize(0, 0));
|
2011-06-16 14:51:05 +04:00
|
|
|
}
|
2015-04-12 05:03:00 +03:00
|
|
|
scissor = ViewAs<RenderTargetPixel>(tmp);
|
2011-05-23 04:27:03 +04:00
|
|
|
|
|
|
|
// Find the nearest ancestor with an intermediate surface
|
|
|
|
do {
|
|
|
|
container = container->GetParent();
|
|
|
|
} while (container && !container->UseIntermediateSurface());
|
2011-02-25 10:44:22 +03:00
|
|
|
}
|
2014-07-30 22:36:15 +04:00
|
|
|
|
2011-05-23 04:27:03 +04:00
|
|
|
if (container) {
|
|
|
|
scissor.MoveBy(-container->GetIntermediateSurfaceRect().TopLeft());
|
2011-02-25 10:44:22 +03:00
|
|
|
}
|
2011-05-23 04:27:03 +04:00
|
|
|
return currentClip.Intersect(scissor);
|
2011-02-25 10:44:22 +03:00
|
|
|
}
|
|
|
|
|
2016-05-05 00:30:26 +03:00
|
|
|
Maybe<ParentLayerIntRect>
|
|
|
|
Layer::GetScrolledClipRect() const
|
|
|
|
{
|
2018-03-02 21:00:03 +03:00
|
|
|
const Maybe<LayerClip> clip = mSimpleAttrs.GetScrolledClip();
|
2017-01-25 03:41:18 +03:00
|
|
|
return clip ? Some(clip->GetClipRect()) : Nothing();
|
2016-05-05 00:30:26 +03:00
|
|
|
}
|
|
|
|
|
2016-03-29 02:14:52 +03:00
|
|
|
const ScrollMetadata&
|
|
|
|
Layer::GetScrollMetadata(uint32_t aIndex) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aIndex < GetScrollMetadataCount());
|
|
|
|
return mScrollMetadata[aIndex];
|
|
|
|
}
|
|
|
|
|
2014-08-28 06:13:40 +04:00
|
|
|
const FrameMetrics&
|
|
|
|
Layer::GetFrameMetrics(uint32_t aIndex) const
|
|
|
|
{
|
2016-03-29 02:14:52 +03:00
|
|
|
return GetScrollMetadata(aIndex).GetMetrics();
|
2014-08-28 06:13:40 +04:00
|
|
|
}
|
|
|
|
|
2014-08-28 06:13:41 +04:00
|
|
|
bool
|
|
|
|
Layer::HasScrollableFrameMetrics() const
|
|
|
|
{
|
2016-03-29 02:14:52 +03:00
|
|
|
for (uint32_t i = 0; i < GetScrollMetadataCount(); i++) {
|
2014-08-28 06:13:41 +04:00
|
|
|
if (GetFrameMetrics(i).IsScrollable()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-28 06:13:42 +04:00
|
|
|
bool
|
2017-07-19 16:24:22 +03:00
|
|
|
Layer::IsScrollableWithoutContent() const
|
2014-08-28 06:13:42 +04:00
|
|
|
{
|
|
|
|
// A scrollable container layer with no children
|
|
|
|
return AsContainerLayer()
|
|
|
|
&& HasScrollableFrameMetrics()
|
|
|
|
&& !GetFirstChild();
|
|
|
|
}
|
|
|
|
|
2016-05-03 17:33:43 +03:00
|
|
|
Matrix4x4
|
2013-07-02 20:27:17 +04:00
|
|
|
Layer::GetTransform() const
|
2012-07-31 06:20:00 +04:00
|
|
|
{
|
2018-03-02 21:00:03 +03:00
|
|
|
Matrix4x4 transform = mSimpleAttrs.GetTransform();
|
2015-01-03 04:06:14 +03:00
|
|
|
transform.PostScale(GetPostXScale(), GetPostYScale(), 1.0f);
|
2013-07-02 20:27:17 +04:00
|
|
|
if (const ContainerLayer* c = AsContainerLayer()) {
|
2014-10-16 13:51:12 +04:00
|
|
|
transform.PreScale(c->GetPreXScale(), c->GetPreYScale(), 1.0f);
|
2012-08-04 01:29:22 +04:00
|
|
|
}
|
2012-07-31 06:20:00 +04:00
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
2016-01-07 02:56:58 +03:00
|
|
|
const CSSTransformMatrix
|
|
|
|
Layer::GetTransformTyped() const
|
|
|
|
{
|
|
|
|
return ViewAs<CSSTransformMatrix>(GetTransform());
|
|
|
|
}
|
|
|
|
|
2016-05-03 17:33:43 +03:00
|
|
|
Matrix4x4
|
2010-11-08 12:06:15 +03:00
|
|
|
Layer::GetLocalTransform()
|
2010-10-14 02:55:45 +04:00
|
|
|
{
|
2017-02-09 15:39:27 +03:00
|
|
|
if (HostLayer* shadow = AsHostLayer()) {
|
2016-05-01 13:54:26 +03:00
|
|
|
return shadow->GetShadowTransform();
|
2017-02-09 15:39:27 +03:00
|
|
|
}
|
|
|
|
return GetTransform();
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
|
|
|
|
2016-01-07 02:56:58 +03:00
|
|
|
const LayerToParentLayerMatrix4x4
|
|
|
|
Layer::GetLocalTransformTyped()
|
|
|
|
{
|
|
|
|
return ViewAs<LayerToParentLayerMatrix4x4>(GetLocalTransform());
|
|
|
|
}
|
|
|
|
|
2018-04-17 22:04:34 +03:00
|
|
|
bool
|
|
|
|
Layer::IsScrollbarContainer() const
|
|
|
|
{
|
|
|
|
const ScrollbarData& data = GetScrollbarData();
|
|
|
|
return (data.mScrollbarLayerType == ScrollbarLayerType::Container)
|
|
|
|
? data.mDirection.isSome()
|
|
|
|
: false;
|
|
|
|
}
|
|
|
|
|
2017-04-12 11:40:48 +03:00
|
|
|
bool
|
|
|
|
Layer::HasOpacityAnimation() const
|
|
|
|
{
|
2017-07-21 09:21:47 +03:00
|
|
|
return mAnimationInfo.HasOpacityAnimation();
|
2017-04-12 11:40:48 +03:00
|
|
|
}
|
|
|
|
|
2015-02-27 01:45:37 +03:00
|
|
|
bool
|
|
|
|
Layer::HasTransformAnimation() const
|
|
|
|
{
|
2017-07-21 09:21:47 +03:00
|
|
|
return mAnimationInfo.HasTransformAnimation();
|
2015-02-27 01:45:37 +03:00
|
|
|
}
|
|
|
|
|
2012-10-03 09:55:50 +04:00
|
|
|
void
|
|
|
|
Layer::ApplyPendingUpdatesForThisTransaction()
|
|
|
|
{
|
2018-03-02 21:00:03 +03:00
|
|
|
if (mPendingTransform && *mPendingTransform != mSimpleAttrs.GetTransform()) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PendingUpdatesForThisTransaction", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
mSimpleAttrs.SetTransform(*mPendingTransform);
|
2017-01-31 08:36:23 +03:00
|
|
|
MutatedSimple();
|
2012-10-03 09:55:50 +04:00
|
|
|
}
|
|
|
|
mPendingTransform = nullptr;
|
2014-03-05 08:13:21 +04:00
|
|
|
|
2017-07-21 09:21:47 +03:00
|
|
|
if (mAnimationInfo.ApplyPendingUpdatesForThisTransaction()) {
|
2014-03-05 08:13:21 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PendingUpdatesForThisTransaction", this));
|
|
|
|
Mutated();
|
|
|
|
}
|
2016-04-13 17:21:13 +03:00
|
|
|
|
|
|
|
for (size_t i = 0; i < mScrollMetadata.Length(); i++) {
|
|
|
|
FrameMetrics& fm = mScrollMetadata[i].GetMetrics();
|
|
|
|
Maybe<ScrollUpdateInfo> update = Manager()->GetPendingScrollInfoUpdate(fm.GetScrollId());
|
|
|
|
if (update) {
|
|
|
|
fm.UpdatePendingScrollInfo(update.value());
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
2012-10-03 09:55:50 +04:00
|
|
|
}
|
|
|
|
|
2016-01-06 04:08:45 +03:00
|
|
|
float
|
2012-07-31 21:28:20 +04:00
|
|
|
Layer::GetLocalOpacity()
|
|
|
|
{
|
2018-03-02 21:00:03 +03:00
|
|
|
float opacity = mSimpleAttrs.GetOpacity();
|
2016-11-24 08:11:27 +03:00
|
|
|
if (HostLayer* shadow = AsHostLayer())
|
2015-08-27 01:15:47 +03:00
|
|
|
opacity = shadow->GetShadowOpacity();
|
|
|
|
return std::min(std::max(opacity, 0.0f), 1.0f);
|
2012-07-31 21:28:20 +04:00
|
|
|
}
|
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
float
|
|
|
|
Layer::GetEffectiveOpacity()
|
|
|
|
{
|
2012-07-31 21:28:20 +04:00
|
|
|
float opacity = GetLocalOpacity();
|
2010-11-08 12:06:15 +03:00
|
|
|
for (ContainerLayer* c = GetParent(); c && !c->UseIntermediateSurface();
|
|
|
|
c = c->GetParent()) {
|
2012-07-31 21:28:20 +04:00
|
|
|
opacity *= c->GetLocalOpacity();
|
2010-10-14 02:55:45 +04:00
|
|
|
}
|
2010-11-08 12:06:15 +03:00
|
|
|
return opacity;
|
2010-10-14 02:55:45 +04:00
|
|
|
}
|
2016-05-01 13:54:26 +03:00
|
|
|
|
2014-02-12 19:07:46 +04:00
|
|
|
CompositionOp
|
2013-09-15 07:23:46 +04:00
|
|
|
Layer::GetEffectiveMixBlendMode()
|
|
|
|
{
|
2018-03-02 21:00:03 +03:00
|
|
|
if (mSimpleAttrs.GetMixBlendMode() != CompositionOp::OP_OVER)
|
|
|
|
return mSimpleAttrs.GetMixBlendMode();
|
2013-09-15 07:23:46 +04:00
|
|
|
for (ContainerLayer* c = GetParent(); c && !c->UseIntermediateSurface();
|
|
|
|
c = c->GetParent()) {
|
2018-03-02 21:00:03 +03:00
|
|
|
if(c->mSimpleAttrs.GetMixBlendMode() != CompositionOp::OP_OVER)
|
|
|
|
return c->mSimpleAttrs.GetMixBlendMode();
|
2013-09-15 07:23:46 +04:00
|
|
|
}
|
|
|
|
|
2018-03-02 21:00:03 +03:00
|
|
|
return mSimpleAttrs.GetMixBlendMode();
|
2013-09-15 07:23:46 +04:00
|
|
|
}
|
2010-10-14 02:55:45 +04:00
|
|
|
|
2017-08-25 06:41:29 +03:00
|
|
|
Matrix4x4
|
|
|
|
Layer::ComputeTransformToPreserve3DRoot()
|
|
|
|
{
|
|
|
|
Matrix4x4 transform = GetLocalTransform();
|
|
|
|
for (Layer* layer = GetParent();
|
|
|
|
layer && layer->Extend3DContext();
|
|
|
|
layer = layer->GetParent()) {
|
|
|
|
transform = transform * layer->GetLocalTransform();
|
|
|
|
}
|
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
2012-02-08 02:27:44 +04:00
|
|
|
void
|
2015-07-01 04:07:09 +03:00
|
|
|
Layer::ComputeEffectiveTransformForMaskLayers(const gfx::Matrix4x4& aTransformToSurface)
|
2012-02-08 02:27:44 +04:00
|
|
|
{
|
2015-07-01 04:07:09 +03:00
|
|
|
if (GetMaskLayer()) {
|
|
|
|
ComputeEffectiveTransformForMaskLayer(GetMaskLayer(), aTransformToSurface);
|
|
|
|
}
|
|
|
|
for (size_t i = 0; i < GetAncestorMaskLayerCount(); i++) {
|
|
|
|
Layer* maskLayer = GetAncestorMaskLayerAt(i);
|
|
|
|
ComputeEffectiveTransformForMaskLayer(maskLayer, aTransformToSurface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
Layer::ComputeEffectiveTransformForMaskLayer(Layer* aMaskLayer, const gfx::Matrix4x4& aTransformToSurface)
|
|
|
|
{
|
|
|
|
aMaskLayer->mEffectiveTransform = aTransformToSurface;
|
2012-07-25 12:48:09 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2015-07-01 04:07:09 +03:00
|
|
|
bool maskIs2D = aMaskLayer->GetTransform().CanDraw2D();
|
|
|
|
NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!");
|
2012-07-25 12:48:09 +04:00
|
|
|
#endif
|
2015-07-01 04:07:09 +03:00
|
|
|
// The mask layer can have an async transform applied to it in some
|
|
|
|
// situations, so be sure to use its GetLocalTransform() rather than
|
|
|
|
// its GetTransform().
|
|
|
|
aMaskLayer->mEffectiveTransform = aMaskLayer->GetLocalTransform() *
|
|
|
|
aMaskLayer->mEffectiveTransform;
|
2012-02-08 02:27:44 +04:00
|
|
|
}
|
|
|
|
|
2014-07-30 22:36:15 +04:00
|
|
|
RenderTargetRect
|
|
|
|
Layer::TransformRectToRenderTarget(const LayerIntRect& aRect)
|
|
|
|
{
|
|
|
|
LayerRect rect(aRect);
|
2015-11-10 01:49:46 +03:00
|
|
|
RenderTargetRect quad = RenderTargetRect::FromUnknownRect(
|
|
|
|
GetEffectiveTransform().TransformBounds(rect.ToUnknownRect()));
|
2014-07-30 22:36:15 +04:00
|
|
|
return quad;
|
|
|
|
}
|
|
|
|
|
2015-01-29 22:41:55 +03:00
|
|
|
bool
|
|
|
|
Layer::GetVisibleRegionRelativeToRootLayer(nsIntRegion& aResult,
|
2016-07-26 17:48:34 +03:00
|
|
|
IntPoint* aLayerOffset)
|
2015-01-29 22:41:55 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aLayerOffset, "invalid offset pointer");
|
|
|
|
|
2015-10-06 22:23:24 +03:00
|
|
|
if (!GetParent()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-01-29 22:41:55 +03:00
|
|
|
IntPoint offset;
|
2016-02-14 03:50:51 +03:00
|
|
|
aResult = GetLocalVisibleRegion().ToUnknownRegion();
|
2015-01-29 22:41:55 +03:00
|
|
|
for (Layer* layer = this; layer; layer = layer->GetParent()) {
|
|
|
|
gfx::Matrix matrix;
|
|
|
|
if (!layer->GetLocalTransform().Is2D(&matrix) ||
|
|
|
|
!matrix.IsTranslation()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The offset of |layer| to its parent.
|
2016-07-26 17:48:34 +03:00
|
|
|
auto currentLayerOffset = IntPoint::Round(matrix.GetTranslation());
|
2015-01-29 22:41:55 +03:00
|
|
|
|
|
|
|
// Translate the accumulated visible region of |this| by the offset of
|
|
|
|
// |layer|.
|
|
|
|
aResult.MoveBy(currentLayerOffset.x, currentLayerOffset.y);
|
|
|
|
|
|
|
|
// If the parent layer clips its lower layers, clip the visible region
|
|
|
|
// we're accumulating.
|
2016-05-02 18:27:35 +03:00
|
|
|
if (layer->GetLocalClipRect()) {
|
|
|
|
aResult.AndWith(layer->GetLocalClipRect()->ToUnknownRect());
|
2015-01-29 22:41:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now we need to walk across the list of siblings for this parent layer,
|
|
|
|
// checking to see if any of these layer trees obscure |this|. If so,
|
|
|
|
// remove these areas from the visible region as well. This will pick up
|
|
|
|
// chrome overlays like a tab modal prompt.
|
|
|
|
Layer* sibling;
|
|
|
|
for (sibling = layer->GetNextSibling(); sibling;
|
|
|
|
sibling = sibling->GetNextSibling()) {
|
|
|
|
gfx::Matrix siblingMatrix;
|
|
|
|
if (!sibling->GetLocalTransform().Is2D(&siblingMatrix) ||
|
|
|
|
!siblingMatrix.IsTranslation()) {
|
2016-03-21 17:52:21 +03:00
|
|
|
continue;
|
2015-01-29 22:41:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Retreive the translation from sibling to |layer|. The accumulated
|
|
|
|
// visible region is currently oriented with |layer|.
|
2016-07-26 17:48:34 +03:00
|
|
|
auto siblingOffset = IntPoint::Round(siblingMatrix.GetTranslation());
|
2016-02-14 03:50:51 +03:00
|
|
|
nsIntRegion siblingVisibleRegion(sibling->GetLocalVisibleRegion().ToUnknownRegion());
|
2015-01-29 22:41:55 +03:00
|
|
|
// Translate the siblings region to |layer|'s origin.
|
|
|
|
siblingVisibleRegion.MoveBy(-siblingOffset.x, -siblingOffset.y);
|
2015-10-27 23:06:57 +03:00
|
|
|
// Apply the sibling's clip.
|
|
|
|
// Layer clip rects are not affected by the layer's transform.
|
2016-05-02 18:27:35 +03:00
|
|
|
Maybe<ParentLayerIntRect> clipRect = sibling->GetLocalClipRect();
|
2015-10-27 23:06:57 +03:00
|
|
|
if (clipRect) {
|
2015-11-07 06:13:40 +03:00
|
|
|
siblingVisibleRegion.AndWith(clipRect->ToUnknownRect());
|
2015-10-27 23:06:57 +03:00
|
|
|
}
|
2015-01-29 22:41:55 +03:00
|
|
|
// Subtract the sibling visible region from the visible region of |this|.
|
|
|
|
aResult.SubOut(siblingVisibleRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Keep track of the total offset for aLayerOffset. We use this in plugin
|
|
|
|
// positioning code.
|
|
|
|
offset += currentLayerOffset;
|
|
|
|
}
|
|
|
|
|
2016-07-26 17:48:34 +03:00
|
|
|
*aLayerOffset = IntPoint(offset.x, offset.y);
|
2015-01-29 22:41:55 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-07-21 09:21:47 +03:00
|
|
|
InfallibleTArray<AnimData>&
|
|
|
|
Layer::GetAnimationData()
|
|
|
|
{
|
|
|
|
return mAnimationInfo.GetAnimationData();
|
|
|
|
}
|
|
|
|
|
2015-06-03 02:34:28 +03:00
|
|
|
Maybe<ParentLayerIntRect>
|
|
|
|
Layer::GetCombinedClipRect() const
|
|
|
|
{
|
|
|
|
Maybe<ParentLayerIntRect> clip = GetClipRect();
|
|
|
|
|
2016-04-30 00:32:53 +03:00
|
|
|
clip = IntersectMaybeRects(clip, GetScrolledClipRect());
|
|
|
|
|
2016-03-29 02:14:52 +03:00
|
|
|
for (size_t i = 0; i < mScrollMetadata.Length(); i++) {
|
2016-04-29 22:44:08 +03:00
|
|
|
clip = IntersectMaybeRects(clip, mScrollMetadata[i].GetClipRect());
|
2015-06-03 02:34:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return clip;
|
|
|
|
}
|
|
|
|
|
2013-07-02 20:01:46 +04:00
|
|
|
ContainerLayer::ContainerLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: Layer(aManager, aImplData),
|
|
|
|
mFirstChild(nullptr),
|
|
|
|
mLastChild(nullptr),
|
|
|
|
mPreXScale(1.0f),
|
|
|
|
mPreYScale(1.0f),
|
|
|
|
mInheritedXScale(1.0f),
|
|
|
|
mInheritedYScale(1.0f),
|
2015-01-03 04:06:14 +03:00
|
|
|
mPresShellResolution(1.0f),
|
|
|
|
mScaleToResolution(false),
|
2013-07-02 20:01:46 +04:00
|
|
|
mUseIntermediateSurface(false),
|
|
|
|
mSupportsComponentAlphaChildren(false),
|
2014-11-19 01:33:36 +03:00
|
|
|
mMayHaveReadbackChild(false),
|
2017-11-09 17:03:52 +03:00
|
|
|
mChildrenChanged(false)
|
2013-07-02 20:01:46 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-07-29 18:57:03 +03:00
|
|
|
ContainerLayer::~ContainerLayer()
|
|
|
|
{
|
|
|
|
}
|
2013-07-02 20:01:46 +04:00
|
|
|
|
2014-02-22 01:50:25 +04:00
|
|
|
bool
|
2013-09-02 02:19:18 +04:00
|
|
|
ContainerLayer::InsertAfter(Layer* aChild, Layer* aAfter)
|
|
|
|
{
|
2014-02-22 01:50:25 +04:00
|
|
|
if(aChild->Manager() != Manager()) {
|
|
|
|
NS_ERROR("Child has wrong manager");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(aChild->GetParent()) {
|
|
|
|
NS_ERROR("aChild already in the tree");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (aChild->GetNextSibling() || aChild->GetPrevSibling()) {
|
|
|
|
NS_ERROR("aChild already has siblings?");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (aAfter && (aAfter->Manager() != Manager() ||
|
|
|
|
aAfter->GetParent() != this))
|
|
|
|
{
|
|
|
|
NS_ERROR("aAfter is not our child");
|
|
|
|
return false;
|
|
|
|
}
|
2013-09-02 02:19:18 +04:00
|
|
|
|
|
|
|
aChild->SetParent(this);
|
|
|
|
if (aAfter == mLastChild) {
|
|
|
|
mLastChild = aChild;
|
|
|
|
}
|
|
|
|
if (!aAfter) {
|
|
|
|
aChild->SetNextSibling(mFirstChild);
|
|
|
|
if (mFirstChild) {
|
|
|
|
mFirstChild->SetPrevSibling(aChild);
|
|
|
|
}
|
|
|
|
mFirstChild = aChild;
|
|
|
|
NS_ADDREF(aChild);
|
|
|
|
DidInsertChild(aChild);
|
2014-02-22 01:50:25 +04:00
|
|
|
return true;
|
2013-09-02 02:19:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Layer* next = aAfter->GetNextSibling();
|
|
|
|
aChild->SetNextSibling(next);
|
|
|
|
aChild->SetPrevSibling(aAfter);
|
|
|
|
if (next) {
|
|
|
|
next->SetPrevSibling(aChild);
|
|
|
|
}
|
|
|
|
aAfter->SetNextSibling(aChild);
|
|
|
|
NS_ADDREF(aChild);
|
|
|
|
DidInsertChild(aChild);
|
2014-02-22 01:50:25 +04:00
|
|
|
return true;
|
2013-09-02 02:19:18 +04:00
|
|
|
}
|
|
|
|
|
2017-01-05 21:41:10 +03:00
|
|
|
void
|
|
|
|
ContainerLayer::RemoveAllChildren()
|
|
|
|
{
|
|
|
|
// Optimizes "while (mFirstChild) ContainerLayer::RemoveChild(mFirstChild);"
|
|
|
|
Layer* current = mFirstChild;
|
|
|
|
|
|
|
|
// This is inlining DidRemoveChild() on each layer; we can skip the calls
|
|
|
|
// to NotifyPaintedLayerRemoved as it gets taken care of when as we call
|
|
|
|
// NotifyRemoved prior to removing any layers.
|
|
|
|
while (current) {
|
|
|
|
Layer* next = current->GetNextSibling();
|
|
|
|
if (current->GetType() == TYPE_READBACK) {
|
|
|
|
static_cast<ReadbackLayer*>(current)->NotifyRemoved();
|
|
|
|
}
|
|
|
|
current = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
current = mFirstChild;
|
|
|
|
mFirstChild = nullptr;
|
|
|
|
while (current) {
|
|
|
|
MOZ_ASSERT(!current->GetPrevSibling());
|
|
|
|
|
|
|
|
Layer* next = current->GetNextSibling();
|
|
|
|
current->SetParent(nullptr);
|
|
|
|
current->SetNextSibling(nullptr);
|
|
|
|
if (next) {
|
|
|
|
next->SetPrevSibling(nullptr);
|
|
|
|
}
|
|
|
|
NS_RELEASE(current);
|
|
|
|
current = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note that ContainerLayer::RemoveAllChildren is an optimized
|
|
|
|
// version of this code; if you make changes to ContainerLayer::RemoveChild
|
|
|
|
// consider whether the matching changes need to be made to
|
|
|
|
// ContainerLayer::RemoveAllChildren
|
2014-02-22 01:50:25 +04:00
|
|
|
bool
|
2013-09-02 02:19:18 +04:00
|
|
|
ContainerLayer::RemoveChild(Layer *aChild)
|
|
|
|
{
|
2014-02-22 01:50:25 +04:00
|
|
|
if (aChild->Manager() != Manager()) {
|
|
|
|
NS_ERROR("Child has wrong manager");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (aChild->GetParent() != this) {
|
|
|
|
NS_ERROR("aChild not our child");
|
|
|
|
return false;
|
|
|
|
}
|
2013-09-02 02:19:18 +04:00
|
|
|
|
|
|
|
Layer* prev = aChild->GetPrevSibling();
|
|
|
|
Layer* next = aChild->GetNextSibling();
|
|
|
|
if (prev) {
|
|
|
|
prev->SetNextSibling(next);
|
|
|
|
} else {
|
|
|
|
this->mFirstChild = next;
|
|
|
|
}
|
|
|
|
if (next) {
|
|
|
|
next->SetPrevSibling(prev);
|
|
|
|
} else {
|
|
|
|
this->mLastChild = prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
aChild->SetNextSibling(nullptr);
|
|
|
|
aChild->SetPrevSibling(nullptr);
|
|
|
|
aChild->SetParent(nullptr);
|
|
|
|
|
|
|
|
this->DidRemoveChild(aChild);
|
|
|
|
NS_RELEASE(aChild);
|
2014-02-22 01:50:25 +04:00
|
|
|
return true;
|
2013-09-02 02:19:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-22 01:50:25 +04:00
|
|
|
bool
|
2013-09-02 02:19:18 +04:00
|
|
|
ContainerLayer::RepositionChild(Layer* aChild, Layer* aAfter)
|
|
|
|
{
|
2014-02-22 01:50:25 +04:00
|
|
|
if (aChild->Manager() != Manager()) {
|
|
|
|
NS_ERROR("Child has wrong manager");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (aChild->GetParent() != this) {
|
|
|
|
NS_ERROR("aChild not our child");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (aAfter && (aAfter->Manager() != Manager() ||
|
|
|
|
aAfter->GetParent() != this))
|
|
|
|
{
|
|
|
|
NS_ERROR("aAfter is not our child");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (aChild == aAfter) {
|
|
|
|
NS_ERROR("aChild cannot be the same as aAfter");
|
|
|
|
return false;
|
|
|
|
}
|
2013-09-02 02:19:18 +04:00
|
|
|
|
|
|
|
Layer* prev = aChild->GetPrevSibling();
|
|
|
|
Layer* next = aChild->GetNextSibling();
|
|
|
|
if (prev == aAfter) {
|
|
|
|
// aChild is already in the correct position, nothing to do.
|
2014-02-22 01:50:25 +04:00
|
|
|
return true;
|
2013-09-02 02:19:18 +04:00
|
|
|
}
|
|
|
|
if (prev) {
|
|
|
|
prev->SetNextSibling(next);
|
2014-02-19 01:38:30 +04:00
|
|
|
} else {
|
|
|
|
mFirstChild = next;
|
2013-09-02 02:19:18 +04:00
|
|
|
}
|
|
|
|
if (next) {
|
|
|
|
next->SetPrevSibling(prev);
|
2014-02-19 01:38:30 +04:00
|
|
|
} else {
|
|
|
|
mLastChild = prev;
|
2013-09-02 02:19:18 +04:00
|
|
|
}
|
|
|
|
if (!aAfter) {
|
|
|
|
aChild->SetPrevSibling(nullptr);
|
|
|
|
aChild->SetNextSibling(mFirstChild);
|
|
|
|
if (mFirstChild) {
|
|
|
|
mFirstChild->SetPrevSibling(aChild);
|
|
|
|
}
|
|
|
|
mFirstChild = aChild;
|
2014-02-22 01:50:25 +04:00
|
|
|
return true;
|
2013-09-02 02:19:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Layer* afterNext = aAfter->GetNextSibling();
|
|
|
|
if (afterNext) {
|
|
|
|
afterNext->SetPrevSibling(aChild);
|
|
|
|
} else {
|
|
|
|
mLastChild = aChild;
|
|
|
|
}
|
|
|
|
aAfter->SetNextSibling(aChild);
|
|
|
|
aChild->SetPrevSibling(aAfter);
|
|
|
|
aChild->SetNextSibling(afterNext);
|
2014-02-22 01:50:25 +04:00
|
|
|
return true;
|
2013-09-02 02:19:18 +04:00
|
|
|
}
|
|
|
|
|
2011-08-09 23:38:26 +04:00
|
|
|
void
|
|
|
|
ContainerLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
|
|
|
|
{
|
2014-08-12 04:00:37 +04:00
|
|
|
aAttrs = ContainerLayerAttributes(mPreXScale, mPreYScale,
|
2014-07-09 23:26:18 +04:00
|
|
|
mInheritedXScale, mInheritedYScale,
|
2017-11-09 17:03:52 +03:00
|
|
|
mPresShellResolution, mScaleToResolution);
|
2011-08-09 23:38:26 +04:00
|
|
|
}
|
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
bool
|
|
|
|
ContainerLayer::Creates3DContextWithExtendingChildren()
|
|
|
|
{
|
|
|
|
if (Extend3DContext()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (Layer* child = GetFirstChild();
|
|
|
|
child;
|
|
|
|
child = child->GetNextSibling()) {
|
|
|
|
if (child->Extend3DContext()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-11-08 12:06:15 +03:00
|
|
|
ContainerLayer::HasMultipleChildren()
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t count = 0;
|
2010-11-08 12:06:15 +03:00
|
|
|
for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) {
|
2016-05-02 18:27:35 +03:00
|
|
|
const Maybe<ParentLayerIntRect>& clipRect = child->GetLocalClipRect();
|
2010-11-08 12:06:15 +03:00
|
|
|
if (clipRect && clipRect->IsEmpty())
|
|
|
|
continue;
|
2016-02-13 04:24:38 +03:00
|
|
|
if (child->GetLocalVisibleRegion().IsEmpty())
|
2010-11-08 12:06:15 +03:00
|
|
|
continue;
|
|
|
|
++count;
|
|
|
|
if (count > 1)
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
2010-10-14 02:55:45 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
2010-10-14 02:55:45 +04:00
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
/**
|
|
|
|
* Collect all leaf descendants of the current 3D context.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ContainerLayer::Collect3DContextLeaves(nsTArray<Layer*>& aToSort)
|
|
|
|
{
|
2016-03-10 12:20:40 +03:00
|
|
|
ForEachNode<ForwardIterator>(
|
|
|
|
(Layer*) this,
|
|
|
|
[this, &aToSort](Layer* layer)
|
|
|
|
{
|
|
|
|
ContainerLayer* container = layer->AsContainerLayer();
|
|
|
|
if (layer == this || (container && container->Extend3DContext() &&
|
|
|
|
!container->UseIntermediateSurface())) {
|
|
|
|
return TraversalFlag::Continue;
|
|
|
|
}
|
2017-02-09 15:39:27 +03:00
|
|
|
aToSort.AppendElement(layer);
|
|
|
|
return TraversalFlag::Skip;
|
2016-03-10 12:20:40 +03:00
|
|
|
}
|
|
|
|
);
|
2015-09-17 04:31:00 +03:00
|
|
|
}
|
|
|
|
|
2016-12-07 02:39:01 +03:00
|
|
|
static nsTArray<LayerPolygon>
|
|
|
|
SortLayersWithBSPTree(nsTArray<Layer*>& aArray)
|
|
|
|
{
|
2017-04-10 17:35:56 +03:00
|
|
|
std::list<LayerPolygon> inputLayers;
|
2016-12-07 02:39:01 +03:00
|
|
|
|
|
|
|
// Build a list of polygons to be sorted.
|
|
|
|
for (Layer* layer : aArray) {
|
|
|
|
// Ignore invisible layers.
|
|
|
|
if (!layer->IsVisible()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const gfx::IntRect& bounds =
|
|
|
|
layer->GetLocalVisibleRegion().ToUnknownRegion().GetBounds();
|
2017-02-23 22:42:10 +03:00
|
|
|
|
2016-12-07 02:39:01 +03:00
|
|
|
const gfx::Matrix4x4& transform = layer->GetEffectiveTransform();
|
|
|
|
|
2017-02-23 22:42:10 +03:00
|
|
|
if (transform.IsSingular()) {
|
|
|
|
// Transform cannot be inverted.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-12-07 02:39:01 +03:00
|
|
|
gfx::Polygon polygon = gfx::Polygon::FromRect(gfx::Rect(bounds));
|
|
|
|
|
|
|
|
// Transform the polygon to screen space.
|
|
|
|
polygon.TransformToScreenSpace(transform);
|
|
|
|
|
|
|
|
if (polygon.GetPoints().Length() >= 3) {
|
|
|
|
inputLayers.push_back(LayerPolygon(layer, Move(polygon)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inputLayers.empty()) {
|
2017-04-10 17:35:56 +03:00
|
|
|
return nsTArray<LayerPolygon>();
|
2016-12-07 02:39:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Build a BSP tree from the list of polygons.
|
|
|
|
BSPTree tree(inputLayers);
|
2017-04-10 17:35:56 +03:00
|
|
|
|
|
|
|
nsTArray<LayerPolygon> orderedLayers(tree.GetDrawOrder());
|
2016-12-07 02:39:01 +03:00
|
|
|
|
|
|
|
// Transform the polygons back to layer space.
|
|
|
|
for (LayerPolygon& layerPolygon : orderedLayers) {
|
|
|
|
gfx::Matrix4x4 inverse =
|
|
|
|
layerPolygon.layer->GetEffectiveTransform().Inverse();
|
|
|
|
|
|
|
|
MOZ_ASSERT(layerPolygon.geometry);
|
|
|
|
layerPolygon.geometry->TransformToLayerSpace(inverse);
|
|
|
|
}
|
|
|
|
|
|
|
|
return orderedLayers;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsTArray<LayerPolygon>
|
|
|
|
StripLayerGeometry(const nsTArray<LayerPolygon>& aLayers)
|
|
|
|
{
|
|
|
|
nsTArray<LayerPolygon> layers;
|
|
|
|
std::set<Layer*> uniqueLayers;
|
|
|
|
|
|
|
|
for (const LayerPolygon& layerPolygon : aLayers) {
|
|
|
|
auto result = uniqueLayers.insert(layerPolygon.layer);
|
|
|
|
|
|
|
|
if (result.second) {
|
|
|
|
// Layer was added to the set.
|
|
|
|
layers.AppendElement(LayerPolygon(layerPolygon.layer));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return layers;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<LayerPolygon>
|
|
|
|
ContainerLayer::SortChildrenBy3DZOrder(SortMode aSortMode)
|
2011-10-07 01:23:18 +04:00
|
|
|
{
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<Layer*, 10> toSort;
|
2016-12-07 02:39:01 +03:00
|
|
|
nsTArray<LayerPolygon> drawOrder;
|
|
|
|
|
|
|
|
for (Layer* layer = GetFirstChild(); layer; layer = layer->GetNextSibling()) {
|
|
|
|
ContainerLayer* container = layer->AsContainerLayer();
|
2011-10-07 01:23:18 +04:00
|
|
|
|
2015-09-28 10:43:00 +03:00
|
|
|
if (container && container->Extend3DContext() &&
|
|
|
|
!container->UseIntermediateSurface()) {
|
2016-12-07 02:39:01 +03:00
|
|
|
|
|
|
|
// Collect 3D layers in toSort array.
|
2015-09-17 04:31:00 +03:00
|
|
|
container->Collect3DContextLeaves(toSort);
|
2016-12-07 02:39:01 +03:00
|
|
|
|
|
|
|
// Sort the 3D layers.
|
2011-10-07 01:23:18 +04:00
|
|
|
if (toSort.Length() > 0) {
|
2016-12-07 02:39:01 +03:00
|
|
|
nsTArray<LayerPolygon> sorted = SortLayersWithBSPTree(toSort);
|
|
|
|
drawOrder.AppendElements(Move(sorted));
|
|
|
|
|
2015-09-08 21:22:02 +03:00
|
|
|
toSort.ClearAndRetainStorage();
|
2011-10-07 01:23:18 +04:00
|
|
|
}
|
2016-12-07 02:39:01 +03:00
|
|
|
|
|
|
|
continue;
|
2011-10-07 01:23:18 +04:00
|
|
|
}
|
2016-12-07 02:39:01 +03:00
|
|
|
|
|
|
|
drawOrder.AppendElement(LayerPolygon(layer));
|
2011-10-07 01:23:18 +04:00
|
|
|
}
|
2016-12-07 02:39:01 +03:00
|
|
|
|
|
|
|
if (aSortMode == SortMode::WITHOUT_GEOMETRY) {
|
|
|
|
// Compositor does not support arbitrary layers, strip the layer geometry
|
|
|
|
// and duplicate layers.
|
|
|
|
return StripLayerGeometry(drawOrder);
|
2011-10-07 01:23:18 +04:00
|
|
|
}
|
2016-12-07 02:39:01 +03:00
|
|
|
|
|
|
|
return drawOrder;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContainerLayer::AnyAncestorOrThisIs3DContextLeaf()
|
|
|
|
{
|
|
|
|
Layer* parent = this;
|
|
|
|
while (parent != nullptr) {
|
|
|
|
if (parent->Is3DContextLeaf()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
parent = parent->GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2011-10-07 01:23:18 +04:00
|
|
|
}
|
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
void
|
2014-01-27 19:28:04 +04:00
|
|
|
ContainerLayer::DefaultComputeEffectiveTransforms(const Matrix4x4& aTransformToSurface)
|
2010-11-08 12:06:15 +03:00
|
|
|
{
|
2014-01-27 19:27:20 +04:00
|
|
|
Matrix residual;
|
2014-01-27 19:28:18 +04:00
|
|
|
Matrix4x4 idealTransform = GetLocalTransform() * aTransformToSurface;
|
2015-09-17 04:31:00 +03:00
|
|
|
|
|
|
|
// Keep 3D transforms for leaves to keep z-order sorting correct.
|
|
|
|
if (!Extend3DContext() && !Is3DContextLeaf()) {
|
|
|
|
idealTransform.ProjectTo2D();
|
|
|
|
}
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool useIntermediateSurface;
|
2015-06-21 19:27:31 +03:00
|
|
|
if (HasMaskLayers() ||
|
2014-05-09 13:41:56 +04:00
|
|
|
GetForceIsolatedGroup()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
useIntermediateSurface = true;
|
2012-03-01 12:26:09 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2015-10-28 16:31:00 +03:00
|
|
|
} else if (gfxEnv::DumpPaintIntermediate() && !Extend3DContext()) {
|
2012-03-01 12:26:09 +04:00
|
|
|
useIntermediateSurface = true;
|
|
|
|
#endif
|
2010-11-08 12:06:15 +03:00
|
|
|
} else {
|
2016-03-17 23:23:51 +03:00
|
|
|
/* Don't use an intermediate surface for opacity when it's within a 3d
|
|
|
|
* context, since we'd rather keep the 3d effects. This matches the
|
|
|
|
* WebKit/blink behaviour, but is changing in the latest spec.
|
|
|
|
*/
|
2012-02-08 02:27:44 +04:00
|
|
|
float opacity = GetEffectiveOpacity();
|
2014-05-09 13:41:56 +04:00
|
|
|
CompositionOp blendMode = GetEffectiveMixBlendMode();
|
2016-03-17 23:23:51 +03:00
|
|
|
if ((HasMultipleChildren() || Creates3DContextWithExtendingChildren()) &&
|
|
|
|
((opacity != 1.0f && !Extend3DContext()) ||
|
|
|
|
(blendMode != CompositionOp::OP_OVER))) {
|
|
|
|
useIntermediateSurface = true;
|
2016-12-07 02:39:01 +03:00
|
|
|
} else if ((!idealTransform.Is2D() || AnyAncestorOrThisIs3DContextLeaf()) &&
|
|
|
|
Creates3DContextWithExtendingChildren()) {
|
2012-02-08 02:27:44 +04:00
|
|
|
useIntermediateSurface = true;
|
2017-06-20 11:17:19 +03:00
|
|
|
} else if (blendMode != CompositionOp::OP_OVER &&
|
|
|
|
Manager()->BlendingRequiresIntermediateSurface()) {
|
|
|
|
useIntermediateSurface = true;
|
2012-02-08 02:27:44 +04:00
|
|
|
} else {
|
|
|
|
useIntermediateSurface = false;
|
2014-01-28 00:25:19 +04:00
|
|
|
gfx::Matrix contTransform;
|
2015-08-28 10:47:00 +03:00
|
|
|
bool checkClipRect = false;
|
|
|
|
bool checkMaskLayers = false;
|
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
if (!idealTransform.Is2D(&contTransform)) {
|
2015-08-28 10:47:00 +03:00
|
|
|
// In 3D case, always check if we should use IntermediateSurface.
|
|
|
|
checkClipRect = true;
|
|
|
|
checkMaskLayers = true;
|
|
|
|
} else {
|
2011-06-16 14:51:05 +04:00
|
|
|
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
2015-08-28 10:47:00 +03:00
|
|
|
if (!contTransform.PreservesAxisAlignedRectangles()) {
|
2011-06-16 14:51:05 +04:00
|
|
|
#else
|
2015-08-28 10:47:00 +03:00
|
|
|
if (gfx::ThebesMatrix(contTransform).HasNonIntegerTranslation()) {
|
2011-06-16 14:51:05 +04:00
|
|
|
#endif
|
2015-08-28 10:47:00 +03:00
|
|
|
checkClipRect = true;
|
|
|
|
}
|
|
|
|
/* In 2D case, only translation and/or positive scaling can be done w/o using IntermediateSurface.
|
|
|
|
* Otherwise, when rotation or flip happen, we should check whether to use IntermediateSurface.
|
|
|
|
*/
|
|
|
|
if (contTransform.HasNonAxisAlignedTransform() || contTransform.HasNegativeScaling()) {
|
|
|
|
checkMaskLayers = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (checkClipRect || checkMaskLayers) {
|
2012-02-08 02:27:44 +04:00
|
|
|
for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) {
|
2016-05-02 18:27:35 +03:00
|
|
|
const Maybe<ParentLayerIntRect>& clipRect = child->GetLocalClipRect();
|
2012-02-08 02:27:44 +04:00
|
|
|
/* We can't (easily) forward our transform to children with a non-empty clip
|
|
|
|
* rect since it would need to be adjusted for the transform. See
|
|
|
|
* the calculations performed by CalculateScissorRect above.
|
2012-06-27 00:06:32 +04:00
|
|
|
* Nor for a child with a mask layer.
|
2012-02-08 02:27:44 +04:00
|
|
|
*/
|
2016-02-13 04:24:38 +03:00
|
|
|
if (checkClipRect && (clipRect && !clipRect->IsEmpty() && !child->GetLocalVisibleRegion().IsEmpty())) {
|
2015-08-28 10:47:00 +03:00
|
|
|
useIntermediateSurface = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (checkMaskLayers && child->HasMaskLayers()) {
|
2012-02-08 02:27:44 +04:00
|
|
|
useIntermediateSurface = true;
|
|
|
|
break;
|
|
|
|
}
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-30 19:10:25 +03:00
|
|
|
NS_ASSERTION(!Extend3DContext() || !useIntermediateSurface, "Can't have an intermediate surface with preserve-3d!");
|
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
if (useIntermediateSurface) {
|
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform, &residual);
|
|
|
|
} else {
|
|
|
|
mEffectiveTransform = idealTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
// For layers extending 3d context, its ideal transform should be
|
|
|
|
// applied on children.
|
|
|
|
if (!Extend3DContext()) {
|
|
|
|
// Without this projection, non-container children would get a 3D
|
|
|
|
// transform while 2D is expected.
|
|
|
|
idealTransform.ProjectTo2D();
|
|
|
|
}
|
2018-03-08 10:00:50 +03:00
|
|
|
mUseIntermediateSurface = useIntermediateSurface;
|
2010-11-08 12:06:15 +03:00
|
|
|
if (useIntermediateSurface) {
|
2014-01-27 19:28:04 +04:00
|
|
|
ComputeEffectiveTransformsForChildren(Matrix4x4::From2D(residual));
|
2010-11-08 12:06:15 +03:00
|
|
|
} else {
|
2014-01-27 19:28:18 +04:00
|
|
|
ComputeEffectiveTransformsForChildren(idealTransform);
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
2012-02-08 02:27:44 +04:00
|
|
|
|
2016-03-21 23:06:58 +03:00
|
|
|
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
2010-10-14 02:55:45 +04:00
|
|
|
|
2014-05-09 14:06:20 +04:00
|
|
|
void
|
|
|
|
ContainerLayer::DefaultComputeSupportsComponentAlphaChildren(bool* aNeedsSurfaceCopy)
|
|
|
|
{
|
2014-07-18 10:48:23 +04:00
|
|
|
if (!(GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA_DESCENDANT) ||
|
|
|
|
!Manager()->AreComponentAlphaLayersEnabled()) {
|
2014-07-18 10:48:23 +04:00
|
|
|
mSupportsComponentAlphaChildren = false;
|
|
|
|
if (aNeedsSurfaceCopy) {
|
|
|
|
*aNeedsSurfaceCopy = false;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-18 10:48:23 +04:00
|
|
|
mSupportsComponentAlphaChildren = false;
|
2014-05-09 14:06:20 +04:00
|
|
|
bool needsSurfaceCopy = false;
|
2014-05-09 14:06:20 +04:00
|
|
|
CompositionOp blendMode = GetEffectiveMixBlendMode();
|
2014-05-09 14:06:20 +04:00
|
|
|
if (UseIntermediateSurface()) {
|
2016-02-14 03:50:51 +03:00
|
|
|
if (GetLocalVisibleRegion().GetNumRects() == 1 &&
|
2014-05-09 14:06:20 +04:00
|
|
|
(GetContentFlags() & Layer::CONTENT_OPAQUE))
|
|
|
|
{
|
2014-07-18 10:48:23 +04:00
|
|
|
mSupportsComponentAlphaChildren = true;
|
2014-05-09 14:06:20 +04:00
|
|
|
} else {
|
|
|
|
gfx::Matrix transform;
|
|
|
|
if (HasOpaqueAncestorLayer(this) &&
|
|
|
|
GetEffectiveTransform().Is2D(&transform) &&
|
2014-05-09 14:06:20 +04:00
|
|
|
!gfx::ThebesMatrix(transform).HasNonIntegerTranslation() &&
|
2017-10-11 03:39:41 +03:00
|
|
|
blendMode == gfx::CompositionOp::OP_OVER)
|
2017-06-20 11:17:22 +03:00
|
|
|
{
|
2014-07-18 10:48:23 +04:00
|
|
|
mSupportsComponentAlphaChildren = true;
|
2014-05-09 14:06:20 +04:00
|
|
|
needsSurfaceCopy = true;
|
|
|
|
}
|
|
|
|
}
|
2014-05-09 14:06:20 +04:00
|
|
|
} else if (blendMode == gfx::CompositionOp::OP_OVER) {
|
2014-07-18 10:48:23 +04:00
|
|
|
mSupportsComponentAlphaChildren =
|
2014-05-09 14:06:20 +04:00
|
|
|
(GetContentFlags() & Layer::CONTENT_OPAQUE) ||
|
|
|
|
(GetParent() && GetParent()->SupportsComponentAlphaChildren());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aNeedsSurfaceCopy) {
|
|
|
|
*aNeedsSurfaceCopy = mSupportsComponentAlphaChildren && needsSurfaceCopy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
void
|
2014-01-27 19:28:04 +04:00
|
|
|
ContainerLayer::ComputeEffectiveTransformsForChildren(const Matrix4x4& aTransformToSurface)
|
2010-11-08 12:06:15 +03:00
|
|
|
{
|
|
|
|
for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) {
|
|
|
|
l->ComputeEffectiveTransforms(aTransformToSurface);
|
|
|
|
}
|
|
|
|
}
|
2010-10-14 02:55:45 +04:00
|
|
|
|
2013-09-02 02:19:18 +04:00
|
|
|
/* static */ bool
|
|
|
|
ContainerLayer::HasOpaqueAncestorLayer(Layer* aLayer)
|
|
|
|
{
|
|
|
|
for (Layer* l = aLayer->GetParent(); l; l = l->GetParent()) {
|
|
|
|
if (l->GetContentFlags() & Layer::CONTENT_OPAQUE)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-05 21:41:10 +03:00
|
|
|
// Note that ContainerLayer::RemoveAllChildren contains an optimized
|
|
|
|
// version of this code; if you make changes to ContainerLayer::DidRemoveChild
|
|
|
|
// consider whether the matching changes need to be made to
|
|
|
|
// ContainerLayer::RemoveAllChildren
|
2011-02-17 01:43:30 +03:00
|
|
|
void
|
|
|
|
ContainerLayer::DidRemoveChild(Layer* aLayer)
|
|
|
|
{
|
2014-09-26 21:06:08 +04:00
|
|
|
PaintedLayer* tl = aLayer->AsPaintedLayer();
|
2011-02-17 01:43:30 +03:00
|
|
|
if (tl && tl->UsedForReadback()) {
|
|
|
|
for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) {
|
|
|
|
if (l->GetType() == TYPE_READBACK) {
|
2014-09-26 21:06:08 +04:00
|
|
|
static_cast<ReadbackLayer*>(l)->NotifyPaintedLayerRemoved(tl);
|
2011-02-17 01:43:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aLayer->GetType() == TYPE_READBACK) {
|
|
|
|
static_cast<ReadbackLayer*>(aLayer)->NotifyRemoved();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContainerLayer::DidInsertChild(Layer* aLayer)
|
|
|
|
{
|
|
|
|
if (aLayer->GetType() == TYPE_READBACK) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mMayHaveReadbackChild = true;
|
2011-02-17 01:43:30 +03:00
|
|
|
}
|
|
|
|
}
|
2012-07-18 03:59:45 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RefLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
|
|
|
|
{
|
2015-02-17 05:30:02 +03:00
|
|
|
aAttrs = RefLayerAttributes(GetReferentId(), mEventRegionsOverride);
|
2012-07-18 03:59:45 +04:00
|
|
|
}
|
|
|
|
|
2016-05-01 13:54:26 +03:00
|
|
|
/**
|
2013-01-23 22:47:44 +04:00
|
|
|
* StartFrameTimeRecording, together with StopFrameTimeRecording
|
2013-11-27 11:32:19 +04:00
|
|
|
* enable recording of frame intervals.
|
2013-01-23 22:47:44 +04:00
|
|
|
*
|
2013-11-27 11:32:19 +04:00
|
|
|
* To allow concurrent consumers, a cyclic array is used which serves all
|
|
|
|
* consumers, practically stateless with regard to consumers.
|
2013-01-23 22:47:44 +04:00
|
|
|
*
|
2013-11-27 11:32:19 +04:00
|
|
|
* To save resources, the buffer is allocated on first call to StartFrameTimeRecording
|
2013-01-23 22:47:44 +04:00
|
|
|
* and recording is paused if no consumer which called StartFrameTimeRecording is able
|
2013-11-27 11:32:19 +04:00
|
|
|
* to get valid results (because the cyclic buffer was overwritten since that call).
|
2013-01-23 22:47:44 +04:00
|
|
|
*
|
|
|
|
* To determine availability of the data upon StopFrameTimeRecording:
|
2017-04-07 07:08:18 +03:00
|
|
|
* - mRecording.mNextIndex increases on each RecordFrame, and never resets.
|
2013-01-23 22:47:44 +04:00
|
|
|
* - Cyclic buffer position is realized as mNextIndex % bufferSize.
|
|
|
|
* - StartFrameTimeRecording returns mNextIndex. When StopFrameTimeRecording is called,
|
|
|
|
* the required start index is passed as an arg, and we're able to calculate the required
|
|
|
|
* length. If this length is bigger than bufferSize, it means data was overwritten.
|
|
|
|
* otherwise, we can return the entire sequence.
|
|
|
|
* - To determine if we need to pause, mLatestStartIndex is updated to mNextIndex
|
|
|
|
* on each call to StartFrameTimeRecording. If this index gets overwritten,
|
|
|
|
* it means that all earlier start indices obtained via StartFrameTimeRecording
|
|
|
|
* were also overwritten, hence, no point in recording, so pause.
|
|
|
|
* - mCurrentRunStartIndex indicates the oldest index of the recording after which
|
|
|
|
* the recording was not paused. If StopFrameTimeRecording is invoked with a start index
|
|
|
|
* older than this, it means that some frames were not recorded, so data is invalid.
|
|
|
|
*/
|
|
|
|
uint32_t
|
2013-11-27 11:32:19 +04:00
|
|
|
LayerManager::StartFrameTimeRecording(int32_t aBufferSize)
|
2012-01-06 02:40:35 +04:00
|
|
|
{
|
2013-01-23 22:47:44 +04:00
|
|
|
if (mRecording.mIsPaused) {
|
|
|
|
mRecording.mIsPaused = false;
|
|
|
|
|
|
|
|
if (!mRecording.mIntervals.Length()) { // Initialize recording buffers
|
2014-02-14 21:56:35 +04:00
|
|
|
mRecording.mIntervals.SetLength(aBufferSize);
|
2013-01-23 22:47:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// After being paused, recent values got invalid. Update them to now.
|
|
|
|
mRecording.mLastFrameTime = TimeStamp::Now();
|
|
|
|
|
|
|
|
// Any recording which started before this is invalid, since we were paused.
|
|
|
|
mRecording.mCurrentRunStartIndex = mRecording.mNextIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we'll overwrite this index, there are no more consumers with aStartIndex
|
|
|
|
// for which we're able to provide the full recording, so no point in keep recording.
|
|
|
|
mRecording.mLatestStartIndex = mRecording.mNextIndex;
|
|
|
|
return mRecording.mNextIndex;
|
2013-01-04 06:53:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-11-27 11:32:19 +04:00
|
|
|
LayerManager::RecordFrame()
|
2012-01-06 02:40:35 +04:00
|
|
|
{
|
2013-01-23 22:47:44 +04:00
|
|
|
if (!mRecording.mIsPaused) {
|
2012-01-06 02:40:35 +04:00
|
|
|
TimeStamp now = TimeStamp::Now();
|
2013-01-23 22:47:44 +04:00
|
|
|
uint32_t i = mRecording.mNextIndex % mRecording.mIntervals.Length();
|
|
|
|
mRecording.mIntervals[i] = static_cast<float>((now - mRecording.mLastFrameTime)
|
|
|
|
.ToMilliseconds());
|
|
|
|
mRecording.mNextIndex++;
|
|
|
|
mRecording.mLastFrameTime = now;
|
|
|
|
|
|
|
|
if (mRecording.mNextIndex > (mRecording.mLatestStartIndex + mRecording.mIntervals.Length())) {
|
|
|
|
// We've just overwritten the most recent recording start -> pause.
|
|
|
|
mRecording.mIsPaused = true;
|
|
|
|
}
|
2012-01-06 02:40:35 +04:00
|
|
|
}
|
2013-11-27 11:32:19 +04:00
|
|
|
}
|
|
|
|
|
2012-11-29 20:14:13 +04:00
|
|
|
void
|
2013-01-23 22:47:44 +04:00
|
|
|
LayerManager::StopFrameTimeRecording(uint32_t aStartIndex,
|
2013-11-27 11:32:19 +04:00
|
|
|
nsTArray<float>& aFrameIntervals)
|
2012-01-06 02:40:35 +04:00
|
|
|
{
|
2013-01-23 22:47:44 +04:00
|
|
|
uint32_t bufferSize = mRecording.mIntervals.Length();
|
|
|
|
uint32_t length = mRecording.mNextIndex - aStartIndex;
|
|
|
|
if (mRecording.mIsPaused || length > bufferSize || aStartIndex < mRecording.mCurrentRunStartIndex) {
|
|
|
|
// aStartIndex is too old. Also if aStartIndex was issued before mRecordingNextIndex overflowed (uint32_t)
|
|
|
|
// and stopped after the overflow (would happen once every 828 days of constant 60fps).
|
|
|
|
length = 0;
|
|
|
|
}
|
|
|
|
|
2014-02-14 21:56:35 +04:00
|
|
|
if (!length) {
|
2013-01-23 22:47:44 +04:00
|
|
|
aFrameIntervals.Clear();
|
2014-02-14 21:56:35 +04:00
|
|
|
return; // empty recording, return empty arrays.
|
2013-01-23 22:47:44 +04:00
|
|
|
}
|
2014-02-14 21:56:35 +04:00
|
|
|
// Set length in advance to avoid possibly repeated reallocations
|
|
|
|
aFrameIntervals.SetLength(length);
|
2013-01-23 22:47:44 +04:00
|
|
|
|
|
|
|
uint32_t cyclicPos = aStartIndex % bufferSize;
|
|
|
|
for (uint32_t i = 0; i < length; i++, cyclicPos++) {
|
|
|
|
if (cyclicPos == bufferSize) {
|
|
|
|
cyclicPos = 0;
|
|
|
|
}
|
|
|
|
aFrameIntervals[i] = mRecording.mIntervals[cyclicPos];
|
|
|
|
}
|
2012-01-06 02:40:35 +04:00
|
|
|
}
|
|
|
|
|
2016-11-24 08:11:27 +03:00
|
|
|
static void PrintInfo(std::stringstream& aStream, HostLayer* aLayerComposite);
|
2010-10-14 02:55:45 +04:00
|
|
|
|
2012-03-01 12:26:09 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
template <typename T>
|
2014-01-08 12:43:46 +04:00
|
|
|
void WriteSnapshotToDumpFile_internal(T* aObj, DataSourceSurface* aSurf)
|
2012-03-01 12:26:09 +04:00
|
|
|
{
|
|
|
|
nsCString string(aObj->Name());
|
2014-05-22 07:48:52 +04:00
|
|
|
string.Append('-');
|
2012-08-22 19:56:38 +04:00
|
|
|
string.AppendInt((uint64_t)aObj);
|
2015-05-12 16:16:54 +03:00
|
|
|
if (gfxUtils::sDumpPaintFile != stderr) {
|
2016-11-15 12:08:18 +03:00
|
|
|
fprintf_stderr(gfxUtils::sDumpPaintFile, R"(array["%s"]=")", string.BeginReading());
|
2013-11-24 02:44:18 +04:00
|
|
|
}
|
2014-06-27 15:19:40 +04:00
|
|
|
gfxUtils::DumpAsDataURI(aSurf, gfxUtils::sDumpPaintFile);
|
2015-05-12 16:16:54 +03:00
|
|
|
if (gfxUtils::sDumpPaintFile != stderr) {
|
2016-11-15 12:08:18 +03:00
|
|
|
fprintf_stderr(gfxUtils::sDumpPaintFile, R"(";)");
|
2013-11-24 02:44:18 +04:00
|
|
|
}
|
2012-03-01 12:26:09 +04:00
|
|
|
}
|
|
|
|
|
2014-01-08 12:37:58 +04:00
|
|
|
void WriteSnapshotToDumpFile(Layer* aLayer, DataSourceSurface* aSurf)
|
2012-03-01 12:26:09 +04:00
|
|
|
{
|
2014-01-08 12:43:46 +04:00
|
|
|
WriteSnapshotToDumpFile_internal(aLayer, aSurf);
|
2012-03-01 12:26:09 +04:00
|
|
|
}
|
|
|
|
|
2014-01-08 12:37:58 +04:00
|
|
|
void WriteSnapshotToDumpFile(LayerManager* aManager, DataSourceSurface* aSurf)
|
2012-03-01 12:26:09 +04:00
|
|
|
{
|
2014-01-08 12:43:46 +04:00
|
|
|
WriteSnapshotToDumpFile_internal(aManager, aSurf);
|
2012-03-01 12:26:09 +04:00
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2013-09-27 04:37:19 +04:00
|
|
|
void WriteSnapshotToDumpFile(Compositor* aCompositor, DrawTarget* aTarget)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SourceSurface> surf = aTarget->Snapshot();
|
|
|
|
RefPtr<DataSourceSurface> dSurf = surf->GetDataSurface();
|
2014-01-08 12:43:46 +04:00
|
|
|
WriteSnapshotToDumpFile_internal(aCompositor, dSurf);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
2012-03-01 12:26:09 +04:00
|
|
|
#endif
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
void
|
2016-03-17 23:18:10 +03:00
|
|
|
Layer::Dump(std::stringstream& aStream, const char* aPrefix,
|
2016-12-07 02:39:01 +03:00
|
|
|
bool aDumpHtml, bool aSorted, const Maybe<gfx::Polygon>& aGeometry)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2015-09-29 00:06:35 +03:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2016-11-24 08:11:27 +03:00
|
|
|
bool dumpCompositorTexture = gfxEnv::DumpCompositorTextures() && AsHostLayer() &&
|
|
|
|
AsHostLayer()->GetCompositableHost();
|
2015-10-28 16:31:00 +03:00
|
|
|
bool dumpClientTexture = gfxEnv::DumpPaint() && AsShadowableLayer() &&
|
2015-09-29 00:06:35 +03:00
|
|
|
AsShadowableLayer()->GetCompositableClient();
|
|
|
|
nsCString layerId(Name());
|
|
|
|
layerId.Append('-');
|
|
|
|
layerId.AppendInt((uint64_t)this);
|
|
|
|
#endif
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2016-11-15 12:08:18 +03:00
|
|
|
aStream << nsPrintfCString(R"(<li><a id="%p" )", this).get();
|
2012-03-01 12:26:09 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2015-09-29 00:06:35 +03:00
|
|
|
if (dumpCompositorTexture || dumpClientTexture) {
|
2016-11-15 12:08:18 +03:00
|
|
|
aStream << nsPrintfCString(R"lit(href="javascript:ViewImage('%s')")lit", layerId.BeginReading()).get();
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2012-03-01 12:26:09 +04:00
|
|
|
#endif
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << ">";
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2016-12-07 02:39:01 +03:00
|
|
|
DumpSelf(aStream, aPrefix, aGeometry);
|
2013-09-12 19:08:50 +04:00
|
|
|
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2015-09-29 00:06:35 +03:00
|
|
|
if (dumpCompositorTexture) {
|
2016-11-24 08:11:27 +03:00
|
|
|
AsHostLayer()->GetCompositableHost()->Dump(aStream, aPrefix, aDumpHtml);
|
2015-09-29 00:06:35 +03:00
|
|
|
} else if (dumpClientTexture) {
|
|
|
|
if (aDumpHtml) {
|
2016-11-15 12:08:18 +03:00
|
|
|
aStream << nsPrintfCString(R"(<script>array["%s"]=")", layerId.BeginReading()).get();
|
2015-09-29 00:06:35 +03:00
|
|
|
}
|
|
|
|
AsShadowableLayer()->GetCompositableClient()->Dump(aStream, aPrefix,
|
|
|
|
aDumpHtml, TextureDumpMode::DoNotCompress);
|
|
|
|
if (aDumpHtml) {
|
2016-11-15 12:08:18 +03:00
|
|
|
aStream << R"(";</script>)";
|
2015-09-29 00:06:35 +03:00
|
|
|
}
|
2013-05-26 06:44:24 +04:00
|
|
|
}
|
2013-09-12 19:08:50 +04:00
|
|
|
#endif
|
|
|
|
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "</a>";
|
2015-09-28 22:22:05 +03:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
if (dumpClientTexture) {
|
|
|
|
aStream << nsPrintfCString("<br><img id=\"%s\">\n", layerId.BeginReading()).get();
|
|
|
|
}
|
|
|
|
#endif
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2012-01-18 05:35:49 +04:00
|
|
|
if (Layer* mask = GetMaskLayer()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString("%s Mask layer:\n", aPrefix).get();
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString pfx(aPrefix);
|
2013-11-26 06:07:44 +04:00
|
|
|
pfx += " ";
|
2014-06-20 02:36:25 +04:00
|
|
|
mask->Dump(aStream, pfx.get(), aDumpHtml);
|
2012-01-18 05:35:49 +04:00
|
|
|
}
|
|
|
|
|
2015-06-21 19:27:31 +03:00
|
|
|
for (size_t i = 0; i < GetAncestorMaskLayerCount(); i++) {
|
|
|
|
aStream << nsPrintfCString("%s Ancestor mask layer %d:\n", aPrefix, uint32_t(i)).get();
|
|
|
|
nsAutoCString pfx(aPrefix);
|
|
|
|
pfx += " ";
|
|
|
|
GetAncestorMaskLayerAt(i)->Dump(aStream, pfx.get(), aDumpHtml);
|
|
|
|
}
|
|
|
|
|
2014-08-22 19:53:24 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
for (size_t i = 0; i < mExtraDumpInfo.Length(); i++) {
|
|
|
|
const nsCString& str = mExtraDumpInfo[i];
|
|
|
|
aStream << aPrefix << " Info:\n" << str.get();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-03-17 23:18:10 +03:00
|
|
|
if (ContainerLayer* container = AsContainerLayer()) {
|
2016-12-07 02:39:01 +03:00
|
|
|
nsTArray<LayerPolygon> children;
|
2016-03-17 23:18:10 +03:00
|
|
|
if (aSorted) {
|
2016-12-07 02:39:01 +03:00
|
|
|
children =
|
|
|
|
container->SortChildrenBy3DZOrder(ContainerLayer::SortMode::WITH_GEOMETRY);
|
2016-03-17 23:18:10 +03:00
|
|
|
} else {
|
|
|
|
for (Layer* l = container->GetFirstChild(); l; l = l->GetNextSibling()) {
|
2016-12-07 02:39:01 +03:00
|
|
|
children.AppendElement(LayerPolygon(l));
|
2016-03-17 23:18:10 +03:00
|
|
|
}
|
|
|
|
}
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString pfx(aPrefix);
|
2010-07-21 22:06:33 +04:00
|
|
|
pfx += " ";
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "<ul>";
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2016-03-17 23:18:10 +03:00
|
|
|
|
2016-12-07 02:39:01 +03:00
|
|
|
for (LayerPolygon& child : children) {
|
|
|
|
child.layer->Dump(aStream, pfx.get(), aDumpHtml, aSorted, child.geometry);
|
2016-03-17 23:18:10 +03:00
|
|
|
}
|
|
|
|
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "</ul>";
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "</li>";
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2016-12-07 02:39:01 +03:00
|
|
|
static void
|
|
|
|
DumpGeometry(std::stringstream& aStream, const Maybe<gfx::Polygon>& aGeometry)
|
|
|
|
{
|
|
|
|
aStream << " [geometry=[";
|
|
|
|
|
|
|
|
const nsTArray<gfx::Point4D>& points = aGeometry->GetPoints();
|
|
|
|
for (size_t i = 0; i < points.Length(); ++i) {
|
|
|
|
const gfx::IntPoint point = TruncatedToInt(points[i].As2DPoint());
|
|
|
|
const char* sfx = (i != points.Length() - 1) ? "," : "";
|
|
|
|
AppendToString(aStream, point, "", sfx);
|
|
|
|
}
|
|
|
|
|
|
|
|
aStream << "]]";
|
|
|
|
}
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
void
|
2016-12-07 02:39:01 +03:00
|
|
|
Layer::DumpSelf(std::stringstream& aStream, const char* aPrefix,
|
|
|
|
const Maybe<gfx::Polygon>& aGeometry)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
PrintInfo(aStream, aPrefix);
|
2016-12-07 02:39:01 +03:00
|
|
|
|
|
|
|
if (aGeometry) {
|
|
|
|
DumpGeometry(aStream, aGeometry);
|
|
|
|
}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "\n";
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
void
|
|
|
|
Layer::Dump(layerscope::LayersPacket* aPacket, const void* aParent)
|
|
|
|
{
|
|
|
|
DumpPacket(aPacket, aParent);
|
|
|
|
|
|
|
|
if (Layer* kid = GetFirstChild()) {
|
|
|
|
kid->Dump(aPacket, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Layer* next = GetNextSibling()) {
|
|
|
|
next->Dump(aPacket, aParent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-03 09:11:00 +03:00
|
|
|
void
|
|
|
|
Layer::SetDisplayListLog(const char* log)
|
|
|
|
{
|
|
|
|
if (gfxUtils::DumpDisplayList()) {
|
|
|
|
mDisplayListLog = log;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Layer::GetDisplayListLog(nsCString& log)
|
|
|
|
{
|
|
|
|
log.SetLength(0);
|
|
|
|
|
|
|
|
if (gfxUtils::DumpDisplayList()) {
|
|
|
|
// This function returns a plain text string which consists of two things
|
|
|
|
// 1. DisplayList log.
|
|
|
|
// 2. Memory address of this layer.
|
|
|
|
// We know the target layer of each display item by information in #1.
|
|
|
|
// Here is an example of a Text display item line log in #1
|
|
|
|
// Text p=0xa9850c00 f=0x0xaa405b00(.....
|
|
|
|
// f keeps the address of the target client layer of a display item.
|
|
|
|
// For LayerScope, display-item-to-client-layer mapping is not enough since
|
|
|
|
// LayerScope, which lives in the chrome process, knows only composite layers.
|
|
|
|
// As so, we need display-item-to-client-layer-to-layer-composite
|
|
|
|
// mapping. That's the reason we insert #2 into the log
|
|
|
|
log.AppendPrintf("0x%p\n%s",(void*) this, mDisplayListLog.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
void
|
|
|
|
Layer::Log(const char* aPrefix)
|
|
|
|
{
|
|
|
|
if (!IsLogEnabled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
LogSelf(aPrefix);
|
|
|
|
|
|
|
|
if (Layer* kid = GetFirstChild()) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString pfx(aPrefix);
|
2010-07-21 22:06:33 +04:00
|
|
|
pfx += " ";
|
|
|
|
kid->Log(pfx.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Layer* next = GetNextSibling())
|
|
|
|
next->Log(aPrefix);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Layer::LogSelf(const char* aPrefix)
|
|
|
|
{
|
|
|
|
if (!IsLogEnabled())
|
|
|
|
return;
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
std::stringstream ss;
|
|
|
|
PrintInfo(ss, aPrefix);
|
|
|
|
MOZ_LAYERS_LOG(("%s", ss.str().c_str()));
|
2013-11-20 08:55:27 +04:00
|
|
|
|
|
|
|
if (mMaskLayer) {
|
|
|
|
nsAutoCString pfx(aPrefix);
|
2016-11-15 12:08:18 +03:00
|
|
|
pfx += R"( \ MaskLayer )";
|
2013-11-20 08:55:27 +04:00
|
|
|
mMaskLayer->LogSelf(pfx.get());
|
|
|
|
}
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
void
|
|
|
|
Layer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << aPrefix;
|
|
|
|
aStream << nsPrintfCString("%s%s (0x%p)", mManager->Name(), Name(), this).get();
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2016-11-24 08:11:27 +03:00
|
|
|
layers::PrintInfo(aStream, AsHostLayer());
|
2010-10-14 02:55:45 +04:00
|
|
|
|
2015-04-12 05:03:00 +03:00
|
|
|
if (mClipRect) {
|
|
|
|
AppendToString(aStream, *mClipRect, " [clip=", "]");
|
2010-08-02 07:06:58 +04:00
|
|
|
}
|
2018-03-02 21:00:03 +03:00
|
|
|
if (mSimpleAttrs.GetScrolledClip()) {
|
|
|
|
AppendToString(aStream, mSimpleAttrs.GetScrolledClip()->GetClipRect(), " [scrolled-clip=", "]");
|
|
|
|
if (const Maybe<size_t>& ix = mSimpleAttrs.GetScrolledClip()->GetMaskLayerIndex()) {
|
2017-06-14 22:18:16 +03:00
|
|
|
AppendToString(aStream, ix.value(), " [scrolled-mask=", "]");
|
|
|
|
}
|
2016-04-30 00:32:53 +03:00
|
|
|
}
|
2018-03-02 21:00:03 +03:00
|
|
|
if (1.0 != mSimpleAttrs.GetPostXScale() || 1.0 != mSimpleAttrs.GetPostYScale()) {
|
|
|
|
aStream << nsPrintfCString(" [postScale=%g, %g]", mSimpleAttrs.GetPostXScale(), mSimpleAttrs.GetPostYScale()).get();
|
2012-08-04 01:29:22 +04:00
|
|
|
}
|
2017-01-25 03:41:18 +03:00
|
|
|
if (!GetBaseTransform().IsIdentity()) {
|
|
|
|
AppendToString(aStream, GetBaseTransform(), " [transform=", "]");
|
2010-09-02 13:18:40 +04:00
|
|
|
}
|
2016-02-07 13:51:11 +03:00
|
|
|
if (!GetEffectiveTransform().IsIdentity()) {
|
|
|
|
AppendToString(aStream, GetEffectiveTransform(), " [effective-transform=", "]");
|
|
|
|
}
|
2017-01-25 03:41:18 +03:00
|
|
|
if (GetTransformIsPerspective()) {
|
2015-11-03 01:38:08 +03:00
|
|
|
aStream << " [perspective]";
|
|
|
|
}
|
2010-09-02 13:18:40 +04:00
|
|
|
if (!mVisibleRegion.IsEmpty()) {
|
2015-11-29 10:07:55 +03:00
|
|
|
AppendToString(aStream, mVisibleRegion.ToUnknownRegion(), " [visible=", "]");
|
2012-09-17 02:25:33 +04:00
|
|
|
} else {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << " [not visible]";
|
2010-09-02 13:18:40 +04:00
|
|
|
}
|
2014-11-14 15:40:14 +03:00
|
|
|
if (!mEventRegions.IsEmpty()) {
|
|
|
|
AppendToString(aStream, mEventRegions, " ", "");
|
2013-12-16 14:47:06 +04:00
|
|
|
}
|
2017-01-25 03:41:18 +03:00
|
|
|
if (1.0 != GetOpacity()) {
|
|
|
|
aStream << nsPrintfCString(" [opacity=%g]", GetOpacity()).get();
|
2010-09-02 13:18:40 +04:00
|
|
|
}
|
2016-04-11 05:51:21 +03:00
|
|
|
if (IsOpaque()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << " [opaqueContent]";
|
2010-09-02 13:18:40 +04:00
|
|
|
}
|
2010-12-20 04:26:14 +03:00
|
|
|
if (GetContentFlags() & CONTENT_COMPONENT_ALPHA) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << " [componentAlpha]";
|
2010-09-02 13:18:40 +04:00
|
|
|
}
|
2015-11-26 12:32:35 +03:00
|
|
|
if (GetContentFlags() & CONTENT_BACKFACE_HIDDEN) {
|
|
|
|
aStream << " [backfaceHidden]";
|
|
|
|
}
|
2016-03-17 23:18:10 +03:00
|
|
|
if (Extend3DContext()) {
|
|
|
|
aStream << " [extend3DContext]";
|
|
|
|
}
|
|
|
|
if (Combines3DTransformWithAncestors()) {
|
|
|
|
aStream << " [combines3DTransformWithAncestors]";
|
|
|
|
}
|
|
|
|
if (Is3DContextLeaf()) {
|
|
|
|
aStream << " [is3DContextLeaf]";
|
|
|
|
}
|
2018-04-17 22:04:34 +03:00
|
|
|
if (IsScrollbarContainer()) {
|
2016-04-14 23:42:18 +03:00
|
|
|
aStream << " [scrollbar]";
|
|
|
|
}
|
2018-04-17 22:04:34 +03:00
|
|
|
if (GetScrollbarData().IsThumb()) {
|
|
|
|
if (Maybe<ScrollDirection> thumbDirection = GetScrollbarData().mDirection) {
|
|
|
|
if (*thumbDirection == ScrollDirection::eVertical) {
|
|
|
|
aStream << nsPrintfCString(" [vscrollbar=%" PRIu64 "]", GetScrollbarData().mTargetViewId).get();
|
|
|
|
}
|
|
|
|
if (*thumbDirection == ScrollDirection::eHorizontal) {
|
|
|
|
aStream << nsPrintfCString(" [hscrollbar=%" PRIu64 "]", GetScrollbarData().mTargetViewId).get();
|
|
|
|
}
|
2017-11-21 03:00:34 +03:00
|
|
|
}
|
2013-12-10 07:14:53 +04:00
|
|
|
}
|
2011-04-06 09:00:25 +04:00
|
|
|
if (GetIsFixedPosition()) {
|
2015-08-18 02:44:42 +03:00
|
|
|
LayerPoint anchor = GetFixedPositionAnchor();
|
2016-12-14 19:32:21 +03:00
|
|
|
aStream << nsPrintfCString(" [isFixedPosition scrollId=%" PRIu64 " sides=0x%x anchor=%s]",
|
2015-08-18 02:44:42 +03:00
|
|
|
GetFixedPositionScrollContainerId(),
|
2015-11-13 17:38:57 +03:00
|
|
|
GetFixedPositionSides(),
|
2016-05-05 03:07:42 +03:00
|
|
|
ToString(anchor).c_str()).get();
|
2011-04-06 09:00:25 +04:00
|
|
|
}
|
2013-09-12 08:17:58 +04:00
|
|
|
if (GetIsStickyPosition()) {
|
2016-12-14 19:32:21 +03:00
|
|
|
aStream << nsPrintfCString(" [isStickyPosition scrollId=%" PRIu64 " outer=(%.3f,%.3f)-(%.3f,%.3f) "
|
2017-01-25 03:41:18 +03:00
|
|
|
"inner=(%.3f,%.3f)-(%.3f,%.3f)]",
|
|
|
|
GetStickyScrollContainerId(),
|
2017-12-19 23:48:39 +03:00
|
|
|
GetStickyScrollRangeOuter().X(),
|
|
|
|
GetStickyScrollRangeOuter().Y(),
|
2017-01-25 03:41:18 +03:00
|
|
|
GetStickyScrollRangeOuter().XMost(),
|
|
|
|
GetStickyScrollRangeOuter().YMost(),
|
2017-12-19 23:48:39 +03:00
|
|
|
GetStickyScrollRangeInner().X(),
|
|
|
|
GetStickyScrollRangeInner().Y(),
|
2017-01-25 03:41:18 +03:00
|
|
|
GetStickyScrollRangeInner().XMost(),
|
|
|
|
GetStickyScrollRangeInner().YMost()).get();
|
2013-09-12 08:17:58 +04:00
|
|
|
}
|
2013-11-20 08:55:27 +04:00
|
|
|
if (mMaskLayer) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString(" [mMaskLayer=%p]", mMaskLayer.get()).get();
|
2013-11-20 08:55:27 +04:00
|
|
|
}
|
2016-03-29 02:14:52 +03:00
|
|
|
for (uint32_t i = 0; i < mScrollMetadata.Length(); i++) {
|
|
|
|
if (!mScrollMetadata[i].IsDefault()) {
|
2014-08-28 06:13:40 +04:00
|
|
|
aStream << nsPrintfCString(" [metrics%d=", i).get();
|
2016-03-29 02:14:52 +03:00
|
|
|
AppendToString(aStream, mScrollMetadata[i], "", "]");
|
2014-08-28 06:13:40 +04:00
|
|
|
}
|
2014-08-12 04:00:36 +04:00
|
|
|
}
|
2017-07-21 09:21:47 +03:00
|
|
|
if (!mAnimationInfo.GetAnimations().IsEmpty()) {
|
2017-02-08 22:31:45 +03:00
|
|
|
aStream << nsPrintfCString(" [%d animations with id=%" PRIu64 " ]",
|
2017-07-21 09:21:47 +03:00
|
|
|
(int) mAnimationInfo.GetAnimations().Length(),
|
|
|
|
mAnimationInfo.GetCompositorAnimationsId()).get();
|
2016-07-20 21:53:38 +03:00
|
|
|
}
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
// The static helper function sets the transform matrix into the packet
|
|
|
|
static void
|
|
|
|
DumpTransform(layerscope::LayersPacket::Layer::Matrix* aLayerMatrix, const Matrix4x4& aMatrix)
|
|
|
|
{
|
|
|
|
aLayerMatrix->set_is2d(aMatrix.Is2D());
|
|
|
|
if (aMatrix.Is2D()) {
|
|
|
|
Matrix m = aMatrix.As2D();
|
|
|
|
aLayerMatrix->set_isid(m.IsIdentity());
|
|
|
|
if (!m.IsIdentity()) {
|
2017-03-28 07:29:42 +03:00
|
|
|
aLayerMatrix->add_m(m._11); aLayerMatrix->add_m(m._12);
|
|
|
|
aLayerMatrix->add_m(m._21); aLayerMatrix->add_m(m._22);
|
|
|
|
aLayerMatrix->add_m(m._31); aLayerMatrix->add_m(m._32);
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
} else {
|
2017-03-28 07:29:42 +03:00
|
|
|
aLayerMatrix->add_m(aMatrix._11); aLayerMatrix->add_m(aMatrix._12);
|
|
|
|
aLayerMatrix->add_m(aMatrix._13); aLayerMatrix->add_m(aMatrix._14);
|
|
|
|
aLayerMatrix->add_m(aMatrix._21); aLayerMatrix->add_m(aMatrix._22);
|
|
|
|
aLayerMatrix->add_m(aMatrix._23); aLayerMatrix->add_m(aMatrix._24);
|
|
|
|
aLayerMatrix->add_m(aMatrix._31); aLayerMatrix->add_m(aMatrix._32);
|
|
|
|
aLayerMatrix->add_m(aMatrix._33); aLayerMatrix->add_m(aMatrix._34);
|
|
|
|
aLayerMatrix->add_m(aMatrix._41); aLayerMatrix->add_m(aMatrix._42);
|
|
|
|
aLayerMatrix->add_m(aMatrix._43); aLayerMatrix->add_m(aMatrix._44);
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:07:53 +03:00
|
|
|
// The static helper function sets the IntRect into the packet
|
2015-04-12 05:03:00 +03:00
|
|
|
template <typename T, typename Sub, typename Point, typename SizeT, typename MarginT>
|
2014-07-28 00:32:00 +04:00
|
|
|
static void
|
2015-04-12 05:03:00 +03:00
|
|
|
DumpRect(layerscope::LayersPacket::Layer::Rect* aLayerRect,
|
|
|
|
const BaseRect<T, Sub, Point, SizeT, MarginT>& aRect)
|
2014-07-28 00:32:00 +04:00
|
|
|
{
|
2017-12-19 23:48:39 +03:00
|
|
|
aLayerRect->set_x(aRect.X());
|
|
|
|
aLayerRect->set_y(aRect.Y());
|
2017-08-14 15:29:28 +03:00
|
|
|
aLayerRect->set_w(aRect.Width());
|
|
|
|
aLayerRect->set_h(aRect.Height());
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// The static helper function sets the nsIntRegion into the packet
|
|
|
|
static void
|
|
|
|
DumpRegion(layerscope::LayersPacket::Layer::Region* aLayerRegion, const nsIntRegion& aRegion)
|
|
|
|
{
|
2016-01-19 04:20:58 +03:00
|
|
|
for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
|
|
|
|
DumpRect(aLayerRegion->add_r(), iter.Get());
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Layer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
|
|
|
|
{
|
|
|
|
// Add a new layer (UnknownLayer)
|
|
|
|
using namespace layerscope;
|
|
|
|
LayersPacket::Layer* layer = aPacket->add_layer();
|
|
|
|
// Basic information
|
|
|
|
layer->set_type(LayersPacket::Layer::UnknownLayer);
|
|
|
|
layer->set_ptr(reinterpret_cast<uint64_t>(this));
|
|
|
|
layer->set_parentptr(reinterpret_cast<uint64_t>(aParent));
|
|
|
|
// Shadow
|
2016-11-24 08:11:27 +03:00
|
|
|
if (HostLayer* lc = AsHostLayer()) {
|
2014-07-28 00:32:00 +04:00
|
|
|
LayersPacket::Layer::Shadow* s = layer->mutable_shadow();
|
2015-04-12 05:03:00 +03:00
|
|
|
if (const Maybe<ParentLayerIntRect>& clipRect = lc->GetShadowClipRect()) {
|
2014-07-28 00:32:00 +04:00
|
|
|
DumpRect(s->mutable_clip(), *clipRect);
|
|
|
|
}
|
2016-02-21 03:05:59 +03:00
|
|
|
if (!lc->GetShadowBaseTransform().IsIdentity()) {
|
|
|
|
DumpTransform(s->mutable_transform(), lc->GetShadowBaseTransform());
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
if (!lc->GetShadowVisibleRegion().IsEmpty()) {
|
2015-11-29 10:07:55 +03:00
|
|
|
DumpRegion(s->mutable_vregion(), lc->GetShadowVisibleRegion().ToUnknownRegion());
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Clip
|
2015-04-12 05:03:00 +03:00
|
|
|
if (mClipRect) {
|
|
|
|
DumpRect(layer->mutable_clip(), *mClipRect);
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
// Transform
|
2017-01-25 03:41:18 +03:00
|
|
|
if (!GetBaseTransform().IsIdentity()) {
|
|
|
|
DumpTransform(layer->mutable_transform(), GetBaseTransform());
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
// Visible region
|
2015-11-29 10:07:55 +03:00
|
|
|
if (!mVisibleRegion.ToUnknownRegion().IsEmpty()) {
|
|
|
|
DumpRegion(layer->mutable_vregion(), mVisibleRegion.ToUnknownRegion());
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
2015-05-27 04:18:00 +03:00
|
|
|
// EventRegions
|
|
|
|
if (!mEventRegions.IsEmpty()) {
|
|
|
|
const EventRegions &e = mEventRegions;
|
|
|
|
if (!e.mHitRegion.IsEmpty()) {
|
|
|
|
DumpRegion(layer->mutable_hitregion(), e.mHitRegion);
|
|
|
|
}
|
|
|
|
if (!e.mDispatchToContentHitRegion.IsEmpty()) {
|
|
|
|
DumpRegion(layer->mutable_dispatchregion(), e.mDispatchToContentHitRegion);
|
|
|
|
}
|
|
|
|
if (!e.mNoActionRegion.IsEmpty()) {
|
|
|
|
DumpRegion(layer->mutable_noactionregion(), e.mNoActionRegion);
|
|
|
|
}
|
|
|
|
if (!e.mHorizontalPanRegion.IsEmpty()) {
|
|
|
|
DumpRegion(layer->mutable_hpanregion(), e.mHorizontalPanRegion);
|
|
|
|
}
|
|
|
|
if (!e.mVerticalPanRegion.IsEmpty()) {
|
|
|
|
DumpRegion(layer->mutable_vpanregion(), e.mVerticalPanRegion);
|
|
|
|
}
|
|
|
|
}
|
2014-07-28 00:32:00 +04:00
|
|
|
// Opacity
|
2017-01-25 03:41:18 +03:00
|
|
|
layer->set_opacity(GetOpacity());
|
2014-07-28 00:32:00 +04:00
|
|
|
// Content opaque
|
|
|
|
layer->set_copaque(static_cast<bool>(GetContentFlags() & CONTENT_OPAQUE));
|
|
|
|
// Component alpha
|
|
|
|
layer->set_calpha(static_cast<bool>(GetContentFlags() & CONTENT_COMPONENT_ALPHA));
|
|
|
|
// Vertical or horizontal bar
|
2018-03-02 21:00:03 +03:00
|
|
|
if (GetScrollbarData().mScrollbarLayerType == layers::ScrollbarLayerType::Thumb) {
|
|
|
|
layer->set_direct(*GetScrollbarData().mDirection == ScrollDirection::eVertical ?
|
2014-07-28 00:32:00 +04:00
|
|
|
LayersPacket::Layer::VERTICAL :
|
|
|
|
LayersPacket::Layer::HORIZONTAL);
|
2018-04-17 22:04:34 +03:00
|
|
|
layer->set_barid(GetScrollbarData().mTargetViewId);
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
2015-08-03 09:11:00 +03:00
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
// Mask layer
|
|
|
|
if (mMaskLayer) {
|
|
|
|
layer->set_mask(reinterpret_cast<uint64_t>(mMaskLayer.get()));
|
|
|
|
}
|
2015-08-03 09:11:00 +03:00
|
|
|
|
|
|
|
// DisplayList log.
|
|
|
|
if (mDisplayListLog.Length() > 0) {
|
|
|
|
layer->set_displaylistloglength(mDisplayListLog.Length());
|
|
|
|
auto compressedData =
|
|
|
|
MakeUnique<char[]>(LZ4::maxCompressedSize(mDisplayListLog.Length()));
|
|
|
|
int compressedSize = LZ4::compress((char*)mDisplayListLog.get(),
|
|
|
|
mDisplayListLog.Length(),
|
|
|
|
compressedData.get());
|
|
|
|
layer->set_displaylistlog(compressedData.get(), compressedSize);
|
|
|
|
}
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
bool
|
|
|
|
Layer::IsBackfaceHidden()
|
|
|
|
{
|
|
|
|
if (GetContentFlags() & CONTENT_BACKFACE_HIDDEN) {
|
|
|
|
Layer* container = AsContainerLayer() ? this : GetParent();
|
|
|
|
if (container) {
|
|
|
|
// The effective transform can include non-preserve-3d parent
|
|
|
|
// transforms, since we don't always require an intermediate.
|
|
|
|
if (container->Extend3DContext() || container->Is3DContextLeaf()) {
|
|
|
|
return container->GetEffectiveTransform().IsBackfaceVisible();
|
|
|
|
}
|
|
|
|
return container->GetBaseTransform().IsBackfaceVisible();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-25 01:17:27 +03:00
|
|
|
UniquePtr<LayerUserData>
|
2015-10-22 23:57:29 +03:00
|
|
|
Layer::RemoveUserData(void* aKey)
|
|
|
|
{
|
2016-05-25 01:17:27 +03:00
|
|
|
UniquePtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
|
2015-10-22 23:57:29 +03:00
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2017-06-27 23:11:01 +03:00
|
|
|
void
|
|
|
|
Layer::SetManager(LayerManager* aManager, HostLayer* aSelf)
|
|
|
|
{
|
|
|
|
// No one should be calling this for weird reasons.
|
|
|
|
MOZ_ASSERT(aSelf);
|
|
|
|
MOZ_ASSERT(aSelf->GetLayer() == this);
|
|
|
|
mManager = aManager;
|
|
|
|
}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
void
|
2014-09-26 21:06:08 +04:00
|
|
|
PaintedLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
Layer::PrintInfo(aStream, aPrefix);
|
2017-06-16 01:20:53 +03:00
|
|
|
nsIntRegion validRegion = GetValidRegion();
|
|
|
|
if (!validRegion.IsEmpty()) {
|
|
|
|
AppendToString(aStream, validRegion, " [valid=", "]");
|
2010-10-14 02:55:45 +04:00
|
|
|
}
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
void
|
2014-09-26 21:06:08 +04:00
|
|
|
PaintedLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
|
2014-07-28 00:32:00 +04:00
|
|
|
{
|
|
|
|
Layer::DumpPacket(aPacket, aParent);
|
|
|
|
// get this layer data
|
|
|
|
using namespace layerscope;
|
|
|
|
LayersPacket::Layer* layer = aPacket->mutable_layer(aPacket->layer_size()-1);
|
2014-09-26 21:06:08 +04:00
|
|
|
layer->set_type(LayersPacket::Layer::PaintedLayer);
|
2017-06-16 01:20:53 +03:00
|
|
|
nsIntRegion validRegion = GetValidRegion();
|
|
|
|
if (!validRegion.IsEmpty()) {
|
|
|
|
DumpRegion(layer->mutable_valid(), validRegion);
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
void
|
|
|
|
ContainerLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
2010-09-04 00:10:45 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
Layer::PrintInfo(aStream, aPrefix);
|
2011-01-08 08:05:35 +03:00
|
|
|
if (UseIntermediateSurface()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << " [usesTmpSurf]";
|
2011-01-08 08:05:35 +03:00
|
|
|
}
|
2012-08-04 01:29:22 +04:00
|
|
|
if (1.0 != mPreXScale || 1.0 != mPreYScale) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString(" [preScale=%g, %g]", mPreXScale, mPreYScale).get();
|
2012-08-04 01:29:22 +04:00
|
|
|
}
|
2015-01-03 04:06:14 +03:00
|
|
|
if (mScaleToResolution) {
|
|
|
|
aStream << nsPrintfCString(" [presShellResolution=%g]", mPresShellResolution).get();
|
|
|
|
}
|
2010-09-04 00:10:45 +04:00
|
|
|
}
|
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
void
|
|
|
|
ContainerLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
|
|
|
|
{
|
|
|
|
Layer::DumpPacket(aPacket, aParent);
|
|
|
|
// Get this layer data
|
|
|
|
using namespace layerscope;
|
|
|
|
LayersPacket::Layer* layer = aPacket->mutable_layer(aPacket->layer_size()-1);
|
|
|
|
layer->set_type(LayersPacket::Layer::ContainerLayer);
|
|
|
|
}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
void
|
|
|
|
ColorLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
Layer::PrintInfo(aStream, aPrefix);
|
|
|
|
AppendToString(aStream, mColor, " [color=", "]");
|
2015-05-21 16:26:47 +03:00
|
|
|
AppendToString(aStream, mBounds, " [bounds=", "]");
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
void
|
|
|
|
ColorLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
|
|
|
|
{
|
|
|
|
Layer::DumpPacket(aPacket, aParent);
|
|
|
|
// Get this layer data
|
|
|
|
using namespace layerscope;
|
|
|
|
LayersPacket::Layer* layer = aPacket->mutable_layer(aPacket->layer_size()-1);
|
|
|
|
layer->set_type(LayersPacket::Layer::ColorLayer);
|
2015-09-25 04:16:45 +03:00
|
|
|
layer->set_color(mColor.ToABGR());
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
|
2016-11-24 08:11:30 +03:00
|
|
|
void
|
|
|
|
BorderLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
|
|
|
{
|
|
|
|
Layer::PrintInfo(aStream, aPrefix);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BorderLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
|
|
|
|
{
|
|
|
|
Layer::DumpPacket(aPacket, aParent);
|
|
|
|
}
|
|
|
|
|
2015-10-12 06:21:02 +03:00
|
|
|
CanvasLayer::CanvasLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: Layer(aManager, aImplData)
|
2017-09-14 13:19:49 +03:00
|
|
|
, mSamplingFilter(SamplingFilter::GOOD)
|
2017-08-03 08:55:14 +03:00
|
|
|
{
|
|
|
|
}
|
2015-10-12 06:21:02 +03:00
|
|
|
|
2016-11-15 12:04:18 +03:00
|
|
|
CanvasLayer::~CanvasLayer() = default;
|
2015-10-12 06:21:02 +03:00
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
void
|
|
|
|
CanvasLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
Layer::PrintInfo(aStream, aPrefix);
|
2016-05-25 19:01:18 +03:00
|
|
|
if (mSamplingFilter != SamplingFilter::GOOD) {
|
|
|
|
AppendToString(aStream, mSamplingFilter, " [filter=", "]");
|
2010-08-02 07:06:58 +04:00
|
|
|
}
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
// This help function is used to assign the correct enum value
|
|
|
|
// to the packet
|
|
|
|
static void
|
2016-05-25 19:01:18 +03:00
|
|
|
DumpFilter(layerscope::LayersPacket::Layer* aLayer,
|
|
|
|
const SamplingFilter& aSamplingFilter)
|
2014-07-28 00:32:00 +04:00
|
|
|
{
|
|
|
|
using namespace layerscope;
|
2016-05-25 19:01:18 +03:00
|
|
|
switch (aSamplingFilter) {
|
|
|
|
case SamplingFilter::GOOD:
|
2014-07-28 00:32:00 +04:00
|
|
|
aLayer->set_filter(LayersPacket::Layer::FILTER_GOOD);
|
|
|
|
break;
|
2016-05-25 19:01:18 +03:00
|
|
|
case SamplingFilter::LINEAR:
|
2015-10-06 03:12:46 +03:00
|
|
|
aLayer->set_filter(LayersPacket::Layer::FILTER_LINEAR);
|
2014-07-28 00:32:00 +04:00
|
|
|
break;
|
2016-05-25 19:01:18 +03:00
|
|
|
case SamplingFilter::POINT:
|
2015-10-06 03:12:46 +03:00
|
|
|
aLayer->set_filter(LayersPacket::Layer::FILTER_POINT);
|
2014-07-28 00:32:00 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// ignore it
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CanvasLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
|
|
|
|
{
|
|
|
|
Layer::DumpPacket(aPacket, aParent);
|
|
|
|
// Get this layer data
|
|
|
|
using namespace layerscope;
|
|
|
|
LayersPacket::Layer* layer = aPacket->mutable_layer(aPacket->layer_size()-1);
|
|
|
|
layer->set_type(LayersPacket::Layer::CanvasLayer);
|
2016-05-25 19:01:18 +03:00
|
|
|
DumpFilter(layer, mSamplingFilter);
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
|
2017-08-03 08:55:14 +03:00
|
|
|
CanvasRenderer*
|
|
|
|
CanvasLayer::CreateOrGetCanvasRenderer()
|
|
|
|
{
|
|
|
|
if (!mCanvasRenderer) {
|
|
|
|
mCanvasRenderer.reset(CreateCanvasRendererInternal());
|
|
|
|
}
|
|
|
|
|
|
|
|
return mCanvasRenderer.get();
|
|
|
|
}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
void
|
|
|
|
ImageLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
Layer::PrintInfo(aStream, aPrefix);
|
2016-05-25 19:01:18 +03:00
|
|
|
if (mSamplingFilter != SamplingFilter::GOOD) {
|
|
|
|
AppendToString(aStream, mSamplingFilter, " [filter=", "]");
|
2010-08-02 07:06:58 +04:00
|
|
|
}
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
void
|
|
|
|
ImageLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
|
|
|
|
{
|
|
|
|
Layer::DumpPacket(aPacket, aParent);
|
|
|
|
// Get this layer data
|
|
|
|
using namespace layerscope;
|
|
|
|
LayersPacket::Layer* layer = aPacket->mutable_layer(aPacket->layer_size()-1);
|
|
|
|
layer->set_type(LayersPacket::Layer::ImageLayer);
|
2016-05-25 19:01:18 +03:00
|
|
|
DumpFilter(layer, mSamplingFilter);
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
void
|
|
|
|
RefLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
2012-07-18 03:59:45 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
ContainerLayer::PrintInfo(aStream, aPrefix);
|
2018-03-25 02:06:01 +03:00
|
|
|
if (mId.IsValid()) {
|
|
|
|
AppendToString(aStream, uint64_t(mId), " [id=", "]");
|
2012-07-18 03:59:45 +04:00
|
|
|
}
|
2017-11-09 17:03:52 +03:00
|
|
|
if (mEventRegionsOverride & EventRegionsOverride::ForceDispatchToContent) {
|
|
|
|
aStream << " [force-dtc]";
|
|
|
|
}
|
|
|
|
if (mEventRegionsOverride & EventRegionsOverride::ForceEmptyHitRegion) {
|
|
|
|
aStream << " [force-ehr]";
|
|
|
|
}
|
2012-07-18 03:59:45 +04:00
|
|
|
}
|
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
void
|
|
|
|
RefLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
|
|
|
|
{
|
|
|
|
Layer::DumpPacket(aPacket, aParent);
|
|
|
|
// Get this layer data
|
|
|
|
using namespace layerscope;
|
|
|
|
LayersPacket::Layer* layer = aPacket->mutable_layer(aPacket->layer_size()-1);
|
|
|
|
layer->set_type(LayersPacket::Layer::RefLayer);
|
2018-03-25 02:06:01 +03:00
|
|
|
layer->set_refid(uint64_t(mId));
|
2014-07-28 00:32:00 +04:00
|
|
|
}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
void
|
|
|
|
ReadbackLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
2011-02-17 01:43:30 +03:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
Layer::PrintInfo(aStream, aPrefix);
|
|
|
|
AppendToString(aStream, mSize, " [size=", "]");
|
2011-02-17 01:43:30 +03:00
|
|
|
if (mBackgroundLayer) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mBackgroundLayer, " [backgroundLayer=", "]");
|
|
|
|
AppendToString(aStream, mBackgroundLayerOffset, " [backgroundOffset=", "]");
|
2015-09-25 04:16:45 +03:00
|
|
|
} else if (mBackgroundColor.a == 1.f) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mBackgroundColor, " [backgroundColor=", "]");
|
2011-02-17 01:43:30 +03:00
|
|
|
} else {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << " [nobackground]";
|
2011-02-17 01:43:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
void
|
|
|
|
ReadbackLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
|
|
|
|
{
|
|
|
|
Layer::DumpPacket(aPacket, aParent);
|
|
|
|
// Get this layer data
|
|
|
|
using namespace layerscope;
|
|
|
|
LayersPacket::Layer* layer = aPacket->mutable_layer(aPacket->layer_size()-1);
|
|
|
|
layer->set_type(LayersPacket::Layer::ReadbackLayer);
|
|
|
|
LayersPacket::Layer::Size* size = layer->mutable_size();
|
|
|
|
size->set_w(mSize.width);
|
|
|
|
size->set_h(mSize.height);
|
|
|
|
}
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
//--------------------------------------------------
|
|
|
|
// LayerManager
|
|
|
|
|
|
|
|
void
|
2016-03-17 23:18:10 +03:00
|
|
|
LayerManager::Dump(std::stringstream& aStream, const char* aPrefix,
|
|
|
|
bool aDumpHtml, bool aSorted)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2012-03-01 12:26:09 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2015-09-28 22:20:03 +03:00
|
|
|
aStream << "<ul><li>";
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2012-03-01 12:26:09 +04:00
|
|
|
#endif
|
2016-03-17 23:18:10 +03:00
|
|
|
DumpSelf(aStream, aPrefix, aSorted);
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString pfx(aPrefix);
|
2010-07-21 22:06:33 +04:00
|
|
|
pfx += " ";
|
2010-09-03 07:50:29 +04:00
|
|
|
if (!GetRoot()) {
|
2017-10-07 01:33:10 +03:00
|
|
|
aStream << nsPrintfCString("%s(null)\n", pfx.get()).get();
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "</li></ul>";
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2010-07-21 22:06:33 +04:00
|
|
|
return;
|
|
|
|
}
|
2012-07-31 21:28:20 +04:00
|
|
|
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "<ul>";
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2016-12-07 02:39:01 +03:00
|
|
|
GetRoot()->Dump(aStream, pfx.get(), aDumpHtml, aSorted);
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "</ul></li></ul>";
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "\n";
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-03-17 23:18:10 +03:00
|
|
|
LayerManager::DumpSelf(std::stringstream& aStream, const char* aPrefix, bool aSorted)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
PrintInfo(aStream, aPrefix);
|
2016-03-17 23:18:10 +03:00
|
|
|
aStream << " --- in " << (aSorted ? "3D-sorted rendering order" : "content order");
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "\n";
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2014-08-02 14:03:00 +04:00
|
|
|
void
|
2016-03-17 23:18:10 +03:00
|
|
|
LayerManager::Dump(bool aSorted)
|
2014-08-02 14:03:00 +04:00
|
|
|
{
|
|
|
|
std::stringstream ss;
|
2016-03-17 23:18:10 +03:00
|
|
|
Dump(ss, "", false, aSorted);
|
2014-08-02 14:03:00 +04:00
|
|
|
print_stderr(ss);
|
|
|
|
}
|
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
void
|
|
|
|
LayerManager::Dump(layerscope::LayersPacket* aPacket)
|
|
|
|
{
|
|
|
|
DumpPacket(aPacket);
|
|
|
|
|
|
|
|
if (GetRoot()) {
|
|
|
|
GetRoot()->Dump(aPacket, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
void
|
|
|
|
LayerManager::Log(const char* aPrefix)
|
|
|
|
{
|
|
|
|
if (!IsLogEnabled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
LogSelf(aPrefix);
|
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString pfx(aPrefix);
|
2010-07-21 22:06:33 +04:00
|
|
|
pfx += " ";
|
2010-09-03 07:50:29 +04:00
|
|
|
if (!GetRoot()) {
|
2010-07-21 22:06:33 +04:00
|
|
|
MOZ_LAYERS_LOG(("%s(null)", pfx.get()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-03 07:50:29 +04:00
|
|
|
GetRoot()->Log(pfx.get());
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LayerManager::LogSelf(const char* aPrefix)
|
|
|
|
{
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString str;
|
2014-06-20 02:36:25 +04:00
|
|
|
std::stringstream ss;
|
|
|
|
PrintInfo(ss, aPrefix);
|
|
|
|
MOZ_LAYERS_LOG(("%s", ss.str().c_str()));
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
void
|
|
|
|
LayerManager::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << aPrefix << nsPrintfCString("%sLayerManager (0x%p)", Name(), this).get();
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
void
|
|
|
|
LayerManager::DumpPacket(layerscope::LayersPacket* aPacket)
|
|
|
|
{
|
|
|
|
using namespace layerscope;
|
|
|
|
// Add a new layer data (LayerManager)
|
|
|
|
LayersPacket::Layer* layer = aPacket->add_layer();
|
|
|
|
layer->set_type(LayersPacket::Layer::LayerManager);
|
|
|
|
layer->set_ptr(reinterpret_cast<uint64_t>(this));
|
|
|
|
// Layer Tree Root
|
|
|
|
layer->set_parentptr(0);
|
|
|
|
}
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
/*static*/ bool
|
|
|
|
LayerManager::IsLogEnabled()
|
|
|
|
{
|
2015-10-30 01:44:31 +03:00
|
|
|
return MOZ_LOG_TEST(GetLog(), LogLevel::Debug);
|
2010-07-21 22:06:33 +04:00
|
|
|
}
|
|
|
|
|
2017-07-12 18:14:11 +03:00
|
|
|
bool
|
2016-04-13 17:21:13 +03:00
|
|
|
LayerManager::SetPendingScrollUpdateForNextTransaction(FrameMetrics::ViewID aScrollId,
|
|
|
|
const ScrollUpdateInfo& aUpdateInfo)
|
|
|
|
{
|
2017-07-12 18:14:11 +03:00
|
|
|
Layer* withPendingTransform = DepthFirstSearch<ForwardIterator>(GetRoot(),
|
|
|
|
[](Layer* aLayer) {
|
|
|
|
return aLayer->HasPendingTransform();
|
|
|
|
});
|
|
|
|
if (withPendingTransform) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-13 17:21:13 +03:00
|
|
|
mPendingScrollUpdates[aScrollId] = aUpdateInfo;
|
2017-07-12 18:14:11 +03:00
|
|
|
return true;
|
2016-04-13 17:21:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<ScrollUpdateInfo>
|
|
|
|
LayerManager::GetPendingScrollInfoUpdate(FrameMetrics::ViewID aScrollId)
|
|
|
|
{
|
|
|
|
auto it = mPendingScrollUpdates.find(aScrollId);
|
|
|
|
if (it != mPendingScrollUpdates.end()) {
|
|
|
|
return Some(it->second);
|
|
|
|
}
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LayerManager::ClearPendingScrollInfoUpdate()
|
|
|
|
{
|
|
|
|
mPendingScrollUpdates.clear();
|
|
|
|
}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
void
|
2016-11-24 08:11:27 +03:00
|
|
|
PrintInfo(std::stringstream& aStream, HostLayer* aLayerComposite)
|
2010-10-14 02:55:45 +04:00
|
|
|
{
|
2013-04-26 02:25:33 +04:00
|
|
|
if (!aLayerComposite) {
|
2014-06-20 02:36:25 +04:00
|
|
|
return;
|
2010-10-14 02:55:45 +04:00
|
|
|
}
|
2015-04-12 05:03:00 +03:00
|
|
|
if (const Maybe<ParentLayerIntRect>& clipRect = aLayerComposite->GetShadowClipRect()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, *clipRect, " [shadow-clip=", "]");
|
2010-10-14 02:55:45 +04:00
|
|
|
}
|
2016-02-21 03:05:59 +03:00
|
|
|
if (!aLayerComposite->GetShadowBaseTransform().IsIdentity()) {
|
|
|
|
AppendToString(aStream, aLayerComposite->GetShadowBaseTransform(), " [shadow-transform=", "]");
|
2010-10-14 02:55:45 +04:00
|
|
|
}
|
2013-04-26 02:25:33 +04:00
|
|
|
if (!aLayerComposite->GetShadowVisibleRegion().IsEmpty()) {
|
2015-11-29 10:07:55 +03:00
|
|
|
AppendToString(aStream, aLayerComposite->GetShadowVisibleRegion().ToUnknownRegion(), " [shadow-visible=", "]");
|
2010-10-14 02:55:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-08 01:06:08 +04:00
|
|
|
void
|
|
|
|
SetAntialiasingFlags(Layer* aLayer, DrawTarget* aTarget)
|
|
|
|
{
|
2014-01-08 05:21:56 +04:00
|
|
|
bool permitSubpixelAA = !(aLayer->GetContentFlags() & Layer::CONTENT_DISABLE_SUBPIXEL_AA);
|
2016-01-06 02:04:42 +03:00
|
|
|
if (aTarget->IsCurrentGroupOpaque()) {
|
2014-01-08 01:06:08 +04:00
|
|
|
aTarget->SetPermitSubpixelAA(permitSubpixelAA);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-29 10:07:55 +03:00
|
|
|
const IntRect& bounds = aLayer->GetVisibleRegion().ToUnknownRegion().GetBounds();
|
2017-12-19 23:48:39 +03:00
|
|
|
gfx::Rect transformedBounds = aTarget->GetTransform().TransformBounds(gfx::Rect(Float(bounds.X()), Float(bounds.Y()),
|
2017-08-14 15:29:28 +03:00
|
|
|
Float(bounds.Width()), Float(bounds.Height())));
|
2014-01-08 01:06:08 +04:00
|
|
|
transformedBounds.RoundOut();
|
|
|
|
IntRect intTransformedBounds;
|
|
|
|
transformedBounds.ToIntRect(&intTransformedBounds);
|
|
|
|
permitSubpixelAA &= !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
|
|
|
|
aTarget->GetOpaqueRect().Contains(intTransformedBounds);
|
|
|
|
aTarget->SetPermitSubpixelAA(permitSubpixelAA);
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:07:53 +03:00
|
|
|
IntRect
|
2014-08-19 00:13:12 +04:00
|
|
|
ToOutsideIntRect(const gfxRect &aRect)
|
|
|
|
{
|
2017-12-19 23:48:39 +03:00
|
|
|
return IntRect::RoundOut(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height());
|
2014-08-19 00:13:12 +04:00
|
|
|
}
|
|
|
|
|
2012-07-31 21:28:20 +04:00
|
|
|
} // namespace layers
|
2010-07-21 22:06:33 +04:00
|
|
|
} // namespace mozilla
|