1 /*
2  * Copyright 2019 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 <composer-vts/2.2/ReadbackVts.h>
20 #include <math/half.h>
21 #include <math/vec3.h>
22 #include <renderengine/ExternalTexture.h>
23 #include <renderengine/RenderEngine.h>
24 #include <ui/GraphicBuffer.h>
25 #include <ui/PixelFormat.h>
26 #include <ui/Rect.h>
27 #include <ui/Region.h>
28 
29 namespace android {
30 namespace hardware {
31 namespace graphics {
32 namespace composer {
33 namespace V2_2 {
34 namespace vts {
35 
36 using renderengine::DisplaySettings;
37 using renderengine::RenderEngineCreationArgs;
38 
39 class TestRenderEngine {
40   public:
41     static constexpr uint32_t sMaxFrameBufferAcquireBuffers = 2;
42 
43     TestRenderEngine(const RenderEngineCreationArgs& args);
44     ~TestRenderEngine();
45 
46     void setRenderLayers(std::vector<std::shared_ptr<TestLayer>> layers);
47     void initGraphicBuffer(uint32_t width, uint32_t height, uint32_t layerCount, uint64_t usage);
setDisplaySettings(DisplaySettings & displaySettings)48     void setDisplaySettings(DisplaySettings& displaySettings) {
49         mDisplaySettings = displaySettings;
50     };
51     void drawLayers();
52     void checkColorBuffer(std::vector<V2_2::IComposerClient::Color>& expectedColors);
53 
getInternalRenderEngine()54     renderengine::RenderEngine& getInternalRenderEngine() { return *mRenderEngine; }
55 
56   private:
57     common::V1_1::PixelFormat mFormat;
58     std::vector<renderengine::LayerSettings> mCompositionLayers;
59     std::unique_ptr<renderengine::RenderEngine> mRenderEngine;
60     std::vector<renderengine::LayerSettings> mRenderLayers;
61     sp<GraphicBuffer> mGraphicBuffer;
62 
63     DisplaySettings mDisplaySettings;
64 };
65 
66 }  // namespace vts
67 }  // namespace V2_2
68 }  // namespace composer
69 }  // namespace graphics
70 }  // namespace hardware
71 }  // namespace android
72