Bug 1362394 - Favicons in bookmarks treeviews don't use high quality scaling. r=tnikkel

MozReview-Commit-ID: 4NLhHtGybyv

--HG--
extra : rebase_source : 9b359b9cce617c089e66f778b728fbd1d20b3911
This commit is contained in:
Marco Bonardo 2017-05-06 14:04:38 +02:00
parent e20c89db7b
commit ff1608be78
2 changed files with 87 additions and 69 deletions

View File

@ -2809,11 +2809,12 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx) override
{
MOZ_ASSERT(aBuilder);
DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(),
mDisableSubpixelAA);
DrawResult result = static_cast<nsTreeBodyFrame*>(mFrame)
->PaintTreeBody(*aCtx, mVisibleRect, ToReferenceFrame());
->PaintTreeBody(*aCtx, mVisibleRect, ToReferenceFrame(), aBuilder);
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
@ -2903,7 +2904,8 @@ nsTreeBodyFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
DrawResult
nsTreeBodyFrame::PaintTreeBody(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect, nsPoint aPt)
const nsRect& aDirtyRect, nsPoint aPt,
nsDisplayListBuilder* aBuilder)
{
// Update our available height and our page count.
CalcInnerBox();
@ -2958,8 +2960,8 @@ nsTreeBodyFrame::PaintTreeBody(nsRenderingContext& aRenderingContext,
nsRect dirtyRect;
if (dirtyRect.IntersectRect(aDirtyRect, rowRect + aPt) &&
rowRect.y < (mInnerBox.y+mInnerBox.height)) {
result &=
PaintRow(i, rowRect + aPt, PresContext(), aRenderingContext, aDirtyRect, aPt);
result &= PaintRow(i, rowRect + aPt, PresContext(), aRenderingContext,
aDirtyRect, aPt, aBuilder);
}
}
@ -3016,12 +3018,13 @@ nsTreeBodyFrame::PaintColumn(nsTreeColumn* aColumn,
}
DrawResult
nsTreeBodyFrame::PaintRow(int32_t aRowIndex,
const nsRect& aRowRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt)
nsTreeBodyFrame::PaintRow(int32_t aRowIndex,
const nsRect& aRowRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt,
nsDisplayListBuilder* aBuilder)
{
// We have been given a rect for our row. We treat this row like a full-blown
// frame, meaning that it can have borders, margins, padding, and a background.
@ -3106,7 +3109,8 @@ nsTreeBodyFrame::PaintRow(int32_t aRowIndex,
cellRect.width, originalRowRect.height);
if (dirtyRect.IntersectRect(aDirtyRect, checkRect)) {
result &= PaintCell(aRowIndex, primaryCol, cellRect, aPresContext,
aRenderingContext, aDirtyRect, primaryX, aPt);
aRenderingContext, aDirtyRect, primaryX, aPt,
aBuilder);
}
}
@ -3172,7 +3176,8 @@ nsTreeBodyFrame::PaintRow(int32_t aRowIndex,
nscoord dummy;
if (dirtyRect.IntersectRect(aDirtyRect, checkRect))
result &= PaintCell(aRowIndex, currCol, cellRect, aPresContext,
aRenderingContext, aDirtyRect, dummy, aPt);
aRenderingContext, aDirtyRect, dummy, aPt,
aBuilder);
}
}
}
@ -3243,14 +3248,15 @@ nsTreeBodyFrame::PaintSeparator(int32_t aRowIndex,
}
DrawResult
nsTreeBodyFrame::PaintCell(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aCellRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nscoord& aCurrX,
nsPoint aPt)
nsTreeBodyFrame::PaintCell(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aCellRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nscoord& aCurrX,
nsPoint aPt,
nsDisplayListBuilder* aBuilder)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
@ -3404,7 +3410,7 @@ nsTreeBodyFrame::PaintCell(int32_t aRowIndex,
if (dirtyRect.IntersectRect(aDirtyRect, iconRect)) {
result &= PaintImage(aRowIndex, aColumn, iconRect, aPresContext,
aRenderingContext, aDirtyRect, remainingWidth,
currX);
currX, aBuilder);
}
// Now paint our element, but only if we aren't a cycler column.
@ -3432,7 +3438,7 @@ nsTreeBodyFrame::PaintCell(int32_t aRowIndex,
case nsITreeView::PROGRESS_UNDETERMINED:
result &= PaintProgressMeter(aRowIndex, aColumn, elementRect,
aPresContext, aRenderingContext,
aDirtyRect);
aDirtyRect, aBuilder);
break;
case nsITreeView::PROGRESS_NONE:
default:
@ -3552,14 +3558,15 @@ nsTreeBodyFrame::PaintTwisty(int32_t aRowIndex,
}
DrawResult
nsTreeBodyFrame::PaintImage(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aImageRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nscoord& aRemainingWidth,
nscoord& aCurrX)
nsTreeBodyFrame::PaintImage(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aImageRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nscoord& aRemainingWidth,
nscoord& aCurrX,
nsDisplayListBuilder* aBuilder)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
@ -3706,11 +3713,12 @@ nsTreeBodyFrame::PaintImage(int32_t aRowIndex,
ctx->PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, opacity);
}
uint32_t drawFlags = aBuilder && aBuilder->IsPaintingToWindow() ?
imgIContainer::FLAG_HIGH_QUALITY_SCALING : imgIContainer::FLAG_NONE;
result &=
nsLayoutUtils::DrawImage(*ctx, aPresContext, image,
nsLayoutUtils::GetSamplingFilterForFrame(this),
wholeImageDest, destRect, destRect.TopLeft(), aDirtyRect,
imgIContainer::FLAG_NONE);
wholeImageDest, destRect, destRect.TopLeft(), aDirtyRect, drawFlags);
if (opacity != 1.0f) {
ctx->PopGroupAndBlend();
@ -3940,12 +3948,13 @@ nsTreeBodyFrame::PaintCheckbox(int32_t aRowIndex,
}
DrawResult
nsTreeBodyFrame::PaintProgressMeter(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aProgressMeterRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
nsTreeBodyFrame::PaintProgressMeter(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aProgressMeterRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsDisplayListBuilder* aBuilder)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
@ -3997,12 +4006,14 @@ nsTreeBodyFrame::PaintProgressMeter(int32_t aRowIndex,
image->GetHeight(&height);
nsSize size(width*nsDeviceContext::AppUnitsPerCSSPixel(),
height*nsDeviceContext::AppUnitsPerCSSPixel());
uint32_t drawFlags = aBuilder && aBuilder->IsPaintingToWindow() ?
imgIContainer::FLAG_HIGH_QUALITY_SCALING : imgIContainer::FLAG_NONE;
result &=
nsLayoutUtils::DrawImage(*aRenderingContext.ThebesContext(),
aPresContext, image,
nsLayoutUtils::GetSamplingFilterForFrame(this),
nsRect(meterRect.TopLeft(), size), meterRect, meterRect.TopLeft(),
aDirtyRect, imgIContainer::FLAG_NONE);
aDirtyRect, drawFlags);
} else {
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
@ -4025,12 +4036,14 @@ nsTreeBodyFrame::PaintProgressMeter(int32_t aRowIndex,
image->GetHeight(&height);
nsSize size(width*nsDeviceContext::AppUnitsPerCSSPixel(),
height*nsDeviceContext::AppUnitsPerCSSPixel());
uint32_t drawFlags = aBuilder && aBuilder->IsPaintingToWindow() ?
imgIContainer::FLAG_HIGH_QUALITY_SCALING : imgIContainer::FLAG_NONE;
result &=
nsLayoutUtils::DrawImage(*aRenderingContext.ThebesContext(),
aPresContext, image,
nsLayoutUtils::GetSamplingFilterForFrame(this),
nsRect(meterRect.TopLeft(), size), meterRect, meterRect.TopLeft(),
aDirtyRect, imgIContainer::FLAG_NONE);
aDirtyRect, drawFlags);
}
}

View File

@ -196,7 +196,8 @@ public:
};
DrawResult PaintTreeBody(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect, nsPoint aPt);
const nsRect& aDirtyRect, nsPoint aPt,
nsDisplayListBuilder* aBuilder);
nsITreeBoxObject* GetTreeBoxObject() const { return mTreeBoxObject; }
@ -217,12 +218,13 @@ protected:
const nsRect& aDirtyRect);
// This method paints a single row in the tree.
DrawResult PaintRow(int32_t aRowIndex,
const nsRect& aRowRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt);
DrawResult PaintRow(int32_t aRowIndex,
const nsRect& aRowRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt,
nsDisplayListBuilder* aBuilder);
// This method paints a single separator in the tree.
DrawResult PaintSeparator(int32_t aRowIndex,
@ -232,14 +234,15 @@ protected:
const nsRect& aDirtyRect);
// This method paints a specific cell in a given row of the tree.
DrawResult PaintCell(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aCellRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nscoord& aCurrX,
nsPoint aPt);
DrawResult PaintCell(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aCellRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nscoord& aCurrX,
nsPoint aPt,
nsDisplayListBuilder* aBuilder);
// This method paints the twisty inside a cell in the primary column of an tree.
DrawResult PaintTwisty(int32_t aRowIndex,
@ -252,14 +255,15 @@ protected:
nscoord& aCurrX);
// This method paints the image inside the cell of an tree.
DrawResult PaintImage(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aImageRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nscoord& aRemainingWidth,
nscoord& aCurrX);
DrawResult PaintImage(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aImageRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nscoord& aRemainingWidth,
nscoord& aCurrX,
nsDisplayListBuilder* aBuilder);
// This method paints the text string inside a particular cell of the tree.
DrawResult PaintText(int32_t aRowIndex,
@ -279,12 +283,13 @@ protected:
const nsRect& aDirtyRect);
// This method paints the progress meter inside a particular cell of the tree.
DrawResult PaintProgressMeter(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aProgressMeterRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
DrawResult PaintProgressMeter(int32_t aRowIndex,
nsTreeColumn* aColumn,
const nsRect& aProgressMeterRect,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsDisplayListBuilder* aBuilder);
// This method paints a drop feedback of the tree.
DrawResult PaintDropFeedback(const nsRect& aDropFeedbackRect,