blob: fd54fef2d703bf1cbbd9e502626ea0ebcdbe3fed [file] [log] [blame]
Marissa Wall5a240aa2016-12-15 12:34:06 -08001/*
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>
Marissa Wallf18cfb02017-02-21 14:01:05 -080021#include <set>
22
Marissa Wall5a240aa2016-12-15 12:34:06 -080023#include <hardware/hwcomposer2.h>
24
Marissa Wall5a240aa2016-12-15 12:34:06 -080025#include <ui/GraphicBuffer.h>
26
27#include "Hwc2TestProperties.h"
28
29class Hwc2TestFenceGenerator;
Marissa Wallf18cfb02017-02-21 14:01:05 -080030class Hwc2TestLayers;
Marissa Wall5a240aa2016-12-15 12:34:06 -080031
32class Hwc2TestBuffer {
33public:
34 Hwc2TestBuffer();
35 ~Hwc2TestBuffer();
36
37 void updateBufferArea(const Area& bufferArea);
38
39 int get(buffer_handle_t* outHandle, int32_t* outFence);
40
41protected:
42 int generateBuffer();
43
Marissa Wall5a240aa2016-12-15 12:34:06 -080044 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
Marissa Wallf18cfb02017-02-21 14:01:05 -080055
56class Hwc2TestClientTargetBuffer {
57public:
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
66protected:
Marissa Wallf18cfb02017-02-21 14:01:05 -080067 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
David Hanna Jr3f056022017-07-27 19:19:15 -070074
75class Hwc2TestVirtualBuffer {
76public:
77 void updateBufferArea(const Area& bufferArea);
78
79 bool writeBufferToFile(std::string path);
80
81 android::sp<android::GraphicBuffer>& graphicBuffer()
82 {
83 return mGraphicBuffer;
84 }
85
86protected:
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
95class Hwc2TestExpectedBuffer : public Hwc2TestVirtualBuffer {
96public:
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
103class Hwc2TestOutputBuffer : public Hwc2TestVirtualBuffer {
104public:
105 int getOutputBuffer(buffer_handle_t* outHandle, int32_t* outFence);
106};
107
Marissa Wall5a240aa2016-12-15 12:34:06 -0800108#endif /* ifndef _HWC2_TEST_BUFFER_H */