Bug 1546856 - Use GetPaintedDisplayItemLayerUserData in more places and use auto*. r=miko

Depends on D70243

Differential Revision: https://phabricator.services.mozilla.com/D70402

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Markus Stange 2020-04-09 16:47:05 +00:00
Родитель 568858e9ed
Коммит b55fdc7f59
1 изменённых файлов: 29 добавлений и 48 удалений

Просмотреть файл

@ -2144,27 +2144,6 @@ static void InvalidatePostTransformRegion(PaintedLayer* aLayer,
#endif
}
static void InvalidatePreTransformRect(PaintedLayer* aLayer,
const nsRect& aRect,
const DisplayItemClip& aClip,
const nsIntPoint& aTranslation,
TransformClipNode* aTransform) {
PaintedDisplayItemLayerUserData* data =
static_cast<PaintedDisplayItemLayerUserData*>(
aLayer->GetUserData(&gPaintedDisplayItemLayerUserData));
nsRect rect = aClip.ApplyNonRoundedIntersection(aRect);
if (aTransform) {
rect = aTransform->TransformRect(rect, data->mAppUnitsPerDevPixel);
}
nsIntRect pixelRect = rect.ScaleToOutsidePixels(data->mXScale, data->mYScale,
data->mAppUnitsPerDevPixel);
InvalidatePostTransformRegion(aLayer, pixelRect, aTranslation);
}
static PaintedDisplayItemLayerUserData* GetPaintedDisplayItemLayerUserData(
Layer* aLayer) {
return static_cast<PaintedDisplayItemLayerUserData*>(
@ -2185,12 +2164,30 @@ static nsIntPoint GetTranslationForPaintedLayer(PaintedLayer* aLayer) {
* that's currently in the layer (which must be an integer translation).
*/
static nsIntPoint GetLastPaintOffset(PaintedLayer* aLayer) {
PaintedDisplayItemLayerUserData* layerData =
GetPaintedDisplayItemLayerUserData(aLayer);
auto* layerData = GetPaintedDisplayItemLayerUserData(aLayer);
MOZ_ASSERT(layerData);
return layerData->mLastPaintOffset.valueOr(layerData->mTranslation);
}
static void InvalidatePreTransformRect(PaintedLayer* aLayer,
const nsRect& aRect,
const DisplayItemClip& aClip,
const nsIntPoint& aTranslation,
TransformClipNode* aTransform) {
auto* data = GetPaintedDisplayItemLayerUserData(aLayer);
nsRect rect = aClip.ApplyNonRoundedIntersection(aRect);
if (aTransform) {
rect = aTransform->TransformRect(rect, data->mAppUnitsPerDevPixel);
}
nsIntRect pixelRect = rect.ScaleToOutsidePixels(data->mXScale, data->mYScale,
data->mAppUnitsPerDevPixel);
InvalidatePostTransformRegion(aLayer, pixelRect, aTranslation);
}
/**
* Some frames can have multiple, nested, retaining layer managers
* associated with them (normal manager, inactive managers, SVG effects).
@ -2234,9 +2231,7 @@ void FrameLayerBuilder::RemoveFrameFromLayerManager(
for (DisplayItemData* data : aArray) {
PaintedLayer* t = data->mLayer ? data->mLayer->AsPaintedLayer() : nullptr;
if (t) {
PaintedDisplayItemLayerUserData* paintedData =
static_cast<PaintedDisplayItemLayerUserData*>(
t->GetUserData(&gPaintedDisplayItemLayerUserData));
auto* paintedData = GetPaintedDisplayItemLayerUserData(t);
if (paintedData && data->mGeometry) {
const int32_t appUnitsPerDevPixel = paintedData->mAppUnitsPerDevPixel;
nsRegion rgn = data->mGeometry->ComputeInvalidationRegion();
@ -2453,9 +2448,7 @@ static void ResetLayerStateForRecycling(Layer* aLayer) {
already_AddRefed<ColorLayer> ContainerState::CreateOrRecycleColorLayer(
PaintedLayer* aPainted) {
PaintedDisplayItemLayerUserData* data =
static_cast<PaintedDisplayItemLayerUserData*>(
aPainted->GetUserData(&gPaintedDisplayItemLayerUserData));
auto* data = GetPaintedDisplayItemLayerUserData(aPainted);
RefPtr<ColorLayer> layer = data->mColorLayer;
if (layer) {
ResetLayerStateForRecycling(layer);
@ -2478,9 +2471,7 @@ already_AddRefed<ColorLayer> ContainerState::CreateOrRecycleColorLayer(
already_AddRefed<ImageLayer> ContainerState::CreateOrRecycleImageLayer(
PaintedLayer* aPainted) {
PaintedDisplayItemLayerUserData* data =
static_cast<PaintedDisplayItemLayerUserData*>(
aPainted->GetUserData(&gPaintedDisplayItemLayerUserData));
auto* data = GetPaintedDisplayItemLayerUserData(aPainted);
RefPtr<ImageLayer> layer = data->mImageLayer;
if (layer) {
ResetLayerStateForRecycling(layer);
@ -2676,9 +2667,7 @@ PaintedDisplayItemLayerUserData* ContainerState::RecyclePaintedLayer(
ResetLayerStateForRecycling(aLayer);
aLayer->ClearExtraDumpInfo();
PaintedDisplayItemLayerUserData* data =
static_cast<PaintedDisplayItemLayerUserData*>(
aLayer->GetUserData(&gPaintedDisplayItemLayerUserData));
auto* data = GetPaintedDisplayItemLayerUserData(aLayer);
NS_ASSERTION(data, "Recycled PaintedLayers must have user data");
// This gets called on recycled PaintedLayers that are going to be in the
@ -3448,8 +3437,7 @@ void ContainerState::FinishPaintedLayerData(
std::move(paintedLayer);
}
PaintedDisplayItemLayerUserData* userData =
GetPaintedDisplayItemLayerUserData(data->mLayer);
auto* userData = GetPaintedDisplayItemLayerUserData(data->mLayer);
NS_ASSERTION(userData, "where did our user data go?");
userData->mLastItemCount = data->mAssignedDisplayItems.size();
@ -5131,8 +5119,7 @@ void ContainerState::ProcessDisplayItems(nsDisplayList* aList) {
if (layer) {
paintedLayerData->mLayer = layer;
PaintedDisplayItemLayerUserData* userData =
GetPaintedDisplayItemLayerUserData(layer);
auto* userData = GetPaintedDisplayItemLayerUserData(layer);
paintedLayerData->mAssignedDisplayItems.reserve(
userData->mLastItemCount);
@ -5254,9 +5241,7 @@ void FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData) {
return;
}
PaintedDisplayItemLayerUserData* layerData =
static_cast<PaintedDisplayItemLayerUserData*>(
aData->mLayer->GetUserData(&gPaintedDisplayItemLayerUserData));
auto* layerData = GetPaintedDisplayItemLayerUserData(aData->mLayer);
nsPoint shift = layerData->mAnimatedGeometryRootOrigin -
layerData->mLastAnimatedGeometryRootOrigin;
@ -5387,9 +5372,7 @@ void FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData,
AssignedDisplayItem& aItem,
Layer* aLayer) {
PaintedLayer* layer = aLayerData->mLayer;
PaintedDisplayItemLayerUserData* paintedData =
static_cast<PaintedDisplayItemLayerUserData*>(
layer->GetUserData(&gPaintedDisplayItemLayerUserData));
auto* paintedData = GetPaintedDisplayItemLayerUserData(layer);
if (layer->Manager() == mRetainingManager) {
DisplayItemData* data = aItem.mDisplayItemData;
@ -7203,9 +7186,7 @@ void FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
FrameLayerBuilder* layerBuilder = aLayer->Manager()->GetLayerBuilder();
NS_ASSERTION(layerBuilder, "Unexpectedly null layer builder!");
PaintedDisplayItemLayerUserData* userData =
static_cast<PaintedDisplayItemLayerUserData*>(
aLayer->GetUserData(&gPaintedDisplayItemLayerUserData));
auto* userData = GetPaintedDisplayItemLayerUserData(aLayer);
NS_ASSERTION(userData, "where did our user data go?");
if (!userData->mContainerLayerFrame) {
return;