1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2016 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Distorted is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.library.main;
|
21
|
|
22
|
import org.distorted.library.effect.EffectType;
|
23
|
import org.distorted.library.effect.PostprocessEffect;
|
24
|
import org.distorted.library.message.EffectMessage;
|
25
|
|
26
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
27
|
|
28
|
class EffectQueuePostprocess extends EffectQueue
|
29
|
{
|
30
|
private static final int NUM_UNIFORMS = PostprocessEffect.NUM_UNIFORMS;
|
31
|
private static final int INDEX = EffectType.POSTPROCESS.ordinal();
|
32
|
|
33
|
|
34
|
private int mHalo;
|
35
|
|
36
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37
|
|
38
|
EffectQueuePostprocess(long id)
|
39
|
{
|
40
|
super(id,NUM_UNIFORMS,INDEX );
|
41
|
}
|
42
|
|
43
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
44
|
|
45
|
void compute(long currTime)
|
46
|
{
|
47
|
if( currTime==mTime ) return;
|
48
|
if( mTime==0 ) mTime = currTime;
|
49
|
long step = (currTime-mTime);
|
50
|
|
51
|
mHalo = 0;
|
52
|
int halo;
|
53
|
|
54
|
for(int i=0; i<mNumEffects; i++)
|
55
|
{
|
56
|
mCurrentDuration[i] += step;
|
57
|
|
58
|
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, mCurrentDuration[i], step) )
|
59
|
{
|
60
|
for(int j=0; j<mNumListeners; j++)
|
61
|
EffectMessageSender.newMessage( mListeners.get(j), EffectMessage.EFFECT_FINISHED, mEffects[i].getID(), mDistortedEffectsID);
|
62
|
|
63
|
if( mEffects[i].isUnity( mUniforms, NUM_UNIFORMS*i) )
|
64
|
{
|
65
|
remove(i--);
|
66
|
mNumEffectsToBe--;
|
67
|
regenerateIDandSort();
|
68
|
continue;
|
69
|
}
|
70
|
}
|
71
|
|
72
|
halo = (int)mUniforms[NUM_UNIFORMS*i];
|
73
|
if( halo>mHalo ) mHalo = halo;
|
74
|
}
|
75
|
|
76
|
mTime = currTime;
|
77
|
}
|
78
|
|
79
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
80
|
|
81
|
int getHalo()
|
82
|
{
|
83
|
return mNumEffects>0 ? mHalo : 0;
|
84
|
}
|
85
|
|
86
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
87
|
|
88
|
int getQuality()
|
89
|
{
|
90
|
return mNumEffects>0 ? ((PostprocessEffect)mEffects[0]).getQuality() : 0;
|
91
|
}
|
92
|
|
93
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
94
|
|
95
|
int getInternalQuality()
|
96
|
{
|
97
|
return mNumEffects>0 ? ((PostprocessEffect)mEffects[0]).getInternalQuality() : 0;
|
98
|
}
|
99
|
|
100
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
101
|
|
102
|
int postprocess(DistortedOutputSurface[] buffers)
|
103
|
{
|
104
|
int numRenders = 0;
|
105
|
|
106
|
for(int i=0; i<mNumEffects; i++)
|
107
|
{
|
108
|
numRenders += ((PostprocessEffect)mEffects[i]).apply(mUniforms,NUM_UNIFORMS*i, buffers);
|
109
|
}
|
110
|
|
111
|
return numRenders;
|
112
|
}
|
113
|
}
|