blob: ca60940aa9389236672533d2f28c6ec858b537d5 [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
25#include <gui/GraphicBufferAlloc.h>
26#include <ui/GraphicBuffer.h>
27
28#include "Hwc2TestProperties.h"
29
30class Hwc2TestFenceGenerator;
Marissa Wallf18cfb02017-02-21 14:01:05 -080031class Hwc2TestLayers;
Marissa Wall5a240aa2016-12-15 12:34:06 -080032
33class Hwc2TestBuffer {
34public:
35 Hwc2TestBuffer();
36 ~Hwc2TestBuffer();
37
38 void updateBufferArea(const Area& bufferArea);
39
40 int get(buffer_handle_t* outHandle, int32_t* outFence);
41
42protected:
43 int generateBuffer();
44
Marissa Wall5a240aa2016-12-15 12:34:06 -080045 android::GraphicBufferAlloc mGraphicBufferAlloc;
46 android::sp<android::GraphicBuffer> mGraphicBuffer;
47
48 std::unique_ptr<Hwc2TestFenceGenerator> mFenceGenerator;
49
50 Area mBufferArea = {-1, -1};
51 const android_pixel_format_t mFormat = HAL_PIXEL_FORMAT_RGBA_8888;
52
53 bool mValidBuffer = false;
54 buffer_handle_t mHandle = nullptr;
55};
56
Marissa Wallf18cfb02017-02-21 14:01:05 -080057
58class Hwc2TestClientTargetBuffer {
59public:
60 Hwc2TestClientTargetBuffer();
61 ~Hwc2TestClientTargetBuffer();
62
63 int get(buffer_handle_t* outHandle, int32_t* outFence,
64 const Area& bufferArea, const Hwc2TestLayers* testLayers,
65 const std::set<hwc2_layer_t>* clientLayers,
66 const std::set<hwc2_layer_t>* clearLayers);
67
68protected:
69 android::GraphicBufferAlloc mGraphicBufferAlloc;
70 android::sp<android::GraphicBuffer> mGraphicBuffer;
71
72 std::unique_ptr<Hwc2TestFenceGenerator> mFenceGenerator;
73
74 const android_pixel_format_t mFormat = HAL_PIXEL_FORMAT_RGBA_8888;
75};
76
Marissa Wall5a240aa2016-12-15 12:34:06 -080077#endif /* ifndef _HWC2_TEST_BUFFER_H */