Revision 07d8ef09
Added by Leszek Koltunski about 8 years ago
src/main/java/org/distorted/library/DistortedTree.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
28 | 28 |
/** |
29 |
* Class which represents a Node in a Tree of (Texture,EffectQueue,Grid) set.
|
|
29 |
* Class which represents a Node in a Tree of (Texture,Grid,Effects) objects.
|
|
30 | 30 |
* |
31 | 31 |
* Having organized such sets into a Tree, we can then render any Node to any Framebuffer. |
32 | 32 |
* That recursively renders the set held in the Node and all its children. |
... | ... | |
37 | 37 |
private static long mNextNodeID =0; |
38 | 38 |
|
39 | 39 |
private GridObject mGrid; |
40 |
private DistortedEffects mQueues;
|
|
40 |
private DistortedEffects mEffects;
|
|
41 | 41 |
private DistortedTexture mTexture; |
42 | 42 |
private NodeData mData; |
43 | 43 |
|
... | ... | |
224 | 224 |
if( mTexture.mBitmapSet[0] ) |
225 | 225 |
{ |
226 | 226 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]); |
227 |
mQueues.drawNoEffectsPriv(mTexture, mGrid, mData.mDF);
|
|
227 |
mEffects.drawNoEffectsPriv(mTexture, mGrid, mData.mDF);
|
|
228 | 228 |
} |
229 | 229 |
|
230 | 230 |
synchronized(this) |
... | ... | |
243 | 243 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mData.mDF.texIds[0]); |
244 | 244 |
} |
245 | 245 |
|
246 |
mQueues.drawPriv(currTime, mTexture, mGrid, df);
|
|
246 |
mEffects.drawPriv(currTime, mTexture, mGrid, df);
|
|
247 | 247 |
} |
248 | 248 |
|
249 | 249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
253 | 253 |
* Constructs new Node of the Tree. |
254 | 254 |
* |
255 | 255 |
* @param texture DistortedTexture to put into the new Node. |
256 |
* @param queues DistortedEffects to put into the new Node.
|
|
256 |
* @param effects DistortedEffects to put into the new Node.
|
|
257 | 257 |
* @param grid GridObject to put into the new Node. |
258 | 258 |
*/ |
259 |
public DistortedTree(DistortedTexture texture, DistortedEffects queues, GridObject grid)
|
|
259 |
public DistortedTree(DistortedTexture texture, DistortedEffects effects, GridObject grid)
|
|
260 | 260 |
{ |
261 | 261 |
mTexture= texture; |
262 |
mQueues = queues;
|
|
262 |
mEffects= effects;
|
|
263 | 263 |
mGrid = grid; |
264 | 264 |
mParent = null; |
265 | 265 |
mChildren = null; |
... | ... | |
296 | 296 |
{ |
297 | 297 |
mParent = null; |
298 | 298 |
mTexture= new DistortedTexture(node.mTexture,flags); |
299 |
mQueues = new DistortedEffects(node.mQueues, flags);
|
|
299 |
mEffects = new DistortedEffects(node.mEffects, flags);
|
|
300 | 300 |
mGrid = node.mGrid; |
301 | 301 |
|
302 | 302 |
if( (flags & Distorted.CLONE_CHILDREN) != 0 ) |
... | ... | |
350 | 350 |
* Adds a new child to the last position in the list of our Node's children. |
351 | 351 |
* |
352 | 352 |
* @param texture DistortedTexture to initialize our child Node with. |
353 |
* @param queues DistortedEffects to initialize our child Node with.
|
|
353 |
* @param effects DistortedEffects to initialize our child Node with.
|
|
354 | 354 |
* @param grid GridObject to initialize our child Node with. |
355 | 355 |
* @return the newly constructed child Node, or null if we couldn't allocate resources. |
356 | 356 |
*/ |
357 |
public synchronized DistortedTree attach(DistortedTexture texture, DistortedEffects queues, GridObject grid)
|
|
357 |
public synchronized DistortedTree attach(DistortedTexture texture, DistortedEffects effects, GridObject grid)
|
|
358 | 358 |
{ |
359 | 359 |
ArrayList<Long> prev = generateIDList(); |
360 | 360 |
|
361 | 361 |
if( mChildren==null ) mChildren = new ArrayList<>(2); |
362 |
DistortedTree node = new DistortedTree(texture,queues,grid);
|
|
362 |
DistortedTree node = new DistortedTree(texture,effects,grid);
|
|
363 | 363 |
node.mParent = this; |
364 | 364 |
mChildren.add(node); |
365 | 365 |
mNumChildren[0]++; |
... | ... | |
400 | 400 |
/** |
401 | 401 |
* Removes the first occurrence of a specified child from the list of children of our Node. |
402 | 402 |
* |
403 |
* @param queues DistortedEffects to remove.
|
|
403 |
* @param effects DistortedEffects to remove.
|
|
404 | 404 |
* @return <code>true</code> if the child was successfully removed. |
405 | 405 |
*/ |
406 |
public synchronized boolean detach(DistortedEffects queues)
|
|
406 |
public synchronized boolean detach(DistortedEffects effects)
|
|
407 | 407 |
{ |
408 |
long id = queues.getID();
|
|
408 |
long id = effects.getID();
|
|
409 | 409 |
DistortedTree node; |
410 | 410 |
|
411 | 411 |
for(int i=0; i<mNumChildren[0]; i++) |
412 | 412 |
{ |
413 | 413 |
node = mChildren.get(i); |
414 | 414 |
|
415 |
if( node.mQueues.getID()==id )
|
|
415 |
if( node.mEffects.getID()==id )
|
|
416 | 416 |
{ |
417 | 417 |
ArrayList<Long> prev = generateIDList(); |
418 | 418 |
|
... | ... | |
458 | 458 |
*/ |
459 | 459 |
public DistortedEffects getEffects() |
460 | 460 |
{ |
461 |
return mQueues;
|
|
461 |
return mEffects;
|
|
462 | 462 |
} |
463 | 463 |
|
464 | 464 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
472 | 472 |
return mTexture; |
473 | 473 |
} |
474 | 474 |
|
475 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
476 | 475 |
} |
477 | 476 |
|
Also available in: Unified diff
Cleanup.