1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.performanceLaunch; 18 19 import android.app.Activity; 20 import android.graphics.Insets; 21 import android.opengl.GLSurfaceView; 22 import android.os.Bundle; 23 import android.os.Trace; 24 import android.view.View; 25 import android.view.WindowInsets; 26 27 import com.android.performanceLaunch.helper.SimpleGLSurfaceView; 28 29 /** 30 * To draw the GLSurface view Source : development/samples/OpenGL/HelloOpenGLES20 31 */ 32 public class SimpleSurfaceGLActivity extends Activity { 33 34 private GLSurfaceView mGLView; 35 36 @Override onCreate(Bundle savedInstanceState)37 public void onCreate(Bundle savedInstanceState) { 38 Trace.beginSection("onCreate"); 39 super.onCreate(savedInstanceState); 40 41 // Create a GLSurfaceView instance and set it 42 // as the ContentView for this Activity 43 mGLView = new SimpleGLSurfaceView(this); 44 setContentView(mGLView); 45 if (mGLView.getParent() instanceof final View parentView) { 46 parentView.setOnApplyWindowInsetsListener( 47 (view, windowInsets) -> { 48 final Insets insets = windowInsets.getSystemWindowInsets(); 49 view.setPadding(insets.left, insets.top, insets.right, insets.bottom); 50 return WindowInsets.CONSUMED; 51 }); 52 } 53 Trace.endSection(); 54 } 55 56 @Override onPause()57 protected void onPause() { 58 super.onPause(); 59 // The following call pauses the rendering thread. 60 // If your OpenGL application is memory intensive, 61 // you should consider de-allocating objects that 62 // consume significant memory here. 63 mGLView.onPause(); 64 } 65 66 @Override onResume()67 protected void onResume() { 68 super.onResume(); 69 // The following call resumes a paused rendering thread. 70 // If you de-allocated graphic objects for onPause() 71 // this is a good place to re-allocate them. 72 mGLView.onResume(); 73 } 74 } 75