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
|
|
|
|
#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
|
|
|
|
#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
|
2014-08-10 11:06:44 +04:00
|
|
|
#include "mozilla/dom/AnimationPlayer.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
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/layers/AsyncPanZoomController.h"
|
|
|
|
#include "mozilla/layers/Compositor.h" // for Compositor
|
|
|
|
#include "mozilla/layers/CompositorTypes.h"
|
|
|
|
#include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite
|
2013-09-06 19:41:00 +04:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for TransformFunction, etc
|
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"
|
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;
|
|
|
|
const ViewID FrameMetrics::NULL_SCROLL_ID = 0;
|
|
|
|
|
|
|
|
using namespace mozilla::gfx;
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2010-09-08 07:27:29 +04:00
|
|
|
//--------------------------------------------------
|
|
|
|
// LayerManager
|
2012-09-27 00:41:56 +04:00
|
|
|
Layer*
|
|
|
|
LayerManager::GetPrimaryScrollableLayer()
|
|
|
|
{
|
|
|
|
if (!mRoot) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<Layer*> queue;
|
|
|
|
queue.AppendElement(mRoot);
|
|
|
|
while (queue.Length()) {
|
|
|
|
ContainerLayer* containerLayer = queue[0]->AsContainerLayer();
|
|
|
|
queue.RemoveElementAt(0);
|
|
|
|
if (!containerLayer) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const FrameMetrics& frameMetrics = containerLayer->GetFrameMetrics();
|
|
|
|
if (frameMetrics.IsScrollable()) {
|
|
|
|
return containerLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
Layer* child = containerLayer->GetFirstChild();
|
|
|
|
while (child) {
|
|
|
|
queue.AppendElement(child);
|
|
|
|
child = child->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return mRoot;
|
|
|
|
}
|
|
|
|
|
2013-01-10 13:10:20 +04:00
|
|
|
void
|
|
|
|
LayerManager::GetScrollableLayers(nsTArray<Layer*>& aArray)
|
|
|
|
{
|
|
|
|
if (!mRoot) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<Layer*> queue;
|
|
|
|
queue.AppendElement(mRoot);
|
|
|
|
while (!queue.IsEmpty()) {
|
|
|
|
ContainerLayer* containerLayer = queue.LastElement()->AsContainerLayer();
|
|
|
|
queue.RemoveElementAt(queue.Length() - 1);
|
|
|
|
if (!containerLayer) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const FrameMetrics& frameMetrics = containerLayer->GetFrameMetrics();
|
|
|
|
if (frameMetrics.IsScrollable()) {
|
|
|
|
aArray.AppendElement(containerLayer);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Layer* child = containerLayer->GetFirstChild();
|
|
|
|
while (child) {
|
|
|
|
queue.AppendElement(child);
|
|
|
|
child = child->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-10 12:49:49 +04:00
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-04-10 12:49:49 +04:00
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-06-24 21:41:18 +04:00
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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>
|
|
|
|
LayerManager::CreateImageContainer()
|
|
|
|
{
|
2012-07-13 23:38:09 +04:00
|
|
|
nsRefPtr<ImageContainer> container = new ImageContainer(ImageContainer::DISABLE_ASYNC);
|
|
|
|
return container.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<ImageContainer>
|
|
|
|
LayerManager::CreateAsynchronousImageContainer()
|
|
|
|
{
|
|
|
|
nsRefPtr<ImageContainer> container = new ImageContainer(ImageContainer::ENABLE_ASYNC);
|
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();
|
|
|
|
}
|
|
|
|
|
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),
|
|
|
|
mUseClipRect(false),
|
|
|
|
mUseTileSourceRect(false),
|
|
|
|
mIsFixedPosition(false),
|
2013-03-07 14:17:33 +04:00
|
|
|
mMargins(0, 0, 0, 0),
|
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),
|
2012-12-12 01:12:43 +04:00
|
|
|
mDebugColorIndex(0),
|
|
|
|
mAnimationGeneration(0)
|
2012-07-31 21:28:20 +04:00
|
|
|
{}
|
|
|
|
|
|
|
|
Layer::~Layer()
|
|
|
|
{}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
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++) {
|
2012-07-31 21:28:20 +04:00
|
|
|
nsRefPtr<nsCSSValue::Array> arr;
|
|
|
|
switch (aFunctions[i].type()) {
|
|
|
|
case TransformFunction::TRotationX:
|
|
|
|
{
|
|
|
|
float theta = aFunctions[i].get_RotationX().radians();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotatex,
|
|
|
|
resultTail);
|
2012-07-31 21:28:20 +04:00
|
|
|
arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TRotationY:
|
|
|
|
{
|
|
|
|
float theta = aFunctions[i].get_RotationY().radians();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotatey,
|
|
|
|
resultTail);
|
2012-07-31 21:28:20 +04:00
|
|
|
arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TRotationZ:
|
|
|
|
{
|
|
|
|
float theta = aFunctions[i].get_RotationZ().radians();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotatez,
|
|
|
|
resultTail);
|
2012-07-31 21:28:20 +04:00
|
|
|
arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TRotation:
|
|
|
|
{
|
|
|
|
float theta = aFunctions[i].get_Rotation().radians();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotate,
|
|
|
|
resultTail);
|
2012-07-31 21:28:20 +04:00
|
|
|
arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian);
|
|
|
|
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();
|
|
|
|
float theta = aFunctions[i].get_Rotation3D().radians();
|
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);
|
|
|
|
arr->Item(4).SetFloatValue(theta, eCSSUnit_Radian);
|
|
|
|
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:
|
|
|
|
{
|
|
|
|
float x = aFunctions[i].get_SkewX().x();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_skewx,
|
|
|
|
resultTail);
|
2013-05-21 14:22:44 +04:00
|
|
|
arr->Item(1).SetFloatValue(x, eCSSUnit_Radian);
|
2012-07-31 21:28:20 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TSkewY:
|
|
|
|
{
|
|
|
|
float y = aFunctions[i].get_SkewY().y();
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_skewy,
|
|
|
|
resultTail);
|
2013-05-21 14:22:44 +04:00
|
|
|
arr->Item(1).SetFloatValue(y, eCSSUnit_Radian);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TSkew:
|
|
|
|
{
|
2014-06-24 10:29:54 +04:00
|
|
|
arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_skew,
|
|
|
|
resultTail);
|
2013-05-21 14:22:44 +04:00
|
|
|
arr->Item(1).SetFloatValue(aFunctions[i].get_Skew().x(), eCSSUnit_Radian);
|
|
|
|
arr->Item(2).SetFloatValue(aFunctions[i].get_Skew().y(), eCSSUnit_Radian);
|
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();
|
2014-08-10 11:06:44 +04:00
|
|
|
InfallibleTArray<nsAutoPtr<ComputedTimingFunction> >& functions =
|
|
|
|
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();
|
2014-08-10 11:06:44 +04:00
|
|
|
ComputedTimingFunction* ctf = new ComputedTimingFunction();
|
2012-07-31 21:28:20 +04:00
|
|
|
switch (tf.type()) {
|
|
|
|
case TimingFunction::TCubicBezierFunction: {
|
|
|
|
CubicBezierFunction cbf = tf.get_CubicBezierFunction();
|
|
|
|
ctf->Init(nsTimingFunction(cbf.x1(), cbf.y1(), cbf.x2(), cbf.y2()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
NS_ASSERTION(tf.type() == TimingFunction::TStepFunction,
|
|
|
|
"Function must be bezier or step");
|
|
|
|
StepFunction sf = tf.get_StepFunction();
|
|
|
|
nsTimingFunction::Type type = sf.type() == 1 ? nsTimingFunction::StepStart
|
|
|
|
: nsTimingFunction::StepEnd;
|
|
|
|
ctf->Init(nsTimingFunction(type, sf.steps()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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();
|
|
|
|
}
|
|
|
|
|
2013-04-18 01:39:13 +04:00
|
|
|
void
|
2013-07-02 20:01:46 +04:00
|
|
|
ContainerLayer::SetAsyncPanZoomController(AsyncPanZoomController *controller)
|
2013-04-18 01:39:13 +04:00
|
|
|
{
|
2013-07-02 20:01:46 +04:00
|
|
|
mAPZC = controller;
|
2013-04-18 01:39:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
AsyncPanZoomController*
|
2013-07-02 20:27:17 +04:00
|
|
|
ContainerLayer::GetAsyncPanZoomController() const
|
2013-04-18 01:39:13 +04:00
|
|
|
{
|
2013-07-02 20:01:46 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (mAPZC) {
|
|
|
|
MOZ_ASSERT(GetFrameMetrics().IsScrollable());
|
2013-04-18 01:39:13 +04:00
|
|
|
}
|
2013-07-02 20:01:46 +04:00
|
|
|
#endif
|
|
|
|
return mAPZC;
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
const nsIntRect*
|
|
|
|
Layer::GetEffectiveClipRect()
|
|
|
|
{
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsIntRegion&
|
|
|
|
Layer::GetEffectiveVisibleRegion()
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2014-01-27 19:27:20 +04:00
|
|
|
Matrix matrix2D;
|
|
|
|
Matrix4x4 result;
|
2013-06-10 04:13:10 +04:00
|
|
|
if (mManager->IsSnappingEffectiveTransforms() &&
|
2012-12-07 03:58:13 +04:00
|
|
|
aTransform.Is2D(&matrix2D) &&
|
|
|
|
!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
|
|
|
}
|
|
|
|
} else {
|
|
|
|
result = aTransform;
|
|
|
|
}
|
|
|
|
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) &&
|
2013-12-13 21:31:53 +04:00
|
|
|
gfx::Size(1.0, 1.0) <= ToSize(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);
|
|
|
|
}
|
|
|
|
|
2012-07-31 21:28:20 +04:00
|
|
|
nsIntRect
|
2011-05-23 04:27:03 +04:00
|
|
|
Layer::CalculateScissorRect(const nsIntRect& aCurrentScissorRect,
|
2014-01-16 11:22:19 +04:00
|
|
|
const gfx::Matrix* aWorldTransform)
|
2011-02-25 10:44:22 +03:00
|
|
|
{
|
2011-05-23 04:27:03 +04:00
|
|
|
ContainerLayer* container = GetParent();
|
|
|
|
NS_ASSERTION(container, "This can't be called on the root!");
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
nsIntRect currentClip;
|
|
|
|
if (container->UseIntermediateSurface()) {
|
|
|
|
currentClip.SizeTo(container->GetIntermediateSurfaceRect().Size());
|
|
|
|
} else {
|
|
|
|
currentClip = aCurrentScissorRect;
|
|
|
|
}
|
2011-02-25 10:44:22 +03:00
|
|
|
|
|
|
|
const nsIntRect *clipRect = GetEffectiveClipRect();
|
2011-05-23 04:27:03 +04:00
|
|
|
if (!clipRect)
|
|
|
|
return currentClip;
|
2011-02-25 10:44:22 +03:00
|
|
|
|
2011-05-23 04:27:03 +04:00
|
|
|
if (clipRect->IsEmpty()) {
|
|
|
|
// We might have a non-translation transform in the container so we can't
|
|
|
|
// use the code path below.
|
|
|
|
return nsIntRect(currentClip.TopLeft(), nsIntSize(0, 0));
|
2011-02-25 10:44:22 +03:00
|
|
|
}
|
|
|
|
|
2011-05-23 04:27:03 +04:00
|
|
|
nsIntRect scissor = *clipRect;
|
|
|
|
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();
|
|
|
|
if (!gfxUtils::GfxRectToIntRect(trScissor, &scissor)) {
|
|
|
|
return nsIntRect(currentClip.TopLeft(), nsIntSize(0, 0));
|
|
|
|
}
|
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
|
|
|
}
|
2011-05-23 04:27:03 +04:00
|
|
|
if (container) {
|
|
|
|
scissor.MoveBy(-container->GetIntermediateSurfaceRect().TopLeft());
|
|
|
|
} else if (aWorldTransform) {
|
2014-01-16 11:22:19 +04:00
|
|
|
gfx::Rect r(scissor.x, scissor.y, scissor.width, scissor.height);
|
|
|
|
gfx::Rect trScissor = aWorldTransform->TransformBounds(r);
|
2011-05-23 04:27:03 +04:00
|
|
|
trScissor.Round();
|
2014-01-16 11:22:19 +04:00
|
|
|
if (!gfxUtils::GfxRectToIntRect(ThebesRect(trScissor), &scissor))
|
2011-05-23 04:27:03 +04:00
|
|
|
return nsIntRect(currentClip.TopLeft(), nsIntSize(0, 0));
|
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
|
|
|
}
|
|
|
|
|
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;
|
2013-07-02 20:27:17 +04:00
|
|
|
if (const ContainerLayer* c = AsContainerLayer()) {
|
2012-08-04 01:29:22 +04:00
|
|
|
transform.Scale(c->GetPreXScale(), c->GetPreYScale(), 1.0f);
|
|
|
|
}
|
2014-01-27 19:28:47 +04:00
|
|
|
transform = transform * Matrix4x4().Scale(mPostXScale, mPostYScale, 1.0f);
|
2012-07-31 06:20:00 +04:00
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2014-01-27 19:29:27 +04:00
|
|
|
Matrix4x4 transform;
|
2013-04-26 02:25:33 +04:00
|
|
|
if (LayerComposite* shadow = AsLayerComposite())
|
2012-07-31 06:20:00 +04:00
|
|
|
transform = shadow->GetShadowTransform();
|
|
|
|
else
|
2014-01-27 19:29:27 +04:00
|
|
|
transform = mTransform;
|
2012-08-04 01:29:22 +04:00
|
|
|
if (ContainerLayer* c = AsContainerLayer()) {
|
|
|
|
transform.Scale(c->GetPreXScale(), c->GetPreYScale(), 1.0f);
|
|
|
|
}
|
2014-01-27 19:29:27 +04:00
|
|
|
transform = transform * Matrix4x4().Scale(mPostXScale, mPostYScale, 1.0f);
|
2014-01-27 19:28:18 +04:00
|
|
|
|
2014-01-27 19:29:27 +04:00
|
|
|
return transform;
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
2012-10-03 09:55:50 +04:00
|
|
|
}
|
|
|
|
|
2012-07-31 21:28:20 +04:00
|
|
|
const float
|
|
|
|
Layer::GetLocalOpacity()
|
|
|
|
{
|
2013-04-26 02:25:33 +04:00
|
|
|
if (LayerComposite* shadow = AsLayerComposite())
|
2012-07-31 21:28:20 +04:00
|
|
|
return shadow->GetShadowOpacity();
|
|
|
|
return mOpacity;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2013-09-15 07:23:46 +04: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
|
|
|
|
2014-02-12 19:07:46 +04:00
|
|
|
gfxContext::GraphicsOperator
|
|
|
|
Layer::DeprecatedGetEffectiveMixBlendMode()
|
|
|
|
{
|
|
|
|
return ThebesOp(GetEffectiveMixBlendMode());
|
|
|
|
}
|
|
|
|
|
2012-02-08 02:27:44 +04:00
|
|
|
void
|
2014-01-27 19:28:04 +04:00
|
|
|
Layer::ComputeEffectiveTransformForMaskLayer(const Matrix4x4& aTransformToSurface)
|
2012-02-08 02:27:44 +04:00
|
|
|
{
|
|
|
|
if (mMaskLayer) {
|
2014-01-27 19:28:04 +04:00
|
|
|
mMaskLayer->mEffectiveTransform = aTransformToSurface;
|
2012-07-25 12:48:09 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2014-01-27 19:28:47 +04:00
|
|
|
bool maskIs2D = mMaskLayer->GetTransform().CanDraw2D();
|
2012-07-25 12:48:09 +04:00
|
|
|
NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!");
|
|
|
|
#endif
|
2014-01-27 19:28:47 +04:00
|
|
|
mMaskLayer->mEffectiveTransform = mMaskLayer->GetTransform() * mMaskLayer->mEffectiveTransform;
|
2012-02-08 02:27:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-02 20:01:46 +04:00
|
|
|
ContainerLayer::ContainerLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: Layer(aManager, aImplData),
|
|
|
|
mFirstChild(nullptr),
|
|
|
|
mLastChild(nullptr),
|
2014-04-12 03:39:21 +04:00
|
|
|
mScrollHandoffParentId(FrameMetrics::NULL_SCROLL_ID),
|
2013-07-02 20:01:46 +04:00
|
|
|
mPreXScale(1.0f),
|
|
|
|
mPreYScale(1.0f),
|
|
|
|
mInheritedXScale(1.0f),
|
|
|
|
mInheritedYScale(1.0f),
|
2014-06-07 00:50:20 +04:00
|
|
|
mBackgroundColor(0, 0, 0, 0),
|
2013-07-02 20:01:46 +04:00
|
|
|
mUseIntermediateSurface(false),
|
|
|
|
mSupportsComponentAlphaChildren(false),
|
|
|
|
mMayHaveReadbackChild(false)
|
|
|
|
{
|
|
|
|
mContentFlags = 0; // Clear NO_TEXT, NO_TEXT_OVER_TRANSPARENT
|
|
|
|
}
|
|
|
|
|
|
|
|
ContainerLayer::~ContainerLayer() {}
|
|
|
|
|
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-04-12 03:39:21 +04:00
|
|
|
aAttrs = ContainerLayerAttributes(GetFrameMetrics(), mScrollHandoffParentId,
|
|
|
|
mPreXScale, mPreYScale,
|
2014-06-07 00:50:20 +04:00
|
|
|
mInheritedXScale, mInheritedYScale,
|
2014-08-01 00:11:47 +04:00
|
|
|
mBackgroundColor, mContentDescription);
|
2011-08-09 23:38:26 +04:00
|
|
|
}
|
|
|
|
|
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()) {
|
|
|
|
const nsIntRect *clipRect = child->GetEffectiveClipRect();
|
|
|
|
if (clipRect && clipRect->IsEmpty())
|
|
|
|
continue;
|
|
|
|
if (child->GetVisibleRegion().IsEmpty())
|
|
|
|
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
|
|
|
|
2011-10-07 01:23:18 +04:00
|
|
|
void
|
|
|
|
ContainerLayer::SortChildrenBy3DZOrder(nsTArray<Layer*>& aArray)
|
|
|
|
{
|
|
|
|
nsAutoTArray<Layer*, 10> toSort;
|
|
|
|
|
|
|
|
for (Layer* l = GetFirstChild(); l; l = l->GetNextSibling()) {
|
|
|
|
ContainerLayer* container = l->AsContainerLayer();
|
|
|
|
if (container && container->GetContentFlags() & CONTENT_PRESERVE_3D) {
|
|
|
|
toSort.AppendElement(l);
|
|
|
|
} else {
|
|
|
|
if (toSort.Length() > 0) {
|
|
|
|
SortLayersBy3DZOrder(toSort);
|
|
|
|
aArray.MoveElementsFrom(toSort);
|
|
|
|
}
|
|
|
|
aArray.AppendElement(l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (toSort.Length() > 0) {
|
|
|
|
SortLayersBy3DZOrder(toSort);
|
|
|
|
aArray.MoveElementsFrom(toSort);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2011-10-07 01:29:07 +04:00
|
|
|
idealTransform.ProjectTo2D();
|
2014-01-27 19:28:18 +04:00
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform, &residual);
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool useIntermediateSurface;
|
2014-05-09 13:41:56 +04:00
|
|
|
if (GetMaskLayer() ||
|
|
|
|
GetForceIsolatedGroup()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
useIntermediateSurface = true;
|
2012-03-01 12:26:09 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
} else if (gfxUtils::sDumpPainting) {
|
|
|
|
useIntermediateSurface = true;
|
|
|
|
#endif
|
2010-11-08 12:06:15 +03:00
|
|
|
} else {
|
2012-02-08 02:27:44 +04:00
|
|
|
float opacity = GetEffectiveOpacity();
|
2014-05-09 13:41:56 +04:00
|
|
|
CompositionOp blendMode = GetEffectiveMixBlendMode();
|
|
|
|
if ((opacity != 1.0f || blendMode != CompositionOp::OP_OVER) && HasMultipleChildren()) {
|
2012-02-08 02:27:44 +04:00
|
|
|
useIntermediateSurface = true;
|
|
|
|
} else {
|
|
|
|
useIntermediateSurface = false;
|
2014-01-28 00:25:19 +04:00
|
|
|
gfx::Matrix contTransform;
|
|
|
|
if (!mEffectiveTransform.Is2D(&contTransform) ||
|
2011-06-16 14:51:05 +04:00
|
|
|
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
|
|
|
!contTransform.PreservesAxisAlignedRectangles()) {
|
|
|
|
#else
|
2014-01-28 00:25:19 +04:00
|
|
|
gfx::ThebesMatrix(contTransform).HasNonIntegerTranslation()) {
|
2011-06-16 14:51:05 +04:00
|
|
|
#endif
|
2012-02-08 02:27:44 +04:00
|
|
|
for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) {
|
|
|
|
const nsIntRect *clipRect = child->GetEffectiveClipRect();
|
|
|
|
/* 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
|
|
|
*/
|
2012-06-27 00:06:32 +04:00
|
|
|
if ((clipRect && !clipRect->IsEmpty() && !child->GetVisibleRegion().IsEmpty()) ||
|
|
|
|
child->GetMaskLayer()) {
|
2012-02-08 02:27:44 +04:00
|
|
|
useIntermediateSurface = true;
|
|
|
|
break;
|
|
|
|
}
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-04 15:02:14 +04:00
|
|
|
mUseIntermediateSurface = useIntermediateSurface && !GetEffectiveVisibleRegion().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
|
|
|
|
|
|
|
if (idealTransform.CanDraw2D()) {
|
|
|
|
ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
|
|
|
|
} else {
|
2014-01-27 19:28:04 +04:00
|
|
|
ComputeEffectiveTransformForMaskLayer(Matrix4x4());
|
2012-02-08 02:27:44 +04:00
|
|
|
}
|
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()) {
|
|
|
|
if (GetEffectiveVisibleRegion().GetNumRects() == 1 &&
|
|
|
|
(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)
|
|
|
|
{
|
|
|
|
ThebesLayer* tl = aLayer->AsThebesLayer();
|
|
|
|
if (tl && tl->UsedForReadback()) {
|
|
|
|
for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) {
|
|
|
|
if (l->GetType() == TYPE_READBACK) {
|
|
|
|
static_cast<ReadbackLayer*>(l)->NotifyThebesLayerRemoved(tl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
aAttrs = RefLayerAttributes(GetReferentId());
|
|
|
|
}
|
|
|
|
|
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-06-20 02:36:25 +04:00
|
|
|
void WriteSnapshotLinkToDumpFile(T* aObj, std::stringstream& aStream)
|
2012-03-01 12:26:09 +04:00
|
|
|
{
|
2013-05-26 06:44:24 +04:00
|
|
|
if (!aObj) {
|
|
|
|
return;
|
|
|
|
}
|
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);
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString("href=\"javascript:ViewImage('%s')\"", string.BeginReading()).get();
|
2012-03-01 12:26:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2013-11-24 02:44:18 +04:00
|
|
|
if (gfxUtils::sDumpPaintFile) {
|
|
|
|
fprintf_stderr(gfxUtils::sDumpPaintFile, "array[\"%s\"]=\"", string.BeginReading());
|
|
|
|
}
|
2014-06-27 15:19:40 +04:00
|
|
|
gfxUtils::DumpAsDataURI(aSurf, gfxUtils::sDumpPaintFile);
|
2013-11-24 02:44:18 +04:00
|
|
|
if (gfxUtils::sDumpPaintFile) {
|
|
|
|
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
|
|
|
{
|
2014-01-08 12:43:46 +04:00
|
|
|
RefPtr<SourceSurface> surf = aTarget->Snapshot();
|
|
|
|
RefPtr<DataSourceSurface> dSurf = surf->GetDataSurface();
|
|
|
|
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
|
2014-06-20 02:36:25 +04:00
|
|
|
Layer::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml)
|
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 << nsPrintfCString("<li><a id=\"%p\" ", this).get();
|
2012-03-01 12:26:09 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2012-08-07 21:57:26 +04:00
|
|
|
if (GetType() == TYPE_CONTAINER || GetType() == TYPE_THEBES) {
|
2014-06-20 02:36:25 +04:00
|
|
|
WriteSnapshotLinkToDumpFile(this, aStream);
|
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
|
2014-05-24 01:06:24 +04:00
|
|
|
if (gfxUtils::sDumpPainting && AsLayerComposite() && AsLayerComposite()->GetCompositableHost()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AsLayerComposite()->GetCompositableHost()->Dump(aStream, aPrefix, aDumpHtml);
|
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>";
|
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
|
|
|
}
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
if (Layer* kid = GetFirstChild()) {
|
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
|
|
|
}
|
2014-06-20 02:36:25 +04:00
|
|
|
kid->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>";
|
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
|
|
|
if (Layer* next = GetNextSibling())
|
2014-06-20 02:36:25 +04:00
|
|
|
next->Dump(aStream, aPrefix, aDumpHtml);
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2010-08-02 07:06:58 +04:00
|
|
|
if (mUseClipRect) {
|
2014-06-20 02:36:25 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
if (!mVisibleRegion.IsEmpty()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mVisibleRegion, " [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
|
|
|
}
|
2013-12-16 14:47:06 +04:00
|
|
|
if (!mEventRegions.mHitRegion.IsEmpty()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mEventRegions.mHitRegion, " [hitregion=", "]");
|
2013-12-16 14:47:06 +04:00
|
|
|
}
|
|
|
|
if (!mEventRegions.mDispatchToContentHitRegion.IsEmpty()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mEventRegions.mDispatchToContentHitRegion, " [dispatchtocontentregion=", "]");
|
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
|
|
|
}
|
|
|
|
if (GetContentFlags() & CONTENT_OPAQUE) {
|
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
|
|
|
}
|
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()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString(" [isFixedPosition anchor=%f,%f margin=%f,%f,%f,%f]", mAnchor.x, mAnchor.y,
|
|
|
|
mMargins.top, mMargins.right, mMargins.bottom, mMargins.left).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
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The static helper function sets the nsIntRect into the packet
|
|
|
|
static void
|
|
|
|
DumpRect(layerscope::LayersPacket::Layer::Rect* aLayerRect, const nsIntRect& aRect)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
nsIntRegionRectIterator it(aRegion);
|
|
|
|
while (const nsIntRect* sr = it.Next()) {
|
|
|
|
DumpRect(aLayerRegion->add_r(), *sr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
if (const nsIntRect* clipRect = lc->GetShadowClipRect()) {
|
|
|
|
DumpRect(s->mutable_clip(), *clipRect);
|
|
|
|
}
|
|
|
|
if (!lc->GetShadowTransform().IsIdentity()) {
|
|
|
|
DumpTransform(s->mutable_transform(), lc->GetShadowTransform());
|
|
|
|
}
|
|
|
|
if (!lc->GetShadowVisibleRegion().IsEmpty()) {
|
|
|
|
DumpRegion(s->mutable_vregion(), lc->GetShadowVisibleRegion());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Clip
|
|
|
|
if (mUseClipRect) {
|
|
|
|
DumpRect(layer->mutable_clip(), mClipRect);
|
|
|
|
}
|
|
|
|
// Transform
|
|
|
|
if (!mTransform.IsIdentity()) {
|
|
|
|
DumpTransform(layer->mutable_transform(), mTransform);
|
|
|
|
}
|
|
|
|
// Visible region
|
|
|
|
if (!mVisibleRegion.IsEmpty()) {
|
|
|
|
DumpRegion(layer->mutable_vregion(), mVisibleRegion);
|
|
|
|
}
|
|
|
|
// 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());
|
|
|
|
}
|
|
|
|
// Mask layer
|
|
|
|
if (mMaskLayer) {
|
|
|
|
layer->set_mask(reinterpret_cast<uint64_t>(mMaskLayer.get()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
void
|
|
|
|
ThebesLayer::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
|
|
|
|
ThebesLayer::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::ThebesLayer);
|
|
|
|
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 (!mFrameMetrics.IsDefault()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mFrameMetrics, " [metrics=", "]");
|
2011-01-08 08:05:35 +03:00
|
|
|
}
|
2014-04-12 03:39:21 +04:00
|
|
|
if (mScrollHandoffParentId != FrameMetrics::NULL_SCROLL_ID) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << nsPrintfCString(" [scrollParent=%llu]", mScrollHandoffParentId).get();
|
2014-04-12 03:39:21 +04:00
|
|
|
}
|
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
|
|
|
}
|
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=", "]");
|
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);
|
|
|
|
layer->set_color(mColor.Packed());
|
|
|
|
}
|
|
|
|
|
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);
|
2013-10-02 01:01:19 +04:00
|
|
|
if (mFilter != GraphicsFilter::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
|
|
|
|
DumpFilter(layerscope::LayersPacket::Layer* aLayer, const GraphicsFilter& aFilter)
|
|
|
|
{
|
|
|
|
using namespace layerscope;
|
|
|
|
switch (aFilter) {
|
|
|
|
case GraphicsFilter::FILTER_FAST:
|
|
|
|
aLayer->set_filter(LayersPacket::Layer::FILTER_FAST);
|
|
|
|
break;
|
|
|
|
case GraphicsFilter::FILTER_GOOD:
|
|
|
|
aLayer->set_filter(LayersPacket::Layer::FILTER_GOOD);
|
|
|
|
break;
|
|
|
|
case GraphicsFilter::FILTER_BEST:
|
|
|
|
aLayer->set_filter(LayersPacket::Layer::FILTER_BEST);
|
|
|
|
break;
|
|
|
|
case GraphicsFilter::FILTER_NEAREST:
|
|
|
|
aLayer->set_filter(LayersPacket::Layer::FILTER_NEAREST);
|
|
|
|
break;
|
|
|
|
case GraphicsFilter::FILTER_BILINEAR:
|
|
|
|
aLayer->set_filter(LayersPacket::Layer::FILTER_BILINEAR);
|
|
|
|
break;
|
|
|
|
case GraphicsFilter::FILTER_GAUSSIAN:
|
|
|
|
aLayer->set_filter(LayersPacket::Layer::FILTER_GAUSSIAN);
|
|
|
|
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);
|
2013-10-02 01:01:19 +04:00
|
|
|
if (mFilter != GraphicsFilter::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=", "]");
|
2011-02-17 01:43:30 +03:00
|
|
|
} else if (mBackgroundColor.a == 1.0) {
|
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
|
2014-06-20 02:36:25 +04:00
|
|
|
LayerManager::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml)
|
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) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "<ul><li><a ";
|
|
|
|
WriteSnapshotLinkToDumpFile(this, aStream);
|
|
|
|
aStream << ">";
|
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
|
|
|
DumpSelf(aStream, aPrefix);
|
2012-03-01 12:26:09 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2012-08-07 21:57:26 +04:00
|
|
|
if (aDumpHtml) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "</a>";
|
2012-08-07 21:57:26 +04:00
|
|
|
}
|
2012-03-01 12:26:09 +04:00
|
|
|
#endif
|
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
|
2014-06-20 02:36:25 +04:00
|
|
|
LayerManager::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-08-02 14:03:00 +04:00
|
|
|
void
|
|
|
|
LayerManager::Dump()
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
Dump(ss);
|
|
|
|
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*/ void
|
|
|
|
LayerManager::InitLog()
|
|
|
|
{
|
|
|
|
if (!sLog)
|
|
|
|
sLog = PR_NewLogModule("Layers");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ bool
|
|
|
|
LayerManager::IsLogEnabled()
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(!!sLog,
|
|
|
|
"layer manager must be created before logging is allowed");
|
|
|
|
return PR_LOG_TEST(sLog, PR_LOG_DEBUG);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2013-04-26 02:25:33 +04:00
|
|
|
if (const nsIntRect* clipRect = aLayerComposite->GetShadowClipRect()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, *clipRect, " [shadow-clip=", "]");
|
2010-10-14 02:55:45 +04:00
|
|
|
}
|
2013-04-26 02:25:33 +04:00
|
|
|
if (!aLayerComposite->GetShadowTransform().IsIdentity()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, aLayerComposite->GetShadowTransform(), " [shadow-transform=", "]");
|
2010-10-14 02:55:45 +04:00
|
|
|
}
|
2013-04-26 02:25:33 +04:00
|
|
|
if (!aLayerComposite->GetShadowVisibleRegion().IsEmpty()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, aLayerComposite->GetShadowVisibleRegion(), " [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);
|
2014-01-10 23:06:16 +04:00
|
|
|
if (aTarget->GetFormat() != SurfaceFormat::B8G8R8A8) {
|
2014-01-08 01:06:08 +04:00
|
|
|
aTarget->SetPermitSubpixelAA(permitSubpixelAA);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
PRLogModuleInfo* LayerManager::sLog;
|
|
|
|
|
2012-07-31 21:28:20 +04:00
|
|
|
} // namespace layers
|
2010-07-21 22:06:33 +04:00
|
|
|
} // namespace mozilla
|