Bug 482689. Optimize display lists for backgrounds. r/sr=roc

This commit is contained in:
Stuart Parmenter 2009-04-08 08:19:51 -07:00
parent 8a4ff1a34f
commit c58c9dbadb
2 changed files with 39 additions and 7 deletions

View File

@ -803,5 +803,6 @@ nsThebesImage::SetHasNoAlpha()
if (mFormat == gfxASurface::ImageFormatARGB32) {
mFormat = gfxASurface::ImageFormatRGB24;
mFormatChanged = PR_TRUE;
mAlphaDepth = 0;
}
}

View File

@ -57,6 +57,11 @@
#include "nsSVGIntegrationUtils.h"
#endif
#include "imgIContainer.h"
#include "gfxIImageFrame.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIImage.h"
nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
PRBool aIsForEvents, PRBool aBuildCaret)
: mReferenceFrame(aReferenceFrame),
@ -493,14 +498,40 @@ nsDisplayBackground::IsOpaque(nsDisplayListBuilder* aBuilder) {
return PR_FALSE;
const nsStyleBackground* bg;
PRBool hasBG =
nsCSSRendering::FindBackground(mFrame->PresContext(), mFrame, &bg);
return (hasBG && NS_GET_A(bg->mBackgroundColor) == 255 &&
// bottom layer's clip is used for the color
bg->BottomLayer().mClip == NS_STYLE_BG_CLIP_BORDER &&
!nsLayoutUtils::HasNonZeroCorner(mFrame->GetStyleBorder()->
mBorderRadius));
if (!nsCSSRendering::FindBackground(mFrame->PresContext(), mFrame, &bg))
return PR_FALSE;
const nsStyleBackground::Layer& bottomLayer = bg->BottomLayer();
// bottom layer's clip is used for the color
if (bottomLayer.mClip != NS_STYLE_BG_CLIP_BORDER ||
nsLayoutUtils::HasNonZeroCorner(mFrame->GetStyleBorder()->mBorderRadius))
return PR_FALSE;
if (NS_GET_A(bg->mBackgroundColor) == 255)
return PR_TRUE;
if (bottomLayer.mRepeat == NS_STYLE_BG_REPEAT_XY) {
if (bottomLayer.mImage.mRequest) {
nsCOMPtr<imgIContainer> container;
bottomLayer.mImage.mRequest->GetImage(getter_AddRefs(container));
PRUint32 nframes;
container->GetNumFrames(&nframes);
if (nframes == 1) {
nsCOMPtr<gfxIImageFrame> imgFrame;
container->GetCurrentFrame(getter_AddRefs(imgFrame));
nsCOMPtr<nsIImage> img(do_GetInterface(imgFrame));
PRBool hasMask = img->GetHasAlphaMask();
return !hasMask;
}
}
}
return PR_FALSE;
}
PRBool