Project

General

Profile

« Previous | Next » 

Revision 29fdea14

Added by Leszek Koltunski over 1 year ago

New app reproduces an issue with crash on my physical LG phone.

View differences:

src/main/AndroidManifest.xml
62 62
        <activity android:name=".singlemesh.SingleMeshActivity"/>
63 63
        <activity android:name=".meshfile.MeshFileActivity"/>
64 64
        <activity android:name=".flatblur.FlatBlurActivity"/>
65
        <activity android:name=".flatblur2.FlatBlur2Activity"/>
65 66
    </application>
66 67
</manifest>
src/main/java/org/distorted/examples/TableOfContents.java
37 37
import org.distorted.examples.deferredjob.DeferredJobActivity;
38 38
import org.distorted.examples.monalisa.MonaLisaActivity;
39 39
import org.distorted.examples.flatblur.FlatBlurActivity;
40
import org.distorted.examples.flatblur2.FlatBlur2Activity;
40 41
import org.distorted.examples.sink.SinkActivity;
41 42
import org.distorted.examples.projection.ProjectionActivity;
42 43
import org.distorted.examples.deform.DeformActivity;
......
129 130
    SINGLEMESH        (R.drawable.icon_example_singlemesh      , R.string.example_singlemesh           , R.string.example_singlemesh_subtitle           ,            SingleMeshActivity.class),
130 131
    MESHFILE          (R.drawable.icon_example_meshfile        , R.string.example_meshfile           , R.string.example_meshfile_subtitle           ,            MeshFileActivity.class),
131 132
    FLATBLUR          (R.drawable.icon_example_flatblur        , R.string.example_flatblur         , R.string.example_flatblur_subtitle         , FlatBlurActivity.class ),
133
    FLATBLUR2         (R.drawable.icon_example_flatblur        , R.string.example_flatblur         , R.string.example_flatblur_subtitle         , FlatBlur2Activity.class ),
132 134

  
133 135
    ;
134 136

  
src/main/java/org/distorted/examples/flatblur2/FlatBlur2Activity.java
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.examples.flatblur2;
21

  
22
import android.app.Activity;
23
import android.opengl.GLSurfaceView;
24
import android.os.Bundle;
25
import android.view.View;
26

  
27
import org.distorted.examples.R;
28
import org.distorted.library.main.DistortedLibrary;
29

  
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31

  
32
public class FlatBlur2Activity extends Activity
33
{
34
    @Override
35
    protected void onCreate(Bundle savedState) 
36
      {
37
      super.onCreate(savedState);
38
      DistortedLibrary.onCreate();
39
      setContentView(R.layout.flatblur2layout);
40
      }
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43
    
44
    @Override
45
    protected void onPause() 
46
      {
47
      super.onPause();
48
      GLSurfaceView view = findViewById(R.id.flatblur2SurfaceView);
49
      view.onPause();
50
      DistortedLibrary.onPause();
51
      }
52

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54
    
55
    @Override
56
    protected void onResume() 
57
      {
58
      super.onResume();
59
      GLSurfaceView view = findViewById(R.id.flatblur2SurfaceView);
60
      view.onResume();
61
      }
62
    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64
    
65
    @Override
66
    protected void onDestroy() 
67
      {
68
      DistortedLibrary.onDestroy();
69
      super.onDestroy();
70
      }
71

  
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

  
74
    public void button1(View view)
75
      {
76
      FlatBlur2SurfaceView v = findViewById(R.id.flatblur2SurfaceView);
77
      FlatBlur2Renderer renderer = v.getRenderer();
78
      renderer.button1();
79
      }
80

  
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82

  
83
    public void button2(View view)
84
      {
85
      FlatBlur2SurfaceView v = findViewById(R.id.flatblur2SurfaceView);
86
      FlatBlur2Renderer renderer = v.getRenderer();
87
      renderer.button2();
88
      }
89
}
src/main/java/org/distorted/examples/flatblur2/FlatBlur2Renderer.java
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.examples.flatblur2;
21

  
22
import android.opengl.GLSurfaceView;
23

  
24
import org.distorted.library.main.DistortedLibrary;
25
import org.distorted.library.main.DistortedScreen;
26

  
27
import javax.microedition.khronos.egl.EGLConfig;
28
import javax.microedition.khronos.opengles.GL10;
29

  
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31

  
32
class FlatBlur2Renderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
33
{
34
    private final GLSurfaceView mView;
35
    private final DistortedScreen mScreen;
36

  
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

  
39
    FlatBlur2Renderer(GLSurfaceView v)
40
      {
41
      mView = v;
42
      mScreen = new DistortedScreen();
43
      }
44

  
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

  
47
    public void onDrawFrame(GL10 glUnused) 
48
      {
49
      mScreen.render(System.currentTimeMillis());
50
      }
51

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

  
54
    public void onSurfaceChanged(GL10 glUnused, int width, int height)
55
      {
56
      mScreen.resize(width,height);
57
      }
58

  
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60
    
61
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
62
      {
63
      OverlayStars.enableEffects();
64
      DistortedLibrary.onSurfaceCreated( mView.getContext(), this);
65
      }
66

  
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

  
69
    public void distortedException(Exception ex)
70
      {
71
      android.util.Log.e("FlatBlur2", ex.getMessage() );
72
      }
73

  
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75

  
76
    public void button1()
77
      {
78
      OverlayStars stars = new OverlayStars();
79
      stars.startOverlay(mScreen);
80
      }
81

  
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83

  
84
    public void button2()
85
      {
86

  
87
      }
88
}
src/main/java/org/distorted/examples/flatblur2/FlatBlur2SurfaceView.java
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.examples.flatblur2;
21

  
22
import android.app.ActivityManager;
23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
25
import android.opengl.GLSurfaceView;
26
import android.util.AttributeSet;
27

  
28
///////////////////////////////////////////////////////////////////////////////////////////////////
29

  
30
class FlatBlur2SurfaceView extends GLSurfaceView
31
{
32
    private FlatBlur2Renderer mRenderer;
33

  
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

  
36
    public FlatBlur2SurfaceView(Context context, AttributeSet attrs)
37
      {
38
      super(context, attrs);
39

  
40
      if(!isInEditMode())
41
        {
42
        mRenderer = new FlatBlur2Renderer(this);
43
        final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
44
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
45
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
46
        setRenderer(mRenderer);
47
        }
48
      }
49

  
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51

  
52
    public FlatBlur2Renderer getRenderer()
53
      {
54
      return mRenderer;
55
      }
56
}
57

  
src/main/java/org/distorted/examples/flatblur2/OverlayStars.java
1
package org.distorted.examples.flatblur2;
2

  
3
import org.distorted.library.effect.EffectQuality;
4
import org.distorted.library.effect.PostprocessEffectGlow;
5
import org.distorted.library.effect.VertexEffectMove;
6
import org.distorted.library.effect.VertexEffectScale;
7
import org.distorted.library.main.DistortedEffects;
8
import org.distorted.library.main.DistortedNode;
9
import org.distorted.library.main.DistortedScreen;
10
import org.distorted.library.main.DistortedTexture;
11
import org.distorted.library.main.InternalOutputSurface;
12
import org.distorted.library.mesh.MeshQuad;
13
import org.distorted.library.message.EffectListener;
14
import org.distorted.library.type.Dynamic;
15
import org.distorted.library.type.Dynamic2D;
16
import org.distorted.library.type.Dynamic3D;
17
import org.distorted.library.type.Dynamic4D;
18
import org.distorted.library.type.Static2D;
19
import org.distorted.library.type.Static3D;
20
import org.distorted.library.type.Static4D;
21

  
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

  
24
public class OverlayStars implements EffectListener
25
{
26
   private static final int DUR_MOV =  4000;
27
   private static final int DUR_GLO =  2000;
28

  
29
   private static final int[] colors = new int[] {0,0,1,  1,0,1,  1,0,0,  1,1,0,  0,1,0,  1,1,1}; // blue, pink, red, yellow, green, white
30
   private static final int INDEX = 5;
31

  
32
   private DistortedNode mNode1, mNode2;
33
   private DistortedScreen mScreen;
34

  
35
   private float mWidth;
36
   private long mMoveID, mGlowID;
37

  
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

  
40
   private Dynamic3D createRandomMove()
41
      {
42
      Dynamic3D move = new Dynamic3D();
43
      move.setMode(Dynamic.MODE_PATH);
44
      move.setDuration(DUR_MOV);
45
      move.setCount(0.5f);
46

  
47
      Static3D pointS = new Static3D(0,-500,0);
48
      Static3D pointE = new Static3D(0,0,0);
49

  
50
      move.add(pointS);
51
      move.add(pointE);
52

  
53
      return move;
54
      }
55

  
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

  
58
   private DistortedNode createNode2()
59
      {
60
      DistortedTexture texture = new DistortedTexture();
61
      texture.setColorARGB(0xffff0000);
62

  
63
      MeshQuad mesh = new MeshQuad();
64

  
65
      DistortedEffects effects = new DistortedEffects();
66

  
67
      float scaleP  = mWidth*0.15f;
68
      VertexEffectScale scaleE = new VertexEffectScale(scaleP);
69
      scaleE.setMeshAssociation(1,-1);
70
      effects.apply(scaleE);
71

  
72
      Dynamic3D moveP = createRandomMove();
73
      VertexEffectMove moveE= new VertexEffectMove(moveP);
74
      moveE.setMeshAssociation(0,0);
75
      effects.apply(moveE);
76

  
77
      mMoveID = moveE.getID();
78
      moveE.notifyWhenFinished(this);
79

  
80
      return new DistortedNode(texture,effects,mesh);
81
      }
82

  
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

  
85
   private DistortedNode createNode1()
86
      {
87
      DistortedTexture texture = new DistortedTexture();
88
      texture.setColorARGB(0xffff0000);
89

  
90
      MeshQuad mesh = new MeshQuad();
91

  
92
      DistortedEffects effects = new DistortedEffects();
93

  
94
      float scaleM  = mWidth*0.40f;
95
      Static3D moveM= new Static3D(0,0,1);
96

  
97
      VertexEffectMove mainMove  = new VertexEffectMove(moveM);
98
      VertexEffectScale mainScale= new VertexEffectScale(scaleM);
99

  
100
      effects.apply(mainMove);
101
      effects.apply(mainScale);
102

  
103
      return new DistortedNode(texture,effects,mesh);
104
      }
105

  
106
///////////////////////////////////////////////////////////////////////////////////////////////////
107

  
108
   public void startOverlay(DistortedScreen screen)
109
      {
110
      mScreen = screen;
111
      mWidth = mScreen.getWidth();
112

  
113
      mNode1 = createNode1();
114
      mNode1.enableDepthStencil(InternalOutputSurface.NO_DEPTH_NO_STENCIL);
115
      mScreen.attach(mNode1);
116

  
117
      mNode2 = createNode2();
118
      mNode2.enableDepthStencil(InternalOutputSurface.NO_DEPTH_NO_STENCIL);
119
      mScreen.attach(mNode2);
120
      }
121

  
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

  
124
   public void effectFinished(long id)
125
      {
126
      if( id==mMoveID )
127
         {
128
         Dynamic2D haloRadius = new Dynamic2D(DUR_GLO,1.0f);
129
         haloRadius.add(new Static2D( 0, 0));
130
         haloRadius.add(new Static2D(15,50));
131
         haloRadius.add(new Static2D( 0, 0));
132

  
133
         Dynamic4D color= new Dynamic4D(DUR_GLO,1.0f);
134
         Static4D P1    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.0f);
135
         Static4D P2    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.5f);
136
         color.add(P1);
137
         color.add(P2);
138
         color.add(P1);
139

  
140
         PostprocessEffectGlow glow = new PostprocessEffectGlow(haloRadius,color);
141
         glow.setQuality(EffectQuality.MEDIUM);
142
         mGlowID = glow.getID();
143
         glow.notifyWhenFinished(this);
144
         DistortedEffects effects = mNode1.getEffects();
145
         effects.apply(glow);
146
         }
147
      if( id==mGlowID )
148
         {
149
         mScreen.detach(mNode1);
150
         mNode1.markForDeletion();
151
         mNode1=null;
152
         mScreen.detach(mNode2);
153
         mNode2.markForDeletion();
154
         mNode2=null;
155
         }
156
      }
157

  
158
///////////////////////////////////////////////////////////////////////////////////////////////////
159

  
160
  @SuppressWarnings("unused")
161
  public static void enableEffects()
162
     {
163
     VertexEffectMove.enable();
164
     VertexEffectScale.enable();
165
     PostprocessEffectGlow.enable();
166
     }
167
}
src/main/res/layout/flatblur2layout.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="fill_parent"
4
    android:layout_height="fill_parent"
5
    android:orientation="vertical" >
6

  
7
    <org.distorted.examples.flatblur2.FlatBlur2SurfaceView
8
        android:id="@+id/flatblur2SurfaceView"
9
        android:layout_width="fill_parent"
10
        android:layout_height="0dp"
11
        android:layout_weight="1" />
12

  
13
    <LinearLayout
14
        android:orientation="horizontal"
15
        android:layout_width="match_parent"
16
        android:layout_height="wrap_content"
17
        android:gravity="center">
18

  
19
        <Button
20
                android:id="@+id/flatblur2Button1"
21
                android:layout_width="0dp"
22
                android:layout_height="match_parent"
23
                android:layout_weight="1"
24
                android:onClick="button1"
25
                android:checked="false"/>
26
        <Button
27
                android:id="@+id/flatblur2Button2"
28
                android:layout_width="0dp"
29
                android:layout_height="match_parent"
30
                android:layout_weight="1"
31
                android:onClick="button2"
32
                android:checked="false"/>
33

  
34
    </LinearLayout>
35

  
36
</LinearLayout>

Also available in: Unified diff