Revision be60d4ff
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/library/DistortedNode.java | ||
---|---|---|
63 | 63 |
private static long mNextNodeID =0; |
64 | 64 |
|
65 | 65 |
private DistortedNode mParent; |
66 |
private DistortedOutputSurface mSurfaceParent; |
|
66 | 67 |
private MeshObject mMesh; |
67 | 68 |
private DistortedEffects mEffects; |
68 | 69 |
private DistortedEffectsPostprocess mPostprocess; |
... | ... | |
261 | 262 |
return numRenders; |
262 | 263 |
} |
263 | 264 |
|
265 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
266 |
|
|
267 |
private void newJob(int t, DistortedNode n, DistortedEffectsPostprocess d) |
|
268 |
{ |
|
269 |
mJobs.add(new Job(t,n,d)); |
|
270 |
} |
|
271 |
|
|
272 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
273 |
|
|
274 |
void setPost(DistortedEffectsPostprocess dep) |
|
275 |
{ |
|
276 |
mPostprocess = dep; |
|
277 |
} |
|
278 |
|
|
279 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
280 |
|
|
281 |
void setSurfaceParent(DistortedOutputSurface dep) |
|
282 |
{ |
|
283 |
mSurfaceParent = dep; |
|
284 |
mParent = null; |
|
285 |
} |
|
286 |
|
|
264 | 287 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
265 | 288 |
// PUBLIC API |
266 | 289 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
282 | 305 |
mNumChildren = new int[1]; |
283 | 306 |
mNumChildren[0]= 0; |
284 | 307 |
mParent = null; |
308 |
mSurfaceParent = null; |
|
285 | 309 |
|
286 | 310 |
ArrayList<Long> list = new ArrayList<>(); |
287 | 311 |
list.add(mSurface.getID()); |
... | ... | |
312 | 336 |
*/ |
313 | 337 |
public DistortedNode(DistortedNode node, int flags) |
314 | 338 |
{ |
315 |
mEffects = new DistortedEffects(node.mEffects,flags); |
|
316 |
mPostprocess = null; |
|
317 |
mMesh = node.mMesh; |
|
318 |
mState = new DistortedRenderState(); |
|
319 |
mParent = null; |
|
339 |
mEffects = new DistortedEffects(node.mEffects,flags); |
|
340 |
mPostprocess = null; |
|
341 |
mMesh = node.mMesh; |
|
342 |
mState = new DistortedRenderState(); |
|
343 |
mParent = null; |
|
344 |
mSurfaceParent= null; |
|
320 | 345 |
|
321 | 346 |
if( (flags & Distorted.CLONE_SURFACE) != 0 ) |
322 | 347 |
{ |
... | ... | |
497 | 522 |
Job job; |
498 | 523 |
|
499 | 524 |
int numChanges=0; |
500 |
int numSorts =0; |
|
501 | 525 |
|
502 | 526 |
for(int i=0; i<num; i++) |
503 | 527 |
{ |
... | ... | |
508 | 532 |
case ATTACH: numChanges++; |
509 | 533 |
if( mChildren==null ) mChildren = new ArrayList<>(2); |
510 | 534 |
job.node.mParent = this; |
511 |
mChildren.add(job.node); |
|
535 |
job.node.mSurfaceParent = null; |
|
536 |
DistortedMaster.addSorted(mChildren,job.node); |
|
512 | 537 |
mNumChildren[0]++; |
513 | 538 |
break; |
514 | 539 |
case DETACH: numChanges++; |
515 | 540 |
if( mNumChildren[0]>0 && mChildren.remove(job.node) ) |
516 | 541 |
{ |
517 | 542 |
job.node.mParent = null; |
543 |
job.node.mSurfaceParent = null; |
|
518 | 544 |
mNumChildren[0]--; |
519 | 545 |
} |
520 | 546 |
break; |
... | ... | |
527 | 553 |
{ |
528 | 554 |
tmp = mChildren.remove(j); |
529 | 555 |
tmp.mParent = null; |
556 |
tmp.mSurfaceParent = null; |
|
530 | 557 |
} |
531 | 558 |
|
532 | 559 |
mNumChildren[0] = 0; |
533 | 560 |
} |
534 | 561 |
break; |
535 |
case SORT : numSorts++; |
|
536 |
// TODO: sort |
|
562 |
case SORT : job.node.mPostprocess = job.dep; |
|
563 |
mChildren.remove(job.node); |
|
564 |
DistortedMaster.addSorted(mChildren,job.node); |
|
537 | 565 |
break; |
538 | 566 |
} |
539 | 567 |
} |
540 | 568 |
|
541 |
if( numChanges>0 ) |
|
542 |
{ |
|
543 |
adjustIsomorphism(); |
|
544 |
|
|
545 |
if( numSorts==0 ) |
|
546 |
{ |
|
547 |
// TODO: sort |
|
548 |
} |
|
549 |
} |
|
569 |
if( numChanges>0 ) adjustIsomorphism(); |
|
550 | 570 |
} |
551 | 571 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
552 | 572 |
/** |
... | ... | |
561 | 581 |
*/ |
562 | 582 |
public void setPostprocessEffects(DistortedEffectsPostprocess dep) |
563 | 583 |
{ |
564 |
mPostprocess = dep; |
|
565 |
|
|
566 |
// TODO: rearrange all the siblings so that all are sorted by the DistortedEffectsPostprocess' ID. |
|
584 |
if( mParent!=null ) |
|
585 |
{ |
|
586 |
mParent.newJob(SORT, this, dep); |
|
587 |
DistortedMaster.newSlave(mParent); |
|
588 |
} |
|
589 |
else if( mSurfaceParent!=null ) |
|
590 |
{ |
|
591 |
mSurfaceParent.newJob(SORT, this, dep); |
|
592 |
DistortedMaster.newSlave(mSurfaceParent); |
|
593 |
} |
|
594 |
else |
|
595 |
{ |
|
596 |
mPostprocess = dep; |
|
597 |
} |
|
567 | 598 |
} |
568 | 599 |
|
569 | 600 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Children now properly sorted into Postprocessing Buckets.