code: public Rectangle[] getDirtyRegions ()
      {
          List<Rectangle> merged = Lists.newArrayList();
  
          for (int ii = _dirty.size() - 1; ii >= 0; ii--) {
              // pop the next rectangle from the dirty list
              Rectangle mr = _dirty.remove(ii);
  
              // merge in any overlapping rectangles
              for (int jj = ii - 1; jj >= 0; jj--) {
                  Rectangle r = _dirty.get(jj);
                  if (mr.intersects(r)) {
                      // remove the overlapping rectangle from the list
                      _dirty.remove(jj);
                      ii--;
                      // grow the merged dirty rectangle
                      mr.add(r);
                  }
              }
  
              // add the merged rectangle to the list
              merged.add(mr);
          }
  
          return merged.toArray(new Rectangle[merged.size()]);
      }
docs: Merges all outstanding dirty regions into a single list of rectangles and returns that to
  the caller. Internally, the list of accumulated dirty regions is cleared out and prepared
  for the next frame.