2010-07-21 22:06:33 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
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
|
|
|
|
#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
|
|
|
|
#include "mozilla/Telemetry.h" // for Accumulate
|
2015-04-21 04:22:09 +03:00
|
|
|
#include "mozilla/dom/Animation.h" // for ComputedTimingFunction
|
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
|
2015-10-12 06:21:02 +03:00
|
|
|
#include "mozilla/layers/AsyncCanvasRenderer.h"
|
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"
|
2016-01-29 16:44:00 +03:00
|
|
|
#include "mozilla/layers/LayerAnimationUtils.h" // for TimingFunctionToComputedTimingFunction
|
2013-08-12 03:17:23 +04:00
|
|
|
#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
|
|
|
|
#include "nsPrintfCString.h" // for nsPrintfCString
|
|
|
|
#include "nsStyleStruct.h" // for nsTimingFunction, etc
|
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"
|
2010-09-04 00:10:45 +04:00
|
|
|
|
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-01-07 18:53:51 +03:00
|
|
|
nsTArray<LayerMetricsWrapper> queue = { LayerMetricsWrapper(mRoot) };
|
2012-09-27 00:41:56 +04:00
|
|
|
while (queue.Length()) {
|
2014-08-28 06:13:41 +04:00
|
|
|
LayerMetricsWrapper layer = queue[0];
|
2012-09-27 00:41:56 +04:00
|
|
|
queue.RemoveElementAt(0);
|
|
|
|
|
2014-08-28 06:13:41 +04:00
|
|
|
const FrameMetrics& frameMetrics = layer.Metrics();
|
2012-09-27 00:41:56 +04:00
|
|
|
if (frameMetrics.IsScrollable()) {
|
2014-08-28 06:13:41 +04:00
|
|
|
return frameMetrics.GetScrollId();
|
2012-09-27 00:41:56 +04:00
|
|
|
}
|
|
|
|
|
2014-08-28 06:13:41 +04:00
|
|
|
LayerMetricsWrapper child = layer.GetFirstChild();
|
|
|
|
while (child) {
|
|
|
|
queue.AppendElement(child);
|
|
|
|
child = child.GetNextSibling();
|
2012-09-27 00:41:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-28 06:13:41 +04:00
|
|
|
return FrameMetrics::NULL_SCROLL_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LayerManager::GetRootScrollableLayers(nsTArray<Layer*>& aArray)
|
|
|
|
{
|
|
|
|
if (!mRoot) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FrameMetrics::ViewID rootScrollableId = GetRootScrollableLayerId();
|
|
|
|
if (rootScrollableId == FrameMetrics::NULL_SCROLL_ID) {
|
|
|
|
aArray.AppendElement(mRoot);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-07 18:53:51 +03:00
|
|
|
nsTArray<Layer*> queue = { mRoot };
|
2014-08-28 06:13:41 +04:00
|
|
|
while (queue.Length()) {
|
|
|
|
Layer* layer = queue[0];
|
|
|
|
queue.RemoveElementAt(0);
|
|
|
|
|
|
|
|
if (LayerMetricsWrapper::TopmostScrollableMetrics(layer).GetScrollId() == rootScrollableId) {
|
|
|
|
aArray.AppendElement(layer);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Layer* child = layer->GetFirstChild(); child; child = child->GetNextSibling()) {
|
|
|
|
queue.AppendElement(child);
|
|
|
|
}
|
|
|
|
}
|
2012-09-27 00:41:56 +04:00
|
|
|
}
|
|
|
|
|
2013-01-10 13:10:20 +04:00
|
|
|
void
|
|
|
|
LayerManager::GetScrollableLayers(nsTArray<Layer*>& aArray)
|
|
|
|
{
|
|
|
|
if (!mRoot) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-07 18:53:51 +03:00
|
|
|
nsTArray<Layer*> queue = { mRoot };
|
2013-01-10 13:10:20 +04:00
|
|
|
while (!queue.IsEmpty()) {
|
2014-08-21 13:40:00 +04:00
|
|
|
Layer* layer = queue.LastElement();
|
2013-01-10 13:10:20 +04:00
|
|
|
queue.RemoveElementAt(queue.Length() - 1);
|
|
|
|
|
2014-08-28 06:13:41 +04:00
|
|
|
if (layer->HasScrollableFrameMetrics()) {
|
2014-08-21 13:40:00 +04:00
|
|
|
aArray.AppendElement(layer);
|
2013-01-10 13:10:20 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-08-28 06:13:41 +04:00
|
|
|
for (Layer* child = layer->GetFirstChild(); child; child = child->GetNextSibling()) {
|
|
|
|
queue.AppendElement(child);
|
2013-01-10 13:10:20 +04: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,
|
|
|
|
mozilla::gfx::SurfaceFormat aFormat)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PersistentBufferProviderBasic> bufferProvider =
|
2015-08-26 13:58:18 +03:00
|
|
|
new PersistentBufferProviderBasic(aSize, aFormat,
|
2015-06-19 02:07:21 +03:00
|
|
|
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend());
|
|
|
|
|
|
|
|
if (!bufferProvider->IsValid()) {
|
|
|
|
bufferProvider =
|
2015-08-26 13:58:18 +03:00
|
|
|
new PersistentBufferProviderBasic(aSize, aFormat,
|
2015-06-19 02:07:21 +03:00
|
|
|
gfxPlatform::GetPlatform()->GetFallbackCanvasBackend());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bufferProvider->IsValid()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bufferProvider.forget();
|
|
|
|
}
|
|
|
|
|
2011-01-26 09:26:37 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
LayerManager::Mutated(Layer* aLayer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-10-22 23:57:29 +03:00
|
|
|
nsAutoPtr<LayerUserData>
|
|
|
|
LayerManager::RemoveUserData(void* aKey)
|
|
|
|
{
|
|
|
|
nsAutoPtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
//--------------------------------------------------
|
|
|
|
// Layer
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2012-07-31 21:28:20 +04:00
|
|
|
Layer::Layer(LayerManager* aManager, void* aImplData) :
|
|
|
|
mManager(aManager),
|
|
|
|
mParent(nullptr),
|
|
|
|
mNextSibling(nullptr),
|
|
|
|
mPrevSibling(nullptr),
|
|
|
|
mImplData(aImplData),
|
|
|
|
mMaskLayer(nullptr),
|
2012-08-04 01:29:22 +04:00
|
|
|
mPostXScale(1.0f),
|
|
|
|
mPostYScale(1.0f),
|
2012-07-31 21:28:20 +04:00
|
|
|
mOpacity(1.0),
|
2014-02-12 19:07:46 +04:00
|
|
|
mMixBlendMode(CompositionOp::OP_OVER),
|
2013-09-15 07:30:00 +04:00
|
|
|
mForceIsolatedGroup(false),
|
2012-07-31 21:28:20 +04:00
|
|
|
mContentFlags(0),
|
|
|
|
mUseTileSourceRect(false),
|
|
|
|
mIsFixedPosition(false),
|
2015-11-03 01:38:08 +03:00
|
|
|
mTransformIsPerspective(false),
|
2015-08-18 02:44:42 +03:00
|
|
|
mFixedPositionData(nullptr),
|
2013-09-12 08:17:58 +04:00
|
|
|
mStickyPositionData(nullptr),
|
2013-12-12 22:34:50 +04:00
|
|
|
mScrollbarTargetId(FrameMetrics::NULL_SCROLL_ID),
|
|
|
|
mScrollbarDirection(ScrollDirection::NONE),
|
2015-04-13 06:03:02 +03:00
|
|
|
mScrollbarThumbRatio(0.0f),
|
2015-01-14 10:55:17 +03:00
|
|
|
mIsScrollbarContainer(false),
|
2016-02-26 18:52:07 +03:00
|
|
|
#ifdef DEBUG
|
2012-12-12 01:12:43 +04:00
|
|
|
mDebugColorIndex(0),
|
2016-02-26 18:52:07 +03:00
|
|
|
#endif
|
2014-08-29 16:23:25 +04:00
|
|
|
mAnimationGeneration(0)
|
2015-07-29 18:57:03 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(Layer);
|
|
|
|
}
|
2012-07-31 21:28:20 +04:00
|
|
|
|
|
|
|
Layer::~Layer()
|
2015-07-29 18:57:03 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(Layer);
|
|
|
|
}
|
2012-07-31 21:28:20 +04:00
|
|
|
|
2012-08-20 17:35:42 +04:00
|
|
|
Animation*
|
2014-03-05 08:13:21 +04:00
|
|
|
Layer::AddAnimation()
|
2012-07-31 21:28:20 +04:00
|
|
|
{
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) AddAnimation", this));
|
|
|
|
|
2014-03-05 08:13:21 +04:00
|
|
|
MOZ_ASSERT(!mPendingAnimations, "should have called ClearAnimations first");
|
|
|
|
|
2012-08-20 17:35:42 +04:00
|
|
|
Animation* anim = mAnimations.AppendElement();
|
2012-07-31 21:28:20 +04:00
|
|
|
|
|
|
|
Mutated();
|
2012-08-20 17:35:42 +04:00
|
|
|
return anim;
|
2012-07-31 21:28:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Layer::ClearAnimations()
|
|
|
|
{
|
2014-03-05 08:13:21 +04:00
|
|
|
mPendingAnimations = nullptr;
|
|
|
|
|
2013-03-22 06:17:28 +04:00
|
|
|
if (mAnimations.IsEmpty() && mAnimationData.IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClearAnimations", this));
|
2012-07-31 21:28:20 +04:00
|
|
|
mAnimations.Clear();
|
|
|
|
mAnimationData.Clear();
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2014-03-05 08:13:21 +04:00
|
|
|
Animation*
|
|
|
|
Layer::AddAnimationForNextTransaction()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mPendingAnimations,
|
|
|
|
"should have called ClearAnimationsForNextTransaction first");
|
|
|
|
|
|
|
|
Animation* anim = mPendingAnimations->AppendElement();
|
|
|
|
|
|
|
|
return anim;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Layer::ClearAnimationsForNextTransaction()
|
|
|
|
{
|
|
|
|
// Ensure we have a non-null mPendingAnimations to mark a future clear.
|
|
|
|
if (!mPendingAnimations) {
|
|
|
|
mPendingAnimations = new AnimationArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
mPendingAnimations->Clear();
|
|
|
|
}
|
|
|
|
|
2015-04-23 19:18:12 +03:00
|
|
|
static inline void
|
|
|
|
SetCSSAngle(const CSSAngle& aAngle, nsCSSValue& aValue)
|
|
|
|
{
|
|
|
|
aValue.SetFloatValue(aAngle.value(), nsCSSUnit(aAngle.unit()));
|
|
|
|
}
|
|
|
|
|
2013-12-12 06:09:44 +04:00
|
|
|
static nsCSSValueSharedList*
|
2012-07-31 21:28:20 +04:00
|
|
|
CreateCSSValueList(const InfallibleTArray<TransformFunction>& aFunctions)
|
|
|
|
{
|
|
|
|
nsAutoPtr<nsCSSValueList> result;
|
|
|
|
nsCSSValueList** resultTail = getter_Transfers(result);
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < aFunctions.Length(); i++) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsCSSValue::Array> arr;
|
2012-07-31 21:28:20 +04:00
|
|
|
switch (aFunctions[i].type()) {
|
|
|
|
case TransformFunction::TRotationX:
|
|
|
|
{
|
2015-04-23 19:18:12 +03:00
|
|
|
const CSSAngle& angle = aFunctions[i].get_RotationX().angle();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotatex,
|
|
|
|
resultTail);
|
2015-04-23 19:18:12 +03:00
|
|
|
SetCSSAngle(angle, arr->Item(1));
|
2012-07-31 21:28:20 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TRotationY:
|
|
|
|
{
|
2015-04-23 19:18:12 +03:00
|
|
|
const CSSAngle& angle = aFunctions[i].get_RotationY().angle();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotatey,
|
|
|
|
resultTail);
|
2015-04-23 19:18:12 +03:00
|
|
|
SetCSSAngle(angle, arr->Item(1));
|
2012-07-31 21:28:20 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TRotationZ:
|
|
|
|
{
|
2015-04-23 19:18:12 +03:00
|
|
|
const CSSAngle& angle = aFunctions[i].get_RotationZ().angle();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotatez,
|
|
|
|
resultTail);
|
2015-04-23 19:18:12 +03:00
|
|
|
SetCSSAngle(angle, arr->Item(1));
|
2012-07-31 21:28:20 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TRotation:
|
|
|
|
{
|
2015-04-23 19:18:12 +03:00
|
|
|
const CSSAngle& angle = aFunctions[i].get_Rotation().angle();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotate,
|
|
|
|
resultTail);
|
2015-04-23 19:18:12 +03:00
|
|
|
SetCSSAngle(angle, arr->Item(1));
|
2012-07-31 21:28:20 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TRotation3D:
|
|
|
|
{
|
|
|
|
float x = aFunctions[i].get_Rotation3D().x();
|
|
|
|
float y = aFunctions[i].get_Rotation3D().y();
|
|
|
|
float z = aFunctions[i].get_Rotation3D().z();
|
2015-04-23 19:18:12 +03:00
|
|
|
const CSSAngle& angle = aFunctions[i].get_Rotation3D().angle();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr =
|
|
|
|
StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotate3d,
|
|
|
|
resultTail);
|
2012-07-31 21:28:20 +04:00
|
|
|
arr->Item(1).SetFloatValue(x, eCSSUnit_Number);
|
|
|
|
arr->Item(2).SetFloatValue(y, eCSSUnit_Number);
|
|
|
|
arr->Item(3).SetFloatValue(z, eCSSUnit_Number);
|
2015-04-23 19:18:12 +03:00
|
|
|
SetCSSAngle(angle, arr->Item(4));
|
2012-07-31 21:28:20 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TScale:
|
|
|
|
{
|
2014-06-24 10:29:54 +04:00
|
|
|
arr =
|
|
|
|
StyleAnimationValue::AppendTransformFunction(eCSSKeyword_scale3d,
|
|
|
|
resultTail);
|
2012-07-31 21:28:20 +04:00
|
|
|
arr->Item(1).SetFloatValue(aFunctions[i].get_Scale().x(), eCSSUnit_Number);
|
|
|
|
arr->Item(2).SetFloatValue(aFunctions[i].get_Scale().y(), eCSSUnit_Number);
|
|
|
|
arr->Item(3).SetFloatValue(aFunctions[i].get_Scale().z(), eCSSUnit_Number);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TTranslation:
|
|
|
|
{
|
2014-06-24 10:29:54 +04:00
|
|
|
arr =
|
|
|
|
StyleAnimationValue::AppendTransformFunction(eCSSKeyword_translate3d,
|
|
|
|
resultTail);
|
2012-07-31 21:28:20 +04:00
|
|
|
arr->Item(1).SetFloatValue(aFunctions[i].get_Translation().x(), eCSSUnit_Pixel);
|
|
|
|
arr->Item(2).SetFloatValue(aFunctions[i].get_Translation().y(), eCSSUnit_Pixel);
|
|
|
|
arr->Item(3).SetFloatValue(aFunctions[i].get_Translation().z(), eCSSUnit_Pixel);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TSkewX:
|
|
|
|
{
|
2015-04-23 19:18:12 +03:00
|
|
|
const CSSAngle& x = aFunctions[i].get_SkewX().x();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_skewx,
|
|
|
|
resultTail);
|
2015-04-23 19:18:12 +03:00
|
|
|
SetCSSAngle(x, arr->Item(1));
|
2012-07-31 21:28:20 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TSkewY:
|
|
|
|
{
|
2015-04-23 19:18:12 +03:00
|
|
|
const CSSAngle& y = aFunctions[i].get_SkewY().y();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_skewy,
|
|
|
|
resultTail);
|
2015-04-23 19:18:12 +03:00
|
|
|
SetCSSAngle(y, arr->Item(1));
|
2013-05-21 14:22:44 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TSkew:
|
|
|
|
{
|
2015-04-23 19:18:12 +03:00
|
|
|
const CSSAngle& x = aFunctions[i].get_Skew().x();
|
|
|
|
const CSSAngle& y = aFunctions[i].get_Skew().y();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_skew,
|
|
|
|
resultTail);
|
2015-04-23 19:18:12 +03:00
|
|
|
SetCSSAngle(x, arr->Item(1));
|
|
|
|
SetCSSAngle(y, arr->Item(2));
|
2012-07-31 21:28:20 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TTransformMatrix:
|
|
|
|
{
|
2014-06-24 10:29:54 +04:00
|
|
|
arr =
|
|
|
|
StyleAnimationValue::AppendTransformFunction(eCSSKeyword_matrix3d,
|
|
|
|
resultTail);
|
2014-01-27 19:28:33 +04:00
|
|
|
const gfx::Matrix4x4& matrix = aFunctions[i].get_TransformMatrix().value();
|
2012-07-31 21:28:20 +04:00
|
|
|
arr->Item(1).SetFloatValue(matrix._11, eCSSUnit_Number);
|
|
|
|
arr->Item(2).SetFloatValue(matrix._12, eCSSUnit_Number);
|
|
|
|
arr->Item(3).SetFloatValue(matrix._13, eCSSUnit_Number);
|
|
|
|
arr->Item(4).SetFloatValue(matrix._14, eCSSUnit_Number);
|
|
|
|
arr->Item(5).SetFloatValue(matrix._21, eCSSUnit_Number);
|
|
|
|
arr->Item(6).SetFloatValue(matrix._22, eCSSUnit_Number);
|
|
|
|
arr->Item(7).SetFloatValue(matrix._23, eCSSUnit_Number);
|
|
|
|
arr->Item(8).SetFloatValue(matrix._24, eCSSUnit_Number);
|
|
|
|
arr->Item(9).SetFloatValue(matrix._31, eCSSUnit_Number);
|
|
|
|
arr->Item(10).SetFloatValue(matrix._32, eCSSUnit_Number);
|
|
|
|
arr->Item(11).SetFloatValue(matrix._33, eCSSUnit_Number);
|
|
|
|
arr->Item(12).SetFloatValue(matrix._34, eCSSUnit_Number);
|
|
|
|
arr->Item(13).SetFloatValue(matrix._41, eCSSUnit_Number);
|
|
|
|
arr->Item(14).SetFloatValue(matrix._42, eCSSUnit_Number);
|
|
|
|
arr->Item(15).SetFloatValue(matrix._43, eCSSUnit_Number);
|
|
|
|
arr->Item(16).SetFloatValue(matrix._44, eCSSUnit_Number);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TPerspective:
|
|
|
|
{
|
|
|
|
float perspective = aFunctions[i].get_Perspective().value();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr =
|
|
|
|
StyleAnimationValue::AppendTransformFunction(eCSSKeyword_perspective,
|
|
|
|
resultTail);
|
2012-07-31 21:28:20 +04:00
|
|
|
arr->Item(1).SetFloatValue(perspective, eCSSUnit_Pixel);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_ASSERTION(false, "All functions should be implemented?");
|
|
|
|
}
|
|
|
|
}
|
2012-08-21 08:06:47 +04:00
|
|
|
if (aFunctions.Length() == 0) {
|
|
|
|
result = new nsCSSValueList();
|
|
|
|
result->mValue.SetNoneValue();
|
|
|
|
}
|
2013-12-12 06:09:44 +04:00
|
|
|
return new nsCSSValueSharedList(result.forget());
|
2012-07-31 21:28:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Layer::SetAnimations(const AnimationArray& aAnimations)
|
|
|
|
{
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) SetAnimations", this));
|
|
|
|
|
2012-07-31 21:28:20 +04:00
|
|
|
mAnimations = aAnimations;
|
|
|
|
mAnimationData.Clear();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mAnimations.Length(); i++) {
|
2012-08-21 08:06:47 +04:00
|
|
|
AnimData* data = mAnimationData.AppendElement();
|
2016-01-29 16:44:00 +03:00
|
|
|
InfallibleTArray<Maybe<ComputedTimingFunction>>& functions =
|
2014-08-10 11:06:44 +04:00
|
|
|
data->mFunctions;
|
2012-11-29 20:14:13 +04:00
|
|
|
const InfallibleTArray<AnimationSegment>& segments =
|
|
|
|
mAnimations.ElementAt(i).segments();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t j = 0; j < segments.Length(); j++) {
|
2012-07-31 21:28:20 +04:00
|
|
|
TimingFunction tf = segments.ElementAt(j).sampleFn();
|
2016-01-29 16:44:00 +03:00
|
|
|
|
|
|
|
Maybe<ComputedTimingFunction> ctf =
|
|
|
|
AnimationUtils::TimingFunctionToComputedTimingFunction(tf);
|
2012-08-21 08:06:47 +04:00
|
|
|
functions.AppendElement(ctf);
|
2012-07-31 21:28:20 +04:00
|
|
|
}
|
|
|
|
|
2014-06-24 10:29:54 +04:00
|
|
|
// Precompute the StyleAnimationValues that we need if this is a transform
|
2012-07-31 21:28:20 +04:00
|
|
|
// animation.
|
2014-06-24 10:29:54 +04:00
|
|
|
InfallibleTArray<StyleAnimationValue>& startValues = data->mStartValues;
|
|
|
|
InfallibleTArray<StyleAnimationValue>& endValues = data->mEndValues;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t j = 0; j < mAnimations[i].segments().Length(); j++) {
|
2012-07-31 21:28:20 +04:00
|
|
|
const AnimationSegment& segment = mAnimations[i].segments()[j];
|
2014-06-24 10:29:54 +04:00
|
|
|
StyleAnimationValue* startValue = startValues.AppendElement();
|
|
|
|
StyleAnimationValue* endValue = endValues.AppendElement();
|
2012-07-31 21:28:20 +04:00
|
|
|
if (segment.endState().type() == Animatable::TArrayOfTransformFunction) {
|
|
|
|
const InfallibleTArray<TransformFunction>& startFunctions =
|
|
|
|
segment.startState().get_ArrayOfTransformFunction();
|
2013-12-12 06:09:44 +04:00
|
|
|
startValue->SetTransformValue(CreateCSSValueList(startFunctions));
|
2012-07-31 21:28:20 +04:00
|
|
|
|
|
|
|
const InfallibleTArray<TransformFunction>& endFunctions =
|
|
|
|
segment.endState().get_ArrayOfTransformFunction();
|
2013-12-12 06:09:44 +04:00
|
|
|
endValue->SetTransformValue(CreateCSSValueList(endFunctions));
|
2012-07-31 21:28:20 +04:00
|
|
|
} else {
|
2012-08-20 17:35:41 +04:00
|
|
|
NS_ASSERTION(segment.endState().type() == Animatable::Tfloat,
|
2012-07-31 21:28:20 +04:00
|
|
|
"Unknown Animatable type");
|
2012-08-21 08:06:47 +04:00
|
|
|
startValue->SetFloatValue(segment.startState().get_float());
|
|
|
|
endValue->SetFloatValue(segment.endState().get_float());
|
2012-07-31 21:28:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2014-12-22 03:35:41 +03:00
|
|
|
void
|
|
|
|
Layer::StartPendingAnimations(const TimeStamp& aReadyTime)
|
|
|
|
{
|
|
|
|
bool updated = false;
|
|
|
|
for (size_t animIdx = 0, animEnd = mAnimations.Length();
|
|
|
|
animIdx < animEnd; animIdx++) {
|
|
|
|
Animation& anim = mAnimations[animIdx];
|
|
|
|
if (anim.startTime().IsNull()) {
|
|
|
|
anim.startTime() = aReadyTime - anim.initialCurrentTime();
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (updated) {
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) {
|
|
|
|
child->StartPendingAnimations(aReadyTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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());
|
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()
|
|
|
|
{
|
|
|
|
ApplyPendingUpdatesForThisTransaction();
|
|
|
|
for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) {
|
|
|
|
child->ApplyPendingUpdatesToSubtree();
|
|
|
|
}
|
2016-04-13 17:21:13 +03:00
|
|
|
if (!GetParent()) {
|
|
|
|
// 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()
|
|
|
|
{
|
|
|
|
return GetLocalOpacity() == 1.0f &&
|
|
|
|
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
|
|
|
{
|
2013-04-26 02:25:33 +04:00
|
|
|
if (LayerComposite* shadow = AsLayerComposite()) {
|
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
|
|
|
{
|
2013-04-26 02:25:33 +04:00
|
|
|
if (LayerComposite* shadow = AsLayerComposite()) {
|
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;
|
|
|
|
Matrix4x4 result;
|
2016-04-06 06:29:32 +03:00
|
|
|
if (aTransform.CanDraw2D(&matrix2D) &&
|
2012-12-07 03:58:13 +04:00
|
|
|
!matrix2D.HasNonTranslation() &&
|
|
|
|
matrix2D.HasNonIntegerTranslation()) {
|
2014-01-27 19:27:20 +04:00
|
|
|
IntPoint snappedTranslation = RoundedToInt(matrix2D.GetTranslation());
|
2014-03-22 03:56:11 +04:00
|
|
|
Matrix snappedMatrix = Matrix::Translation(snappedTranslation.x,
|
|
|
|
snappedTranslation.y);
|
2014-01-27 19:27:20 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
Point3D transformedOrigin = aTransform * Point3D();
|
|
|
|
|
|
|
|
// Compute the transformed snap by rounding the values of
|
|
|
|
// transformed origin.
|
|
|
|
IntPoint transformedSnapXY =
|
|
|
|
RoundedToInt(Point(transformedOrigin.x, transformedOrigin.y));
|
|
|
|
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.
|
|
|
|
Point3D snap = inverse * transformedSnap;
|
|
|
|
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;
|
|
|
|
result = aTransform;
|
|
|
|
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()) {
|
2014-01-27 19:27:20 +04:00
|
|
|
IntPoint transformedTopLeft = RoundedToInt(matrix2D * ToPoint(aSnapRect.TopLeft()));
|
|
|
|
IntPoint transformedTopRight = RoundedToInt(matrix2D * ToPoint(aSnapRect.TopRight()));
|
|
|
|
IntPoint transformedBottomRight = RoundedToInt(matrix2D * ToPoint(aSnapRect.BottomRight()));
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
|
2015-09-14 19:26:10 +03:00
|
|
|
if (GetVisibleRegion().IsEmpty()) {
|
|
|
|
// 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-02-13 04:24:38 +03:00
|
|
|
// Note that we do not use GetLocalVisibleRegion(), because that can be
|
|
|
|
// empty for a layer whose rendered contents have been async-scrolled
|
|
|
|
// completely offscreen, but for which we still need to draw a
|
|
|
|
// checkerboarding backround color, and calculating an empty scissor rect
|
|
|
|
// for such a layer would prevent that (see bug 1247452 comment 10).
|
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");
|
2014-01-28 00:25:19 +04:00
|
|
|
gfx::Rect r(scissor.x, scissor.y, scissor.width, scissor.height);
|
|
|
|
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-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
|
|
|
|
Layer::IsScrollInfoLayer() const
|
|
|
|
{
|
|
|
|
// A scrollable container layer with no children
|
|
|
|
return AsContainerLayer()
|
|
|
|
&& HasScrollableFrameMetrics()
|
|
|
|
&& !GetFirstChild();
|
|
|
|
}
|
|
|
|
|
2014-01-27 19:28:47 +04:00
|
|
|
const Matrix4x4
|
2013-07-02 20:27:17 +04:00
|
|
|
Layer::GetTransform() const
|
2012-07-31 06:20:00 +04:00
|
|
|
{
|
2014-01-27 19:29:06 +04:00
|
|
|
Matrix4x4 transform = mTransform;
|
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());
|
|
|
|
}
|
|
|
|
|
2014-01-27 19:28:18 +04:00
|
|
|
const Matrix4x4
|
2010-11-08 12:06:15 +03:00
|
|
|
Layer::GetLocalTransform()
|
2010-10-14 02:55:45 +04:00
|
|
|
{
|
2013-04-26 02:25:33 +04:00
|
|
|
if (LayerComposite* shadow = AsLayerComposite())
|
2016-05-01 13:54:26 +03:00
|
|
|
return shadow->GetShadowTransform();
|
2012-07-31 06:20:00 +04:00
|
|
|
else
|
2016-05-01 13:54:26 +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());
|
|
|
|
}
|
|
|
|
|
2015-02-27 01:45:37 +03:00
|
|
|
bool
|
|
|
|
Layer::HasTransformAnimation() const
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < mAnimations.Length(); i++) {
|
|
|
|
if (mAnimations[i].property() == eCSSProperty_transform) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-03 09:55:50 +04:00
|
|
|
void
|
|
|
|
Layer::ApplyPendingUpdatesForThisTransaction()
|
|
|
|
{
|
|
|
|
if (mPendingTransform && *mPendingTransform != mTransform) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PendingUpdatesForThisTransaction", this));
|
2012-10-03 09:55:50 +04:00
|
|
|
mTransform = *mPendingTransform;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
mPendingTransform = nullptr;
|
2014-03-05 08:13:21 +04:00
|
|
|
|
|
|
|
if (mPendingAnimations) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PendingUpdatesForThisTransaction", this));
|
|
|
|
mPendingAnimations->SwapElements(mAnimations);
|
|
|
|
mPendingAnimations = nullptr;
|
|
|
|
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()
|
|
|
|
{
|
2015-08-27 01:15:47 +03:00
|
|
|
float opacity = mOpacity;
|
|
|
|
if (LayerComposite* shadow = AsLayerComposite())
|
|
|
|
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()
|
|
|
|
{
|
2014-02-12 19:07:46 +04:00
|
|
|
if(mMixBlendMode != CompositionOp::OP_OVER)
|
2013-09-15 07:23:46 +04:00
|
|
|
return mMixBlendMode;
|
|
|
|
for (ContainerLayer* c = GetParent(); c && !c->UseIntermediateSurface();
|
|
|
|
c = c->GetParent()) {
|
2014-02-12 19:07:46 +04:00
|
|
|
if(c->mMixBlendMode != CompositionOp::OP_OVER)
|
2013-09-15 07:23:46 +04:00
|
|
|
return c->mMixBlendMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mMixBlendMode;
|
|
|
|
}
|
2010-10-14 02:55:45 +04:00
|
|
|
|
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,
|
|
|
|
nsIntPoint* aLayerOffset)
|
|
|
|
{
|
|
|
|
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.
|
|
|
|
IntPoint currentLayerOffset = RoundedToInt(matrix.GetTranslation());
|
|
|
|
|
|
|
|
// 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|.
|
|
|
|
IntPoint siblingOffset = RoundedToInt(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;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aLayerOffset = nsIntPoint(offset.x, offset.y);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-03 02:34:28 +03:00
|
|
|
Maybe<ParentLayerIntRect>
|
|
|
|
Layer::GetCombinedClipRect() const
|
|
|
|
{
|
|
|
|
Maybe<ParentLayerIntRect> clip = GetClipRect();
|
|
|
|
|
2016-03-29 02:14:52 +03:00
|
|
|
for (size_t i = 0; i < mScrollMetadata.Length(); i++) {
|
|
|
|
if (!mScrollMetadata[i].HasClipRect()) {
|
2015-06-03 02:34:28 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-03-29 02:14:52 +03:00
|
|
|
const ParentLayerIntRect& other = mScrollMetadata[i].ClipRect();
|
2015-06-03 02:34:28 +03:00
|
|
|
if (clip) {
|
|
|
|
clip = Some(clip.value().Intersect(other));
|
|
|
|
} else {
|
|
|
|
clip = Some(other);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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),
|
2015-02-11 00:28:07 +03:00
|
|
|
mChildrenChanged(false),
|
2015-09-18 00:23:13 +03:00
|
|
|
mEventRegionsOverride(EventRegionsOverride::NoOverride),
|
2016-01-09 05:50:10 +03:00
|
|
|
mVRDeviceID(0),
|
|
|
|
mInputFrameID(0)
|
2013-07-02 20:01:46 +04:00
|
|
|
{
|
2015-07-29 18:57:03 +03:00
|
|
|
MOZ_COUNT_CTOR(ContainerLayer);
|
2013-07-02 20:01:46 +04:00
|
|
|
mContentFlags = 0; // Clear NO_TEXT, NO_TEXT_OVER_TRANSPARENT
|
|
|
|
}
|
|
|
|
|
2015-07-29 18:57:03 +03:00
|
|
|
ContainerLayer::~ContainerLayer()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(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
|
|
|
}
|
|
|
|
|
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,
|
2015-01-03 04:06:14 +03:00
|
|
|
mPresShellResolution, mScaleToResolution,
|
2015-02-17 05:30:02 +03:00
|
|
|
mEventRegionsOverride,
|
2016-01-09 05:50:10 +03:00
|
|
|
mVRDeviceID,
|
|
|
|
mInputFrameID);
|
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)
|
|
|
|
{
|
|
|
|
for (Layer* l = GetFirstChild(); l; l = l->GetNextSibling()) {
|
|
|
|
ContainerLayer* container = l->AsContainerLayer();
|
2015-09-28 10:43:00 +03:00
|
|
|
if (container && container->Extend3DContext() &&
|
|
|
|
!container->UseIntermediateSurface()) {
|
2015-09-17 04:31:00 +03:00
|
|
|
container->Collect3DContextLeaves(aToSort);
|
|
|
|
} else {
|
|
|
|
aToSort.AppendElement(l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-07 01:23:18 +04:00
|
|
|
void
|
|
|
|
ContainerLayer::SortChildrenBy3DZOrder(nsTArray<Layer*>& aArray)
|
|
|
|
{
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<Layer*, 10> toSort;
|
2011-10-07 01:23:18 +04:00
|
|
|
|
|
|
|
for (Layer* l = GetFirstChild(); l; l = l->GetNextSibling()) {
|
|
|
|
ContainerLayer* container = l->AsContainerLayer();
|
2015-09-28 10:43:00 +03:00
|
|
|
if (container && container->Extend3DContext() &&
|
|
|
|
!container->UseIntermediateSurface()) {
|
2015-09-17 04:31:00 +03:00
|
|
|
container->Collect3DContextLeaves(toSort);
|
2011-10-07 01:23:18 +04:00
|
|
|
} else {
|
|
|
|
if (toSort.Length() > 0) {
|
|
|
|
SortLayersBy3DZOrder(toSort);
|
2015-08-11 18:29:46 +03:00
|
|
|
aArray.AppendElements(Move(toSort));
|
2015-09-08 21:22:02 +03:00
|
|
|
// XXX The move analysis gets confused here, because toSort gets moved
|
|
|
|
// here, and then gets used again outside of the loop. To clarify that
|
|
|
|
// we realize that the array is going to be empty to the move checker,
|
|
|
|
// we clear it again here. (This method renews toSort for the move
|
|
|
|
// analysis)
|
|
|
|
toSort.ClearAndRetainStorage();
|
2011-10-07 01:23:18 +04:00
|
|
|
}
|
|
|
|
aArray.AppendElement(l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (toSort.Length() > 0) {
|
|
|
|
SortLayersBy3DZOrder(toSort);
|
2015-08-11 18:29:46 +03:00
|
|
|
aArray.AppendElements(Move(toSort));
|
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;
|
|
|
|
} else if (!idealTransform.Is2D() && Creates3DContextWithExtendingChildren()) {
|
2012-02-08 02:27:44 +04:00
|
|
|
useIntermediateSurface = true;
|
|
|
|
} 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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
2016-02-14 03:50:51 +03:00
|
|
|
mUseIntermediateSurface = useIntermediateSurface && !GetLocalVisibleRegion().IsEmpty();
|
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() &&
|
|
|
|
blendMode == gfx::CompositionOp::OP_OVER) {
|
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;
|
|
|
|
}
|
|
|
|
|
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:
|
|
|
|
* - mRecording.mNextIndex increases on each PostPresent, and never resets.
|
|
|
|
* - 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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LayerManager::PostPresent()
|
|
|
|
{
|
2012-10-11 21:54:27 +04:00
|
|
|
if (!mTabSwitchStart.IsNull()) {
|
|
|
|
Telemetry::Accumulate(Telemetry::FX_TAB_SWITCH_TOTAL_MS,
|
|
|
|
uint32_t((TimeStamp::Now() - mTabSwitchStart).ToMilliseconds()));
|
|
|
|
mTabSwitchStart = TimeStamp();
|
|
|
|
}
|
2012-01-06 02:40:35 +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
|
|
|
}
|
|
|
|
|
2012-10-11 21:54:27 +04:00
|
|
|
void
|
|
|
|
LayerManager::BeginTabSwitch()
|
|
|
|
{
|
|
|
|
mTabSwitchStart = TimeStamp::Now();
|
|
|
|
}
|
2011-07-05 06:52:00 +04:00
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
static void PrintInfo(std::stringstream& aStream, LayerComposite* 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) {
|
2013-11-24 02:44:18 +04:00
|
|
|
fprintf_stderr(gfxUtils::sDumpPaintFile, "array[\"%s\"]=\"", string.BeginReading());
|
|
|
|
}
|
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) {
|
2013-11-24 02:44:18 +04:00
|
|
|
fprintf_stderr(gfxUtils::sDumpPaintFile, "\";");
|
|
|
|
}
|
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,
|
|
|
|
bool aDumpHtml, bool aSorted)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2015-09-29 00:06:35 +03:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2015-10-28 16:31:00 +03:00
|
|
|
bool dumpCompositorTexture = gfxEnv::DumpCompositorTextures() && AsLayerComposite() &&
|
2015-09-29 00:06:35 +03:00
|
|
|
AsLayerComposite()->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) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString("<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) {
|
|
|
|
aStream << nsPrintfCString("href=\"javascript:ViewImage('%s')\"", 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
|
|
|
}
|
2014-06-20 02:36:25 +04:00
|
|
|
DumpSelf(aStream, aPrefix);
|
2013-09-12 19:08:50 +04:00
|
|
|
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2015-09-29 00:06:35 +03:00
|
|
|
if (dumpCompositorTexture) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AsLayerComposite()->GetCompositableHost()->Dump(aStream, aPrefix, aDumpHtml);
|
2015-09-29 00:06:35 +03:00
|
|
|
} else if (dumpClientTexture) {
|
|
|
|
if (aDumpHtml) {
|
|
|
|
aStream << nsPrintfCString("<script>array[\"%s\"]=\"", layerId.BeginReading()).get();
|
|
|
|
}
|
|
|
|
AsShadowableLayer()->GetCompositableClient()->Dump(aStream, aPrefix,
|
|
|
|
aDumpHtml, TextureDumpMode::DoNotCompress);
|
|
|
|
if (aDumpHtml) {
|
|
|
|
aStream << "\";</script>";
|
|
|
|
}
|
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()) {
|
|
|
|
AutoTArray<Layer*, 12> children;
|
|
|
|
if (aSorted) {
|
|
|
|
container->SortChildrenBy3DZOrder(children);
|
|
|
|
} else {
|
|
|
|
for (Layer* l = container->GetFirstChild(); l; l = l->GetNextSibling()) {
|
|
|
|
children.AppendElement(l);
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
|
|
|
for (Layer* child : children) {
|
|
|
|
child->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>";
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-06-20 02:36:25 +04:00
|
|
|
Layer::DumpSelf(std::stringstream& aStream, const char* aPrefix)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
PrintInfo(aStream, aPrefix);
|
|
|
|
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);
|
|
|
|
pfx += " \\ MaskLayer ";
|
|
|
|
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
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
layers::PrintInfo(aStream, AsLayerComposite());
|
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
|
|
|
}
|
2012-08-04 01:29:22 +04:00
|
|
|
if (1.0 != mPostXScale || 1.0 != mPostYScale) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString(" [postScale=%g, %g]", mPostXScale, mPostYScale).get();
|
2012-08-04 01:29:22 +04:00
|
|
|
}
|
2010-09-02 13:18:40 +04:00
|
|
|
if (!mTransform.IsIdentity()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mTransform, " [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=", "]");
|
|
|
|
}
|
2015-11-03 01:38:08 +03:00
|
|
|
if (mTransformIsPerspective) {
|
|
|
|
aStream << " [perspective]";
|
|
|
|
}
|
2014-09-16 00:09:52 +04:00
|
|
|
if (!mLayerBounds.IsEmpty()) {
|
|
|
|
AppendToString(aStream, mLayerBounds, " [bounds=", "]");
|
|
|
|
}
|
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
|
|
|
}
|
2010-09-02 13:18:40 +04:00
|
|
|
if (1.0 != mOpacity) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString(" [opacity=%g]", mOpacity).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]";
|
|
|
|
}
|
2016-04-14 23:42:18 +03:00
|
|
|
if (IsScrollbarContainer()) {
|
|
|
|
aStream << " [scrollbar]";
|
|
|
|
}
|
2013-12-12 22:34:50 +04:00
|
|
|
if (GetScrollbarDirection() == VERTICAL) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString(" [vscrollbar=%lld]", GetScrollbarTargetContainerId()).get();
|
2013-12-12 22:34:50 +04:00
|
|
|
}
|
|
|
|
if (GetScrollbarDirection() == HORIZONTAL) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString(" [hscrollbar=%lld]", GetScrollbarTargetContainerId()).get();
|
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();
|
2015-11-13 17:38:57 +03:00
|
|
|
aStream << nsPrintfCString(" [isFixedPosition scrollId=%lld sides=0x%x anchor=%s%s]",
|
2015-08-18 02:44:42 +03:00
|
|
|
GetFixedPositionScrollContainerId(),
|
2015-11-13 17:38:57 +03:00
|
|
|
GetFixedPositionSides(),
|
2015-09-05 00:26:33 +03:00
|
|
|
ToString(anchor).c_str(),
|
|
|
|
IsClipFixed() ? "" : " scrollingClip").get();
|
2011-04-06 09:00:25 +04:00
|
|
|
}
|
2013-09-12 08:17:58 +04:00
|
|
|
if (GetIsStickyPosition()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString(" [isStickyPosition scrollId=%d outer=%f,%f %fx%f "
|
2013-09-12 08:17:58 +04:00
|
|
|
"inner=%f,%f %fx%f]", mStickyPositionData->mScrollId,
|
|
|
|
mStickyPositionData->mOuter.x, mStickyPositionData->mOuter.y,
|
|
|
|
mStickyPositionData->mOuter.width, mStickyPositionData->mOuter.height,
|
|
|
|
mStickyPositionData->mInner.x, mStickyPositionData->mInner.y,
|
2014-06-20 02:36:25 +04:00
|
|
|
mStickyPositionData->mInner.width, mStickyPositionData->mInner.height).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
|
|
|
}
|
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()) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
aLayerRect->set_x(aRect.x);
|
|
|
|
aLayerRect->set_y(aRect.y);
|
|
|
|
aLayerRect->set_w(aRect.width);
|
|
|
|
aLayerRect->set_h(aRect.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
if (LayerComposite* lc = AsLayerComposite()) {
|
|
|
|
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
|
|
|
|
if (!mTransform.IsIdentity()) {
|
|
|
|
DumpTransform(layer->mutable_transform(), mTransform);
|
|
|
|
}
|
|
|
|
// 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
|
|
|
|
layer->set_opacity(mOpacity);
|
|
|
|
// 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
|
|
|
|
if (GetScrollbarDirection() != NONE) {
|
|
|
|
layer->set_direct(GetScrollbarDirection() == VERTICAL ?
|
|
|
|
LayersPacket::Layer::VERTICAL :
|
|
|
|
LayersPacket::Layer::HORIZONTAL);
|
|
|
|
layer->set_barid(GetScrollbarTargetContainerId());
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2015-10-22 23:57:29 +03:00
|
|
|
nsAutoPtr<LayerUserData>
|
|
|
|
Layer::RemoveUserData(void* aKey)
|
|
|
|
{
|
|
|
|
nsAutoPtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
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);
|
2010-10-14 02:55:45 +04:00
|
|
|
if (!mValidRegion.IsEmpty()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mValidRegion, " [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);
|
2014-07-28 00:32:00 +04:00
|
|
|
if (!mValidRegion.IsEmpty()) {
|
|
|
|
DumpRegion(layer->mutable_valid(), mValidRegion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
2015-02-17 05:30:02 +03:00
|
|
|
if (mEventRegionsOverride & EventRegionsOverride::ForceDispatchToContent) {
|
2015-02-11 00:28:07 +03:00
|
|
|
aStream << " [force-dtc]";
|
|
|
|
}
|
2015-02-17 05:30:02 +03:00
|
|
|
if (mEventRegionsOverride & EventRegionsOverride::ForceEmptyHitRegion) {
|
|
|
|
aStream << " [force-ehr]";
|
|
|
|
}
|
2015-09-18 00:23:13 +03:00
|
|
|
if (mVRDeviceID) {
|
2016-01-09 05:50:10 +03:00
|
|
|
aStream << nsPrintfCString(" [hmd=%lu] [hmdframe=%l]", mVRDeviceID, mInputFrameID).get();
|
2014-07-09 23:26:18 +04:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2015-10-12 06:21:02 +03:00
|
|
|
CanvasLayer::CanvasLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: Layer(aManager, aImplData)
|
|
|
|
, mPreTransCallback(nullptr)
|
|
|
|
, mPreTransCallbackData(nullptr)
|
|
|
|
, mPostTransCallback(nullptr)
|
|
|
|
, mPostTransCallbackData(nullptr)
|
|
|
|
, mFilter(gfx::Filter::GOOD)
|
|
|
|
, mDirty(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
CanvasLayer::~CanvasLayer()
|
|
|
|
{}
|
|
|
|
|
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);
|
2015-10-06 03:12:46 +03:00
|
|
|
if (mFilter != Filter::GOOD) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mFilter, " [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
|
2015-10-06 03:18:10 +03:00
|
|
|
DumpFilter(layerscope::LayersPacket::Layer* aLayer, const Filter& aFilter)
|
2014-07-28 00:32:00 +04:00
|
|
|
{
|
|
|
|
using namespace layerscope;
|
|
|
|
switch (aFilter) {
|
2015-10-06 03:12:46 +03:00
|
|
|
case Filter::GOOD:
|
2014-07-28 00:32:00 +04:00
|
|
|
aLayer->set_filter(LayersPacket::Layer::FILTER_GOOD);
|
|
|
|
break;
|
2015-10-06 03:12:46 +03:00
|
|
|
case Filter::LINEAR:
|
|
|
|
aLayer->set_filter(LayersPacket::Layer::FILTER_LINEAR);
|
2014-07-28 00:32:00 +04:00
|
|
|
break;
|
2015-10-06 03:12:46 +03:00
|
|
|
case Filter::POINT:
|
|
|
|
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);
|
|
|
|
DumpFilter(layer, mFilter);
|
|
|
|
}
|
|
|
|
|
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);
|
2015-10-06 03:12:46 +03:00
|
|
|
if (mFilter != Filter::GOOD) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mFilter, " [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);
|
|
|
|
DumpFilter(layer, mFilter);
|
|
|
|
}
|
|
|
|
|
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);
|
2012-08-21 08:06:46 +04:00
|
|
|
if (0 != mId) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mId, " [id=", "]");
|
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);
|
|
|
|
layer->set_refid(mId);
|
|
|
|
}
|
|
|
|
|
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()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString("%s(null)", 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
|
|
|
}
|
2014-06-20 02:36:25 +04:00
|
|
|
GetRoot()->Dump(aStream, pfx.get(), aDumpHtml);
|
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
|
|
|
}
|
|
|
|
|
2016-04-13 17:21:13 +03:00
|
|
|
void
|
|
|
|
LayerManager::SetPendingScrollUpdateForNextTransaction(FrameMetrics::ViewID aScrollId,
|
|
|
|
const ScrollUpdateInfo& aUpdateInfo)
|
|
|
|
{
|
|
|
|
mPendingScrollUpdates[aScrollId] = aUpdateInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
PrintInfo(std::stringstream& aStream, LayerComposite* 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();
|
2014-01-08 01:06:08 +04:00
|
|
|
gfx::Rect transformedBounds = aTarget->GetTransform().TransformBounds(gfx::Rect(Float(bounds.x), Float(bounds.y),
|
|
|
|
Float(bounds.width), Float(bounds.height)));
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
gfxRect r = aRect;
|
|
|
|
r.RoundOut();
|
2015-05-07 12:07:53 +03:00
|
|
|
return IntRect(r.X(), r.Y(), r.Width(), r.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
|