John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 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 | */ |
Chris Craik | 5e00c7c | 2016-07-06 16:10:09 -0700 | [diff] [blame] | 16 | |
| 17 | #pragma once |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 18 | |
John Reck | ed024d2 | 2017-11-10 15:06:32 -0800 | [diff] [blame] | 19 | #include <gui/Surface.h> |
| 20 | #include <utils/StrongPointer.h> |
| 21 | |
Chris Craik | 27e58b4 | 2015-12-07 10:01:38 -0800 | [diff] [blame] | 22 | #include <string> |
| 23 | #include <unordered_map> |
| 24 | |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 25 | namespace android { |
Stan Iliev | 06152cd | 2016-07-27 17:55:43 -0400 | [diff] [blame] | 26 | |
| 27 | class Canvas; |
| 28 | |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 29 | namespace uirenderer { |
| 30 | class RenderNode; |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 31 | class RecordingCanvas; |
Chris Craik | 5e00c7c | 2016-07-06 16:10:09 -0700 | [diff] [blame] | 32 | |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 33 | namespace test { |
| 34 | |
| 35 | class TestScene { |
| 36 | public: |
Chris Craik | 27e58b4 | 2015-12-07 10:01:38 -0800 | [diff] [blame] | 37 | struct Options { |
| 38 | int count = 0; |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 39 | int reportFrametimeWeight = 0; |
sergeyv | 202c10b | 2016-07-11 17:53:45 -0700 | [diff] [blame] | 40 | bool renderOffscreen = true; |
Chris Craik | 27e58b4 | 2015-12-07 10:01:38 -0800 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | template <class T> |
| 44 | static test::TestScene* simpleCreateScene(const TestScene::Options&) { |
| 45 | return new T(); |
| 46 | } |
| 47 | |
| 48 | typedef test::TestScene* (*CreateScene)(const TestScene::Options&); |
| 49 | |
| 50 | struct Info { |
| 51 | std::string name; |
| 52 | std::string description; |
| 53 | CreateScene createScene; |
| 54 | }; |
| 55 | |
| 56 | class Registrar { |
| 57 | public: |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 58 | explicit Registrar(const TestScene::Info& info) { TestScene::registerScene(info); } |
| 59 | |
Chris Craik | 27e58b4 | 2015-12-07 10:01:38 -0800 | [diff] [blame] | 60 | private: |
| 61 | Registrar() = delete; |
| 62 | Registrar(const Registrar&) = delete; |
| 63 | Registrar& operator=(const Registrar&) = delete; |
| 64 | }; |
| 65 | |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 66 | virtual ~TestScene() {} |
Stan Iliev | 06152cd | 2016-07-27 17:55:43 -0400 | [diff] [blame] | 67 | virtual void createContent(int width, int height, Canvas& renderer) = 0; |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 68 | virtual void doFrame(int frameNr) = 0; |
Chris Craik | 27e58b4 | 2015-12-07 10:01:38 -0800 | [diff] [blame] | 69 | |
| 70 | static std::unordered_map<std::string, Info>& testMap(); |
| 71 | static void registerScene(const Info& info); |
John Reck | ed024d2 | 2017-11-10 15:06:32 -0800 | [diff] [blame] | 72 | |
| 73 | sp<Surface> renderTarget; |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 74 | }; |
| 75 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 76 | } // namespace test |
| 77 | } // namespace uirenderer |
| 78 | } // namespace android |