Skip to content

Commit

Permalink
Bug 1733294 - Remove unused PaintedLayer. r=aosmond
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmuizel committed Oct 1, 2021
1 parent 3146eda commit f6d4a2a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 425 deletions.
8 changes: 0 additions & 8 deletions gfx/layers/Layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,14 +1233,6 @@ UniquePtr<LayerUserData> Layer::RemoveUserData(void* aKey) {
return d;
}

void PaintedLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix) {
Layer::PrintInfo(aStream, aPrefix);
nsIntRegion validRegion = GetValidRegion();
if (!validRegion.IsEmpty()) {
aStream << " [valid=" << validRegion << "]";
}
}

void ContainerLayer::PrintInfo(std::stringstream& aStream,
const char* aPrefix) {
Layer::PrintInfo(aStream, aPrefix);
Expand Down
212 changes: 0 additions & 212 deletions gfx/layers/Layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -777,12 +777,6 @@ class Layer {
*/
virtual void Disconnect() {}

/**
* Dynamic downcast to a PaintedLayer. Returns null if this is not
* a PaintedLayer.
*/
virtual PaintedLayer* AsPaintedLayer() { return nullptr; }

/**
* Dynamic cast to a ContainerLayer. Returns null if this is not
* a ContainerLayer.
Expand Down Expand Up @@ -1152,212 +1146,6 @@ class Layer {
nsCString mDisplayListLog;
};

/**
* A Layer which we can paint into. It is a conceptually
* infinite surface, but each PaintedLayer has an associated "valid region"
* of contents that it is currently storing, which is finite. PaintedLayer
* implementations can store content between paints.
*
* PaintedLayers are rendered into during the drawing phase of a transaction.
*
* Currently the contents of a PaintedLayer are in the device output color
* space.
*/
class PaintedLayer : public Layer {
public:
/**
* CONSTRUCTION PHASE ONLY
* Tell this layer that the content in some region has changed and
* will need to be repainted. This area is removed from the valid
* region.
*/
virtual void InvalidateRegion(const nsIntRegion& aRegion) = 0;
/**
* CONSTRUCTION PHASE ONLY
* Set whether ComputeEffectiveTransforms should compute the
* "residual translation" --- the translation that should be applied *before*
* mEffectiveTransform to get the ideal transform for this PaintedLayer.
* When this is true, ComputeEffectiveTransforms will compute the residual
* and ensure that the layer is invalidated whenever the residual changes.
* When it's false, a change in the residual will not trigger invalidation
* and GetResidualTranslation will return 0,0.
* So when the residual is to be ignored, set this to false for better
* performance.
*/
void SetAllowResidualTranslation(bool aAllow) {
mAllowResidualTranslation = aAllow;
}

void SetValidRegion(const nsIntRegion& aRegion) {
MOZ_LAYERS_LOG_IF_SHADOWABLE(this,
("Layer::Mutated(%p) ValidRegion", this));
mValidRegion = aRegion;
mValidRegionIsCurrent = true;
Mutated();
}

/**
* Can be used anytime
*/
const nsIntRegion& GetValidRegion() const {
EnsureValidRegionIsCurrent();
return mValidRegion;
}

void InvalidateWholeLayer() {
mInvalidRegion.Add(GetValidRegion().GetBounds());
ClearValidRegion();
}

void ClearValidRegion() {
mValidRegion.SetEmpty();
mValidRegionIsCurrent = true;
}
void AddToValidRegion(const nsIntRegion& aRegion) {
EnsureValidRegionIsCurrent();
mValidRegion.OrWith(aRegion);
}
void SubtractFromValidRegion(const nsIntRegion& aRegion) {
EnsureValidRegionIsCurrent();
mValidRegion.SubOut(aRegion);
}
void UpdateValidRegionAfterInvalidRegionChanged() {
// Changes to mInvalidRegion will be applied to mValidRegion on the next
// call to EnsureValidRegionIsCurrent().
mValidRegionIsCurrent = false;
}

void ClearInvalidRegion() override {
// mInvalidRegion is about to be reset. This is the last chance to apply
// any pending changes from it to mValidRegion. Do that by calling
// EnsureValidRegionIsCurrent().
EnsureValidRegionIsCurrent();
mInvalidRegion.SetEmpty();
}

PaintedLayer* AsPaintedLayer() override { return this; }

MOZ_LAYER_DECL_NAME("PaintedLayer", TYPE_PAINTED)

void ComputeEffectiveTransforms(
const gfx::Matrix4x4& aTransformToSurface) override {
gfx::Matrix4x4 idealTransform = GetLocalTransform() * aTransformToSurface;
gfx::Matrix residual;
mEffectiveTransform = SnapTransformTranslation(
idealTransform, mAllowResidualTranslation ? &residual : nullptr);
// The residual can only be a translation because SnapTransformTranslation
// only changes the transform if it's a translation
NS_ASSERTION(residual.IsTranslation(),
"Residual transform can only be a translation");
if (!gfx::ThebesPoint(residual.GetTranslation())
.WithinEpsilonOf(mResidualTranslation, 1e-3f)) {
mResidualTranslation = gfx::ThebesPoint(residual.GetTranslation());
DebugOnly<mozilla::gfx::Point> transformedOrig =
idealTransform.TransformPoint(mozilla::gfx::Point());
#ifdef DEBUG
DebugOnly<mozilla::gfx::Point> transformed =
idealTransform.TransformPoint(mozilla::gfx::Point(
mResidualTranslation.x, mResidualTranslation.y)) -
*&transformedOrig;
#endif
NS_ASSERTION(-0.5 <= (&transformed)->x && (&transformed)->x < 0.5 &&
-0.5 <= (&transformed)->y && (&transformed)->y < 0.5,
"Residual translation out of range");
ClearValidRegion();
}
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
}

LayerManager::PaintedLayerCreationHint GetCreationHint() const {
return mCreationHint;
}

bool UsedForReadback() { return mUsedForReadback; }
void SetUsedForReadback(bool aUsed) { mUsedForReadback = aUsed; }

/**
* Returns true if aLayer is optimized for the given PaintedLayerCreationHint.
*/
virtual bool IsOptimizedFor(
LayerManager::PaintedLayerCreationHint aCreationHint) {
return true;
}

/**
* Returns the residual translation. Apply this translation when drawing
* into the PaintedLayer so that when mEffectiveTransform is applied
* afterwards by layer compositing, the results exactly match the "ideal
* transform" (the product of the transform of this layer and its ancestors).
* Returns 0,0 unless SetAllowResidualTranslation(true) has been called.
* The residual translation components are always in the range [-0.5, 0.5).
*/
gfxPoint GetResidualTranslation() const { return mResidualTranslation; }

protected:
PaintedLayer(
LayerManager* aManager, void* aImplData,
LayerManager::PaintedLayerCreationHint aCreationHint = LayerManager::NONE)
: Layer(aManager, aImplData),
mValidRegion(),
mValidRegionIsCurrent(true),
mCreationHint(aCreationHint),
mUsedForReadback(false),
mAllowResidualTranslation(false) {}

void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;

/**
* ComputeEffectiveTransforms snaps the ideal transform to get
* mEffectiveTransform. mResidualTranslation is the translation that should be
* applied *before* mEffectiveTransform to get the ideal transform.
*/
gfxPoint mResidualTranslation;

private:
/**
* Needs to be called prior to accessing mValidRegion, unless mValidRegion is
* being completely overwritten.
*/
void EnsureValidRegionIsCurrent() const {
if (!mValidRegionIsCurrent) {
// Apply any pending mInvalidRegion changes to mValidRegion.
if (!mValidRegion.IsEmpty()) {
// Calling mInvalidRegion.GetRegion() is expensive.
// That's why we delay the adjustment of mValidRegion for as long as
// possible, so that multiple modifications to mInvalidRegion can be
// applied to mValidRegion in one go.
mValidRegion.SubOut(mInvalidRegion.GetRegion());
}
mValidRegionIsCurrent = true;
}
}

/**
* The layer's valid region. If mValidRegionIsCurrent is false, then
* mValidRegion has not yet been updated for recent changes to
* mInvalidRegion. Those pending changes can be applied by calling
* EnsureValidRegionIsCurrent().
*/
mutable nsIntRegion mValidRegion;

mutable bool mValidRegionIsCurrent;

protected:
/**
* The creation hint that was used when constructing this layer.
*/
const LayerManager::PaintedLayerCreationHint mCreationHint;
/**
* Set when this PaintedLayer is participating in readback, i.e. some
* ReadbackLayer (may) be getting its background from this layer.
*/
bool mUsedForReadback;
/**
* True when
*/
bool mAllowResidualTranslation;
};

/**
* A Layer which other layers render into. It holds references to its
* children.
Expand Down
Loading

0 comments on commit f6d4a2a

Please sign in to comment.