2010-07-21 11:06:33 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 04:12:37 -07: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 11:06:33 -07:00
|
|
|
|
2010-09-03 13:10:45 -07:00
|
|
|
#include "Layers.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include <algorithm> // for max, min
|
|
|
|
#include "AnimationCommon.h" // for ComputedTimingFunction
|
|
|
|
#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
|
|
|
|
#include "gfxUtils.h" // for gfxUtils, etc
|
2013-12-13 09:31:53 -08:00
|
|
|
#include "gfx2DGlue.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/DebugOnly.h" // for DebugOnly
|
|
|
|
#include "mozilla/Telemetry.h" // for Accumulate
|
|
|
|
#include "mozilla/gfx/2D.h" // for DrawTarget
|
|
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
2014-01-24 17:49:19 -08:00
|
|
|
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
2013-08-11 16:17:23 -07: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 08:41:00 -07:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for TransformFunction, etc
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "nsAString.h"
|
|
|
|
#include "nsCSSValue.h" // for nsCSSValue::Array, etc
|
|
|
|
#include "nsPrintfCString.h" // for nsPrintfCString
|
|
|
|
#include "nsStyleStruct.h" // for nsTimingFunction, etc
|
2014-05-09 03:06:20 -07:00
|
|
|
#include "gfxPrefs.h"
|
2010-09-03 13:10:45 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t gLayerManagerLayerBuilder;
|
2012-08-20 21:06:46 -07:00
|
|
|
|
2014-05-22 03:11:45 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2010-07-21 11:06:33 -07:00
|
|
|
FILE*
|
|
|
|
FILEOrDefault(FILE* aFile)
|
|
|
|
{
|
|
|
|
return aFile ? aFile : stderr;
|
|
|
|
}
|
|
|
|
|
2014-05-22 03:11:45 -07:00
|
|
|
typedef FrameMetrics::ViewID ViewID;
|
|
|
|
const ViewID FrameMetrics::NULL_SCROLL_ID = 0;
|
|
|
|
|
|
|
|
using namespace mozilla::gfx;
|
2010-07-21 11:06:33 -07:00
|
|
|
|
2010-09-07 20:27:29 -07:00
|
|
|
//--------------------------------------------------
|
|
|
|
// LayerManager
|
2012-09-26 13:41:56 -07: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 01:10:20 -08: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 01:49:49 -07:00
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
LayerManager::CreateOptimalDrawTarget(const gfx::IntSize &aSize,
|
|
|
|
SurfaceFormat aFormat)
|
2010-09-07 20:27:29 -07:00
|
|
|
{
|
2014-04-10 01:49:49 -07:00
|
|
|
return gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(aSize,
|
|
|
|
aFormat);
|
2010-09-07 20:27:29 -07:00
|
|
|
}
|
|
|
|
|
2014-04-10 01:49:49 -07:00
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
LayerManager::CreateOptimalMaskDrawTarget(const gfx::IntSize &aSize)
|
2012-06-25 19:43:31 -07:00
|
|
|
{
|
2014-04-10 01:49:49 -07:00
|
|
|
return CreateOptimalDrawTarget(aSize, SurfaceFormat::A8);
|
2012-06-25 19:43:31 -07:00
|
|
|
}
|
|
|
|
|
2011-06-24 10:41:18 -07:00
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
LayerManager::CreateDrawTarget(const IntSize &aSize,
|
|
|
|
SurfaceFormat aFormat)
|
|
|
|
{
|
2011-11-02 12:55:03 -07:00
|
|
|
return gfxPlatform::GetPlatform()->
|
2013-08-22 23:13:55 -07:00
|
|
|
CreateOffscreenCanvasDrawTarget(aSize, aFormat);
|
2011-06-24 10:41:18 -07:00
|
|
|
}
|
|
|
|
|
2011-01-25 22:26:37 -08:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
LayerManager::Mutated(Layer* aLayer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2012-01-31 18:18:30 -08:00
|
|
|
already_AddRefed<ImageContainer>
|
|
|
|
LayerManager::CreateImageContainer()
|
|
|
|
{
|
2012-07-13 12:38:09 -07: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-01-31 18:18:30 -08:00
|
|
|
return container.forget();
|
|
|
|
}
|
|
|
|
|
2010-07-21 11:06:33 -07:00
|
|
|
//--------------------------------------------------
|
|
|
|
// Layer
|
2010-07-21 11:06:33 -07:00
|
|
|
|
2012-07-31 10:28:20 -07:00
|
|
|
Layer::Layer(LayerManager* aManager, void* aImplData) :
|
|
|
|
mManager(aManager),
|
|
|
|
mParent(nullptr),
|
|
|
|
mNextSibling(nullptr),
|
|
|
|
mPrevSibling(nullptr),
|
|
|
|
mImplData(aImplData),
|
|
|
|
mMaskLayer(nullptr),
|
2012-08-03 14:29:22 -07:00
|
|
|
mPostXScale(1.0f),
|
|
|
|
mPostYScale(1.0f),
|
2012-07-31 10:28:20 -07:00
|
|
|
mOpacity(1.0),
|
2014-02-12 07:07:46 -08:00
|
|
|
mMixBlendMode(CompositionOp::OP_OVER),
|
2013-09-14 20:30:00 -07:00
|
|
|
mForceIsolatedGroup(false),
|
2012-07-31 10:28:20 -07:00
|
|
|
mContentFlags(0),
|
|
|
|
mUseClipRect(false),
|
|
|
|
mUseTileSourceRect(false),
|
|
|
|
mIsFixedPosition(false),
|
2013-03-07 02:17:33 -08:00
|
|
|
mMargins(0, 0, 0, 0),
|
2013-09-11 21:17:58 -07:00
|
|
|
mStickyPositionData(nullptr),
|
2013-12-12 10:34:50 -08:00
|
|
|
mScrollbarTargetId(FrameMetrics::NULL_SCROLL_ID),
|
|
|
|
mScrollbarDirection(ScrollDirection::NONE),
|
2012-12-11 13:12:43 -08:00
|
|
|
mDebugColorIndex(0),
|
|
|
|
mAnimationGeneration(0)
|
2012-07-31 10:28:20 -07:00
|
|
|
{}
|
|
|
|
|
|
|
|
Layer::~Layer()
|
|
|
|
{}
|
|
|
|
|
2012-08-20 06:35:42 -07:00
|
|
|
Animation*
|
2014-03-04 20:13:21 -08:00
|
|
|
Layer::AddAnimation()
|
2012-07-31 10:28:20 -07:00
|
|
|
{
|
2013-03-21 19:17:28 -07:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) AddAnimation", this));
|
|
|
|
|
2014-03-04 20:13:21 -08:00
|
|
|
MOZ_ASSERT(!mPendingAnimations, "should have called ClearAnimations first");
|
|
|
|
|
2012-08-20 06:35:42 -07:00
|
|
|
Animation* anim = mAnimations.AppendElement();
|
2012-07-31 10:28:20 -07:00
|
|
|
|
|
|
|
Mutated();
|
2012-08-20 06:35:42 -07:00
|
|
|
return anim;
|
2012-07-31 10:28:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Layer::ClearAnimations()
|
|
|
|
{
|
2014-03-04 20:13:21 -08:00
|
|
|
mPendingAnimations = nullptr;
|
|
|
|
|
2013-03-21 19:17:28 -07:00
|
|
|
if (mAnimations.IsEmpty() && mAnimationData.IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClearAnimations", this));
|
2012-07-31 10:28:20 -07:00
|
|
|
mAnimations.Clear();
|
|
|
|
mAnimationData.Clear();
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2014-03-04 20:13:21 -08: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-11 18:09:44 -08:00
|
|
|
static nsCSSValueSharedList*
|
2012-07-31 10:28:20 -07:00
|
|
|
CreateCSSValueList(const InfallibleTArray<TransformFunction>& aFunctions)
|
|
|
|
{
|
|
|
|
nsAutoPtr<nsCSSValueList> result;
|
|
|
|
nsCSSValueList** resultTail = getter_Transfers(result);
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < aFunctions.Length(); i++) {
|
2012-07-31 10:28:20 -07:00
|
|
|
nsRefPtr<nsCSSValue::Array> arr;
|
|
|
|
switch (aFunctions[i].type()) {
|
|
|
|
case TransformFunction::TRotationX:
|
|
|
|
{
|
|
|
|
float theta = aFunctions[i].get_RotationX().radians();
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_rotatex, resultTail);
|
|
|
|
arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TRotationY:
|
|
|
|
{
|
|
|
|
float theta = aFunctions[i].get_RotationY().radians();
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_rotatey, resultTail);
|
|
|
|
arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TRotationZ:
|
|
|
|
{
|
|
|
|
float theta = aFunctions[i].get_RotationZ().radians();
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_rotatez, resultTail);
|
|
|
|
arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TRotation:
|
|
|
|
{
|
|
|
|
float theta = aFunctions[i].get_Rotation().radians();
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_rotate, resultTail);
|
|
|
|
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();
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_rotate3d, resultTail);
|
|
|
|
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:
|
|
|
|
{
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_scale3d, resultTail);
|
|
|
|
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:
|
|
|
|
{
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_translate3d, resultTail);
|
|
|
|
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();
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_skewx, resultTail);
|
2013-05-21 03:22:44 -07:00
|
|
|
arr->Item(1).SetFloatValue(x, eCSSUnit_Radian);
|
2012-07-31 10:28:20 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TSkewY:
|
|
|
|
{
|
|
|
|
float y = aFunctions[i].get_SkewY().y();
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_skewy, resultTail);
|
2013-05-21 03:22:44 -07:00
|
|
|
arr->Item(1).SetFloatValue(y, eCSSUnit_Radian);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TSkew:
|
|
|
|
{
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_skew, resultTail);
|
|
|
|
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 10:28:20 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransformFunction::TTransformMatrix:
|
|
|
|
{
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_matrix3d, resultTail);
|
2014-01-27 07:28:33 -08:00
|
|
|
const gfx::Matrix4x4& matrix = aFunctions[i].get_TransformMatrix().value();
|
2012-07-31 10:28:20 -07: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();
|
|
|
|
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_perspective, resultTail);
|
|
|
|
arr->Item(1).SetFloatValue(perspective, eCSSUnit_Pixel);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_ASSERTION(false, "All functions should be implemented?");
|
|
|
|
}
|
|
|
|
}
|
2012-08-20 21:06:47 -07:00
|
|
|
if (aFunctions.Length() == 0) {
|
|
|
|
result = new nsCSSValueList();
|
|
|
|
result->mValue.SetNoneValue();
|
|
|
|
}
|
2013-12-11 18:09:44 -08:00
|
|
|
return new nsCSSValueSharedList(result.forget());
|
2012-07-31 10:28:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Layer::SetAnimations(const AnimationArray& aAnimations)
|
|
|
|
{
|
2013-03-21 19:17:28 -07:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) SetAnimations", this));
|
|
|
|
|
2012-07-31 10:28:20 -07:00
|
|
|
mAnimations = aAnimations;
|
|
|
|
mAnimationData.Clear();
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < mAnimations.Length(); i++) {
|
2012-08-20 21:06:47 -07:00
|
|
|
AnimData* data = mAnimationData.AppendElement();
|
2013-04-08 11:31:10 -07:00
|
|
|
InfallibleTArray<nsAutoPtr<css::ComputedTimingFunction> >& functions = data->mFunctions;
|
2012-11-29 08:14:13 -08:00
|
|
|
const InfallibleTArray<AnimationSegment>& segments =
|
|
|
|
mAnimations.ElementAt(i).segments();
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t j = 0; j < segments.Length(); j++) {
|
2012-07-31 10:28:20 -07:00
|
|
|
TimingFunction tf = segments.ElementAt(j).sampleFn();
|
|
|
|
css::ComputedTimingFunction* ctf = new css::ComputedTimingFunction();
|
|
|
|
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-20 21:06:47 -07:00
|
|
|
functions.AppendElement(ctf);
|
2012-07-31 10:28:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Precompute the nsStyleAnimation::Values that we need if this is a transform
|
|
|
|
// animation.
|
2012-08-20 21:06:47 -07:00
|
|
|
InfallibleTArray<nsStyleAnimation::Value>& startValues = data->mStartValues;
|
|
|
|
InfallibleTArray<nsStyleAnimation::Value>& endValues = data->mEndValues;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t j = 0; j < mAnimations[i].segments().Length(); j++) {
|
2012-07-31 10:28:20 -07:00
|
|
|
const AnimationSegment& segment = mAnimations[i].segments()[j];
|
2012-08-20 21:06:47 -07:00
|
|
|
nsStyleAnimation::Value* startValue = startValues.AppendElement();
|
|
|
|
nsStyleAnimation::Value* endValue = endValues.AppendElement();
|
2012-07-31 10:28:20 -07:00
|
|
|
if (segment.endState().type() == Animatable::TArrayOfTransformFunction) {
|
|
|
|
const InfallibleTArray<TransformFunction>& startFunctions =
|
|
|
|
segment.startState().get_ArrayOfTransformFunction();
|
2013-12-11 18:09:44 -08:00
|
|
|
startValue->SetTransformValue(CreateCSSValueList(startFunctions));
|
2012-07-31 10:28:20 -07:00
|
|
|
|
|
|
|
const InfallibleTArray<TransformFunction>& endFunctions =
|
|
|
|
segment.endState().get_ArrayOfTransformFunction();
|
2013-12-11 18:09:44 -08:00
|
|
|
endValue->SetTransformValue(CreateCSSValueList(endFunctions));
|
2012-07-31 10:28:20 -07:00
|
|
|
} else {
|
2012-08-20 06:35:41 -07:00
|
|
|
NS_ASSERTION(segment.endState().type() == Animatable::Tfloat,
|
2012-07-31 10:28:20 -07:00
|
|
|
"Unknown Animatable type");
|
2012-08-20 21:06:47 -07:00
|
|
|
startValue->SetFloatValue(segment.startState().get_float());
|
|
|
|
endValue->SetFloatValue(segment.endState().get_float());
|
2012-07-31 10:28:20 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2013-04-17 14:39:13 -07:00
|
|
|
void
|
2013-07-02 09:01:46 -07:00
|
|
|
ContainerLayer::SetAsyncPanZoomController(AsyncPanZoomController *controller)
|
2013-04-17 14:39:13 -07:00
|
|
|
{
|
2013-07-02 09:01:46 -07:00
|
|
|
mAPZC = controller;
|
2013-04-17 14:39:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
AsyncPanZoomController*
|
2013-07-02 09:27:17 -07:00
|
|
|
ContainerLayer::GetAsyncPanZoomController() const
|
2013-04-17 14:39:13 -07:00
|
|
|
{
|
2013-07-02 09:01:46 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (mAPZC) {
|
|
|
|
MOZ_ASSERT(GetFrameMetrics().IsScrollable());
|
2013-04-17 14:39:13 -07:00
|
|
|
}
|
2013-07-02 09:01:46 -07:00
|
|
|
#endif
|
|
|
|
return mAPZC;
|
2013-04-17 14:39:13 -07:00
|
|
|
}
|
|
|
|
|
2012-10-02 22:55:50 -07:00
|
|
|
void
|
|
|
|
Layer::ApplyPendingUpdatesToSubtree()
|
|
|
|
{
|
|
|
|
ApplyPendingUpdatesForThisTransaction();
|
|
|
|
for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) {
|
|
|
|
child->ApplyPendingUpdatesToSubtree();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2010-07-21 11:06:33 -07:00
|
|
|
Layer::CanUseOpaqueSurface()
|
|
|
|
{
|
|
|
|
// If the visible content in the layer is opaque, there is no need
|
|
|
|
// for an alpha channel.
|
2010-09-02 02:18:40 -07:00
|
|
|
if (GetContentFlags() & CONTENT_OPAQUE)
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-07-21 11:06:33 -07: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-13 15:55:45 -07:00
|
|
|
// NB: eventually these methods will be defined unconditionally, and
|
|
|
|
// can be moved into Layers.h
|
|
|
|
const nsIntRect*
|
|
|
|
Layer::GetEffectiveClipRect()
|
|
|
|
{
|
2013-04-25 15:25:33 -07:00
|
|
|
if (LayerComposite* shadow = AsLayerComposite()) {
|
2010-10-13 15:55:45 -07:00
|
|
|
return shadow->GetShadowClipRect();
|
|
|
|
}
|
|
|
|
return GetClipRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsIntRegion&
|
|
|
|
Layer::GetEffectiveVisibleRegion()
|
|
|
|
{
|
2013-04-25 15:25:33 -07:00
|
|
|
if (LayerComposite* shadow = AsLayerComposite()) {
|
2010-10-13 15:55:45 -07:00
|
|
|
return shadow->GetShadowVisibleRegion();
|
|
|
|
}
|
|
|
|
return GetVisibleRegion();
|
|
|
|
}
|
|
|
|
|
2014-01-27 07:27:20 -08:00
|
|
|
Matrix4x4
|
|
|
|
Layer::SnapTransformTranslation(const Matrix4x4& aTransform,
|
|
|
|
Matrix* aResidualTransform)
|
2012-12-06 15:58:13 -08:00
|
|
|
{
|
|
|
|
if (aResidualTransform) {
|
2014-01-27 07:27:20 -08:00
|
|
|
*aResidualTransform = Matrix();
|
2012-12-06 15:58:13 -08:00
|
|
|
}
|
|
|
|
|
2014-01-27 07:27:20 -08:00
|
|
|
Matrix matrix2D;
|
|
|
|
Matrix4x4 result;
|
2013-06-09 17:13:10 -07:00
|
|
|
if (mManager->IsSnappingEffectiveTransforms() &&
|
2012-12-06 15:58:13 -08:00
|
|
|
aTransform.Is2D(&matrix2D) &&
|
|
|
|
!matrix2D.HasNonTranslation() &&
|
|
|
|
matrix2D.HasNonIntegerTranslation()) {
|
2014-01-27 07:27:20 -08:00
|
|
|
IntPoint snappedTranslation = RoundedToInt(matrix2D.GetTranslation());
|
2014-03-21 16:56:11 -07:00
|
|
|
Matrix snappedMatrix = Matrix::Translation(snappedTranslation.x,
|
|
|
|
snappedTranslation.y);
|
2014-01-27 07:27:20 -08:00
|
|
|
result = Matrix4x4::From2D(snappedMatrix);
|
2012-12-06 15:58:13 -08:00
|
|
|
if (aResidualTransform) {
|
|
|
|
// set aResidualTransform so that aResidual * snappedMatrix == matrix2D.
|
|
|
|
// (I.e., appying snappedMatrix after aResidualTransform gives the
|
|
|
|
// ideal transform.)
|
|
|
|
*aResidualTransform =
|
2014-03-21 16:56:11 -07:00
|
|
|
Matrix::Translation(matrix2D._31 - snappedTranslation.x,
|
|
|
|
matrix2D._32 - snappedTranslation.y);
|
2012-12-06 15:58:13 -08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
result = aTransform;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-01-27 07:27:20 -08:00
|
|
|
Matrix4x4
|
|
|
|
Layer::SnapTransform(const Matrix4x4& aTransform,
|
2010-11-08 01:06:15 -08:00
|
|
|
const gfxRect& aSnapRect,
|
2014-01-27 07:27:20 -08:00
|
|
|
Matrix* aResidualTransform)
|
2010-11-08 01:06:15 -08:00
|
|
|
{
|
2012-12-07 04:37:36 -08:00
|
|
|
if (aResidualTransform) {
|
2014-01-27 07:27:20 -08:00
|
|
|
*aResidualTransform = Matrix();
|
2012-12-07 04:37:36 -08:00
|
|
|
}
|
|
|
|
|
2014-01-27 07:27:20 -08:00
|
|
|
Matrix matrix2D;
|
|
|
|
Matrix4x4 result;
|
2013-06-09 17:13:10 -07:00
|
|
|
if (mManager->IsSnappingEffectiveTransforms() &&
|
2010-11-08 01:06:15 -08:00
|
|
|
aTransform.Is2D(&matrix2D) &&
|
2013-12-13 09:31:53 -08:00
|
|
|
gfx::Size(1.0, 1.0) <= ToSize(aSnapRect.Size()) &&
|
2012-12-06 15:58:13 -08:00
|
|
|
matrix2D.PreservesAxisAlignedRectangles()) {
|
2014-01-27 07:27:20 -08: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-06 15:58:13 -08:00
|
|
|
transformedTopLeft, transformedTopRight, transformedBottomRight);
|
|
|
|
|
2014-01-27 07:27:20 -08:00
|
|
|
result = Matrix4x4::From2D(snappedMatrix);
|
2010-11-08 01:06:15 -08: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 07:27:20 -08:00
|
|
|
Matrix snappedMatrixInverse = snappedMatrix;
|
2010-11-08 01:06:15 -08:00
|
|
|
snappedMatrixInverse.Invert();
|
|
|
|
*aResidualTransform = matrix2D * snappedMatrixInverse;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
result = aTransform;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-12-11 21:21:23 -08: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 07:29:06 -08:00
|
|
|
Matrix transform2d;
|
|
|
|
return !GetEffectiveTransform().Is2D(&transform2d) ||
|
|
|
|
ThebesMatrix(transform2d).HasNonIntegerTranslation() ||
|
2012-12-11 21:21:23 -08:00
|
|
|
AncestorLayerMayChangeTransform(this);
|
|
|
|
}
|
|
|
|
|
2012-07-31 10:28:20 -07:00
|
|
|
nsIntRect
|
2011-05-22 17:27:03 -07:00
|
|
|
Layer::CalculateScissorRect(const nsIntRect& aCurrentScissorRect,
|
2014-01-15 23:22:19 -08:00
|
|
|
const gfx::Matrix* aWorldTransform)
|
2011-02-24 23:44:22 -08:00
|
|
|
{
|
2011-05-22 17:27:03 -07: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-24 23:44:22 -08:00
|
|
|
|
|
|
|
const nsIntRect *clipRect = GetEffectiveClipRect();
|
2011-05-22 17:27:03 -07:00
|
|
|
if (!clipRect)
|
|
|
|
return currentClip;
|
2011-02-24 23:44:22 -08:00
|
|
|
|
2011-05-22 17:27:03 -07: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-24 23:44:22 -08:00
|
|
|
}
|
|
|
|
|
2011-05-22 17:27:03 -07:00
|
|
|
nsIntRect scissor = *clipRect;
|
|
|
|
if (!container->UseIntermediateSurface()) {
|
2014-01-27 12:25:19 -08:00
|
|
|
gfx::Matrix matrix;
|
|
|
|
DebugOnly<bool> is2D = container->GetEffectiveTransform().Is2D(&matrix);
|
2011-05-22 17:27:03 -07:00
|
|
|
// See DefaultComputeEffectiveTransforms below
|
2011-06-16 03:51:05 -07:00
|
|
|
NS_ASSERTION(is2D && matrix.PreservesAxisAlignedRectangles(),
|
|
|
|
"Non preserves axis aligned transform with clipped child should have forced intermediate surface");
|
2014-01-27 12:25:19 -08:00
|
|
|
gfx::Rect r(scissor.x, scissor.y, scissor.width, scissor.height);
|
|
|
|
gfxRect trScissor = gfx::ThebesRect(matrix.TransformBounds(r));
|
2011-06-16 03:51:05 -07:00
|
|
|
trScissor.Round();
|
|
|
|
if (!gfxUtils::GfxRectToIntRect(trScissor, &scissor)) {
|
|
|
|
return nsIntRect(currentClip.TopLeft(), nsIntSize(0, 0));
|
|
|
|
}
|
2011-05-22 17:27:03 -07:00
|
|
|
|
|
|
|
// Find the nearest ancestor with an intermediate surface
|
|
|
|
do {
|
|
|
|
container = container->GetParent();
|
|
|
|
} while (container && !container->UseIntermediateSurface());
|
2011-02-24 23:44:22 -08:00
|
|
|
}
|
2011-05-22 17:27:03 -07:00
|
|
|
if (container) {
|
|
|
|
scissor.MoveBy(-container->GetIntermediateSurfaceRect().TopLeft());
|
|
|
|
} else if (aWorldTransform) {
|
2014-01-15 23:22:19 -08:00
|
|
|
gfx::Rect r(scissor.x, scissor.y, scissor.width, scissor.height);
|
|
|
|
gfx::Rect trScissor = aWorldTransform->TransformBounds(r);
|
2011-05-22 17:27:03 -07:00
|
|
|
trScissor.Round();
|
2014-01-15 23:22:19 -08:00
|
|
|
if (!gfxUtils::GfxRectToIntRect(ThebesRect(trScissor), &scissor))
|
2011-05-22 17:27:03 -07:00
|
|
|
return nsIntRect(currentClip.TopLeft(), nsIntSize(0, 0));
|
2011-02-24 23:44:22 -08:00
|
|
|
}
|
2011-05-22 17:27:03 -07:00
|
|
|
return currentClip.Intersect(scissor);
|
2011-02-24 23:44:22 -08:00
|
|
|
}
|
|
|
|
|
2014-01-27 07:28:47 -08:00
|
|
|
const Matrix4x4
|
2013-07-02 09:27:17 -07:00
|
|
|
Layer::GetTransform() const
|
2012-07-30 19:20:00 -07:00
|
|
|
{
|
2014-01-27 07:29:06 -08:00
|
|
|
Matrix4x4 transform = mTransform;
|
2013-07-02 09:27:17 -07:00
|
|
|
if (const ContainerLayer* c = AsContainerLayer()) {
|
2012-08-03 14:29:22 -07:00
|
|
|
transform.Scale(c->GetPreXScale(), c->GetPreYScale(), 1.0f);
|
|
|
|
}
|
2014-01-27 07:28:47 -08:00
|
|
|
transform = transform * Matrix4x4().Scale(mPostXScale, mPostYScale, 1.0f);
|
2012-07-30 19:20:00 -07:00
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
2014-01-27 07:28:18 -08:00
|
|
|
const Matrix4x4
|
2010-11-08 01:06:15 -08:00
|
|
|
Layer::GetLocalTransform()
|
2010-10-13 15:55:45 -07:00
|
|
|
{
|
2014-01-27 07:29:27 -08:00
|
|
|
Matrix4x4 transform;
|
2013-04-25 15:25:33 -07:00
|
|
|
if (LayerComposite* shadow = AsLayerComposite())
|
2012-07-30 19:20:00 -07:00
|
|
|
transform = shadow->GetShadowTransform();
|
|
|
|
else
|
2014-01-27 07:29:27 -08:00
|
|
|
transform = mTransform;
|
2012-08-03 14:29:22 -07:00
|
|
|
if (ContainerLayer* c = AsContainerLayer()) {
|
|
|
|
transform.Scale(c->GetPreXScale(), c->GetPreYScale(), 1.0f);
|
|
|
|
}
|
2014-01-27 07:29:27 -08:00
|
|
|
transform = transform * Matrix4x4().Scale(mPostXScale, mPostYScale, 1.0f);
|
2014-01-27 07:28:18 -08:00
|
|
|
|
2014-01-27 07:29:27 -08:00
|
|
|
return transform;
|
2010-11-08 01:06:15 -08:00
|
|
|
}
|
|
|
|
|
2012-10-02 22:55:50 -07:00
|
|
|
void
|
|
|
|
Layer::ApplyPendingUpdatesForThisTransaction()
|
|
|
|
{
|
|
|
|
if (mPendingTransform && *mPendingTransform != mTransform) {
|
2013-03-21 19:17:28 -07:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PendingUpdatesForThisTransaction", this));
|
2012-10-02 22:55:50 -07:00
|
|
|
mTransform = *mPendingTransform;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
mPendingTransform = nullptr;
|
2014-03-04 20:13:21 -08:00
|
|
|
|
|
|
|
if (mPendingAnimations) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PendingUpdatesForThisTransaction", this));
|
|
|
|
mPendingAnimations->SwapElements(mAnimations);
|
|
|
|
mPendingAnimations = nullptr;
|
|
|
|
Mutated();
|
|
|
|
}
|
2012-10-02 22:55:50 -07:00
|
|
|
}
|
|
|
|
|
2012-07-31 10:28:20 -07:00
|
|
|
const float
|
|
|
|
Layer::GetLocalOpacity()
|
|
|
|
{
|
2013-04-25 15:25:33 -07:00
|
|
|
if (LayerComposite* shadow = AsLayerComposite())
|
2012-07-31 10:28:20 -07:00
|
|
|
return shadow->GetShadowOpacity();
|
|
|
|
return mOpacity;
|
|
|
|
}
|
|
|
|
|
2010-11-08 01:06:15 -08:00
|
|
|
float
|
|
|
|
Layer::GetEffectiveOpacity()
|
|
|
|
{
|
2012-07-31 10:28:20 -07:00
|
|
|
float opacity = GetLocalOpacity();
|
2010-11-08 01:06:15 -08:00
|
|
|
for (ContainerLayer* c = GetParent(); c && !c->UseIntermediateSurface();
|
|
|
|
c = c->GetParent()) {
|
2012-07-31 10:28:20 -07:00
|
|
|
opacity *= c->GetLocalOpacity();
|
2010-10-13 15:55:45 -07:00
|
|
|
}
|
2010-11-08 01:06:15 -08:00
|
|
|
return opacity;
|
2010-10-13 15:55:45 -07:00
|
|
|
}
|
2013-09-14 20:23:46 -07:00
|
|
|
|
2014-02-12 07:07:46 -08:00
|
|
|
CompositionOp
|
2013-09-14 20:23:46 -07:00
|
|
|
Layer::GetEffectiveMixBlendMode()
|
|
|
|
{
|
2014-02-12 07:07:46 -08:00
|
|
|
if(mMixBlendMode != CompositionOp::OP_OVER)
|
2013-09-14 20:23:46 -07:00
|
|
|
return mMixBlendMode;
|
|
|
|
for (ContainerLayer* c = GetParent(); c && !c->UseIntermediateSurface();
|
|
|
|
c = c->GetParent()) {
|
2014-02-12 07:07:46 -08:00
|
|
|
if(c->mMixBlendMode != CompositionOp::OP_OVER)
|
2013-09-14 20:23:46 -07:00
|
|
|
return c->mMixBlendMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mMixBlendMode;
|
|
|
|
}
|
2010-10-13 15:55:45 -07:00
|
|
|
|
2014-02-12 07:07:46 -08:00
|
|
|
gfxContext::GraphicsOperator
|
|
|
|
Layer::DeprecatedGetEffectiveMixBlendMode()
|
|
|
|
{
|
|
|
|
return ThebesOp(GetEffectiveMixBlendMode());
|
|
|
|
}
|
|
|
|
|
2012-02-07 14:27:44 -08:00
|
|
|
void
|
2014-01-27 07:28:04 -08:00
|
|
|
Layer::ComputeEffectiveTransformForMaskLayer(const Matrix4x4& aTransformToSurface)
|
2012-02-07 14:27:44 -08:00
|
|
|
{
|
|
|
|
if (mMaskLayer) {
|
2014-01-27 07:28:04 -08:00
|
|
|
mMaskLayer->mEffectiveTransform = aTransformToSurface;
|
2012-07-25 01:48:09 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2014-01-27 07:28:47 -08:00
|
|
|
bool maskIs2D = mMaskLayer->GetTransform().CanDraw2D();
|
2012-07-25 01:48:09 -07:00
|
|
|
NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!");
|
|
|
|
#endif
|
2014-01-27 07:28:47 -08:00
|
|
|
mMaskLayer->mEffectiveTransform = mMaskLayer->GetTransform() * mMaskLayer->mEffectiveTransform;
|
2012-02-07 14:27:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-02 09:01:46 -07:00
|
|
|
ContainerLayer::ContainerLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: Layer(aManager, aImplData),
|
|
|
|
mFirstChild(nullptr),
|
|
|
|
mLastChild(nullptr),
|
2014-04-11 16:39:21 -07:00
|
|
|
mScrollHandoffParentId(FrameMetrics::NULL_SCROLL_ID),
|
2013-07-02 09:01:46 -07:00
|
|
|
mPreXScale(1.0f),
|
|
|
|
mPreYScale(1.0f),
|
|
|
|
mInheritedXScale(1.0f),
|
|
|
|
mInheritedYScale(1.0f),
|
|
|
|
mUseIntermediateSurface(false),
|
|
|
|
mSupportsComponentAlphaChildren(false),
|
|
|
|
mMayHaveReadbackChild(false)
|
|
|
|
{
|
|
|
|
mContentFlags = 0; // Clear NO_TEXT, NO_TEXT_OVER_TRANSPARENT
|
|
|
|
}
|
|
|
|
|
|
|
|
ContainerLayer::~ContainerLayer() {}
|
|
|
|
|
2014-02-21 13:50:25 -08:00
|
|
|
bool
|
2013-09-01 15:19:18 -07:00
|
|
|
ContainerLayer::InsertAfter(Layer* aChild, Layer* aAfter)
|
|
|
|
{
|
2014-02-21 13:50:25 -08: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-01 15:19:18 -07: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-21 13:50:25 -08:00
|
|
|
return true;
|
2013-09-01 15:19:18 -07: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-21 13:50:25 -08:00
|
|
|
return true;
|
2013-09-01 15:19:18 -07:00
|
|
|
}
|
|
|
|
|
2014-02-21 13:50:25 -08:00
|
|
|
bool
|
2013-09-01 15:19:18 -07:00
|
|
|
ContainerLayer::RemoveChild(Layer *aChild)
|
|
|
|
{
|
2014-02-21 13:50:25 -08: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-01 15:19:18 -07: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-21 13:50:25 -08:00
|
|
|
return true;
|
2013-09-01 15:19:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-21 13:50:25 -08:00
|
|
|
bool
|
2013-09-01 15:19:18 -07:00
|
|
|
ContainerLayer::RepositionChild(Layer* aChild, Layer* aAfter)
|
|
|
|
{
|
2014-02-21 13:50:25 -08: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-01 15:19:18 -07:00
|
|
|
|
|
|
|
Layer* prev = aChild->GetPrevSibling();
|
|
|
|
Layer* next = aChild->GetNextSibling();
|
|
|
|
if (prev == aAfter) {
|
|
|
|
// aChild is already in the correct position, nothing to do.
|
2014-02-21 13:50:25 -08:00
|
|
|
return true;
|
2013-09-01 15:19:18 -07:00
|
|
|
}
|
|
|
|
if (prev) {
|
|
|
|
prev->SetNextSibling(next);
|
2014-02-18 13:38:30 -08:00
|
|
|
} else {
|
|
|
|
mFirstChild = next;
|
2013-09-01 15:19:18 -07:00
|
|
|
}
|
|
|
|
if (next) {
|
|
|
|
next->SetPrevSibling(prev);
|
2014-02-18 13:38:30 -08:00
|
|
|
} else {
|
|
|
|
mLastChild = prev;
|
2013-09-01 15:19:18 -07:00
|
|
|
}
|
|
|
|
if (!aAfter) {
|
|
|
|
aChild->SetPrevSibling(nullptr);
|
|
|
|
aChild->SetNextSibling(mFirstChild);
|
|
|
|
if (mFirstChild) {
|
|
|
|
mFirstChild->SetPrevSibling(aChild);
|
|
|
|
}
|
|
|
|
mFirstChild = aChild;
|
2014-02-21 13:50:25 -08:00
|
|
|
return true;
|
2013-09-01 15:19:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Layer* afterNext = aAfter->GetNextSibling();
|
|
|
|
if (afterNext) {
|
|
|
|
afterNext->SetPrevSibling(aChild);
|
|
|
|
} else {
|
|
|
|
mLastChild = aChild;
|
|
|
|
}
|
|
|
|
aAfter->SetNextSibling(aChild);
|
|
|
|
aChild->SetPrevSibling(aAfter);
|
|
|
|
aChild->SetNextSibling(afterNext);
|
2014-02-21 13:50:25 -08:00
|
|
|
return true;
|
2013-09-01 15:19:18 -07:00
|
|
|
}
|
|
|
|
|
2011-08-09 12:38:26 -07:00
|
|
|
void
|
|
|
|
ContainerLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
|
|
|
|
{
|
2014-04-11 16:39:21 -07:00
|
|
|
aAttrs = ContainerLayerAttributes(GetFrameMetrics(), mScrollHandoffParentId,
|
|
|
|
mPreXScale, mPreYScale,
|
2013-01-08 01:39:12 -08:00
|
|
|
mInheritedXScale, mInheritedYScale);
|
2011-08-09 12:38:26 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2010-11-08 01:06:15 -08:00
|
|
|
ContainerLayer::HasMultipleChildren()
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t count = 0;
|
2010-11-08 01:06:15 -08: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 07:59:28 -07:00
|
|
|
return true;
|
2010-11-08 01:06:15 -08:00
|
|
|
}
|
2010-10-13 15:55:45 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-11-08 01:06:15 -08:00
|
|
|
}
|
2010-10-13 15:55:45 -07:00
|
|
|
|
2011-10-06 14:23:18 -07: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 01:06:15 -08:00
|
|
|
void
|
2014-01-27 07:28:04 -08:00
|
|
|
ContainerLayer::DefaultComputeEffectiveTransforms(const Matrix4x4& aTransformToSurface)
|
2010-11-08 01:06:15 -08:00
|
|
|
{
|
2014-01-27 07:27:20 -08:00
|
|
|
Matrix residual;
|
2014-01-27 07:28:18 -08:00
|
|
|
Matrix4x4 idealTransform = GetLocalTransform() * aTransformToSurface;
|
2011-10-06 14:29:07 -07:00
|
|
|
idealTransform.ProjectTo2D();
|
2014-01-27 07:28:18 -08:00
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform, &residual);
|
2010-11-08 01:06:15 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool useIntermediateSurface;
|
2014-05-09 02:41:56 -07:00
|
|
|
if (GetMaskLayer() ||
|
|
|
|
GetForceIsolatedGroup()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
useIntermediateSurface = true;
|
2012-03-01 00:26:09 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
} else if (gfxUtils::sDumpPainting) {
|
|
|
|
useIntermediateSurface = true;
|
|
|
|
#endif
|
2010-11-08 01:06:15 -08:00
|
|
|
} else {
|
2012-02-07 14:27:44 -08:00
|
|
|
float opacity = GetEffectiveOpacity();
|
2014-05-09 02:41:56 -07:00
|
|
|
CompositionOp blendMode = GetEffectiveMixBlendMode();
|
|
|
|
if ((opacity != 1.0f || blendMode != CompositionOp::OP_OVER) && HasMultipleChildren()) {
|
2012-02-07 14:27:44 -08:00
|
|
|
useIntermediateSurface = true;
|
|
|
|
} else {
|
|
|
|
useIntermediateSurface = false;
|
2014-01-27 12:25:19 -08:00
|
|
|
gfx::Matrix contTransform;
|
|
|
|
if (!mEffectiveTransform.Is2D(&contTransform) ||
|
2011-06-16 03:51:05 -07:00
|
|
|
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
|
|
|
!contTransform.PreservesAxisAlignedRectangles()) {
|
|
|
|
#else
|
2014-01-27 12:25:19 -08:00
|
|
|
gfx::ThebesMatrix(contTransform).HasNonIntegerTranslation()) {
|
2011-06-16 03:51:05 -07:00
|
|
|
#endif
|
2012-02-07 14:27:44 -08: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-26 13:06:32 -07:00
|
|
|
* Nor for a child with a mask layer.
|
2012-02-07 14:27:44 -08:00
|
|
|
*/
|
2012-06-26 13:06:32 -07:00
|
|
|
if ((clipRect && !clipRect->IsEmpty() && !child->GetVisibleRegion().IsEmpty()) ||
|
|
|
|
child->GetMaskLayer()) {
|
2012-02-07 14:27:44 -08:00
|
|
|
useIntermediateSurface = true;
|
|
|
|
break;
|
|
|
|
}
|
2010-11-08 01:06:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mUseIntermediateSurface = useIntermediateSurface;
|
|
|
|
if (useIntermediateSurface) {
|
2014-01-27 07:28:04 -08:00
|
|
|
ComputeEffectiveTransformsForChildren(Matrix4x4::From2D(residual));
|
2010-11-08 01:06:15 -08:00
|
|
|
} else {
|
2014-01-27 07:28:18 -08:00
|
|
|
ComputeEffectiveTransformsForChildren(idealTransform);
|
2010-11-08 01:06:15 -08:00
|
|
|
}
|
2012-02-07 14:27:44 -08:00
|
|
|
|
|
|
|
if (idealTransform.CanDraw2D()) {
|
|
|
|
ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
|
|
|
|
} else {
|
2014-01-27 07:28:04 -08:00
|
|
|
ComputeEffectiveTransformForMaskLayer(Matrix4x4());
|
2012-02-07 14:27:44 -08:00
|
|
|
}
|
2010-11-08 01:06:15 -08:00
|
|
|
}
|
2010-10-13 15:55:45 -07:00
|
|
|
|
2014-05-09 03:06:20 -07:00
|
|
|
void
|
|
|
|
ContainerLayer::DefaultComputeSupportsComponentAlphaChildren(bool* aNeedsSurfaceCopy)
|
|
|
|
{
|
|
|
|
bool supportsComponentAlphaChildren = false;
|
|
|
|
bool needsSurfaceCopy = false;
|
2014-05-09 03:06:20 -07:00
|
|
|
CompositionOp blendMode = GetEffectiveMixBlendMode();
|
2014-05-09 03:06:20 -07:00
|
|
|
if (UseIntermediateSurface()) {
|
|
|
|
if (GetEffectiveVisibleRegion().GetNumRects() == 1 &&
|
|
|
|
(GetContentFlags() & Layer::CONTENT_OPAQUE))
|
|
|
|
{
|
|
|
|
supportsComponentAlphaChildren = true;
|
|
|
|
} else {
|
|
|
|
gfx::Matrix transform;
|
|
|
|
if (HasOpaqueAncestorLayer(this) &&
|
|
|
|
GetEffectiveTransform().Is2D(&transform) &&
|
2014-05-09 03:06:20 -07:00
|
|
|
!gfx::ThebesMatrix(transform).HasNonIntegerTranslation() &&
|
|
|
|
blendMode == gfx::CompositionOp::OP_OVER) {
|
2014-05-09 03:06:20 -07:00
|
|
|
supportsComponentAlphaChildren = true;
|
|
|
|
needsSurfaceCopy = true;
|
|
|
|
}
|
|
|
|
}
|
2014-05-09 03:06:20 -07:00
|
|
|
} else if (blendMode == gfx::CompositionOp::OP_OVER) {
|
2014-05-09 03:06:20 -07:00
|
|
|
supportsComponentAlphaChildren =
|
|
|
|
(GetContentFlags() & Layer::CONTENT_OPAQUE) ||
|
|
|
|
(GetParent() && GetParent()->SupportsComponentAlphaChildren());
|
|
|
|
}
|
|
|
|
|
|
|
|
mSupportsComponentAlphaChildren = supportsComponentAlphaChildren &&
|
|
|
|
gfxPrefs::ComponentAlphaEnabled();
|
|
|
|
if (aNeedsSurfaceCopy) {
|
|
|
|
*aNeedsSurfaceCopy = mSupportsComponentAlphaChildren && needsSurfaceCopy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-08 01:06:15 -08:00
|
|
|
void
|
2014-01-27 07:28:04 -08:00
|
|
|
ContainerLayer::ComputeEffectiveTransformsForChildren(const Matrix4x4& aTransformToSurface)
|
2010-11-08 01:06:15 -08:00
|
|
|
{
|
|
|
|
for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) {
|
|
|
|
l->ComputeEffectiveTransforms(aTransformToSurface);
|
|
|
|
}
|
|
|
|
}
|
2010-10-13 15:55:45 -07:00
|
|
|
|
2013-09-01 15:19:18 -07: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-16 14:43:30 -08: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 07:59:28 -07:00
|
|
|
mMayHaveReadbackChild = true;
|
2011-02-16 14:43:30 -08:00
|
|
|
}
|
|
|
|
}
|
2012-07-17 16:59:45 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
RefLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
|
|
|
|
{
|
|
|
|
aAttrs = RefLayerAttributes(GetReferentId());
|
|
|
|
}
|
|
|
|
|
2013-01-23 10:47:44 -08:00
|
|
|
/**
|
|
|
|
* StartFrameTimeRecording, together with StopFrameTimeRecording
|
2013-11-26 23:32:19 -08:00
|
|
|
* enable recording of frame intervals.
|
2013-01-23 10:47:44 -08:00
|
|
|
*
|
2013-11-26 23:32:19 -08:00
|
|
|
* To allow concurrent consumers, a cyclic array is used which serves all
|
|
|
|
* consumers, practically stateless with regard to consumers.
|
2013-01-23 10:47:44 -08:00
|
|
|
*
|
2013-11-26 23:32:19 -08:00
|
|
|
* To save resources, the buffer is allocated on first call to StartFrameTimeRecording
|
2013-01-23 10:47:44 -08:00
|
|
|
* and recording is paused if no consumer which called StartFrameTimeRecording is able
|
2013-11-26 23:32:19 -08:00
|
|
|
* to get valid results (because the cyclic buffer was overwritten since that call).
|
2013-01-23 10:47:44 -08: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-26 23:32:19 -08:00
|
|
|
LayerManager::StartFrameTimeRecording(int32_t aBufferSize)
|
2012-01-05 14:40:35 -08:00
|
|
|
{
|
2013-01-23 10:47:44 -08:00
|
|
|
if (mRecording.mIsPaused) {
|
|
|
|
mRecording.mIsPaused = false;
|
|
|
|
|
|
|
|
if (!mRecording.mIntervals.Length()) { // Initialize recording buffers
|
2014-02-14 09:56:35 -08:00
|
|
|
mRecording.mIntervals.SetLength(aBufferSize);
|
2013-01-23 10:47:44 -08: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-03 18:53:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-11-26 23:32:19 -08:00
|
|
|
LayerManager::RecordFrame()
|
2012-01-05 14:40:35 -08:00
|
|
|
{
|
2013-01-23 10:47:44 -08:00
|
|
|
if (!mRecording.mIsPaused) {
|
2012-01-05 14:40:35 -08:00
|
|
|
TimeStamp now = TimeStamp::Now();
|
2013-01-23 10:47:44 -08: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-05 14:40:35 -08:00
|
|
|
}
|
2013-11-26 23:32:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LayerManager::PostPresent()
|
|
|
|
{
|
2012-10-11 10:54:27 -07:00
|
|
|
if (!mTabSwitchStart.IsNull()) {
|
|
|
|
Telemetry::Accumulate(Telemetry::FX_TAB_SWITCH_TOTAL_MS,
|
|
|
|
uint32_t((TimeStamp::Now() - mTabSwitchStart).ToMilliseconds()));
|
|
|
|
mTabSwitchStart = TimeStamp();
|
|
|
|
}
|
2012-01-05 14:40:35 -08:00
|
|
|
}
|
|
|
|
|
2012-11-29 08:14:13 -08:00
|
|
|
void
|
2013-01-23 10:47:44 -08:00
|
|
|
LayerManager::StopFrameTimeRecording(uint32_t aStartIndex,
|
2013-11-26 23:32:19 -08:00
|
|
|
nsTArray<float>& aFrameIntervals)
|
2012-01-05 14:40:35 -08:00
|
|
|
{
|
2013-01-23 10:47:44 -08: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 09:56:35 -08:00
|
|
|
if (!length) {
|
2013-01-23 10:47:44 -08:00
|
|
|
aFrameIntervals.Clear();
|
2014-02-14 09:56:35 -08:00
|
|
|
return; // empty recording, return empty arrays.
|
2013-01-23 10:47:44 -08:00
|
|
|
}
|
2014-02-14 09:56:35 -08:00
|
|
|
// Set length in advance to avoid possibly repeated reallocations
|
|
|
|
aFrameIntervals.SetLength(length);
|
2013-01-23 10:47:44 -08: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-05 14:40:35 -08:00
|
|
|
}
|
|
|
|
|
2012-10-11 10:54:27 -07:00
|
|
|
void
|
|
|
|
LayerManager::BeginTabSwitch()
|
|
|
|
{
|
|
|
|
mTabSwitchStart = TimeStamp::Now();
|
|
|
|
}
|
2011-07-04 19:52:00 -07:00
|
|
|
|
2013-04-25 15:25:33 -07:00
|
|
|
static nsACString& PrintInfo(nsACString& aTo, LayerComposite* aLayerComposite);
|
2010-10-13 15:55:45 -07:00
|
|
|
|
2012-03-01 00:26:09 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
template <typename T>
|
|
|
|
void WriteSnapshotLinkToDumpFile(T* aObj, FILE* aFile)
|
|
|
|
{
|
2013-05-25 19:44:24 -07:00
|
|
|
if (!aObj) {
|
|
|
|
return;
|
|
|
|
}
|
2012-03-01 00:26:09 -08:00
|
|
|
nsCString string(aObj->Name());
|
2014-05-21 20:48:52 -07:00
|
|
|
string.Append('-');
|
2012-08-22 08:56:38 -07:00
|
|
|
string.AppendInt((uint64_t)aObj);
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(aFile, "href=\"javascript:ViewImage('%s')\"", string.BeginReading());
|
2012-03-01 00:26:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2014-01-08 00:43:46 -08:00
|
|
|
void WriteSnapshotToDumpFile_internal(T* aObj, DataSourceSurface* aSurf)
|
2012-03-01 00:26:09 -08:00
|
|
|
{
|
2014-01-08 00:43:46 -08:00
|
|
|
nsRefPtr<gfxImageSurface> deprecatedSurf =
|
|
|
|
new gfxImageSurface(aSurf->GetData(),
|
|
|
|
ThebesIntSize(aSurf->GetSize()),
|
|
|
|
aSurf->Stride(),
|
|
|
|
SurfaceFormatToImageFormat(aSurf->GetFormat()));
|
2012-03-01 00:26:09 -08:00
|
|
|
nsCString string(aObj->Name());
|
2014-05-21 20:48:52 -07:00
|
|
|
string.Append('-');
|
2012-08-22 08:56:38 -07:00
|
|
|
string.AppendInt((uint64_t)aObj);
|
2013-11-23 14:44:18 -08:00
|
|
|
if (gfxUtils::sDumpPaintFile) {
|
|
|
|
fprintf_stderr(gfxUtils::sDumpPaintFile, "array[\"%s\"]=\"", string.BeginReading());
|
|
|
|
}
|
2014-01-08 00:43:46 -08:00
|
|
|
deprecatedSurf->DumpAsDataURL(gfxUtils::sDumpPaintFile);
|
2013-11-23 14:44:18 -08:00
|
|
|
if (gfxUtils::sDumpPaintFile) {
|
|
|
|
fprintf_stderr(gfxUtils::sDumpPaintFile, "\";");
|
|
|
|
}
|
2012-03-01 00:26:09 -08:00
|
|
|
}
|
|
|
|
|
2014-01-08 00:37:58 -08:00
|
|
|
void WriteSnapshotToDumpFile(Layer* aLayer, DataSourceSurface* aSurf)
|
2012-03-01 00:26:09 -08:00
|
|
|
{
|
2014-01-08 00:43:46 -08:00
|
|
|
WriteSnapshotToDumpFile_internal(aLayer, aSurf);
|
2012-03-01 00:26:09 -08:00
|
|
|
}
|
|
|
|
|
2014-01-08 00:37:58 -08:00
|
|
|
void WriteSnapshotToDumpFile(LayerManager* aManager, DataSourceSurface* aSurf)
|
2012-03-01 00:26:09 -08:00
|
|
|
{
|
2014-01-08 00:43:46 -08:00
|
|
|
WriteSnapshotToDumpFile_internal(aManager, aSurf);
|
2012-03-01 00:26:09 -08: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 02:20:52 -07:00
|
|
|
|
2013-09-26 17:37:19 -07: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 02:20:52 -07:00
|
|
|
{
|
2014-01-08 00:43:46 -08: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 02:20:52 -07:00
|
|
|
}
|
2012-03-01 00:26:09 -08:00
|
|
|
#endif
|
|
|
|
|
2010-07-21 11:06:33 -07:00
|
|
|
void
|
2012-08-07 10:57:26 -07:00
|
|
|
Layer::Dump(FILE* aFile, const char* aPrefix, bool aDumpHtml)
|
2010-07-21 11:06:33 -07:00
|
|
|
{
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(aFile, "<li><a id=\"%p\" ", this);
|
2012-03-01 00:26:09 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2012-08-07 10:57:26 -07:00
|
|
|
if (GetType() == TYPE_CONTAINER || GetType() == TYPE_THEBES) {
|
|
|
|
WriteSnapshotLinkToDumpFile(this, aFile);
|
|
|
|
}
|
2012-03-01 00:26:09 -08:00
|
|
|
#endif
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(aFile, ">");
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
2010-07-21 11:06:33 -07:00
|
|
|
DumpSelf(aFile, aPrefix);
|
2013-09-12 08:08:50 -07:00
|
|
|
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2013-05-25 19:44:24 -07:00
|
|
|
if (AsLayerComposite() && AsLayerComposite()->GetCompositableHost()) {
|
|
|
|
AsLayerComposite()->GetCompositableHost()->Dump(aFile, aPrefix, aDumpHtml);
|
|
|
|
}
|
2013-09-12 08:08:50 -07:00
|
|
|
#endif
|
|
|
|
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(aFile, "</a>");
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
2010-07-21 11:06:33 -07:00
|
|
|
|
2012-01-17 17:35:49 -08:00
|
|
|
if (Layer* mask = GetMaskLayer()) {
|
2013-11-25 18:07:44 -08:00
|
|
|
fprintf_stderr(aFile, "%s Mask layer:\n", aPrefix);
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString pfx(aPrefix);
|
2013-11-25 18:07:44 -08:00
|
|
|
pfx += " ";
|
2013-05-25 19:44:24 -07:00
|
|
|
mask->Dump(aFile, pfx.get(), aDumpHtml);
|
2012-01-17 17:35:49 -08:00
|
|
|
}
|
|
|
|
|
2010-07-21 11:06:33 -07:00
|
|
|
if (Layer* kid = GetFirstChild()) {
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString pfx(aPrefix);
|
2010-07-21 11:06:33 -07:00
|
|
|
pfx += " ";
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(aFile, "<ul>");
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
2013-05-25 19:44:24 -07:00
|
|
|
kid->Dump(aFile, pfx.get(), aDumpHtml);
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(aFile, "</ul>");
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
2010-07-21 11:06:33 -07:00
|
|
|
}
|
|
|
|
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(aFile, "</li>");
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
2010-07-21 11:06:33 -07:00
|
|
|
if (Layer* next = GetNextSibling())
|
2012-08-07 10:57:26 -07:00
|
|
|
next->Dump(aFile, aPrefix, aDumpHtml);
|
2010-07-21 11:06:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Layer::DumpSelf(FILE* aFile, const char* aPrefix)
|
|
|
|
{
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString str;
|
2010-07-21 11:06:33 -07:00
|
|
|
PrintInfo(str, aPrefix);
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(aFile, "%s\n", str.get());
|
2010-07-21 11:06:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Layer::Log(const char* aPrefix)
|
|
|
|
{
|
|
|
|
if (!IsLogEnabled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
LogSelf(aPrefix);
|
|
|
|
|
|
|
|
if (Layer* kid = GetFirstChild()) {
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString pfx(aPrefix);
|
2010-07-21 11:06:33 -07:00
|
|
|
pfx += " ";
|
|
|
|
kid->Log(pfx.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Layer* next = GetNextSibling())
|
|
|
|
next->Log(aPrefix);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Layer::LogSelf(const char* aPrefix)
|
|
|
|
{
|
|
|
|
if (!IsLogEnabled())
|
|
|
|
return;
|
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString str;
|
2010-07-21 11:06:33 -07:00
|
|
|
PrintInfo(str, aPrefix);
|
|
|
|
MOZ_LAYERS_LOG(("%s", str.get()));
|
2013-11-19 20:55:27 -08:00
|
|
|
|
|
|
|
if (mMaskLayer) {
|
|
|
|
nsAutoCString pfx(aPrefix);
|
|
|
|
pfx += " \\ MaskLayer ";
|
|
|
|
mMaskLayer->LogSelf(pfx.get());
|
|
|
|
}
|
2010-07-21 11:06:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsACString&
|
|
|
|
Layer::PrintInfo(nsACString& aTo, const char* aPrefix)
|
|
|
|
{
|
|
|
|
aTo += aPrefix;
|
2012-04-24 11:43:00 -07:00
|
|
|
aTo += nsPrintfCString("%s%s (0x%p)", mManager->Name(), Name(), this);
|
2010-07-21 11:06:33 -07:00
|
|
|
|
2014-05-22 03:11:45 -07:00
|
|
|
layers::PrintInfo(aTo, AsLayerComposite());
|
2010-10-13 15:55:45 -07:00
|
|
|
|
2010-08-01 20:06:58 -07:00
|
|
|
if (mUseClipRect) {
|
|
|
|
AppendToString(aTo, mClipRect, " [clip=", "]");
|
|
|
|
}
|
2012-08-03 14:29:22 -07:00
|
|
|
if (1.0 != mPostXScale || 1.0 != mPostYScale) {
|
|
|
|
aTo.AppendPrintf(" [postScale=%g, %g]", mPostXScale, mPostYScale);
|
|
|
|
}
|
2010-09-02 02:18:40 -07:00
|
|
|
if (!mTransform.IsIdentity()) {
|
2010-07-21 11:06:33 -07:00
|
|
|
AppendToString(aTo, mTransform, " [transform=", "]");
|
2010-09-02 02:18:40 -07:00
|
|
|
}
|
|
|
|
if (!mVisibleRegion.IsEmpty()) {
|
2010-08-01 20:06:58 -07:00
|
|
|
AppendToString(aTo, mVisibleRegion, " [visible=", "]");
|
2012-09-16 15:25:33 -07:00
|
|
|
} else {
|
|
|
|
aTo += " [not visible]";
|
2010-09-02 02:18:40 -07:00
|
|
|
}
|
2013-12-16 02:47:06 -08:00
|
|
|
if (!mEventRegions.mHitRegion.IsEmpty()) {
|
|
|
|
AppendToString(aTo, mEventRegions.mHitRegion, " [hitregion=", "]");
|
|
|
|
}
|
|
|
|
if (!mEventRegions.mDispatchToContentHitRegion.IsEmpty()) {
|
|
|
|
AppendToString(aTo, mEventRegions.mDispatchToContentHitRegion, " [dispatchtocontentregion=", "]");
|
|
|
|
}
|
2010-09-02 02:18:40 -07:00
|
|
|
if (1.0 != mOpacity) {
|
2010-07-21 11:06:33 -07:00
|
|
|
aTo.AppendPrintf(" [opacity=%g]", mOpacity);
|
2010-09-02 02:18:40 -07:00
|
|
|
}
|
|
|
|
if (GetContentFlags() & CONTENT_OPAQUE) {
|
2010-07-21 11:06:33 -07:00
|
|
|
aTo += " [opaqueContent]";
|
2010-09-02 02:18:40 -07:00
|
|
|
}
|
2010-12-19 17:26:14 -08:00
|
|
|
if (GetContentFlags() & CONTENT_COMPONENT_ALPHA) {
|
|
|
|
aTo += " [componentAlpha]";
|
2010-09-02 02:18:40 -07:00
|
|
|
}
|
2013-12-12 10:34:50 -08:00
|
|
|
if (GetScrollbarDirection() == VERTICAL) {
|
|
|
|
aTo.AppendPrintf(" [vscrollbar=%lld]", GetScrollbarTargetContainerId());
|
|
|
|
}
|
|
|
|
if (GetScrollbarDirection() == HORIZONTAL) {
|
|
|
|
aTo.AppendPrintf(" [hscrollbar=%lld]", GetScrollbarTargetContainerId());
|
2013-12-09 19:14:53 -08:00
|
|
|
}
|
2011-04-05 22:00:25 -07:00
|
|
|
if (GetIsFixedPosition()) {
|
2013-12-12 04:33:02 -08:00
|
|
|
aTo.AppendPrintf(" [isFixedPosition anchor=%f,%f margin=%f,%f,%f,%f]", mAnchor.x, mAnchor.y,
|
|
|
|
mMargins.top, mMargins.right, mMargins.bottom, mMargins.left);
|
2011-04-05 22:00:25 -07:00
|
|
|
}
|
2013-09-11 21:17:58 -07:00
|
|
|
if (GetIsStickyPosition()) {
|
|
|
|
aTo.AppendPrintf(" [isStickyPosition scrollId=%d outer=%f,%f %fx%f "
|
|
|
|
"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,
|
|
|
|
mStickyPositionData->mInner.width, mStickyPositionData->mInner.height);
|
|
|
|
}
|
2013-11-19 20:55:27 -08:00
|
|
|
if (mMaskLayer) {
|
|
|
|
aTo.AppendPrintf(" [mMaskLayer=%p]", mMaskLayer.get());
|
|
|
|
}
|
2010-07-21 11:06:33 -07:00
|
|
|
|
|
|
|
return aTo;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsACString&
|
|
|
|
ThebesLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
|
|
|
|
{
|
|
|
|
Layer::PrintInfo(aTo, aPrefix);
|
2010-10-13 15:55:45 -07:00
|
|
|
if (!mValidRegion.IsEmpty()) {
|
|
|
|
AppendToString(aTo, mValidRegion, " [valid=", "]");
|
|
|
|
}
|
|
|
|
return aTo;
|
2010-07-21 11:06:33 -07:00
|
|
|
}
|
|
|
|
|
2010-09-03 13:10:45 -07:00
|
|
|
nsACString&
|
|
|
|
ContainerLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
|
|
|
|
{
|
|
|
|
Layer::PrintInfo(aTo, aPrefix);
|
2011-01-07 21:05:35 -08:00
|
|
|
if (!mFrameMetrics.IsDefault()) {
|
|
|
|
AppendToString(aTo, mFrameMetrics, " [metrics=", "]");
|
|
|
|
}
|
2014-04-11 16:39:21 -07:00
|
|
|
if (mScrollHandoffParentId != FrameMetrics::NULL_SCROLL_ID) {
|
|
|
|
aTo.AppendPrintf(" [scrollParent=%llu]", mScrollHandoffParentId);
|
|
|
|
}
|
2011-01-07 21:05:35 -08:00
|
|
|
if (UseIntermediateSurface()) {
|
|
|
|
aTo += " [usesTmpSurf]";
|
|
|
|
}
|
2012-08-03 14:29:22 -07:00
|
|
|
if (1.0 != mPreXScale || 1.0 != mPreYScale) {
|
|
|
|
aTo.AppendPrintf(" [preScale=%g, %g]", mPreXScale, mPreYScale);
|
|
|
|
}
|
2011-01-07 21:05:35 -08:00
|
|
|
return aTo;
|
2010-09-03 13:10:45 -07:00
|
|
|
}
|
|
|
|
|
2010-07-21 11:06:33 -07:00
|
|
|
nsACString&
|
|
|
|
ColorLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
|
|
|
|
{
|
|
|
|
Layer::PrintInfo(aTo, aPrefix);
|
|
|
|
AppendToString(aTo, mColor, " [color=", "]");
|
|
|
|
return aTo;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsACString&
|
|
|
|
CanvasLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
|
|
|
|
{
|
|
|
|
Layer::PrintInfo(aTo, aPrefix);
|
2013-10-01 14:01:19 -07:00
|
|
|
if (mFilter != GraphicsFilter::FILTER_GOOD) {
|
2010-08-01 20:06:58 -07:00
|
|
|
AppendToString(aTo, mFilter, " [filter=", "]");
|
|
|
|
}
|
2010-07-21 11:06:33 -07:00
|
|
|
return aTo;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsACString&
|
|
|
|
ImageLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
|
|
|
|
{
|
|
|
|
Layer::PrintInfo(aTo, aPrefix);
|
2013-10-01 14:01:19 -07:00
|
|
|
if (mFilter != GraphicsFilter::FILTER_GOOD) {
|
2010-08-01 20:06:58 -07:00
|
|
|
AppendToString(aTo, mFilter, " [filter=", "]");
|
|
|
|
}
|
2010-07-21 11:06:33 -07:00
|
|
|
return aTo;
|
|
|
|
}
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
nsACString&
|
|
|
|
RefLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
|
|
|
|
{
|
|
|
|
ContainerLayer::PrintInfo(aTo, aPrefix);
|
2012-08-20 21:06:46 -07:00
|
|
|
if (0 != mId) {
|
2012-07-17 16:59:45 -07:00
|
|
|
AppendToString(aTo, mId, " [id=", "]");
|
|
|
|
}
|
|
|
|
return aTo;
|
|
|
|
}
|
|
|
|
|
2011-02-16 14:43:30 -08:00
|
|
|
nsACString&
|
|
|
|
ReadbackLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
|
|
|
|
{
|
|
|
|
Layer::PrintInfo(aTo, aPrefix);
|
|
|
|
AppendToString(aTo, mSize, " [size=", "]");
|
|
|
|
if (mBackgroundLayer) {
|
|
|
|
AppendToString(aTo, mBackgroundLayer, " [backgroundLayer=", "]");
|
|
|
|
AppendToString(aTo, mBackgroundLayerOffset, " [backgroundOffset=", "]");
|
|
|
|
} else if (mBackgroundColor.a == 1.0) {
|
|
|
|
AppendToString(aTo, mBackgroundColor, " [backgroundColor=", "]");
|
|
|
|
} else {
|
|
|
|
aTo += " [nobackground]";
|
|
|
|
}
|
|
|
|
return aTo;
|
|
|
|
}
|
|
|
|
|
2010-07-21 11:06:33 -07:00
|
|
|
//--------------------------------------------------
|
|
|
|
// LayerManager
|
|
|
|
|
|
|
|
void
|
2012-08-07 10:57:26 -07:00
|
|
|
LayerManager::Dump(FILE* aFile, const char* aPrefix, bool aDumpHtml)
|
2010-07-21 11:06:33 -07:00
|
|
|
{
|
|
|
|
FILE* file = FILEOrDefault(aFile);
|
2012-07-31 10:28:20 -07:00
|
|
|
|
2012-03-01 00:26:09 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(file, "<ul><li><a ");
|
2012-08-07 10:57:26 -07:00
|
|
|
WriteSnapshotLinkToDumpFile(this, file);
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(file, ">");
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
2012-03-01 00:26:09 -08:00
|
|
|
#endif
|
2010-07-21 11:06:33 -07:00
|
|
|
DumpSelf(file, aPrefix);
|
2012-03-01 00:26:09 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(file, "</a>");
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
2012-03-01 00:26:09 -08:00
|
|
|
#endif
|
2010-07-21 11:06:33 -07:00
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString pfx(aPrefix);
|
2010-07-21 11:06:33 -07:00
|
|
|
pfx += " ";
|
2010-09-02 20:50:29 -07:00
|
|
|
if (!GetRoot()) {
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(file, "%s(null)", pfx.get());
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(file, "</li></ul>");
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
2010-07-21 11:06:33 -07:00
|
|
|
return;
|
|
|
|
}
|
2012-07-31 10:28:20 -07:00
|
|
|
|
2012-08-07 10:57:26 -07:00
|
|
|
if (aDumpHtml) {
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(file, "<ul>");
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
|
|
|
GetRoot()->Dump(file, pfx.get(), aDumpHtml);
|
|
|
|
if (aDumpHtml) {
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(file, "</ul></li></ul>");
|
2012-08-07 10:57:26 -07:00
|
|
|
}
|
2013-11-25 18:07:41 -08:00
|
|
|
fprintf_stderr(file, "\n");
|
2010-07-21 11:06:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LayerManager::DumpSelf(FILE* aFile, const char* aPrefix)
|
|
|
|
{
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString str;
|
2010-07-21 11:06:33 -07:00
|
|
|
PrintInfo(str, aPrefix);
|
2013-11-23 14:44:18 -08:00
|
|
|
fprintf_stderr(FILEOrDefault(aFile), "%s\n", str.get());
|
2010-07-21 11:06:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LayerManager::Log(const char* aPrefix)
|
|
|
|
{
|
|
|
|
if (!IsLogEnabled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
LogSelf(aPrefix);
|
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString pfx(aPrefix);
|
2010-07-21 11:06:33 -07:00
|
|
|
pfx += " ";
|
2010-09-02 20:50:29 -07:00
|
|
|
if (!GetRoot()) {
|
2010-07-21 11:06:33 -07:00
|
|
|
MOZ_LAYERS_LOG(("%s(null)", pfx.get()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-02 20:50:29 -07:00
|
|
|
GetRoot()->Log(pfx.get());
|
2010-07-21 11:06:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LayerManager::LogSelf(const char* aPrefix)
|
|
|
|
{
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString str;
|
2010-07-21 11:06:33 -07:00
|
|
|
PrintInfo(str, aPrefix);
|
|
|
|
MOZ_LAYERS_LOG(("%s", str.get()));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsACString&
|
|
|
|
LayerManager::PrintInfo(nsACString& aTo, const char* aPrefix)
|
|
|
|
{
|
|
|
|
aTo += aPrefix;
|
2012-04-24 11:43:00 -07:00
|
|
|
return aTo += nsPrintfCString("%sLayerManager (0x%p)", Name(), this);
|
2010-07-21 11:06:33 -07: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);
|
|
|
|
}
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
static nsACString&
|
2013-04-25 15:25:33 -07:00
|
|
|
PrintInfo(nsACString& aTo, LayerComposite* aLayerComposite)
|
2010-10-13 15:55:45 -07:00
|
|
|
{
|
2013-04-25 15:25:33 -07:00
|
|
|
if (!aLayerComposite) {
|
2010-10-13 15:55:45 -07:00
|
|
|
return aTo;
|
|
|
|
}
|
2013-04-25 15:25:33 -07:00
|
|
|
if (const nsIntRect* clipRect = aLayerComposite->GetShadowClipRect()) {
|
2010-10-13 15:55:45 -07:00
|
|
|
AppendToString(aTo, *clipRect, " [shadow-clip=", "]");
|
|
|
|
}
|
2013-04-25 15:25:33 -07:00
|
|
|
if (!aLayerComposite->GetShadowTransform().IsIdentity()) {
|
|
|
|
AppendToString(aTo, aLayerComposite->GetShadowTransform(), " [shadow-transform=", "]");
|
2010-10-13 15:55:45 -07:00
|
|
|
}
|
2013-04-25 15:25:33 -07:00
|
|
|
if (!aLayerComposite->GetShadowVisibleRegion().IsEmpty()) {
|
|
|
|
AppendToString(aTo, aLayerComposite->GetShadowVisibleRegion(), " [shadow-visible=", "]");
|
2010-10-13 15:55:45 -07:00
|
|
|
}
|
|
|
|
return aTo;
|
|
|
|
}
|
|
|
|
|
2014-01-07 13:06:08 -08:00
|
|
|
void
|
|
|
|
SetAntialiasingFlags(Layer* aLayer, DrawTarget* aTarget)
|
|
|
|
{
|
2014-01-07 17:21:56 -08:00
|
|
|
bool permitSubpixelAA = !(aLayer->GetContentFlags() & Layer::CONTENT_DISABLE_SUBPIXEL_AA);
|
2014-01-10 11:06:16 -08:00
|
|
|
if (aTarget->GetFormat() != SurfaceFormat::B8G8R8A8) {
|
2014-01-07 13:06:08 -08: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);
|
|
|
|
}
|
|
|
|
|
2013-11-17 18:07:08 -08:00
|
|
|
void
|
|
|
|
SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget)
|
|
|
|
{
|
|
|
|
if (!aTarget->IsCairo()) {
|
2014-01-07 13:06:08 -08:00
|
|
|
SetAntialiasingFlags(aLayer, aTarget->GetDrawTarget());
|
|
|
|
return;
|
|
|
|
}
|
2013-11-17 18:07:08 -08:00
|
|
|
|
2014-01-07 17:21:56 -08:00
|
|
|
bool permitSubpixelAA = !(aLayer->GetContentFlags() & Layer::CONTENT_DISABLE_SUBPIXEL_AA);
|
2014-01-07 13:06:08 -08:00
|
|
|
nsRefPtr<gfxASurface> surface = aTarget->CurrentSurface();
|
2014-01-23 10:26:40 -08:00
|
|
|
if (surface->GetContentType() != gfxContentType::COLOR_ALPHA) {
|
2014-01-07 13:06:08 -08:00
|
|
|
// Destination doesn't have alpha channel; no need to set any special flags
|
2013-12-13 10:53:18 -08:00
|
|
|
surface->SetSubpixelAntialiasingEnabled(permitSubpixelAA);
|
2014-01-07 13:06:08 -08:00
|
|
|
return;
|
2013-11-17 18:07:08 -08:00
|
|
|
}
|
2014-01-07 13:06:08 -08:00
|
|
|
|
|
|
|
const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
|
|
|
|
permitSubpixelAA &= !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
|
|
|
|
surface->GetOpaqueRect().Contains(
|
|
|
|
aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height)));
|
|
|
|
surface->SetSubpixelAntialiasingEnabled(permitSubpixelAA);
|
2013-11-17 18:07:08 -08:00
|
|
|
}
|
|
|
|
|
2010-07-21 11:06:33 -07:00
|
|
|
PRLogModuleInfo* LayerManager::sLog;
|
|
|
|
|
2012-07-31 10:28:20 -07:00
|
|
|
} // namespace layers
|
2010-07-21 11:06:33 -07:00
|
|
|
} // namespace mozilla
|