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
29class Hwc2TestFenceGenerator;
30class Hwc2TestLayers;
31
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
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
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:
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#endif /* ifndef _HWC2_TEST_BUFFER_H */
75