Marissa Wall | 5a240aa | 2016-12-15 12:34:06 -0800 | [diff] [blame^] | 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 <hardware/hwcomposer2.h> |
| 22 | |
| 23 | #include <gui/GraphicBufferAlloc.h> |
| 24 | #include <ui/GraphicBuffer.h> |
| 25 | |
| 26 | #include "Hwc2TestProperties.h" |
| 27 | |
| 28 | class Hwc2TestFenceGenerator; |
| 29 | |
| 30 | class Hwc2TestBuffer { |
| 31 | public: |
| 32 | Hwc2TestBuffer(); |
| 33 | ~Hwc2TestBuffer(); |
| 34 | |
| 35 | void updateBufferArea(const Area& bufferArea); |
| 36 | |
| 37 | int get(buffer_handle_t* outHandle, int32_t* outFence); |
| 38 | |
| 39 | protected: |
| 40 | int generateBuffer(); |
| 41 | |
| 42 | void setColor(int32_t x, int32_t y, android_pixel_format_t format, |
| 43 | uint32_t stride, uint8_t* img, uint8_t r, uint8_t g, uint8_t b, |
| 44 | uint8_t a); |
| 45 | |
| 46 | android::GraphicBufferAlloc mGraphicBufferAlloc; |
| 47 | android::sp<android::GraphicBuffer> mGraphicBuffer; |
| 48 | |
| 49 | std::unique_ptr<Hwc2TestFenceGenerator> mFenceGenerator; |
| 50 | |
| 51 | Area mBufferArea = {-1, -1}; |
| 52 | const android_pixel_format_t mFormat = HAL_PIXEL_FORMAT_RGBA_8888; |
| 53 | |
| 54 | bool mValidBuffer = false; |
| 55 | buffer_handle_t mHandle = nullptr; |
| 56 | }; |
| 57 | |
| 58 | #endif /* ifndef _HWC2_TEST_BUFFER_H */ |