зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1364830 - Fix background image layer's draw result and image flags. r=mattwoodrow
This commit is contained in:
Родитель
7ae24a697f
Коммит
e853c9b0a6
|
@ -2006,12 +2006,12 @@ nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(const PaintBGParams
|
||||||
// draw the background. The canvas really should be drawing the
|
// draw the background. The canvas really should be drawing the
|
||||||
// bg, but there's no way to hook that up via css.
|
// bg, but there's no way to hook that up via css.
|
||||||
if (!aParams.frame->StyleDisplay()->UsedAppearance()) {
|
if (!aParams.frame->StyleDisplay()->UsedAppearance()) {
|
||||||
return DrawResult::NOT_READY;
|
return DrawResult::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIContent* content = aParams.frame->GetContent();
|
nsIContent* content = aParams.frame->GetContent();
|
||||||
if (!content || content->GetParent()) {
|
if (!content || content->GetParent()) {
|
||||||
return DrawResult::NOT_READY;
|
return DrawResult::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc = aParams.frame->StyleContext();
|
sc = aParams.frame->StyleContext();
|
||||||
|
@ -2777,11 +2777,12 @@ nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayerWithSC(const PaintBG
|
||||||
return DrawResult::SUCCESS;
|
return DrawResult::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DrawResult result = DrawResult::SUCCESS;
|
||||||
nsBackgroundLayerState state =
|
nsBackgroundLayerState state =
|
||||||
PrepareImageLayer(&aParams.presCtx, aParams.frame,
|
PrepareImageLayer(&aParams.presCtx, aParams.frame,
|
||||||
aParams.paintFlags, paintBorderArea,
|
aParams.paintFlags, paintBorderArea,
|
||||||
clipState.mBGClipArea, layer, nullptr);
|
clipState.mBGClipArea, layer, nullptr);
|
||||||
|
result &= state.mImageRenderer.PrepareResult();
|
||||||
if (!state.mFillArea.IsEmpty()) {
|
if (!state.mFillArea.IsEmpty()) {
|
||||||
return state.mImageRenderer.BuildWebRenderDisplayItemsForLayer(&aParams.presCtx,
|
return state.mImageRenderer.BuildWebRenderDisplayItemsForLayer(&aParams.presCtx,
|
||||||
aBuilder, aSc, aParentCommands, aLayer,
|
aBuilder, aSc, aParentCommands, aLayer,
|
||||||
|
@ -2791,7 +2792,7 @@ nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayerWithSC(const PaintBG
|
||||||
state.mRepeatSize, aParams.opacity);
|
state.mRepeatSize, aParams.opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DrawResult::SUCCESS;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRect
|
nsRect
|
||||||
|
|
|
@ -2983,6 +2983,7 @@ nsDisplayBackgroundImage::nsDisplayBackgroundImage(const InitData& aInitData)
|
||||||
, mLayer(aInitData.layer)
|
, mLayer(aInitData.layer)
|
||||||
, mIsRasterImage(aInitData.isRasterImage)
|
, mIsRasterImage(aInitData.isRasterImage)
|
||||||
, mShouldFixToViewport(aInitData.shouldFixToViewport)
|
, mShouldFixToViewport(aInitData.shouldFixToViewport)
|
||||||
|
, mImageFlags(0)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsDisplayBackgroundImage);
|
MOZ_COUNT_CTOR(nsDisplayBackgroundImage);
|
||||||
|
|
||||||
|
@ -3411,11 +3412,27 @@ nsDisplayBackgroundImage::ShouldCreateOwnLayer(nsDisplayListBuilder* aBuilder,
|
||||||
return NO_LAYER_NEEDED;
|
return NO_LAYER_NEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CheckForBorderItem(nsDisplayItem *aItem, uint32_t& aFlags)
|
||||||
|
{
|
||||||
|
nsDisplayItem* nextItem = aItem->GetAbove();
|
||||||
|
while (nextItem && nextItem->GetType() == nsDisplayItem::TYPE_BACKGROUND) {
|
||||||
|
nextItem = nextItem->GetAbove();
|
||||||
|
}
|
||||||
|
if (nextItem &&
|
||||||
|
nextItem->Frame() == aItem->Frame() &&
|
||||||
|
nextItem->GetType() == nsDisplayItem::TYPE_BORDER) {
|
||||||
|
aFlags |= nsCSSRendering::PAINTBG_WILL_PAINT_BORDER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LayerState
|
LayerState
|
||||||
nsDisplayBackgroundImage::GetLayerState(nsDisplayListBuilder* aBuilder,
|
nsDisplayBackgroundImage::GetLayerState(nsDisplayListBuilder* aBuilder,
|
||||||
LayerManager* aManager,
|
LayerManager* aManager,
|
||||||
const ContainerLayerParameters& aParameters)
|
const ContainerLayerParameters& aParameters)
|
||||||
{
|
{
|
||||||
|
mImageFlags = aBuilder->GetBackgroundPaintFlags();
|
||||||
|
CheckForBorderItem(this, mImageFlags);
|
||||||
|
|
||||||
if (ShouldUseAdvancedLayer(aManager, gfxPrefs::LayersAllowBackgroundImage) &&
|
if (ShouldUseAdvancedLayer(aManager, gfxPrefs::LayersAllowBackgroundImage) &&
|
||||||
CanBuildWebRenderDisplayItems(aManager)) {
|
CanBuildWebRenderDisplayItems(aManager)) {
|
||||||
return LAYER_ACTIVE;
|
return LAYER_ACTIVE;
|
||||||
|
@ -3505,7 +3522,7 @@ nsDisplayBackgroundImage::CreateWebRenderCommands(wr::DisplayListBuilder& aBuild
|
||||||
nsCSSRendering::PaintBGParams params =
|
nsCSSRendering::PaintBGParams params =
|
||||||
nsCSSRendering::PaintBGParams::ForSingleLayer(*StyleFrame()->PresContext(),
|
nsCSSRendering::PaintBGParams::ForSingleLayer(*StyleFrame()->PresContext(),
|
||||||
mVisibleRect, mBackgroundRect,
|
mVisibleRect, mBackgroundRect,
|
||||||
StyleFrame(), 0, mLayer,
|
StyleFrame(), mImageFlags, mLayer,
|
||||||
CompositionOp::OP_OVER);
|
CompositionOp::OP_OVER);
|
||||||
params.bgClipRect = &mBounds;
|
params.bgClipRect = &mBounds;
|
||||||
|
|
||||||
|
@ -3644,19 +3661,6 @@ nsDisplayBackgroundImage::RenderingMightDependOnPositioningAreaSizeChange()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CheckForBorderItem(nsDisplayItem *aItem, uint32_t& aFlags)
|
|
||||||
{
|
|
||||||
nsDisplayItem* nextItem = aItem->GetAbove();
|
|
||||||
while (nextItem && nextItem->GetType() == nsDisplayItem::TYPE_BACKGROUND) {
|
|
||||||
nextItem = nextItem->GetAbove();
|
|
||||||
}
|
|
||||||
if (nextItem &&
|
|
||||||
nextItem->Frame() == aItem->Frame() &&
|
|
||||||
nextItem->GetType() == nsDisplayItem::TYPE_BORDER) {
|
|
||||||
aFlags |= nsCSSRendering::PAINTBG_WILL_PAINT_BORDER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsDisplayBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
|
nsDisplayBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
|
||||||
nsRenderingContext* aCtx) {
|
nsRenderingContext* aCtx) {
|
||||||
|
@ -3667,9 +3671,6 @@ void
|
||||||
nsDisplayBackgroundImage::PaintInternal(nsDisplayListBuilder* aBuilder,
|
nsDisplayBackgroundImage::PaintInternal(nsDisplayListBuilder* aBuilder,
|
||||||
nsRenderingContext* aCtx, const nsRect& aBounds,
|
nsRenderingContext* aCtx, const nsRect& aBounds,
|
||||||
nsRect* aClipRect) {
|
nsRect* aClipRect) {
|
||||||
uint32_t flags = aBuilder->GetBackgroundPaintFlags();
|
|
||||||
CheckForBorderItem(this, flags);
|
|
||||||
|
|
||||||
gfxContext* ctx = aCtx->ThebesContext();
|
gfxContext* ctx = aCtx->ThebesContext();
|
||||||
StyleGeometryBox clip = mBackgroundStyle->mImage.mLayers[mLayer].mClip;
|
StyleGeometryBox clip = mBackgroundStyle->mImage.mLayers[mLayer].mClip;
|
||||||
|
|
||||||
|
@ -3682,7 +3683,7 @@ nsDisplayBackgroundImage::PaintInternal(nsDisplayListBuilder* aBuilder,
|
||||||
nsCSSRendering::PaintBGParams params =
|
nsCSSRendering::PaintBGParams params =
|
||||||
nsCSSRendering::PaintBGParams::ForSingleLayer(*StyleFrame()->PresContext(),
|
nsCSSRendering::PaintBGParams::ForSingleLayer(*StyleFrame()->PresContext(),
|
||||||
aBounds, mBackgroundRect,
|
aBounds, mBackgroundRect,
|
||||||
StyleFrame(), flags, mLayer,
|
StyleFrame(), mImageFlags, mLayer,
|
||||||
CompositionOp::OP_OVER);
|
CompositionOp::OP_OVER);
|
||||||
params.bgClipRect = aClipRect;
|
params.bgClipRect = aClipRect;
|
||||||
image::DrawResult result =
|
image::DrawResult result =
|
||||||
|
|
|
@ -3197,6 +3197,7 @@ protected:
|
||||||
bool mIsRasterImage;
|
bool mIsRasterImage;
|
||||||
/* Whether the image should be treated as fixed to the viewport. */
|
/* Whether the image should be treated as fixed to the viewport. */
|
||||||
bool mShouldFixToViewport;
|
bool mShouldFixToViewport;
|
||||||
|
uint32_t mImageFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TableType : uint8_t {
|
enum class TableType : uint8_t {
|
||||||
|
|
|
@ -615,7 +615,7 @@ nsImageRenderer::BuildWebRenderDisplayItems(nsPresContext* aPresContext,
|
||||||
ConvertImageRendererToDrawFlags(mFlags));
|
ConvertImageRendererToDrawFlags(mFlags));
|
||||||
if (!container) {
|
if (!container) {
|
||||||
NS_WARNING("Failed to get image container");
|
NS_WARNING("Failed to get image container");
|
||||||
return DrawResult::BAD_IMAGE;
|
return DrawResult::NOT_READY;
|
||||||
}
|
}
|
||||||
Maybe<wr::ImageKey> key = aLayer->SendImageContainer(container, aParentCommands);
|
Maybe<wr::ImageKey> key = aLayer->SendImageContainer(container, aParentCommands);
|
||||||
if (key.isNothing()) {
|
if (key.isNothing()) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче