blob: e3777ca2c3c2102c00b539bc63b3fcfea56d1677 [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
Chris Craik27e58b42015-12-07 10:01:38 -080019#include <string>
20#include <unordered_map>
21
John Reck16c9d6a2015-11-17 15:51:08 -080022namespace android {
Stan Iliev06152cd2016-07-27 17:55:43 -040023
24class Canvas;
25
John Reck16c9d6a2015-11-17 15:51:08 -080026namespace uirenderer {
27class RenderNode;
John Reck16c9d6a2015-11-17 15:51:08 -080028class RecordingCanvas;
Chris Craik5e00c7c2016-07-06 16:10:09 -070029
John Reck16c9d6a2015-11-17 15:51:08 -080030namespace test {
31
32class TestScene {
33public:
Chris Craik27e58b42015-12-07 10:01:38 -080034 struct Options {
35 int count = 0;
John Reck682573c2015-10-30 10:37:35 -070036 int reportFrametimeWeight = 0;
sergeyv202c10b2016-07-11 17:53:45 -070037 bool renderOffscreen = true;
Chris Craik27e58b42015-12-07 10:01:38 -080038 };
39
40 template <class T>
41 static test::TestScene* simpleCreateScene(const TestScene::Options&) {
42 return new T();
43 }
44
45 typedef test::TestScene* (*CreateScene)(const TestScene::Options&);
46
47 struct Info {
48 std::string name;
49 std::string description;
50 CreateScene createScene;
51 };
52
53 class Registrar {
54 public:
55 Registrar(const TestScene::Info& info) {
56 TestScene::registerScene(info);
57 }
58 private:
59 Registrar() = delete;
60 Registrar(const Registrar&) = delete;
61 Registrar& operator=(const Registrar&) = delete;
62 };
63
John Reck16c9d6a2015-11-17 15:51:08 -080064 virtual ~TestScene() {}
Stan Iliev06152cd2016-07-27 17:55:43 -040065 virtual void createContent(int width, int height, Canvas& renderer) = 0;
John Reck16c9d6a2015-11-17 15:51:08 -080066 virtual void doFrame(int frameNr) = 0;
Chris Craik27e58b42015-12-07 10:01:38 -080067
68 static std::unordered_map<std::string, Info>& testMap();
69 static void registerScene(const Info& info);
John Reck16c9d6a2015-11-17 15:51:08 -080070};
71
72} // namespace test
73} // namespace uirenderer
74} // namespace android