Backout changeset 6234134d4430 (bug 539356) because of performance and correctness regressions

This commit is contained in:
Ehsan Akhgari 2012-07-03 20:08:19 -04:00
parent 197fdca966
commit 64c98e2147
6 changed files with 4 additions and 137 deletions

View File

@ -818,7 +818,6 @@ FrameLayerBuilder::ProcessRemovedDisplayItems(DisplayItemDataEntry* aEntry,
item.mGeometry->ComputeInvalidationRegion().
ScaleToOutsidePixels(data->mXScale, data->mYScale, item.mGeometry->mAppUnitsPerDevPixel),
item.mGeometry->mPaintOffset);
aEntry->GetKey()->ClearDisplayItemCache();
}
}
@ -2004,7 +2003,6 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem, Layer* aNewLayer,
GetTranslationForThebesLayer(newThebesLayer));
}
}
aItem->GetUnderlyingFrame()->ClearDisplayItemCache();
return;
}
if (!aNewLayer) {
@ -2059,7 +2057,6 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem, Layer* aNewLayer,
InvalidatePostTransformRegion(newThebesLayer,
combined.ScaleToOutsidePixels(data->mXScale, data->mYScale, mAppUnitsPerDevPixel),
GetTranslationForThebesLayer(newThebesLayer));
aItem->GetUnderlyingFrame()->ClearDisplayItemCache();
}
}
@ -2895,9 +2892,7 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
}
if (cdi->mInactiveLayer) {
builder->SetIsCompositingCheap(false);
PaintInactiveLayer(builder, cdi->mInactiveLayer, cdi->mItem, aContext, rc);
builder->SetIsCompositingCheap(aLayer->Manager()->IsCompositingCheap());
} else {
nsIFrame* frame = cdi->mItem->GetUnderlyingFrame();
if (frame) {

View File

@ -65,8 +65,7 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
mSyncDecodeImages(false),
mIsPaintingToWindow(false),
mHasDisplayPort(false),
mHasFixedItems(false),
mIsCompositingCheap(false)
mHasFixedItems(false)
{
MOZ_COUNT_CTOR(nsDisplayListBuilder);
PL_InitArenaPool(&mPool, "displayListArena", 1024,
@ -669,7 +668,6 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
layerManager->SetRoot(root);
layerBuilder->WillEndTransaction();
aBuilder->SetIsCompositingCheap(layerManager->IsCompositingCheap());
layerManager->EndTransaction(FrameLayerBuilder::DrawThebesLayer,
aBuilder, (aFlags & PAINT_NO_COMPOSITE) ? LayerManager::END_NO_COMPOSITE : LayerManager::END_DEFAULT);
layerBuilder->DidEndTransaction();
@ -1134,65 +1132,6 @@ static bool RoundedRectContainsRect(const nsRect& aRoundedRect,
return rgn.Contains(aContainedRect);
}
bool
nsDisplayBackground::IsSingleFixedPositionImage(nsDisplayListBuilder* aBuilder, const nsRect& aClipRect)
{
if (mIsThemed)
return false;
nsPresContext* presContext = mFrame->PresContext();
nsStyleContext* bgSC;
if (!nsCSSRendering::FindBackground(presContext, mFrame, &bgSC))
return false;
bool drawBackgroundImage;
bool drawBackgroundColor;
nsCSSRendering::DetermineBackgroundColor(presContext,
bgSC,
mFrame,
drawBackgroundImage,
drawBackgroundColor);
// For now we don't know how to draw image layers with a background color.
if (!drawBackgroundImage || drawBackgroundColor)
return false;
const nsStyleBackground *bg = bgSC->GetStyleBackground();
// We could pretty easily support multiple image layers, but for now we
// just punt here.
if (bg->mLayers.Length() != 1)
return false;
PRUint32 flags = aBuilder->GetBackgroundPaintFlags();
nsPoint offset = ToReferenceFrame();
nsRect borderArea = nsRect(offset, mFrame->GetSize());
const nsStyleBackground::Layer &layer = bg->mLayers[0];
if (layer.mAttachment != NS_STYLE_BG_ATTACHMENT_FIXED)
return false;
nsBackgroundLayerState state =
nsCSSRendering::PrepareBackgroundLayer(presContext,
mFrame,
flags,
borderArea,
aClipRect,
*bg,
layer);
nsImageRenderer* imageRenderer = &state.mImageRenderer;
// We only care about images here, not gradients.
if (!imageRenderer->IsRasterImage())
return false;
PRInt32 appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
mDestRect = nsLayoutUtils::RectToGfxRect(state.mFillArea, appUnitsPerDevPixel);
return true;
}
bool
nsDisplayBackground::TryOptimizeToImageLayer(nsDisplayListBuilder* aBuilder)
{
@ -1589,7 +1528,6 @@ nsDisplayBackground::ShouldFixToViewport(nsDisplayListBuilder* aBuilder)
void
nsDisplayBackground::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx) {
nsPoint offset = ToReferenceFrame();
PRUint32 flags = aBuilder->GetBackgroundPaintFlags();
nsDisplayItem* nextItem = GetAbove();

View File

@ -224,9 +224,6 @@ public:
*/
void SetPaintingToWindow(bool aToWindow) { mIsPaintingToWindow = aToWindow; }
bool IsPaintingToWindow() const { return mIsPaintingToWindow; }
void SetIsCompositingCheap(bool aCompositingCheap) { mIsCompositingCheap = aCompositingCheap; }
bool IsCompositingCheap() const { return mIsCompositingCheap; }
/**
* Display the caret if needed.
*/
@ -535,7 +532,6 @@ private:
bool mIsPaintingToWindow;
bool mHasDisplayPort;
bool mHasFixedItems;
bool mIsCompositingCheap;
};
class nsDisplayItem;
@ -1707,7 +1703,6 @@ protected:
const nsRect& aRect, bool* aSnap);
bool TryOptimizeToImageLayer(nsDisplayListBuilder* aBuilder);
bool IsSingleFixedPositionImage(nsDisplayListBuilder* aBuilder, const nsRect& aClipRect);
void ConfigureLayer(ImageLayer* aLayer);
/* Used to cache mFrame->IsThemed() since it isn't a cheap call */

View File

@ -179,16 +179,6 @@ nsRect nsCanvasFrame::CanvasArea() const
return result;
}
static void BlitSurface(gfxContext* aDest, const gfxRect& aRect, gfxASurface* aSource)
{
aDest->Translate(gfxPoint(aRect.x, aRect.y));
aDest->SetSource(aSource);
aDest->NewPath();
aDest->Rectangle(gfxRect(0, 0, aRect.width, aRect.height));
aDest->Fill();
aDest->Translate(-gfxPoint(aRect.x, aRect.y));
}
void
nsDisplayCanvasBackground::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
@ -196,46 +186,17 @@ nsDisplayCanvasBackground::Paint(nsDisplayListBuilder* aBuilder,
nsCanvasFrame* frame = static_cast<nsCanvasFrame*>(mFrame);
nsPoint offset = ToReferenceFrame();
nsRect bgClipRect = frame->CanvasArea() + offset;
if (NS_GET_A(mExtraBackgroundColor) > 0) {
aCtx->SetColor(mExtraBackgroundColor);
aCtx->FillRect(bgClipRect);
}
bool snap;
nsRect bounds = GetBounds(aBuilder, &snap);
nsIntRect pixelRect = bounds.ToOutsidePixels(mFrame->PresContext()->AppUnitsPerDevPixel());
nsRenderingContext context;
nsRefPtr<gfxContext> dest = aCtx->ThebesContext();
nsRefPtr<gfxASurface> surf;
nsRefPtr<gfxContext> ctx;
#ifndef MOZ_GFX_OPTIMIZE_MOBILE
if (IsSingleFixedPositionImage(aBuilder, bgClipRect) && aBuilder->IsPaintingToWindow() && !aBuilder->IsCompositingCheap()) {
surf = static_cast<gfxASurface*>(GetUnderlyingFrame()->Properties().Get(nsIFrame::CachedBackgroundImage()));
nsRefPtr<gfxASurface> destSurf = dest->CurrentSurface();
if (surf && surf->GetType() == destSurf->GetType()) {
BlitSurface(dest, mDestRect, surf);
return;
}
surf = destSurf->CreateSimilarSurface(gfxASurface::CONTENT_COLOR_ALPHA, gfxIntSize(ceil(mDestRect.width), ceil(mDestRect.height)));
if (surf) {
ctx = new gfxContext(surf);
ctx->Translate(-gfxPoint(mDestRect.x, mDestRect.y));
context.Init(aCtx->DeviceContext(), ctx);
}
}
#endif
nsCSSRendering::PaintBackground(mFrame->PresContext(), surf ? context : *aCtx, mFrame,
surf ? bounds : mVisibleRect,
nsCSSRendering::PaintBackground(mFrame->PresContext(), *aCtx, mFrame,
mVisibleRect,
nsRect(offset, mFrame->GetSize()),
aBuilder->GetBackgroundPaintFlags(),
&bgClipRect);
if (surf) {
BlitSurface(dest, mDestRect, surf);
GetUnderlyingFrame()->Properties().Set(nsIFrame::CachedBackgroundImage(), surf.forget().get());
GetUnderlyingFrame()->AddStateBits(NS_FRAME_HAS_CACHED_BACKGROUND);
}
}
/**

View File

@ -253,15 +253,6 @@ nsIFrame::MarkAsAbsoluteContainingBlock() {
Properties().Set(AbsoluteContainingBlockProperty(), new nsAbsoluteContainingBlock(GetAbsoluteListID()));
}
void
nsIFrame::ClearDisplayItemCache()
{
if (HasAnyStateBits(NS_FRAME_HAS_CACHED_BACKGROUND)) {
Properties().Delete(CachedBackgroundImage());
RemoveStateBits(NS_FRAME_HAS_CACHED_BACKGROUND);
}
}
bool
nsIFrame::CheckAndClearPaintedState()
{

View File

@ -295,10 +295,6 @@ typedef PRUint64 nsFrameState;
// Frame is a descendant of a popup
#define NS_FRAME_IN_POPUP NS_FRAME_STATE_BIT(48)
// Frame has a cached rasterization of anV
// nsDisplayBackground display item
#define NS_FRAME_HAS_CACHED_BACKGROUND NS_FRAME_STATE_BIT(49)
// Box layout bits
#define NS_STATE_IS_HORIZONTAL NS_FRAME_STATE_BIT(22)
#define NS_STATE_IS_DIRECTION_NORMAL NS_FRAME_STATE_BIT(31)
@ -879,11 +875,6 @@ public:
delete static_cast<nsOverflowAreas*>(aPropertyValue);
}
static void DestroySurface(void* aPropertyValue)
{
static_cast<gfxASurface*>(aPropertyValue)->Release();
}
#ifdef _MSC_VER
// XXX Workaround MSVC issue by making the static FramePropertyDescriptor
// non-const. See bug 555727.
@ -927,8 +918,6 @@ public:
NS_DECLARE_FRAME_PROPERTY(LineBaselineOffset, nsnull)
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImage, DestroySurface)
/**
* Return the distance between the border edge of the frame and the
* margin edge of the frame. Like GetRect(), returns the dimensions
@ -2558,8 +2547,6 @@ NS_PTR_TO_INT32(frame->Properties().Get(nsIFrame::ParagraphDepthProperty()))
*/
virtual bool IsFocusable(PRInt32 *aTabIndex = nsnull, bool aWithMouse = false);
void ClearDisplayItemCache();
// BOX LAYOUT METHODS
// These methods have been migrated from nsIBox and are in the process of
// being refactored. DO NOT USE OUTSIDE OF XUL.