Bug 695275 - Fix conversion of ThebesLayers to ImageLayers. r=roc

This commit is contained in:
Matt Woodrow 2011-10-21 14:22:19 +13:00
parent 19882a2aeb
commit 7722ff274a
2 changed files with 23 additions and 11 deletions

View File

@ -970,6 +970,12 @@ ContainerState::PopThebesLayerData()
nsRefPtr<ImageLayer> imageLayer = CreateOrRecycleImageLayer();
imageLayer->SetContainer(imageContainer);
data->mImage->ConfigureLayer(imageLayer);
if (mParameters.mInActiveTransformedSubtree) {
// The layer's current transform is applied first, then the result is scaled.
gfx3DMatrix transform = imageLayer->GetTransform()*
gfx3DMatrix::ScalingMatrix(mParameters.mXScale, mParameters.mYScale, 1.0f);
imageLayer->SetTransform(transform);
}
NS_ASSERTION(data->mImageClip.mRoundedClipRects.IsEmpty(),
"How did we get rounded clip rects here?");
if (data->mImageClip.mHaveClipRect) {
@ -1124,6 +1130,17 @@ ContainerState::ThebesLayerData::Accumulate(ContainerState* aState,
{
nscolor uniformColor;
bool isUniform = aItem->IsUniform(aState->mBuilder, &uniformColor);
/* Mark as available for conversion to image layer if this is a nsDisplayImage and
* we are the first visible item in the ThebesLayerData object.
*/
if (aItem->GetType() == nsDisplayItem::TYPE_IMAGE && mVisibleRegion.IsEmpty()) {
mImage = static_cast<nsDisplayImage*>(aItem);
mImageClip = aClip;
} else {
mImage = nsnull;
}
// Some display items have to exist (so they can set forceTransparentSurface
// below) but don't draw anything. They'll return true for isUniform but
// a color with opacity 0.
@ -1152,16 +1169,6 @@ ContainerState::ThebesLayerData::Accumulate(ContainerState* aState,
mDrawRegion.Or(mDrawRegion, aDrawRect);
mDrawRegion.SimplifyOutward(4);
}
/* Mark as available for conversion to image layer if this is a nsDisplayImage and
* we are the first visible item in the ThebesLayerData object.
*/
if (aItem->GetType() == nsDisplayItem::TYPE_IMAGE && mVisibleRegion.IsEmpty()) {
mImage = static_cast<nsDisplayImage*>(aItem);
mImageClip = aClip;
} else {
mImage = nsnull;
}
bool forceTransparentSurface = false;
nsRegion opaque = aItem->GetOpaqueRegion(aState->mBuilder, &forceTransparentSurface);

View File

@ -544,6 +544,7 @@ nsImageFrame::OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage)
*/
nsPresContext *presContext = PresContext();
aImage->SetAnimationMode(presContext->ImageAnimationMode());
mImageContainer = nsnull;
if (IsPendingLoad(aRequest)) {
// We don't care
@ -621,6 +622,7 @@ nsImageFrame::OnStopDecode(imgIRequest *aRequest,
nsPresContext *presContext = PresContext();
nsIPresShell *presShell = presContext->GetPresShell();
NS_ASSERTION(presShell, "No PresShell.");
mImageContainer = nsnull;
// Check what request type we're dealing with
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
@ -1237,7 +1239,10 @@ nsDisplayImage::ConfigureLayer(ImageLayer* aLayer)
nsRefPtr<ImageContainer>
nsImageFrame::GetContainer(LayerManager* aManager, imgIContainer* aImage)
{
if (mImageContainer && mImageContainer->Manager() == aManager) {
if (mImageContainer &&
(mImageContainer->Manager() == aManager ||
(!mImageContainer->Manager() &&
(mImageContainer->GetBackendType() == aManager->GetBackendType())))) {
return mImageContainer;
}