1 /* 2 * Copyright 2018 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 #pragma once 18 19 #include <array> 20 21 #include <GLES2/gl2.h> 22 23 namespace samples { 24 25 struct Circle { 26 struct Color { ColorCircle::Color27 Color(GLfloat r, GLfloat g, GLfloat b) : r(r), g(g), b(b) {} 28 29 union { 30 std::array<GLfloat, 3> values; 31 struct { 32 GLfloat r; 33 GLfloat g; 34 GLfloat b; 35 }; 36 }; 37 }; 38 CircleCircle39 Circle(const Color &color, float radius, float x, float y) : color(color), radius(radius), x(x), 40 y(y) {}; 41 42 static void draw(float aspectRatio, const std::vector<Circle> &circles, int workload); 43 getSegmentsForWorkloadCircle44 static int getSegmentsForWorkload(int workload) { 45 float loadF = workload / 100.0f; 46 47 int num_segmets = (MAX_SEGMENTS - MIN_SEGMENTS) * loadF + MIN_SEGMENTS; 48 // make sure we get full triangles 49 num_segmets = (num_segmets / 3) * 3; 50 return num_segmets; 51 } 52 53 static const long MAX_SEGMENTS = 28800000; 54 static const long MIN_SEGMENTS = 36; 55 56 static std::vector<GLfloat> &getVertices(int); 57 58 const Color color; 59 const float radius; 60 const float x; 61 const float y; 62 }; 63 64 } // namespace samples 65