Skip to content

Commit a5d4e99

Browse files
committed
Merge tag 'v152.1' into be
2 parents cc6e6ce + cde6d76 commit a5d4e99

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

arc-core/src/arc/util/Tmp.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class Tmp{
4747
public static final Mat m1 = new Mat();
4848
public static final Mat m2 = new Mat();
4949
public static final Mat m3 = new Mat();
50+
public static final Mat m4 = new Mat();
5051

5152
public static final Bezier<Vec2> bz2 = new Bezier<>();
5253
public static final Bezier<Vec3> bz3 = new Bezier<>();

backends/backend-android/src/arc/backend/android/AndroidGraphics.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package arc.backend.android;
22

3+
import android.annotation.*;
34
import android.opengl.*;
45
import android.opengl.GLSurfaceView.*;
6+
import android.os.*;
57
import android.util.*;
68
import android.view.*;
79
import arc.*;
@@ -45,6 +47,7 @@ public class AndroidGraphics extends Graphics implements Renderer{
4547
protected int fps;
4648
int width;
4749
int height;
50+
int safeInsetLeft, safeInsetTop, safeInsetBottom, safeInsetRight;
4851
AndroidApplication app;
4952
GL20 gl20;
5053
GL30 gl30;
@@ -215,6 +218,7 @@ public void onSurfaceChanged(GL10 gl, int width, int height){
215218
this.width = width;
216219
this.height = height;
217220
updatePpi();
221+
updateSafeAreaInsets();
218222
gl.glViewport(0, 0, this.width, this.height);
219223
if(!created){
220224
app.mainThread = Thread.currentThread();
@@ -238,6 +242,7 @@ public void onSurfaceCreated(GL10 gl, EGLConfig config){
238242
setupGL(gl);
239243
logConfig(config);
240244
updatePpi();
245+
updateSafeAreaInsets();
241246

242247
Display display = app.getWindowManager().getDefaultDisplay();
243248
this.width = display.getWidth();
@@ -389,6 +394,35 @@ public void onDrawFrame(GL10 gl){
389394
frames++;
390395
}
391396

397+
@TargetApi(Build.VERSION_CODES.P)
398+
protected void updateSafeAreaInsets(){
399+
400+
safeInsetLeft = 0;
401+
safeInsetTop = 0;
402+
safeInsetRight = 0;
403+
safeInsetBottom = 0;
404+
405+
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){
406+
try{
407+
DisplayCutout displayCutout = app.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
408+
if(displayCutout != null){
409+
safeInsetRight = displayCutout.getSafeInsetRight();
410+
safeInsetBottom = displayCutout.getSafeInsetBottom();
411+
safeInsetTop = displayCutout.getSafeInsetTop();
412+
safeInsetLeft = displayCutout.getSafeInsetLeft();
413+
}
414+
} // Some Application implementations (such as Live Wallpapers) do not implement Application#getApplicationWindow()
415+
catch(UnsupportedOperationException e){
416+
Log.err("AndroidGraphics", "Unable to get safe area insets", e);
417+
}
418+
}
419+
}
420+
421+
@Override
422+
public int[] getSafeInsets(){
423+
return new int[]{safeInsetLeft, safeInsetRight, safeInsetTop, safeInsetBottom};
424+
}
425+
392426
@Override
393427
public long getFrameId(){
394428
return frameId;

0 commit comments

Comments
 (0)