Project

General

Profile

« Previous | Next » 

Revision a4b182d4

Added by Leszek Koltunski about 6 years ago

Introduce possibility that an OutputSurface is backed up by a larger texture than necessary and the 'cloneSize()' method.

View differences:

src/main/java/org/distorted/library/main/DistortedOutputSurface.java
99 99

  
100 100
  private int mDebugLevel;
101 101

  
102
  protected int mRealWidth;   // the Surface can be backed up with a texture that is
103
  protected int mRealHeight;  // larger than the viewport we have to it.
104
                              // mWidth,mHeight are the sizes of the Viewport, those -
105
                              // sizes of the backing up texture.
106

  
102 107
  ////////////////////////////////////////////////////////////////////////////////
103 108
  // section dealing with Shader Storage Buffer Object (for counting transparency)
104 109
  private static final int FRAME_DELAY = 3;
......
138 143
    {
139 144
    super(width,height,createColor,numcolors,type);
140 145

  
146
    mRealWidth = width;
147
    mRealHeight= height;
148

  
141 149
    mProjectionMatrix = new float[16];
142 150

  
143 151
    mFOV = 60.0f;
......
290 298
      mBuffer[j].mMipmap = mipmap;
291 299
      mBuffer[j].mNear   = mNear;  // copy mNear as well (for blitting- see PostprocessEffect.apply() )
292 300
      mBuffer[j].glClearColor(1.0f,1.0f,1.0f,0.0f);
301

  
293 302
      mipmap *= EffectQuality.MULTIPLIER;
294 303
      }
295 304

  
......
314 323
      }
315 324
    }
316 325

  
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327

  
328
  private void cloneSize(DistortedOutputSurface from)
329
    {
330
    mWidth = from.mWidth;
331
    mHeight= from.mHeight;
332

  
333
    createProjection();
334

  
335
    int maxw = mWidth >mRealWidth  ? mWidth :mRealWidth ;
336
    int maxh = mHeight>mRealHeight ? mHeight:mRealHeight;
337

  
338
    if( maxw>mRealWidth || maxh>mRealHeight )
339
      {
340
      mRealWidth = maxw;
341
      mRealHeight= maxh;
342

  
343
      recreateSurface();
344
      createSurface();
345
      }
346
    }
347

  
317 348
///////////////////////////////////////////////////////////////////////////////////////////////////
318 349

  
319 350
  private int blitWithDepth(long currTime, DistortedOutputSurface buffer)
......
534 565
          {
535 566
          android.util.Log.d("surface", "id " + mSurfaceID +
536 567
              (mType == TYPE_USER ? " USER" : (mType == TYPE_SYST ? " SYST" : " TREE")) +
537
              " (" + mWidth + "x" + mHeight + ") last frame: " + (value - mLastValue[mLastIndex])
568
              "viewport: (" + mWidth + "x" + mHeight + ") last frame: " + (value - mLastValue[mLastIndex])
538 569
              + " avg: " + (mAvgSum/RUNNING_AVERAGE)
539 570
          );
540 571
          }
......
706 737
    {
707 738
    if( mWidth!=width || mHeight!=height )
708 739
      {
709
      mWidth = width;
710
      mHeight= height;
740
      mWidth = mRealWidth = width;
741
      mHeight= mRealHeight= height;
711 742

  
712 743
      createProjection();
713 744

  

Also available in: Unified diff