Exemple #1
0
bool nsRegion::Contains(const nsRegion& aRgn) const
{
  // XXX this could be made faster by iterating over
  // both regions at the same time some how
  for (auto iter = aRgn.RectIter(); !iter.Done(); iter.Next()) {
    if (!Contains(iter.Get())) {
      return false;
    }
  }
  return true;
}
Exemple #2
0
 void set(nsRegion &region) {
   clear();
   for (auto iter = region.RectIter(); !iter.Done(); iter.Next()) {
     const nsRect& r = iter.Get();
     for (int y = r.y; y < r.YMost(); y++) {
       for (int x = r.x; x < r.XMost(); x++) {
         bitmap[x + y * width] = REGION_VALUE;
       }
     }
   }
 }
static float
ComputeDistanceFromRegion(const nsPoint& aPoint, const nsRegion& aRegion)
{
  MOZ_ASSERT(!aRegion.IsEmpty(), "can't compute distance between point and empty region");
  float minDist = -1;
  for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
    float dist = ComputeDistanceFromRect(aPoint, iter.Get());
    if (dist < minDist || minDist < 0) {
      minDist = dist;
    }
  }
  return minDist;
}
void
AppendToString(std::stringstream& aStream, const nsRegion& r,
               const char* pfx, const char* sfx)
{
  aStream << pfx;

  aStream << "< ";
  for (auto iter = r.RectIter(); !iter.Done(); iter.Next()) {
    AppendToString(aStream, iter.Get());
    aStream << "; ";
  }
  aStream << ">";

  aStream << sfx;
}