зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1690653 - Don't create a CATransaction if nothing changed. r=mattwoodrow
This avoids some overhead from committing the transaction. Differential Revision: https://phabricator.services.mozilla.com/D104085
This commit is contained in:
Родитель
718867e499
Коммит
4b48af6bb7
|
@ -244,6 +244,7 @@ class NativeLayerCA : public NativeLayer {
|
|||
typedef NativeLayerRootCA::WhichRepresentation WhichRepresentation;
|
||||
CALayer* UnderlyingCALayer(WhichRepresentation aRepresentation);
|
||||
void ApplyChanges(WhichRepresentation aRepresentation);
|
||||
bool HasUpdate(WhichRepresentation aRepresentation);
|
||||
void SetBackingScale(float aBackingScale);
|
||||
|
||||
// Invalidates the specified region in all surfaces that are tracked by this
|
||||
|
@ -298,6 +299,13 @@ class NativeLayerCA : public NativeLayer {
|
|||
gfx::SamplingFilter aSamplingFilter,
|
||||
CFTypeRefPtr<IOSurfaceRef> aFrontSurface);
|
||||
|
||||
// Return whether any aspects of this layer representation have been mutated
|
||||
// since the last call to ApplyChanges, i.e. whether ApplyChanges needs to
|
||||
// be called.
|
||||
// This is used to optimize away a CATransaction commit if no layers have
|
||||
// changed.
|
||||
bool HasUpdate();
|
||||
|
||||
// Lazily initialized by first call to ApplyChanges. mWrappingLayer is the
|
||||
// layer that applies the intersection of mDisplayRect and mClipRect (if
|
||||
// set), and mContentCALayer is the layer that hosts the IOSurface. We do
|
||||
|
|
|
@ -283,6 +283,14 @@ NativeLayerRootCA::Representation::~Representation() {
|
|||
|
||||
void NativeLayerRootCA::Representation::Commit(WhichRepresentation aRepresentation,
|
||||
const nsTArray<RefPtr<NativeLayerCA>>& aSublayers) {
|
||||
if (!mMutated &&
|
||||
std::none_of(aSublayers.begin(), aSublayers.end(), [=](const RefPtr<NativeLayerCA>& layer) {
|
||||
return layer->HasUpdate(aRepresentation);
|
||||
})) {
|
||||
// No updates, skip creating the CATransaction altogether.
|
||||
return;
|
||||
}
|
||||
|
||||
AutoCATransaction transaction;
|
||||
|
||||
// Call ApplyChanges on our sublayers first, and then update the root layer's
|
||||
|
@ -805,6 +813,11 @@ void NativeLayerCA::ApplyChanges(WhichRepresentation aRepresentation) {
|
|||
mSurfaceIsFlipped, mSamplingFilter, surface);
|
||||
}
|
||||
|
||||
bool NativeLayerCA::HasUpdate(WhichRepresentation aRepresentation) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
return GetRepresentation(aRepresentation).HasUpdate();
|
||||
}
|
||||
|
||||
CALayer* NativeLayerCA::UnderlyingCALayer(WhichRepresentation aRepresentation) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
return GetRepresentation(aRepresentation).UnderlyingCALayer();
|
||||
|
@ -961,6 +974,16 @@ void NativeLayerCA::Representation::ApplyChanges(
|
|||
mMutatedSamplingFilter = false;
|
||||
}
|
||||
|
||||
bool NativeLayerCA::Representation::HasUpdate() {
|
||||
if (!mWrappingCALayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return mMutatedPosition || mMutatedTransform || mMutatedDisplayRect || mMutatedClipRect ||
|
||||
mMutatedBackingScale || mMutatedSize || mMutatedSurfaceIsFlipped || mMutatedFrontSurface ||
|
||||
mMutatedSamplingFilter;
|
||||
}
|
||||
|
||||
// Called when mMutex is already being held by the current thread.
|
||||
Maybe<NativeLayerCA::SurfaceWithInvalidRegion> NativeLayerCA::GetUnusedSurfaceAndCleanUp(
|
||||
const MutexAutoLock&) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче