Project

General

Profile

« Previous | Next » 

Revision 7c6d11c8

Added by Leszek Koltunski over 7 years ago

Do not change postprocessing Quality mid-render but go through the Master.

View differences:

src/main/java/org/distorted/library/DistortedEffectsPostprocess.java
22 22
import org.distorted.library.message.EffectListener;
23 23
import org.distorted.library.type.Data1D;
24 24

  
25
import java.util.ArrayList;
26

  
25 27
///////////////////////////////////////////////////////////////////////////////////////////////////
26 28

  
27 29
/**
......
35 37
 * <p>
36 38
 * The queue holds actual effects to be applied to a given bucket of several (DistortedTexture,MeshObject) combos.
37 39
 */
38
public class DistortedEffectsPostprocess
40
public class DistortedEffectsPostprocess implements DistortedSlave
39 41
  {
42
  private static final int MIPMAP = 0;
43

  
40 44
  private static long mNextID =0;
41 45
  private long mID;
42 46

  
......
44 48

  
45 49
  private boolean postprocessCloned;
46 50

  
51
  private class Job
52
    {
53
    int type;
54
    int level;
55

  
56
    Job(int t, int l)
57
      {
58
      type = t;
59
      level= l;
60
      }
61
    }
62

  
63
  private ArrayList<Job> mJobs = new ArrayList<>();
64

  
47 65
///////////////////////////////////////////////////////////////////////////////////////////////////
48 66

  
49 67
  private void initializeEffectLists(DistortedEffectsPostprocess d, int flags)
......
125 143
    initializeEffectLists(dc,flags);
126 144
    }
127 145

  
146
///////////////////////////////////////////////////////////////////////////////////////////////////
147
/**
148
 * This is not really part of the public API. Has to be public only because it is a part of the
149
 * DistortedSlave interface, which should really be a class that we extend here instead but
150
 * Java has no multiple inheritance.
151
 *
152
 * @y.exclude
153
 */
154
  public void doWork()
155
    {
156
    int num = mJobs.size();
157
    Job job;
158

  
159
    for(int i=0; i<num; i++)
160
      {
161
      job = mJobs.remove(0);
162

  
163
      switch(job.type)
164
        {
165
        case MIPMAP: int level = job.level;
166
                     mP.mQualityLevel = level;
167
                     mP.mQualityScale = 1.0f;
168
                     for(int j=0; j<level; j++) mP.mQualityScale*=EffectQuality.MULTIPLIER;
169
                     break;
170
        }
171
      }
172
    }
173

  
128 174
///////////////////////////////////////////////////////////////////////////////////////////////////
129 175
/**
130 176
 * Releases all resources. After this call, the queue should not be used anymore.
......
291 337
 * <p>
292 338
 * This works by rendering into smaller and smaller intermediate buffers. Each step renders into a
293 339
 * buffer that's half the size of the previous one.
340
 * <p>
341
 * We cannot this during mid-render - thus, give it to the Master to assign us back this job on the
342
 * next render.
294 343
 */
295 344
  public void setQuality(EffectQuality quality)
296 345
    {
297
    int level = quality.level;
298

  
299
    mP.mQualityLevel = level;
300
    mP.mQualityScale = 1.0f;
301

  
302
    for(int i=0; i<level; i++) mP.mQualityScale*=EffectQuality.MULTIPLIER;
346
    mJobs.add(new Job(MIPMAP,quality.level));
347
    DistortedMaster.newSlave(this);
303 348
    }
304 349

  
305 350
///////////////////////////////////////////////////////////////////////////////////////////////////   
src/main/java/org/distorted/library/DistortedInputSurface.java
21 21

  
22 22
///////////////////////////////////////////////////////////////////////////////////////////////////
23 23
/**
24
 * A Surface that we can set as Input, i.e. take its rectangle of pixels and skin our Mesh with it.
24
 * A Surface that we can set as an Input (take its rectangle of pixels and skin a Mesh with it).
25 25
 */
26 26

  
27 27
public interface DistortedInputSurface

Also available in: Unified diff