Bug 1359360 - Handle draw result for webrender background image layer. r=mattwoodrow

This commit is contained in:
Ethan Lin 2017-04-26 15:31:49 +08:00
Родитель 5490a9c0ff
Коммит 2b6ab30c4d
5 изменённых файлов: 63 добавлений и 56 удалений

Просмотреть файл

@ -1968,7 +1968,7 @@ nsCSSRendering::CanBuildWebRenderDisplayItemsForStyleImageLayer(nsPresContext& a
aBackgroundStyle->mImage.mLayers[aLayer].mImage.GetType() == eStyleImageType_Image; aBackgroundStyle->mImage.mLayers[aLayer].mImage.GetType() == eStyleImageType_Image;
} }
void DrawResult
nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(const PaintBGParams& aParams, nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(const PaintBGParams& aParams,
mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands, nsTArray<WebRenderParentCommand>& aParentCommands,
@ -1985,12 +1985,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; return DrawResult::NOT_READY;
} }
nsIContent* content = aParams.frame->GetContent(); nsIContent* content = aParams.frame->GetContent();
if (!content || content->GetParent()) { if (!content || content->GetParent()) {
return; return DrawResult::NOT_READY;
} }
sc = aParams.frame->StyleContext(); sc = aParams.frame->StyleContext();
@ -2709,7 +2709,7 @@ nsCSSRendering::PaintStyleImageLayerWithSC(const PaintBGParams& aParams,
return result; return result;
} }
void DrawResult
nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayerWithSC(const PaintBGParams& aParams, nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayerWithSC(const PaintBGParams& aParams,
mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands, nsTArray<WebRenderParentCommand>& aParentCommands,
@ -2747,7 +2747,7 @@ nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayerWithSC(const PaintBG
// Skip the following layer painting code if we found the dirty region is // Skip the following layer painting code if we found the dirty region is
// empty or the current layer is not selected for drawing. // empty or the current layer is not selected for drawing.
if (clipState.mDirtyRectInDevPx.IsEmpty()) { if (clipState.mDirtyRectInDevPx.IsEmpty()) {
return; return DrawResult::SUCCESS;
} }
nsBackgroundLayerState state = nsBackgroundLayerState state =
@ -2756,13 +2756,15 @@ nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayerWithSC(const PaintBG
clipState.mBGClipArea, layer, nullptr); clipState.mBGClipArea, layer, nullptr);
if (!state.mFillArea.IsEmpty()) { if (!state.mFillArea.IsEmpty()) {
state.mImageRenderer.BuildWebRenderDisplayItemsForLayer(&aParams.presCtx, return state.mImageRenderer.BuildWebRenderDisplayItemsForLayer(&aParams.presCtx,
aBuilder, aParentCommands, aLayer, aBuilder, aParentCommands, aLayer,
state.mDestArea, state.mFillArea, state.mDestArea, state.mFillArea,
state.mAnchor + paintBorderArea.TopLeft(), state.mAnchor + paintBorderArea.TopLeft(),
clipState.mDirtyRectInAppUnits, clipState.mDirtyRectInAppUnits,
state.mRepeatSize, aParams.opacity); state.mRepeatSize, aParams.opacity);
} }
return DrawResult::SUCCESS;
} }
nsRect nsRect

Просмотреть файл

@ -495,17 +495,17 @@ struct nsCSSRendering {
nsIFrame *aFrame, nsIFrame *aFrame,
const nsStyleBackground* aBackgroundStyle, const nsStyleBackground* aBackgroundStyle,
int32_t aLayer); int32_t aLayer);
static void BuildWebRenderDisplayItemsForStyleImageLayer(const PaintBGParams& aParams, static DrawResult BuildWebRenderDisplayItemsForStyleImageLayer(const PaintBGParams& aParams,
mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<mozilla::layers::WebRenderParentCommand>& aParentCommands,
mozilla::layers::WebRenderDisplayItemLayer* aLayer);
static void BuildWebRenderDisplayItemsForStyleImageLayerWithSC(const PaintBGParams& aParams,
mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<mozilla::layers::WebRenderParentCommand>& aParentCommands, nsTArray<mozilla::layers::WebRenderParentCommand>& aParentCommands,
mozilla::layers::WebRenderDisplayItemLayer* aLayer, mozilla::layers::WebRenderDisplayItemLayer* aLayer);
nsStyleContext *mBackgroundSC,
const nsStyleBorder& aBorder); static DrawResult BuildWebRenderDisplayItemsForStyleImageLayerWithSC(const PaintBGParams& aParams,
mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<mozilla::layers::WebRenderParentCommand>& aParentCommands,
mozilla::layers::WebRenderDisplayItemLayer* aLayer,
nsStyleContext *mBackgroundSC,
const nsStyleBorder& aBorder);
/** /**
* Returns the rectangle covered by the given background layer image, taking * Returns the rectangle covered by the given background layer image, taking

Просмотреть файл

@ -3436,7 +3436,10 @@ nsDisplayBackgroundImage::CreateWebRenderCommands(wr::DisplayListBuilder& aBuild
CompositionOp::OP_OVER); CompositionOp::OP_OVER);
params.bgClipRect = &mBounds; params.bgClipRect = &mBounds;
nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(params, aBuilder, aParentCommands, aLayer); image::DrawResult result =
nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(params, aBuilder, aParentCommands, aLayer);
nsDisplayBackgroundGeometry::UpdateDrawResult(this, result);
} }
void void

Просмотреть файл

@ -577,7 +577,7 @@ nsImageRenderer::Draw(nsPresContext* aPresContext,
return result; return result;
} }
void DrawResult
nsImageRenderer::BuildWebRenderDisplayItems(nsPresContext* aPresContext, nsImageRenderer::BuildWebRenderDisplayItems(nsPresContext* aPresContext,
mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands, nsTArray<WebRenderParentCommand>& aParentCommands,
@ -592,11 +592,11 @@ nsImageRenderer::BuildWebRenderDisplayItems(nsPresContext* aPresContext,
{ {
if (!IsReady()) { if (!IsReady()) {
NS_NOTREACHED("Ensure PrepareImage() has returned true before calling me"); NS_NOTREACHED("Ensure PrepareImage() has returned true before calling me");
return; return DrawResult::NOT_READY;
} }
if (aDest.IsEmpty() || aFill.IsEmpty() || if (aDest.IsEmpty() || aFill.IsEmpty() ||
mSize.width <= 0 || mSize.height <= 0) { mSize.width <= 0 || mSize.height <= 0) {
return; return DrawResult::SUCCESS;
} }
switch (mType) { switch (mType) {
@ -614,11 +614,11 @@ 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; return DrawResult::BAD_IMAGE;
} }
Maybe<wr::ImageKey> key = aLayer->SendImageContainer(container, aParentCommands); Maybe<wr::ImageKey> key = aLayer->SendImageContainer(container, aParentCommands);
if (key.isNothing()) { if (key.isNothing()) {
return; return DrawResult::BAD_IMAGE;
} }
const int32_t appUnitsPerDevPixel = mForFrame->PresContext()->AppUnitsPerDevPixel(); const int32_t appUnitsPerDevPixel = mForFrame->PresContext()->AppUnitsPerDevPixel();
@ -639,6 +639,8 @@ nsImageRenderer::BuildWebRenderDisplayItems(nsPresContext* aPresContext,
default: default:
break; break;
} }
return DrawResult::SUCCESS;
} }
already_AddRefed<gfxDrawable> already_AddRefed<gfxDrawable>
@ -701,7 +703,7 @@ nsImageRenderer::DrawLayer(nsPresContext* aPresContext,
aOpacity); aOpacity);
} }
void DrawResult
nsImageRenderer::BuildWebRenderDisplayItemsForLayer(nsPresContext* aPresContext, nsImageRenderer::BuildWebRenderDisplayItemsForLayer(nsPresContext* aPresContext,
mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands, nsTArray<WebRenderParentCommand>& aParentCommands,
@ -715,19 +717,19 @@ nsImageRenderer::BuildWebRenderDisplayItemsForLayer(nsPresContext* aPresCo
{ {
if (!IsReady()) { if (!IsReady()) {
NS_NOTREACHED("Ensure PrepareImage() has returned true before calling me"); NS_NOTREACHED("Ensure PrepareImage() has returned true before calling me");
return; return mPrepareResult;
} }
if (aDest.IsEmpty() || aFill.IsEmpty() || if (aDest.IsEmpty() || aFill.IsEmpty() ||
mSize.width <= 0 || mSize.height <= 0) { mSize.width <= 0 || mSize.height <= 0) {
return; return DrawResult::SUCCESS;
} }
BuildWebRenderDisplayItems(aPresContext, aBuilder, aParentCommands, aLayer, return BuildWebRenderDisplayItems(aPresContext, aBuilder, aParentCommands, aLayer,
aDirty, aDest, aFill, aAnchor, aRepeatSize, aDirty, aDest, aFill, aAnchor, aRepeatSize,
CSSIntRect(0, 0, CSSIntRect(0, 0,
nsPresContext::AppUnitsToIntCSSPixels(mSize.width), nsPresContext::AppUnitsToIntCSSPixels(mSize.width),
nsPresContext::AppUnitsToIntCSSPixels(mSize.height)), nsPresContext::AppUnitsToIntCSSPixels(mSize.height)),
aOpacity); aOpacity);
} }
/** /**

Просмотреть файл

@ -206,16 +206,16 @@ public:
* {background|mask}-specific arguments. * {background|mask}-specific arguments.
* @see nsLayoutUtils::DrawImage() for parameters. * @see nsLayoutUtils::DrawImage() for parameters.
*/ */
void BuildWebRenderDisplayItemsForLayer(nsPresContext* aPresContext, DrawResult BuildWebRenderDisplayItemsForLayer(nsPresContext* aPresContext,
mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<layers::WebRenderParentCommand>& aParentCommands, nsTArray<layers::WebRenderParentCommand>& aParentCommands,
mozilla::layers::WebRenderDisplayItemLayer* aLayer, mozilla::layers::WebRenderDisplayItemLayer* aLayer,
const nsRect& aDest, const nsRect& aDest,
const nsRect& aFill, const nsRect& aFill,
const nsPoint& aAnchor, const nsPoint& aAnchor,
const nsRect& aDirty, const nsRect& aDirty,
const nsSize& aRepeatSize, const nsSize& aRepeatSize,
float aOpacity); float aOpacity);
/** /**
* Draw the image to a single component of a border-image style rendering. * Draw the image to a single component of a border-image style rendering.
@ -290,17 +290,17 @@ private:
* *
* @see nsLayoutUtils::DrawImage() for other parameters. * @see nsLayoutUtils::DrawImage() for other parameters.
*/ */
void BuildWebRenderDisplayItems(nsPresContext* aPresContext, DrawResult BuildWebRenderDisplayItems(nsPresContext* aPresContext,
mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<layers::WebRenderParentCommand>& aParentCommands, nsTArray<layers::WebRenderParentCommand>& aParentCommands,
mozilla::layers::WebRenderDisplayItemLayer* aLayer, mozilla::layers::WebRenderDisplayItemLayer* aLayer,
const nsRect& aDirtyRect, const nsRect& aDirtyRect,
const nsRect& aDest, const nsRect& aDest,
const nsRect& aFill, const nsRect& aFill,
const nsPoint& aAnchor, const nsPoint& aAnchor,
const nsSize& aRepeatSize, const nsSize& aRepeatSize,
const mozilla::CSSIntRect& aSrc, const mozilla::CSSIntRect& aSrc,
float aOpacity = 1.0); float aOpacity = 1.0);
/** /**
* Helper method for creating a gfxDrawable from mPaintServerFrame or * Helper method for creating a gfxDrawable from mPaintServerFrame or