Revision 09ab7524
Added by Leszek Koltunski over 8 years ago
| src/main/java/org/distorted/library/DistortedEffects.java | ||
|---|---|---|
| 77 | 77 |
private static long mNextID =0; |
| 78 | 78 |
private long mID; |
| 79 | 79 |
|
| 80 |
private static DistortedFramebuffer mBufferFBO = new DistortedFramebuffer(true,1,1); |
|
| 80 |
private static DistortedFramebuffer mBufferFBO = new DistortedFramebuffer(true,DistortedSurface.TYPE_SYST,1,1);
|
|
| 81 | 81 |
|
| 82 | 82 |
private EffectQueueMatrix mM; |
| 83 | 83 |
private EffectQueueFragment mF; |
| src/main/java/org/distorted/library/DistortedFramebuffer.java | ||
|---|---|---|
| 154 | 154 |
} |
| 155 | 155 |
|
| 156 | 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 157 |
// create 'system' Framebuffers, i.e. those that are used internally by the library. |
|
| 158 |
// Those do not get removed in onDestroy(); |
|
| 157 |
// create SYSTEM or TREE framebuffers (those are just like normal FBOs, just hold information |
|
| 158 |
// that they were autocreated only for the Library's internal purposes (SYSTEM) or for using |
|
| 159 |
// inside a Tree of DistortedNodes (TREE) |
|
| 160 |
// SYSTEM surfaces do not get removed in onDestroy(). |
|
| 159 | 161 |
|
| 160 |
DistortedFramebuffer(boolean depthEnabled, int width, int height) |
|
| 162 |
DistortedFramebuffer(boolean depthEnabled, int type, int width, int height)
|
|
| 161 | 163 |
{
|
| 162 |
super(width,height,NOT_CREATED_YET, (depthEnabled ? NOT_CREATED_YET:DONT_CREATE),NOT_CREATED_YET, true);
|
|
| 164 |
super(width,height,NOT_CREATED_YET, (depthEnabled ? NOT_CREATED_YET:DONT_CREATE),NOT_CREATED_YET, type);
|
|
| 163 | 165 |
} |
| 164 | 166 |
|
| 165 | 167 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 175 | 177 |
@SuppressWarnings("unused")
|
| 176 | 178 |
public DistortedFramebuffer(int width, int height, boolean depthEnabled) |
| 177 | 179 |
{
|
| 178 |
super(width,height,NOT_CREATED_YET,(depthEnabled ? NOT_CREATED_YET:DONT_CREATE),NOT_CREATED_YET,false);
|
|
| 180 |
super(width,height,NOT_CREATED_YET,(depthEnabled ? NOT_CREATED_YET:DONT_CREATE),NOT_CREATED_YET,TYPE_USER);
|
|
| 179 | 181 |
} |
| 180 | 182 |
|
| 181 | 183 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 189 | 191 |
@SuppressWarnings("unused")
|
| 190 | 192 |
public DistortedFramebuffer(int width, int height) |
| 191 | 193 |
{
|
| 192 |
super(width,height,NOT_CREATED_YET,DONT_CREATE,NOT_CREATED_YET,false);
|
|
| 194 |
super(width,height,NOT_CREATED_YET,DONT_CREATE,NOT_CREATED_YET,TYPE_USER);
|
|
| 193 | 195 |
} |
| 194 | 196 |
|
| 195 | 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/library/DistortedNode.java | ||
|---|---|---|
| 169 | 169 |
else |
| 170 | 170 |
{
|
| 171 | 171 |
android.util.Log.d("NODE", "creating new FBO of node surfaceID="+mSurface.getID());
|
| 172 |
newData.mFBO = new DistortedFramebuffer(mSurface.getWidth(),mSurface.getHeight()); |
|
| 172 |
newData.mFBO = new DistortedFramebuffer(true,DistortedSurface.TYPE_TREE,mSurface.getWidth(),mSurface.getHeight());
|
|
| 173 | 173 |
} |
| 174 | 174 |
} |
| 175 | 175 |
if( mNumChildren[0]==0 && newData.mFBO!=null ) |
| ... | ... | |
| 303 | 303 |
|
| 304 | 304 |
if( node.mSurface instanceof DistortedTexture ) |
| 305 | 305 |
{
|
| 306 |
mSurface = new DistortedTexture(w,h); |
|
| 306 |
mSurface = new DistortedTexture(w,h, DistortedSurface.TYPE_TREE);
|
|
| 307 | 307 |
} |
| 308 | 308 |
else if( node.mSurface instanceof DistortedFramebuffer ) |
| 309 | 309 |
{
|
| 310 | 310 |
boolean hasDepth = ((DistortedFramebuffer) node.mSurface).hasDepth(); |
| 311 |
mSurface = new DistortedFramebuffer(w,h,hasDepth);
|
|
| 311 |
mSurface = new DistortedFramebuffer(hasDepth,DistortedSurface.TYPE_TREE,w,h);
|
|
| 312 | 312 |
} |
| 313 | 313 |
} |
| 314 | 314 |
if( (flags & Distorted.CLONE_CHILDREN) != 0 ) |
| src/main/java/org/distorted/library/DistortedOutputSurface.java | ||
|---|---|---|
| 43 | 43 |
|
| 44 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 45 | 45 |
|
| 46 |
DistortedOutputSurface(int width, int height, int createColor, int createDepth, int fbo, boolean system)
|
|
| 46 |
DistortedOutputSurface(int width, int height, int createColor, int createDepth, int fbo, int type)
|
|
| 47 | 47 |
{
|
| 48 |
super(width,height,createColor,system);
|
|
| 48 |
super(width,height,createColor,type);
|
|
| 49 | 49 |
|
| 50 | 50 |
mProjectionMatrix = new float[16]; |
| 51 | 51 |
|
| ... | ... | |
| 114 | 114 |
mRender++; |
| 115 | 115 |
|
| 116 | 116 |
// change tree topology (attach and detach children) |
| 117 |
// create and delete all underlying OpenGL resources |
|
| 118 |
// Watch out: FIRST change topology, only then deal |
|
| 119 |
// with OpenGL resources. That's because changing Tree |
|
| 120 |
// can result in additional Framebuffers that would need |
|
| 121 |
// to be created immediately, before the calls to drawRecursive() |
|
| 122 |
|
|
| 123 | 117 |
boolean changed = DistortedAttachDaemon.toDo(); |
| 124 | 118 |
|
| 119 |
// if some changes have been made, we need to rebuilt our tree-isomorphism data structures. |
|
| 125 | 120 |
if( changed ) |
| 126 | 121 |
{
|
| 127 | 122 |
for(int i=0; i<mNumChildren; i++) |
| ... | ... | |
| 133 | 128 |
DistortedNode.debugMap(); |
| 134 | 129 |
} |
| 135 | 130 |
|
| 131 |
// create and delete all underlying OpenGL resources |
|
| 132 |
// Watch out: FIRST change topology, only then deal |
|
| 133 |
// with OpenGL resources. That's because changing Tree |
|
| 134 |
// can result in additional Framebuffers that would need |
|
| 135 |
// to be created immediately, before the calls to drawRecursive() |
|
| 136 | 136 |
toDo(); |
| 137 | 137 |
|
| 138 | 138 |
if( changed ) |
| src/main/java/org/distorted/library/DistortedScreen.java | ||
|---|---|---|
| 46 | 46 |
{
|
| 47 | 47 |
// set color to 'DONT_CREATE' so that Screens will not get added to the Surface lists |
| 48 | 48 |
// set depth to 'CREATED' so that depth will be, by default, on. |
| 49 |
super(0,0,DONT_CREATE,CREATED,0,false);
|
|
| 49 |
super(0,0,DONT_CREATE,CREATED,0,TYPE_USER);
|
|
| 50 | 50 |
} |
| 51 | 51 |
} |
| src/main/java/org/distorted/library/DistortedSurface.java | ||
|---|---|---|
| 36 | 36 |
static final int DONT_CREATE = 3; |
| 37 | 37 |
static final int CREATED = 4; |
| 38 | 38 |
|
| 39 |
static final int TYPE_USER = 0; |
|
| 40 |
static final int TYPE_TREE = 1; |
|
| 41 |
static final int TYPE_SYST = 2; |
|
| 42 |
|
|
| 39 | 43 |
private static boolean mToDo = false; |
| 40 | 44 |
private static LinkedList<DistortedSurface> mDoneList = new LinkedList<>(); |
| 41 | 45 |
private static LinkedList<DistortedSurface> mToDoList = new LinkedList<>(); |
| ... | ... | |
| 44 | 48 |
|
| 45 | 49 |
private long mID; |
| 46 | 50 |
private boolean mMarked; |
| 47 |
private boolean mSystem;
|
|
| 51 |
private int mType;
|
|
| 48 | 52 |
int mColorCreated; |
| 49 | 53 |
int[] mColorH = new int[1]; |
| 50 | 54 |
int mSizeX, mSizeY; // in screen space |
| ... | ... | |
| 98 | 102 |
{
|
| 99 | 103 |
surface = mDoneList.removeFirst(); |
| 100 | 104 |
|
| 101 |
if( surface.mSystem )
|
|
| 105 |
if( surface.mType==TYPE_SYST )
|
|
| 102 | 106 |
{
|
| 103 | 107 |
mToDoList.add(surface); |
| 104 | 108 |
surface.recreate(); |
| ... | ... | |
| 111 | 115 |
{
|
| 112 | 116 |
surface = mToDoList.get(i); |
| 113 | 117 |
|
| 114 |
if( !surface.mSystem )
|
|
| 118 |
if( surface.mType!=TYPE_SYST )
|
|
| 115 | 119 |
{
|
| 116 | 120 |
mDoneList.remove(i); |
| 117 | 121 |
i--; |
| ... | ... | |
| 165 | 169 |
|
| 166 | 170 |
str += ("("+surface.getWidth()+","+surface.getHeight()+") surfaceID:"+surface.getID());
|
| 167 | 171 |
|
| 172 |
switch(surface.mType) |
|
| 173 |
{
|
|
| 174 |
case TYPE_SYST: str+=" SYSTEM"; break; |
|
| 175 |
case TYPE_USER: str+=" USER" ; break; |
|
| 176 |
case TYPE_TREE: str+=" TREE" ; break; |
|
| 177 |
default : str+=" ERROR??"; |
|
| 178 |
} |
|
| 179 |
|
|
| 168 | 180 |
android.util.Log.e("Surface", str);
|
| 169 | 181 |
} |
| 170 | 182 |
} |
| 171 | 183 |
|
| 172 | 184 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 173 | 185 |
|
| 174 |
DistortedSurface(int width, int height, int create, boolean system)
|
|
| 186 |
DistortedSurface(int width, int height, int create, int type)
|
|
| 175 | 187 |
{
|
| 176 | 188 |
mSizeX = width ; |
| 177 | 189 |
mSizeY = height; |
| 178 | 190 |
mColorCreated = create; |
| 179 | 191 |
mColorH[0] = 0; |
| 180 | 192 |
mMarked = false; |
| 181 |
mID = system ? --mNextSystemID : ++mNextClientID;
|
|
| 182 |
mSystem = system;
|
|
| 193 |
mID = type==TYPE_SYST ? --mNextSystemID : ++mNextClientID;
|
|
| 194 |
mType = type;
|
|
| 183 | 195 |
|
| 184 | 196 |
if( create!=DONT_CREATE ) |
| 185 | 197 |
{
|
| src/main/java/org/distorted/library/DistortedTexture.java | ||
|---|---|---|
| 111 | 111 |
GLES30.glUniform1i(textureH, 0); |
| 112 | 112 |
} |
| 113 | 113 |
|
| 114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 115 |
// create SYSTEM or TREE textures (those are just like normal Textures, just hold information |
|
| 116 |
// that they were autocreated only for the Library's internal purposes (SYSTEM) or for using |
|
| 117 |
// inside a Tree of DistortedNodes (TREE) |
|
| 118 |
// SYSTEM surfaces do not get removed in onDestroy(). |
|
| 119 |
|
|
| 120 |
public DistortedTexture(int width, int height, int type) |
|
| 121 |
{
|
|
| 122 |
super(width,height,NOT_CREATED_YET,type); |
|
| 123 |
mBmp= null; |
|
| 124 |
} |
|
| 125 |
|
|
| 114 | 126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 115 | 127 |
// PUBLIC API |
| 116 | 128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 119 | 131 |
*/ |
| 120 | 132 |
public DistortedTexture(int width, int height) |
| 121 | 133 |
{
|
| 122 |
super(width,height,NOT_CREATED_YET,false);
|
|
| 134 |
super(width,height,NOT_CREATED_YET,TYPE_USER);
|
|
| 123 | 135 |
mBmp= null; |
| 124 | 136 |
} |
| 125 | 137 |
|
| src/main/java/org/distorted/library/EffectQueuePostprocess.java | ||
|---|---|---|
| 69 | 69 |
mQuadTextureInv.put(textureInv).position(0); |
| 70 | 70 |
} |
| 71 | 71 |
|
| 72 |
private static DistortedFramebuffer mBufferFBO = new DistortedFramebuffer(true,1,1); |
|
| 72 |
private static DistortedFramebuffer mBufferFBO = new DistortedFramebuffer(true,DistortedSurface.TYPE_SYST,1,1);
|
|
| 73 | 73 |
|
| 74 | 74 |
private static float[] mMVPMatrix = new float[16]; |
| 75 | 75 |
private static float[] mTmpMatrix = new float[16]; |
Also available in: Unified diff
Introduce 3 types of Surfaces: System, Tree, User