2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2016-06-15 14:28:10 +03:00
|
|
|
#include "ClientLayerManager.h" // for ClientLayerManager
|
2010-07-22 01:17:33 +04:00
|
|
|
#include "ShadowLayers.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <set> // for _Rb_tree_const_iterator, etc
|
|
|
|
#include <vector> // for vector
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 10:08:53 +03:00
|
|
|
#include "GeckoProfiler.h" // for AUTO_PROFILER_LABEL
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "ISurfaceAllocator.h" // for IsSurfaceDescriptorValid
|
|
|
|
#include "Layers.h" // for Layer
|
|
|
|
#include "RenderTrace.h" // for RenderTraceScope
|
2013-12-20 20:46:29 +04:00
|
|
|
#include "gfx2DGlue.h" // for Moz2D transition helpers
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxPlatform.h" // for gfxImageFormat, gfxPlatform
|
2017-04-11 05:44:45 +03:00
|
|
|
#include "gfxPrefs.h"
|
2016-03-17 16:58:58 +03:00
|
|
|
//#include "gfxSharedImageSurface.h" // for gfxSharedImageSurface
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "ipc/IPCMessageUtils.h" // for gfxContentType, null_t
|
2016-01-07 13:17:40 +03:00
|
|
|
#include "IPDLActor.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
2017-03-29 08:49:20 +03:00
|
|
|
#include "mozilla/dom/TabGroup.h"
|
2013-12-20 20:46:30 +04:00
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/layers/CompositableClient.h" // for CompositableClient, etc
|
2016-04-13 00:04:50 +03:00
|
|
|
#include "mozilla/layers/CompositorBridgeChild.h"
|
2017-01-18 05:47:05 +03:00
|
|
|
#include "mozilla/layers/ContentClient.h"
|
2016-03-17 16:58:58 +03:00
|
|
|
#include "mozilla/layers/ImageDataSerializer.h"
|
2016-06-15 14:28:10 +03:00
|
|
|
#include "mozilla/layers/ImageBridgeChild.h"
|
2013-09-06 19:41:00 +04:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for Edit, etc
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc
|
|
|
|
#include "mozilla/layers/LayersTypes.h" // for MOZ_LAYERS_LOG
|
2013-11-27 19:19:34 +04:00
|
|
|
#include "mozilla/layers/LayerTransactionChild.h"
|
2016-07-26 21:56:35 +03:00
|
|
|
#include "mozilla/layers/PTextureChild.h"
|
2017-08-07 13:15:24 +03:00
|
|
|
#include "mozilla/layers/SyncObject.h"
|
Bug 1265824 - Wait on texture handles with IPC r=jld,mattwoodrow
There's a lot going on here, but it all fits under the idea of
being able to communicate about texture locking statuses
without spinning on IsReadLocked. This is a bit of a trade -
we could just always allocate/grab a texture from the pool,
which would put a smaller cap on the amount of time we can
possibly spend when a texture is locked. However, this eats
up more CPU and memory than waiting on the textures to unlock,
and could take longer, especially if there were a large number
of textures which we just need to wait for for a short amount
of time. In any case, we very rarely hit the case where we
actually need to wait on the sync IPC to the compositor - most
of the time the textures are already unlocked.
There is also an async IPC call in here, which we make before
flushing async paints. This just causes the compositor to
check whether the GPU is done with its textures or not and
unlock them if it is. This helps us avoid the case where we
take a long time painting asynchronously, turn IPC back on at
the end of that, and then have to wait for the compositor
to to get into TiledLayerBufferComposite::UseTiles before
getting a response. Specifically this eliminates several talos
regressions which use ASAP mode.
Lastly, there seem to be no other cases of static Monitors
being used. This seems like it falls under similar use cases
as StaticMutexes, so I added it in. I can move it into its own
file if we think it might be generally useful in the future.
MozReview-Commit-ID: IYQLwUqMxg2
--HG--
extra : rebase_source : 4f05832f51dae6db98773dcad03cb008a80eca6c
2018-05-06 01:46:26 +03:00
|
|
|
#ifdef XP_DARWIN
|
|
|
|
#include "mozilla/layers/TextureSync.h"
|
|
|
|
#endif
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "ShadowLayerUtils.h"
|
|
|
|
#include "mozilla/layers/TextureClient.h" // for TextureClient
|
|
|
|
#include "mozilla/mozalloc.h" // for operator new, etc
|
2016-02-02 18:36:30 +03:00
|
|
|
#include "nsTArray.h" // for AutoTArray, nsTArray, etc
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsXULAppAPI.h" // for XRE_GetProcessType, etc
|
2014-07-31 10:44:31 +04:00
|
|
|
#include "mozilla/ReentrantMonitor.h"
|
2010-07-22 01:17:33 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-08-12 03:17:23 +04:00
|
|
|
namespace ipc {
|
|
|
|
class Shmem;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace ipc
|
2013-08-12 03:17:23 +04:00
|
|
|
|
2010-07-22 01:17:33 +04:00
|
|
|
namespace layers {
|
|
|
|
|
2015-07-04 01:52:42 +03:00
|
|
|
using namespace mozilla::gfx;
|
2014-05-22 14:11:45 +04:00
|
|
|
using namespace mozilla::gl;
|
2015-07-04 01:52:42 +03:00
|
|
|
using namespace mozilla::ipc;
|
2014-05-22 14:11:45 +04:00
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
class ClientTiledLayerBuffer;
|
2013-08-12 03:17:23 +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
|
|
|
typedef nsTArray<SurfaceDescriptor> BufferArray;
|
2017-01-12 20:49:30 +03:00
|
|
|
typedef nsTArray<Edit> EditVector;
|
2016-10-13 18:27:58 +03:00
|
|
|
typedef nsTHashtable<nsPtrHashKey<ShadowableLayer>> ShadowableLayerSet;
|
2016-01-07 13:17:40 +03:00
|
|
|
typedef nsTArray<OpDestroy> OpDestroyVector;
|
2010-07-22 01:17:33 +04:00
|
|
|
|
|
|
|
class Transaction
|
|
|
|
{
|
|
|
|
public:
|
2012-05-01 23:23:39 +04:00
|
|
|
Transaction()
|
2018-03-14 01:00:18 +03:00
|
|
|
: mTargetRotation(ROTATION_0)
|
2012-05-18 12:29:38 +04:00
|
|
|
, mOpen(false)
|
2012-11-06 13:11:43 +04:00
|
|
|
, mRotationChanged(false)
|
2012-05-01 23:23:39 +04:00
|
|
|
{}
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2015-04-21 18:04:57 +03:00
|
|
|
void Begin(const gfx::IntRect& aTargetBounds, ScreenRotation aRotation,
|
2015-08-19 00:55:09 +03:00
|
|
|
dom::ScreenOrientationInternal aOrientation)
|
2012-07-24 23:01:09 +04:00
|
|
|
{
|
|
|
|
mOpen = true;
|
|
|
|
mTargetBounds = aTargetBounds;
|
2012-11-06 13:11:43 +04:00
|
|
|
if (aRotation != mTargetRotation) {
|
2013-02-26 09:18:20 +04:00
|
|
|
// the first time this is called, mRotationChanged will be false if
|
|
|
|
// aRotation is 0, but we should be OK because for the first transaction
|
|
|
|
// we should only compose if it is non-empty. See the caller(s) of
|
|
|
|
// RotationChanged.
|
|
|
|
mRotationChanged = true;
|
2012-11-06 13:11:43 +04:00
|
|
|
}
|
2012-07-24 23:01:09 +04:00
|
|
|
mTargetRotation = aRotation;
|
2012-11-22 06:40:57 +04:00
|
|
|
mTargetOrientation = aOrientation;
|
2012-07-24 23:01:09 +04:00
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
void AddEdit(const Edit& aEdit)
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!Finished(), "forgot BeginTransaction?");
|
2017-01-12 20:49:30 +03:00
|
|
|
mCset.AppendElement(aEdit);
|
2010-07-22 01:17:33 +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
|
|
|
void AddEdit(const CompositableOperation& aEdit)
|
|
|
|
{
|
|
|
|
AddEdit(Edit(aEdit));
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddNoSwapPaint(const CompositableOperation& aPaint)
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!Finished(), "forgot BeginTransaction?");
|
2017-01-12 20:49:30 +03:00
|
|
|
mPaints.AppendElement(Edit(aPaint));
|
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
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
void AddMutant(ShadowableLayer* aLayer)
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!Finished(), "forgot BeginTransaction?");
|
2016-10-13 18:27:58 +03:00
|
|
|
mMutants.PutEntry(aLayer);
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
2017-01-25 03:41:18 +03:00
|
|
|
void AddSimpleMutant(ShadowableLayer* aLayer)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!Finished(), "forgot BeginTransaction?");
|
|
|
|
mSimpleMutants.PutEntry(aLayer);
|
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
void End()
|
|
|
|
{
|
2017-01-12 20:49:30 +03:00
|
|
|
mCset.Clear();
|
|
|
|
mPaints.Clear();
|
2016-10-13 18:27:58 +03:00
|
|
|
mMutants.Clear();
|
2017-01-25 03:41:18 +03:00
|
|
|
mSimpleMutants.Clear();
|
2016-01-07 13:17:40 +03:00
|
|
|
mDestroyedActors.Clear();
|
2011-10-17 18:59:28 +04:00
|
|
|
mOpen = false;
|
2012-11-06 13:11:43 +04:00
|
|
|
mRotationChanged = false;
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool Empty() const {
|
2017-01-25 03:41:18 +03:00
|
|
|
return mCset.IsEmpty() &&
|
|
|
|
mPaints.IsEmpty() &&
|
|
|
|
mMutants.IsEmpty() &&
|
|
|
|
mSimpleMutants.IsEmpty() &&
|
|
|
|
mDestroyedActors.IsEmpty();
|
2010-09-16 01:03:13 +04:00
|
|
|
}
|
2012-11-06 13:11:43 +04:00
|
|
|
bool RotationChanged() const {
|
|
|
|
return mRotationChanged;
|
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
bool Finished() const { return !mOpen && Empty(); }
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2014-10-07 22:37:15 +04:00
|
|
|
bool Opened() const { return mOpen; }
|
|
|
|
|
2010-07-22 01:17:33 +04:00
|
|
|
EditVector mCset;
|
2017-01-25 03:41:17 +03:00
|
|
|
nsTArray<CompositableOperation> mPaints;
|
2016-01-07 13:17:40 +03:00
|
|
|
OpDestroyVector mDestroyedActors;
|
2010-07-22 01:17:33 +04:00
|
|
|
ShadowableLayerSet mMutants;
|
2017-01-25 03:41:18 +03:00
|
|
|
ShadowableLayerSet mSimpleMutants;
|
2015-04-21 18:04:57 +03:00
|
|
|
gfx::IntRect mTargetBounds;
|
2012-07-24 23:01:09 +04:00
|
|
|
ScreenRotation mTargetRotation;
|
2015-08-19 00:55:09 +03:00
|
|
|
dom::ScreenOrientationInternal mTargetOrientation;
|
2010-07-22 01:17:33 +04:00
|
|
|
|
|
|
|
private:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mOpen;
|
2012-11-06 13:11:43 +04:00
|
|
|
bool mRotationChanged;
|
2010-07-22 01:17:33 +04:00
|
|
|
|
|
|
|
// disabled
|
|
|
|
Transaction(const Transaction&);
|
|
|
|
Transaction& operator=(const Transaction&);
|
|
|
|
};
|
|
|
|
struct AutoTxnEnd {
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit AutoTxnEnd(Transaction* aTxn) : mTxn(aTxn) {}
|
2010-07-22 01:17:33 +04:00
|
|
|
~AutoTxnEnd() { mTxn->End(); }
|
|
|
|
Transaction* mTxn;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
void
|
2016-09-27 06:22:20 +03:00
|
|
|
KnowsCompositor::IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2013-07-12 06:32:09 +04:00
|
|
|
mTextureFactoryIdentifier = aIdentifier;
|
2014-12-13 04:50:47 +03:00
|
|
|
|
2017-08-07 13:15:24 +03:00
|
|
|
mSyncObject = SyncObjectClient::CreateSyncObjectClient(aIdentifier.mSyncHandle);
|
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
|
|
|
}
|
|
|
|
|
2016-10-07 11:13:32 +03:00
|
|
|
KnowsCompositor::KnowsCompositor()
|
|
|
|
: mSerial(++sSerialCounter)
|
|
|
|
{}
|
|
|
|
|
|
|
|
KnowsCompositor::~KnowsCompositor()
|
|
|
|
{}
|
|
|
|
|
2017-12-05 13:56:20 +03:00
|
|
|
KnowsCompositorMediaProxy::KnowsCompositorMediaProxy(const TextureFactoryIdentifier& aIdentifier)
|
|
|
|
{
|
|
|
|
mTextureFactoryIdentifier = aIdentifier;
|
|
|
|
// overwrite mSerial's value set by the parent class because we use the same serial
|
|
|
|
// as the KnowsCompositor we are proxying.
|
|
|
|
mThreadSafeAllocator = ImageBridgeChild::GetSingleton();
|
|
|
|
mSyncObject = mThreadSafeAllocator->GetSyncObject();
|
|
|
|
}
|
|
|
|
|
|
|
|
KnowsCompositorMediaProxy::~KnowsCompositorMediaProxy()
|
|
|
|
{}
|
|
|
|
|
|
|
|
TextureForwarder*
|
|
|
|
KnowsCompositorMediaProxy::GetTextureForwarder()
|
|
|
|
{
|
|
|
|
return mThreadSafeAllocator->GetTextureForwarder();
|
|
|
|
}
|
|
|
|
|
|
|
|
LayersIPCActor*
|
|
|
|
KnowsCompositorMediaProxy::GetLayersIPCActor()
|
|
|
|
{
|
|
|
|
return mThreadSafeAllocator->GetLayersIPCActor();
|
|
|
|
}
|
|
|
|
|
|
|
|
ActiveResourceTracker*
|
|
|
|
KnowsCompositorMediaProxy::GetActiveResourceTracker()
|
|
|
|
{
|
|
|
|
return mThreadSafeAllocator->GetActiveResourceTracker();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
KnowsCompositorMediaProxy::SyncWithCompositor()
|
|
|
|
{
|
|
|
|
mThreadSafeAllocator->SyncWithCompositor();
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<KnowsCompositor>
|
|
|
|
ShadowLayerForwarder::GetForMedia()
|
|
|
|
{
|
|
|
|
return MakeAndAddRef<KnowsCompositorMediaProxy>(GetTextureFactoryIdentifier());
|
|
|
|
}
|
|
|
|
|
2016-06-15 14:28:10 +03:00
|
|
|
ShadowLayerForwarder::ShadowLayerForwarder(ClientLayerManager* aClientLayerManager)
|
2016-07-20 02:59:30 +03:00
|
|
|
: mClientLayerManager(aClientLayerManager)
|
2016-06-15 14:28:10 +03:00
|
|
|
, mMessageLoop(MessageLoop::current())
|
2016-03-17 16:58:58 +03:00
|
|
|
, mDiagnosticTypes(DiagnosticTypes::NO_DIAGNOSTIC)
|
2012-03-12 19:50:15 +04:00
|
|
|
, mIsFirstPaint(false)
|
2013-06-20 17:01:20 +04:00
|
|
|
, mWindowOverlayChanged(false)
|
2016-12-21 18:43:47 +03:00
|
|
|
, mNextLayerHandle(1)
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
|
|
|
mTxn = new Transaction();
|
2017-03-29 08:49:20 +03:00
|
|
|
if (TabGroup* tabGroup = mClientLayerManager->GetTabGroup()) {
|
|
|
|
mEventTarget = tabGroup->EventTargetFor(TaskCategory::Other);
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mEventTarget || !XRE_IsContentProcess());
|
|
|
|
mActiveResourceTracker = MakeUnique<ActiveResourceTracker>(
|
|
|
|
1000, "CompositableForwarder", mEventTarget);
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
2016-11-08 05:24:36 +03:00
|
|
|
template<typename T>
|
|
|
|
struct ReleaseOnMainThreadTask : public Runnable
|
|
|
|
{
|
|
|
|
UniquePtr<T> mObj;
|
|
|
|
|
|
|
|
explicit ReleaseOnMainThreadTask(UniquePtr<T>& aObj)
|
2017-06-12 22:34:10 +03:00
|
|
|
: Runnable("layers::ReleaseOnMainThreadTask")
|
2018-05-30 22:15:35 +03:00
|
|
|
, mObj(std::move(aObj))
|
2016-11-08 05:24:36 +03:00
|
|
|
{}
|
|
|
|
|
|
|
|
NS_IMETHOD Run() override {
|
|
|
|
mObj = nullptr;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-07-22 01:17:33 +04:00
|
|
|
ShadowLayerForwarder::~ShadowLayerForwarder()
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mTxn->Finished(), "unfinished transaction?");
|
2010-07-22 01:17:33 +04:00
|
|
|
delete mTxn;
|
2014-05-06 05:56:40 +04:00
|
|
|
if (mShadowManager) {
|
|
|
|
mShadowManager->SetForwarder(nullptr);
|
2017-02-08 18:21:45 +03:00
|
|
|
if (NS_IsMainThread()) {
|
|
|
|
mShadowManager->Destroy();
|
|
|
|
} else {
|
2017-03-29 08:49:20 +03:00
|
|
|
if (mEventTarget) {
|
|
|
|
mEventTarget->Dispatch(
|
|
|
|
NewRunnableMethod("LayerTransactionChild::Destroy", mShadowManager,
|
|
|
|
&LayerTransactionChild::Destroy),
|
|
|
|
nsIEventTarget::DISPATCH_NORMAL);
|
|
|
|
} else {
|
|
|
|
NS_DispatchToMainThread(
|
2017-06-12 22:34:10 +03:00
|
|
|
NewRunnableMethod("layers::LayerTransactionChild::Destroy",
|
|
|
|
mShadowManager,
|
|
|
|
&LayerTransactionChild::Destroy));
|
2017-03-29 08:49:20 +03:00
|
|
|
}
|
2017-02-08 18:21:45 +03:00
|
|
|
}
|
2014-05-06 05:56:40 +04:00
|
|
|
}
|
2017-02-08 18:21:45 +03:00
|
|
|
|
2016-11-08 05:24:36 +03:00
|
|
|
if (!NS_IsMainThread()) {
|
2017-03-29 08:49:20 +03:00
|
|
|
RefPtr<ReleaseOnMainThreadTask<ActiveResourceTracker>> event =
|
|
|
|
new ReleaseOnMainThreadTask<ActiveResourceTracker>(mActiveResourceTracker);
|
|
|
|
if (mEventTarget) {
|
|
|
|
mEventTarget->Dispatch(event.forget(), nsIEventTarget::DISPATCH_NORMAL);
|
|
|
|
} else {
|
|
|
|
NS_DispatchToMainThread(event);
|
|
|
|
}
|
2016-11-08 05:24:36 +03:00
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-04-21 18:04:57 +03:00
|
|
|
ShadowLayerForwarder::BeginTransaction(const gfx::IntRect& aTargetBounds,
|
2012-11-22 06:40:57 +04:00
|
|
|
ScreenRotation aRotation,
|
2015-08-19 00:55:09 +03:00
|
|
|
dom::ScreenOrientationInternal aOrientation)
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
2016-10-18 03:35:00 +03:00
|
|
|
MOZ_ASSERT(IPCOpen(), "no manager to forward to");
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mTxn->Finished(), "uncommitted txn?");
|
2016-06-15 14:28:10 +03:00
|
|
|
UpdateFwdTransactionId();
|
2014-09-10 23:59:00 +04:00
|
|
|
mTxn->Begin(aTargetBounds, aRotation, aOrientation);
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
2016-12-21 18:43:47 +03:00
|
|
|
static const LayerHandle&
|
2010-07-22 01:17:33 +04:00
|
|
|
Shadow(ShadowableLayer* aLayer)
|
|
|
|
{
|
|
|
|
return aLayer->GetShadow();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename OpCreateT>
|
|
|
|
static void
|
|
|
|
CreatedLayer(Transaction* aTxn, ShadowableLayer* aLayer)
|
|
|
|
{
|
2016-12-21 18:43:47 +03:00
|
|
|
aTxn->AddEdit(OpCreateT(Shadow(aLayer)));
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-26 21:06:08 +04:00
|
|
|
ShadowLayerForwarder::CreatedPaintedLayer(ShadowableLayer* aThebes)
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
2014-09-26 21:06:08 +04:00
|
|
|
CreatedLayer<OpCreatePaintedLayer>(mTxn, aThebes);
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
void
|
|
|
|
ShadowLayerForwarder::CreatedContainerLayer(ShadowableLayer* aContainer)
|
|
|
|
{
|
|
|
|
CreatedLayer<OpCreateContainerLayer>(mTxn, aContainer);
|
|
|
|
}
|
|
|
|
void
|
|
|
|
ShadowLayerForwarder::CreatedImageLayer(ShadowableLayer* aImage)
|
|
|
|
{
|
|
|
|
CreatedLayer<OpCreateImageLayer>(mTxn, aImage);
|
|
|
|
}
|
|
|
|
void
|
|
|
|
ShadowLayerForwarder::CreatedColorLayer(ShadowableLayer* aColor)
|
|
|
|
{
|
|
|
|
CreatedLayer<OpCreateColorLayer>(mTxn, aColor);
|
|
|
|
}
|
|
|
|
void
|
|
|
|
ShadowLayerForwarder::CreatedCanvasLayer(ShadowableLayer* aCanvas)
|
|
|
|
{
|
|
|
|
CreatedLayer<OpCreateCanvasLayer>(mTxn, aCanvas);
|
|
|
|
}
|
2012-07-18 03:59:45 +04:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::CreatedRefLayer(ShadowableLayer* aRef)
|
|
|
|
{
|
|
|
|
CreatedLayer<OpCreateRefLayer>(mTxn, aRef);
|
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2010-09-03 07:05:01 +04:00
|
|
|
void
|
2010-07-22 01:17:33 +04:00
|
|
|
ShadowLayerForwarder::Mutated(ShadowableLayer* aMutant)
|
|
|
|
{
|
2017-01-25 03:41:18 +03:00
|
|
|
mTxn->AddMutant(aMutant);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowLayerForwarder::MutatedSimple(ShadowableLayer* aMutant)
|
|
|
|
{
|
|
|
|
mTxn->AddSimpleMutant(aMutant);
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowLayerForwarder::SetRoot(ShadowableLayer* aRoot)
|
|
|
|
{
|
2016-12-21 18:43:47 +03:00
|
|
|
mTxn->AddEdit(OpSetRoot(Shadow(aRoot)));
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
void
|
|
|
|
ShadowLayerForwarder::InsertAfter(ShadowableLayer* aContainer,
|
|
|
|
ShadowableLayer* aChild,
|
|
|
|
ShadowableLayer* aAfter)
|
|
|
|
{
|
2014-07-30 17:38:47 +04:00
|
|
|
if (!aChild->HasShadow()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (aAfter && !aAfter->HasShadow()) {
|
|
|
|
aAfter = aAfter->AsLayer()->GetPrevSibling() ? aAfter->AsLayer()->GetPrevSibling()->AsShadowableLayer() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aAfter) {
|
2016-12-21 18:43:47 +03:00
|
|
|
mTxn->AddEdit(OpInsertAfter(Shadow(aContainer), Shadow(aChild), Shadow(aAfter)));
|
2014-07-30 17:38:47 +04:00
|
|
|
} else {
|
2016-12-21 18:43:47 +03:00
|
|
|
mTxn->AddEdit(OpPrependChild(Shadow(aContainer), Shadow(aChild)));
|
2014-07-30 17:38:47 +04:00
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
void
|
|
|
|
ShadowLayerForwarder::RemoveChild(ShadowableLayer* aContainer,
|
|
|
|
ShadowableLayer* aChild)
|
|
|
|
{
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG(("[LayersForwarder] OpRemoveChild container=%p child=%p\n",
|
|
|
|
aContainer->AsLayer(), aChild->AsLayer()));
|
|
|
|
|
2014-07-30 17:38:47 +04:00
|
|
|
if (!aChild->HasShadow()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-21 18:43:47 +03:00
|
|
|
mTxn->AddEdit(OpRemoveChild(Shadow(aContainer), Shadow(aChild)));
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
2012-08-29 14:52:55 +04:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::RepositionChild(ShadowableLayer* aContainer,
|
|
|
|
ShadowableLayer* aChild,
|
|
|
|
ShadowableLayer* aAfter)
|
|
|
|
{
|
2014-07-30 17:38:47 +04:00
|
|
|
if (!aChild->HasShadow()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (aAfter && !aAfter->HasShadow()) {
|
|
|
|
aAfter = aAfter->AsLayer()->GetPrevSibling() ? aAfter->AsLayer()->GetPrevSibling()->AsShadowableLayer() : nullptr;
|
|
|
|
}
|
|
|
|
|
2013-03-22 06:17:28 +04:00
|
|
|
if (aAfter) {
|
|
|
|
MOZ_LAYERS_LOG(("[LayersForwarder] OpRepositionChild container=%p child=%p after=%p",
|
|
|
|
aContainer->AsLayer(), aChild->AsLayer(), aAfter->AsLayer()));
|
2016-12-21 18:43:47 +03:00
|
|
|
mTxn->AddEdit(OpRepositionChild(Shadow(aContainer), Shadow(aChild), Shadow(aAfter)));
|
2013-03-22 06:17:28 +04:00
|
|
|
} else {
|
|
|
|
MOZ_LAYERS_LOG(("[LayersForwarder] OpRaiseToTopChild container=%p child=%p",
|
|
|
|
aContainer->AsLayer(), aChild->AsLayer()));
|
2016-12-21 18:43:47 +03:00
|
|
|
mTxn->AddEdit(OpRaiseToTopChild(Shadow(aContainer), Shadow(aChild)));
|
2013-03-22 06:17:28 +04:00
|
|
|
}
|
2012-08-29 14:52:55 +04:00
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2013-10-21 18:23:42 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
ShadowLayerForwarder::CheckSurfaceDescriptor(const SurfaceDescriptor* aDescriptor) const
|
|
|
|
{
|
|
|
|
if (!aDescriptor) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
if (aDescriptor->type() == SurfaceDescriptor::TSurfaceDescriptorBuffer &&
|
|
|
|
aDescriptor->get_SurfaceDescriptorBuffer().data().type() == MemoryOrShmem::TShmem) {
|
|
|
|
const Shmem& shmem = aDescriptor->get_SurfaceDescriptorBuffer().data().get_Shmem();
|
|
|
|
shmem.AssertInvariants();
|
2013-11-01 10:36:02 +04:00
|
|
|
MOZ_ASSERT(mShadowManager &&
|
2015-12-16 21:50:58 +03:00
|
|
|
mShadowManager->IsTrackingSharedMemory(shmem.mSegment));
|
2013-10-21 18:23:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-04-13 19:17:39 +04:00
|
|
|
void
|
2014-03-08 01:34:04 +04:00
|
|
|
ShadowLayerForwarder::UseTiledLayerBuffer(CompositableClient* aCompositable,
|
|
|
|
const SurfaceDescriptorTiles& aTileLayerDescriptor)
|
2012-04-13 19:17:39 +04:00
|
|
|
{
|
2016-11-10 05:26:48 +03:00
|
|
|
MOZ_ASSERT(aCompositable);
|
|
|
|
|
|
|
|
if (!aCompositable->IsConnected()) {
|
|
|
|
return;
|
|
|
|
}
|
2015-11-06 18:56:03 +03:00
|
|
|
|
2017-01-18 05:47:06 +03:00
|
|
|
mTxn->AddNoSwapPaint(CompositableOperation(aCompositable->GetIPCHandle(),
|
2016-03-25 11:35:16 +03:00
|
|
|
OpUseTiledLayerBuffer(aTileLayerDescriptor)));
|
2012-04-13 19:17:39 +04:00
|
|
|
}
|
|
|
|
|
2010-07-22 01:17:33 +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
|
|
|
ShadowLayerForwarder::UpdateTextureRegion(CompositableClient* aCompositable,
|
|
|
|
const ThebesBufferData& aThebesBufferData,
|
|
|
|
const nsIntRegion& aUpdatedRegion)
|
2010-07-22 01:17:33 +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
|
|
|
MOZ_ASSERT(aCompositable);
|
2016-11-10 05:26:48 +03:00
|
|
|
|
|
|
|
if (!aCompositable->IsConnected()) {
|
|
|
|
return;
|
|
|
|
}
|
2015-11-06 18:56:03 +03:00
|
|
|
|
2017-02-14 11:10:36 +03:00
|
|
|
mTxn->AddNoSwapPaint(
|
2016-03-25 11:35:16 +03:00
|
|
|
CompositableOperation(
|
2017-01-18 05:47:06 +03:00
|
|
|
aCompositable->GetIPCHandle(),
|
2016-03-25 11:35:16 +03:00
|
|
|
OpPaintTextureRegion(aThebesBufferData, aUpdatedRegion)));
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
void
|
2015-07-03 13:37:03 +03:00
|
|
|
ShadowLayerForwarder::UseTextures(CompositableClient* aCompositable,
|
|
|
|
const nsTArray<TimedTextureClient>& aTextures)
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
2016-11-10 05:26:48 +03:00
|
|
|
MOZ_ASSERT(aCompositable);
|
|
|
|
|
|
|
|
if (!aCompositable->IsConnected()) {
|
|
|
|
return;
|
|
|
|
}
|
2015-07-03 13:37:03 +03:00
|
|
|
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<TimedTexture,4> textures;
|
2015-07-03 13:37:03 +03:00
|
|
|
|
|
|
|
for (auto& t : aTextures) {
|
|
|
|
MOZ_ASSERT(t.mTextureClient);
|
|
|
|
MOZ_ASSERT(t.mTextureClient->GetIPDLActor());
|
2016-07-26 21:56:35 +03:00
|
|
|
MOZ_RELEASE_ASSERT(t.mTextureClient->GetIPDLActor()->GetIPCChannel() == mShadowManager->GetIPCChannel());
|
2018-03-12 16:10:13 +03:00
|
|
|
bool readLocked = t.mTextureClient->OnForwardedToHost();
|
2015-07-03 13:37:03 +03:00
|
|
|
textures.AppendElement(TimedTexture(nullptr, t.mTextureClient->GetIPDLActor(),
|
2015-07-06 06:02:26 +03:00
|
|
|
t.mTimeStamp, t.mPictureRect,
|
2018-03-12 16:10:13 +03:00
|
|
|
t.mFrameID, t.mProducerID,
|
|
|
|
readLocked));
|
2016-06-15 14:28:10 +03:00
|
|
|
mClientLayerManager->GetCompositorBridgeChild()->HoldUntilCompositableRefReleasedIfNecessary(t.mTextureClient);
|
2015-07-03 13:37:03 +03:00
|
|
|
}
|
2017-01-18 05:47:06 +03:00
|
|
|
mTxn->AddEdit(CompositableOperation(aCompositable->GetIPCHandle(),
|
2016-03-25 11:35:16 +03:00
|
|
|
OpUseTexture(textures)));
|
2013-12-11 22:05:11 +04:00
|
|
|
}
|
|
|
|
|
2014-02-06 15:28:29 +04:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::UseComponentAlphaTextures(CompositableClient* aCompositable,
|
|
|
|
TextureClient* aTextureOnBlack,
|
|
|
|
TextureClient* aTextureOnWhite)
|
|
|
|
{
|
2014-04-11 20:47:56 +04:00
|
|
|
MOZ_ASSERT(aCompositable);
|
2016-11-10 05:26:48 +03:00
|
|
|
|
|
|
|
if (!aCompositable->IsConnected()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-11 20:47:56 +04:00
|
|
|
MOZ_ASSERT(aTextureOnWhite);
|
|
|
|
MOZ_ASSERT(aTextureOnBlack);
|
2017-01-18 05:47:06 +03:00
|
|
|
MOZ_ASSERT(aCompositable->GetIPCHandle());
|
2014-04-11 20:47:56 +04:00
|
|
|
MOZ_ASSERT(aTextureOnBlack->GetIPDLActor());
|
|
|
|
MOZ_ASSERT(aTextureOnWhite->GetIPDLActor());
|
2014-03-21 21:03:20 +04:00
|
|
|
MOZ_ASSERT(aTextureOnBlack->GetSize() == aTextureOnWhite->GetSize());
|
2016-07-26 21:56:35 +03:00
|
|
|
MOZ_RELEASE_ASSERT(aTextureOnWhite->GetIPDLActor()->GetIPCChannel() == mShadowManager->GetIPCChannel());
|
|
|
|
MOZ_RELEASE_ASSERT(aTextureOnBlack->GetIPDLActor()->GetIPCChannel() == mShadowManager->GetIPCChannel());
|
2015-11-06 18:56:03 +03:00
|
|
|
|
2018-03-12 16:10:13 +03:00
|
|
|
bool readLockedB = aTextureOnBlack->OnForwardedToHost();
|
|
|
|
bool readLockedW = aTextureOnWhite->OnForwardedToHost();
|
2016-06-02 12:00:23 +03:00
|
|
|
|
2016-06-15 14:28:10 +03:00
|
|
|
mClientLayerManager->GetCompositorBridgeChild()->HoldUntilCompositableRefReleasedIfNecessary(aTextureOnBlack);
|
|
|
|
mClientLayerManager->GetCompositorBridgeChild()->HoldUntilCompositableRefReleasedIfNecessary(aTextureOnWhite);
|
|
|
|
|
2016-03-25 11:35:16 +03:00
|
|
|
mTxn->AddEdit(
|
|
|
|
CompositableOperation(
|
2017-01-18 05:47:06 +03:00
|
|
|
aCompositable->GetIPCHandle(),
|
2016-03-25 11:35:16 +03:00
|
|
|
OpUseComponentAlphaTextures(
|
|
|
|
nullptr, aTextureOnBlack->GetIPDLActor(),
|
2016-06-02 12:00:23 +03:00
|
|
|
nullptr, aTextureOnWhite->GetIPDLActor(),
|
2018-03-12 16:10:13 +03:00
|
|
|
readLockedB, readLockedW)
|
2016-06-02 12:00:23 +03:00
|
|
|
)
|
|
|
|
);
|
2014-02-06 15:28:29 +04:00
|
|
|
}
|
|
|
|
|
2016-01-07 13:17:40 +03:00
|
|
|
static bool
|
2017-02-16 01:28:24 +03:00
|
|
|
AddOpDestroy(Transaction* aTxn, const OpDestroy& op)
|
2016-01-07 13:17:40 +03:00
|
|
|
{
|
|
|
|
if (!aTxn->Opened()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
aTxn->mDestroyedActors.AppendElement(op);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-02-16 01:28:24 +03:00
|
|
|
ShadowLayerForwarder::DestroyInTransaction(PTextureChild* aTexture)
|
2016-01-07 13:17:40 +03:00
|
|
|
{
|
2017-02-16 01:28:24 +03:00
|
|
|
return AddOpDestroy(mTxn, OpDestroy(aTexture));
|
2016-01-07 13:17:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-01-18 05:47:06 +03:00
|
|
|
ShadowLayerForwarder::DestroyInTransaction(const CompositableHandle& aHandle)
|
2016-01-07 13:17:40 +03:00
|
|
|
{
|
2017-02-16 01:28:24 +03:00
|
|
|
return AddOpDestroy(mTxn, OpDestroy(aHandle));
|
2016-01-07 13:17:40 +03:00
|
|
|
}
|
|
|
|
|
2014-02-11 00:52:35 +04:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::RemoveTextureFromCompositable(CompositableClient* aCompositable,
|
|
|
|
TextureClient* aTexture)
|
|
|
|
{
|
2014-04-11 20:47:56 +04:00
|
|
|
MOZ_ASSERT(aCompositable);
|
|
|
|
MOZ_ASSERT(aTexture);
|
|
|
|
MOZ_ASSERT(aTexture->GetIPDLActor());
|
2016-07-26 21:56:35 +03:00
|
|
|
MOZ_RELEASE_ASSERT(aTexture->GetIPDLActor()->GetIPCChannel() == mShadowManager->GetIPCChannel());
|
2015-11-06 18:56:03 +03:00
|
|
|
if (!aCompositable->IsConnected() || !aTexture->GetIPDLActor()) {
|
|
|
|
// We don't have an actor anymore, don't try to use it!
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-25 11:35:16 +03:00
|
|
|
mTxn->AddEdit(
|
|
|
|
CompositableOperation(
|
2017-01-18 05:47:06 +03:00
|
|
|
aCompositable->GetIPCHandle(),
|
2016-03-25 11:35:16 +03:00
|
|
|
OpRemoveTexture(nullptr, aTexture->GetIPDLActor())));
|
2014-02-11 00:52:35 +04:00
|
|
|
}
|
|
|
|
|
2014-07-31 10:44:31 +04:00
|
|
|
bool
|
|
|
|
ShadowLayerForwarder::InWorkerThread()
|
|
|
|
{
|
2016-09-27 06:22:20 +03:00
|
|
|
return MessageLoop::current() && (GetTextureForwarder()->GetMessageLoop()->id() == MessageLoop::current()->id());
|
2014-07-31 10:44:31 +04:00
|
|
|
}
|
|
|
|
|
2015-01-29 22:41:55 +03:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::StorePluginWidgetConfigurations(const nsTArray<nsIWidget::Configuration>&
|
|
|
|
aConfigurations)
|
|
|
|
{
|
|
|
|
// Cache new plugin widget configs here until we call update, at which
|
|
|
|
// point this data will get shipped over to chrome.
|
|
|
|
mPluginWindowData.Clear();
|
|
|
|
for (uint32_t idx = 0; idx < aConfigurations.Length(); idx++) {
|
|
|
|
const nsIWidget::Configuration& configuration = aConfigurations[idx];
|
|
|
|
mPluginWindowData.AppendElement(PluginWindowData(configuration.mWindowID,
|
|
|
|
configuration.mClipRegion,
|
2015-12-03 01:32:55 +03:00
|
|
|
configuration.mBounds,
|
2015-01-29 22:41:55 +03:00
|
|
|
configuration.mVisible));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-16 18:46:13 +03:00
|
|
|
void
|
2018-04-20 22:13:06 +03:00
|
|
|
ShadowLayerForwarder::SendPaintTime(TransactionId aId, TimeDuration aPaintTime)
|
2016-08-16 18:46:13 +03:00
|
|
|
{
|
2016-10-18 03:35:00 +03:00
|
|
|
if (!IPCOpen() ||
|
2016-08-16 18:46:13 +03:00
|
|
|
!mShadowManager->SendPaintTime(aId, aPaintTime)) {
|
|
|
|
NS_WARNING("Could not send paint times over IPC");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2017-01-18 05:47:05 +03:00
|
|
|
ShadowLayerForwarder::EndTransaction(const nsIntRegion& aRegionToClear,
|
2018-04-20 22:13:06 +03:00
|
|
|
TransactionId aId,
|
2014-03-28 07:38:32 +04:00
|
|
|
bool aScheduleComposite,
|
2014-05-07 01:26:13 +04:00
|
|
|
uint32_t aPaintSequenceNumber,
|
2014-05-31 02:52:43 +04:00
|
|
|
bool aIsRepeatTransaction,
|
2018-06-26 21:40:10 +03:00
|
|
|
const mozilla::TimeStamp& aRefreshStart,
|
2014-08-28 23:24:26 +04:00
|
|
|
const mozilla::TimeStamp& aTransactionStart,
|
2014-03-28 07:38:32 +04:00
|
|
|
bool* aSent)
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
2013-10-22 00:14:47 +04:00
|
|
|
*aSent = false;
|
|
|
|
|
2017-01-04 20:58:58 +03:00
|
|
|
TransactionInfo info;
|
|
|
|
|
2016-10-18 03:35:00 +03:00
|
|
|
MOZ_ASSERT(IPCOpen(), "no manager to forward to");
|
2016-10-12 04:04:00 +03:00
|
|
|
if (!IPCOpen()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-11 05:44:45 +03:00
|
|
|
Maybe<TimeStamp> startTime;
|
|
|
|
if (gfxPrefs::LayersDrawFPS()) {
|
|
|
|
startTime = Some(TimeStamp::Now());
|
|
|
|
}
|
|
|
|
|
2016-09-27 06:22:20 +03:00
|
|
|
GetCompositorBridgeChild()->WillEndTransaction();
|
2016-02-23 21:15:24 +03:00
|
|
|
|
2018-04-20 22:13:06 +03:00
|
|
|
MOZ_ASSERT(aId.IsValid());
|
2014-05-29 01:42:14 +04:00
|
|
|
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 10:08:53 +03:00
|
|
|
AUTO_PROFILER_LABEL("ShadowLayerForwarder::EndTransaction", GRAPHICS);
|
2014-05-24 01:12:29 +04:00
|
|
|
|
2012-02-28 20:24:24 +04:00
|
|
|
RenderTraceScope rendertrace("Foward Transaction", "000091");
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mTxn->Finished(), "forgot BeginTransaction?");
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2013-08-03 02:50:17 +04:00
|
|
|
DiagnosticTypes diagnostics = gfxPlatform::GetPlatform()->GetLayerDiagnosticTypes();
|
|
|
|
if (mDiagnosticTypes != diagnostics) {
|
|
|
|
mDiagnosticTypes = diagnostics;
|
|
|
|
mTxn->AddEdit(OpSetDiagnosticTypes(diagnostics));
|
2013-03-21 21:08:01 +04:00
|
|
|
}
|
2015-10-30 13:49:07 +03:00
|
|
|
if (mWindowOverlayChanged) {
|
|
|
|
mTxn->AddEdit(OpWindowOverlayChanged());
|
|
|
|
}
|
2013-03-21 21:08:01 +04:00
|
|
|
|
2010-07-22 01:17:33 +04:00
|
|
|
AutoTxnEnd _(mTxn);
|
|
|
|
|
2015-10-30 13:49:07 +03:00
|
|
|
if (mTxn->Empty() && !mTxn->RotationChanged()) {
|
2012-11-06 13:11:43 +04:00
|
|
|
MOZ_LAYERS_LOG(("[LayersForwarder] 0-length cset (?) and no rotation event, skipping Update()"));
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
2017-01-12 20:49:30 +03:00
|
|
|
if (!mTxn->mPaints.IsEmpty()) {
|
2015-05-04 13:35:18 +03:00
|
|
|
// With some platforms, telling the drawing backend that there will be no more
|
|
|
|
// drawing for this frame helps with preventing command queues from spanning
|
|
|
|
// across multiple frames.
|
|
|
|
gfxPlatform::GetPlatform()->FlushContentDrawing();
|
|
|
|
}
|
|
|
|
|
2010-09-14 09:23:08 +04:00
|
|
|
MOZ_LAYERS_LOG(("[LayersForwarder] destroying buffers..."));
|
|
|
|
|
2010-09-14 09:23:08 +04:00
|
|
|
MOZ_LAYERS_LOG(("[LayersForwarder] building transaction..."));
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2017-01-25 03:41:18 +03:00
|
|
|
nsTArray<OpSetSimpleLayerAttributes> setSimpleAttrs;
|
|
|
|
for (ShadowableLayerSet::Iterator it(&mTxn->mSimpleMutants); !it.Done(); it.Next()) {
|
|
|
|
ShadowableLayer* shadow = it.Get()->GetKey();
|
|
|
|
if (!shadow->HasShadow()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Layer* mutant = shadow->AsLayer();
|
|
|
|
setSimpleAttrs.AppendElement(OpSetSimpleLayerAttributes(
|
|
|
|
Shadow(shadow),
|
|
|
|
mutant->GetSimpleAttributes()));
|
|
|
|
}
|
|
|
|
|
2017-01-25 03:41:18 +03:00
|
|
|
nsTArray<OpSetLayerAttributes> setAttrs;
|
|
|
|
|
2010-09-16 01:03:13 +04:00
|
|
|
// We purposely add attribute-change ops to the final changeset
|
|
|
|
// before we add paint ops. This allows layers to record the
|
|
|
|
// attribute changes before new pixels arrive, which can be useful
|
|
|
|
// for setting up back/front buffers.
|
2012-02-28 20:24:24 +04:00
|
|
|
RenderTraceScope rendertrace2("Foward Transaction", "000092");
|
2016-10-13 18:27:58 +03:00
|
|
|
for (ShadowableLayerSet::Iterator it(&mTxn->mMutants);
|
|
|
|
!it.Done(); it.Next()) {
|
|
|
|
ShadowableLayer* shadow = it.Get()->GetKey();
|
2014-07-30 17:38:47 +04:00
|
|
|
|
|
|
|
if (!shadow->HasShadow()) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
Layer* mutant = shadow->AsLayer();
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!!mutant, "unshadowable layer?");
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2017-01-25 03:41:18 +03:00
|
|
|
OpSetLayerAttributes op;
|
|
|
|
op.layer() = Shadow(shadow);
|
|
|
|
|
|
|
|
LayerAttributes& attrs = op.attrs();
|
2010-07-22 01:17:33 +04:00
|
|
|
CommonLayerAttributes& common = attrs.common();
|
|
|
|
common.visibleRegion() = mutant->GetVisibleRegion();
|
2013-12-16 14:47:06 +04:00
|
|
|
common.eventRegions() = mutant->GetEventRegions();
|
2010-07-22 01:17:33 +04:00
|
|
|
common.useClipRect() = !!mutant->GetClipRect();
|
|
|
|
common.clipRect() = (common.useClipRect() ?
|
2015-04-12 05:03:00 +03:00
|
|
|
*mutant->GetClipRect() : ParentLayerIntRect());
|
2012-03-19 03:02:38 +04:00
|
|
|
if (Layer* maskLayer = mutant->GetMaskLayer()) {
|
2016-12-21 18:43:47 +03:00
|
|
|
common.maskLayer() = Shadow(maskLayer->AsShadowableLayer());
|
2012-03-19 03:02:38 +04:00
|
|
|
} else {
|
2016-12-21 18:43:47 +03:00
|
|
|
common.maskLayer() = LayerHandle();
|
2012-03-19 03:02:38 +04:00
|
|
|
}
|
2017-02-08 22:31:45 +03:00
|
|
|
common.compositorAnimations().id() = mutant->GetCompositorAnimationsId();
|
|
|
|
common.compositorAnimations().animations() = mutant->GetAnimations();
|
2016-04-18 20:49:14 +03:00
|
|
|
common.invalidRegion() = mutant->GetInvalidRegion().GetRegion();
|
2016-03-29 02:14:52 +03:00
|
|
|
common.scrollMetadata() = mutant->GetAllScrollMetadata();
|
2015-06-21 19:27:31 +03:00
|
|
|
for (size_t i = 0; i < mutant->GetAncestorMaskLayerCount(); i++) {
|
|
|
|
auto layer = Shadow(mutant->GetAncestorMaskLayerAt(i)->AsShadowableLayer());
|
2016-12-21 18:43:47 +03:00
|
|
|
common.ancestorMaskLayers().AppendElement(layer);
|
2015-06-21 19:27:31 +03:00
|
|
|
}
|
2015-08-03 09:11:00 +03:00
|
|
|
nsCString log;
|
|
|
|
mutant->GetDisplayListLog(log);
|
|
|
|
common.displayListLog() = log;
|
|
|
|
|
2010-07-22 01:17:33 +04:00
|
|
|
attrs.specific() = null_t();
|
|
|
|
mutant->FillSpecificAttributes(attrs.specific());
|
|
|
|
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG(("[LayersForwarder] OpSetLayerAttributes(%p)\n", mutant));
|
|
|
|
|
2017-01-25 03:41:18 +03:00
|
|
|
setAttrs.AppendElement(op);
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
2017-01-12 20:49:30 +03:00
|
|
|
if (mTxn->mCset.IsEmpty() &&
|
|
|
|
mTxn->mPaints.IsEmpty() &&
|
2017-01-25 03:41:18 +03:00
|
|
|
setAttrs.IsEmpty() &&
|
2017-01-12 20:49:30 +03:00
|
|
|
!mTxn->RotationChanged())
|
|
|
|
{
|
2016-10-04 05:14:56 +03:00
|
|
|
return true;
|
|
|
|
}
|
2010-09-16 01:03:13 +04:00
|
|
|
|
2013-06-20 17:01:20 +04:00
|
|
|
mWindowOverlayChanged = false;
|
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
info.cset() = std::move(mTxn->mCset);
|
|
|
|
info.setSimpleAttrs() = std::move(setSimpleAttrs);
|
|
|
|
info.setAttrs() = std::move(setAttrs);
|
|
|
|
info.paints() = std::move(mTxn->mPaints);
|
2017-01-04 20:58:58 +03:00
|
|
|
info.toDestroy() = mTxn->mDestroyedActors;
|
|
|
|
info.fwdTransactionId() = GetFwdTransactionId();
|
|
|
|
info.id() = aId;
|
|
|
|
info.plugins() = mPluginWindowData;
|
|
|
|
info.isFirstPaint() = mIsFirstPaint;
|
2017-06-13 09:00:49 +03:00
|
|
|
info.focusTarget() = mFocusTarget;
|
2017-01-04 20:58:58 +03:00
|
|
|
info.scheduleComposite() = aScheduleComposite;
|
|
|
|
info.paintSequenceNumber() = aPaintSequenceNumber;
|
|
|
|
info.isRepeatTransaction() = aIsRepeatTransaction;
|
2018-06-26 21:40:10 +03:00
|
|
|
info.refreshStart() = aRefreshStart;
|
2017-01-04 20:58:58 +03:00
|
|
|
info.transactionStart() = aTransactionStart;
|
2017-08-11 04:57:21 +03:00
|
|
|
#if defined(ENABLE_FRAME_LATENCY_LOG)
|
|
|
|
info.fwdTime() = TimeStamp::Now();
|
|
|
|
#endif
|
2017-01-04 20:58:58 +03:00
|
|
|
|
2014-03-28 07:38:32 +04:00
|
|
|
TargetConfig targetConfig(mTxn->mTargetBounds,
|
|
|
|
mTxn->mTargetRotation,
|
|
|
|
mTxn->mTargetOrientation,
|
|
|
|
aRegionToClear);
|
2017-01-04 20:58:58 +03:00
|
|
|
info.targetConfig() = targetConfig;
|
2012-07-24 23:01:09 +04:00
|
|
|
|
2016-09-27 06:22:20 +03:00
|
|
|
if (!GetTextureForwarder()->IsSameProcess()) {
|
2014-06-11 17:52:20 +04:00
|
|
|
MOZ_LAYERS_LOG(("[LayersForwarder] syncing before send..."));
|
|
|
|
PlatformSyncBeforeUpdate();
|
|
|
|
}
|
2010-09-14 09:23:08 +04:00
|
|
|
|
2017-04-11 05:44:45 +03:00
|
|
|
if (startTime) {
|
|
|
|
mPaintTiming.serializeMs() = (TimeStamp::Now() - startTime.value()).ToMilliseconds();
|
|
|
|
startTime = Some(TimeStamp::Now());
|
|
|
|
}
|
|
|
|
|
2017-07-06 01:19:52 +03:00
|
|
|
// We delay at the last possible minute, to give the paint thread a chance to
|
|
|
|
// finish. If it does we don't have to delay messages at all.
|
|
|
|
GetCompositorBridgeChild()->PostponeMessagesIfAsyncPainting();
|
|
|
|
|
2018-07-22 15:02:26 +03:00
|
|
|
if (recordreplay::IsRecordingOrReplaying()) {
|
|
|
|
recordreplay::child::NotifyPaintStart();
|
|
|
|
}
|
|
|
|
|
2017-02-16 01:31:18 +03:00
|
|
|
MOZ_LAYERS_LOG(("[LayersForwarder] sending transaction..."));
|
|
|
|
RenderTraceScope rendertrace3("Forward Transaction", "000093");
|
|
|
|
if (!mShadowManager->SendUpdate(info)) {
|
|
|
|
MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
|
|
|
|
return false;
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
2018-07-22 15:02:26 +03:00
|
|
|
if (recordreplay::IsRecordingOrReplaying()) {
|
|
|
|
recordreplay::child::WaitForPaintToComplete();
|
|
|
|
}
|
|
|
|
|
2017-04-11 05:44:45 +03:00
|
|
|
if (startTime) {
|
|
|
|
mPaintTiming.sendMs() = (TimeStamp::Now() - startTime.value()).ToMilliseconds();
|
|
|
|
mShadowManager->SendRecordPaintTimes(mPaintTiming);
|
|
|
|
}
|
|
|
|
|
2013-10-22 00:14:47 +04:00
|
|
|
*aSent = true;
|
2012-03-12 19:50:15 +04:00
|
|
|
mIsFirstPaint = false;
|
2017-06-13 09:00:49 +03:00
|
|
|
mFocusTarget = FocusTarget();
|
2010-07-22 01:17:33 +04:00
|
|
|
MOZ_LAYERS_LOG(("[LayersForwarder] ... done"));
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
2017-01-18 05:47:06 +03:00
|
|
|
RefPtr<CompositableClient>
|
|
|
|
ShadowLayerForwarder::FindCompositable(const CompositableHandle& aHandle)
|
|
|
|
{
|
|
|
|
CompositableClient* client = nullptr;
|
|
|
|
if (!mCompositables.Get(aHandle.Value(), &client)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return client;
|
|
|
|
}
|
|
|
|
|
2016-07-23 02:36:45 +03:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::SetLayerObserverEpoch(uint64_t aLayerObserverEpoch)
|
|
|
|
{
|
2016-10-18 03:35:00 +03:00
|
|
|
if (!IPCOpen()) {
|
2016-07-23 02:36:45 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
Unused << mShadowManager->SendSetLayerObserverEpoch(aLayerObserverEpoch);
|
|
|
|
}
|
|
|
|
|
Bug 1265824 - Wait on texture handles with IPC r=jld,mattwoodrow
There's a lot going on here, but it all fits under the idea of
being able to communicate about texture locking statuses
without spinning on IsReadLocked. This is a bit of a trade -
we could just always allocate/grab a texture from the pool,
which would put a smaller cap on the amount of time we can
possibly spend when a texture is locked. However, this eats
up more CPU and memory than waiting on the textures to unlock,
and could take longer, especially if there were a large number
of textures which we just need to wait for for a short amount
of time. In any case, we very rarely hit the case where we
actually need to wait on the sync IPC to the compositor - most
of the time the textures are already unlocked.
There is also an async IPC call in here, which we make before
flushing async paints. This just causes the compositor to
check whether the GPU is done with its textures or not and
unlock them if it is. This helps us avoid the case where we
take a long time painting asynchronously, turn IPC back on at
the end of that, and then have to wait for the compositor
to to get into TiledLayerBufferComposite::UseTiles before
getting a response. Specifically this eliminates several talos
regressions which use ASAP mode.
Lastly, there seem to be no other cases of static Monitors
being used. This seems like it falls under similar use cases
as StaticMutexes, so I added it in. I can move it into its own
file if we think it might be generally useful in the future.
MozReview-Commit-ID: IYQLwUqMxg2
--HG--
extra : rebase_source : 4f05832f51dae6db98773dcad03cb008a80eca6c
2018-05-06 01:46:26 +03:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::UpdateTextureLocks()
|
|
|
|
{
|
|
|
|
#ifdef XP_DARWIN
|
|
|
|
if (!IPCOpen()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto compositorBridge = GetCompositorBridgeChild();
|
|
|
|
if (compositorBridge) {
|
|
|
|
auto pid = compositorBridge->OtherPid();
|
|
|
|
TextureSync::UpdateTextureLocks(pid);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowLayerForwarder::SyncTextures(const nsTArray<uint64_t>& aSerials)
|
|
|
|
{
|
|
|
|
#ifdef XP_DARWIN
|
|
|
|
if (!IPCOpen()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto compositorBridge = GetCompositorBridgeChild();
|
|
|
|
if (compositorBridge) {
|
|
|
|
auto pid = compositorBridge->OtherPid();
|
|
|
|
TextureSync::WaitForTextures(pid, aSerials);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-12-21 18:43:47 +03:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::ReleaseLayer(const LayerHandle& aHandle)
|
|
|
|
{
|
|
|
|
if (!IPCOpen()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Unused << mShadowManager->SendReleaseLayer(aHandle);
|
|
|
|
}
|
|
|
|
|
2013-11-27 19:18:38 +04:00
|
|
|
bool
|
|
|
|
ShadowLayerForwarder::IPCOpen() const
|
|
|
|
{
|
2014-11-19 23:22:03 +03:00
|
|
|
return HasShadowManager() && mShadowManager->IPCOpen();
|
2013-11-27 19:18:38 +04:00
|
|
|
}
|
|
|
|
|
2013-11-01 10:36:02 +04:00
|
|
|
/**
|
|
|
|
* We bail out when we have no shadow manager. That can happen when the
|
|
|
|
* layer manager is created by the preallocated process.
|
|
|
|
* See bug 914843 for details.
|
|
|
|
*/
|
2016-12-21 18:43:47 +03:00
|
|
|
LayerHandle
|
2010-07-22 01:17:33 +04:00
|
|
|
ShadowLayerForwarder::ConstructShadowFor(ShadowableLayer* aLayer)
|
|
|
|
{
|
2016-12-21 18:43:47 +03:00
|
|
|
return LayerHandle(mNextLayerHandle++);
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
2010-09-14 09:23:08 +04:00
|
|
|
#if !defined(MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS)
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ShadowLayerForwarder::PlatformSyncBeforeUpdate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // !defined(MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS)
|
|
|
|
|
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
|
|
|
void
|
2015-07-06 06:02:26 +03:00
|
|
|
ShadowLayerForwarder::Connect(CompositableClient* aCompositable,
|
|
|
|
ImageContainer* aImageContainer)
|
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
|
|
|
{
|
|
|
|
#ifdef GFX_COMPOSITOR_LOGGING
|
|
|
|
printf("ShadowLayerForwarder::Connect(Compositable)\n");
|
|
|
|
#endif
|
|
|
|
MOZ_ASSERT(aCompositable);
|
2013-11-01 10:36:02 +04:00
|
|
|
MOZ_ASSERT(mShadowManager);
|
2016-10-18 03:35:00 +03:00
|
|
|
if (!IPCOpen()) {
|
2014-04-16 05:59:09 +04:00
|
|
|
return;
|
|
|
|
}
|
2017-01-18 05:47:06 +03:00
|
|
|
|
|
|
|
static uint64_t sNextID = 1;
|
|
|
|
uint64_t id = sNextID++;
|
|
|
|
|
|
|
|
mCompositables.Put(id, aCompositable);
|
|
|
|
|
|
|
|
CompositableHandle handle(id);
|
|
|
|
aCompositable->InitIPDL(handle);
|
|
|
|
mShadowManager->SendNewCompositable(handle, aCompositable->GetTextureInfo());
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void ShadowLayerForwarder::Attach(CompositableClient* aCompositable,
|
|
|
|
ShadowableLayer* aLayer)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aLayer);
|
|
|
|
MOZ_ASSERT(aCompositable);
|
2017-01-18 05:47:06 +03:00
|
|
|
mTxn->AddEdit(OpAttachCompositable(Shadow(aLayer), aCompositable->GetIPCHandle()));
|
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
|
|
|
}
|
|
|
|
|
2017-01-18 05:47:05 +03:00
|
|
|
void ShadowLayerForwarder::AttachAsyncCompositable(const CompositableHandle& aHandle,
|
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
|
|
|
ShadowableLayer* aLayer)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aLayer);
|
2017-01-18 05:47:05 +03:00
|
|
|
MOZ_ASSERT(aHandle);
|
2017-01-18 05:47:06 +03:00
|
|
|
mTxn->AddEdit(OpAttachAsyncCompositable(Shadow(aLayer), aHandle));
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
2012-07-12 16:51:58 +04:00
|
|
|
|
2013-11-27 19:19:34 +04:00
|
|
|
void ShadowLayerForwarder::SetShadowManager(PLayerTransactionChild* aShadowManager)
|
|
|
|
{
|
|
|
|
mShadowManager = static_cast<LayerTransactionChild*>(aShadowManager);
|
2014-05-06 05:56:40 +04:00
|
|
|
mShadowManager->SetForwarder(this);
|
2013-11-27 19:19:34 +04:00
|
|
|
}
|
|
|
|
|
2014-05-06 05:56:40 +04:00
|
|
|
void ShadowLayerForwarder::StopReceiveAsyncParentMessge()
|
|
|
|
{
|
2016-10-18 03:35:00 +03:00
|
|
|
if (!IPCOpen()) {
|
2014-05-06 05:56:40 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
mShadowManager->SetForwarder(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShadowLayerForwarder::ClearCachedResources()
|
|
|
|
{
|
2016-10-18 03:35:00 +03:00
|
|
|
if (!IPCOpen()) {
|
2014-05-06 05:56:40 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
mShadowManager->SendClearCachedResources();
|
|
|
|
}
|
|
|
|
|
2018-02-02 16:57:35 +03:00
|
|
|
void ShadowLayerForwarder::ScheduleComposite()
|
2014-05-06 05:56:40 +04:00
|
|
|
{
|
2016-10-18 03:35:00 +03:00
|
|
|
if (!IPCOpen()) {
|
2014-05-06 05:56:40 +04:00
|
|
|
return;
|
|
|
|
}
|
2018-02-02 16:57:35 +03:00
|
|
|
mShadowManager->SendScheduleComposite();
|
2014-05-06 05:56:40 +04:00
|
|
|
}
|
|
|
|
|
2016-03-17 16:58:58 +03:00
|
|
|
bool
|
|
|
|
IsSurfaceDescriptorValid(const SurfaceDescriptor& aSurface)
|
|
|
|
{
|
|
|
|
return aSurface.type() != SurfaceDescriptor::T__None &&
|
|
|
|
aSurface.type() != SurfaceDescriptor::Tnull_t;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t*
|
|
|
|
GetAddressFromDescriptor(const SurfaceDescriptor& aDescriptor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsSurfaceDescriptorValid(aDescriptor));
|
2016-06-06 18:17:23 +03:00
|
|
|
MOZ_RELEASE_ASSERT(aDescriptor.type() == SurfaceDescriptor::TSurfaceDescriptorBuffer, "GFX: surface descriptor is not the right type.");
|
2016-03-17 16:58:58 +03:00
|
|
|
|
|
|
|
auto memOrShmem = aDescriptor.get_SurfaceDescriptorBuffer().data();
|
|
|
|
if (memOrShmem.type() == MemoryOrShmem::TShmem) {
|
|
|
|
return memOrShmem.get_Shmem().get<uint8_t>();
|
|
|
|
} else {
|
|
|
|
return reinterpret_cast<uint8_t*>(memOrShmem.get_uintptr_t());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<gfx::DataSourceSurface>
|
|
|
|
GetSurfaceForDescriptor(const SurfaceDescriptor& aDescriptor)
|
|
|
|
{
|
2016-11-04 03:28:28 +03:00
|
|
|
if (aDescriptor.type() != SurfaceDescriptor::TSurfaceDescriptorBuffer) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2016-03-17 16:58:58 +03:00
|
|
|
uint8_t* data = GetAddressFromDescriptor(aDescriptor);
|
|
|
|
auto rgb = aDescriptor.get_SurfaceDescriptorBuffer().desc().get_RGBDescriptor();
|
|
|
|
uint32_t stride = ImageDataSerializer::GetRGBStride(rgb);
|
|
|
|
return gfx::Factory::CreateWrappingDataSourceSurface(data, stride, rgb.size(),
|
|
|
|
rgb.format());
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<gfx::DrawTarget>
|
|
|
|
GetDrawTargetForDescriptor(const SurfaceDescriptor& aDescriptor, gfx::BackendType aBackend)
|
|
|
|
{
|
|
|
|
uint8_t* data = GetAddressFromDescriptor(aDescriptor);
|
|
|
|
auto rgb = aDescriptor.get_SurfaceDescriptorBuffer().desc().get_RGBDescriptor();
|
|
|
|
uint32_t stride = ImageDataSerializer::GetRGBStride(rgb);
|
|
|
|
return gfx::Factory::CreateDrawTargetForData(gfx::BackendType::CAIRO,
|
|
|
|
data, rgb.size(),
|
|
|
|
stride, rgb.format());
|
|
|
|
}
|
|
|
|
|
2016-11-04 03:28:28 +03:00
|
|
|
void
|
|
|
|
DestroySurfaceDescriptor(IShmemAllocator* aAllocator, SurfaceDescriptor* aSurface)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aSurface);
|
|
|
|
|
|
|
|
SurfaceDescriptorBuffer& desc = aSurface->get_SurfaceDescriptorBuffer();
|
|
|
|
switch (desc.data().type()) {
|
|
|
|
case MemoryOrShmem::TShmem: {
|
|
|
|
aAllocator->DeallocShmem(desc.data().get_Shmem());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MemoryOrShmem::Tuintptr_t: {
|
|
|
|
uint8_t* ptr = (uint8_t*)desc.data().get_uintptr_t();
|
|
|
|
GfxMemoryImageReporter::WillFree(ptr);
|
|
|
|
delete [] ptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2017-10-25 09:30:31 +03:00
|
|
|
MOZ_CRASH("surface type not implemented!");
|
2016-11-04 03:28:28 +03:00
|
|
|
}
|
|
|
|
*aSurface = SurfaceDescriptor();
|
|
|
|
}
|
|
|
|
|
2016-03-17 16:58:58 +03:00
|
|
|
bool
|
|
|
|
ShadowLayerForwarder::AllocSurfaceDescriptor(const gfx::IntSize& aSize,
|
|
|
|
gfxContentType aContent,
|
|
|
|
SurfaceDescriptor* aBuffer)
|
|
|
|
{
|
|
|
|
if (!IPCOpen()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return AllocSurfaceDescriptorWithCaps(aSize, aContent, DEFAULT_BUFFER_CAPS, aBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ShadowLayerForwarder::AllocSurfaceDescriptorWithCaps(const gfx::IntSize& aSize,
|
|
|
|
gfxContentType aContent,
|
|
|
|
uint32_t aCaps,
|
|
|
|
SurfaceDescriptor* aBuffer)
|
|
|
|
{
|
|
|
|
if (!IPCOpen()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
gfx::SurfaceFormat format =
|
|
|
|
gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aContent);
|
|
|
|
size_t size = ImageDataSerializer::ComputeRGBBufferSize(aSize, format);
|
|
|
|
if (!size) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
MemoryOrShmem bufferDesc;
|
2016-09-27 06:22:20 +03:00
|
|
|
if (GetTextureForwarder()->IsSameProcess()) {
|
2016-03-17 16:58:58 +03:00
|
|
|
uint8_t* data = new (std::nothrow) uint8_t[size];
|
|
|
|
if (!data) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
GfxMemoryImageReporter::DidAlloc(data);
|
2016-07-21 17:38:34 +03:00
|
|
|
memset(data, 0, size);
|
2016-03-17 16:58:58 +03:00
|
|
|
bufferDesc = reinterpret_cast<uintptr_t>(data);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
mozilla::ipc::Shmem shmem;
|
2016-09-27 06:22:20 +03:00
|
|
|
if (!GetTextureForwarder()->AllocUnsafeShmem(size, OptimalShmemType(), &shmem)) {
|
2016-03-17 16:58:58 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bufferDesc = shmem;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use an intermediate buffer by default. Skipping the intermediate buffer is
|
|
|
|
// only possible in certain configurations so let's keep it simple here for now.
|
|
|
|
const bool hasIntermediateBuffer = true;
|
|
|
|
*aBuffer = SurfaceDescriptorBuffer(RGBDescriptor(aSize, format, hasIntermediateBuffer),
|
|
|
|
bufferDesc);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ bool
|
|
|
|
ShadowLayerForwarder::IsShmem(SurfaceDescriptor* aSurface)
|
|
|
|
{
|
|
|
|
return aSurface && (aSurface->type() == SurfaceDescriptor::TSurfaceDescriptorBuffer)
|
|
|
|
&& (aSurface->get_SurfaceDescriptorBuffer().data().type() == MemoryOrShmem::TShmem);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowLayerForwarder::DestroySurfaceDescriptor(SurfaceDescriptor* aSurface)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aSurface);
|
|
|
|
MOZ_ASSERT(IPCOpen());
|
|
|
|
if (!IPCOpen() || !aSurface) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-04 03:28:28 +03:00
|
|
|
::mozilla::layers::DestroySurfaceDescriptor(GetTextureForwarder(), aSurface);
|
2016-03-17 16:58:58 +03:00
|
|
|
}
|
|
|
|
|
2016-06-15 14:28:10 +03:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::UpdateFwdTransactionId()
|
|
|
|
{
|
2016-07-04 16:10:22 +03:00
|
|
|
auto compositorBridge = GetCompositorBridgeChild();
|
|
|
|
if (compositorBridge) {
|
|
|
|
compositorBridge->UpdateFwdTransactionId();
|
|
|
|
}
|
2016-06-15 14:28:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
ShadowLayerForwarder::GetFwdTransactionId()
|
|
|
|
{
|
2016-07-04 16:10:22 +03:00
|
|
|
auto compositorBridge = GetCompositorBridgeChild();
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(compositorBridge);
|
|
|
|
return compositorBridge ? compositorBridge->GetFwdTransactionId() : 0;
|
2016-06-15 14:28:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CompositorBridgeChild*
|
|
|
|
ShadowLayerForwarder::GetCompositorBridgeChild()
|
|
|
|
{
|
|
|
|
if (mCompositorBridgeChild) {
|
|
|
|
return mCompositorBridgeChild;
|
|
|
|
}
|
2016-07-04 16:10:22 +03:00
|
|
|
if (!mShadowManager) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2016-06-29 12:18:30 +03:00
|
|
|
mCompositorBridgeChild = static_cast<CompositorBridgeChild*>(mShadowManager->Manager());
|
2016-06-15 14:28:10 +03:00
|
|
|
return mCompositorBridgeChild;
|
|
|
|
}
|
|
|
|
|
2016-10-11 14:23:11 +03:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::SyncWithCompositor()
|
|
|
|
{
|
|
|
|
auto compositorBridge = GetCompositorBridgeChild();
|
|
|
|
if (compositorBridge && compositorBridge->IPCOpen()) {
|
|
|
|
compositorBridge->SendSyncWithCompositor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-18 05:47:06 +03:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::ReleaseCompositable(const CompositableHandle& aHandle)
|
|
|
|
{
|
|
|
|
AssertInForwarderThread();
|
|
|
|
if (!DestroyInTransaction(aHandle)) {
|
2017-04-17 10:50:42 +03:00
|
|
|
if (!IPCOpen()) {
|
|
|
|
return;
|
|
|
|
}
|
2017-01-18 05:47:06 +03:00
|
|
|
mShadowManager->SendReleaseCompositable(aHandle);
|
|
|
|
}
|
|
|
|
mCompositables.Remove(aHandle.Value());
|
|
|
|
}
|
|
|
|
|
2017-05-12 08:44:27 +03:00
|
|
|
void
|
|
|
|
ShadowLayerForwarder::SynchronouslyShutdown()
|
|
|
|
{
|
|
|
|
if (IPCOpen()) {
|
|
|
|
mShadowManager->SendShutdownSync();
|
|
|
|
mShadowManager->MarkDestroyed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-21 18:43:04 +03:00
|
|
|
ShadowableLayer::~ShadowableLayer()
|
|
|
|
{
|
2016-12-21 18:43:47 +03:00
|
|
|
if (mShadow) {
|
|
|
|
mForwarder->ReleaseLayer(GetShadow());
|
2016-12-21 18:43:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-22 01:17:33 +04:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|