Debian Codegraph @

libs/hwui/tests/common/TestScene.h

raw symbols SCIP
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 #pragma once
18
19 #include <gui/Surface.h>
20 #include <utils/StrongPointer.h>
21
22 #include <map>
23 #include <string>
24
25 namespace android {
26
27 class Canvas;
28
29 namespace uirenderer {
30 class RenderNode;
31 class RecordingCanvas;
32
33 namespace test {
34
35 class TestScene {
36 public:
37 struct Options {
38 int frameCount = 150;
39 int repeatCount = 1;
40 int reportFrametimeWeight = 0;
41 bool renderOffscreen = true;
42 bool reportGpuMemoryUsage = false;
43 bool reportGpuMemoryUsageVerbose = false;
44 };
45
46 template <class T>
47 static test::TestScene* simpleCreateScene(const TestScene::Options&) {
48 return new T();
49 }
50
51 typedef test::TestScene* (*CreateScene)(const TestScene::Options&);
52
53 struct Info {
54 std::string name;
55 std::string description;
56 CreateScene createScene;
57 };
58
59 class Registrar {
60 public:
61 explicit Registrar(const TestScene::Info& info) { TestScene::registerScene(info); }
62
63 private:
64 Registrar() = delete;
65 Registrar(const Registrar&) = delete;
66 Registrar& operator=(const Registrar&) = delete;
67 };
68
69 virtual ~TestScene() {}
70 virtual void createContent(int width, int height, Canvas& renderer) = 0;
71 virtual void doFrame(int frameNr) = 0;
72
73 static std::map<std::string, Info>& testMap();
74 static void registerScene(const Info& info);
75
76 sp<Surface> renderTarget;
77 };
78
79 } // namespace test
80 } // namespace uirenderer
81 } // namespace android