blob: 4813ff0de174d8261c6c835215589639f315089d [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 {
23namespace uirenderer {
24class RenderNode;
John Reck16c9d6a2015-11-17 15:51:08 -080025class RecordingCanvas;
Chris Craik5e00c7c2016-07-06 16:10:09 -070026
John Reck16c9d6a2015-11-17 15:51:08 -080027typedef RecordingCanvas TestCanvas;
John Reck16c9d6a2015-11-17 15:51:08 -080028
29namespace test {
30
31class TestScene {
32public:
Chris Craik27e58b42015-12-07 10:01:38 -080033 struct Options {
34 int count = 0;
John Reck682573c2015-10-30 10:37:35 -070035 int reportFrametimeWeight = 0;
John Reckf1480762016-07-03 18:28:25 -070036 bool renderOffscreen = false;
Chris Craik27e58b42015-12-07 10:01:38 -080037 };
38
39 template <class T>
40 static test::TestScene* simpleCreateScene(const TestScene::Options&) {
41 return new T();
42 }
43
44 typedef test::TestScene* (*CreateScene)(const TestScene::Options&);
45
46 struct Info {
47 std::string name;
48 std::string description;
49 CreateScene createScene;
50 };
51
52 class Registrar {
53 public:
54 Registrar(const TestScene::Info& info) {
55 TestScene::registerScene(info);
56 }
57 private:
58 Registrar() = delete;
59 Registrar(const Registrar&) = delete;
60 Registrar& operator=(const Registrar&) = delete;
61 };
62
John Reck16c9d6a2015-11-17 15:51:08 -080063 virtual ~TestScene() {}
64 virtual void createContent(int width, int height, TestCanvas& renderer) = 0;
65 virtual void doFrame(int frameNr) = 0;
Chris Craik27e58b42015-12-07 10:01:38 -080066
67 static std::unordered_map<std::string, Info>& testMap();
68 static void registerScene(const Info& info);
John Reck16c9d6a2015-11-17 15:51:08 -080069};
70
71} // namespace test
72} // namespace uirenderer
73} // namespace android