Bug 1128769 (Part 5) - Record the last draw result for various less common frame types and use it to decide whether to sync decode. r=tn

This commit is contained in:
Seth Fowler 2015-02-09 23:27:40 -08:00
parent 9bc6846579
commit a1186f0369
5 changed files with 91 additions and 23 deletions

View File

@ -19,6 +19,8 @@
#define HOVER "hover"
#define FOCUS "focus"
using namespace mozilla::image;
nsButtonFrameRenderer::nsButtonFrameRenderer()
{
MOZ_COUNT_CTOR(nsButtonFrameRenderer);
@ -121,6 +123,7 @@ public:
nsRenderingContext* aCtx) MOZ_OVERRIDE;
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
bool* aSnap) MOZ_OVERRIDE;
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion) MOZ_OVERRIDE;
@ -156,12 +159,25 @@ private:
nsButtonFrameRenderer* mBFR;
};
nsDisplayItemGeometry*
nsDisplayButtonBorderBackground::AllocateGeometry(nsDisplayListBuilder* aBuilder)
{
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void
nsDisplayButtonBorderBackground::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion)
{
AddInvalidRegionForSyncDecodeBackgroundImages(aBuilder, aGeometry, aInvalidRegion);
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
}
@ -174,8 +190,11 @@ void nsDisplayButtonBorderBackground::Paint(nsDisplayListBuilder* aBuilder,
nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize());
// draw the border and background inside the focus and outline borders
mBFR->PaintBorderAndBackground(pc, *aCtx, mVisibleRect, r,
aBuilder->GetBackgroundPaintFlags());
DrawResult result =
mBFR->PaintBorderAndBackground(pc, *aCtx, mVisibleRect, r,
aBuilder->GetBackgroundPaintFlags());
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
void nsDisplayButtonForeground::Paint(nsDisplayListBuilder* aBuilder,
@ -251,7 +270,7 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsPresContext* aPresContext,
}
void
DrawResult
nsButtonFrameRenderer::PaintBorderAndBackground(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
@ -265,12 +284,15 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsPresContext* aPresContext,
nsStyleContext* context = mFrame->StyleContext();
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, aBGFlags);
DrawResult result =
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, aBGFlags);
nsCSSRendering::PaintBoxShadowInner(aPresContext, aRenderingContext,
mFrame, buttonRect, aDirtyRect);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, context);
return result;
}

View File

@ -6,6 +6,7 @@
#ifndef nsButtonFrameRenderer_h___
#define nsButtonFrameRenderer_h___
#include "imgIContainer.h"
#include "nsAutoPtr.h"
#include "nsMargin.h"
@ -24,6 +25,8 @@ class nsStyleContext;
#define NS_BUTTON_RENDERER_LAST_CONTEXT_INDEX NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX
class nsButtonFrameRenderer {
typedef mozilla::image::DrawResult DrawResult;
public:
nsButtonFrameRenderer();
@ -41,11 +44,11 @@ public:
const nsRect& aDirtyRect,
const nsRect& aRect);
void PaintBorderAndBackground(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
const nsRect& aRect,
uint32_t aBGFlags);
DrawResult PaintBorderAndBackground(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
const nsRect& aRect,
uint32_t aBGFlags);
void SetFrame(nsFrame* aFrame, nsPresContext* aPresContext);

View File

@ -24,6 +24,7 @@
using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::image;
using namespace mozilla::layout;
nsContainerFrame*
@ -106,6 +107,7 @@ public:
nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE;
virtual void Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx) MOZ_OVERRIDE;
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion) MOZ_OVERRIDE;
@ -125,9 +127,17 @@ void
nsDisplayFieldSetBorderBackground::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
static_cast<nsFieldSetFrame*>(mFrame)->
DrawResult result = static_cast<nsFieldSetFrame*>(mFrame)->
PaintBorderBackground(*aCtx, ToReferenceFrame(),
mVisibleRect, aBuilder->GetBackgroundPaintFlags());
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
nsDisplayItemGeometry*
nsDisplayFieldSetBorderBackground::AllocateGeometry(nsDisplayListBuilder* aBuilder)
{
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void
@ -135,7 +145,14 @@ nsDisplayFieldSetBorderBackground::ComputeInvalidationRegion(nsDisplayListBuilde
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion)
{
AddInvalidRegionForSyncDecodeBackgroundImages(aBuilder, aGeometry, aInvalidRegion);
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
}
@ -192,7 +209,7 @@ nsFieldSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
contentDisplayItems.MoveTo(aLists);
}
void
DrawResult
nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
nsPoint aPt, const nsRect& aDirtyRect, uint32_t aBGFlags)
{
@ -206,8 +223,9 @@ nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
rect += aPt;
nsPresContext* presContext = PresContext();
nsCSSRendering::PaintBackground(presContext, aRenderingContext, this,
aDirtyRect, rect, aBGFlags);
DrawResult result =
nsCSSRendering::PaintBackground(presContext, aRenderingContext, this,
aDirtyRect, rect, aBGFlags);
nsCSSRendering::PaintBoxShadowInner(presContext, aRenderingContext,
this, rect, aDirtyRect);
@ -270,6 +288,8 @@ nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
nsRect(aPt, mRect.Size()),
mStyleContext);
}
return result;
}
nscoord

View File

@ -7,10 +7,13 @@
#define nsFieldSetFrame_h___
#include "mozilla/Attributes.h"
#include "imgIContainer.h"
#include "nsContainerFrame.h"
class nsFieldSetFrame MOZ_FINAL : public nsContainerFrame
{
typedef mozilla::image::DrawResult DrawResult;
public:
NS_DECL_FRAMEARENA_HELPERS
@ -47,8 +50,9 @@ public:
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
void PaintBorderBackground(nsRenderingContext& aRenderingContext,
nsPoint aPt, const nsRect& aDirtyRect, uint32_t aBGFlags);
DrawResult PaintBorderBackground(nsRenderingContext& aRenderingContext,
nsPoint aPt, const nsRect& aDirtyRect,
uint32_t aBGFlags);
#ifdef DEBUG
virtual void SetInitialChildList(ChildListID aListID,

View File

@ -41,6 +41,7 @@
using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::image;
//#define NOISY_SEARCH 1
@ -1885,6 +1886,7 @@ public:
}
#endif
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion) MOZ_OVERRIDE;
@ -1896,12 +1898,25 @@ private:
nsRect mRect;
};
nsDisplayItemGeometry*
nsDisplayMathMLCharBackground::AllocateGeometry(nsDisplayListBuilder* aBuilder)
{
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void
nsDisplayMathMLCharBackground::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion)
{
AddInvalidRegionForSyncDecodeBackgroundImages(aBuilder, aGeometry, aInvalidRegion);
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
}
@ -1911,10 +1926,14 @@ void nsDisplayMathMLCharBackground::Paint(nsDisplayListBuilder* aBuilder,
{
const nsStyleBorder* border = mStyleContext->StyleBorder();
nsRect rect(mRect + ToReferenceFrame());
nsCSSRendering::PaintBackgroundWithSC(mFrame->PresContext(), *aCtx, mFrame,
mVisibleRect, rect,
mStyleContext, *border,
aBuilder->GetBackgroundPaintFlags());
DrawResult result =
nsCSSRendering::PaintBackgroundWithSC(mFrame->PresContext(), *aCtx, mFrame,
mVisibleRect, rect,
mStyleContext, *border,
aBuilder->GetBackgroundPaintFlags());
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
class nsDisplayMathMLCharForeground : public nsDisplayItem {