зеркало из https://github.com/mozilla/gecko-dev.git
Bug 947062 - Refactor nsDisplayBackgroundImage::GetLayerState. r=mattwoodrow
--HG-- extra : commitid : 3smcI8XeXP2 extra : rebase_source : 7fc94ccc5ffc6ce1420dc2250c32b48732665315 extra : amend_source : 9dab8e397f9428cb09ec0ce0c7ba7f97acedc1d9
This commit is contained in:
Родитель
9b562aa73b
Коммит
7d8fa64572
|
@ -2462,41 +2462,53 @@ nsDisplayBackgroundImage::GetContainer(LayerManager* aManager,
|
||||||
return container.forget();
|
return container.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerState
|
nsDisplayBackgroundImage::ImageLayerization
|
||||||
nsDisplayBackgroundImage::GetLayerState(nsDisplayListBuilder* aBuilder,
|
nsDisplayBackgroundImage::ShouldCreateOwnLayer(nsDisplayListBuilder* aBuilder,
|
||||||
LayerManager* aManager,
|
LayerManager* aManager)
|
||||||
const ContainerLayerParameters& aParameters)
|
|
||||||
{
|
{
|
||||||
bool animated = false;
|
if (nsLayoutUtils::AnimatedImageLayersEnabled() && mBackgroundStyle) {
|
||||||
if (mBackgroundStyle) {
|
|
||||||
const nsStyleBackground::Layer &layer = mBackgroundStyle->mLayers[mLayer];
|
const nsStyleBackground::Layer &layer = mBackgroundStyle->mLayers[mLayer];
|
||||||
const nsStyleImage* image = &layer.mImage;
|
const nsStyleImage* image = &layer.mImage;
|
||||||
if (image->GetType() == eStyleImageType_Image) {
|
if (image->GetType() == eStyleImageType_Image) {
|
||||||
imgIRequest* imgreq = image->GetImageData();
|
imgIRequest* imgreq = image->GetImageData();
|
||||||
nsCOMPtr<imgIContainer> image;
|
nsCOMPtr<imgIContainer> image;
|
||||||
if (NS_SUCCEEDED(imgreq->GetImage(getter_AddRefs(image))) && image) {
|
if (NS_SUCCEEDED(imgreq->GetImage(getter_AddRefs(image))) && image) {
|
||||||
if (NS_FAILED(image->GetAnimated(&animated))) {
|
bool animated = false;
|
||||||
animated = false;
|
if (NS_SUCCEEDED(image->GetAnimated(&animated)) && animated) {
|
||||||
|
return WHENEVER_POSSIBLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!animated ||
|
if (nsLayoutUtils::GPUImageScalingEnabled() &&
|
||||||
!nsLayoutUtils::AnimatedImageLayersEnabled()) {
|
aManager->IsCompositingCheap()) {
|
||||||
if (!aManager->IsCompositingCheap() ||
|
return ONLY_FOR_SCALING;
|
||||||
!nsLayoutUtils::GPUImageScalingEnabled()) {
|
|
||||||
return LAYER_NONE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CanOptimizeToImageLayer(aManager, aBuilder)) {
|
return NO_LAYER_NEEDED;
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerState
|
||||||
|
nsDisplayBackgroundImage::GetLayerState(nsDisplayListBuilder* aBuilder,
|
||||||
|
LayerManager* aManager,
|
||||||
|
const ContainerLayerParameters& aParameters)
|
||||||
|
{
|
||||||
|
ImageLayerization shouldLayerize = ShouldCreateOwnLayer(aBuilder, aManager);
|
||||||
|
if (shouldLayerize == NO_LAYER_NEEDED) {
|
||||||
|
// We can skip the call to CanOptimizeToImageLayer if we don't want a
|
||||||
|
// layer anyway.
|
||||||
return LAYER_NONE;
|
return LAYER_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CanOptimizeToImageLayer(aManager, aBuilder)) {
|
||||||
|
if (shouldLayerize == WHENEVER_POSSIBLE) {
|
||||||
|
return LAYER_ACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MOZ_ASSERT(shouldLayerize == ONLY_FOR_SCALING, "unhandled ImageLayerization value?");
|
||||||
|
|
||||||
MOZ_ASSERT(mImage);
|
MOZ_ASSERT(mImage);
|
||||||
|
|
||||||
if (!animated) {
|
|
||||||
int32_t imageWidth;
|
int32_t imageWidth;
|
||||||
int32_t imageHeight;
|
int32_t imageHeight;
|
||||||
mImage->GetWidth(&imageWidth);
|
mImage->GetWidth(&imageWidth);
|
||||||
|
@ -2509,18 +2521,16 @@ nsDisplayBackgroundImage::GetLayerState(nsDisplayListBuilder* aBuilder,
|
||||||
const gfxSize scale = gfxSize(destLayerRect.width / imageWidth,
|
const gfxSize scale = gfxSize(destLayerRect.width / imageWidth,
|
||||||
destLayerRect.height / imageHeight);
|
destLayerRect.height / imageHeight);
|
||||||
|
|
||||||
// If we are not scaling at all, no point in separating this into a layer.
|
if ((scale.width != 1.0f || scale.height != 1.0f) &&
|
||||||
if (scale.width == 1.0f && scale.height == 1.0f) {
|
(destLayerRect.width * destLayerRect.height >= 64 * 64)) {
|
||||||
return LAYER_NONE;
|
// Separate this image into a layer.
|
||||||
}
|
// There's no point in doing this if we are not scaling at all or if the
|
||||||
|
// target size is pretty small.
|
||||||
// If the target size is pretty small, no point in using a layer.
|
|
||||||
if (destLayerRect.width * destLayerRect.height < 64 * 64) {
|
|
||||||
return LAYER_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return LAYER_ACTIVE;
|
return LAYER_ACTIVE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return LAYER_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<Layer>
|
already_AddRefed<Layer>
|
||||||
|
|
|
@ -2619,6 +2619,16 @@ protected:
|
||||||
void PaintInternal(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx,
|
void PaintInternal(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx,
|
||||||
const nsRect& aBounds, nsRect* aClipRect);
|
const nsRect& aBounds, nsRect* aClipRect);
|
||||||
|
|
||||||
|
// Determine whether we want to be separated into our own layer, independent
|
||||||
|
// of whether this item can actually be layerized.
|
||||||
|
enum ImageLayerization {
|
||||||
|
WHENEVER_POSSIBLE,
|
||||||
|
ONLY_FOR_SCALING,
|
||||||
|
NO_LAYER_NEEDED
|
||||||
|
};
|
||||||
|
ImageLayerization ShouldCreateOwnLayer(nsDisplayListBuilder* aBuilder,
|
||||||
|
LayerManager* aManager);
|
||||||
|
|
||||||
// Cache the result of nsCSSRendering::FindBackground. Always null if
|
// Cache the result of nsCSSRendering::FindBackground. Always null if
|
||||||
// mIsThemed is true or if FindBackground returned false.
|
// mIsThemed is true or if FindBackground returned false.
|
||||||
const nsStyleBackground* mBackgroundStyle;
|
const nsStyleBackground* mBackgroundStyle;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче