1 /* 2 * Copyright (C) 2019 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 package android.gameperformance; 17 18 import java.util.ArrayList; 19 import java.util.List; 20 21 import android.annotation.NonNull; 22 23 /** 24 * Tests that verifies maximum number of device calls to render the geometry to keep FPS close to 25 * the device refresh rate. This uses trivial one triangle patch that is rendered multiple times. 26 */ 27 public class DeviceCallsOpenGLTest extends RenderPatchOpenGLTest { 28 DeviceCallsOpenGLTest(@onNull GamePerformanceActivity activity)29 public DeviceCallsOpenGLTest(@NonNull GamePerformanceActivity activity) { 30 super(activity); 31 } 32 33 @Override getName()34 public String getName() { 35 return "device_calls"; 36 } 37 38 @Override getUnitName()39 public String getUnitName() { 40 return "calls"; 41 } 42 43 @Override getUnitScale()44 public double getUnitScale() { 45 return 25.0; 46 } 47 48 @Override initUnits(double deviceCallsD)49 public void initUnits(double deviceCallsD) { 50 final List<RenderPatchAnimation> renderPatches = new ArrayList<>(); 51 final RenderPatch renderPatch = new RenderPatch(1 /* triangleCount */, 52 0.05f /* dimension */, 53 RenderPatch.TESSELLATION_BASE); 54 final int deviceCalls = (int)Math.round(deviceCallsD); 55 for (int i = 0; i < deviceCalls; ++i) { 56 renderPatches.add(new RenderPatchAnimation(renderPatch, getView().getRenderRatio())); 57 } 58 setRenderPatches(renderPatches); 59 } 60 }