Project

General

Profile

« Previous | Next » 

Revision aa6e92f2

Added by Leszek Koltunski over 4 years ago

Improve debugging in DistortedScreen

View differences:

src/main/java/org/distorted/library/main/DistortedScreen.java
40 40
  {
41 41
  ///// DEBUGGING ONLY /////////////////////////
42 42
  private static final int NUM_FRAMES  = 100;
43
  private static final int DEBUG_W     = 150;
44
  private static final int DEBUG_H     =  70;
43
  private static final float DEBUG_SCR_FRAC = 0.15f;
44
  private static final float DEBUG_FRAC     = 0.5f;
45 45

  
46 46
  private static final int DEBUG_MODE_NONE = 0;
47 47
  private static final int DEBUG_MODE_FPS  = 1;
......
89 89
    mQueueSize = -1;
90 90
    }
91 91

  
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

  
94
   private void allocateDebug()
95
     {
96
     if( !mDebugAllocated )
97
       {
98
       mDebugAllocated = true;
99

  
100
       debugString = "";
101
       debugBitmap = Bitmap.createBitmap(DEBUG_W, DEBUG_H, Bitmap.Config.ARGB_8888);
102
       debugMesh = new MeshQuad();
103
       debugTexture = new DistortedTexture();
104
       debugTexture.setTexture(debugBitmap);
105
       debugCanvas = new Canvas(debugBitmap);
106
       debugEffects = new DistortedEffects();
107
       debugEffects.apply( new MatrixEffectScale( new Static3D(DEBUG_W,DEBUG_H,1) ) );
108
       debugEffects.apply(mMoveEffect);
109

  
110
       mPaint = new Paint();
111
       mPaint.setAntiAlias(true);
112
       mPaint.setTextAlign(Paint.Align.CENTER);
113
       mPaint.setTextSize(0.7f * DEBUG_H);
114
       }
115
     }
116

  
117 92
///////////////////////////////////////////////////////////////////////////////////////////////////
118 93
/**
119 94
 * Draws all the attached children to this OutputSurface.
......
144 119
        frameNumber++;
145 120
        }
146 121

  
122
      int width = (int)(mWidth*DEBUG_SCR_FRAC);
123
      int height= (int)(mWidth*DEBUG_SCR_FRAC*DEBUG_FRAC);
124

  
125
      if( !mDebugAllocated )
126
       {
127
       mDebugAllocated = true;
128
       debugString = "";
129

  
130
       debugBitmap = Bitmap.createBitmap( width, height, Bitmap.Config.ARGB_8888);
131
       debugMesh = new MeshQuad();
132
       debugTexture = new DistortedTexture();
133
       debugTexture.setTexture(debugBitmap);
134
       debugCanvas = new Canvas(debugBitmap);
135
       debugEffects = new DistortedEffects();
136
       debugEffects.apply( new MatrixEffectScale( new Static3D(width,height,1) ) );
137
       debugEffects.apply(mMoveEffect);
138

  
139
       mPaint = new Paint();
140
       mPaint.setAntiAlias(true);
141
       mPaint.setTextAlign(Paint.Align.CENTER);
142
       mPaint.setTextSize(0.7f*height);
143
       }
144

  
147 145
      mPaint.setColor(0xffffffff);
148
      debugCanvas.drawRect(0, 0, DEBUG_W, DEBUG_H, mPaint);
146
      debugCanvas.drawRect(0, 0, width, height, mPaint);
149 147
      mPaint.setColor(0xff000000);
150
      debugCanvas.drawText(debugString, 0.5f*DEBUG_W, 0.75f*DEBUG_H, mPaint);
148
      debugCanvas.drawText(debugString, 0.5f*width, 0.75f*height, mPaint);
151 149
      debugTexture.setTexture(debugBitmap);
152 150

  
153
      mMoveVector.set( (-mWidth+DEBUG_W)/2 +5, (mHeight-DEBUG_H)/2 -5, 0);
151
      mMoveVector.set( (-mWidth+width)*0.5f +5, (mHeight-height)*0.5f -5, 0);
154 152

  
155 153
      lastTime = time;
156 154
      }
......
206 204
    {
207 205
    if( mDebugMode!=DEBUG_MODE_FPS )
208 206
      {
209
      allocateDebug();
210 207
      mDebugMode = DEBUG_MODE_FPS;
211 208

  
212 209
      durations = new long[NUM_FRAMES + 1];
......
226 223
    {
227 224
    if( mDebugMode!=DEBUG_MODE_FRAME )
228 225
      {
229
      allocateDebug();
230 226
      mDebugMode = DEBUG_MODE_FRAME;
231 227
      frameNumber = 0;
232 228
      }

Also available in: Unified diff