Project

General

Profile

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

library / src / main / java / org / distorted / library / DistortedEffects.java @ dbe8ea80

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import android.content.res.Resources;
23
import android.opengl.GLES20;
24
import android.opengl.Matrix;
25

    
26
import org.distorted.library.message.EffectListener;
27
import org.distorted.library.program.DistortedProgram;
28
import org.distorted.library.program.FragmentCompilationException;
29
import org.distorted.library.program.FragmentUniformsException;
30
import org.distorted.library.program.LinkingException;
31
import org.distorted.library.program.VertexCompilationException;
32
import org.distorted.library.program.VertexUniformsException;
33
import org.distorted.library.type.Data1D;
34
import org.distorted.library.type.Data2D;
35
import org.distorted.library.type.Data3D;
36
import org.distorted.library.type.Data4D;
37
import org.distorted.library.type.Data5D;
38
import org.distorted.library.type.Static3D;
39

    
40
import java.io.InputStream;
41
import java.nio.ByteBuffer;
42
import java.nio.ByteOrder;
43
import java.nio.FloatBuffer;
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46
/**
47
 * Class containing {@link EffectTypes#LENGTH} queues, each a class derived from EffectQueue.
48
 * <p>
49
 * The queues hold actual effects to be applied to a given (DistortedTexture,MeshObject) combo.
50
 */
51
public class DistortedEffects
52
  {
53
  private static final int POSITION_DATA_SIZE= 3; // Main Program: size of the position data in elements
54
  private static final int NORMAL_DATA_SIZE  = 3; // Main Program: size of the normal data in elements
55
  private static final int TEX_DATA_SIZE     = 2; // Main Program: size of the texture coordinate data in elements.
56

    
57
  private static DistortedProgram mProgram;
58

    
59
  /// DEBUG ONLY /////
60
  private static DistortedProgram mDebugProgram;
61
  private static final FloatBuffer mQuadPositions;
62

    
63
  static
64
    {
65
    float[] positionData= { -0.5f, -0.5f,  -0.5f, 0.5f,  0.5f,-0.5f,  0.5f, 0.5f };
66
    mQuadPositions = ByteBuffer.allocateDirect(32).order(ByteOrder.nativeOrder()).asFloatBuffer();
67
    mQuadPositions.put(positionData).position(0);
68
    }
69

    
70
  private static int mObjDH;
71
  private static int mMVPMatrixH;
72
  /// END DEBUG //////
73

    
74
  private static float[] mMVPMatrix = new float[16];
75
  private static float[] mTmpMatrix = new float[16];
76

    
77
  private static long mNextID =0;
78
  private long mID;
79

    
80
  private static DistortedFramebuffer mBufferFBO = new DistortedFramebuffer(1,1);
81

    
82
  private EffectQueueMatrix      mM;
83
  private EffectQueueFragment    mF;
84
  private EffectQueueVertex      mV;
85
  private EffectQueuePostprocess mP;
86

    
87
  private boolean matrixCloned, vertexCloned, fragmentCloned, postprocessCloned;
88

    
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90

    
91
  static void createProgram(Resources resources)
92
  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
93
    {
94
    final InputStream mainVertexStream   = resources.openRawResource(R.raw.main_vertex_shader);
95
    final InputStream mainFragmentStream = resources.openRawResource(R.raw.main_fragment_shader);
96

    
97
    String mainVertexHeader= ("#version 100\n#define NUM_VERTEX "  + getMaxVertex()+"\n");
98

    
99
    for(EffectNames name: EffectNames.values() )
100
      {
101
      if( name.getType()== EffectTypes.VERTEX)
102
        mainVertexHeader += ("#define "+name.name()+" "+name.ordinal()+"\n");
103
      }
104

    
105
    String mainFragmentHeader= ("#version 100\n#define NUM_FRAGMENT "  + getMaxFragment()+"\n");
106

    
107
    for(EffectNames name: EffectNames.values() )
108
      {
109
      if( name.getType()== EffectTypes.FRAGMENT)
110
        mainFragmentHeader += ("#define "+name.name()+" "+name.ordinal()+"\n");
111
      }
112

    
113
    mProgram = new DistortedProgram(mainVertexStream,mainFragmentStream, mainVertexHeader, mainFragmentHeader);
114

    
115
    int mainProgramH = mProgram.getProgramHandle();
116
    EffectQueueFragment.getUniforms(mainProgramH);
117
    EffectQueueVertex.getUniforms(mainProgramH);
118
    EffectQueueMatrix.getUniforms(mainProgramH);
119
    DistortedTexture.getUniforms(mainProgramH);
120

    
121
    // DEBUG ONLY //////////////////////////////////////
122
    final InputStream debugVertexStream   = resources.openRawResource(R.raw.test_vertex_shader);
123
    final InputStream debugFragmentStream = resources.openRawResource(R.raw.test_fragment_shader);
124

    
125
    mDebugProgram = new DistortedProgram(debugVertexStream,debugFragmentStream, "#version 100\n", "#version 100\n");
126

    
127
    int debugProgramH = mDebugProgram.getProgramHandle();
128
    mObjDH      = GLES20.glGetUniformLocation( debugProgramH, "u_objD");
129
    mMVPMatrixH = GLES20.glGetUniformLocation( debugProgramH, "u_MVPMatrix");
130
    // END DEBUG  //////////////////////////////////////
131
    }
132

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

    
135
  private void initializeEffectLists(DistortedEffects d, int flags)
136
    {
137
    if( (flags & Distorted.CLONE_MATRIX) != 0 )
138
      {
139
      mM = d.mM;
140
      matrixCloned = true;
141
      }
142
    else
143
      {
144
      mM = new EffectQueueMatrix(mID);
145
      matrixCloned = false;
146
      }
147
    
148
    if( (flags & Distorted.CLONE_VERTEX) != 0 )
149
      {
150
      mV = d.mV;
151
      vertexCloned = true;
152
      }
153
    else
154
      {
155
      mV = new EffectQueueVertex(mID);
156
      vertexCloned = false;
157
      }
158
    
159
    if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
160
      {
161
      mF = d.mF;
162
      fragmentCloned = true;
163
      }
164
    else
165
      {
166
      mF = new EffectQueueFragment(mID);
167
      fragmentCloned = false;
168
      }
169

    
170
    if( (flags & Distorted.CLONE_POSTPROCESS) != 0 )
171
      {
172
      mP = d.mP;
173
      postprocessCloned = true;
174
      }
175
    else
176
      {
177
      mP = new EffectQueuePostprocess(mID);
178
      postprocessCloned = false;
179
      }
180
    }
181

    
182
///////////////////////////////////////////////////////////////////////////////////////////////////
183
// DEBUG ONLY
184

    
185
  @SuppressWarnings("unused")
186
  private void displayBoundingRect(float halfX, float halfY, float halfZ, DistortedFramebuffer df, float[] mvp, float[] vertices)
187
    {
188
    int len  = vertices.length/3;
189
    int minx = Integer.MAX_VALUE;
190
    int maxx = Integer.MIN_VALUE;
191
    int miny = Integer.MAX_VALUE;
192
    int maxy = Integer.MIN_VALUE;
193
    int wx,wy;
194

    
195
    float x,y,z, X,Y,W, ndcX,ndcY;
196

    
197
    for(int i=0; i<len; i++)
198
      {
199
      x = 2*halfX*vertices[3*i  ];
200
      y = 2*halfY*vertices[3*i+1];
201
      z = 2*halfZ*vertices[3*i+2];
202

    
203
      X = mvp[ 0]*x + mvp[ 4]*y + mvp[ 8]*z + mvp[12];
204
      Y = mvp[ 1]*x + mvp[ 5]*y + mvp[ 9]*z + mvp[13];
205
      W = mvp[ 3]*x + mvp[ 7]*y + mvp[11]*z + mvp[15];
206

    
207
      ndcX = X/W;
208
      ndcY = Y/W;
209

    
210
      wx = (int)(df.mWidth *(ndcX+1)/2);
211
      wy = (int)(df.mHeight*(ndcY+1)/2);
212

    
213
      if( wx<minx ) minx = wx;
214
      if( wx>maxx ) maxx = wx;
215
      if( wy<miny ) miny = wy;
216
      if( wy>maxy ) maxy = wy;
217
      }
218

    
219
    mDebugProgram.useProgram();
220
    df.setAsOutput();
221

    
222
    Matrix.setIdentityM( mTmpMatrix, 0);
223
    Matrix.translateM  ( mTmpMatrix, 0, minx-df.mWidth/2, maxy-df.mHeight/2, -df.mDistance);
224
    Matrix.scaleM      ( mTmpMatrix, 0, (float)(maxx-minx)/(2*halfX), (float)(maxy-miny)/(2*halfY), 1.0f);
225
    Matrix.translateM  ( mTmpMatrix, 0, halfX,-halfY, 0);
226
    Matrix.multiplyMM  ( mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
227

    
228
    GLES20.glUniform2f( mObjDH , 2*halfX, 2*halfY);
229
    GLES20.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0);
230

    
231
    GLES20.glVertexAttribPointer(mDebugProgram.mAttribute[0], 2, GLES20.GL_FLOAT, false, 0, mQuadPositions);
232
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
233
    }
234

    
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236

    
237
  void drawPriv(float halfInputW, float halfInputH, MeshObject mesh, DistortedFramebuffer df, long currTime)
238
    {
239
    mM.compute(currTime);
240
    mV.compute(currTime);
241
    mF.compute(currTime);
242
    mP.compute(currTime);
243

    
244
    float halfZ = halfInputW*mesh.zFactor;
245
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
246

    
247
    if( mP.mNumEffects==0 )
248
      {
249
      mProgram.useProgram();
250
      df.setAsOutput();
251
      mM.send(df,halfInputW,halfInputH,halfZ);
252
      mV.send(halfInputW,halfInputH,halfZ);
253
      mF.send(halfInputW,halfInputH);
254
      GLES20.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mesh.mMeshPositions);
255
      GLES20.glVertexAttribPointer(mProgram.mAttribute[1], NORMAL_DATA_SIZE  , GLES20.GL_FLOAT, false, 0, mesh.mMeshNormals);
256
      GLES20.glVertexAttribPointer(mProgram.mAttribute[2], TEX_DATA_SIZE     , GLES20.GL_FLOAT, false, 0, mesh.mMeshTexture);
257
      GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
258
      }
259
    else
260
      {
261
      if( mV.mNumEffects==0 && mF.mNumEffects==0 && (mesh instanceof MeshFlat) && mM.canUseShortcut() )
262
        {
263
        mM.constructMatrices(df,halfInputW,halfInputH);
264
        mP.render(2*halfInputW, 2*halfInputH, mM.getMVP(), df);
265
        }
266
      else
267
        {
268
        mProgram.useProgram();
269
        mBufferFBO.resizeFast(df.mWidth, df.mHeight);
270
        mBufferFBO.setAsOutput();
271
        GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
272
        GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
273
        mM.send(mBufferFBO,halfInputW,halfInputH,halfZ);
274
        mV.send(halfInputW,halfInputH,halfZ);
275
        mF.send(halfInputW,halfInputH);
276
        GLES20.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mesh.mMeshPositions);
277
        GLES20.glVertexAttribPointer(mProgram.mAttribute[1], NORMAL_DATA_SIZE  , GLES20.GL_FLOAT, false, 0, mesh.mMeshNormals);
278
        GLES20.glVertexAttribPointer(mProgram.mAttribute[2], TEX_DATA_SIZE     , GLES20.GL_FLOAT, false, 0, mesh.mMeshTexture);
279
        GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
280

    
281
        Matrix.setIdentityM(mTmpMatrix, 0);
282
        Matrix.translateM(mTmpMatrix, 0, 0, 0, -df.mDistance);
283
        Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
284

    
285
        mBufferFBO.setAsInput();
286
        mP.render(df.mWidth, df.mHeight, mMVPMatrix, df);
287
        }
288
      }
289

    
290
    /// DEBUG ONLY //////
291
    // displayBoundingRect(halfInputW, halfInputH, halfZ, df, mM.getMVP(), mesh.getBoundingVertices() );
292
    /// END DEBUG ///////
293
    }
294

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296
   
297
  static void drawNoEffectsPriv(float halfInputW, float halfInputH, MeshObject mesh, DistortedFramebuffer df)
298
    {
299
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
300

    
301
    Matrix.setIdentityM(mTmpMatrix, 0);
302
    Matrix.translateM(mTmpMatrix, 0, 0, 0, -df.mDistance);
303
    Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
304

    
305
    EffectQueueMatrix.sendZero(df,halfInputW,halfInputH,halfInputW*mesh.zFactor);
306
    EffectQueueVertex.sendZero();
307
    EffectQueueFragment.sendZero();
308
    EffectQueuePostprocess.sendZero(df.mWidth, df.mHeight, mMVPMatrix);
309

    
310
    GLES20.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mesh.mMeshPositions);
311
    GLES20.glVertexAttribPointer(mProgram.mAttribute[1], NORMAL_DATA_SIZE  , GLES20.GL_FLOAT, false, 0, mesh.mMeshNormals);
312
    GLES20.glVertexAttribPointer(mProgram.mAttribute[2], TEX_DATA_SIZE     , GLES20.GL_FLOAT, false, 0, mesh.mMeshTexture);
313
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
314
    }
315
    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317
   
318
  private void releasePriv()
319
    {
320
    if( !matrixCloned     ) mM.abortAll(false);
321
    if( !vertexCloned     ) mV.abortAll(false);
322
    if( !fragmentCloned   ) mF.abortAll(false);
323
    if( !postprocessCloned) mP.abortAll(false);
324

    
325
    mM = null;
326
    mV = null;
327
    mF = null;
328
    mP = null;
329
    }
330

    
331
///////////////////////////////////////////////////////////////////////////////////////////////////
332

    
333
  static void onDestroy()
334
    {
335
    mNextID = 0;
336
    }
337

    
338
///////////////////////////////////////////////////////////////////////////////////////////////////
339
// PUBLIC API
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341
/**
342
 * Create empty effect queue.
343
 */
344
  public DistortedEffects()
345
    {
346
    mID = mNextID++;
347
    initializeEffectLists(this,0);
348
    }
349

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351
/**
352
 * Copy constructor.
353
 * <p>
354
 * Whatever we do not clone gets created just like in the default constructor.
355
 *
356
 * @param dc    Source object to create our object from
357
 * @param flags A bitmask of values specifying what to copy.
358
 *              For example, CLONE_VERTEX | CLONE_MATRIX.
359
 */
360
  public DistortedEffects(DistortedEffects dc, int flags)
361
    {
362
    mID = mNextID++;
363
    initializeEffectLists(dc,flags);
364
    }
365

    
366
///////////////////////////////////////////////////////////////////////////////////////////////////
367
/**
368
 * Releases all resources. After this call, the queue should not be used anymore.
369
 */
370
  public synchronized void delete()
371
    {
372
    releasePriv();
373
    }
374

    
375
///////////////////////////////////////////////////////////////////////////////////////////////////
376
/**
377
 * Returns unique ID of this instance.
378
 *
379
 * @return ID of the object.
380
 */
381
  public long getID()
382
      {
383
      return mID;
384
      }
385

    
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387
/**
388
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
389
 * to one of the Effects in those queues. Nothing will happen if 'el' is already in the list.
390
 * 
391
 * @param el A class implementing the EffectListener interface that wants to get notifications.
392
 */
393
  public void registerForMessages(EffectListener el)
394
    {
395
    mV.registerForMessages(el);
396
    mF.registerForMessages(el);
397
    mM.registerForMessages(el);
398
    mP.registerForMessages(el);
399
    }
400

    
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402
/**
403
 * Removes the calling class from the list of Listeners.
404
 * 
405
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
406
 */
407
  public void deregisterForMessages(EffectListener el)
408
    {
409
    mV.deregisterForMessages(el);
410
    mF.deregisterForMessages(el);
411
    mM.deregisterForMessages(el);
412
    mP.deregisterForMessages(el);
413
    }
414

    
415
///////////////////////////////////////////////////////////////////////////////////////////////////
416
/**
417
 * Aborts all Effects.
418
 * @return Number of effects aborted.
419
 */
420
  public int abortAllEffects()
421
      {
422
      return mM.abortAll(true) + mV.abortAll(true) + mF.abortAll(true) + mP.abortAll(true);
423
      }
424

    
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426
/**
427
 * Aborts all Effects of a given type, for example all MATRIX Effects.
428
 * 
429
 * @param type one of the constants defined in {@link EffectTypes}
430
 * @return Number of effects aborted.
431
 */
432
  public int abortEffects(EffectTypes type)
433
    {
434
    switch(type)
435
      {
436
      case MATRIX     : return mM.abortAll(true);
437
      case VERTEX     : return mV.abortAll(true);
438
      case FRAGMENT   : return mF.abortAll(true);
439
      case POSTPROCESS: return mP.abortAll(true);
440
      default         : return 0;
441
      }
442
    }
443
    
444
///////////////////////////////////////////////////////////////////////////////////////////////////
445
/**
446
 * Aborts a single Effect.
447
 * 
448
 * @param id ID of the Effect we want to abort.
449
 * @return number of Effects aborted. Always either 0 or 1.
450
 */
451
  public int abortEffect(long id)
452
    {
453
    int type = (int)(id&EffectTypes.MASK);
454

    
455
    if( type==EffectTypes.MATRIX.type      ) return mM.removeByID(id>>EffectTypes.LENGTH);
456
    if( type==EffectTypes.VERTEX.type      ) return mV.removeByID(id>>EffectTypes.LENGTH);
457
    if( type==EffectTypes.FRAGMENT.type    ) return mF.removeByID(id>>EffectTypes.LENGTH);
458
    if( type==EffectTypes.POSTPROCESS.type ) return mP.removeByID(id>>EffectTypes.LENGTH);
459

    
460
    return 0;
461
    }
462

    
463
///////////////////////////////////////////////////////////////////////////////////////////////////
464
/**
465
 * Abort all Effects of a given name, for example all rotations.
466
 * 
467
 * @param name one of the constants defined in {@link EffectNames}
468
 * @return number of Effects aborted.
469
 */
470
  public int abortEffects(EffectNames name)
471
    {
472
    switch(name.getType())
473
      {
474
      case MATRIX     : return mM.removeByType(name);
475
      case VERTEX     : return mV.removeByType(name);
476
      case FRAGMENT   : return mF.removeByType(name);
477
      case POSTPROCESS: return mP.removeByType(name);
478
      default         : return 0;
479
      }
480
    }
481
    
482
///////////////////////////////////////////////////////////////////////////////////////////////////
483
/**
484
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
485
 * 
486
 * @param id Effect ID we want to print info about
487
 * @return <code>true</code> if a single Effect of type effectType has been found.
488
 */
489
    
490
  public boolean printEffect(long id)
491
    {
492
    int type = (int)(id&EffectTypes.MASK);
493

    
494
    if( type==EffectTypes.MATRIX.type      )  return mM.printByID(id>>EffectTypes.LENGTH);
495
    if( type==EffectTypes.VERTEX.type      )  return mV.printByID(id>>EffectTypes.LENGTH);
496
    if( type==EffectTypes.FRAGMENT.type    )  return mF.printByID(id>>EffectTypes.LENGTH);
497
    if( type==EffectTypes.POSTPROCESS.type )  return mP.printByID(id>>EffectTypes.LENGTH);
498

    
499
    return false;
500
    }
501

    
502
///////////////////////////////////////////////////////////////////////////////////////////////////
503
/**
504
 * Returns the maximum number of Matrix effects.
505
 *
506
 * @return The maximum number of Matrix effects
507
 */
508
  public static int getMaxMatrix()
509
    {
510
    return EffectQueue.getMax(EffectTypes.MATRIX.ordinal());
511
    }
512

    
513
///////////////////////////////////////////////////////////////////////////////////////////////////
514
/**
515
 * Returns the maximum number of Vertex effects.
516
 *
517
 * @return The maximum number of Vertex effects
518
 */
519
  public static int getMaxVertex()
520
    {
521
    return EffectQueue.getMax(EffectTypes.VERTEX.ordinal());
522
    }
523

    
524
///////////////////////////////////////////////////////////////////////////////////////////////////
525
/**
526
 * Returns the maximum number of Fragment effects.
527
 *
528
 * @return The maximum number of Fragment effects
529
 */
530
  public static int getMaxFragment()
531
    {
532
    return EffectQueue.getMax(EffectTypes.FRAGMENT.ordinal());
533
    }
534

    
535
///////////////////////////////////////////////////////////////////////////////////////////////////
536
/**
537
 * Returns the maximum number of Postprocess effects.
538
 *
539
 * @return The maximum number of Postprocess effects
540
 */
541
  public static int getMaxPostprocess()
542
    {
543
    return EffectQueue.getMax(EffectTypes.POSTPROCESS.ordinal());
544
    }
545

    
546
///////////////////////////////////////////////////////////////////////////////////////////////////
547
/**
548
 * Sets the maximum number of Matrix effects that can be stored in a single EffectQueue at one time.
549
 * This can fail if:
550
 * <ul>
551
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
552
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
553
 *     before the Vertex Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
554
 *     time only decreasing the value of 'max' is permitted.
555
 * <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
556
 * </ul>
557
 *
558
 * @param max new maximum number of simultaneous Matrix Effects. Has to be a non-negative number not greater
559
 *            than Byte.MAX_VALUE
560
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
561
 */
562
  public static boolean setMaxMatrix(int max)
563
    {
564
    return EffectQueue.setMax(EffectTypes.MATRIX.ordinal(),max);
565
    }
566

    
567
///////////////////////////////////////////////////////////////////////////////////////////////////
568
/**
569
 * Sets the maximum number of Vertex effects that can be stored in a single EffectQueue at one time.
570
 * This can fail if:
571
 * <ul>
572
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
573
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
574
 *     before the Vertex Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
575
 *     time only decreasing the value of 'max' is permitted.
576
* <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
577
 * </ul>
578
 *
579
 * @param max new maximum number of simultaneous Vertex Effects. Has to be a non-negative number not greater
580
 *            than Byte.MAX_VALUE
581
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
582
 */
583
  public static boolean setMaxVertex(int max)
584
    {
585
    return EffectQueue.setMax(EffectTypes.VERTEX.ordinal(),max);
586
    }
587

    
588
///////////////////////////////////////////////////////////////////////////////////////////////////
589
/**
590
 * Sets the maximum number of Fragment effects that can be stored in a single EffectQueue at one time.
591
 * This can fail if:
592
 * <ul>
593
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
594
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
595
 *     before the Fragment Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
596
 *     time only decreasing the value of 'max' is permitted.
597
 * <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
598
 * </ul>
599
 *
600
 * @param max new maximum number of simultaneous Fragment Effects. Has to be a non-negative number not greater
601
 *            than Byte.MAX_VALUE
602
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
603
 */
604
  public static boolean setMaxFragment(int max)
605
    {
606
    return EffectQueue.setMax(EffectTypes.FRAGMENT.ordinal(),max);
607
    }
608

    
609
///////////////////////////////////////////////////////////////////////////////////////////////////
610
/**
611
 * Sets the maximum number of Postprocess effects that can be stored in a single EffectQueue at one time.
612
 * This can fail if:
613
 * <ul>
614
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
615
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
616
 *     before the Fragment Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
617
 *     time only decreasing the value of 'max' is permitted.
618
 * <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
619
 * </ul>
620
 *
621
 * @param max new maximum number of simultaneous Postprocess Effects. Has to be a non-negative number not greater
622
 *            than Byte.MAX_VALUE
623
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
624
 */
625
  public static boolean setMaxPostprocess(int max)
626
    {
627
    return EffectQueue.setMax(EffectTypes.POSTPROCESS.ordinal(),max);
628
    }
629

    
630
///////////////////////////////////////////////////////////////////////////////////////////////////   
631
///////////////////////////////////////////////////////////////////////////////////////////////////
632
// Individual effect functions.
633
///////////////////////////////////////////////////////////////////////////////////////////////////
634
// Matrix-based effects
635
///////////////////////////////////////////////////////////////////////////////////////////////////
636
/**
637
 * Moves the Object by a (possibly changing in time) vector.
638
 * 
639
 * @param vector 3-dimensional Data which at any given time will return a Static3D
640
 *               representing the current coordinates of the vector we want to move the Object with.
641
 * @return       ID of the effect added, or -1 if we failed to add one.
642
 */
643
  public long move(Data3D vector)
644
    {   
645
    return mM.add(EffectNames.MOVE,vector);
646
    }
647

    
648
///////////////////////////////////////////////////////////////////////////////////////////////////
649
/**
650
 * Scales the Object by (possibly changing in time) 3D scale factors.
651
 * 
652
 * @param scale 3-dimensional Data which at any given time returns a Static3D
653
 *              representing the current x- , y- and z- scale factors.
654
 * @return      ID of the effect added, or -1 if we failed to add one.
655
 */
656
  public long scale(Data3D scale)
657
    {   
658
    return mM.add(EffectNames.SCALE,scale);
659
    }
660

    
661
///////////////////////////////////////////////////////////////////////////////////////////////////
662
/**
663
 * Scales the Object by one uniform, constant factor in all 3 dimensions. Convenience function.
664
 *
665
 * @param scale The factor to scale all 3 dimensions with.
666
 * @return      ID of the effect added, or -1 if we failed to add one.
667
 */
668
  public long scale(float scale)
669
    {
670
    return mM.add(EffectNames.SCALE, new Static3D(scale,scale,scale));
671
    }
672

    
673
///////////////////////////////////////////////////////////////////////////////////////////////////
674
/**
675
 * Rotates the Object by 'angle' degrees around the center.
676
 * Static axis of rotation is given by the last parameter.
677
 *
678
 * @param angle  Angle that we want to rotate the Object to. Unit: degrees
679
 * @param axis   Axis of rotation
680
 * @param center Coordinates of the Point we are rotating around.
681
 * @return       ID of the effect added, or -1 if we failed to add one.
682
 */
683
  public long rotate(Data1D angle, Static3D axis, Data3D center )
684
    {   
685
    return mM.add(EffectNames.ROTATE, angle, axis, center);
686
    }
687

    
688
///////////////////////////////////////////////////////////////////////////////////////////////////
689
/**
690
 * Rotates the Object by 'angle' degrees around the center.
691
 * Here both angle and axis can dynamically change.
692
 *
693
 * @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ).
694
 * @param center    Coordinates of the Point we are rotating around.
695
 * @return          ID of the effect added, or -1 if we failed to add one.
696
 */
697
  public long rotate(Data4D angleaxis, Data3D center)
698
    {
699
    return mM.add(EffectNames.ROTATE, angleaxis, center);
700
    }
701

    
702
///////////////////////////////////////////////////////////////////////////////////////////////////
703
/**
704
 * Rotates the Object by quaternion.
705
 *
706
 * @param quaternion The quaternion describing the rotation.
707
 * @param center     Coordinates of the Point we are rotating around.
708
 * @return           ID of the effect added, or -1 if we failed to add one.
709
 */
710
  public long quaternion(Data4D quaternion, Data3D center )
711
    {
712
    return mM.add(EffectNames.QUATERNION,quaternion,center);
713
    }
714

    
715
///////////////////////////////////////////////////////////////////////////////////////////////////
716
/**
717
 * Shears the Object.
718
 *
719
 * @param shear   The 3-tuple of shear factors. The first controls level
720
 *                of shearing in the X-axis, second - Y-axis and the third -
721
 *                Z-axis. Each is the tangens of the shear angle, i.e 0 -
722
 *                no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc.
723
 * @param center  Center of shearing, i.e. the point which stays unmoved.
724
 * @return        ID of the effect added, or -1 if we failed to add one.
725
 */
726
  public long shear(Data3D shear, Data3D center)
727
    {
728
    return mM.add(EffectNames.SHEAR, shear, center);
729
    }
730

    
731
///////////////////////////////////////////////////////////////////////////////////////////////////
732
// Fragment-based effects  
733
///////////////////////////////////////////////////////////////////////////////////////////////////
734
/**
735
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
736
 *        
737
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
738
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
739
 *               Valid range: <0,1>
740
 * @param color  Color to mix. (1,0,0) is RED.
741
 * @param region Region this Effect is limited to.
742
 * @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region.
743
 * @return       ID of the effect added, or -1 if we failed to add one.
744
 */
745
  public long chroma(Data1D blend, Data3D color, Data4D region, boolean smooth)
746
    {
747
    return mF.add( smooth? EffectNames.SMOOTH_CHROMA:EffectNames.CHROMA, blend, color, region);
748
    }
749

    
750
///////////////////////////////////////////////////////////////////////////////////////////////////
751
/**
752
 * Makes the whole Object smoothly change all three of its RGB components.
753
 *
754
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
755
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
756
 *               Valid range: <0,1>
757
 * @param color  Color to mix. (1,0,0) is RED.
758
 * @return       ID of the effect added, or -1 if we failed to add one.
759
 */
760
  public long chroma(Data1D blend, Data3D color)
761
    {
762
    return mF.add(EffectNames.CHROMA, blend, color);
763
    }
764

    
765
///////////////////////////////////////////////////////////////////////////////////////////////////
766
/**
767
 * Makes a certain sub-region of the Object smoothly change its transparency level.
768
 *        
769
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any given
770
 *               moment: pixel.a *= alpha.
771
 *               Valid range: <0,1>
772
 * @param region Region this Effect is limited to. 
773
 * @param smooth If true, the level of 'alpha' will smoothly fade out towards the edges of the region.
774
 * @return       ID of the effect added, or -1 if we failed to add one. 
775
 */
776
  public long alpha(Data1D alpha, Data4D region, boolean smooth)
777
    {
778
    return mF.add( smooth? EffectNames.SMOOTH_ALPHA:EffectNames.ALPHA, alpha, region);
779
    }
780

    
781
///////////////////////////////////////////////////////////////////////////////////////////////////
782
/**
783
 * Makes the whole Object smoothly change its transparency level.
784
 *
785
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any
786
 *               given moment: pixel.a *= alpha.
787
 *               Valid range: <0,1>
788
 * @return       ID of the effect added, or -1 if we failed to add one.
789
 */
790
  public long alpha(Data1D alpha)
791
    {
792
    return mF.add(EffectNames.ALPHA, alpha);
793
    }
794

    
795
///////////////////////////////////////////////////////////////////////////////////////////////////
796
/**
797
 * Makes a certain sub-region of the Object smoothly change its brightness level.
798
 *        
799
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
800
 *                   at any given moment. Valid range: <0,infinity)
801
 * @param region     Region this Effect is limited to.
802
 * @param smooth     If true, the level of 'brightness' will smoothly fade out towards the edges of the region.
803
 * @return           ID of the effect added, or -1 if we failed to add one.
804
 */
805
  public long brightness(Data1D brightness, Data4D region, boolean smooth)
806
    {
807
    return mF.add( smooth ? EffectNames.SMOOTH_BRIGHTNESS: EffectNames.BRIGHTNESS, brightness, region);
808
    }
809

    
810
///////////////////////////////////////////////////////////////////////////////////////////////////
811
/**
812
 * Makes the whole Object smoothly change its brightness level.
813
 *
814
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
815
 *                   at any given moment. Valid range: <0,infinity)
816
 * @return           ID of the effect added, or -1 if we failed to add one.
817
 */
818
  public long brightness(Data1D brightness)
819
    {
820
    return mF.add(EffectNames.BRIGHTNESS, brightness);
821
    }
822

    
823
///////////////////////////////////////////////////////////////////////////////////////////////////
824
/**
825
 * Makes a certain sub-region of the Object smoothly change its contrast level.
826
 *        
827
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
828
 *                 at any given moment. Valid range: <0,infinity)
829
 * @param region   Region this Effect is limited to.
830
 * @param smooth   If true, the level of 'contrast' will smoothly fade out towards the edges of the region.
831
 * @return         ID of the effect added, or -1 if we failed to add one.
832
 */
833
  public long contrast(Data1D contrast, Data4D region, boolean smooth)
834
    {
835
    return mF.add( smooth ? EffectNames.SMOOTH_CONTRAST:EffectNames.CONTRAST, contrast, region);
836
    }
837

    
838
///////////////////////////////////////////////////////////////////////////////////////////////////
839
/**
840
 * Makes the whole Object smoothly change its contrast level.
841
 *
842
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
843
 *                 at any given moment. Valid range: <0,infinity)
844
 * @return         ID of the effect added, or -1 if we failed to add one.
845
 */
846
  public long contrast(Data1D contrast)
847
    {
848
    return mF.add(EffectNames.CONTRAST, contrast);
849
    }
850

    
851
///////////////////////////////////////////////////////////////////////////////////////////////////
852
/**
853
 * Makes a certain sub-region of the Object smoothly change its saturation level.
854
 *        
855
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
856
 *                   at any given moment. Valid range: <0,infinity)
857
 * @param region     Region this Effect is limited to.
858
 * @param smooth     If true, the level of 'saturation' will smoothly fade out towards the edges of the region.
859
 * @return           ID of the effect added, or -1 if we failed to add one.
860
 */
861
  public long saturation(Data1D saturation, Data4D region, boolean smooth)
862
    {
863
    return mF.add( smooth ? EffectNames.SMOOTH_SATURATION:EffectNames.SATURATION, saturation, region);
864
    }
865

    
866
///////////////////////////////////////////////////////////////////////////////////////////////////
867
/**
868
 * Makes the whole Object smoothly change its saturation level.
869
 *
870
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
871
 *                   at any given moment. Valid range: <0,infinity)
872
 * @return           ID of the effect added, or -1 if we failed to add one.
873
 */
874
  public long saturation(Data1D saturation)
875
    {
876
    return mF.add(EffectNames.SATURATION, saturation);
877
    }
878

    
879
///////////////////////////////////////////////////////////////////////////////////////////////////
880
// Vertex-based effects  
881
///////////////////////////////////////////////////////////////////////////////////////////////////
882
/**
883
 * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
884
 *
885
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
886
 *               currently being dragged with.
887
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
888
 * @param region Region that masks the Effect.
889
 * @return       ID of the effect added, or -1 if we failed to add one.
890
 */
891
  public long distort(Data3D vector, Data3D center, Data4D region)
892
    {  
893
    return mV.add(EffectNames.DISTORT, vector, center, region);
894
    }
895

    
896
///////////////////////////////////////////////////////////////////////////////////////////////////
897
/**
898
 * Distort the whole Object by a (possibly changing in time) vector of force.
899
 *
900
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
901
 *               currently being dragged with.
902
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
903
 * @return       ID of the effect added, or -1 if we failed to add one.
904
 */
905
  public long distort(Data3D vector, Data3D center)
906
    {
907
    return mV.add(EffectNames.DISTORT, vector, center, null);
908
    }
909

    
910
///////////////////////////////////////////////////////////////////////////////////////////////////
911
/**
912
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
913
 * a (possibly changing in time) point on the Object.
914
 *
915
 * @param vector Vector of force that deforms the shape of the whole Object.
916
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
917
 * @param region Region that masks the Effect.
918
 * @return       ID of the effect added, or -1 if we failed to add one.
919
 */
920
  public long deform(Data3D vector, Data3D center, Data4D region)
921
    {
922
    return mV.add(EffectNames.DEFORM, vector, center, region);
923
    }
924

    
925
///////////////////////////////////////////////////////////////////////////////////////////////////
926
/**
927
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
928
 * a (possibly changing in time) point on the Object.
929
 *     
930
 * @param vector Vector of force that deforms the shape of the whole Object.
931
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
932
 * @return       ID of the effect added, or -1 if we failed to add one.
933
 */
934
  public long deform(Data3D vector, Data3D center)
935
    {  
936
    return mV.add(EffectNames.DEFORM, vector, center, null);
937
    }
938

    
939
///////////////////////////////////////////////////////////////////////////////////////////////////  
940
/**
941
 * Pull all points around the center of the Effect towards the center (if degree>=1) or push them
942
 * away from the center (degree<=1)
943
 *
944
 * @param sink   The current degree of the Effect.
945
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
946
 * @param region Region that masks the Effect.
947
 * @return       ID of the effect added, or -1 if we failed to add one.
948
 */
949
  public long sink(Data1D sink, Data3D center, Data4D region)
950
    {
951
    return mV.add(EffectNames.SINK, sink, center, region);
952
    }
953

    
954
///////////////////////////////////////////////////////////////////////////////////////////////////
955
/**
956
 * Pull all points around the center of the Effect towards the center (if degree>=1) or push them
957
 * away from the center (degree<=1)
958
 *
959
 * @param sink   The current degree of the Effect.
960
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
961
 * @return       ID of the effect added, or -1 if we failed to add one.
962
 */
963
  public long sink(Data1D sink, Data3D center)
964
    {
965
    return mV.add(EffectNames.SINK, sink, center);
966
    }
967

    
968
///////////////////////////////////////////////////////////////////////////////////////////////////
969
/**
970
 * Pull all points around the center of the Effect towards a line passing through the center
971
 * (that's if degree>=1) or push them away from the line (degree<=1)
972
 *
973
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
974
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
975
 * @param region Region that masks the Effect.
976
 * @return       ID of the effect added, or -1 if we failed to add one.
977
 */
978
  public long pinch(Data2D pinch, Data3D center, Data4D region)
979
    {
980
    return mV.add(EffectNames.PINCH, pinch, center, region);
981
    }
982

    
983
///////////////////////////////////////////////////////////////////////////////////////////////////
984
/**
985
 * Pull all points around the center of the Effect towards a line passing through the center
986
 * (that's if degree>=1) or push them away from the line (degree<=1)
987
 *
988
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
989
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
990
 * @return       ID of the effect added, or -1 if we failed to add one.
991
 */
992
  public long pinch(Data2D pinch, Data3D center)
993
    {
994
    return mV.add(EffectNames.PINCH, pinch, center);
995
    }
996

    
997
///////////////////////////////////////////////////////////////////////////////////////////////////  
998
/**
999
 * Rotate part of the Object around the Center of the Effect by a certain angle.
1000
 *
1001
 * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
1002
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1003
 * @param region Region that masks the Effect.
1004
 * @return       ID of the effect added, or -1 if we failed to add one.
1005
 */
1006
  public long swirl(Data1D swirl, Data3D center, Data4D region)
1007
    {    
1008
    return mV.add(EffectNames.SWIRL, swirl, center, region);
1009
    }
1010

    
1011
///////////////////////////////////////////////////////////////////////////////////////////////////
1012
/**
1013
 * Rotate the whole Object around the Center of the Effect by a certain angle.
1014
 *
1015
 * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
1016
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1017
 * @return       ID of the effect added, or -1 if we failed to add one.
1018
 */
1019
  public long swirl(Data1D swirl, Data3D center)
1020
    {
1021
    return mV.add(EffectNames.SWIRL, swirl, center);
1022
    }
1023

    
1024
///////////////////////////////////////////////////////////////////////////////////////////////////
1025
/**
1026
 * Directional, sinusoidal wave effect.
1027
 *
1028
 * @param wave   A 5-dimensional data structure describing the wave: first member is the amplitude,
1029
 *               second is the wave length, third is the phase (i.e. when phase = PI/2, the sine
1030
 *               wave at the center does not start from sin(0), but from sin(PI/2) ) and the next two
1031
 *               describe the 'direction' of the wave.
1032
 *               <p>
1033
 *               Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
1034
 *               need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
1035
 *               forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
1036
 *               the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
1037
 *               <p>
1038
 *               <p>
1039
 *               Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
1040
 *               in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
1041
 *               will be sine shapes.
1042
 *               <p>
1043
 *               Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
1044
 *               but this time it waves in the Y-direction, i.e. cross sections of the surface and the
1045
 *               YZ-plane with be sine shapes.
1046
 *               <p>
1047
 *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
1048
 *               is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the
1049
 *               value if sin at this point.
1050
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1051
 * @return       ID of the effect added, or -1 if we failed to add one.
1052
 */
1053
  public long wave(Data5D wave, Data3D center)
1054
    {
1055
    return mV.add(EffectNames.WAVE, wave, center, null);
1056
    }
1057

    
1058
///////////////////////////////////////////////////////////////////////////////////////////////////
1059
/**
1060
 * Directional, sinusoidal wave effect.
1061
 *
1062
 * @param wave   see {@link DistortedEffects#wave(Data5D,Data3D)}
1063
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1064
 * @param region Region that masks the Effect.
1065
 * @return       ID of the effect added, or -1 if we failed to add one.
1066
 */
1067
  public long wave(Data5D wave, Data3D center, Data4D region)
1068
    {
1069
    return mV.add(EffectNames.WAVE, wave, center, region);
1070
    }
1071

    
1072
///////////////////////////////////////////////////////////////////////////////////////////////////
1073
// Postprocess-based effects
1074
///////////////////////////////////////////////////////////////////////////////////////////////////
1075
/**
1076
 * Blur the object.
1077
 *
1078
 * @param radius The 'strength' if the effect, in pixels. 0 = no blur, 10 = when blurring a given pixel,
1079
 *               take into account 10 pixels in each direction.
1080
 * @return ID of the effect added, or -1 if we failed to add one.
1081
 */
1082
  public long blur(Data1D radius)
1083
    {
1084
    return mP.add(EffectNames.BLUR, radius);
1085
    }
1086
  }
(2-2/16)