mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-15 14:30:47 +00:00
Bug 837242. Part 2. Add a function to calculate the area of an nsRegion. r=roc
This commit is contained in:
parent
7d3be384bc
commit
680c0cb73c
@ -1275,6 +1275,18 @@ bool nsRegion::IsEqual (const nsRegion& aRegion) const
|
||||
}
|
||||
|
||||
|
||||
uint64_t nsRegion::Area () const
|
||||
{
|
||||
uint64_t area = 0;
|
||||
nsRegionRectIterator iter(*this);
|
||||
const nsRect* r;
|
||||
while ((r = iter.Next()) != nullptr) {
|
||||
area += uint64_t(r->width)*r->height;
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
|
||||
void nsRegion::MoveBy (nsPoint aPt)
|
||||
{
|
||||
if (aPt.x || aPt.y)
|
||||
|
@ -147,6 +147,7 @@ public:
|
||||
bool IsEqual (const nsRegion& aRegion) const;
|
||||
uint32_t GetNumRects () const { return mRectCount; }
|
||||
const nsRect& GetBounds () const { return mBoundRect; }
|
||||
uint64_t Area () const;
|
||||
// Converts this region from aFromAPP, an appunits per pixel ratio, to
|
||||
// aToAPP. This applies nsRect::ConvertAppUnitsRoundOut/In to each rect of
|
||||
// the region.
|
||||
|
@ -718,17 +718,6 @@ nsDisplayListBuilder::GetBackgroundPaintFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
static uint64_t RegionArea(const nsRegion& aRegion)
|
||||
{
|
||||
uint64_t area = 0;
|
||||
nsRegionRectIterator iter(aRegion);
|
||||
const nsRect* r;
|
||||
while ((r = iter.Next()) != nullptr) {
|
||||
area += uint64_t(r->width)*r->height;
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
void
|
||||
nsDisplayListBuilder::SubtractFromVisibleRegion(nsRegion* aVisibleRegion,
|
||||
const nsRegion& aRegion)
|
||||
@ -743,7 +732,7 @@ nsDisplayListBuilder::SubtractFromVisibleRegion(nsRegion* aVisibleRegion,
|
||||
// Do let aVisibleRegion get more complex if by doing so we reduce its
|
||||
// area by at least half.
|
||||
if (GetAccurateVisibleRegions() || tmp.GetNumRects() <= 15 ||
|
||||
RegionArea(tmp) <= RegionArea(*aVisibleRegion)/2) {
|
||||
tmp.Area() <= aVisibleRegion->Area()/2) {
|
||||
*aVisibleRegion = tmp;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user