зеркало из https://github.com/mozilla/gecko-dev.git
Bug 913443 - Break up CreateOrRecyclePaintedLayer into more parts. r=roc
--HG-- extra : rebase_source : d02edc77f41f0192f17d756e70e6e5c447c420bd
This commit is contained in:
Родитель
5f382d9022
Коммит
09230009c4
|
@ -42,6 +42,8 @@ using namespace mozilla::gfx;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
class PaintedDisplayItemLayerUserData;
|
||||
|
||||
FrameLayerBuilder::DisplayItemData::DisplayItemData(LayerManagerData* aParent, uint32_t aKey,
|
||||
nsIFrame* aFrame)
|
||||
|
||||
|
@ -705,6 +707,25 @@ protected:
|
|||
already_AddRefed<PaintedLayer> CreateOrRecyclePaintedLayer(const nsIFrame* aAnimatedGeometryRoot,
|
||||
const nsIFrame *aReferenceFrame,
|
||||
const nsPoint& aTopLeft);
|
||||
|
||||
/**
|
||||
* Recycle aLayer and do any necessary invalidation.
|
||||
*/
|
||||
PaintedDisplayItemLayerUserData* RecyclePaintedLayer(PaintedLayer* aLayer,
|
||||
const nsIFrame* aAnimatedGeometryRoot,
|
||||
bool& didResetScrollPositionForLayerPixelAlignment);
|
||||
|
||||
/**
|
||||
* Perform the last step of CreateOrRecyclePaintedLayer: Initialize aData,
|
||||
* set up the layer's transform for scrolling, and invalidate the layer for
|
||||
* layer pixel alignment changes if necessary.
|
||||
*/
|
||||
void PreparePaintedLayerForUse(PaintedLayer* aLayer,
|
||||
PaintedDisplayItemLayerUserData* aData,
|
||||
const nsIFrame* aAnimatedGeometryRoot,
|
||||
const nsIFrame* aReferenceFrame,
|
||||
const nsPoint& aTopLeft,
|
||||
bool aDidResetScrollPositionForLayerPixelAlignment);
|
||||
/**
|
||||
* Grab the next recyclable ColorLayer, or create one if there are no
|
||||
* more recyclable ColorLayers.
|
||||
|
@ -1690,53 +1711,10 @@ ContainerState::CreateOrRecyclePaintedLayer(const nsIFrame* aAnimatedGeometryRoo
|
|||
|
||||
// Check if the layer hint has changed and whether or not the layer should
|
||||
// be recreated because of it.
|
||||
if (mManager->IsOptimizedFor(layer->AsPaintedLayer(), creationHint)) {
|
||||
if (mManager->IsOptimizedFor(layer, creationHint)) {
|
||||
layerRecycled = true;
|
||||
|
||||
// Clear clip rect and mask layer so we don't accidentally stay clipped.
|
||||
// We will reapply any necessary clipping.
|
||||
layer->SetMaskLayer(nullptr);
|
||||
layer->ClearExtraDumpInfo();
|
||||
|
||||
data = static_cast<PaintedDisplayItemLayerUserData*>
|
||||
(layer->GetUserData(&gPaintedDisplayItemLayerUserData));
|
||||
NS_ASSERTION(data, "Recycled PaintedLayers must have user data");
|
||||
|
||||
// This gets called on recycled PaintedLayers that are going to be in the
|
||||
// final layer tree, so it's a convenient time to invalidate the
|
||||
// content that changed where we don't know what PaintedLayer it belonged
|
||||
// to, or if we need to invalidate the entire layer, we can do that.
|
||||
// This needs to be done before we update the PaintedLayer to its new
|
||||
// transform. See nsGfxScrollFrame::InvalidateInternal, where
|
||||
// we ensure that mInvalidPaintedContent is updated according to the
|
||||
// scroll position as of the most recent paint.
|
||||
if (!FuzzyEqual(data->mXScale, mParameters.mXScale, 0.00001f) ||
|
||||
!FuzzyEqual(data->mYScale, mParameters.mYScale, 0.00001f) ||
|
||||
data->mAppUnitsPerDevPixel != mAppUnitsPerDevPixel) {
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
|
||||
printf_stderr("Recycled layer %p changed scale\n", layer.get());
|
||||
}
|
||||
#endif
|
||||
InvalidateEntirePaintedLayer(layer, aAnimatedGeometryRoot, "recycled layer changed state");
|
||||
didResetScrollPositionForLayerPixelAlignment = true;
|
||||
}
|
||||
if (!data->mRegionToInvalidate.IsEmpty()) {
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
|
||||
printf_stderr("Invalidating deleted frame content from layer %p\n", layer.get());
|
||||
}
|
||||
#endif
|
||||
layer->InvalidateRegion(data->mRegionToInvalidate);
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
|
||||
nsAutoCString str;
|
||||
AppendToString(str, data->mRegionToInvalidate);
|
||||
printf_stderr("Invalidating layer %p: %s\n", layer.get(), str.get());
|
||||
}
|
||||
#endif
|
||||
data->mRegionToInvalidate.SetEmpty();
|
||||
}
|
||||
data = RecyclePaintedLayer(layer, aAnimatedGeometryRoot,
|
||||
didResetScrollPositionForLayerPixelAlignment);
|
||||
|
||||
// We do not need to Invalidate these areas in the widget because we
|
||||
// assume the caller of InvalidatePaintedLayerContents has ensured
|
||||
|
@ -1755,6 +1733,78 @@ ContainerState::CreateOrRecyclePaintedLayer(const nsIFrame* aAnimatedGeometryRoo
|
|||
ResetScrollPositionForLayerPixelAlignment(aAnimatedGeometryRoot);
|
||||
didResetScrollPositionForLayerPixelAlignment = true;
|
||||
}
|
||||
|
||||
PreparePaintedLayerForUse(layer, data, aAnimatedGeometryRoot,
|
||||
aReferenceFrame, aTopLeft,
|
||||
didResetScrollPositionForLayerPixelAlignment);
|
||||
|
||||
return layer.forget();
|
||||
}
|
||||
|
||||
PaintedDisplayItemLayerUserData*
|
||||
ContainerState::RecyclePaintedLayer(PaintedLayer* aLayer,
|
||||
const nsIFrame* aAnimatedGeometryRoot,
|
||||
bool& didResetScrollPositionForLayerPixelAlignment)
|
||||
{
|
||||
// Clear clip rect and mask layer so we don't accidentally stay clipped.
|
||||
// We will reapply any necessary clipping.
|
||||
aLayer->SetMaskLayer(nullptr);
|
||||
aLayer->ClearExtraDumpInfo();
|
||||
|
||||
PaintedDisplayItemLayerUserData* data =
|
||||
static_cast<PaintedDisplayItemLayerUserData*>(
|
||||
aLayer->GetUserData(&gPaintedDisplayItemLayerUserData));
|
||||
NS_ASSERTION(data, "Recycled PaintedLayers must have user data");
|
||||
|
||||
// This gets called on recycled PaintedLayers that are going to be in the
|
||||
// final layer tree, so it's a convenient time to invalidate the
|
||||
// content that changed where we don't know what PaintedLayer it belonged
|
||||
// to, or if we need to invalidate the entire layer, we can do that.
|
||||
// This needs to be done before we update the PaintedLayer to its new
|
||||
// transform. See nsGfxScrollFrame::InvalidateInternal, where
|
||||
// we ensure that mInvalidPaintedContent is updated according to the
|
||||
// scroll position as of the most recent paint.
|
||||
if (!FuzzyEqual(data->mXScale, mParameters.mXScale, 0.00001f) ||
|
||||
!FuzzyEqual(data->mYScale, mParameters.mYScale, 0.00001f) ||
|
||||
data->mAppUnitsPerDevPixel != mAppUnitsPerDevPixel) {
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
|
||||
printf_stderr("Recycled layer %p changed scale\n", aLayer);
|
||||
}
|
||||
#endif
|
||||
InvalidateEntirePaintedLayer(aLayer, aAnimatedGeometryRoot, "recycled layer changed state");
|
||||
didResetScrollPositionForLayerPixelAlignment = true;
|
||||
}
|
||||
if (!data->mRegionToInvalidate.IsEmpty()) {
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
|
||||
printf_stderr("Invalidating deleted frame content from layer %p\n", aLayer);
|
||||
}
|
||||
#endif
|
||||
aLayer->InvalidateRegion(data->mRegionToInvalidate);
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
|
||||
nsAutoCString str;
|
||||
AppendToString(str, data->mRegionToInvalidate);
|
||||
printf_stderr("Invalidating layer %p: %s\n", aLayer, str.get());
|
||||
}
|
||||
#endif
|
||||
data->mRegionToInvalidate.SetEmpty();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void
|
||||
ContainerState::PreparePaintedLayerForUse(PaintedLayer* aLayer,
|
||||
PaintedDisplayItemLayerUserData* aData,
|
||||
const nsIFrame* aAnimatedGeometryRoot,
|
||||
const nsIFrame* aReferenceFrame,
|
||||
const nsPoint& aTopLeft,
|
||||
bool didResetScrollPositionForLayerPixelAlignment)
|
||||
{
|
||||
PaintedLayer* layer = aLayer;
|
||||
PaintedDisplayItemLayerUserData* data = aData;
|
||||
|
||||
data->mXScale = mParameters.mXScale;
|
||||
data->mYScale = mParameters.mYScale;
|
||||
data->mLastAnimatedGeometryRootOrigin = data->mAnimatedGeometryRootOrigin;
|
||||
|
@ -1797,8 +1847,6 @@ ContainerState::CreateOrRecyclePaintedLayer(const nsIFrame* aAnimatedGeometryRoo
|
|||
#else
|
||||
unused << didResetScrollPositionForLayerPixelAlignment;
|
||||
#endif
|
||||
|
||||
return layer.forget();
|
||||
}
|
||||
|
||||
#if defined(DEBUG) || defined(MOZ_DUMP_PAINTING)
|
||||
|
|
Загрузка…
Ссылка в новой задаче