Project

General

Profile

Download (17.7 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / DistortedOutputSurface.java @ 6e7c8721

1 c5369f1b leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.library;
21
22 a436ccc5 leszek
import android.opengl.GLES30;
23 af4cc5db Leszek Koltunski
import android.opengl.Matrix;
24 a09ada4c Leszek Koltunski
import java.util.ArrayList;
25 af4cc5db Leszek Koltunski
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27
28 efe3d8fe leszek
abstract class DistortedOutputSurface extends DistortedSurface implements DistortedSlave
29 af4cc5db Leszek Koltunski
{
30 efe3d8fe leszek
  private static final int ATTACH = 0;
31
  private static final int DETACH = 1;
32
  private static final int DETALL = 2;
33
  private static final int SORT   = 3;
34
35 a09ada4c Leszek Koltunski
  private ArrayList<DistortedNode> mChildren;
36
  private int mNumChildren;   // ==mChildren.length(), but we only create mChildren if the first one gets added
37
38 efe3d8fe leszek
  private class Job
39
    {
40
    int type;
41
    DistortedNode node;
42 be60d4ff leszek
    DistortedEffectsPostprocess dep;
43 efe3d8fe leszek
44 be60d4ff leszek
    Job(int t, DistortedNode n, DistortedEffectsPostprocess d)
45 efe3d8fe leszek
      {
46
      type = t;
47
      node = n;
48 be60d4ff leszek
      dep  = d;
49 efe3d8fe leszek
      }
50
    }
51
52
  private ArrayList<Job> mJobs = new ArrayList<>();
53
54 b7dba709 Leszek Koltunski
  DistortedFramebuffer mBuffer1, mBuffer2;
55 60c1c622 leszek
56 95c441a2 leszek
  private long mTime;
57 c2c08950 leszek
  private float mFOV;
58
  float mDistance, mNear;
59 af4cc5db Leszek Koltunski
  float[] mProjectionMatrix;
60
61 c7da4e65 leszek
  int mDepthCreated;
62 a436ccc5 leszek
  int[] mDepthH = new int[1];
63
  int[] mFBOH   = new int[1];
64
65 a9f41fa3 leszek
  private float mClearR, mClearG, mClearB, mClearA;
66
  private float mClearDepth;
67 0afc143a leszek
68
//private String sNew="", sOld="";
69
70 af4cc5db Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
71
72 09ab7524 Leszek Koltunski
  DistortedOutputSurface(int width, int height, int createColor, int createDepth, int fbo, int type)
73 af4cc5db Leszek Koltunski
    {
74 09ab7524 Leszek Koltunski
    super(width,height,createColor,type);
75 af4cc5db Leszek Koltunski
76
    mProjectionMatrix = new float[16];
77
78
    mWidth = width;
79
    mHeight= height;
80
81
    mFOV = 60.0f;
82 54fe333a leszek
    mNear=  0.5f;
83 af4cc5db Leszek Koltunski
84 c7da4e65 leszek
    mDepthCreated= createDepth;
85 a436ccc5 leszek
    mFBOH[0]     = fbo;
86 c7da4e65 leszek
    mDepthH[0]   = 0;
87 a436ccc5 leszek
88 95c441a2 leszek
    mTime = 0;
89
90 a9f41fa3 leszek
    mClearR = 0.0f;
91
    mClearG = 0.0f;
92
    mClearB = 0.0f;
93
    mClearA = 0.0f;
94
95
    mClearDepth = 1.0f;
96
97 af4cc5db Leszek Koltunski
    createProjection();
98
    }
99
100 c5369f1b leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
101
102 be60d4ff leszek
  private void createProjection()
103 af4cc5db Leszek Koltunski
    {
104
    if( mWidth>0 && mHeight>1 )
105
      {
106
      if( mFOV>0.0f )  // perspective projection
107
        {
108 54fe333a leszek
        float a = 2.0f*(float)Math.tan(mFOV*Math.PI/360);
109 c2c08950 leszek
        float q = mWidth*mNear;
110 54fe333a leszek
        float c = mHeight*mNear;
111
112 c2c08950 leszek
        float left   = -q/2;
113
        float right  = +q/2;
114
        float bottom = -c/2;
115
        float top    = +c/2;
116
        float near   =  c/a;
117 54fe333a leszek
118
        mDistance    = mHeight/a;
119 af4cc5db Leszek Koltunski
        float far    = 2*mDistance-near;
120
121
        Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
122
        }
123
      else             // parallel projection
124
        {
125 54fe333a leszek
        float left   = -mWidth /2.0f;
126
        float right  = +mWidth /2.0f;
127
        float bottom = -mHeight/2.0f;
128
        float top    = +mHeight/2.0f;
129
        float near   = mWidth+mHeight-mHeight*(1.0f-mNear);
130
        mDistance    = mWidth+mHeight;
131
        float far    = mWidth+mHeight+mHeight*(1.0f-mNear);
132 af4cc5db Leszek Koltunski
133
        Matrix.orthoM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
134
        }
135
      }
136
    }
137
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139 e02264ff leszek
// Render all children, one by one. If there are no postprocessing effects, just render to THIS.
140
// Otherwise, render to a buffer and on each change of Postprocessing Bucket, apply the postprocessing
141
// to a whole buffer and merge it.
142 39086ebb leszek
143 b2939df4 Leszek Koltunski
  int renderChildren(long time, int num, ArrayList<DistortedNode> children)
144
    {
145
    int numRenders = 0;
146 b9798977 leszek
    DistortedNode child;
147 27f42cd6 leszek
    DistortedEffectsPostprocess lastP=null, currP;
148 e137d4f5 Leszek Koltunski
    long lastB=0, currB;
149 0afc143a leszek
150
//sNew = "";
151
152 b2939df4 Leszek Koltunski
    for(int i=0; i<num; i++)
153 39086ebb leszek
      {
154 b9798977 leszek
      child = children.get(i);
155 27f42cd6 leszek
      currP = child.getEffectsPostprocess();
156 13687207 leszek
      currB = currP==null ? 0 : currP.getBucket();
157 0afc143a leszek
158
//sNew += currB;
159
160 13687207 leszek
      if( lastB!=currB && lastB!=0 )
161
        {
162
        numRenders += lastP.postprocess(time,this);
163
        }
164 b9798977 leszek
165 13687207 leszek
      if( currB==0 )
166
        {
167
        numRenders += child.draw(time,this);
168
        }
169 60c1c622 leszek
      else
170
        {
171 b7dba709 Leszek Koltunski
        if( mBuffer1==null )
172 60c1c622 leszek
          {
173 b7dba709 Leszek Koltunski
          mBuffer1 = new DistortedFramebuffer(mDepthCreated!=DONT_CREATE, DistortedSurface.TYPE_SYST, mWidth, mHeight);
174
          mBuffer2 = new DistortedFramebuffer(false                     , DistortedSurface.TYPE_SYST, mWidth, mHeight);
175 893e008d leszek
          DistortedSurface.toDo();  // create immediately
176 60c1c622 leszek
          }
177 b9798977 leszek
178 b7dba709 Leszek Koltunski
        numRenders += child.draw(time,mBuffer1);
179 13687207 leszek
        if( i==num-1 )
180
          {
181
          numRenders += currP.postprocess(time,this);
182
          }
183 60c1c622 leszek
        }
184 b9798977 leszek
185 60c1c622 leszek
      lastP = currP;
186
      lastB = currB;
187 95c441a2 leszek
      }
188 be60d4ff leszek
/*
189
if( !sNew.equals(sOld) )
190
  {
191
  sOld = sNew;
192
  android.util.Log.e("surface", "Surface"+getID()+": "+sOld);
193
  }
194
*/
195 39086ebb leszek
    return numRenders;
196
    }
197
198 be60d4ff leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
199
200
  void newJob(int t, DistortedNode n, DistortedEffectsPostprocess d)
201
    {
202
    mJobs.add(new Job(t,n,d));
203
    }
204
205 b2939df4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
206
// PUBLIC API
207 39086ebb leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
208 c5369f1b leszek
/**
209 d9706fd2 Leszek Koltunski
 * Draws all the attached children to this OutputSurface.
210 af4cc5db Leszek Koltunski
 * <p>
211
 * Must be called from a thread holding OpenGL Context.
212
 *
213 d9706fd2 Leszek Koltunski
 * @param time Current time, in milliseconds. This will be passed to all the Effects stored in the children Nodes.
214 7691a39f leszek
 * @return Number of objects rendered.
215 c5369f1b leszek
 */
216 b2939df4 Leszek Koltunski
  public int render(long time)
217 af4cc5db Leszek Koltunski
    {
218 c204c69d leszek
    // change tree topology (attach and detach children)
219 889cce10 Leszek Koltunski
/*
220
    boolean changed =
221
*/
222 efe3d8fe leszek
    DistortedMaster.toDo();
223 eadf0859 leszek
/*
224 f28fffc2 Leszek Koltunski
    // debugging only
225 af27df87 leszek
    if( changed )
226 c204c69d leszek
      {
227
      for(int i=0; i<mNumChildren; i++)
228
        {
229 af27df87 leszek
        mChildren.get(i).debug(0);
230 c204c69d leszek
        }
231 af27df87 leszek
232 7691a39f leszek
      DistortedNode.debugMap();
233 c204c69d leszek
      }
234 eadf0859 leszek
*/
235 09ab7524 Leszek Koltunski
    // create and delete all underlying OpenGL resources
236
    // Watch out: FIRST change topology, only then deal
237
    // with OpenGL resources. That's because changing Tree
238
    // can result in additional Framebuffers that would need
239
    // to be created immediately, before the calls to drawRecursive()
240 f8377ef8 leszek
    toDo();
241 eadf0859 leszek
/*
242 f28fffc2 Leszek Koltunski
    // debugging only
243 af27df87 leszek
    if( changed )
244
      {
245
      DistortedSurface.debugLists();
246
      }
247 eadf0859 leszek
*/
248 c834348d leszek
    // mark OpenGL state as unknown
249
    DistortedRenderState.reset();
250 2ed1c692 leszek
251 b2939df4 Leszek Koltunski
    int numRenders=0;
252 7691a39f leszek
253 d9706fd2 Leszek Koltunski
    for(int i=0; i<mNumChildren; i++)
254 af4cc5db Leszek Koltunski
      {
255 b2939df4 Leszek Koltunski
      numRenders += mChildren.get(i).renderRecursive(time);
256 af4cc5db Leszek Koltunski
      }
257 7691a39f leszek
258 95c441a2 leszek
    setAsOutput(time);
259 b2939df4 Leszek Koltunski
    numRenders += renderChildren(time,mNumChildren,mChildren);
260
261 7691a39f leszek
    return numRenders;
262 af4cc5db Leszek Koltunski
    }
263
264
///////////////////////////////////////////////////////////////////////////////////////////////////
265 c5369f1b leszek
/**
266
 * Bind this Surface as a Framebuffer we can render to.
267 02ab6f9d leszek
 *
268
 * @param time Present time, in milliseconds. The point: looking at this param the library can figure
269
 *             out if this is the first time during present frame that this FBO is being set as output.
270
 *             If so, the library, in addition to binding the Surface for output, also clears the
271
 *             Surface's color and depth attachments.
272 c5369f1b leszek
 */
273 95c441a2 leszek
  public void setAsOutput(long time)
274 a436ccc5 leszek
    {
275
    GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]);
276 95c441a2 leszek
277
    if( mTime!=time )
278
      {
279
      mTime = time;
280
      DistortedRenderState.colorDepthOn();
281 a9f41fa3 leszek
      GLES30.glClearColor(mClearR, mClearG, mClearB, mClearA);
282
      GLES30.glClearDepthf(mClearDepth);
283 95c441a2 leszek
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
284
      }
285 a436ccc5 leszek
    }
286 af4cc5db Leszek Koltunski
287 a9f41fa3 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
288
/**
289
 * Set the (R,G,B,A) values of GLES30.glClearColor() to set up color with which to clear
290
 * this Surface before each render.
291
 *
292
 * @param r the Red component. Default: 0.0f
293
 * @param g the Green component. Default: 0.0f
294
 * @param b the Blue component. Default: 0.0f
295
 * @param a the Alpha component. Default: 0.0f
296
 */
297
  public void glClearColor(float r, float g, float b, float a)
298
    {
299
    mClearR = r;
300
    mClearG = g;
301
    mClearB = b;
302
    mClearA = a;
303
    }
304
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306
/**
307
 * Set the Depth value of GLES30.glClearDepthf() to set up depth with which to clear
308
 * the Depth buffer of Surface before each render.
309
 *
310
 * @param d the Depth. Default: 1.0f
311
 */
312
  public void glClearDepthf(float d)
313
    {
314
    mClearDepth = d;
315
    }
316
317 af4cc5db Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
318
/**
319
 * Create new Projection matrix.
320
 *
321
 * @param fov Vertical 'field of view' of the Projection frustrum (in degrees).
322 54fe333a leszek
 *            Valid values: 0<=fov<180. FOV==0 means 'parallel projection'.
323
 * @param near Distance between the screen plane and the near plane.
324
 *             Valid vaules: 0<near<1. When near==0, the Near Plane is exactly at the tip of the
325
 *             pyramid. When near==1 (illegal!) the near plane is equivalent to the screen plane.
326 af4cc5db Leszek Koltunski
 */
327 54fe333a leszek
  public void setProjection(float fov, float near)
328 af4cc5db Leszek Koltunski
    {
329 8069e806 Leszek Koltunski
    if( fov < 180.0f && fov >=0.0f )
330
      {
331
      mFOV = fov;
332
      }
333
334
    if( near<   1.0f && near> 0.0f )
335
      {
336
      mNear= near;
337
      }
338
    else if( near<=0.0f )
339
      {
340
      mNear = 0.01f;
341
      }
342
    else if( near>=1.0f )
343
      {
344
      mNear=0.99f;
345
      }
346 af4cc5db Leszek Koltunski
347
    createProjection();
348
    }
349
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351 c5369f1b leszek
/**
352 af4cc5db Leszek Koltunski
 * Resize the underlying Framebuffer.
353 c7da4e65 leszek
 * <p>
354
 * This method can be safely called mid-render as it doesn't interfere with rendering.
355 af4cc5db Leszek Koltunski
 *
356
 * @param width The new width.
357
 * @param height The new height.
358 c5369f1b leszek
 */
359 af4cc5db Leszek Koltunski
  public void resize(int width, int height)
360
    {
361
    if( mWidth!=width || mHeight!=height )
362
      {
363
      mWidth = width;
364
      mHeight= height;
365 f8377ef8 leszek
366
      createProjection();
367
368 c7da4e65 leszek
      if( mColorCreated==CREATED )
369 f8377ef8 leszek
        {
370 f28fffc2 Leszek Koltunski
        markForCreation();
371 f8377ef8 leszek
        recreate();
372
        }
373 af4cc5db Leszek Koltunski
      }
374
    }
375 a09ada4c Leszek Koltunski
376 a436ccc5 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
377
/**
378
 * Create a new DEPTH buffer and attach it or (param=false) detach an existing DEPTH attachment and recreate it.
379
 *
380
 * @param enable <bold>true</bold> if we want to attach a new DEPTH buffer to the FBO.<br>
381
 *               <bold>false</bold> if we want to detach the DEPTH attachment.
382
 */
383
  public void enableDepth(boolean enable)
384
    {
385 c7da4e65 leszek
    if( enable && mDepthCreated==DONT_CREATE )
386
      {
387
      mDepthCreated = NOT_CREATED_YET;
388 f28fffc2 Leszek Koltunski
      markForCreation();
389 c7da4e65 leszek
      }
390
    if( !enable && mDepthCreated!=DONT_CREATE )
391 a436ccc5 leszek
      {
392 c7da4e65 leszek
      mDepthCreated = DONT_CREATE;
393 f28fffc2 Leszek Koltunski
      markForCreation();
394 a436ccc5 leszek
      }
395
    }
396
397
///////////////////////////////////////////////////////////////////////////////////////////////////
398
/**
399
 * Return true if the Surface contains a DEPTH attachment.
400
 *
401
 * @return <bold>true</bold> if the FBO contains a DEPTH attachment.
402
 */
403
  public boolean hasDepth()
404
    {
405 c7da4e65 leszek
    return mDepthCreated==CREATED;
406 a436ccc5 leszek
    }
407
408 a09ada4c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
409
/**
410
 * Adds a new child to the last position in the list of our Surface's children.
411 c204c69d leszek
 * <p>
412
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
413 efe3d8fe leszek
 * DistortedMaster (by calling doWork())
414 a09ada4c Leszek Koltunski
 *
415
 * @param node The new Node to add.
416
 */
417 c204c69d leszek
  public void attach(DistortedNode node)
418 a09ada4c Leszek Koltunski
    {
419 be60d4ff leszek
    mJobs.add(new Job(ATTACH,node,null));
420 efe3d8fe leszek
    DistortedMaster.newSlave(this);
421 a09ada4c Leszek Koltunski
    }
422
423
///////////////////////////////////////////////////////////////////////////////////////////////////
424
/**
425
 * Adds a new child to the last position in the list of our Surface's children.
426 c204c69d leszek
 * <p>
427
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
428 efe3d8fe leszek
 * DistortedMaster (by calling doWork())
429 a09ada4c Leszek Koltunski
 *
430
 * @param surface InputSurface to initialize our child Node with.
431
 * @param effects DistortedEffects to initialize our child Node with.
432
 * @param mesh MeshObject to initialize our child Node with.
433
 * @return the newly constructed child Node, or null if we couldn't allocate resources.
434
 */
435 c204c69d leszek
  public DistortedNode attach(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh)
436 a09ada4c Leszek Koltunski
    {
437
    DistortedNode node = new DistortedNode(surface,effects,mesh);
438 be60d4ff leszek
    mJobs.add(new Job(ATTACH,node,null));
439 efe3d8fe leszek
    DistortedMaster.newSlave(this);
440 c204c69d leszek
    return node;
441
    }
442
443 af27df87 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
444
/**
445
 * Removes the first occurrence of a specified child from the list of children of our Surface.
446
 * <p>
447
 * A bit questionable method as there can be many different Nodes attached as children, some
448
 * of them having the same Effects but - for instance - different Mesh. Use with care.
449
 * <p>
450
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
451 efe3d8fe leszek
 * DistortedMaster (by calling doWork())
452 af27df87 leszek
 *
453
 * @param effects DistortedEffects to remove.
454
 */
455
  public void detach(DistortedEffects effects)
456
    {
457
    long id = effects.getID();
458
    DistortedNode node;
459 8baa1fe6 Leszek Koltunski
    boolean detached = false;
460 af27df87 leszek
461
    for(int i=0; i<mNumChildren; i++)
462
      {
463
      node = mChildren.get(i);
464
465
      if( node.getEffects().getID()==id )
466
        {
467 8baa1fe6 Leszek Koltunski
        detached = true;
468 be60d4ff leszek
        mJobs.add(new Job(DETACH,node,null));
469 efe3d8fe leszek
        DistortedMaster.newSlave(this);
470 af27df87 leszek
        break;
471
        }
472
      }
473 8baa1fe6 Leszek Koltunski
474
    if( !detached )
475
      {
476
      // if we failed to detach any, it still might be the case that
477 efe3d8fe leszek
      // there's an ATTACH job that we need to cancel.
478
      int num = mJobs.size();
479
      Job job;
480
481
      for(int i=0; i<num; i++)
482
        {
483
        job = mJobs.get(i);
484
485
        if( job.type==ATTACH && job.node.getEffects()==effects )
486
          {
487
          mJobs.remove(i);
488
          break;
489
          }
490
        }
491 8baa1fe6 Leszek Koltunski
      }
492 af27df87 leszek
    }
493
494 a09ada4c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
495
/**
496
 * Removes the first occurrence of a specified child from the list of children of our Surface.
497 c204c69d leszek
 * <p>
498
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
499 efe3d8fe leszek
 * DistortedMaster (by calling doWork())
500 c204c69d leszek
 *
501
 * @param node The Node to remove.
502
 */
503
  public void detach(DistortedNode node)
504
    {
505 be60d4ff leszek
    mJobs.add(new Job(DETACH,node,null));
506 efe3d8fe leszek
    DistortedMaster.newSlave(this);
507 a09ada4c Leszek Koltunski
    }
508
509
///////////////////////////////////////////////////////////////////////////////////////////////////
510
/**
511
 * Removes all children Nodes.
512 c204c69d leszek
 * <p>
513
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
514 efe3d8fe leszek
 * DistortedMaster (by calling doWork())
515 c204c69d leszek
 */
516
  public void detachAll()
517
    {
518 be60d4ff leszek
    mJobs.add(new Job(DETALL,null,null));
519 efe3d8fe leszek
    DistortedMaster.newSlave(this);
520 c204c69d leszek
    }
521
522
///////////////////////////////////////////////////////////////////////////////////////////////////
523
/**
524
 * This is not really part of the public API. Has to be public only because it is a part of the
525 efe3d8fe leszek
 * DistortedSlave interface, which should really be a class that we extend here instead but
526 c204c69d leszek
 * Java has no multiple inheritance.
527 43fbf0dd leszek
 *
528
 * @y.exclude
529 a09ada4c Leszek Koltunski
 */
530 efe3d8fe leszek
  public void doWork()
531 a09ada4c Leszek Koltunski
    {
532 efe3d8fe leszek
    int num = mJobs.size();
533
    Job job;
534
535
    for(int i=0; i<num; i++)
536
      {
537
      job = mJobs.remove(0);
538
539
      switch(job.type)
540
        {
541 be60d4ff leszek
        case ATTACH: if( mChildren==null ) mChildren = new ArrayList<>(2);
542
                     job.node.setSurfaceParent(this);
543
                     DistortedMaster.addSorted(mChildren,job.node);
544 efe3d8fe leszek
                     mNumChildren++;
545
                     break;
546 be60d4ff leszek
        case DETACH: if( mNumChildren>0 && mChildren.remove(job.node) )
547 efe3d8fe leszek
                       {
548 be60d4ff leszek
                       job.node.setSurfaceParent(null);
549 efe3d8fe leszek
                       mNumChildren--;
550
                       }
551
                     break;
552 be60d4ff leszek
        case DETALL: if( mNumChildren>0 )
553 efe3d8fe leszek
                       {
554 be60d4ff leszek
                       DistortedNode tmp;
555
556
                       for(int j=mNumChildren-1; j>=0; j--)
557
                         {
558
                         tmp = mChildren.remove(j);
559
                         tmp.setSurfaceParent(null);
560
                         }
561
562 efe3d8fe leszek
                       mNumChildren = 0;
563
                       }
564
                     break;
565 be60d4ff leszek
        case SORT  : job.node.setPost(job.dep);
566
                     mChildren.remove(job.node);
567
                     DistortedMaster.addSorted(mChildren,job.node);
568 efe3d8fe leszek
                     break;
569
        }
570
      }
571 a09ada4c Leszek Koltunski
    }
572 af4cc5db Leszek Koltunski
}