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