Project

General

Profile

« Previous | Next » 

Revision 2f1f7570

Added by Leszek Koltunski over 5 years ago

Properly clean up static varaibles in the Effect classes!

View differences:

src/main/java/org/distorted/library/effect/EffectName.java
43 43
public enum EffectName
44 44
  {
45 45
  // EFFECT NAME /////// EFFECT TYPE ////////// EFFECT UNITY //////////// DIM REGION CENTER
46
  ROTATE           ( EffectType.MATRIX  ,   new float[] {0.0f}           , 4, false, true  ),
47
  QUATERNION       ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 4, false, true  ),
48
  MOVE             ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, false, false ),
49
  SCALE            ( EffectType.MATRIX  ,   new float[] {1.0f,1.0f,1.0f} , 3, false, false ),
50
  SHEAR            ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, false, true  ),
51

  
52
  DISTORT          ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, true , true  ),
53
  DEFORM           ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, true , true  ),
54
  SINK             ( EffectType.VERTEX  ,   new float[] {1.0f}           , 1, true , true  ),
55
  PINCH            ( EffectType.VERTEX  ,   new float[] {1.0f}           , 2, true , true  ),
56
  SWIRL            ( EffectType.VERTEX  ,   new float[] {0.0f}           , 1, true , true  ),
57
  WAVE             ( EffectType.VERTEX  ,   new float[] {0.0f}           , 5, true , true  ),
58

  
59
  ALPHA            ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false ),
60
  SMOOTH_ALPHA     ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false ),
61
  CHROMA           ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, true , false ),
62
  SMOOTH_CHROMA    ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, true , false ),
63
  BRIGHTNESS       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false ),
64
  SMOOTH_BRIGHTNESS( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false ),
65
  SATURATION       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false ),
66
  SMOOTH_SATURATION( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false ),
67
  CONTRAST         ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false ),
68
  SMOOTH_CONTRAST  ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false ),
69

  
70
  BLUR             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 1, false, false ),
71
  GLOW             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 5, false, false );
46
  ROTATE           ( EffectType.MATRIX  ,   new float[] {0.0f}           , 4, false, true  , MatrixEffectRotate.class       ),
47
  QUATERNION       ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 4, false, true  , MatrixEffectQuaternion.class   ),
48
  MOVE             ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, false, false , MatrixEffectMove.class         ),
49
  SCALE            ( EffectType.MATRIX  ,   new float[] {1.0f,1.0f,1.0f} , 3, false, false , MatrixEffectScale.class        ),
50
  SHEAR            ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, false, true  , MatrixEffectShear.class        ),
51

  
52
  DISTORT          ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, true , true  , VertexEffectDistort.class      ),
53
  DEFORM           ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, true , true  , VertexEffectDeform.class       ),
54
  SINK             ( EffectType.VERTEX  ,   new float[] {1.0f}           , 1, true , true  , VertexEffectSink.class         ),
55
  PINCH            ( EffectType.VERTEX  ,   new float[] {1.0f}           , 2, true , true  , VertexEffectPinch.class        ),
56
  SWIRL            ( EffectType.VERTEX  ,   new float[] {0.0f}           , 1, true , true  , VertexEffectSwirl.class        ),
57
  WAVE             ( EffectType.VERTEX  ,   new float[] {0.0f}           , 5, true , true  , VertexEffectWave.class         ),
58

  
59
  ALPHA            ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectAlpha.class      ),
60
  SMOOTH_ALPHA     ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectAlpha.class      ),
61
  CHROMA           ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, true , false , FragmentEffectChroma.class     ),
62
  SMOOTH_CHROMA    ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, true , false , FragmentEffectChroma.class     ),
63
  BRIGHTNESS       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectBrightness.class ),
64
  SMOOTH_BRIGHTNESS( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectBrightness.class ),
65
  SATURATION       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectSaturation.class ),
66
  SMOOTH_SATURATION( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectSaturation.class ),
67
  CONTRAST         ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectContrast.class   ),
68
  SMOOTH_CONTRAST  ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectContrast.class   ),
69

  
70
  BLUR             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 1, false, false , PostprocessEffectBlur.class    ),
71
  GLOW             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 5, false, false , PostprocessEffectGlow.class    );
72 72

  
73 73
///////////////////////////////////////////////////////////////////////////////////////////////////
74 74

  
75
  private static final int MAXDIM = 4;  // maximum supported dimension of effect's unity
76 75
  public static final int LENGTH = values().length;
77 76

  
78 77
  private final EffectType type;
......
80 79
  private final int dimension;
81 80
  private final boolean supportsR;
82 81
  private final boolean supportsC;
82
  private final Class<? extends Effect> effectClass;
83 83

  
84
  private static final float[] unities;
85
  private static final int[] unityDimensions;
86 84
  private static final int[] dimensions;
87 85
  private static final boolean[] supportsRegion;
88 86
  private static final boolean[] supportsCenter;
......
92 90
    {
93 91
    int i=0;
94 92

  
95
    unities         = new float[MAXDIM*LENGTH];
96
    unityDimensions = new int[LENGTH];
97 93
    dimensions      = new int[LENGTH];
98 94
    supportsRegion  = new boolean[LENGTH];
99 95
    supportsCenter  = new boolean[LENGTH];
......
101 97

  
102 98
    for(EffectName name: EffectName.values())
103 99
      {
104
      unityDimensions[i] = (name.unity==null ? 0 : name.unity.length);
105 100
      dimensions[i]      = name.dimension;
106 101
      supportsRegion[i]  = name.supportsR;
107 102
      supportsCenter[i]  = name.supportsC;
108 103
      names[i]           = name;
109 104

  
110
      switch(unityDimensions[i])
111
        {
112
        case 4: unities[MAXDIM*i+3] = name.unity[3];
113
        case 3: unities[MAXDIM*i+2] = name.unity[2];
114
        case 2: unities[MAXDIM*i+1] = name.unity[1];
115
        case 1: unities[MAXDIM*i  ] = name.unity[0];
116
        case 0: break;
117
        }
118

  
119 105
      i++;
120 106
      }
121 107
    }
......
129 115

  
130 116
///////////////////////////////////////////////////////////////////////////////////////////////////
131 117

  
132
  EffectName(EffectType type, float[] unity, int dimension, boolean supportsR, boolean supportsC)
118
  EffectName(EffectType type, float[] unity, int dimension, boolean supportsR,
119
             boolean supportsC, Class<? extends Effect> effectClass )
133 120
    {
134
    this.type      = type;
135
    this.unity     = unity;
136
    this.dimension = dimension;
137
    this.supportsR = supportsR;
138
    this.supportsC = supportsC;
121
    this.type        = type;
122
    this.unity       = unity;
123
    this.dimension   = dimension;
124
    this.supportsR   = supportsR;
125
    this.supportsC   = supportsC;
126
    this.effectClass = effectClass;
139 127
    }
140 128

  
141 129
///////////////////////////////////////////////////////////////////////////////////////////////////
......
151 139
    return type;
152 140
    }
153 141

  
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143
  /**
144
   * Returns the Class of an individual Effect. For example, EffectName.ROTATION.getType() will
145
   * return MatrixEffectRotation.class.
146
   * @return effect class.
147
   */
148
  public Class<? extends Effect> getEffectClass()
149
    {
150
    return effectClass;
151
    }
152

  
154 153
///////////////////////////////////////////////////////////////////////////////////////////////////
155 154
/**
156 155
 * Returns the i-th EffectName.

Also available in: Unified diff