blob: eaf5988dca494f7ba16d8abc232c898c783ab0fc [file] [log] [blame]
John Reck16c9d6a2015-11-17 15:51:08 -08001/*
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 */
Chris Craik5e00c7c2016-07-06 16:10:09 -070016
17#pragma once
John Reck16c9d6a2015-11-17 15:51:08 -080018
John Recked024d22017-11-10 15:06:32 -080019#include <gui/Surface.h>
20#include <utils/StrongPointer.h>
21
Chris Craik27e58b42015-12-07 10:01:38 -080022#include <string>
23#include <unordered_map>
24
John Reck16c9d6a2015-11-17 15:51:08 -080025namespace android {
Stan Iliev06152cd2016-07-27 17:55:43 -040026
27class Canvas;
28
John Reck16c9d6a2015-11-17 15:51:08 -080029namespace uirenderer {
30class RenderNode;
John Reck16c9d6a2015-11-17 15:51:08 -080031class RecordingCanvas;
Chris Craik5e00c7c2016-07-06 16:10:09 -070032
John Reck16c9d6a2015-11-17 15:51:08 -080033namespace test {
34
35class TestScene {
36public:
Chris Craik27e58b42015-12-07 10:01:38 -080037 struct Options {
John Recka8427802021-05-10 17:47:50 -040038 int frameCount = 150;
39 int repeatCount = 1;
John Reck682573c2015-10-30 10:37:35 -070040 int reportFrametimeWeight = 0;
sergeyv202c10b2016-07-11 17:53:45 -070041 bool renderOffscreen = true;
Chris Craik27e58b42015-12-07 10:01:38 -080042 };
43
44 template <class T>
45 static test::TestScene* simpleCreateScene(const TestScene::Options&) {
46 return new T();
47 }
48
49 typedef test::TestScene* (*CreateScene)(const TestScene::Options&);
50
51 struct Info {
52 std::string name;
53 std::string description;
54 CreateScene createScene;
55 };
56
57 class Registrar {
58 public:
John Reck1bcacfd2017-11-03 10:12:19 -070059 explicit Registrar(const TestScene::Info& info) { TestScene::registerScene(info); }
60
Chris Craik27e58b42015-12-07 10:01:38 -080061 private:
62 Registrar() = delete;
63 Registrar(const Registrar&) = delete;
64 Registrar& operator=(const Registrar&) = delete;
65 };
66
John Reck16c9d6a2015-11-17 15:51:08 -080067 virtual ~TestScene() {}
Stan Iliev06152cd2016-07-27 17:55:43 -040068 virtual void createContent(int width, int height, Canvas& renderer) = 0;
John Reck16c9d6a2015-11-17 15:51:08 -080069 virtual void doFrame(int frameNr) = 0;
Chris Craik27e58b42015-12-07 10:01:38 -080070
71 static std::unordered_map<std::string, Info>& testMap();
72 static void registerScene(const Info& info);
John Recked024d22017-11-10 15:06:32 -080073
74 sp<Surface> renderTarget;
John Reck16c9d6a2015-11-17 15:51:08 -080075};
76
John Reck1bcacfd2017-11-03 10:12:19 -070077} // namespace test
78} // namespace uirenderer
79} // namespace android