• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 #ifndef _HWC2_TEST_BUFFER_H
18 #define _HWC2_TEST_BUFFER_H
19 
20 #include <android-base/unique_fd.h>
21 #include <set>
22 
23 #include <hardware/hwcomposer2.h>
24 
25 #include <ui/GraphicBuffer.h>
26 
27 #include "Hwc2TestProperties.h"
28 
29 class Hwc2TestFenceGenerator;
30 class Hwc2TestLayers;
31 
32 class Hwc2TestBuffer {
33 public:
34     Hwc2TestBuffer();
35     ~Hwc2TestBuffer();
36 
37     void updateBufferArea(const Area& bufferArea);
38 
39     int  get(buffer_handle_t* outHandle, int32_t* outFence);
40 
41 protected:
42     int generateBuffer();
43 
44     android::sp<android::GraphicBuffer> mGraphicBuffer;
45 
46     std::unique_ptr<Hwc2TestFenceGenerator> mFenceGenerator;
47 
48     Area mBufferArea = {-1, -1};
49     const android_pixel_format_t mFormat = HAL_PIXEL_FORMAT_RGBA_8888;
50 
51     bool mValidBuffer = false;
52     buffer_handle_t mHandle = nullptr;
53 };
54 
55 
56 class Hwc2TestClientTargetBuffer {
57 public:
58     Hwc2TestClientTargetBuffer();
59     ~Hwc2TestClientTargetBuffer();
60 
61     int  get(buffer_handle_t* outHandle, int32_t* outFence,
62             const Area& bufferArea, const Hwc2TestLayers* testLayers,
63             const std::set<hwc2_layer_t>* clientLayers,
64             const std::set<hwc2_layer_t>* clearLayers);
65 
66 protected:
67     android::sp<android::GraphicBuffer> mGraphicBuffer;
68 
69     std::unique_ptr<Hwc2TestFenceGenerator> mFenceGenerator;
70 
71     const android_pixel_format_t mFormat = HAL_PIXEL_FORMAT_RGBA_8888;
72 };
73 
74 
75 class Hwc2TestVirtualBuffer {
76 public:
77     void updateBufferArea(const Area& bufferArea);
78 
79     bool writeBufferToFile(std::string path);
80 
graphicBuffer()81     android::sp<android::GraphicBuffer>& graphicBuffer()
82     {
83         return mGraphicBuffer;
84     }
85 
86 protected:
87     android::sp<android::GraphicBuffer> mGraphicBuffer;
88 
89     Area mBufferArea = {-1, -1};
90 
91     const android_pixel_format_t mFormat = HAL_PIXEL_FORMAT_RGBA_8888;
92 };
93 
94 
95 class Hwc2TestExpectedBuffer : public Hwc2TestVirtualBuffer {
96 public:
97     int generateExpectedBuffer(const Hwc2TestLayers* testLayers,
98             const std::vector<hwc2_layer_t>* allLayers,
99             const std::set<hwc2_layer_t>* clearLayers);
100 };
101 
102 
103 class Hwc2TestOutputBuffer : public Hwc2TestVirtualBuffer {
104 public:
105     int getOutputBuffer(buffer_handle_t* outHandle, int32_t* outFence);
106 };
107 
108 #endif /* ifndef _HWC2_TEST_BUFFER_H */
109