2012-04-16 16:02:45 -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/. */
|
|
|
|
|
2013-04-30 22:03:25 -07:00
|
|
|
#include "ClientTiledThebesLayer.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "FrameMetrics.h" // for FrameMetrics
|
|
|
|
#include "Units.h" // for ScreenIntRect, CSSPoint, etc
|
2014-03-10 14:56:59 -07:00
|
|
|
#include "UnitTransforms.h" // for TransformTo
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "ClientLayerManager.h" // for ClientLayerManager, etc
|
|
|
|
#include "gfx3DMatrix.h" // for gfx3DMatrix
|
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
2014-02-26 18:53:31 -08:00
|
|
|
#include "gfxPrefs.h" // for gfxPrefs
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "gfxRect.h" // for gfxRect
|
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
|
|
|
#include "mozilla/gfx/Rect.h" // for Rect, RectTyped
|
2013-09-06 08:41:00 -07:00
|
|
|
#include "mozilla/layers/LayersMessages.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
2014-02-26 13:36:35 -08:00
|
|
|
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "nsRect.h" // for nsIntRect
|
2012-04-16 16:02:45 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
|
2013-04-30 22:03:25 -07:00
|
|
|
ClientTiledThebesLayer::ClientTiledThebesLayer(ClientLayerManager* const aManager)
|
2013-08-16 06:18:36 -07:00
|
|
|
: ThebesLayer(aManager,
|
|
|
|
static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
|
2013-04-16 14:36:06 -07:00
|
|
|
, mContentClient()
|
2012-12-05 09:10:41 -08:00
|
|
|
{
|
2013-04-30 22:03:25 -07:00
|
|
|
MOZ_COUNT_CTOR(ClientTiledThebesLayer);
|
2014-03-22 02:17:54 -07:00
|
|
|
mPaintData.mLastScrollOffset = ParentLayerPoint(0, 0);
|
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
|
|
|
mPaintData.mFirstPaint = true;
|
2012-12-05 09:10:41 -08:00
|
|
|
}
|
|
|
|
|
2013-04-30 22:03:25 -07:00
|
|
|
ClientTiledThebesLayer::~ClientTiledThebesLayer()
|
2012-12-05 09:10:41 -08:00
|
|
|
{
|
2013-04-30 22:03:25 -07:00
|
|
|
MOZ_COUNT_DTOR(ClientTiledThebesLayer);
|
2012-12-05 09:10:41 -08:00
|
|
|
}
|
|
|
|
|
2014-03-07 13:34:04 -08:00
|
|
|
void
|
|
|
|
ClientTiledThebesLayer::ClearCachedResources()
|
|
|
|
{
|
|
|
|
if (mContentClient) {
|
|
|
|
mContentClient->ClearCachedResources();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-16 16:02:45 -07:00
|
|
|
void
|
2013-04-30 22:03:25 -07:00
|
|
|
ClientTiledThebesLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
|
2012-04-16 16:02:45 -07:00
|
|
|
{
|
|
|
|
aAttrs = ThebesLayerAttributes(GetValidRegion());
|
|
|
|
}
|
|
|
|
|
2013-11-27 09:33:27 -08:00
|
|
|
static LayoutDeviceRect
|
2014-03-10 14:56:59 -07:00
|
|
|
ApplyParentLayerToLayoutTransform(const gfx3DMatrix& aTransform, const ParentLayerRect& aParentLayerRect)
|
2013-11-27 09:33:27 -08:00
|
|
|
{
|
2014-03-10 14:56:59 -07:00
|
|
|
return TransformTo<LayoutDevicePixel>(aTransform, aParentLayerRect);
|
2013-11-27 09:33:27 -08:00
|
|
|
}
|
|
|
|
|
2012-11-29 05:08:40 -08:00
|
|
|
void
|
2013-04-30 22:03:25 -07:00
|
|
|
ClientTiledThebesLayer::BeginPaint()
|
2012-11-29 05:08:40 -08:00
|
|
|
{
|
2013-04-30 22:03:25 -07:00
|
|
|
if (ClientManager()->IsRepeatTransaction()) {
|
2012-11-29 05:08:40 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mPaintData.mLowPrecisionPaintCount = 0;
|
|
|
|
mPaintData.mPaintFinished = false;
|
2014-03-22 02:17:54 -07:00
|
|
|
mPaintData.mCompositionBounds.SetEmpty();
|
|
|
|
mPaintData.mCriticalDisplayPort.SetEmpty();
|
|
|
|
|
|
|
|
if (!GetBaseTransform().Is2DIntegerTranslation()) {
|
|
|
|
// Give up if the layer is transformed. The code below assumes that there
|
|
|
|
// is no transform set, and not making that assumption would cause huge
|
|
|
|
// complication to handle a quite rare case.
|
|
|
|
//
|
|
|
|
// FIXME The intention is to bail out of this function when there's a CSS
|
|
|
|
// transform set on the layer, but unfortunately there's no way to
|
|
|
|
// distinguish transforms due to scrolling from transforms due to
|
|
|
|
// CSS transforms.
|
|
|
|
//
|
|
|
|
// Because of this, there may be unintended behaviour when setting
|
|
|
|
// 2d CSS translations on the children of scrollable displayport
|
|
|
|
// layers.
|
|
|
|
return;
|
|
|
|
}
|
2012-11-29 05:08:40 -08:00
|
|
|
|
2014-03-22 02:17:54 -07:00
|
|
|
// Get the metrics of the nearest scrollable layer and the nearest layer
|
|
|
|
// with a displayport.
|
|
|
|
ContainerLayer* displayPortParent = nullptr;
|
2013-11-27 09:33:27 -08:00
|
|
|
ContainerLayer* scrollParent = nullptr;
|
2012-11-29 05:08:40 -08:00
|
|
|
for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
|
2013-11-27 09:33:27 -08:00
|
|
|
const FrameMetrics& metrics = parent->GetFrameMetrics();
|
2014-03-22 02:17:54 -07:00
|
|
|
if (!scrollParent && metrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID) {
|
2013-11-27 09:33:27 -08:00
|
|
|
scrollParent = parent;
|
2014-03-22 02:17:54 -07:00
|
|
|
}
|
|
|
|
if (!metrics.mDisplayPort.IsEmpty()) {
|
|
|
|
displayPortParent = parent;
|
|
|
|
// Any layer that has a displayport must be scrollable, so we can break
|
|
|
|
// here.
|
2013-11-27 09:33:27 -08:00
|
|
|
break;
|
2012-11-29 05:08:40 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-22 02:17:54 -07:00
|
|
|
if (!displayPortParent || !scrollParent) {
|
|
|
|
// No displayport or scroll parent, so we can't do progressive rendering.
|
|
|
|
// Just set the composition bounds to empty and return.
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_B2G)
|
|
|
|
// Both Android and b2g are guaranteed to have a displayport set, so this
|
|
|
|
// should never happen.
|
2013-11-27 09:33:27 -08:00
|
|
|
NS_WARNING("Tiled Thebes layer with no scrollable container parent");
|
2014-03-22 02:17:54 -07:00
|
|
|
#endif
|
2013-11-27 09:33:27 -08:00
|
|
|
return;
|
2012-11-29 05:08:40 -08:00
|
|
|
}
|
|
|
|
|
2014-03-22 02:17:54 -07:00
|
|
|
// Note, not handling transformed layers lets us assume that LayoutDevice
|
|
|
|
// space of the scroll parent layer is the same as LayoutDevice space of
|
|
|
|
// this layer.
|
|
|
|
const FrameMetrics& scrollMetrics = scrollParent->GetFrameMetrics();
|
|
|
|
const FrameMetrics& displayportMetrics = displayPortParent->GetFrameMetrics();
|
|
|
|
|
|
|
|
// Calculate the transform required to convert ParentLayer space of our
|
|
|
|
// display port parent to LayoutDevice space of this layer.
|
|
|
|
gfx::Matrix4x4 transform = scrollParent->GetTransform();
|
|
|
|
ContainerLayer* displayPortParentParent = displayPortParent->GetParent() ?
|
|
|
|
displayPortParent->GetParent()->GetParent() : nullptr;
|
|
|
|
for (ContainerLayer* parent = scrollParent->GetParent();
|
|
|
|
parent != displayPortParentParent;
|
|
|
|
parent = parent->GetParent()) {
|
|
|
|
transform = transform * parent->GetTransform();
|
2012-11-29 05:08:40 -08:00
|
|
|
}
|
2014-03-22 02:17:54 -07:00
|
|
|
gfx3DMatrix layoutDeviceToScrollParentLayer;
|
|
|
|
gfx::To3DMatrix(transform, layoutDeviceToScrollParentLayer);
|
|
|
|
layoutDeviceToScrollParentLayer.ScalePost(scrollMetrics.mCumulativeResolution.scale,
|
|
|
|
scrollMetrics.mCumulativeResolution.scale,
|
|
|
|
1.f);
|
|
|
|
|
|
|
|
mPaintData.mTransformParentLayerToLayoutDevice = layoutDeviceToScrollParentLayer.Inverse();
|
|
|
|
|
|
|
|
// Compute the critical display port of the display port layer in
|
|
|
|
// LayoutDevice space of this layer.
|
|
|
|
ParentLayerRect criticalDisplayPort =
|
|
|
|
(displayportMetrics.mCriticalDisplayPort + displayportMetrics.GetScrollOffset()) *
|
|
|
|
displayportMetrics.GetZoomToParent();
|
|
|
|
mPaintData.mCriticalDisplayPort = LayoutDeviceIntRect::ToUntyped(RoundedOut(
|
|
|
|
ApplyParentLayerToLayoutTransform(mPaintData.mTransformParentLayerToLayoutDevice,
|
|
|
|
criticalDisplayPort)));
|
|
|
|
|
|
|
|
// Compute the viewport of the display port layer in LayoutDevice space of
|
|
|
|
// this layer.
|
|
|
|
ParentLayerRect viewport =
|
|
|
|
(displayportMetrics.mViewport + displayportMetrics.GetScrollOffset()) *
|
|
|
|
displayportMetrics.GetZoomToParent();
|
|
|
|
mPaintData.mViewport = ApplyParentLayerToLayoutTransform(
|
|
|
|
mPaintData.mTransformParentLayerToLayoutDevice, viewport);
|
|
|
|
|
|
|
|
// Store the scroll parent resolution. Because this is Gecko-side, before any
|
|
|
|
// async transforms have occurred, we can use the zoom for this.
|
|
|
|
mPaintData.mResolution = displayportMetrics.GetZoomToParent();
|
|
|
|
|
|
|
|
// Store the parent composition bounds in LayoutDevice units.
|
|
|
|
// This is actually in LayoutDevice units of the scrollParent's parent layer,
|
|
|
|
// but because there is no transform, we can assume that these are the same.
|
|
|
|
mPaintData.mCompositionBounds =
|
|
|
|
scrollMetrics.mCompositionBounds / scrollMetrics.GetParentResolution();
|
|
|
|
|
|
|
|
// Calculate the scroll offset since the last transaction
|
|
|
|
mPaintData.mScrollOffset = displayportMetrics.GetScrollOffset() * displayportMetrics.GetZoomToParent();
|
2012-11-29 05:08:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-30 22:03:25 -07:00
|
|
|
ClientTiledThebesLayer::EndPaint(bool aFinish)
|
2012-11-29 05:08:40 -08:00
|
|
|
{
|
|
|
|
if (!aFinish && !mPaintData.mPaintFinished) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
mPaintData.mLastScrollOffset = mPaintData.mScrollOffset;
|
2012-11-29 05:08:40 -08:00
|
|
|
mPaintData.mPaintFinished = true;
|
2013-11-27 09:33:27 -08:00
|
|
|
mPaintData.mFirstPaint = false;
|
2012-11-29 05:08:40 -08:00
|
|
|
}
|
|
|
|
|
2012-04-16 16:02:45 -07:00
|
|
|
void
|
2013-04-30 22:03:25 -07:00
|
|
|
ClientTiledThebesLayer::RenderLayer()
|
2012-04-16 16:02:45 -07:00
|
|
|
{
|
2013-04-30 22:03:25 -07:00
|
|
|
LayerManager::DrawThebesLayerCallback callback =
|
|
|
|
ClientManager()->GetThebesLayerCallback();
|
|
|
|
void *data = ClientManager()->GetThebesLayerCallbackData();
|
|
|
|
if (!callback) {
|
|
|
|
ClientManager()->SetTransactionIncomplete();
|
2012-04-16 16:02:45 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-16 14:36:06 -07:00
|
|
|
if (!mContentClient) {
|
2013-04-30 22:03:25 -07:00
|
|
|
mContentClient = new TiledContentClient(this, ClientManager());
|
2013-04-16 14:36:06 -07:00
|
|
|
|
|
|
|
mContentClient->Connect();
|
2013-11-27 07:19:34 -08:00
|
|
|
ClientManager()->AsShadowForwarder()->Attach(mContentClient, this);
|
2013-04-16 14:36:06 -07:00
|
|
|
MOZ_ASSERT(mContentClient->GetForwarder());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mContentClient->mTiledBuffer.HasFormatChanged()) {
|
2012-09-04 15:05:31 -07:00
|
|
|
mValidRegion = nsIntRegion();
|
|
|
|
}
|
|
|
|
|
2012-10-15 01:33:48 -07:00
|
|
|
nsIntRegion invalidRegion = mVisibleRegion;
|
|
|
|
invalidRegion.Sub(invalidRegion, mValidRegion);
|
2012-11-29 05:08:40 -08:00
|
|
|
if (invalidRegion.IsEmpty()) {
|
|
|
|
EndPaint(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// Only paint the mask layer on the first transaction.
|
2013-04-30 22:03:25 -07:00
|
|
|
if (GetMaskLayer() && !ClientManager()->IsRepeatTransaction()) {
|
|
|
|
ToClientLayer(GetMaskLayer())->RenderLayer();
|
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-03-31 09:42:32 -07:00
|
|
|
bool isFixed = GetIsFixedPosition() || GetParent()->GetIsFixedPosition();
|
|
|
|
|
2012-11-29 05:08:40 -08:00
|
|
|
// Fast path for no progressive updates, no low-precision updates and no
|
2014-03-31 09:42:32 -07:00
|
|
|
// critical display-port set, or no display-port set, or this is a fixed
|
|
|
|
// position layer/contained in a fixed position layer
|
2013-11-27 09:33:27 -08:00
|
|
|
const FrameMetrics& parentMetrics = GetParent()->GetFrameMetrics();
|
2014-02-26 18:53:31 -08:00
|
|
|
if ((!gfxPrefs::UseProgressiveTilePainting() &&
|
|
|
|
!gfxPrefs::UseLowPrecisionBuffer() &&
|
2013-11-27 09:33:27 -08:00
|
|
|
parentMetrics.mCriticalDisplayPort.IsEmpty()) ||
|
2014-03-31 09:42:32 -07:00
|
|
|
parentMetrics.mDisplayPort.IsEmpty() ||
|
|
|
|
isFixed) {
|
2012-11-29 05:08:40 -08:00
|
|
|
mValidRegion = mVisibleRegion;
|
|
|
|
|
2013-04-30 22:03:25 -07:00
|
|
|
NS_ASSERTION(!ClientManager()->IsRepeatTransaction(), "Didn't paint our mask layer");
|
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-04-16 14:36:06 -07:00
|
|
|
mContentClient->mTiledBuffer.PaintThebes(mValidRegion, invalidRegion,
|
2013-04-30 22:03:25 -07:00
|
|
|
callback, data);
|
2012-11-29 05:08:40 -08:00
|
|
|
|
2013-04-30 22:03:25 -07:00
|
|
|
ClientManager()->Hold(this);
|
2014-03-07 13:34:04 -08:00
|
|
|
mContentClient->UseTiledLayerBuffer(TiledContentClient::TILED_BUFFER);
|
2012-11-29 05:08:40 -08:00
|
|
|
|
2012-04-16 16:02:45 -07:00
|
|
|
return;
|
2012-11-29 05:08:40 -08:00
|
|
|
}
|
2012-04-16 16:02:45 -07:00
|
|
|
|
2012-11-29 05:08:40 -08:00
|
|
|
// Calculate everything we need to perform the paint.
|
|
|
|
BeginPaint();
|
|
|
|
if (mPaintData.mPaintFinished) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure that tiles that fall outside of the visible region are
|
|
|
|
// discarded on the first update.
|
2013-04-30 22:03:25 -07:00
|
|
|
if (!ClientManager()->IsRepeatTransaction()) {
|
2012-11-29 05:08:40 -08:00
|
|
|
mValidRegion.And(mValidRegion, mVisibleRegion);
|
2014-03-22 02:17:54 -07:00
|
|
|
if (!mPaintData.mCriticalDisplayPort.IsEmpty()) {
|
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
|
|
|
// Make sure that tiles that fall outside of the critical displayport are
|
|
|
|
// discarded on the first update.
|
2014-03-22 02:17:54 -07:00
|
|
|
mValidRegion.And(mValidRegion, mPaintData.mCriticalDisplayPort);
|
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-11-21 14:34:18 -08:00
|
|
|
}
|
|
|
|
|
2012-11-21 14:34:20 -08:00
|
|
|
nsIntRegion lowPrecisionInvalidRegion;
|
2014-03-22 02:17:54 -07:00
|
|
|
if (!mPaintData.mCriticalDisplayPort.IsEmpty()) {
|
2014-02-26 18:53:31 -08:00
|
|
|
if (gfxPrefs::UseLowPrecisionBuffer()) {
|
2012-11-29 05:08:40 -08:00
|
|
|
// Calculate the invalid region for the low precision buffer
|
|
|
|
lowPrecisionInvalidRegion.Sub(mVisibleRegion, mLowPrecisionValidRegion);
|
|
|
|
|
|
|
|
// Remove the valid region from the low precision valid region (we don't
|
|
|
|
// validate this part of the low precision buffer).
|
|
|
|
lowPrecisionInvalidRegion.Sub(lowPrecisionInvalidRegion, mValidRegion);
|
|
|
|
}
|
2012-11-21 14:34:18 -08:00
|
|
|
|
|
|
|
// Clip the invalid region to the critical display-port
|
2014-03-22 02:17:54 -07:00
|
|
|
invalidRegion.And(invalidRegion, mPaintData.mCriticalDisplayPort);
|
2012-11-21 14:34:20 -08:00
|
|
|
if (invalidRegion.IsEmpty() && lowPrecisionInvalidRegion.IsEmpty()) {
|
2012-11-29 05:08:40 -08:00
|
|
|
EndPaint(true);
|
2012-11-21 14:34:18 -08:00
|
|
|
return;
|
2012-11-21 14:34:20 -08:00
|
|
|
}
|
2012-11-21 14:34:18 -08:00
|
|
|
}
|
|
|
|
|
2012-11-29 05:08:40 -08:00
|
|
|
if (!invalidRegion.IsEmpty() && mPaintData.mLowPrecisionPaintCount == 0) {
|
2012-11-21 14:34:20 -08:00
|
|
|
bool updatedBuffer = false;
|
|
|
|
// Only draw progressively when the resolution is unchanged.
|
2014-02-26 18:53:31 -08:00
|
|
|
if (gfxPrefs::UseProgressiveTilePainting() &&
|
2013-04-30 22:03:25 -07:00
|
|
|
!ClientManager()->HasShadowTarget() &&
|
2013-04-16 14:36:06 -07:00
|
|
|
mContentClient->mTiledBuffer.GetFrameResolution() == mPaintData.mResolution) {
|
2012-11-21 14:34:20 -08:00
|
|
|
// Store the old valid region, then clear it before painting.
|
|
|
|
// We clip the old valid region to the visible region, as it only gets
|
|
|
|
// used to decide stale content (currently valid and previously visible)
|
2013-04-16 14:36:06 -07:00
|
|
|
nsIntRegion oldValidRegion = mContentClient->mTiledBuffer.GetValidRegion();
|
2012-11-21 14:34:20 -08:00
|
|
|
oldValidRegion.And(oldValidRegion, mVisibleRegion);
|
2014-03-22 02:17:54 -07:00
|
|
|
if (!mPaintData.mCriticalDisplayPort.IsEmpty()) {
|
|
|
|
oldValidRegion.And(oldValidRegion, mPaintData.mCriticalDisplayPort);
|
2012-11-21 14:34:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
updatedBuffer =
|
2013-04-16 14:36:06 -07:00
|
|
|
mContentClient->mTiledBuffer.ProgressiveUpdate(mValidRegion, invalidRegion,
|
|
|
|
oldValidRegion, &mPaintData,
|
2013-04-30 22:03:25 -07:00
|
|
|
callback, data);
|
2012-11-21 14:34:20 -08:00
|
|
|
} else {
|
|
|
|
updatedBuffer = true;
|
|
|
|
mValidRegion = mVisibleRegion;
|
2014-03-22 02:17:54 -07:00
|
|
|
if (!mPaintData.mCriticalDisplayPort.IsEmpty()) {
|
|
|
|
mValidRegion.And(mValidRegion, mPaintData.mCriticalDisplayPort);
|
2012-11-21 14:34:18 -08:00
|
|
|
}
|
2013-04-16 14:36:06 -07:00
|
|
|
mContentClient->mTiledBuffer.SetFrameResolution(mPaintData.mResolution);
|
|
|
|
mContentClient->mTiledBuffer.PaintThebes(mValidRegion, invalidRegion,
|
2013-04-30 22:03:25 -07:00
|
|
|
callback, data);
|
2012-11-21 11:16:53 -08:00
|
|
|
}
|
2012-11-21 11:16:52 -08:00
|
|
|
|
2012-11-21 14:34:20 -08:00
|
|
|
if (updatedBuffer) {
|
2013-04-30 22:03:25 -07:00
|
|
|
ClientManager()->Hold(this);
|
2014-03-07 13:34:04 -08:00
|
|
|
mContentClient->UseTiledLayerBuffer(TiledContentClient::TILED_BUFFER);
|
2012-11-29 05:08:40 -08:00
|
|
|
|
|
|
|
// If there are low precision updates, mark the paint as unfinished and
|
|
|
|
// request a repeat transaction.
|
|
|
|
if (!lowPrecisionInvalidRegion.IsEmpty() && mPaintData.mPaintFinished) {
|
2013-04-30 22:03:25 -07:00
|
|
|
ClientManager()->SetRepeatTransaction();
|
2012-11-29 05:08:40 -08:00
|
|
|
mPaintData.mLowPrecisionPaintCount = 1;
|
|
|
|
mPaintData.mPaintFinished = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return so that low precision updates aren't performed in the same
|
|
|
|
// transaction as high-precision updates.
|
|
|
|
EndPaint(false);
|
|
|
|
return;
|
2012-11-21 14:34:20 -08:00
|
|
|
}
|
|
|
|
}
|
2012-11-21 14:34:19 -08:00
|
|
|
|
2012-11-29 05:08:40 -08:00
|
|
|
// Render the low precision buffer, if there's area to invalidate and the
|
|
|
|
// visible region is larger than the critical display port.
|
2012-11-21 14:34:19 -08:00
|
|
|
bool updatedLowPrecision = false;
|
2012-11-29 05:08:40 -08:00
|
|
|
if (!lowPrecisionInvalidRegion.IsEmpty() &&
|
2014-03-22 02:17:54 -07:00
|
|
|
!nsIntRegion(mPaintData.mCriticalDisplayPort).Contains(mVisibleRegion)) {
|
2013-04-16 14:36:06 -07:00
|
|
|
nsIntRegion oldValidRegion =
|
|
|
|
mContentClient->mLowPrecisionTiledBuffer.GetValidRegion();
|
2012-11-21 14:34:19 -08:00
|
|
|
oldValidRegion.And(oldValidRegion, mVisibleRegion);
|
|
|
|
|
2012-11-29 05:08:41 -08:00
|
|
|
// If the frame resolution or format have changed, invalidate the buffer
|
2013-04-16 14:36:06 -07:00
|
|
|
if (mContentClient->mLowPrecisionTiledBuffer.GetFrameResolution() != mPaintData.mResolution ||
|
|
|
|
mContentClient->mLowPrecisionTiledBuffer.HasFormatChanged()) {
|
2012-11-21 14:34:19 -08:00
|
|
|
if (!mLowPrecisionValidRegion.IsEmpty()) {
|
2012-11-21 14:34:20 -08:00
|
|
|
updatedLowPrecision = true;
|
2012-11-21 14:34:19 -08:00
|
|
|
}
|
|
|
|
oldValidRegion.SetEmpty();
|
|
|
|
mLowPrecisionValidRegion.SetEmpty();
|
2013-04-16 14:36:06 -07:00
|
|
|
mContentClient->mLowPrecisionTiledBuffer.SetFrameResolution(mPaintData.mResolution);
|
2012-11-29 05:08:41 -08:00
|
|
|
lowPrecisionInvalidRegion = mVisibleRegion;
|
2012-11-21 14:34:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Invalidate previously valid content that is no longer visible
|
2012-11-29 05:08:40 -08:00
|
|
|
if (mPaintData.mLowPrecisionPaintCount == 1) {
|
2012-11-21 14:34:19 -08:00
|
|
|
mLowPrecisionValidRegion.And(mLowPrecisionValidRegion, mVisibleRegion);
|
|
|
|
}
|
2012-11-29 05:08:40 -08:00
|
|
|
mPaintData.mLowPrecisionPaintCount++;
|
2012-11-21 14:34:19 -08:00
|
|
|
|
2012-11-21 14:34:19 -08:00
|
|
|
// Remove the valid high-precision region from the invalid low-precision
|
|
|
|
// region. We don't want to spend time drawing things twice.
|
2012-11-29 05:08:40 -08:00
|
|
|
lowPrecisionInvalidRegion.Sub(lowPrecisionInvalidRegion, mValidRegion);
|
2012-11-21 14:34:19 -08:00
|
|
|
|
2012-11-21 14:34:19 -08:00
|
|
|
if (!lowPrecisionInvalidRegion.IsEmpty()) {
|
2013-04-16 14:36:06 -07:00
|
|
|
updatedLowPrecision = mContentClient->mLowPrecisionTiledBuffer
|
|
|
|
.ProgressiveUpdate(mLowPrecisionValidRegion,
|
|
|
|
lowPrecisionInvalidRegion,
|
|
|
|
oldValidRegion, &mPaintData,
|
2013-04-30 22:03:25 -07:00
|
|
|
callback, data);
|
2012-11-21 14:34:19 -08:00
|
|
|
}
|
|
|
|
} else if (!mLowPrecisionValidRegion.IsEmpty()) {
|
|
|
|
// Clear the low precision tiled buffer
|
2012-11-21 14:34:20 -08:00
|
|
|
updatedLowPrecision = true;
|
2012-11-21 14:34:19 -08:00
|
|
|
mLowPrecisionValidRegion.SetEmpty();
|
2013-04-16 14:36:06 -07:00
|
|
|
mContentClient->mLowPrecisionTiledBuffer.PaintThebes(mLowPrecisionValidRegion,
|
|
|
|
mLowPrecisionValidRegion,
|
2013-04-30 22:03:25 -07:00
|
|
|
callback, data);
|
2012-11-21 14:34:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// We send a Painted callback if we clear the valid region of the low
|
|
|
|
// precision buffer, so that the shadow buffer's valid region can be updated
|
|
|
|
// and the associated resources can be freed.
|
2012-11-21 14:34:20 -08:00
|
|
|
if (updatedLowPrecision) {
|
2013-04-30 22:03:25 -07:00
|
|
|
ClientManager()->Hold(this);
|
2014-03-07 13:34:04 -08:00
|
|
|
mContentClient->UseTiledLayerBuffer(TiledContentClient::LOW_PRECISION_TILED_BUFFER);
|
2012-11-21 14:34:19 -08:00
|
|
|
}
|
|
|
|
|
2012-11-29 05:08:40 -08:00
|
|
|
EndPaint(false);
|
2012-04-16 16:02:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
} // mozilla
|
|
|
|
} // layers
|