Revision 85bfeb7a
Added by Leszek Koltunski over 7 years ago
| src/main/java/org/distorted/library/main/DistortedMaster.java | ||
|---|---|---|
| 96 | 96 |
} |
| 97 | 97 |
|
| 98 | 98 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 99 |
// can make this logarithmic but the typical number of children is very small anyway |
|
| 99 |
// Can make this logarithmic but the typical number of children is very small anyway. |
|
| 100 |
// |
|
| 101 |
// We want to keep same buckets next to each other, while avoiding changes in order of the children |
|
| 102 |
// (if possible!) We want to keep bucket=0 (i.e. the non-postprocessed children) at the beginning. |
|
| 100 | 103 |
|
| 101 |
static void addSorted(ArrayList<DistortedNode> mChildren, DistortedNode newChild)
|
|
| 104 |
static void addSortingByBuckets(ArrayList<DistortedNode> mChildren, DistortedNode newChild)
|
|
| 102 | 105 |
{
|
| 103 | 106 |
int i,num = mChildren.size(); |
| 104 | 107 |
long bucket = newChild.getPostprocessQueue().getID(); |
| 108 |
boolean sameBucket = false; |
|
| 105 | 109 |
|
| 106 | 110 |
for(i=0; i<num; i++) |
| 107 | 111 |
{
|
| 108 |
if( mChildren.get(i).getPostprocessQueue().getID() > bucket ) break; |
|
| 112 |
if( mChildren.get(i).getPostprocessQueue().getID() == bucket ) |
|
| 113 |
{
|
|
| 114 |
sameBucket=true; |
|
| 115 |
} |
|
| 116 |
else if( sameBucket || bucket==0 ) |
|
| 117 |
{
|
|
| 118 |
break; |
|
| 119 |
} |
|
| 109 | 120 |
} |
| 110 | 121 |
|
| 111 | 122 |
mChildren.add(i,newChild); |
| src/main/java/org/distorted/library/main/DistortedNode.java | ||
|---|---|---|
| 228 | 228 |
if( mNumChildren[0]==0 && newData.mFBO!=null ) |
| 229 | 229 |
{
|
| 230 | 230 |
newData.mFBO.markForDeletion(); |
| 231 |
android.util.Log.d("NODE", "ERROR!! this NodeData cannot possibly contain a non-null FBO!! "+newData.mFBO.getID() );
|
|
| 231 |
android.util.Log.e("NODE", "ERROR!! this NodeData cannot possibly contain a non-null FBO!! "+newData.mFBO.getID() );
|
|
| 232 | 232 |
newData.mFBO = null; |
| 233 | 233 |
} |
| 234 | 234 |
|
| ... | ... | |
| 362 | 362 |
if( mParent!=null ) |
| 363 | 363 |
{
|
| 364 | 364 |
mParent.mChildren.remove(this); |
| 365 |
DistortedMaster.addSorted(mParent.mChildren,this);
|
|
| 365 |
DistortedMaster.addSortingByBuckets(mParent.mChildren,this);
|
|
| 366 | 366 |
} |
| 367 | 367 |
else if( mSurfaceParent!=null ) |
| 368 | 368 |
{
|
| 369 | 369 |
ArrayList<DistortedNode> children = mSurfaceParent.getChildren(); |
| 370 | 370 |
children.remove(this); |
| 371 |
DistortedMaster.addSorted(children,this);
|
|
| 371 |
DistortedMaster.addSortingByBuckets(children,this);
|
|
| 372 | 372 |
} |
| 373 | 373 |
} |
| 374 | 374 |
|
| ... | ... | |
| 649 | 649 |
if( mChildren==null ) mChildren = new ArrayList<>(2); |
| 650 | 650 |
job.node.mParent = this; |
| 651 | 651 |
job.node.mSurfaceParent = null; |
| 652 |
DistortedMaster.addSorted(mChildren,job.node);
|
|
| 652 |
DistortedMaster.addSortingByBuckets(mChildren,job.node);
|
|
| 653 | 653 |
mNumChildren[0]++; |
| 654 | 654 |
break; |
| 655 | 655 |
case DETACH: numChanges++; |
| ... | ... | |
| 676 | 676 |
} |
| 677 | 677 |
break; |
| 678 | 678 |
case SORT : mChildren.remove(job.node); |
| 679 |
DistortedMaster.addSorted(mChildren,job.node);
|
|
| 679 |
DistortedMaster.addSortingByBuckets(mChildren,job.node);
|
|
| 680 | 680 |
break; |
| 681 | 681 |
} |
| 682 | 682 |
} |
| src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
|---|---|---|
| 889 | 889 |
{
|
| 890 | 890 |
case ATTACH: if( mChildren==null ) mChildren = new ArrayList<>(2); |
| 891 | 891 |
job.node.setSurfaceParent(this); |
| 892 |
DistortedMaster.addSorted(mChildren,job.node);
|
|
| 892 |
DistortedMaster.addSortingByBuckets(mChildren,job.node);
|
|
| 893 | 893 |
mNumChildren++; |
| 894 | 894 |
break; |
| 895 | 895 |
case DETACH: if( mNumChildren>0 && mChildren.remove(job.node) ) |
| ... | ... | |
| 912 | 912 |
} |
| 913 | 913 |
break; |
| 914 | 914 |
case SORT : mChildren.remove(job.node); |
| 915 |
DistortedMaster.addSorted(mChildren,job.node);
|
|
| 915 |
DistortedMaster.addSortingByBuckets(mChildren,job.node);
|
|
| 916 | 916 |
break; |
| 917 | 917 |
} |
| 918 | 918 |
} |
Also available in: Unified diff
Try and avoid re-sorting the children by buckets (if we can!). This makes change in rendering order in the 'Transparency' app actually work.