Project

General

Profile

« Previous | Next » 

Revision 30c71dd5

Added by Leszek Koltunski over 7 years ago

Remove 'statics' from the Deform app

View differences:

src/main/java/org/distorted/examples/deform/DeformRenderer.java
42 42
class DeformRenderer implements GLSurfaceView.Renderer 
43 43
{
44 44
   private static final int NUM_VECTORS = 8;
45
   private static final int NUMLINES = 10;
46
   private static final int NUMFRAMES =10;
45
   private static final int NUM_LINES = 10;
46
   private static final int NUM_FRAMES =10;
47 47

  
48 48
   private GLSurfaceView mView;
49 49
   private DistortedBitmap fps;
50 50
   private DistortedBitmap stretch;
51 51
   private Static3D touchPoint;
52 52

  
53
   private static Dynamic3D mReleasedDistortDynamic;
54
   private static Dynamic3D mMovingDistortDynamic;
55
   private static Static3D[] vDistort;
56
   private static Dynamic3D mReleasedDeformDynamic;
57
   private static Dynamic3D mMovingDeformDynamic;
58
   private static Static3D[] vDeform;
59
   private static Dynamic3D mReleasedShearDynamic;
60
   private static Dynamic3D mMovingShearDynamic;
61
   private static Static3D[] vShear;
62

  
63
   private static Static4D dr;
53
   private Dynamic3D mReleasedDistortDynamic;
54
   private Dynamic3D mMovingDistortDynamic;
55
   private Static3D[] vDistort;
56
   private Dynamic3D mReleasedDeformDynamic;
57
   private Dynamic3D mMovingDeformDynamic;
58
   private Static3D[] vDeform;
59
   private Dynamic3D mReleasedShearDynamic;
60
   private Dynamic3D mMovingShearDynamic;
61
   private Static3D[] vShear;
62

  
63
   private Static4D dr;
64 64
   private Canvas fpsCanvas;
65
   private Bitmap fpsBitmap, stretchBitmap;
65
   private Bitmap fpsBitmap;
66 66
   private int scrHeight, scrWidth;
67 67
   private Paint mPaint;
68 68
   private int fpsH, fpsW;
......
71 71
   private long[] durations;
72 72
   private int currDuration;
73 73

  
74
   private static EffectNames mMode = EffectNames.DISTORT;
75
   private static boolean bitmapCreated = false;
76

  
77
   private static long mLastEffect = -1;
74
   private EffectNames mMode = EffectNames.DISTORT;
75
   private boolean bitmapCreated = false;
76
   private long mLastEffect = -1;
78 77

  
79 78
///////////////////////////////////////////////////////////////////////////////////////////////////
80 79

  
81
   public DeformRenderer(GLSurfaceView view) 
80
   DeformRenderer(GLSurfaceView view)
82 81
      { 
83 82
      mView = view;
84 83
      
85 84
      dr = new Static4D(0,0,0,0);
86 85

  
87
      durations = new long[NUMFRAMES+1];
86
      durations = new long[NUM_FRAMES+1];
88 87
      currDuration = 0;
89 88

  
90
      for(int i=0; i<NUMFRAMES+1; i++)
89
      for(int i=0; i<NUM_FRAMES+1; i++)
91 90
        {
92 91
        durations[i]=0;
93 92
        }
......
143 142

  
144 143
///////////////////////////////////////////////////////////////////////////////////////////////////
145 144

  
146
   public static void setMode(EffectNames mode)
145
   void setMode(EffectNames mode)
147 146
      {
148 147
      mMode = mode;  
149 148
      }
150 149
   
151 150
///////////////////////////////////////////////////////////////////////////////////////////////////
152 151

  
153
   public static void setRegionRadius(int r)
152
   void setRegionRadius(int r)
154 153
      {
155 154
      dr.set(0,0,r); 
156 155
      }
157 156

  
158 157
///////////////////////////////////////////////////////////////////////////////////////////////////
159 158

  
160
    public static void onPause()
159
    public void onPause()
161 160
      {
162 161
      bitmapCreated = false;  
163 162
      }
......
230 229
      
231 230
      mPaint = new Paint();
232 231
      stretch = new DistortedBitmap(w,h, 50);   
233
      stretchBitmap = Bitmap.createBitmap(w,h, Bitmap.Config.ARGB_8888);
232
      Bitmap stretchBitmap = Bitmap.createBitmap(w,h, Bitmap.Config.ARGB_8888);
234 233
      stretchCanvas = new Canvas(stretchBitmap);
235 234
      
236 235
      fpsW = scrWidth/5;
......
244 243
      stretchCanvas.drawRect(0, 0, w, h, mPaint);
245 244
      mPaint.setColor(0xffffffff);
246 245
      
247
      for(int i=0; i<=NUMLINES ; i++ )
246
      for(int i=0; i<=NUM_LINES ; i++ )
248 247
        {
249
        stretchCanvas.drawRect(w*i/NUMLINES - 1,                0,  w*i/NUMLINES + 1,  h               , mPaint);
250
        stretchCanvas.drawRect(               0, h *i/NUMLINES -1,  w               ,  h*i/NUMLINES + 1, mPaint);  
248
        stretchCanvas.drawRect(w*i/NUM_LINES - 1,                 0,  w*i/NUM_LINES + 1,  h                , mPaint);
249
        stretchCanvas.drawRect(                0, h *i/NUM_LINES -1,  w                ,  h*i/NUM_LINES + 1, mPaint);
251 250
        }
252 251
        
253 252
      touchPoint= new Static3D(0,0,0);
......
262 261

  
263 262
///////////////////////////////////////////////////////////////////////////////////////////////////
264 263

  
265
    public void down(int x, int y)
264
    void down(int x, int y)
266 265
      {
267 266
      int xt = x-scrWidth/4;
268 267
      int yt = y-scrHeight/4;
......
290 289
    
291 290
///////////////////////////////////////////////////////////////////////////////////////////////////
292 291

  
293
    public void move(int x, int y)
292
    void move(int x, int y)
294 293
      {
295 294
      switch(mMode)
296 295
        {
......
305 304
    
306 305
///////////////////////////////////////////////////////////////////////////////////////////////////
307 306

  
308
    public void up()
307
    void up()
309 308
      {
310 309
      stretch.abortEffect(mLastEffect);
311 310

  
......
344 343
      if( lastTime!=0 )
345 344
        {
346 345
        currDuration++;
347
        if( currDuration>=NUMFRAMES ) currDuration = 0;  
348
        durations[NUMFRAMES] += ((currentTime-lastTime)-durations[currDuration]);
346
        if( currDuration>=NUM_FRAMES ) currDuration = 0;
347
        durations[NUM_FRAMES] += ((currentTime-lastTime)-durations[currDuration]);
349 348
        durations[currDuration] = currentTime-lastTime;
350 349

  
351
        fpsString = "" + ((int)(10000.0f*NUMFRAMES/durations[NUMFRAMES]))/10.0f;
350
        fpsString = "" + ((int)(10000.0f*NUM_FRAMES/durations[NUM_FRAMES]))/10.0f;
352 351
        }
353 352
      
354 353
      lastTime = currentTime;   

Also available in: Unified diff