2012-06-29 10:01:34 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <stdint.h> // for uint32_t
|
|
|
|
#include <stdlib.h> // for rand, RAND_MAX
|
|
|
|
#include <sys/types.h> // for int32_t
|
2016-03-10 12:20:40 +03:00
|
|
|
#include <stack> // for stack
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "BasicContainerLayer.h" // for BasicContainerLayer
|
|
|
|
#include "BasicLayersImpl.h" // for ToData, BasicReadbackLayer, etc
|
2013-08-22 11:11:51 +04:00
|
|
|
#include "GeckoProfiler.h" // for PROFILER_LABEL
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "ImageContainer.h" // for ImageFactory
|
|
|
|
#include "Layers.h" // for Layer, ContainerLayer, etc
|
|
|
|
#include "ReadbackLayer.h" // for ReadbackLayer
|
|
|
|
#include "ReadbackProcessor.h" // for ReadbackProcessor
|
|
|
|
#include "RenderTrace.h" // for RenderTraceLayers, etc
|
|
|
|
#include "basic/BasicImplData.h" // for BasicImplData
|
|
|
|
#include "basic/BasicLayers.h" // for BasicLayerManager, etc
|
|
|
|
#include "gfxASurface.h" // for gfxASurface, etc
|
|
|
|
#include "gfxContext.h" // for gfxContext, etc
|
|
|
|
#include "gfxImageSurface.h" // for gfxImageSurface
|
|
|
|
#include "gfxMatrix.h" // for gfxMatrix
|
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
2014-02-27 06:53:31 +04:00
|
|
|
#include "gfxPrefs.h" // for gfxPrefs
|
2015-05-29 18:01:46 +03:00
|
|
|
#include "gfxPoint.h" // for IntSize, gfxPoint
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxRect.h" // for gfxRect
|
|
|
|
#include "gfxUtils.h" // for gfxUtils
|
2013-12-20 20:46:28 +04:00
|
|
|
#include "gfx2DGlue.h" // for thebes --> moz2d transition
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
|
|
#include "mozilla/WidgetUtils.h" // for ScreenRotation
|
|
|
|
#include "mozilla/gfx/2D.h" // for DrawTarget
|
|
|
|
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
|
|
|
#include "mozilla/gfx/BaseRect.h" // for BaseRect
|
|
|
|
#include "mozilla/gfx/Matrix.h" // for Matrix
|
2014-10-19 13:22:47 +04:00
|
|
|
#include "mozilla/gfx/PathHelpers.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/gfx/Rect.h" // for IntRect, Rect
|
|
|
|
#include "mozilla/layers/LayersTypes.h" // for BufferMode::BUFFER_NONE, etc
|
|
|
|
#include "mozilla/mozalloc.h" // for operator new
|
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
|
|
|
#include "nsDebug.h" // for NS_ASSERTION, etc
|
|
|
|
#include "nsISupportsImpl.h" // for gfxContext::Release, etc
|
|
|
|
#include "nsPoint.h" // for nsIntPoint
|
2015-05-07 12:07:35 +03:00
|
|
|
#include "nsRect.h" // for mozilla::gfx::IntRect
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsRegion.h" // for nsIntRegion, etc
|
2016-02-02 18:36:30 +03:00
|
|
|
#include "nsTArray.h" // for AutoTArray
|
2016-03-10 12:20:40 +03:00
|
|
|
#include "TreeTraversal.h" // for ForEachNode
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
class nsIWidget;
|
2012-10-04 22:45:16 +04:00
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
namespace mozilla {
|
2012-07-12 16:51:57 +04:00
|
|
|
namespace layers {
|
2012-06-29 10:01:34 +04:00
|
|
|
|
2014-05-22 14:11:45 +04:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
/**
|
|
|
|
* Clips to the smallest device-pixel-aligned rectangle containing aRect
|
|
|
|
* in user space.
|
|
|
|
* Returns true if the clip is "perfect", i.e. we actually clipped exactly to
|
|
|
|
* aRect.
|
|
|
|
*/
|
|
|
|
static bool
|
2015-05-07 12:07:35 +03:00
|
|
|
ClipToContain(gfxContext* aContext, const IntRect& aRect)
|
2012-06-29 10:01:34 +04:00
|
|
|
{
|
|
|
|
gfxRect userRect(aRect.x, aRect.y, aRect.width, aRect.height);
|
|
|
|
gfxRect deviceRect = aContext->UserToDevice(userRect);
|
|
|
|
deviceRect.RoundOut();
|
|
|
|
|
|
|
|
gfxMatrix currentMatrix = aContext->CurrentMatrix();
|
2014-09-11 10:57:39 +04:00
|
|
|
aContext->SetMatrix(gfxMatrix());
|
2012-06-29 10:01:34 +04:00
|
|
|
aContext->NewPath();
|
|
|
|
aContext->Rectangle(deviceRect);
|
|
|
|
aContext->Clip();
|
|
|
|
aContext->SetMatrix(currentMatrix);
|
|
|
|
|
|
|
|
return aContext->DeviceToUser(deviceRect).IsEqualInterior(userRect);
|
|
|
|
}
|
|
|
|
|
2016-07-04 21:14:00 +03:00
|
|
|
bool
|
|
|
|
BasicLayerManager::PushGroupForLayer(gfxContext* aContext, Layer* aLayer, const nsIntRegion& aRegion, PushedGroup& aGroupResult)
|
2012-06-29 10:01:34 +04:00
|
|
|
{
|
2016-07-04 21:14:00 +03:00
|
|
|
aGroupResult.mVisibleRegion = aRegion;
|
|
|
|
aGroupResult.mFinalTarget = aContext;
|
|
|
|
aGroupResult.mOperator = GetEffectiveOperator(aLayer);
|
|
|
|
aGroupResult.mOpacity = aLayer->GetEffectiveOpacity();
|
2015-11-11 18:15:39 +03:00
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
// If we need to call PushGroup, we should clip to the smallest possible
|
|
|
|
// area first to minimize the size of the temporary surface.
|
|
|
|
bool didCompleteClip = ClipToContain(aContext, aRegion.GetBounds());
|
|
|
|
|
2016-07-04 21:14:00 +03:00
|
|
|
bool canPushGroup = aGroupResult.mOperator == CompositionOp::OP_OVER ||
|
|
|
|
(aGroupResult.mOperator == CompositionOp::OP_SOURCE && (aLayer->CanUseOpaqueSurface() || aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA));
|
2015-11-11 18:15:39 +03:00
|
|
|
|
|
|
|
if (!canPushGroup) {
|
|
|
|
aContext->Save();
|
2016-07-04 21:14:00 +03:00
|
|
|
gfxUtils::ClipToRegion(aGroupResult.mFinalTarget, aGroupResult.mVisibleRegion);
|
2015-11-11 18:15:39 +03:00
|
|
|
|
|
|
|
// PushGroup/PopGroup do not support non operator over.
|
|
|
|
gfxMatrix oldMat = aContext->CurrentMatrix();
|
|
|
|
aContext->SetMatrix(gfxMatrix());
|
|
|
|
gfxRect rect = aContext->GetClipExtents();
|
|
|
|
aContext->SetMatrix(oldMat);
|
|
|
|
rect.RoundOut();
|
|
|
|
IntRect surfRect;
|
|
|
|
ToRect(rect).ToIntRect(&surfRect);
|
|
|
|
|
2015-11-17 18:27:17 +03:00
|
|
|
if (!surfRect.IsEmpty()) {
|
|
|
|
RefPtr<DrawTarget> dt = aContext->GetDrawTarget()->CreateSimilarDrawTarget(surfRect.Size(), SurfaceFormat::B8G8R8A8);
|
2015-11-11 18:15:39 +03:00
|
|
|
|
2016-06-07 02:39:56 +03:00
|
|
|
RefPtr<gfxContext> ctx =
|
|
|
|
gfxContext::CreateOrNull(dt, ToRect(rect).TopLeft());
|
2016-04-12 22:18:11 +03:00
|
|
|
if (!ctx) {
|
2016-07-04 21:14:00 +03:00
|
|
|
gfxCriticalNote << "BasicLayerManager context problem in PushGroupForLayer " << gfx::hexa(dt);
|
|
|
|
return false;
|
2016-04-12 22:18:11 +03:00
|
|
|
}
|
2015-11-17 18:27:17 +03:00
|
|
|
ctx->SetMatrix(oldMat);
|
2015-11-11 18:15:39 +03:00
|
|
|
|
2016-07-04 21:14:00 +03:00
|
|
|
aGroupResult.mGroupOffset = surfRect.TopLeft();
|
|
|
|
aGroupResult.mGroupTarget = ctx;
|
2015-11-11 18:15:39 +03:00
|
|
|
|
2016-07-04 21:14:00 +03:00
|
|
|
aGroupResult.mMaskSurface = GetMaskForLayer(aLayer, &aGroupResult.mMaskTransform);
|
|
|
|
return true;
|
2015-11-17 18:27:17 +03:00
|
|
|
}
|
2016-02-05 15:53:45 +03:00
|
|
|
aContext->Restore();
|
2015-11-11 18:15:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Matrix maskTransform;
|
|
|
|
RefPtr<SourceSurface> maskSurf = GetMaskForLayer(aLayer, &maskTransform);
|
|
|
|
|
2015-11-26 17:51:49 +03:00
|
|
|
if (maskSurf) {
|
|
|
|
// The returned transform will transform the mask to device space on the
|
|
|
|
// destination. Since the User->Device space transform will be applied
|
|
|
|
// to the mask by PopGroupAndBlend we need to adjust the transform to
|
|
|
|
// transform the mask to user space.
|
2016-07-04 21:14:00 +03:00
|
|
|
Matrix currentTransform = ToMatrix(aGroupResult.mFinalTarget->CurrentMatrix());
|
2015-11-26 17:51:49 +03:00
|
|
|
currentTransform.Invert();
|
|
|
|
maskTransform = maskTransform * currentTransform;
|
|
|
|
}
|
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
if (aLayer->CanUseOpaqueSurface() &&
|
|
|
|
((didCompleteClip && aRegion.GetNumRects() == 1) ||
|
|
|
|
!aContext->CurrentMatrix().HasNonIntegerTranslation())) {
|
2014-01-23 22:26:40 +04:00
|
|
|
// If the layer is opaque in its visible region we can push a gfxContentType::COLOR
|
2012-06-29 10:01:34 +04:00
|
|
|
// group. We need to make sure that only pixels inside the layer's visible
|
|
|
|
// region are copied back to the destination. Remember if we've already
|
|
|
|
// clipped precisely to the visible region.
|
2016-07-04 21:14:00 +03:00
|
|
|
aGroupResult.mNeedsClipToVisibleRegion = !didCompleteClip || aRegion.GetNumRects() > 1;
|
|
|
|
if (aGroupResult.mNeedsClipToVisibleRegion) {
|
|
|
|
aGroupResult.mFinalTarget->Save();
|
|
|
|
gfxUtils::ClipToRegion(aGroupResult.mFinalTarget, aGroupResult.mVisibleRegion);
|
2015-11-11 18:15:39 +03:00
|
|
|
}
|
|
|
|
|
2016-07-04 21:14:00 +03:00
|
|
|
aContext->PushGroupForBlendBack(gfxContentType::COLOR, aGroupResult.mOpacity, maskSurf, maskTransform);
|
2012-06-29 10:01:34 +04:00
|
|
|
} else {
|
2012-08-01 14:03:42 +04:00
|
|
|
if (aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) {
|
2016-07-04 21:14:00 +03:00
|
|
|
aContext->PushGroupAndCopyBackground(gfxContentType::COLOR_ALPHA, aGroupResult.mOpacity, maskSurf, maskTransform);
|
2012-08-01 14:03:42 +04:00
|
|
|
} else {
|
2016-07-04 21:14:00 +03:00
|
|
|
aContext->PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, aGroupResult.mOpacity, maskSurf, maskTransform);
|
2012-08-01 14:03:42 +04:00
|
|
|
}
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
2015-11-11 18:15:39 +03:00
|
|
|
|
2016-07-04 21:14:00 +03:00
|
|
|
aGroupResult.mGroupTarget = aGroupResult.mFinalTarget;
|
|
|
|
|
|
|
|
return true;
|
2015-11-11 18:15:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BasicLayerManager::PopGroupForLayer(PushedGroup &group)
|
|
|
|
{
|
|
|
|
if (group.mFinalTarget == group.mGroupTarget) {
|
|
|
|
group.mFinalTarget->PopGroupAndBlend();
|
|
|
|
if (group.mNeedsClipToVisibleRegion) {
|
|
|
|
group.mFinalTarget->Restore();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawTarget* dt = group.mFinalTarget->GetDrawTarget();
|
|
|
|
RefPtr<DrawTarget> sourceDT = group.mGroupTarget->GetDrawTarget();
|
|
|
|
group.mGroupTarget = nullptr;
|
|
|
|
|
|
|
|
RefPtr<SourceSurface> src = sourceDT->Snapshot();
|
|
|
|
|
|
|
|
if (group.mMaskSurface) {
|
2015-11-26 17:51:49 +03:00
|
|
|
Point finalOffset = group.mFinalTarget->GetDeviceOffset();
|
|
|
|
dt->SetTransform(group.mMaskTransform * Matrix::Translation(-finalOffset));
|
|
|
|
Matrix surfTransform = group.mMaskTransform;
|
|
|
|
surfTransform.Invert();
|
|
|
|
dt->MaskSurface(SurfacePattern(src, ExtendMode::CLAMP, surfTransform *
|
|
|
|
Matrix::Translation(group.mGroupOffset.x, group.mGroupOffset.y)),
|
2015-11-11 18:15:39 +03:00
|
|
|
group.mMaskSurface, Point(0, 0), DrawOptions(group.mOpacity, group.mOperator));
|
|
|
|
} else {
|
|
|
|
// For now this is required since our group offset is in device space of the final target,
|
|
|
|
// context but that may still have its own device offset. Once PushGroup/PopGroup logic is
|
|
|
|
// migrated to DrawTargets this can go as gfxContext::GetDeviceOffset will essentially
|
|
|
|
// always become null.
|
|
|
|
dt->SetTransform(Matrix::Translation(-group.mFinalTarget->GetDeviceOffset()));
|
|
|
|
dt->DrawSurface(src, Rect(group.mGroupOffset.x, group.mGroupOffset.y, src->GetSize().width, src->GetSize().height),
|
2016-05-25 19:01:18 +03:00
|
|
|
Rect(0, 0, src->GetSize().width, src->GetSize().height), DrawSurfaceOptions(SamplingFilter::POINT), DrawOptions(group.mOpacity, group.mOperator));
|
2015-11-11 18:15:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (group.mNeedsClipToVisibleRegion) {
|
|
|
|
dt->PopClip();
|
|
|
|
}
|
|
|
|
|
|
|
|
group.mFinalTarget->Restore();
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
|
2015-05-07 12:07:35 +03:00
|
|
|
static IntRect
|
2012-06-29 10:01:34 +04:00
|
|
|
ToInsideIntRect(const gfxRect& aRect)
|
|
|
|
{
|
|
|
|
gfxRect r = aRect;
|
|
|
|
r.RoundIn();
|
2015-05-07 12:07:35 +03:00
|
|
|
return IntRect(r.X(), r.Y(), r.Width(), r.Height());
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
|
2012-09-11 02:31:38 +04:00
|
|
|
// A context helper for BasicLayerManager::PaintLayer() that holds all the
|
|
|
|
// painting context together in a data structure so it can be easily passed
|
|
|
|
// around. It also uses ensures that the Transform and Opaque rect are restored
|
|
|
|
// to their former state on destruction.
|
|
|
|
|
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
|
|
|
class PaintLayerContext {
|
2012-09-11 02:31:38 +04:00
|
|
|
public:
|
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
|
|
|
PaintLayerContext(gfxContext* aTarget, Layer* aLayer,
|
2014-09-26 21:06:08 +04:00
|
|
|
LayerManager::DrawPaintedLayerCallback aCallback,
|
2014-05-12 04:31:28 +04:00
|
|
|
void* aCallbackData)
|
2012-09-11 02:31:38 +04:00
|
|
|
: mTarget(aTarget)
|
|
|
|
, mTargetMatrixSR(aTarget)
|
|
|
|
, mLayer(aLayer)
|
|
|
|
, mCallback(aCallback)
|
|
|
|
, mCallbackData(aCallbackData)
|
|
|
|
, mPushedOpaqueRect(false)
|
|
|
|
{}
|
|
|
|
|
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
|
|
|
~PaintLayerContext()
|
2012-09-11 02:31:38 +04:00
|
|
|
{
|
|
|
|
// Matrix is restored by mTargetMatrixSR
|
|
|
|
if (mPushedOpaqueRect)
|
|
|
|
{
|
|
|
|
ClearOpaqueRect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-07 16:32:21 +04:00
|
|
|
// Gets the effective transform and returns true if it is a 2D
|
|
|
|
// transform.
|
|
|
|
bool Setup2DTransform()
|
2012-09-11 02:31:38 +04:00
|
|
|
{
|
|
|
|
// Will return an identity matrix for 3d transforms.
|
2014-12-07 04:12:50 +03:00
|
|
|
return mLayer->GetEffectiveTransformForBuffer().CanDraw2D(&mTransform);
|
2012-09-07 16:32:21 +04:00
|
|
|
}
|
2012-09-11 02:31:38 +04:00
|
|
|
|
2012-09-07 16:32:21 +04:00
|
|
|
// Applies the effective transform if it's 2D. If it's a 3D transform then
|
|
|
|
// it applies an identity.
|
|
|
|
void Apply2DTransform()
|
|
|
|
{
|
2014-01-28 00:25:19 +04:00
|
|
|
mTarget->SetMatrix(ThebesMatrix(mTransform));
|
2012-09-11 02:31:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the opaque rect to match the bounds of the visible region.
|
|
|
|
void AnnotateOpaqueRect()
|
|
|
|
{
|
2016-02-14 03:50:51 +03:00
|
|
|
const nsIntRegion visibleRegion = mLayer->GetLocalVisibleRegion().ToUnknownRegion();
|
2015-05-07 12:07:35 +03:00
|
|
|
const IntRect& bounds = visibleRegion.GetBounds();
|
2012-09-11 02:31:38 +04:00
|
|
|
|
2014-07-10 13:58:08 +04:00
|
|
|
DrawTarget *dt = mTarget->GetDrawTarget();
|
|
|
|
const IntRect& targetOpaqueRect = dt->GetOpaqueRect();
|
|
|
|
|
|
|
|
// Try to annotate currentSurface with a region of pixels that have been
|
|
|
|
// (or will be) painted opaque, if no such region is currently set.
|
|
|
|
if (targetOpaqueRect.IsEmpty() && visibleRegion.GetNumRects() == 1 &&
|
|
|
|
(mLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) &&
|
|
|
|
!mTransform.HasNonAxisAlignedTransform()) {
|
|
|
|
|
|
|
|
gfx::Rect opaqueRect = dt->GetTransform().TransformBounds(
|
|
|
|
gfx::Rect(bounds.x, bounds.y, bounds.width, bounds.height));
|
|
|
|
opaqueRect.RoundIn();
|
|
|
|
IntRect intOpaqueRect;
|
|
|
|
if (opaqueRect.ToIntRect(&intOpaqueRect)) {
|
|
|
|
mTarget->GetDrawTarget()->SetOpaqueRect(intOpaqueRect);
|
2012-09-11 02:31:38 +04:00
|
|
|
mPushedOpaqueRect = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear the Opaque rect. Although this doesn't really restore it to it's
|
|
|
|
// previous state it will happen on the exit path of the PaintLayer() so when
|
|
|
|
// painting is complete the opaque rect qill be clear.
|
|
|
|
void ClearOpaqueRect() {
|
2014-07-10 13:58:08 +04:00
|
|
|
mTarget->GetDrawTarget()->SetOpaqueRect(IntRect());
|
2012-09-11 02:31:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxContext* mTarget;
|
|
|
|
gfxContextMatrixAutoSaveRestore mTargetMatrixSR;
|
|
|
|
Layer* mLayer;
|
2014-09-26 21:06:08 +04:00
|
|
|
LayerManager::DrawPaintedLayerCallback mCallback;
|
2012-09-11 02:31:38 +04:00
|
|
|
void* mCallbackData;
|
2014-01-28 00:25:19 +04:00
|
|
|
Matrix mTransform;
|
2012-09-11 02:31:38 +04:00
|
|
|
bool mPushedOpaqueRect;
|
|
|
|
};
|
|
|
|
|
2014-06-19 22:22:17 +04:00
|
|
|
BasicLayerManager::BasicLayerManager(nsIWidget* aWidget)
|
|
|
|
: mPhase(PHASE_NONE)
|
|
|
|
, mWidget(aWidget)
|
|
|
|
, mDoubleBuffering(BufferMode::BUFFER_NONE)
|
|
|
|
, mType(BLM_WIDGET)
|
|
|
|
, mUsingDefaultTarget(false)
|
2012-06-29 10:01:34 +04:00
|
|
|
, mTransactionIncomplete(false)
|
2012-09-25 08:15:18 +04:00
|
|
|
, mCompositorMightResample(false)
|
2012-06-29 10:01:34 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(BasicLayerManager);
|
|
|
|
NS_ASSERTION(aWidget, "Must provide a widget");
|
|
|
|
}
|
|
|
|
|
2014-06-19 22:22:17 +04:00
|
|
|
BasicLayerManager::BasicLayerManager(BasicLayerManagerType aType)
|
|
|
|
: mPhase(PHASE_NONE)
|
|
|
|
, mWidget(nullptr)
|
|
|
|
, mDoubleBuffering(BufferMode::BUFFER_NONE)
|
|
|
|
, mType(aType)
|
|
|
|
, mUsingDefaultTarget(false)
|
2012-06-29 10:01:34 +04:00
|
|
|
, mTransactionIncomplete(false)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(BasicLayerManager);
|
2014-06-19 22:22:17 +04:00
|
|
|
MOZ_ASSERT(mType != BLM_WIDGET);
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BasicLayerManager::~BasicLayerManager()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!InTransaction(), "Died during transaction?");
|
|
|
|
|
|
|
|
ClearCachedResources();
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mRoot = nullptr;
|
2012-06-29 10:01:34 +04:00
|
|
|
|
|
|
|
MOZ_COUNT_DTOR(BasicLayerManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-15 05:10:40 +04:00
|
|
|
BasicLayerManager::SetDefaultTarget(gfxContext* aContext)
|
2012-06-29 10:01:34 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!InTransaction(),
|
|
|
|
"Must set default target outside transaction");
|
|
|
|
mDefaultTarget = aContext;
|
2012-08-15 05:10:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BasicLayerManager::SetDefaultTargetConfiguration(BufferMode aDoubleBuffering, ScreenRotation aRotation)
|
|
|
|
{
|
2012-06-29 10:01:34 +04:00
|
|
|
mDoubleBuffering = aDoubleBuffering;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BasicLayerManager::BeginTransaction()
|
|
|
|
{
|
2012-08-16 01:55:38 +04:00
|
|
|
mInTransaction = true;
|
2012-06-29 10:01:34 +04:00
|
|
|
mUsingDefaultTarget = true;
|
|
|
|
BeginTransactionWithTarget(mDefaultTarget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BasicLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
|
|
|
|
{
|
2012-08-16 01:55:38 +04:00
|
|
|
mInTransaction = true;
|
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
#ifdef MOZ_LAYERS_HAVE_LOG
|
|
|
|
MOZ_LAYERS_LOG(("[----- BeginTransaction"));
|
|
|
|
Log();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_ASSERTION(!InTransaction(), "Nested transactions not allowed");
|
|
|
|
mPhase = PHASE_CONSTRUCTION;
|
|
|
|
mTarget = aTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-05-07 12:07:35 +03:00
|
|
|
TransformIntRect(IntRect& aRect, const Matrix& aMatrix,
|
|
|
|
IntRect (*aRoundMethod)(const gfxRect&))
|
2012-06-29 10:01:34 +04:00
|
|
|
{
|
2014-01-28 00:25:19 +04:00
|
|
|
Rect gr = Rect(aRect.x, aRect.y, aRect.width, aRect.height);
|
2012-06-29 10:01:34 +04:00
|
|
|
gr = aMatrix.TransformBounds(gr);
|
2014-01-28 00:25:19 +04:00
|
|
|
aRect = (*aRoundMethod)(ThebesRect(gr));
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function assumes that GetEffectiveTransform transforms
|
|
|
|
* all layers to the same coordinate system (the "root coordinate system").
|
|
|
|
* It can't be used as is by accelerated layers because of intermediate surfaces.
|
|
|
|
* This must set the hidden flag to true or false on *all* layers in the subtree.
|
|
|
|
* It also sets the operator for all layers to "OVER", and call
|
|
|
|
* SetDrawAtomically(false).
|
|
|
|
* It clears mClipToVisibleRegion on all layers.
|
|
|
|
* @param aClipRect the cliprect, in the root coordinate system. We assume
|
|
|
|
* that any layer drawing is clipped to this rect. It is therefore not
|
|
|
|
* allowed to add to the opaque region outside that rect.
|
|
|
|
* @param aDirtyRect the dirty rect that will be painted, in the root
|
|
|
|
* coordinate system. Layers outside this rect should be hidden.
|
|
|
|
* @param aOpaqueRegion the opaque region covering aLayer, in the
|
|
|
|
* root coordinate system.
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
ALLOW_OPAQUE = 0x01,
|
|
|
|
};
|
|
|
|
static void
|
2015-05-07 12:07:35 +03:00
|
|
|
MarkLayersHidden(Layer* aLayer, const IntRect& aClipRect,
|
|
|
|
const IntRect& aDirtyRect,
|
2012-06-29 10:01:34 +04:00
|
|
|
nsIntRegion& aOpaqueRegion,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags)
|
2012-06-29 10:01:34 +04:00
|
|
|
{
|
2015-05-07 12:07:35 +03:00
|
|
|
IntRect newClipRect(aClipRect);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t newFlags = aFlags;
|
2012-06-29 10:01:34 +04:00
|
|
|
|
|
|
|
// Allow aLayer or aLayer's descendants to cover underlying layers
|
|
|
|
// only if it's opaque.
|
|
|
|
if (aLayer->GetOpacity() != 1.0f) {
|
|
|
|
newFlags &= ~ALLOW_OPAQUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2016-05-02 18:27:35 +03:00
|
|
|
const Maybe<ParentLayerIntRect>& clipRect = aLayer->GetLocalClipRect();
|
2012-06-29 10:01:34 +04:00
|
|
|
if (clipRect) {
|
2015-11-07 06:13:40 +03:00
|
|
|
IntRect cr = clipRect->ToUnknownRect();
|
2012-06-29 10:01:34 +04:00
|
|
|
// clipRect is in the container's coordinate system. Get it into the
|
|
|
|
// global coordinate system.
|
|
|
|
if (aLayer->GetParent()) {
|
2014-01-28 00:25:19 +04:00
|
|
|
Matrix tr;
|
|
|
|
if (aLayer->GetParent()->GetEffectiveTransform().CanDraw2D(&tr)) {
|
2012-06-29 10:01:34 +04:00
|
|
|
// Clip rect is applied after aLayer's transform, i.e., in the coordinate
|
|
|
|
// system of aLayer's parent.
|
|
|
|
TransformIntRect(cr, tr, ToInsideIntRect);
|
|
|
|
} else {
|
|
|
|
cr.SetRect(0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
newClipRect.IntersectRect(newClipRect, cr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BasicImplData* data = ToData(aLayer);
|
2014-02-12 19:07:46 +04:00
|
|
|
data->SetOperator(CompositionOp::OP_OVER);
|
2012-06-29 10:01:34 +04:00
|
|
|
data->SetClipToVisibleRegion(false);
|
|
|
|
data->SetDrawAtomically(false);
|
|
|
|
|
|
|
|
if (!aLayer->AsContainerLayer()) {
|
2014-01-28 00:25:19 +04:00
|
|
|
Matrix transform;
|
|
|
|
if (!aLayer->GetEffectiveTransform().CanDraw2D(&transform)) {
|
2012-06-29 10:01:34 +04:00
|
|
|
data->SetHidden(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-14 03:50:51 +03:00
|
|
|
nsIntRegion region = aLayer->GetLocalVisibleRegion().ToUnknownRegion();
|
2015-05-07 12:07:35 +03:00
|
|
|
IntRect r = region.GetBounds();
|
2012-06-29 10:01:34 +04:00
|
|
|
TransformIntRect(r, transform, ToOutsideIntRect);
|
|
|
|
r.IntersectRect(r, aDirtyRect);
|
|
|
|
data->SetHidden(aOpaqueRegion.Contains(r));
|
|
|
|
|
|
|
|
// Allow aLayer to cover underlying layers only if aLayer's
|
|
|
|
// content is opaque
|
|
|
|
if ((aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) &&
|
|
|
|
(newFlags & ALLOW_OPAQUE)) {
|
2016-01-19 04:20:58 +03:00
|
|
|
for (auto iter = region.RectIter(); !iter.Done(); iter.Next()) {
|
|
|
|
r = iter.Get();
|
2012-06-29 10:01:34 +04:00
|
|
|
TransformIntRect(r, transform, ToInsideIntRect);
|
|
|
|
|
|
|
|
r.IntersectRect(r, newClipRect);
|
|
|
|
aOpaqueRegion.Or(aOpaqueRegion, r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Layer* child = aLayer->GetLastChild();
|
|
|
|
bool allHidden = true;
|
|
|
|
for (; child; child = child->GetPrevSibling()) {
|
|
|
|
MarkLayersHidden(child, newClipRect, aDirtyRect, aOpaqueRegion, newFlags);
|
|
|
|
if (!ToData(child)->IsHidden()) {
|
|
|
|
allHidden = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data->SetHidden(allHidden);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function assumes that GetEffectiveTransform transforms
|
|
|
|
* all layers to the same coordinate system (the "root coordinate system").
|
|
|
|
* MarkLayersHidden must be called before calling this.
|
|
|
|
* @param aVisibleRect the rectangle of aLayer that is visible (i.e. not
|
|
|
|
* clipped and in the dirty rect), in the root coordinate system.
|
|
|
|
*/
|
|
|
|
static void
|
2015-05-07 12:07:35 +03:00
|
|
|
ApplyDoubleBuffering(Layer* aLayer, const IntRect& aVisibleRect)
|
2012-06-29 10:01:34 +04:00
|
|
|
{
|
2016-07-07 06:14:02 +03:00
|
|
|
BasicImplData* data = ToData(aLayer);
|
|
|
|
if (data->IsHidden())
|
|
|
|
return;
|
2012-06-29 10:01:34 +04:00
|
|
|
|
2016-07-07 06:14:02 +03:00
|
|
|
IntRect newVisibleRect(aVisibleRect);
|
2012-06-29 10:01:34 +04:00
|
|
|
|
2016-07-07 06:14:02 +03:00
|
|
|
{
|
|
|
|
const Maybe<ParentLayerIntRect>& clipRect = aLayer->GetLocalClipRect();
|
|
|
|
if (clipRect) {
|
|
|
|
IntRect cr = clipRect->ToUnknownRect();
|
|
|
|
// clipRect is in the container's coordinate system. Get it into the
|
|
|
|
// global coordinate system.
|
|
|
|
if (aLayer->GetParent()) {
|
|
|
|
Matrix tr;
|
|
|
|
if (aLayer->GetParent()->GetEffectiveTransform().CanDraw2D(&tr)) {
|
|
|
|
NS_ASSERTION(!ThebesMatrix(tr).HasNonIntegerTranslation(),
|
|
|
|
"Parent can only have an integer translation");
|
|
|
|
cr += nsIntPoint(int32_t(tr._31), int32_t(tr._32));
|
2012-06-29 10:01:34 +04:00
|
|
|
} else {
|
2016-07-07 06:14:02 +03:00
|
|
|
NS_ERROR("Parent can only have an integer translation");
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
2016-07-07 06:14:02 +03:00
|
|
|
}
|
|
|
|
newVisibleRect.IntersectRect(newVisibleRect, cr);
|
|
|
|
}
|
|
|
|
}
|
2012-06-29 10:01:34 +04:00
|
|
|
|
2016-07-07 06:14:02 +03:00
|
|
|
BasicContainerLayer* container =
|
|
|
|
static_cast<BasicContainerLayer*>(aLayer->AsContainerLayer());
|
|
|
|
// Layers that act as their own backbuffers should be drawn to the destination
|
|
|
|
// using OP_SOURCE to ensure that alpha values in a transparent window are
|
|
|
|
// cleared. This can also be faster than OP_OVER.
|
|
|
|
if (!container) {
|
|
|
|
data->SetOperator(CompositionOp::OP_SOURCE);
|
|
|
|
data->SetDrawAtomically(true);
|
|
|
|
} else {
|
|
|
|
if (container->UseIntermediateSurface() ||
|
|
|
|
!container->ChildrenPartitionVisibleRegion(newVisibleRect)) {
|
|
|
|
// We need to double-buffer this container.
|
|
|
|
data->SetOperator(CompositionOp::OP_SOURCE);
|
|
|
|
container->ForceIntermediateSurface();
|
|
|
|
} else {
|
|
|
|
// Tell the children to clip to their visible regions so our assumption
|
|
|
|
// that they don't paint outside their visible regions is valid!
|
|
|
|
for (Layer* child = aLayer->GetFirstChild(); child;
|
|
|
|
child = child->GetNextSibling()) {
|
|
|
|
ToData(child)->SetClipToVisibleRegion(true);
|
|
|
|
ApplyDoubleBuffering(child, newVisibleRect);
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
2016-07-07 06:14:02 +03:00
|
|
|
}
|
|
|
|
}
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-26 21:06:08 +04:00
|
|
|
BasicLayerManager::EndTransaction(DrawPaintedLayerCallback aCallback,
|
2012-06-29 10:01:34 +04:00
|
|
|
void* aCallbackData,
|
|
|
|
EndTransactionFlags aFlags)
|
|
|
|
{
|
2012-08-16 01:55:38 +04:00
|
|
|
mInTransaction = false;
|
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
EndTransactionInternal(aCallback, aCallbackData, aFlags);
|
|
|
|
}
|
2012-07-20 08:53:55 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
BasicLayerManager::AbortTransaction()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(InConstruction(), "Should be in construction phase");
|
|
|
|
mPhase = PHASE_NONE;
|
|
|
|
mUsingDefaultTarget = false;
|
2012-08-16 01:55:38 +04:00
|
|
|
mInTransaction = false;
|
2012-07-20 08:53:55 +04:00
|
|
|
}
|
2012-06-29 10:01:34 +04:00
|
|
|
|
|
|
|
bool
|
2014-09-26 21:06:08 +04:00
|
|
|
BasicLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback,
|
2012-06-29 10:01:34 +04:00
|
|
|
void* aCallbackData,
|
|
|
|
EndTransactionFlags aFlags)
|
|
|
|
{
|
2014-05-24 01:12:29 +04:00
|
|
|
PROFILER_LABEL("BasicLayerManager", "EndTransactionInternal",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
#ifdef MOZ_LAYERS_HAVE_LOG
|
|
|
|
MOZ_LAYERS_LOG((" ----- (beginning paint)"));
|
|
|
|
Log();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_ASSERTION(InConstruction(), "Should be in construction phase");
|
|
|
|
mPhase = PHASE_DRAWING;
|
|
|
|
|
2013-10-15 07:23:21 +04:00
|
|
|
RenderTraceLayers(mRoot, "FF00");
|
2012-06-29 10:01:34 +04:00
|
|
|
|
|
|
|
mTransactionIncomplete = false;
|
|
|
|
|
2013-10-15 07:23:21 +04:00
|
|
|
if (mRoot) {
|
2014-11-11 05:01:28 +03:00
|
|
|
if (aFlags & END_NO_COMPOSITE) {
|
|
|
|
// Apply pending tree updates before recomputing effective
|
|
|
|
// properties.
|
|
|
|
mRoot->ApplyPendingUpdatesToSubtree();
|
|
|
|
}
|
|
|
|
|
2013-10-15 07:23:21 +04:00
|
|
|
// Need to do this before we call ApplyDoubleBuffering,
|
|
|
|
// which depends on correct effective transforms
|
2014-10-19 13:22:47 +04:00
|
|
|
if (mTarget) {
|
|
|
|
mSnapEffectiveTransforms =
|
|
|
|
!mTarget->GetDrawTarget()->GetUserData(&sDisablePixelSnapping);
|
|
|
|
} else {
|
|
|
|
mSnapEffectiveTransforms = true;
|
|
|
|
}
|
2014-01-27 19:28:04 +04:00
|
|
|
mRoot->ComputeEffectiveTransforms(mTarget ? Matrix4x4::From2D(ToMatrix(mTarget->CurrentMatrix())) : Matrix4x4());
|
2013-10-15 07:23:21 +04:00
|
|
|
|
2014-05-12 04:31:28 +04:00
|
|
|
ToData(mRoot)->Validate(aCallback, aCallbackData, nullptr);
|
2013-10-15 07:23:21 +04:00
|
|
|
if (mRoot->GetMaskLayer()) {
|
2014-05-12 04:31:28 +04:00
|
|
|
ToData(mRoot->GetMaskLayer())->Validate(aCallback, aCallbackData, nullptr);
|
2013-10-15 07:23:21 +04:00
|
|
|
}
|
2012-08-13 14:10:10 +04:00
|
|
|
}
|
|
|
|
|
2013-10-15 07:23:21 +04:00
|
|
|
if (mTarget && mRoot &&
|
|
|
|
!(aFlags & END_NO_IMMEDIATE_REDRAW) &&
|
|
|
|
!(aFlags & END_NO_COMPOSITE)) {
|
2015-05-07 12:07:35 +03:00
|
|
|
IntRect clipRect;
|
2013-10-15 07:23:21 +04:00
|
|
|
|
|
|
|
{
|
2012-06-29 10:01:34 +04:00
|
|
|
gfxContextMatrixAutoSaveRestore save(mTarget);
|
|
|
|
mTarget->SetMatrix(gfxMatrix());
|
|
|
|
clipRect = ToOutsideIntRect(mTarget->GetClipExtents());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsRetained()) {
|
|
|
|
nsIntRegion region;
|
|
|
|
MarkLayersHidden(mRoot, clipRect, clipRect, region, ALLOW_OPAQUE);
|
2014-01-23 22:26:41 +04:00
|
|
|
if (mUsingDefaultTarget && mDoubleBuffering != BufferMode::BUFFER_NONE) {
|
2012-06-29 10:01:34 +04:00
|
|
|
ApplyDoubleBuffering(mRoot, clipRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-12 04:31:28 +04:00
|
|
|
PaintLayer(mTarget, mRoot, aCallback, aCallbackData);
|
2014-02-13 04:20:41 +04:00
|
|
|
if (!mRegionToClear.IsEmpty()) {
|
2016-01-19 04:20:58 +03:00
|
|
|
for (auto iter = mRegionToClear.RectIter(); !iter.Done(); iter.Next()) {
|
|
|
|
const IntRect& r = iter.Get();
|
|
|
|
mTarget->GetDrawTarget()->ClearRect(Rect(r.x, r.y, r.width, r.height));
|
2014-02-13 04:20:41 +04:00
|
|
|
}
|
|
|
|
}
|
2013-10-15 07:23:21 +04:00
|
|
|
if (mWidget) {
|
|
|
|
FlashWidgetUpdateArea(mTarget);
|
2012-07-17 21:03:51 +04:00
|
|
|
}
|
2013-11-27 11:32:19 +04:00
|
|
|
RecordFrame();
|
|
|
|
PostPresent();
|
2012-06-29 10:01:34 +04:00
|
|
|
|
|
|
|
if (!mTransactionIncomplete) {
|
|
|
|
// Clear out target if we have a complete transaction.
|
2012-07-30 18:20:58 +04:00
|
|
|
mTarget = nullptr;
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-22 03:35:41 +03:00
|
|
|
if (mRoot) {
|
|
|
|
mAnimationReadyTime = TimeStamp::Now();
|
2014-12-22 03:35:41 +03:00
|
|
|
mRoot->StartPendingAnimations(mAnimationReadyTime);
|
2014-12-22 03:35:41 +03:00
|
|
|
}
|
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
#ifdef MOZ_LAYERS_HAVE_LOG
|
|
|
|
Log();
|
|
|
|
MOZ_LAYERS_LOG(("]----- EndTransaction"));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Go back to the construction phase if the transaction isn't complete.
|
|
|
|
// Layout will update the layer tree and call EndTransaction().
|
|
|
|
mPhase = mTransactionIncomplete ? PHASE_CONSTRUCTION : PHASE_NONE;
|
|
|
|
|
|
|
|
if (!mTransactionIncomplete) {
|
|
|
|
// This is still valid if the transaction was incomplete.
|
|
|
|
mUsingDefaultTarget = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(!aCallback || !mTransactionIncomplete,
|
|
|
|
"If callback is not null, transaction must be complete");
|
|
|
|
|
|
|
|
// XXX - We should probably assert here that for an incomplete transaction
|
|
|
|
// out target is the default target.
|
|
|
|
|
|
|
|
return !mTransactionIncomplete;
|
|
|
|
}
|
|
|
|
|
2012-07-17 21:03:51 +04:00
|
|
|
void
|
|
|
|
BasicLayerManager::FlashWidgetUpdateArea(gfxContext *aContext)
|
|
|
|
{
|
2014-02-27 06:53:32 +04:00
|
|
|
if (gfxPrefs::WidgetUpdateFlashing()) {
|
2012-07-17 21:03:51 +04:00
|
|
|
float r = float(rand()) / RAND_MAX;
|
|
|
|
float g = float(rand()) / RAND_MAX;
|
|
|
|
float b = float(rand()) / RAND_MAX;
|
2015-09-24 09:42:58 +03:00
|
|
|
aContext->SetColor(Color(r, g, b, 0.2f));
|
2012-07-17 21:03:51 +04:00
|
|
|
aContext->Paint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
bool
|
2012-08-13 14:10:10 +04:00
|
|
|
BasicLayerManager::EndEmptyTransaction(EndTransactionFlags aFlags)
|
2012-06-29 10:01:34 +04:00
|
|
|
{
|
2012-08-16 01:55:38 +04:00
|
|
|
mInTransaction = false;
|
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
if (!mRoot) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-13 14:10:10 +04:00
|
|
|
return EndTransactionInternal(nullptr, nullptr, aFlags);
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BasicLayerManager::SetRoot(Layer* aLayer)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aLayer, "Root can't be null");
|
|
|
|
NS_ASSERTION(aLayer->Manager() == this, "Wrong manager");
|
|
|
|
NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
|
|
|
|
mRoot = aLayer;
|
|
|
|
}
|
|
|
|
|
2012-09-11 02:31:38 +04:00
|
|
|
void
|
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
|
|
|
BasicLayerManager::PaintSelfOrChildren(PaintLayerContext& aPaintContext,
|
2012-09-11 02:31:38 +04:00
|
|
|
gfxContext* aGroupTarget)
|
|
|
|
{
|
2015-05-20 11:47:29 +03:00
|
|
|
MOZ_ASSERT(aGroupTarget);
|
2012-09-11 02:31:38 +04:00
|
|
|
BasicImplData* data = ToData(aPaintContext.mLayer);
|
|
|
|
|
|
|
|
/* Only paint ourself, or our children - This optimization relies on this! */
|
|
|
|
Layer* child = aPaintContext.mLayer->GetFirstChild();
|
|
|
|
if (!child) {
|
2014-09-26 21:06:08 +04:00
|
|
|
if (aPaintContext.mLayer->AsPaintedLayer()) {
|
2012-09-11 02:31:38 +04:00
|
|
|
data->PaintThebes(aGroupTarget, aPaintContext.mLayer->GetMaskLayer(),
|
2014-05-12 04:31:28 +04:00
|
|
|
aPaintContext.mCallback, aPaintContext.mCallbackData);
|
2012-09-11 02:31:38 +04:00
|
|
|
} else {
|
2014-04-01 08:02:10 +04:00
|
|
|
data->Paint(aGroupTarget->GetDrawTarget(),
|
2014-05-12 04:31:27 +04:00
|
|
|
aGroupTarget->GetDeviceOffset(),
|
2014-04-01 08:02:10 +04:00
|
|
|
aPaintContext.mLayer->GetMaskLayer());
|
2012-09-11 02:31:38 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ContainerLayer* container =
|
|
|
|
static_cast<ContainerLayer*>(aPaintContext.mLayer);
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<Layer*, 12> children;
|
2012-09-11 02:31:38 +04:00
|
|
|
container->SortChildrenBy3DZOrder(children);
|
|
|
|
for (uint32_t i = 0; i < children.Length(); i++) {
|
2015-09-17 04:31:00 +03:00
|
|
|
Layer* layer = children.ElementAt(i);
|
|
|
|
if (layer->IsBackfaceHidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!layer->AsContainerLayer() && !layer->IsVisible()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
PaintLayer(aGroupTarget, layer, aPaintContext.mCallback,
|
2014-05-12 04:31:28 +04:00
|
|
|
aPaintContext.mCallbackData);
|
2012-09-11 02:31:38 +04:00
|
|
|
if (mTransactionIncomplete)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-29 10:01:34 +04:00
|
|
|
|
2012-09-11 02:31:38 +04:00
|
|
|
void
|
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
|
|
|
BasicLayerManager::FlushGroup(PaintLayerContext& aPaintContext, bool aNeedsClipToVisibleRegion)
|
2012-09-11 02:31:38 +04:00
|
|
|
{
|
|
|
|
// If we're doing our own double-buffering, we need to avoid drawing
|
|
|
|
// the results of an incomplete transaction to the destination surface ---
|
|
|
|
// that could cause flicker. Double-buffering is implemented using a
|
|
|
|
// temporary surface for one or more container layers, so we need to stop
|
|
|
|
// those temporary surfaces from being composited to aTarget.
|
|
|
|
// ApplyDoubleBuffering guarantees that this container layer can't
|
|
|
|
// intersect any other leaf layers, so if the transaction is not yet marked
|
|
|
|
// incomplete, the contents of this container layer are the final contents
|
|
|
|
// for the window.
|
|
|
|
if (!mTransactionIncomplete) {
|
|
|
|
if (aNeedsClipToVisibleRegion) {
|
|
|
|
gfxUtils::ClipToRegion(aPaintContext.mTarget,
|
2016-02-14 03:50:51 +03:00
|
|
|
aPaintContext.mLayer->GetLocalVisibleRegion().ToUnknownRegion());
|
2012-09-11 02:31:38 +04:00
|
|
|
}
|
2014-02-27 20:56:48 +04:00
|
|
|
|
|
|
|
CompositionOp op = GetEffectiveOperator(aPaintContext.mLayer);
|
2015-09-25 08:38:58 +03:00
|
|
|
AutoSetOperator setOperator(aPaintContext.mTarget, op);
|
2014-02-27 20:56:48 +04:00
|
|
|
|
2012-09-11 02:31:38 +04:00
|
|
|
PaintWithMask(aPaintContext.mTarget, aPaintContext.mLayer->GetEffectiveOpacity(),
|
2013-10-15 07:23:21 +04:00
|
|
|
aPaintContext.mLayer->GetMaskLayer());
|
2012-09-11 02:31:38 +04:00
|
|
|
}
|
|
|
|
}
|
2012-06-29 10:01:34 +04:00
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
/**
|
|
|
|
* Install the clip applied to the layer on the given gfxContext. The
|
|
|
|
* given gfxContext is the buffer that the layer will be painted to.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
InstallLayerClipPreserves3D(gfxContext* aTarget, Layer* aLayer)
|
|
|
|
{
|
2016-05-02 18:27:35 +03:00
|
|
|
const Maybe<ParentLayerIntRect> &clipRect = aLayer->GetLocalClipRect();
|
2015-09-17 04:31:00 +03:00
|
|
|
|
|
|
|
if (!clipRect) {
|
|
|
|
return;
|
|
|
|
}
|
2015-10-23 06:29:00 +03:00
|
|
|
MOZ_ASSERT(!aLayer->Extend3DContext() ||
|
|
|
|
!aLayer->Combines3DTransformWithAncestors(),
|
|
|
|
"Layers in a preserve 3D context have no clip"
|
|
|
|
" except leaves and the estabisher!");
|
2015-09-17 04:31:00 +03:00
|
|
|
|
|
|
|
Layer* parent = aLayer->GetParent();
|
|
|
|
Matrix4x4 transform3d =
|
|
|
|
parent && parent->Extend3DContext() ?
|
|
|
|
parent->GetEffectiveTransform() :
|
|
|
|
Matrix4x4();
|
|
|
|
Matrix transform;
|
|
|
|
if (!transform3d.CanDraw2D(&transform)) {
|
2015-12-10 15:01:00 +03:00
|
|
|
gfxDevCrash(LogReason::CannotDraw3D) << "GFX: We should not have a 3D transform that CanDraw2D() is false!";
|
2015-09-17 04:31:00 +03:00
|
|
|
}
|
|
|
|
gfxMatrix oldTransform = aTarget->CurrentMatrix();
|
|
|
|
transform *= ToMatrix(oldTransform);
|
|
|
|
aTarget->SetMatrix(ThebesMatrix(transform));
|
|
|
|
|
|
|
|
aTarget->NewPath();
|
|
|
|
aTarget->SnappedRectangle(gfxRect(clipRect->x, clipRect->y,
|
|
|
|
clipRect->width, clipRect->height));
|
|
|
|
aTarget->Clip();
|
|
|
|
|
|
|
|
aTarget->SetMatrix(oldTransform);
|
|
|
|
}
|
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
void
|
|
|
|
BasicLayerManager::PaintLayer(gfxContext* aTarget,
|
|
|
|
Layer* aLayer,
|
2014-09-26 21:06:08 +04:00
|
|
|
DrawPaintedLayerCallback aCallback,
|
2014-05-12 04:31:28 +04:00
|
|
|
void* aCallbackData)
|
2012-06-29 10:01:34 +04:00
|
|
|
{
|
2015-05-20 11:47:29 +03:00
|
|
|
MOZ_ASSERT(aTarget);
|
|
|
|
|
2014-05-24 01:12:29 +04:00
|
|
|
PROFILER_LABEL("BasicLayerManager", "PaintLayer",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
2014-05-12 04:31:28 +04:00
|
|
|
PaintLayerContext paintLayerContext(aTarget, aLayer, aCallback, aCallbackData);
|
2012-09-11 02:31:38 +04:00
|
|
|
|
2012-11-30 02:11:04 +04:00
|
|
|
// Don't attempt to paint layers with a singular transform, cairo will
|
|
|
|
// just throw an error.
|
|
|
|
if (aLayer->GetEffectiveTransform().IsSingular()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
RenderTraceScope trace("BasicLayerManager::PaintLayer", "707070");
|
|
|
|
|
2016-05-02 18:27:35 +03:00
|
|
|
const Maybe<ParentLayerIntRect>& clipRect = aLayer->GetLocalClipRect();
|
2014-10-07 18:18:00 +04:00
|
|
|
BasicContainerLayer* container =
|
|
|
|
static_cast<BasicContainerLayer*>(aLayer->AsContainerLayer());
|
|
|
|
bool needsGroup = container && container->UseIntermediateSurface();
|
2012-06-29 10:01:34 +04:00
|
|
|
BasicImplData* data = ToData(aLayer);
|
|
|
|
bool needsClipToVisibleRegion =
|
2014-09-26 21:06:08 +04:00
|
|
|
data->GetClipToVisibleRegion() && !aLayer->AsPaintedLayer();
|
2014-10-07 18:18:00 +04:00
|
|
|
NS_ASSERTION(needsGroup || !container ||
|
2014-02-12 19:07:46 +04:00
|
|
|
container->GetOperator() == CompositionOp::OP_OVER,
|
2012-06-29 10:01:34 +04:00
|
|
|
"non-OVER operator should have forced UseIntermediateSurface");
|
2014-10-07 18:18:00 +04:00
|
|
|
NS_ASSERTION(!container || !aLayer->GetMaskLayer() ||
|
2012-06-29 10:01:34 +04:00
|
|
|
container->UseIntermediateSurface(),
|
|
|
|
"ContainerLayer with mask layer should force UseIntermediateSurface");
|
|
|
|
|
2012-09-11 02:31:38 +04:00
|
|
|
gfxContextAutoSaveRestore contextSR;
|
2012-09-07 16:32:21 +04:00
|
|
|
gfxMatrix transform;
|
|
|
|
// Will return an identity matrix for 3d transforms, and is handled separately below.
|
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
|
|
|
bool is2D = paintLayerContext.Setup2DTransform();
|
2015-09-17 04:31:00 +03:00
|
|
|
MOZ_ASSERT(is2D || needsGroup || !container ||
|
|
|
|
container->Extend3DContext() ||
|
|
|
|
container->Is3DContextLeaf(),
|
|
|
|
"Must PushGroup for 3d transforms!");
|
2012-09-07 16:32:21 +04:00
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
Layer* parent = aLayer->GetParent();
|
|
|
|
bool inPreserves3DChain = parent && parent->Extend3DContext();
|
2012-09-07 16:32:21 +04:00
|
|
|
bool needsSaveRestore =
|
2015-09-17 04:31:00 +03:00
|
|
|
needsGroup || clipRect || needsClipToVisibleRegion || !is2D ||
|
|
|
|
inPreserves3DChain;
|
2012-06-29 10:01:34 +04:00
|
|
|
if (needsSaveRestore) {
|
2012-09-11 02:31:38 +04:00
|
|
|
contextSR.SetContext(aTarget);
|
2012-06-29 10:01:34 +04:00
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
// The clips on ancestors on the preserved3d chain should be
|
|
|
|
// installed on the aTarget before painting the layer.
|
|
|
|
InstallLayerClipPreserves3D(aTarget, aLayer);
|
|
|
|
for (Layer* l = parent; l && l->Extend3DContext(); l = l->GetParent()) {
|
|
|
|
InstallLayerClipPreserves3D(aTarget, l);
|
2012-06-29 10:01:34 +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
|
|
|
paintLayerContext.Apply2DTransform();
|
2012-06-29 10:01:34 +04:00
|
|
|
|
2016-04-24 04:07:41 +03:00
|
|
|
nsIntRegion visibleRegion = aLayer->GetLocalVisibleRegion().ToUnknownRegion();
|
2012-06-29 10:01:34 +04:00
|
|
|
// If needsGroup is true, we'll clip to the visible region after we've popped the group
|
|
|
|
if (needsClipToVisibleRegion && !needsGroup) {
|
|
|
|
gfxUtils::ClipToRegion(aTarget, visibleRegion);
|
|
|
|
// Don't need to clip to visible region again
|
|
|
|
needsClipToVisibleRegion = false;
|
|
|
|
}
|
2016-05-02 18:27:35 +03:00
|
|
|
|
2012-06-29 10:01:34 +04:00
|
|
|
if (is2D) {
|
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
|
|
|
paintLayerContext.AnnotateOpaqueRect();
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
|
2015-05-20 11:47:29 +03:00
|
|
|
bool clipIsEmpty = aTarget->GetClipExtents().IsEmpty();
|
2012-09-11 02:31:38 +04:00
|
|
|
if (clipIsEmpty) {
|
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
|
|
|
PaintSelfOrChildren(paintLayerContext, aTarget);
|
2012-09-11 02:31:38 +04:00
|
|
|
return;
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
|
2012-09-11 02:31:38 +04:00
|
|
|
if (is2D) {
|
|
|
|
if (needsGroup) {
|
2016-07-04 21:14:00 +03:00
|
|
|
PushedGroup pushedGroup;
|
|
|
|
if (PushGroupForLayer(aTarget, aLayer, aLayer->GetLocalVisibleRegion().ToUnknownRegion(), pushedGroup)) {
|
|
|
|
PaintSelfOrChildren(paintLayerContext, pushedGroup.mGroupTarget);
|
|
|
|
PopGroupForLayer(pushedGroup);
|
|
|
|
}
|
2012-06-29 10:01:34 +04:00
|
|
|
} else {
|
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
|
|
|
PaintSelfOrChildren(paintLayerContext, aTarget);
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
} else {
|
2015-09-17 04:31:00 +03:00
|
|
|
if (!needsGroup && container) {
|
|
|
|
PaintSelfOrChildren(paintLayerContext, aTarget);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-24 04:07:41 +03:00
|
|
|
IntRect bounds = visibleRegion.GetBounds();
|
2016-06-15 12:06:11 +03:00
|
|
|
// DrawTarget without the 3D transform applied:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DrawTarget> untransformedDT =
|
2013-11-27 04:29:45 +04:00
|
|
|
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(bounds.width, bounds.height),
|
2014-01-10 23:06:16 +04:00
|
|
|
SurfaceFormat::B8G8R8A8);
|
2016-04-12 22:18:11 +03:00
|
|
|
if (!untransformedDT || !untransformedDT->IsValid()) {
|
2012-09-11 02:31:38 +04:00
|
|
|
return;
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
2016-06-15 12:06:11 +03:00
|
|
|
untransformedDT->SetTransform(Matrix::Translation(-Point(bounds.x, bounds.y)));
|
2013-11-27 04:29:45 +04:00
|
|
|
|
2016-06-15 12:06:11 +03:00
|
|
|
RefPtr<gfxContext> groupTarget =
|
|
|
|
gfxContext::CreatePreservingTransformOrNull(untransformedDT);
|
2016-04-12 22:18:11 +03:00
|
|
|
MOZ_ASSERT(groupTarget); // already checked the target above
|
2012-06-29 10:01:34 +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
|
|
|
PaintSelfOrChildren(paintLayerContext, groupTarget);
|
2012-06-29 10:01:34 +04:00
|
|
|
|
2012-09-11 02:31:38 +04:00
|
|
|
// Temporary fast fix for bug 725886
|
|
|
|
// Revert these changes when 725886 is ready
|
2012-06-29 10:01:34 +04:00
|
|
|
#ifdef DEBUG
|
2012-09-11 02:31:38 +04:00
|
|
|
if (aLayer->GetDebugColorIndex() != 0) {
|
2015-09-24 09:42:58 +03:00
|
|
|
Color color((aLayer->GetDebugColorIndex() & 1) ? 1.f : 0.f,
|
|
|
|
(aLayer->GetDebugColorIndex() & 2) ? 1.f : 0.f,
|
|
|
|
(aLayer->GetDebugColorIndex() & 4) ? 1.f : 0.f);
|
2016-06-15 12:06:11 +03:00
|
|
|
untransformedDT->FillRect(Rect(bounds), ColorPattern(color));
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
2012-09-11 02:31:38 +04:00
|
|
|
#endif
|
2015-07-11 03:06:35 +03:00
|
|
|
Matrix4x4 effectiveTransform = aLayer->GetEffectiveTransform();
|
2016-03-23 08:03:10 +03:00
|
|
|
Rect xformBounds =
|
|
|
|
effectiveTransform.TransformAndClipBounds(Rect(bounds),
|
|
|
|
ToRect(aTarget->GetClipExtents()));
|
|
|
|
xformBounds.RoundOut();
|
|
|
|
effectiveTransform.PostTranslate(-xformBounds.x, -xformBounds.y, 0);
|
2016-04-24 04:07:41 +03:00
|
|
|
effectiveTransform.PreTranslate(bounds.x, bounds.y, 0);
|
2016-03-23 08:03:10 +03:00
|
|
|
|
|
|
|
RefPtr<SourceSurface> untransformedSurf = untransformedDT->Snapshot();
|
|
|
|
RefPtr<DrawTarget> xformDT =
|
|
|
|
untransformedDT->CreateSimilarDrawTarget(IntSize(xformBounds.width, xformBounds.height),
|
|
|
|
SurfaceFormat::B8G8R8A8);
|
|
|
|
RefPtr<SourceSurface> xformSurf;
|
|
|
|
if(xformDT && untransformedSurf &&
|
|
|
|
xformDT->Draw3DTransformedSurface(untransformedSurf, effectiveTransform)) {
|
|
|
|
xformSurf = xformDT->Snapshot();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xformSurf) {
|
|
|
|
aTarget->SetPattern(
|
|
|
|
new gfxPattern(xformSurf,
|
|
|
|
Matrix::Translation(xformBounds.TopLeft())));
|
2012-09-11 02:31:38 +04:00
|
|
|
|
2012-09-07 16:32:21 +04:00
|
|
|
// Azure doesn't support EXTEND_NONE, so to avoid extending the edges
|
|
|
|
// of the source surface out to the current clip region, clip to
|
|
|
|
// the rectangle of the result surface now.
|
|
|
|
aTarget->NewPath();
|
2016-03-23 08:03:10 +03:00
|
|
|
aTarget->SnappedRectangle(ThebesRect(xformBounds));
|
2012-09-07 16:32:21 +04:00
|
|
|
aTarget->Clip();
|
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
|
|
|
FlushGroup(paintLayerContext, needsClipToVisibleRegion);
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-11-08 07:51:55 +04:00
|
|
|
BasicLayerManager::ClearCachedResources(Layer* aSubtree)
|
2012-06-29 10:01:34 +04:00
|
|
|
{
|
2012-11-08 07:51:55 +04:00
|
|
|
MOZ_ASSERT(!aSubtree || aSubtree->Manager() == this);
|
|
|
|
if (aSubtree) {
|
|
|
|
ClearLayer(aSubtree);
|
|
|
|
} else if (mRoot) {
|
2012-06-29 10:01:34 +04:00
|
|
|
ClearLayer(mRoot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void
|
|
|
|
BasicLayerManager::ClearLayer(Layer* aLayer)
|
|
|
|
{
|
|
|
|
ToData(aLayer)->ClearCachedResources();
|
|
|
|
for (Layer* child = aLayer->GetFirstChild(); child;
|
|
|
|
child = child->GetNextSibling()) {
|
|
|
|
ClearLayer(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<ReadbackLayer>
|
|
|
|
BasicLayerManager::CreateReadbackLayer()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ReadbackLayer> layer = new BasicReadbackLayer(this);
|
2012-06-29 10:01:34 +04:00
|
|
|
return layer.forget();
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|