harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Petrenko" <alexey.a.petre...@gmail.com>
Subject [HARMONY-5026] Dirty regions calculations...
Date Fri, 26 Oct 2007 09:54:36 GMT
Here is a part of the patch for HARMONY-5026 responsible for dirty
regions calculations:

=== cut ===
    public void addDirtyRegion(Rectangle r){
        if (dirtyRegions == null) {
            dirtyRegions = new MultiRectArea(r);
        } else {
            Rectangle rects[] = dirtyRegions.getRectangles();
            if (rects.length == 1){
                if (rects[0].contains(r)) return;

    public int[] getDirtyRegions(){
        if(dirtyRegions != null) return dirtyRegions.rect;
        else return null;
=== cut ===

As we can see MultiRectArea.add method is used here for adding a new region.
Here is the MultiRectArea.add method:

=== cut ===
    public void add(Rectangle rect) {
        setRect(union(this, new MultiRectArea(rect)).rect, false);
=== cut ===

I would say that this is probably too heavy method to call very often.

I can suggest the following strategy to use here:
1. Store all the dirty rectangles in some list (array, Vector or something)
2. Create MultiRectArea only once in getDirtyRegions methods. This
will theoretically save us a lot of object creations and array copying
in MultiRectArea.add method.


SY, Alexey

View raw message