Revision c43abe6c
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/library/main/Distorted.java | ||
---|---|---|
26 | 26 |
import android.opengl.GLES31; |
27 | 27 |
|
28 | 28 |
import org.distorted.library.effect.Effect; |
29 |
import org.distorted.library.effect.FragmentEffect; |
|
30 | 29 |
import org.distorted.library.effect.PostprocessEffect; |
31 |
import org.distorted.library.effect.VertexEffect; |
|
32 | 30 |
import org.distorted.library.message.EffectMessageSender; |
33 | 31 |
|
34 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
108 | 106 |
// ARM Mali driver r12 has problems when we keep swapping many FBOs (fixed in r22) |
109 | 107 |
// PowerVR GE8100 compiler fails to compile OIT programs. |
110 | 108 |
|
111 |
static void detectBuggyDrivers() |
|
109 |
private static void detectBuggyDrivers()
|
|
112 | 110 |
{ |
113 | 111 |
String vendor = GLES31.glGetString(GLES31.GL_VENDOR); |
114 | 112 |
String version = GLES31.glGetString(GLES31.GL_VERSION); |
... | ... | |
149 | 147 |
|
150 | 148 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
151 | 149 |
/** |
152 |
* When OpenGL context gets created, you need to call this method so that the library can initialise its internal data structures.
|
|
150 |
* When OpenGL context gets created, call this method so that the library can initialise its internal data structures. |
|
153 | 151 |
* I.e. best called from GLSurfaceView.onCreate(). |
154 | 152 |
* <p> |
155 | 153 |
* Needs to be called from a thread holding the OpenGL context. |
src/main/java/org/distorted/library/main/DistortedEffects.java | ||
---|---|---|
415 | 415 |
|
416 | 416 |
void newNode(DistortedNode node) |
417 | 417 |
{ |
418 |
mM.newNode(node); |
|
419 |
mF.newNode(node); |
|
420 |
mV.newNode(node); |
|
421 | 418 |
mP.newNode(node); |
422 | 419 |
} |
423 | 420 |
|
421 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
422 |
|
|
423 |
void removeNode(DistortedNode node) |
|
424 |
{ |
|
425 |
mP.removeNode(node); |
|
426 |
} |
|
427 |
|
|
424 | 428 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
425 | 429 |
|
426 | 430 |
private void displayNormals(MeshBase mesh) |
src/main/java/org/distorted/library/main/DistortedNode.java | ||
---|---|---|
101 | 101 |
mMapNodeID.clear(); |
102 | 102 |
} |
103 | 103 |
|
104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
105 |
|
|
106 |
public void markForDeletion() |
|
107 |
{ |
|
108 |
if( --mData.numPointingNodes==0 ) |
|
109 |
{ |
|
110 |
mMapNodeID.remove(mData.key); |
|
111 |
|
|
112 |
if( mData.mFBO!=null ) |
|
113 |
{ |
|
114 |
mData.mFBO.markForDeletion(); |
|
115 |
mData.mFBO = null; |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
mEffects.removeNode(this); |
|
120 |
} |
|
121 |
|
|
104 | 122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
105 | 123 |
|
106 | 124 |
private ArrayList<Long> generateIDList() |
... | ... | |
656 | 674 |
public void doWork() |
657 | 675 |
{ |
658 | 676 |
int num = mJobs.size(); |
659 |
Job job; |
|
660 |
|
|
661 |
int numChanges=0; |
|
662 | 677 |
|
663 |
for(int i=0; i<num; i++)
|
|
678 |
if( num>0 )
|
|
664 | 679 |
{ |
665 |
job = mJobs.remove(0); |
|
680 |
Job job; |
|
681 |
int numChanges=0; |
|
666 | 682 |
|
667 |
switch(job.type)
|
|
683 |
for(int i=0; i<num; i++)
|
|
668 | 684 |
{ |
669 |
case ATTACH: numChanges++; |
|
670 |
if( mChildren==null ) mChildren = new ArrayList<>(2); |
|
671 |
job.node.mParent = this; |
|
672 |
job.node.mSurfaceParent = null; |
|
673 |
DistortedMaster.addSortingByBuckets(mChildren,job.node); |
|
674 |
mNumChildren[0]++; |
|
675 |
break; |
|
676 |
case DETACH: numChanges++; |
|
677 |
if( mNumChildren[0]>0 && mChildren.remove(job.node) ) |
|
678 |
{ |
|
679 |
job.node.mParent = null; |
|
685 |
job = mJobs.remove(0); |
|
686 |
|
|
687 |
switch(job.type) |
|
688 |
{ |
|
689 |
case ATTACH: numChanges++; |
|
690 |
if( mChildren==null ) mChildren = new ArrayList<>(2); |
|
691 |
job.node.mParent = this; |
|
680 | 692 |
job.node.mSurfaceParent = null; |
681 |
mNumChildren[0]--; |
|
682 |
} |
|
683 |
break; |
|
684 |
case DETALL: numChanges++; |
|
685 |
if( mNumChildren[0]>0 ) |
|
686 |
{ |
|
687 |
DistortedNode tmp; |
|
688 |
|
|
689 |
for(int j=mNumChildren[0]-1; j>=0; j--) |
|
693 |
DistortedMaster.addSortingByBuckets(mChildren,job.node); |
|
694 |
mNumChildren[0]++; |
|
695 |
break; |
|
696 |
case DETACH: numChanges++; |
|
697 |
if( mNumChildren[0]>0 && mChildren.remove(job.node) ) |
|
690 | 698 |
{ |
691 |
tmp = mChildren.remove(j);
|
|
692 |
tmp.mParent = null;
|
|
693 |
tmp.mSurfaceParent = null;
|
|
699 |
job.node.mParent = null;
|
|
700 |
job.node.mSurfaceParent = null;
|
|
701 |
mNumChildren[0]--;
|
|
694 | 702 |
} |
703 |
break; |
|
704 |
case DETALL: numChanges++; |
|
705 |
if( mNumChildren[0]>0 ) |
|
706 |
{ |
|
707 |
DistortedNode tmp; |
|
708 |
|
|
709 |
for(int j=mNumChildren[0]-1; j>=0; j--) |
|
710 |
{ |
|
711 |
tmp = mChildren.remove(j); |
|
712 |
tmp.mParent = null; |
|
713 |
tmp.mSurfaceParent = null; |
|
714 |
} |
|
695 | 715 |
|
696 |
mNumChildren[0] = 0; |
|
697 |
} |
|
698 |
break; |
|
699 |
case SORT : mChildren.remove(job.node); |
|
700 |
DistortedMaster.addSortingByBuckets(mChildren,job.node); |
|
701 |
break; |
|
716 |
mNumChildren[0] = 0; |
|
717 |
} |
|
718 |
break; |
|
719 |
case SORT : mChildren.remove(job.node); |
|
720 |
DistortedMaster.addSortingByBuckets(mChildren,job.node); |
|
721 |
break; |
|
722 |
} |
|
702 | 723 |
} |
724 |
if( numChanges>0 ) adjustIsomorphism(); |
|
703 | 725 |
} |
704 |
|
|
705 |
if( numChanges>0 ) adjustIsomorphism(); |
|
706 | 726 |
} |
707 | 727 |
|
708 | 728 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/library/main/DistortedObject.java | ||
---|---|---|
171 | 171 |
{ |
172 | 172 |
android.util.Log.e("Object", "Done list:"); |
173 | 173 |
|
174 |
DistortedObject object; |
|
175 |
int num = mDoneList.size(); |
|
176 |
|
|
177 |
for(int i=0; i<num; i++) |
|
174 |
for(DistortedObject object : mDoneList) |
|
178 | 175 |
{ |
179 |
object = mDoneList.get(i); |
|
180 | 176 |
object.print(""); |
181 | 177 |
} |
182 | 178 |
|
src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
---|---|---|
1041 | 1041 |
public void doWork() |
1042 | 1042 |
{ |
1043 | 1043 |
int num = mJobs.size(); |
1044 |
Job job; |
|
1045 | 1044 |
|
1046 |
for(int i=0; i<num; i++)
|
|
1045 |
if( num>0 )
|
|
1047 | 1046 |
{ |
1048 |
job = mJobs.remove(0);
|
|
1047 |
Job job;
|
|
1049 | 1048 |
|
1050 |
switch(job.type)
|
|
1049 |
for(int i=0; i<num; i++)
|
|
1051 | 1050 |
{ |
1052 |
case ATTACH: if( mChildren==null ) mChildren = new ArrayList<>(2); |
|
1053 |
job.node.setSurfaceParent(this); |
|
1054 |
DistortedMaster.addSortingByBuckets(mChildren,job.node); |
|
1055 |
mNumChildren++; |
|
1056 |
break; |
|
1057 |
case DETACH: if( mNumChildren>0 && mChildren.remove(job.node) ) |
|
1058 |
{ |
|
1059 |
job.node.setSurfaceParent(null); |
|
1060 |
mNumChildren--; |
|
1061 |
} |
|
1062 |
break; |
|
1063 |
case DETALL: if( mNumChildren>0 ) |
|
1064 |
{ |
|
1065 |
DistortedNode tmp; |
|
1066 |
|
|
1067 |
for(int j=mNumChildren-1; j>=0; j--) |
|
1051 |
job = mJobs.remove(0); |
|
1052 |
|
|
1053 |
switch(job.type) |
|
1054 |
{ |
|
1055 |
case ATTACH: if( mChildren==null ) mChildren = new ArrayList<>(2); |
|
1056 |
job.node.setSurfaceParent(this); |
|
1057 |
DistortedMaster.addSortingByBuckets(mChildren,job.node); |
|
1058 |
mNumChildren++; |
|
1059 |
break; |
|
1060 |
case DETACH: if( mNumChildren>0 && mChildren.remove(job.node) ) |
|
1068 | 1061 |
{ |
1069 |
tmp = mChildren.remove(j);
|
|
1070 |
tmp.setSurfaceParent(null);
|
|
1062 |
job.node.setSurfaceParent(null);
|
|
1063 |
mNumChildren--;
|
|
1071 | 1064 |
} |
1065 |
break; |
|
1066 |
case DETALL: if( mNumChildren>0 ) |
|
1067 |
{ |
|
1068 |
DistortedNode tmp; |
|
1069 |
|
|
1070 |
for(int j=mNumChildren-1; j>=0; j--) |
|
1071 |
{ |
|
1072 |
tmp = mChildren.remove(j); |
|
1073 |
tmp.setSurfaceParent(null); |
|
1074 |
} |
|
1072 | 1075 |
|
1073 |
mNumChildren = 0; |
|
1074 |
} |
|
1075 |
break; |
|
1076 |
case SORT : mChildren.remove(job.node); |
|
1077 |
DistortedMaster.addSortingByBuckets(mChildren,job.node); |
|
1078 |
break; |
|
1076 |
mNumChildren = 0; |
|
1077 |
} |
|
1078 |
break; |
|
1079 |
case SORT : mChildren.remove(job.node); |
|
1080 |
DistortedMaster.addSortingByBuckets(mChildren,job.node); |
|
1081 |
break; |
|
1082 |
} |
|
1079 | 1083 |
} |
1080 | 1084 |
} |
1081 | 1085 |
} |
src/main/java/org/distorted/library/main/EffectQueue.java | ||
---|---|---|
148 | 148 |
mNodes.add(node); |
149 | 149 |
} |
150 | 150 |
|
151 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
152 |
|
|
153 |
void removeNode(DistortedNode node) |
|
154 |
{ |
|
155 |
mNodes.remove(node); |
|
156 |
} |
|
157 |
|
|
151 | 158 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
152 | 159 |
|
153 | 160 |
@SuppressWarnings("unused") |
Also available in: Unified diff
Fixes for memory leak problems uncovered by the 'Rubik' app. (mainly: new method DistortedNode.markForDeletion)