Marissa Wall | 273b1df | 2016-12-15 12:28:47 -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_LAYERS_H |
| 18 | #define _HWC2_TEST_LAYERS_H |
| 19 | |
| 20 | #include <map> |
| 21 | |
| 22 | #define HWC2_INCLUDE_STRINGIFICATION |
| 23 | #define HWC2_USE_CPP11 |
| 24 | #include <hardware/hwcomposer2.h> |
| 25 | #undef HWC2_INCLUDE_STRINGIFICATION |
| 26 | #undef HWC2_USE_CPP11 |
| 27 | |
| 28 | #include "Hwc2TestProperties.h" |
| 29 | #include "Hwc2TestLayer.h" |
| 30 | |
| 31 | class Hwc2TestLayers { |
| 32 | public: |
| 33 | Hwc2TestLayers(const std::vector<hwc2_layer_t>& layers, |
Marissa Wall | 600a73b | 2016-12-15 12:30:39 -0800 | [diff] [blame] | 34 | Hwc2TestCoverage coverage, const Area& displayArea); |
Marissa Wall | 273b1df | 2016-12-15 12:28:47 -0800 | [diff] [blame] | 35 | |
Marissa Wall | 563030b | 2017-02-21 14:01:05 -0800 | [diff] [blame] | 36 | Hwc2TestLayers(const std::vector<hwc2_layer_t>& layers, |
| 37 | Hwc2TestCoverage coverage, const Area& displayArea, |
| 38 | const std::unordered_map<Hwc2TestPropertyName, |
| 39 | Hwc2TestCoverage>& coverageExceptions); |
| 40 | |
Marissa Wall | 273b1df | 2016-12-15 12:28:47 -0800 | [diff] [blame] | 41 | std::string dump() const; |
| 42 | |
| 43 | void reset(); |
| 44 | |
Marissa Wall | 1cd789c | 2017-01-27 12:55:36 -0800 | [diff] [blame] | 45 | bool advance(); |
Marissa Wall | f7618ed | 2016-12-15 12:34:39 -0800 | [diff] [blame] | 46 | bool advanceVisibleRegions(); |
| 47 | |
Marissa Wall | f18cfb0 | 2017-02-21 14:01:05 -0800 | [diff] [blame] | 48 | /* Test cases with multiple layers and property values can take quite some |
| 49 | * time to run. A significant amount of time can be spent on test cases |
| 50 | * where one layer is changing property values but is not visible. To |
| 51 | * decrease runtime, this function can be called. Removes layouts where a |
| 52 | * layer is completely blocked from view. It also removes layouts that do |
| 53 | * not cover the entire display.*/ |
| 54 | bool optimizeLayouts(); |
| 55 | |
Marissa Wall | 1cd789c | 2017-01-27 12:55:36 -0800 | [diff] [blame] | 56 | bool contains(hwc2_layer_t layer) const; |
| 57 | |
| 58 | int getBuffer(hwc2_layer_t layer, buffer_handle_t* outHandle, |
| 59 | int32_t* outAcquireFence); |
| 60 | |
| 61 | hwc2_blend_mode_t getBlendMode(hwc2_layer_t layer) const; |
Marissa Wall | f18cfb0 | 2017-02-21 14:01:05 -0800 | [diff] [blame] | 62 | Area getBufferArea(hwc2_layer_t layer) const; |
Marissa Wall | 1cd789c | 2017-01-27 12:55:36 -0800 | [diff] [blame] | 63 | hwc_color_t getColor(hwc2_layer_t layer) const; |
| 64 | hwc2_composition_t getComposition(hwc2_layer_t layer) const; |
| 65 | hwc_rect_t getCursorPosition(hwc2_layer_t layer) const; |
Peiyong Lin | 34beb7a | 2018-03-28 11:57:12 -0700 | [diff] [blame] | 66 | android::ui::Dataspace getDataspace(hwc2_layer_t layer) const; |
Marissa Wall | 1cd789c | 2017-01-27 12:55:36 -0800 | [diff] [blame] | 67 | hwc_rect_t getDisplayFrame(hwc2_layer_t layer) const; |
| 68 | android_pixel_format_t getFormat(hwc2_layer_t layer) const; |
| 69 | float getPlaneAlpha(hwc2_layer_t layer) const; |
| 70 | hwc_frect_t getSourceCrop(hwc2_layer_t layer) const; |
| 71 | hwc_region_t getSurfaceDamage(hwc2_layer_t layer) const; |
| 72 | hwc_transform_t getTransform(hwc2_layer_t layer) const; |
| 73 | hwc_region_t getVisibleRegion(hwc2_layer_t layer) const; |
| 74 | uint32_t getZOrder(hwc2_layer_t layer) const; |
Marissa Wall | 273b1df | 2016-12-15 12:28:47 -0800 | [diff] [blame] | 75 | |
| 76 | private: |
Marissa Wall | f18cfb0 | 2017-02-21 14:01:05 -0800 | [diff] [blame] | 77 | bool setVisibleRegions(); |
Marissa Wall | f7618ed | 2016-12-15 12:34:39 -0800 | [diff] [blame] | 78 | |
Marissa Wall | 273b1df | 2016-12-15 12:28:47 -0800 | [diff] [blame] | 79 | std::map<hwc2_layer_t, Hwc2TestLayer> mTestLayers; |
Marissa Wall | 1cd789c | 2017-01-27 12:55:36 -0800 | [diff] [blame] | 80 | |
| 81 | Area mDisplayArea; |
Marissa Wall | f18cfb0 | 2017-02-21 14:01:05 -0800 | [diff] [blame] | 82 | |
| 83 | bool mOptimize = false; |
Marissa Wall | 273b1df | 2016-12-15 12:28:47 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | #endif /* ifndef _HWC2_TEST_LAYERS_H */ |