Revision a09ada4c
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/library/DistortedOutputSurface.java | ||
---|---|---|
20 | 20 |
package org.distorted.library; |
21 | 21 |
|
22 | 22 |
import android.opengl.Matrix; |
23 |
import java.util.ArrayList; |
|
23 | 24 |
|
24 | 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
25 | 26 |
|
26 | 27 |
abstract class DistortedOutputSurface extends DistortedSurface |
27 | 28 |
{ |
29 |
private ArrayList<DistortedNode> mChildren; |
|
30 |
private int mNumChildren; // ==mChildren.length(), but we only create mChildren if the first one gets added |
|
31 |
|
|
28 | 32 |
private float mX, mY, mFOV; |
29 | 33 |
int mWidth,mHeight,mDepth; |
30 | 34 |
float mDistance; |
... | ... | |
114 | 118 |
* <p> |
115 | 119 |
* Must be called from a thread holding OpenGL Context. |
116 | 120 |
* |
117 |
* @param dt DistortedTree to render.
|
|
121 |
* @param dt DistortedNode to render.
|
|
118 | 122 |
* @param time Current time, in milliseconds. This will be passed to all the Effects stored in the Tree. |
119 | 123 |
*/ |
120 |
public void renderTo(DistortedTree dt, long time)
|
|
124 |
public void renderTo(DistortedNode dt, long time)
|
|
121 | 125 |
{ |
122 | 126 |
DistortedSurface.deleteAllMarked(); |
123 | 127 |
create(); |
... | ... | |
166 | 170 |
if( mColorH[0]>0 ) markForDeletion(); |
167 | 171 |
} |
168 | 172 |
} |
173 |
|
|
174 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
175 |
/** |
|
176 |
* Adds a new child to the last position in the list of our Surface's children. |
|
177 |
* |
|
178 |
* @param node The new Node to add. |
|
179 |
*/ |
|
180 |
public synchronized void attach(DistortedNode node) |
|
181 |
{ |
|
182 |
if( mChildren==null ) mChildren = new ArrayList<>(2); |
|
183 |
mChildren.add(node); |
|
184 |
mNumChildren++; |
|
185 |
} |
|
186 |
|
|
187 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
188 |
/** |
|
189 |
* Adds a new child to the last position in the list of our Surface's children. |
|
190 |
* |
|
191 |
* @param surface InputSurface to initialize our child Node with. |
|
192 |
* @param effects DistortedEffects to initialize our child Node with. |
|
193 |
* @param mesh MeshObject to initialize our child Node with. |
|
194 |
* @return the newly constructed child Node, or null if we couldn't allocate resources. |
|
195 |
*/ |
|
196 |
public synchronized DistortedNode attach(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh) |
|
197 |
{ |
|
198 |
if( mChildren==null ) mChildren = new ArrayList<>(2); |
|
199 |
DistortedNode node = new DistortedNode(surface,effects,mesh); |
|
200 |
mChildren.add(node); |
|
201 |
mNumChildren++; |
|
202 |
|
|
203 |
return node; |
|
204 |
} |
|
205 |
|
|
206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
207 |
/** |
|
208 |
* Removes the first occurrence of a specified child from the list of children of our Surface. |
|
209 |
* |
|
210 |
* @param node The Node to remove. |
|
211 |
* @return <code>true</code> if the child was successfully removed. |
|
212 |
*/ |
|
213 |
public synchronized boolean detach(DistortedNode node) |
|
214 |
{ |
|
215 |
if( mChildren.remove(node) ) |
|
216 |
{ |
|
217 |
mNumChildren--; |
|
218 |
return true; |
|
219 |
} |
|
220 |
|
|
221 |
return false; |
|
222 |
} |
|
223 |
|
|
224 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
225 |
/** |
|
226 |
* Removes all children Nodes. |
|
227 |
*/ |
|
228 |
public synchronized void detachAll() |
|
229 |
{ |
|
230 |
mNumChildren = 0; |
|
231 |
mChildren.clear(); |
|
232 |
} |
|
169 | 233 |
} |
Also available in: Unified diff
Preparation for change of the render API.