| Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright 2019 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 | #include <compositionengine/impl/OutputLayer.h> | 
| Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 18 | #include <compositionengine/impl/OutputLayerCompositionState.h> | 
| Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 19 | #include <compositionengine/mock/CompositionEngine.h> | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 20 | #include <compositionengine/mock/DisplayColorProfile.h> | 
| Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 21 | #include <compositionengine/mock/LayerFE.h> | 
|  | 22 | #include <compositionengine/mock/Output.h> | 
|  | 23 | #include <gtest/gtest.h> | 
|  | 24 |  | 
| Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 25 | #include "MockHWC2.h" | 
|  | 26 | #include "MockHWComposer.h" | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 27 | #include "RegionMatcher.h" | 
| Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 28 |  | 
| Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 29 | namespace android::compositionengine { | 
|  | 30 | namespace { | 
|  | 31 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 32 | using testing::_; | 
| Lloyd Pique | 46b72df | 2019-10-29 13:19:27 -0700 | [diff] [blame] | 33 | using testing::InSequence; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 34 | using testing::Return; | 
|  | 35 | using testing::ReturnRef; | 
| Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 36 | using testing::StrictMock; | 
|  | 37 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 38 | constexpr auto TR_IDENT = 0u; | 
|  | 39 | constexpr auto TR_FLP_H = HAL_TRANSFORM_FLIP_H; | 
|  | 40 | constexpr auto TR_FLP_V = HAL_TRANSFORM_FLIP_V; | 
|  | 41 | constexpr auto TR_ROT_90 = HAL_TRANSFORM_ROT_90; | 
|  | 42 | constexpr auto TR_ROT_180 = TR_FLP_H | TR_FLP_V; | 
|  | 43 | constexpr auto TR_ROT_270 = TR_ROT_90 | TR_ROT_180; | 
|  | 44 |  | 
|  | 45 | const std::string kOutputName{"Test Output"}; | 
|  | 46 |  | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 47 | MATCHER_P(ColorEq, expected, "") { | 
|  | 48 | *result_listener << "Colors are not equal\n"; | 
|  | 49 | *result_listener << "expected " << expected.r << " " << expected.g << " " << expected.b << " " | 
|  | 50 | << expected.a << "\n"; | 
|  | 51 | *result_listener << "actual " << arg.r << " " << arg.g << " " << arg.b << " " << arg.a << "\n"; | 
|  | 52 |  | 
|  | 53 | return expected.r == arg.r && expected.g == arg.g && expected.b == arg.b && expected.a == arg.a; | 
|  | 54 | } | 
|  | 55 |  | 
| Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 56 | struct OutputLayerTest : public testing::Test { | 
| Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 57 | struct OutputLayer final : public impl::OutputLayer { | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 58 | OutputLayer(const compositionengine::Output& output, sp<compositionengine::LayerFE> layerFE) | 
|  | 59 | : mOutput(output), mLayerFE(layerFE) {} | 
| Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 60 | ~OutputLayer() override = default; | 
|  | 61 |  | 
|  | 62 | // compositionengine::OutputLayer overrides | 
|  | 63 | const compositionengine::Output& getOutput() const override { return mOutput; } | 
| Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 64 | compositionengine::LayerFE& getLayerFE() const override { return *mLayerFE; } | 
|  | 65 | const impl::OutputLayerCompositionState& getState() const override { return mState; } | 
|  | 66 | impl::OutputLayerCompositionState& editState() override { return mState; } | 
|  | 67 |  | 
|  | 68 | // compositionengine::impl::OutputLayer overrides | 
|  | 69 | void dumpState(std::string& out) const override { mState.dump(out); } | 
|  | 70 |  | 
|  | 71 | const compositionengine::Output& mOutput; | 
| Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 72 | sp<compositionengine::LayerFE> mLayerFE; | 
|  | 73 | impl::OutputLayerCompositionState mState; | 
|  | 74 | }; | 
|  | 75 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 76 | OutputLayerTest() { | 
|  | 77 | EXPECT_CALL(*mLayerFE, getDebugName()).WillRepeatedly(Return("Test LayerFE")); | 
|  | 78 | EXPECT_CALL(mOutput, getName()).WillRepeatedly(ReturnRef(kOutputName)); | 
|  | 79 |  | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 80 | EXPECT_CALL(*mLayerFE, getCompositionState()).WillRepeatedly(Return(&mLayerFEState)); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 81 | EXPECT_CALL(mOutput, getState()).WillRepeatedly(ReturnRef(mOutputState)); | 
|  | 82 | } | 
|  | 83 |  | 
| Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 84 | compositionengine::mock::Output mOutput; | 
| Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 85 | sp<compositionengine::mock::LayerFE> mLayerFE{ | 
|  | 86 | new StrictMock<compositionengine::mock::LayerFE>()}; | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 87 | OutputLayer mOutputLayer{mOutput, mLayerFE}; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 88 |  | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 89 | LayerFECompositionState mLayerFEState; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 90 | impl::OutputCompositionState mOutputState; | 
| Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 91 | }; | 
|  | 92 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 93 | /* | 
| Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 94 | * Basic construction | 
|  | 95 | */ | 
|  | 96 |  | 
|  | 97 | TEST_F(OutputLayerTest, canInstantiateOutputLayer) {} | 
|  | 98 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 99 | /* | 
| Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 100 | * OutputLayer::setHwcLayer() | 
| Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 101 | */ | 
|  | 102 |  | 
| Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 103 | TEST_F(OutputLayerTest, settingNullHwcLayerSetsEmptyHwcState) { | 
| Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 104 | StrictMock<compositionengine::mock::CompositionEngine> compositionEngine; | 
|  | 105 |  | 
| Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 106 | mOutputLayer.setHwcLayer(nullptr); | 
| Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 107 |  | 
|  | 108 | EXPECT_FALSE(mOutputLayer.getState().hwc); | 
|  | 109 | } | 
|  | 110 |  | 
| Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 111 | TEST_F(OutputLayerTest, settingHwcLayerSetsHwcState) { | 
|  | 112 | auto hwcLayer = std::make_shared<StrictMock<HWC2::mock::Layer>>(); | 
| Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 113 |  | 
| Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 114 | mOutputLayer.setHwcLayer(hwcLayer); | 
| Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 115 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 116 | const auto& outputLayerState = mOutputLayer.getState(); | 
|  | 117 | ASSERT_TRUE(outputLayerState.hwc); | 
| Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 118 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 119 | const auto& hwcState = *outputLayerState.hwc; | 
| Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 120 | EXPECT_EQ(hwcLayer, hwcState.hwcLayer); | 
| Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 121 | } | 
|  | 122 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 123 | /* | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 124 | * OutputLayer::calculateOutputSourceCrop() | 
|  | 125 | */ | 
|  | 126 |  | 
|  | 127 | struct OutputLayerSourceCropTest : public OutputLayerTest { | 
|  | 128 | OutputLayerSourceCropTest() { | 
|  | 129 | // Set reasonable default values for a simple case. Each test will | 
|  | 130 | // set one specific value to something different. | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 131 | mLayerFEState.geomUsesSourceCrop = true; | 
|  | 132 | mLayerFEState.geomContentCrop = Rect{0, 0, 1920, 1080}; | 
|  | 133 | mLayerFEState.transparentRegionHint = Region{}; | 
|  | 134 | mLayerFEState.geomLayerBounds = FloatRect{0.f, 0.f, 1920.f, 1080.f}; | 
|  | 135 | mLayerFEState.geomLayerTransform = ui::Transform{TR_IDENT}; | 
|  | 136 | mLayerFEState.geomBufferSize = Rect{0, 0, 1920, 1080}; | 
|  | 137 | mLayerFEState.geomBufferTransform = TR_IDENT; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 138 |  | 
|  | 139 | mOutputState.viewport = Rect{0, 0, 1920, 1080}; | 
|  | 140 | } | 
|  | 141 |  | 
|  | 142 | FloatRect calculateOutputSourceCrop() { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 143 | mLayerFEState.geomInverseLayerTransform = mLayerFEState.geomLayerTransform.inverse(); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 144 |  | 
|  | 145 | return mOutputLayer.calculateOutputSourceCrop(); | 
|  | 146 | } | 
|  | 147 | }; | 
|  | 148 |  | 
|  | 149 | TEST_F(OutputLayerSourceCropTest, computesEmptyIfSourceCropNotUsed) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 150 | mLayerFEState.geomUsesSourceCrop = false; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 151 |  | 
|  | 152 | const FloatRect expected{}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 153 | EXPECT_THAT(calculateOutputSourceCrop(), expected); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 154 | } | 
|  | 155 |  | 
|  | 156 | TEST_F(OutputLayerSourceCropTest, correctForSimpleDefaultCase) { | 
|  | 157 | const FloatRect expected{0.f, 0.f, 1920.f, 1080.f}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 158 | EXPECT_THAT(calculateOutputSourceCrop(), expected); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 159 | } | 
|  | 160 |  | 
|  | 161 | TEST_F(OutputLayerSourceCropTest, handlesBoundsOutsideViewport) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 162 | mLayerFEState.geomLayerBounds = FloatRect{-2000.f, -2000.f, 2000.f, 2000.f}; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 163 |  | 
|  | 164 | const FloatRect expected{0.f, 0.f, 1920.f, 1080.f}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 165 | EXPECT_THAT(calculateOutputSourceCrop(), expected); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 166 | } | 
|  | 167 |  | 
|  | 168 | TEST_F(OutputLayerSourceCropTest, handlesBoundsOutsideViewportRotated) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 169 | mLayerFEState.geomLayerBounds = FloatRect{-2000.f, -2000.f, 2000.f, 2000.f}; | 
|  | 170 | mLayerFEState.geomLayerTransform.set(HAL_TRANSFORM_ROT_90, 1920, 1080); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 171 |  | 
|  | 172 | const FloatRect expected{0.f, 0.f, 1080.f, 1080.f}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 173 | EXPECT_THAT(calculateOutputSourceCrop(), expected); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 174 | } | 
|  | 175 |  | 
|  | 176 | TEST_F(OutputLayerSourceCropTest, calculateOutputSourceCropWorksWithATransformedBuffer) { | 
|  | 177 | struct Entry { | 
|  | 178 | uint32_t bufferInvDisplay; | 
|  | 179 | uint32_t buffer; | 
|  | 180 | uint32_t display; | 
|  | 181 | FloatRect expected; | 
|  | 182 | }; | 
|  | 183 | // Not an exhaustive list of cases, but hopefully enough. | 
|  | 184 | const std::array<Entry, 12> testData = { | 
|  | 185 | // clang-format off | 
|  | 186 | //             inv      buffer      display     expected | 
|  | 187 | /*  0 */ Entry{false,   TR_IDENT,   TR_IDENT,   FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 188 | /*  1 */ Entry{false,   TR_IDENT,   TR_ROT_90,  FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 189 | /*  2 */ Entry{false,   TR_IDENT,   TR_ROT_180, FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 190 | /*  3 */ Entry{false,   TR_IDENT,   TR_ROT_270, FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 191 |  | 
|  | 192 | /*  4 */ Entry{true,    TR_IDENT,   TR_IDENT,   FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 193 | /*  5 */ Entry{true,    TR_IDENT,   TR_ROT_90,  FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 194 | /*  6 */ Entry{true,    TR_IDENT,   TR_ROT_180, FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 195 | /*  7 */ Entry{true,    TR_IDENT,   TR_ROT_270, FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 196 |  | 
|  | 197 | /*  8 */ Entry{false,   TR_IDENT,   TR_IDENT,   FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 198 | /*  9 */ Entry{false,   TR_ROT_90,  TR_ROT_90,  FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 199 | /* 10 */ Entry{false,   TR_ROT_180, TR_ROT_180, FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 200 | /* 11 */ Entry{false,   TR_ROT_270, TR_ROT_270, FloatRect{0.f, 0.f, 1920.f, 1080.f}}, | 
|  | 201 |  | 
|  | 202 | // clang-format on | 
|  | 203 | }; | 
|  | 204 |  | 
|  | 205 | for (size_t i = 0; i < testData.size(); i++) { | 
|  | 206 | const auto& entry = testData[i]; | 
|  | 207 |  | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 208 | mLayerFEState.geomBufferUsesDisplayInverseTransform = entry.bufferInvDisplay; | 
|  | 209 | mLayerFEState.geomBufferTransform = entry.buffer; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 210 | mOutputState.orientation = entry.display; | 
|  | 211 |  | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 212 | EXPECT_THAT(calculateOutputSourceCrop(), entry.expected) << "entry " << i; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 213 | } | 
|  | 214 | } | 
|  | 215 |  | 
|  | 216 | TEST_F(OutputLayerSourceCropTest, geomContentCropAffectsCrop) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 217 | mLayerFEState.geomContentCrop = Rect{0, 0, 960, 540}; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 218 |  | 
|  | 219 | const FloatRect expected{0.f, 0.f, 960.f, 540.f}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 220 | EXPECT_THAT(calculateOutputSourceCrop(), expected); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 221 | } | 
|  | 222 |  | 
|  | 223 | TEST_F(OutputLayerSourceCropTest, viewportAffectsCrop) { | 
|  | 224 | mOutputState.viewport = Rect{0, 0, 960, 540}; | 
|  | 225 |  | 
|  | 226 | const FloatRect expected{0.f, 0.f, 960.f, 540.f}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 227 | EXPECT_THAT(calculateOutputSourceCrop(), expected); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 228 | } | 
|  | 229 |  | 
|  | 230 | /* | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 231 | * OutputLayer::calculateOutputDisplayFrame() | 
|  | 232 | */ | 
|  | 233 |  | 
|  | 234 | struct OutputLayerDisplayFrameTest : public OutputLayerTest { | 
|  | 235 | OutputLayerDisplayFrameTest() { | 
|  | 236 | // Set reasonable default values for a simple case. Each test will | 
|  | 237 | // set one specific value to something different. | 
|  | 238 |  | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 239 | mLayerFEState.transparentRegionHint = Region{}; | 
|  | 240 | mLayerFEState.geomLayerTransform = ui::Transform{TR_IDENT}; | 
|  | 241 | mLayerFEState.geomBufferSize = Rect{0, 0, 1920, 1080}; | 
|  | 242 | mLayerFEState.geomBufferUsesDisplayInverseTransform = false; | 
|  | 243 | mLayerFEState.geomCrop = Rect{0, 0, 1920, 1080}; | 
|  | 244 | mLayerFEState.geomLayerBounds = FloatRect{0.f, 0.f, 1920.f, 1080.f}; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 245 |  | 
|  | 246 | mOutputState.viewport = Rect{0, 0, 1920, 1080}; | 
|  | 247 | mOutputState.transform = ui::Transform{TR_IDENT}; | 
|  | 248 | } | 
|  | 249 |  | 
|  | 250 | Rect calculateOutputDisplayFrame() { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 251 | mLayerFEState.geomInverseLayerTransform = mLayerFEState.geomLayerTransform.inverse(); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 252 |  | 
|  | 253 | return mOutputLayer.calculateOutputDisplayFrame(); | 
|  | 254 | } | 
|  | 255 | }; | 
|  | 256 |  | 
|  | 257 | TEST_F(OutputLayerDisplayFrameTest, correctForSimpleDefaultCase) { | 
|  | 258 | const Rect expected{0, 0, 1920, 1080}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 259 | EXPECT_THAT(calculateOutputDisplayFrame(), expected); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 260 | } | 
|  | 261 |  | 
|  | 262 | TEST_F(OutputLayerDisplayFrameTest, fullActiveTransparentRegionReturnsEmptyFrame) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 263 | mLayerFEState.transparentRegionHint = Region{Rect{0, 0, 1920, 1080}}; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 264 | const Rect expected{0, 0, 0, 0}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 265 | EXPECT_THAT(calculateOutputDisplayFrame(), expected); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 266 | } | 
|  | 267 |  | 
|  | 268 | TEST_F(OutputLayerDisplayFrameTest, cropAffectsDisplayFrame) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 269 | mLayerFEState.geomCrop = Rect{100, 200, 300, 500}; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 270 | const Rect expected{100, 200, 300, 500}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 271 | EXPECT_THAT(calculateOutputDisplayFrame(), expected); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 272 | } | 
|  | 273 |  | 
|  | 274 | TEST_F(OutputLayerDisplayFrameTest, cropAffectsDisplayFrameRotated) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 275 | mLayerFEState.geomCrop = Rect{100, 200, 300, 500}; | 
|  | 276 | mLayerFEState.geomLayerTransform.set(HAL_TRANSFORM_ROT_90, 1920, 1080); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 277 | const Rect expected{1420, 100, 1720, 300}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 278 | EXPECT_THAT(calculateOutputDisplayFrame(), expected); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 279 | } | 
|  | 280 |  | 
|  | 281 | TEST_F(OutputLayerDisplayFrameTest, emptyGeomCropIsNotUsedToComputeFrame) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 282 | mLayerFEState.geomCrop = Rect{}; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 283 | const Rect expected{0, 0, 1920, 1080}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 284 | EXPECT_THAT(calculateOutputDisplayFrame(), expected); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 285 | } | 
|  | 286 |  | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 287 | TEST_F(OutputLayerDisplayFrameTest, geomLayerBoundsAffectsFrame) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 288 | mLayerFEState.geomLayerBounds = FloatRect{0.f, 0.f, 960.f, 540.f}; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 289 | const Rect expected{0, 0, 960, 540}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 290 | EXPECT_THAT(calculateOutputDisplayFrame(), expected); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 291 | } | 
|  | 292 |  | 
|  | 293 | TEST_F(OutputLayerDisplayFrameTest, viewportAffectsFrame) { | 
|  | 294 | mOutputState.viewport = Rect{0, 0, 960, 540}; | 
|  | 295 | const Rect expected{0, 0, 960, 540}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 296 | EXPECT_THAT(calculateOutputDisplayFrame(), expected); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 297 | } | 
|  | 298 |  | 
|  | 299 | TEST_F(OutputLayerDisplayFrameTest, outputTransformAffectsDisplayFrame) { | 
|  | 300 | mOutputState.transform = ui::Transform{HAL_TRANSFORM_ROT_90}; | 
|  | 301 | const Rect expected{-1080, 0, 0, 1920}; | 
| Lloyd Pique | ea62928 | 2019-12-03 15:57:10 -0800 | [diff] [blame] | 302 | EXPECT_THAT(calculateOutputDisplayFrame(), expected); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 303 | } | 
|  | 304 |  | 
|  | 305 | /* | 
|  | 306 | * OutputLayer::calculateOutputRelativeBufferTransform() | 
|  | 307 | */ | 
|  | 308 |  | 
|  | 309 | TEST_F(OutputLayerTest, calculateOutputRelativeBufferTransformTestsNeeded) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 310 | mLayerFEState.geomBufferUsesDisplayInverseTransform = false; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 311 |  | 
|  | 312 | struct Entry { | 
|  | 313 | uint32_t layer; | 
|  | 314 | uint32_t buffer; | 
|  | 315 | uint32_t display; | 
|  | 316 | uint32_t expected; | 
|  | 317 | }; | 
|  | 318 | // Not an exhaustive list of cases, but hopefully enough. | 
|  | 319 | const std::array<Entry, 24> testData = { | 
|  | 320 | // clang-format off | 
|  | 321 | //             layer       buffer      display     expected | 
|  | 322 | /*  0 */ Entry{TR_IDENT,   TR_IDENT,   TR_IDENT,   TR_IDENT}, | 
|  | 323 | /*  1 */ Entry{TR_IDENT,   TR_IDENT,   TR_ROT_90,  TR_ROT_90}, | 
|  | 324 | /*  2 */ Entry{TR_IDENT,   TR_IDENT,   TR_ROT_180, TR_ROT_180}, | 
|  | 325 | /*  3 */ Entry{TR_IDENT,   TR_IDENT,   TR_ROT_270, TR_ROT_270}, | 
|  | 326 |  | 
|  | 327 | /*  4 */ Entry{TR_IDENT,   TR_FLP_H,   TR_IDENT,   TR_FLP_H ^ TR_IDENT}, | 
|  | 328 | /*  5 */ Entry{TR_IDENT,   TR_FLP_H,   TR_ROT_90,  TR_FLP_H ^ TR_ROT_90}, | 
|  | 329 | /*  6 */ Entry{TR_IDENT,   TR_FLP_H,   TR_ROT_180, TR_FLP_H ^ TR_ROT_180}, | 
|  | 330 | /*  7 */ Entry{TR_IDENT,   TR_FLP_H,   TR_ROT_270, TR_FLP_H ^ TR_ROT_270}, | 
|  | 331 |  | 
|  | 332 | /*  8 */ Entry{TR_IDENT,   TR_FLP_V,   TR_IDENT,   TR_FLP_V}, | 
|  | 333 | /*  9 */ Entry{TR_IDENT,   TR_ROT_90,  TR_ROT_90,  TR_ROT_180}, | 
|  | 334 | /* 10 */ Entry{TR_IDENT,   TR_ROT_180, TR_ROT_180, TR_IDENT}, | 
|  | 335 | /* 11 */ Entry{TR_IDENT,   TR_ROT_270, TR_ROT_270, TR_ROT_180}, | 
|  | 336 |  | 
|  | 337 | /* 12 */ Entry{TR_ROT_90,  TR_IDENT,   TR_IDENT,   TR_IDENT ^ TR_ROT_90}, | 
|  | 338 | /* 13 */ Entry{TR_ROT_90,  TR_FLP_H,   TR_ROT_90,  TR_FLP_H ^ TR_ROT_180}, | 
|  | 339 | /* 14 */ Entry{TR_ROT_90,  TR_IDENT,   TR_ROT_180, TR_IDENT ^ TR_ROT_270}, | 
|  | 340 | /* 15 */ Entry{TR_ROT_90,  TR_FLP_H,   TR_ROT_270, TR_FLP_H ^ TR_IDENT}, | 
|  | 341 |  | 
|  | 342 | /* 16 */ Entry{TR_ROT_180, TR_FLP_H,   TR_IDENT,   TR_FLP_H ^ TR_ROT_180}, | 
|  | 343 | /* 17 */ Entry{TR_ROT_180, TR_IDENT,   TR_ROT_90,  TR_IDENT ^ TR_ROT_270}, | 
|  | 344 | /* 18 */ Entry{TR_ROT_180, TR_FLP_H,   TR_ROT_180, TR_FLP_H ^ TR_IDENT}, | 
|  | 345 | /* 19 */ Entry{TR_ROT_180, TR_IDENT,   TR_ROT_270, TR_IDENT ^ TR_ROT_90}, | 
|  | 346 |  | 
|  | 347 | /* 20 */ Entry{TR_ROT_270, TR_IDENT,   TR_IDENT,   TR_IDENT ^ TR_ROT_270}, | 
|  | 348 | /* 21 */ Entry{TR_ROT_270, TR_FLP_H,   TR_ROT_90,  TR_FLP_H ^ TR_IDENT}, | 
|  | 349 | /* 22 */ Entry{TR_ROT_270, TR_FLP_H,   TR_ROT_180, TR_FLP_H ^ TR_ROT_90}, | 
|  | 350 | /* 23 */ Entry{TR_ROT_270, TR_IDENT,   TR_ROT_270, TR_IDENT ^ TR_ROT_180}, | 
|  | 351 | // clang-format on | 
|  | 352 | }; | 
|  | 353 |  | 
|  | 354 | for (size_t i = 0; i < testData.size(); i++) { | 
|  | 355 | const auto& entry = testData[i]; | 
|  | 356 |  | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 357 | mLayerFEState.geomLayerTransform.set(entry.layer, 1920, 1080); | 
|  | 358 | mLayerFEState.geomBufferTransform = entry.buffer; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 359 | mOutputState.orientation = entry.display; | 
| Rashed Abdel-Tawab | 6643cd8 | 2019-10-29 10:01:56 -0700 | [diff] [blame] | 360 | mOutputState.transform = ui::Transform{entry.display}; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 361 |  | 
|  | 362 | auto actual = mOutputLayer.calculateOutputRelativeBufferTransform(); | 
|  | 363 | EXPECT_EQ(entry.expected, actual) << "entry " << i; | 
|  | 364 | } | 
|  | 365 | } | 
|  | 366 |  | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 367 | TEST_F(OutputLayerTest, | 
|  | 368 | calculateOutputRelativeBufferTransformTestWithOfBufferUsesDisplayInverseTransform) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 369 | mLayerFEState.geomBufferUsesDisplayInverseTransform = true; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 370 |  | 
|  | 371 | struct Entry { | 
|  | 372 | uint32_t layer; | 
|  | 373 | uint32_t buffer; | 
|  | 374 | uint32_t display; | 
|  | 375 | uint32_t expected; | 
|  | 376 | }; | 
|  | 377 | // Not an exhaustive list of cases, but hopefully enough. | 
|  | 378 | const std::array<Entry, 24> testData = { | 
|  | 379 | // clang-format off | 
|  | 380 | //             layer       buffer      display     expected | 
|  | 381 | /*  0 */ Entry{TR_IDENT,   TR_IDENT,   TR_IDENT,   TR_IDENT}, | 
|  | 382 | /*  1 */ Entry{TR_IDENT,   TR_IDENT,   TR_ROT_90,  TR_IDENT}, | 
|  | 383 | /*  2 */ Entry{TR_IDENT,   TR_IDENT,   TR_ROT_180, TR_IDENT}, | 
|  | 384 | /*  3 */ Entry{TR_IDENT,   TR_IDENT,   TR_ROT_270, TR_IDENT}, | 
|  | 385 |  | 
|  | 386 | /*  4 */ Entry{TR_IDENT,   TR_FLP_H,   TR_IDENT,   TR_FLP_H}, | 
|  | 387 | /*  5 */ Entry{TR_IDENT,   TR_FLP_H,   TR_ROT_90,  TR_FLP_H}, | 
|  | 388 | /*  6 */ Entry{TR_IDENT,   TR_FLP_H,   TR_ROT_180, TR_FLP_H}, | 
|  | 389 | /*  7 */ Entry{TR_IDENT,   TR_FLP_H,   TR_ROT_270, TR_FLP_H}, | 
|  | 390 |  | 
|  | 391 | /*  8 */ Entry{TR_IDENT,   TR_FLP_V,   TR_IDENT,   TR_FLP_V}, | 
|  | 392 | /*  9 */ Entry{TR_IDENT,   TR_ROT_90,  TR_ROT_90,  TR_ROT_90}, | 
|  | 393 | /* 10 */ Entry{TR_IDENT,   TR_ROT_180, TR_ROT_180, TR_ROT_180}, | 
|  | 394 | /* 11 */ Entry{TR_IDENT,   TR_ROT_270, TR_ROT_270, TR_ROT_270}, | 
|  | 395 |  | 
|  | 396 | /* 12 */ Entry{TR_ROT_90,  TR_IDENT,   TR_IDENT,   TR_IDENT}, | 
|  | 397 | /* 13 */ Entry{TR_ROT_90,  TR_FLP_H,   TR_ROT_90,  TR_FLP_H}, | 
|  | 398 | /* 14 */ Entry{TR_ROT_90,  TR_IDENT,   TR_ROT_180, TR_IDENT}, | 
|  | 399 | /* 15 */ Entry{TR_ROT_90,  TR_FLP_H,   TR_ROT_270, TR_FLP_H}, | 
|  | 400 |  | 
|  | 401 | /* 16 */ Entry{TR_ROT_180, TR_FLP_H,   TR_IDENT,   TR_FLP_H}, | 
|  | 402 | /* 17 */ Entry{TR_ROT_180, TR_IDENT,   TR_ROT_90,  TR_IDENT}, | 
|  | 403 | /* 18 */ Entry{TR_ROT_180, TR_FLP_H,   TR_ROT_180, TR_FLP_H}, | 
|  | 404 | /* 19 */ Entry{TR_ROT_180, TR_IDENT,   TR_ROT_270, TR_IDENT}, | 
|  | 405 |  | 
|  | 406 | /* 20 */ Entry{TR_ROT_270, TR_IDENT,   TR_IDENT,   TR_IDENT}, | 
|  | 407 | /* 21 */ Entry{TR_ROT_270, TR_FLP_H,   TR_ROT_90,  TR_FLP_H}, | 
|  | 408 | /* 22 */ Entry{TR_ROT_270, TR_FLP_H,   TR_ROT_180, TR_FLP_H}, | 
|  | 409 | /* 23 */ Entry{TR_ROT_270, TR_IDENT,   TR_ROT_270, TR_IDENT}, | 
|  | 410 | // clang-format on | 
|  | 411 | }; | 
|  | 412 |  | 
|  | 413 | for (size_t i = 0; i < testData.size(); i++) { | 
|  | 414 | const auto& entry = testData[i]; | 
|  | 415 |  | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 416 | mLayerFEState.geomLayerTransform = ui::Transform{entry.layer}; | 
|  | 417 | mLayerFEState.geomBufferTransform = entry.buffer; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 418 | mOutputState.orientation = entry.display; | 
| Rashed Abdel-Tawab | 6643cd8 | 2019-10-29 10:01:56 -0700 | [diff] [blame] | 419 | mOutputState.transform = ui::Transform{entry.display}; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 420 |  | 
|  | 421 | auto actual = mOutputLayer.calculateOutputRelativeBufferTransform(); | 
|  | 422 | EXPECT_EQ(entry.expected, actual) << "entry " << i; | 
|  | 423 | } | 
|  | 424 | } | 
|  | 425 |  | 
|  | 426 | /* | 
|  | 427 | * OutputLayer::updateCompositionState() | 
|  | 428 | */ | 
|  | 429 |  | 
|  | 430 | struct OutputLayerPartialMockForUpdateCompositionState : public impl::OutputLayer { | 
|  | 431 | OutputLayerPartialMockForUpdateCompositionState(const compositionengine::Output& output, | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 432 | sp<compositionengine::LayerFE> layerFE) | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 433 | : mOutput(output), mLayerFE(layerFE) {} | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 434 | // Mock everything called by updateCompositionState to simplify testing it. | 
|  | 435 | MOCK_CONST_METHOD0(calculateOutputSourceCrop, FloatRect()); | 
|  | 436 | MOCK_CONST_METHOD0(calculateOutputDisplayFrame, Rect()); | 
|  | 437 | MOCK_CONST_METHOD0(calculateOutputRelativeBufferTransform, uint32_t()); | 
| Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 438 |  | 
|  | 439 | // compositionengine::OutputLayer overrides | 
|  | 440 | const compositionengine::Output& getOutput() const override { return mOutput; } | 
| Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 441 | compositionengine::LayerFE& getLayerFE() const override { return *mLayerFE; } | 
|  | 442 | const impl::OutputLayerCompositionState& getState() const override { return mState; } | 
|  | 443 | impl::OutputLayerCompositionState& editState() override { return mState; } | 
|  | 444 |  | 
|  | 445 | // These need implementations though are not expected to be called. | 
|  | 446 | MOCK_CONST_METHOD1(dumpState, void(std::string&)); | 
|  | 447 |  | 
|  | 448 | const compositionengine::Output& mOutput; | 
| Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 449 | sp<compositionengine::LayerFE> mLayerFE; | 
|  | 450 | impl::OutputLayerCompositionState mState; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 451 | }; | 
|  | 452 |  | 
|  | 453 | struct OutputLayerUpdateCompositionStateTest : public OutputLayerTest { | 
|  | 454 | public: | 
|  | 455 | OutputLayerUpdateCompositionStateTest() { | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 456 | EXPECT_CALL(mOutput, getState()).WillRepeatedly(ReturnRef(mOutputState)); | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 457 | EXPECT_CALL(mOutput, getDisplayColorProfile()) | 
|  | 458 | .WillRepeatedly(Return(&mDisplayColorProfile)); | 
|  | 459 | EXPECT_CALL(mDisplayColorProfile, isDataspaceSupported(_)).WillRepeatedly(Return(true)); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 460 | } | 
|  | 461 |  | 
|  | 462 | ~OutputLayerUpdateCompositionStateTest() = default; | 
|  | 463 |  | 
|  | 464 | void setupGeometryChildCallValues() { | 
|  | 465 | EXPECT_CALL(mOutputLayer, calculateOutputSourceCrop()).WillOnce(Return(kSourceCrop)); | 
|  | 466 | EXPECT_CALL(mOutputLayer, calculateOutputDisplayFrame()).WillOnce(Return(kDisplayFrame)); | 
|  | 467 | EXPECT_CALL(mOutputLayer, calculateOutputRelativeBufferTransform()) | 
|  | 468 | .WillOnce(Return(mBufferTransform)); | 
|  | 469 | } | 
|  | 470 |  | 
|  | 471 | void validateComputedGeometryState() { | 
|  | 472 | const auto& state = mOutputLayer.getState(); | 
|  | 473 | EXPECT_EQ(kSourceCrop, state.sourceCrop); | 
|  | 474 | EXPECT_EQ(kDisplayFrame, state.displayFrame); | 
|  | 475 | EXPECT_EQ(static_cast<Hwc2::Transform>(mBufferTransform), state.bufferTransform); | 
|  | 476 | } | 
|  | 477 |  | 
|  | 478 | const FloatRect kSourceCrop{1.f, 2.f, 3.f, 4.f}; | 
|  | 479 | const Rect kDisplayFrame{11, 12, 13, 14}; | 
|  | 480 | uint32_t mBufferTransform{21}; | 
|  | 481 |  | 
|  | 482 | using OutputLayer = OutputLayerPartialMockForUpdateCompositionState; | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 483 | StrictMock<OutputLayer> mOutputLayer{mOutput, mLayerFE}; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 484 | StrictMock<mock::DisplayColorProfile> mDisplayColorProfile; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 485 | }; | 
|  | 486 |  | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 487 | TEST_F(OutputLayerUpdateCompositionStateTest, doesNothingIfNoFECompositionState) { | 
|  | 488 | EXPECT_CALL(*mLayerFE, getCompositionState()).WillOnce(Return(nullptr)); | 
|  | 489 |  | 
|  | 490 | mOutputLayer.updateCompositionState(true, false); | 
|  | 491 | } | 
|  | 492 |  | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 493 | TEST_F(OutputLayerUpdateCompositionStateTest, setsStateNormally) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 494 | mLayerFEState.isSecure = true; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 495 | mOutputState.isSecure = true; | 
| Lloyd Pique | fe67102 | 2019-09-24 10:43:03 -0700 | [diff] [blame] | 496 | mOutputLayer.editState().forceClientComposition = true; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 497 |  | 
|  | 498 | setupGeometryChildCallValues(); | 
|  | 499 |  | 
| Lloyd Pique | 7a23491 | 2019-10-03 11:54:27 -0700 | [diff] [blame] | 500 | mOutputLayer.updateCompositionState(true, false); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 501 |  | 
|  | 502 | validateComputedGeometryState(); | 
|  | 503 |  | 
|  | 504 | EXPECT_EQ(false, mOutputLayer.getState().forceClientComposition); | 
|  | 505 | } | 
|  | 506 |  | 
|  | 507 | TEST_F(OutputLayerUpdateCompositionStateTest, | 
|  | 508 | alsoSetsForceCompositionIfSecureLayerOnNonsecureOutput) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 509 | mLayerFEState.isSecure = true; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 510 | mOutputState.isSecure = false; | 
|  | 511 |  | 
|  | 512 | setupGeometryChildCallValues(); | 
|  | 513 |  | 
| Lloyd Pique | 7a23491 | 2019-10-03 11:54:27 -0700 | [diff] [blame] | 514 | mOutputLayer.updateCompositionState(true, false); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 515 |  | 
|  | 516 | validateComputedGeometryState(); | 
|  | 517 |  | 
|  | 518 | EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); | 
|  | 519 | } | 
|  | 520 |  | 
|  | 521 | TEST_F(OutputLayerUpdateCompositionStateTest, | 
|  | 522 | alsoSetsForceCompositionIfUnsupportedBufferTransform) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 523 | mLayerFEState.isSecure = true; | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 524 | mOutputState.isSecure = true; | 
|  | 525 |  | 
|  | 526 | mBufferTransform = ui::Transform::ROT_INVALID; | 
|  | 527 |  | 
|  | 528 | setupGeometryChildCallValues(); | 
|  | 529 |  | 
| Lloyd Pique | 7a23491 | 2019-10-03 11:54:27 -0700 | [diff] [blame] | 530 | mOutputLayer.updateCompositionState(true, false); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 531 |  | 
|  | 532 | validateComputedGeometryState(); | 
|  | 533 |  | 
|  | 534 | EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); | 
|  | 535 | } | 
|  | 536 |  | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 537 | TEST_F(OutputLayerUpdateCompositionStateTest, setsOutputLayerColorspaceCorrectly) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 538 | mLayerFEState.dataspace = ui::Dataspace::DISPLAY_P3; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 539 | mOutputState.targetDataspace = ui::Dataspace::V0_SCRGB; | 
|  | 540 |  | 
|  | 541 | // If the layer is not colorspace agnostic, the output layer dataspace | 
|  | 542 | // should use the layers requested colorspace. | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 543 | mLayerFEState.isColorspaceAgnostic = false; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 544 |  | 
| Lloyd Pique | 7a23491 | 2019-10-03 11:54:27 -0700 | [diff] [blame] | 545 | mOutputLayer.updateCompositionState(false, false); | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 546 |  | 
|  | 547 | EXPECT_EQ(ui::Dataspace::DISPLAY_P3, mOutputLayer.getState().dataspace); | 
|  | 548 |  | 
|  | 549 | // If the layer is colorspace agnostic, the output layer dataspace | 
|  | 550 | // should use the colorspace chosen for the whole output. | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 551 | mLayerFEState.isColorspaceAgnostic = true; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 552 |  | 
| Lloyd Pique | 7a23491 | 2019-10-03 11:54:27 -0700 | [diff] [blame] | 553 | mOutputLayer.updateCompositionState(false, false); | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 554 |  | 
|  | 555 | EXPECT_EQ(ui::Dataspace::V0_SCRGB, mOutputLayer.getState().dataspace); | 
|  | 556 | } | 
|  | 557 |  | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 558 | TEST_F(OutputLayerUpdateCompositionStateTest, doesNotRecomputeGeometryIfNotRequested) { | 
| Lloyd Pique | fe67102 | 2019-09-24 10:43:03 -0700 | [diff] [blame] | 559 | mOutputLayer.editState().forceClientComposition = false; | 
|  | 560 |  | 
| Lloyd Pique | 7a23491 | 2019-10-03 11:54:27 -0700 | [diff] [blame] | 561 | mOutputLayer.updateCompositionState(false, false); | 
| Lloyd Pique | 67e3d9b | 2019-03-22 23:09:28 +0000 | [diff] [blame] | 562 |  | 
|  | 563 | EXPECT_EQ(false, mOutputLayer.getState().forceClientComposition); | 
|  | 564 | } | 
|  | 565 |  | 
| Lloyd Pique | fe67102 | 2019-09-24 10:43:03 -0700 | [diff] [blame] | 566 | TEST_F(OutputLayerUpdateCompositionStateTest, | 
|  | 567 | doesNotClearForceClientCompositionIfNotDoingGeometry) { | 
|  | 568 | mOutputLayer.editState().forceClientComposition = true; | 
|  | 569 |  | 
| Lloyd Pique | 7a23491 | 2019-10-03 11:54:27 -0700 | [diff] [blame] | 570 | mOutputLayer.updateCompositionState(false, false); | 
| Lloyd Pique | fe67102 | 2019-09-24 10:43:03 -0700 | [diff] [blame] | 571 |  | 
|  | 572 | EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); | 
|  | 573 | } | 
|  | 574 |  | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 575 | TEST_F(OutputLayerUpdateCompositionStateTest, clientCompositionForcedFromFrontEndFlagAtAnyTime) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 576 | mLayerFEState.forceClientComposition = true; | 
| Lloyd Pique | fe67102 | 2019-09-24 10:43:03 -0700 | [diff] [blame] | 577 | mOutputLayer.editState().forceClientComposition = false; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 578 |  | 
| Lloyd Pique | 7a23491 | 2019-10-03 11:54:27 -0700 | [diff] [blame] | 579 | mOutputLayer.updateCompositionState(false, false); | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 580 |  | 
|  | 581 | EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); | 
|  | 582 | } | 
|  | 583 |  | 
|  | 584 | TEST_F(OutputLayerUpdateCompositionStateTest, | 
|  | 585 | clientCompositionForcedFromUnsupportedDataspaceAtAnyTime) { | 
| Lloyd Pique | fe67102 | 2019-09-24 10:43:03 -0700 | [diff] [blame] | 586 | mOutputLayer.editState().forceClientComposition = false; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 587 | EXPECT_CALL(mDisplayColorProfile, isDataspaceSupported(_)).WillRepeatedly(Return(false)); | 
|  | 588 |  | 
| Lloyd Pique | 7a23491 | 2019-10-03 11:54:27 -0700 | [diff] [blame] | 589 | mOutputLayer.updateCompositionState(false, false); | 
|  | 590 |  | 
|  | 591 | EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); | 
|  | 592 | } | 
|  | 593 |  | 
|  | 594 | TEST_F(OutputLayerUpdateCompositionStateTest, clientCompositionForcedFromArgumentFlag) { | 
|  | 595 | mLayerFEState.forceClientComposition = false; | 
|  | 596 | mOutputLayer.editState().forceClientComposition = false; | 
|  | 597 |  | 
|  | 598 | mOutputLayer.updateCompositionState(false, true); | 
|  | 599 |  | 
|  | 600 | EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); | 
|  | 601 |  | 
|  | 602 | mOutputLayer.editState().forceClientComposition = false; | 
|  | 603 |  | 
|  | 604 | setupGeometryChildCallValues(); | 
|  | 605 |  | 
|  | 606 | mOutputLayer.updateCompositionState(true, true); | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 607 |  | 
|  | 608 | EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); | 
|  | 609 | } | 
|  | 610 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 611 | /* | 
|  | 612 | * OutputLayer::writeStateToHWC() | 
|  | 613 | */ | 
|  | 614 |  | 
|  | 615 | struct OutputLayerWriteStateToHWCTest : public OutputLayerTest { | 
|  | 616 | static constexpr HWC2::Error kError = HWC2::Error::Unsupported; | 
|  | 617 | static constexpr FloatRect kSourceCrop{11.f, 12.f, 13.f, 14.f}; | 
|  | 618 | static constexpr uint32_t kZOrder = 21u; | 
|  | 619 | static constexpr Hwc2::Transform kBufferTransform = static_cast<Hwc2::Transform>(31); | 
|  | 620 | static constexpr Hwc2::IComposerClient::BlendMode kBlendMode = | 
|  | 621 | static_cast<Hwc2::IComposerClient::BlendMode>(41); | 
|  | 622 | static constexpr float kAlpha = 51.f; | 
|  | 623 | static constexpr uint32_t kType = 61u; | 
|  | 624 | static constexpr uint32_t kAppId = 62u; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 625 | static constexpr ui::Dataspace kDataspace = static_cast<ui::Dataspace>(71); | 
|  | 626 | static constexpr int kSupportedPerFrameMetadata = 101; | 
|  | 627 | static constexpr int kExpectedHwcSlot = 0; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 628 |  | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 629 | static const half4 kColor; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 630 | static const Rect kDisplayFrame; | 
| Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 631 | static const Region kOutputSpaceVisibleRegion; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 632 | static const mat4 kColorTransform; | 
|  | 633 | static const Region kSurfaceDamage; | 
|  | 634 | static const HdrMetadata kHdrMetadata; | 
|  | 635 | static native_handle_t* kSidebandStreamHandle; | 
|  | 636 | static const sp<GraphicBuffer> kBuffer; | 
|  | 637 | static const sp<Fence> kFence; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 638 |  | 
|  | 639 | OutputLayerWriteStateToHWCTest() { | 
|  | 640 | auto& outputLayerState = mOutputLayer.editState(); | 
|  | 641 | outputLayerState.hwc = impl::OutputLayerCompositionState::Hwc(mHwcLayer); | 
|  | 642 |  | 
|  | 643 | outputLayerState.displayFrame = kDisplayFrame; | 
|  | 644 | outputLayerState.sourceCrop = kSourceCrop; | 
|  | 645 | outputLayerState.z = kZOrder; | 
|  | 646 | outputLayerState.bufferTransform = static_cast<Hwc2::Transform>(kBufferTransform); | 
| Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 647 | outputLayerState.outputSpaceVisibleRegion = kOutputSpaceVisibleRegion; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 648 | outputLayerState.dataspace = kDataspace; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 649 |  | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 650 | mLayerFEState.blendMode = kBlendMode; | 
|  | 651 | mLayerFEState.alpha = kAlpha; | 
|  | 652 | mLayerFEState.type = kType; | 
|  | 653 | mLayerFEState.appId = kAppId; | 
|  | 654 | mLayerFEState.colorTransform = kColorTransform; | 
|  | 655 | mLayerFEState.color = kColor; | 
|  | 656 | mLayerFEState.surfaceDamage = kSurfaceDamage; | 
|  | 657 | mLayerFEState.hdrMetadata = kHdrMetadata; | 
|  | 658 | mLayerFEState.sidebandStream = NativeHandle::create(kSidebandStreamHandle, false); | 
|  | 659 | mLayerFEState.buffer = kBuffer; | 
|  | 660 | mLayerFEState.bufferSlot = BufferQueue::INVALID_BUFFER_SLOT; | 
|  | 661 | mLayerFEState.acquireFence = kFence; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 662 |  | 
|  | 663 | EXPECT_CALL(mOutput, getDisplayColorProfile()) | 
|  | 664 | .WillRepeatedly(Return(&mDisplayColorProfile)); | 
|  | 665 | EXPECT_CALL(mDisplayColorProfile, getSupportedPerFrameMetadata()) | 
|  | 666 | .WillRepeatedly(Return(kSupportedPerFrameMetadata)); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 667 | } | 
|  | 668 |  | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 669 | // Some tests may need to simulate unsupported HWC calls | 
|  | 670 | enum class SimulateUnsupported { None, ColorTransform }; | 
|  | 671 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 672 | void expectGeometryCommonCalls() { | 
|  | 673 | EXPECT_CALL(*mHwcLayer, setDisplayFrame(kDisplayFrame)).WillOnce(Return(kError)); | 
|  | 674 | EXPECT_CALL(*mHwcLayer, setSourceCrop(kSourceCrop)).WillOnce(Return(kError)); | 
|  | 675 | EXPECT_CALL(*mHwcLayer, setZOrder(kZOrder)).WillOnce(Return(kError)); | 
|  | 676 | EXPECT_CALL(*mHwcLayer, setTransform(static_cast<HWC2::Transform>(kBufferTransform))) | 
|  | 677 | .WillOnce(Return(kError)); | 
|  | 678 |  | 
|  | 679 | EXPECT_CALL(*mHwcLayer, setBlendMode(static_cast<HWC2::BlendMode>(kBlendMode))) | 
|  | 680 | .WillOnce(Return(kError)); | 
|  | 681 | EXPECT_CALL(*mHwcLayer, setPlaneAlpha(kAlpha)).WillOnce(Return(kError)); | 
|  | 682 | EXPECT_CALL(*mHwcLayer, setInfo(kType, kAppId)).WillOnce(Return(kError)); | 
|  | 683 | } | 
|  | 684 |  | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 685 | void expectPerFrameCommonCalls(SimulateUnsupported unsupported = SimulateUnsupported::None) { | 
| Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 686 | EXPECT_CALL(*mHwcLayer, setVisibleRegion(RegionEq(kOutputSpaceVisibleRegion))) | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 687 | .WillOnce(Return(kError)); | 
|  | 688 | EXPECT_CALL(*mHwcLayer, setDataspace(kDataspace)).WillOnce(Return(kError)); | 
|  | 689 | EXPECT_CALL(*mHwcLayer, setColorTransform(kColorTransform)) | 
|  | 690 | .WillOnce(Return(unsupported == SimulateUnsupported::ColorTransform | 
|  | 691 | ? HWC2::Error::Unsupported | 
|  | 692 | : HWC2::Error::None)); | 
|  | 693 | EXPECT_CALL(*mHwcLayer, setSurfaceDamage(RegionEq(kSurfaceDamage))) | 
|  | 694 | .WillOnce(Return(kError)); | 
|  | 695 | } | 
|  | 696 |  | 
|  | 697 | void expectSetCompositionTypeCall(Hwc2::IComposerClient::Composition compositionType) { | 
|  | 698 | EXPECT_CALL(*mHwcLayer, setCompositionType(static_cast<HWC2::Composition>(compositionType))) | 
|  | 699 | .WillOnce(Return(kError)); | 
|  | 700 | } | 
|  | 701 |  | 
|  | 702 | void expectNoSetCompositionTypeCall() { | 
|  | 703 | EXPECT_CALL(*mHwcLayer, setCompositionType(_)).Times(0); | 
|  | 704 | } | 
|  | 705 |  | 
|  | 706 | void expectSetColorCall() { | 
|  | 707 | hwc_color_t color = {static_cast<uint8_t>(std::round(kColor.r * 255)), | 
|  | 708 | static_cast<uint8_t>(std::round(kColor.g * 255)), | 
|  | 709 | static_cast<uint8_t>(std::round(kColor.b * 255)), 255}; | 
|  | 710 |  | 
|  | 711 | EXPECT_CALL(*mHwcLayer, setColor(ColorEq(color))).WillOnce(Return(kError)); | 
|  | 712 | } | 
|  | 713 |  | 
|  | 714 | void expectSetSidebandHandleCall() { | 
|  | 715 | EXPECT_CALL(*mHwcLayer, setSidebandStream(kSidebandStreamHandle)); | 
|  | 716 | } | 
|  | 717 |  | 
|  | 718 | void expectSetHdrMetadataAndBufferCalls() { | 
|  | 719 | EXPECT_CALL(*mHwcLayer, setPerFrameMetadata(kSupportedPerFrameMetadata, kHdrMetadata)); | 
|  | 720 | EXPECT_CALL(*mHwcLayer, setBuffer(kExpectedHwcSlot, kBuffer, kFence)); | 
|  | 721 | } | 
|  | 722 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 723 | std::shared_ptr<HWC2::mock::Layer> mHwcLayer{std::make_shared<StrictMock<HWC2::mock::Layer>>()}; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 724 | StrictMock<mock::DisplayColorProfile> mDisplayColorProfile; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 725 | }; | 
|  | 726 |  | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 727 | const half4 OutputLayerWriteStateToHWCTest::kColor{81.f / 255.f, 82.f / 255.f, 83.f / 255.f, | 
|  | 728 | 84.f / 255.f}; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 729 | const Rect OutputLayerWriteStateToHWCTest::kDisplayFrame{1001, 1002, 1003, 10044}; | 
| Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 730 | const Region OutputLayerWriteStateToHWCTest::kOutputSpaceVisibleRegion{ | 
|  | 731 | Rect{1005, 1006, 1007, 1008}}; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 732 | const mat4 OutputLayerWriteStateToHWCTest::kColorTransform{ | 
|  | 733 | 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, | 
|  | 734 | 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, | 
|  | 735 | }; | 
|  | 736 | const Region OutputLayerWriteStateToHWCTest::kSurfaceDamage{Rect{1025, 1026, 1027, 1028}}; | 
|  | 737 | const HdrMetadata OutputLayerWriteStateToHWCTest::kHdrMetadata{{/* LightFlattenable */}, 1029}; | 
|  | 738 | native_handle_t* OutputLayerWriteStateToHWCTest::kSidebandStreamHandle = | 
|  | 739 | reinterpret_cast<native_handle_t*>(1031); | 
|  | 740 | const sp<GraphicBuffer> OutputLayerWriteStateToHWCTest::kBuffer; | 
|  | 741 | const sp<Fence> OutputLayerWriteStateToHWCTest::kFence; | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 742 |  | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 743 | TEST_F(OutputLayerWriteStateToHWCTest, doesNothingIfNoFECompositionState) { | 
|  | 744 | EXPECT_CALL(*mLayerFE, getCompositionState()).WillOnce(Return(nullptr)); | 
|  | 745 |  | 
|  | 746 | mOutputLayer.writeStateToHWC(true); | 
|  | 747 | } | 
|  | 748 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 749 | TEST_F(OutputLayerWriteStateToHWCTest, doesNothingIfNoHWCState) { | 
|  | 750 | mOutputLayer.editState().hwc.reset(); | 
|  | 751 |  | 
|  | 752 | mOutputLayer.writeStateToHWC(true); | 
|  | 753 | } | 
|  | 754 |  | 
|  | 755 | TEST_F(OutputLayerWriteStateToHWCTest, doesNothingIfNoHWCLayer) { | 
|  | 756 | mOutputLayer.editState().hwc = impl::OutputLayerCompositionState::Hwc(nullptr); | 
|  | 757 |  | 
|  | 758 | mOutputLayer.writeStateToHWC(true); | 
|  | 759 | } | 
|  | 760 |  | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 761 | TEST_F(OutputLayerWriteStateToHWCTest, canSetAllState) { | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 762 | expectGeometryCommonCalls(); | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 763 | expectPerFrameCommonCalls(); | 
|  | 764 |  | 
|  | 765 | expectNoSetCompositionTypeCall(); | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 766 |  | 
|  | 767 | mOutputLayer.writeStateToHWC(true); | 
|  | 768 | } | 
|  | 769 |  | 
| Rashed Abdel-Tawab | 6643cd8 | 2019-10-29 10:01:56 -0700 | [diff] [blame] | 770 | TEST_F(OutputLayerTest, displayInstallOrientationBufferTransformSetTo90) { | 
|  | 771 | mLayerFEState.geomBufferUsesDisplayInverseTransform = false; | 
|  | 772 | mLayerFEState.geomLayerTransform = ui::Transform{TR_IDENT}; | 
|  | 773 | // This test simulates a scenario where displayInstallOrientation is set to | 
|  | 774 | // ROT_90. This only has an effect on the transform; orientation stays 0 (see | 
|  | 775 | // DisplayDevice::setProjection). | 
|  | 776 | mOutputState.orientation = TR_IDENT; | 
|  | 777 | mOutputState.transform = ui::Transform{TR_ROT_90}; | 
|  | 778 | // Buffers are pre-rotated based on the transform hint (ROT_90); their | 
|  | 779 | // geomBufferTransform is set to the inverse transform. | 
|  | 780 | mLayerFEState.geomBufferTransform = TR_ROT_270; | 
|  | 781 |  | 
|  | 782 | EXPECT_EQ(TR_IDENT, mOutputLayer.calculateOutputRelativeBufferTransform()); | 
|  | 783 | } | 
|  | 784 |  | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 785 | TEST_F(OutputLayerWriteStateToHWCTest, canSetPerFrameStateForSolidColor) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 786 | mLayerFEState.compositionType = Hwc2::IComposerClient::Composition::SOLID_COLOR; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 787 |  | 
|  | 788 | expectPerFrameCommonCalls(); | 
| Lloyd Pique | 46b72df | 2019-10-29 13:19:27 -0700 | [diff] [blame] | 789 |  | 
|  | 790 | // Setting the composition type should happen before setting the color. We | 
|  | 791 | // check this in this test only by setting up an testing::InSeqeuence | 
|  | 792 | // instance before setting up the two expectations. | 
|  | 793 | InSequence s; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 794 | expectSetCompositionTypeCall(Hwc2::IComposerClient::Composition::SOLID_COLOR); | 
| Lloyd Pique | 46b72df | 2019-10-29 13:19:27 -0700 | [diff] [blame] | 795 | expectSetColorCall(); | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 796 |  | 
|  | 797 | mOutputLayer.writeStateToHWC(false); | 
|  | 798 | } | 
|  | 799 |  | 
|  | 800 | TEST_F(OutputLayerWriteStateToHWCTest, canSetPerFrameStateForSideband) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 801 | mLayerFEState.compositionType = Hwc2::IComposerClient::Composition::SIDEBAND; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 802 |  | 
|  | 803 | expectPerFrameCommonCalls(); | 
|  | 804 | expectSetSidebandHandleCall(); | 
|  | 805 | expectSetCompositionTypeCall(Hwc2::IComposerClient::Composition::SIDEBAND); | 
|  | 806 |  | 
|  | 807 | mOutputLayer.writeStateToHWC(false); | 
|  | 808 | } | 
|  | 809 |  | 
|  | 810 | TEST_F(OutputLayerWriteStateToHWCTest, canSetPerFrameStateForCursor) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 811 | mLayerFEState.compositionType = Hwc2::IComposerClient::Composition::CURSOR; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 812 |  | 
|  | 813 | expectPerFrameCommonCalls(); | 
|  | 814 | expectSetHdrMetadataAndBufferCalls(); | 
|  | 815 | expectSetCompositionTypeCall(Hwc2::IComposerClient::Composition::CURSOR); | 
|  | 816 |  | 
|  | 817 | mOutputLayer.writeStateToHWC(false); | 
|  | 818 | } | 
|  | 819 |  | 
|  | 820 | TEST_F(OutputLayerWriteStateToHWCTest, canSetPerFrameStateForDevice) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 821 | mLayerFEState.compositionType = Hwc2::IComposerClient::Composition::DEVICE; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 822 |  | 
|  | 823 | expectPerFrameCommonCalls(); | 
|  | 824 | expectSetHdrMetadataAndBufferCalls(); | 
|  | 825 | expectSetCompositionTypeCall(Hwc2::IComposerClient::Composition::DEVICE); | 
|  | 826 |  | 
|  | 827 | mOutputLayer.writeStateToHWC(false); | 
|  | 828 | } | 
|  | 829 |  | 
|  | 830 | TEST_F(OutputLayerWriteStateToHWCTest, compositionTypeIsNotSetIfUnchanged) { | 
|  | 831 | (*mOutputLayer.editState().hwc).hwcCompositionType = | 
|  | 832 | Hwc2::IComposerClient::Composition::SOLID_COLOR; | 
|  | 833 |  | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 834 | mLayerFEState.compositionType = Hwc2::IComposerClient::Composition::SOLID_COLOR; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 835 |  | 
|  | 836 | expectPerFrameCommonCalls(); | 
|  | 837 | expectSetColorCall(); | 
|  | 838 | expectNoSetCompositionTypeCall(); | 
|  | 839 |  | 
|  | 840 | mOutputLayer.writeStateToHWC(false); | 
|  | 841 | } | 
|  | 842 |  | 
|  | 843 | TEST_F(OutputLayerWriteStateToHWCTest, compositionTypeIsSetToClientIfColorTransformNotSupported) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 844 | mLayerFEState.compositionType = Hwc2::IComposerClient::Composition::SOLID_COLOR; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 845 |  | 
|  | 846 | expectPerFrameCommonCalls(SimulateUnsupported::ColorTransform); | 
|  | 847 | expectSetColorCall(); | 
|  | 848 | expectSetCompositionTypeCall(Hwc2::IComposerClient::Composition::CLIENT); | 
|  | 849 |  | 
|  | 850 | mOutputLayer.writeStateToHWC(false); | 
|  | 851 | } | 
|  | 852 |  | 
|  | 853 | TEST_F(OutputLayerWriteStateToHWCTest, compositionTypeIsSetToClientIfClientCompositionForced) { | 
|  | 854 | mOutputLayer.editState().forceClientComposition = true; | 
|  | 855 |  | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 856 | mLayerFEState.compositionType = Hwc2::IComposerClient::Composition::SOLID_COLOR; | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 857 |  | 
|  | 858 | expectPerFrameCommonCalls(); | 
|  | 859 | expectSetColorCall(); | 
|  | 860 | expectSetCompositionTypeCall(Hwc2::IComposerClient::Composition::CLIENT); | 
|  | 861 |  | 
|  | 862 | mOutputLayer.writeStateToHWC(false); | 
|  | 863 | } | 
|  | 864 |  | 
| Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 865 | /* | 
| Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 866 | * OutputLayer::writeCursorPositionToHWC() | 
|  | 867 | */ | 
|  | 868 |  | 
|  | 869 | struct OutputLayerWriteCursorPositionToHWCTest : public OutputLayerTest { | 
|  | 870 | static constexpr int kDefaultTransform = TR_IDENT; | 
|  | 871 | static constexpr HWC2::Error kDefaultError = HWC2::Error::Unsupported; | 
|  | 872 |  | 
|  | 873 | static const Rect kDefaultDisplayViewport; | 
|  | 874 | static const Rect kDefaultCursorFrame; | 
|  | 875 |  | 
|  | 876 | OutputLayerWriteCursorPositionToHWCTest() { | 
|  | 877 | auto& outputLayerState = mOutputLayer.editState(); | 
|  | 878 | outputLayerState.hwc = impl::OutputLayerCompositionState::Hwc(mHwcLayer); | 
|  | 879 |  | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 880 | mLayerFEState.cursorFrame = kDefaultCursorFrame; | 
| Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 881 |  | 
|  | 882 | mOutputState.viewport = kDefaultDisplayViewport; | 
|  | 883 | mOutputState.transform = ui::Transform{kDefaultTransform}; | 
|  | 884 | } | 
|  | 885 |  | 
|  | 886 | std::shared_ptr<HWC2::mock::Layer> mHwcLayer{std::make_shared<StrictMock<HWC2::mock::Layer>>()}; | 
|  | 887 | }; | 
|  | 888 |  | 
|  | 889 | const Rect OutputLayerWriteCursorPositionToHWCTest::kDefaultDisplayViewport{0, 0, 1920, 1080}; | 
|  | 890 | const Rect OutputLayerWriteCursorPositionToHWCTest::kDefaultCursorFrame{1, 2, 3, 4}; | 
|  | 891 |  | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 892 | TEST_F(OutputLayerWriteCursorPositionToHWCTest, doesNothingIfNoFECompositionState) { | 
|  | 893 | EXPECT_CALL(*mLayerFE, getCompositionState()).WillOnce(Return(nullptr)); | 
|  | 894 |  | 
|  | 895 | mOutputLayer.writeCursorPositionToHWC(); | 
|  | 896 | } | 
|  | 897 |  | 
| Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 898 | TEST_F(OutputLayerWriteCursorPositionToHWCTest, writeCursorPositionToHWCHandlesNoHwcState) { | 
|  | 899 | mOutputLayer.editState().hwc.reset(); | 
|  | 900 |  | 
|  | 901 | mOutputLayer.writeCursorPositionToHWC(); | 
|  | 902 | } | 
|  | 903 |  | 
|  | 904 | TEST_F(OutputLayerWriteCursorPositionToHWCTest, writeCursorPositionToHWCWritesStateToHWC) { | 
|  | 905 | EXPECT_CALL(*mHwcLayer, setCursorPosition(1, 2)).WillOnce(Return(kDefaultError)); | 
|  | 906 |  | 
|  | 907 | mOutputLayer.writeCursorPositionToHWC(); | 
|  | 908 | } | 
|  | 909 |  | 
|  | 910 | TEST_F(OutputLayerWriteCursorPositionToHWCTest, writeCursorPositionToHWCIntersectedWithViewport) { | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 911 | mLayerFEState.cursorFrame = Rect{3000, 3000, 3016, 3016}; | 
| Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 912 |  | 
|  | 913 | EXPECT_CALL(*mHwcLayer, setCursorPosition(1920, 1080)).WillOnce(Return(kDefaultError)); | 
|  | 914 |  | 
|  | 915 | mOutputLayer.writeCursorPositionToHWC(); | 
|  | 916 | } | 
|  | 917 |  | 
|  | 918 | TEST_F(OutputLayerWriteCursorPositionToHWCTest, writeCursorPositionToHWCRotatedByTransform) { | 
|  | 919 | mOutputState.transform = ui::Transform{TR_ROT_90}; | 
|  | 920 |  | 
|  | 921 | EXPECT_CALL(*mHwcLayer, setCursorPosition(-4, 1)).WillOnce(Return(kDefaultError)); | 
|  | 922 |  | 
|  | 923 | mOutputLayer.writeCursorPositionToHWC(); | 
|  | 924 | } | 
|  | 925 |  | 
|  | 926 | /* | 
| Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 927 | * OutputLayer::getHwcLayer() | 
|  | 928 | */ | 
|  | 929 |  | 
|  | 930 | TEST_F(OutputLayerTest, getHwcLayerHandlesNoHwcState) { | 
|  | 931 | mOutputLayer.editState().hwc.reset(); | 
|  | 932 |  | 
|  | 933 | EXPECT_TRUE(mOutputLayer.getHwcLayer() == nullptr); | 
|  | 934 | } | 
|  | 935 |  | 
|  | 936 | TEST_F(OutputLayerTest, getHwcLayerHandlesNoHwcLayer) { | 
|  | 937 | mOutputLayer.editState().hwc = impl::OutputLayerCompositionState::Hwc{nullptr}; | 
|  | 938 |  | 
|  | 939 | EXPECT_TRUE(mOutputLayer.getHwcLayer() == nullptr); | 
|  | 940 | } | 
|  | 941 |  | 
|  | 942 | TEST_F(OutputLayerTest, getHwcLayerReturnsHwcLayer) { | 
|  | 943 | auto hwcLayer = std::make_shared<StrictMock<HWC2::mock::Layer>>(); | 
|  | 944 | mOutputLayer.editState().hwc = impl::OutputLayerCompositionState::Hwc{hwcLayer}; | 
|  | 945 |  | 
|  | 946 | EXPECT_EQ(hwcLayer.get(), mOutputLayer.getHwcLayer()); | 
|  | 947 | } | 
|  | 948 |  | 
|  | 949 | /* | 
|  | 950 | * OutputLayer::requiresClientComposition() | 
|  | 951 | */ | 
|  | 952 |  | 
|  | 953 | TEST_F(OutputLayerTest, requiresClientCompositionReturnsTrueIfNoHWC2State) { | 
|  | 954 | mOutputLayer.editState().hwc.reset(); | 
|  | 955 |  | 
|  | 956 | EXPECT_TRUE(mOutputLayer.requiresClientComposition()); | 
|  | 957 | } | 
|  | 958 |  | 
|  | 959 | TEST_F(OutputLayerTest, requiresClientCompositionReturnsTrueIfSetToClientComposition) { | 
|  | 960 | mOutputLayer.editState().hwc = impl::OutputLayerCompositionState::Hwc{nullptr}; | 
|  | 961 | mOutputLayer.editState().hwc->hwcCompositionType = Hwc2::IComposerClient::Composition::CLIENT; | 
|  | 962 |  | 
|  | 963 | EXPECT_TRUE(mOutputLayer.requiresClientComposition()); | 
|  | 964 | } | 
|  | 965 |  | 
|  | 966 | TEST_F(OutputLayerTest, requiresClientCompositionReturnsFalseIfSetToDeviceComposition) { | 
|  | 967 | mOutputLayer.editState().hwc = impl::OutputLayerCompositionState::Hwc{nullptr}; | 
|  | 968 | mOutputLayer.editState().hwc->hwcCompositionType = Hwc2::IComposerClient::Composition::DEVICE; | 
|  | 969 |  | 
|  | 970 | EXPECT_FALSE(mOutputLayer.requiresClientComposition()); | 
|  | 971 | } | 
|  | 972 |  | 
|  | 973 | /* | 
| Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 974 | * OutputLayer::isHardwareCursor() | 
|  | 975 | */ | 
|  | 976 |  | 
|  | 977 | TEST_F(OutputLayerTest, isHardwareCursorReturnsFalseIfNoHWC2State) { | 
|  | 978 | mOutputLayer.editState().hwc.reset(); | 
|  | 979 |  | 
|  | 980 | EXPECT_FALSE(mOutputLayer.isHardwareCursor()); | 
|  | 981 | } | 
|  | 982 |  | 
|  | 983 | TEST_F(OutputLayerTest, isHardwareCursorReturnsTrueIfSetToCursorComposition) { | 
|  | 984 | mOutputLayer.editState().hwc = impl::OutputLayerCompositionState::Hwc{nullptr}; | 
|  | 985 | mOutputLayer.editState().hwc->hwcCompositionType = Hwc2::IComposerClient::Composition::CURSOR; | 
|  | 986 |  | 
|  | 987 | EXPECT_TRUE(mOutputLayer.isHardwareCursor()); | 
|  | 988 | } | 
|  | 989 |  | 
|  | 990 | TEST_F(OutputLayerTest, isHardwareCursorReturnsFalseIfSetToDeviceComposition) { | 
|  | 991 | mOutputLayer.editState().hwc = impl::OutputLayerCompositionState::Hwc{nullptr}; | 
|  | 992 | mOutputLayer.editState().hwc->hwcCompositionType = Hwc2::IComposerClient::Composition::DEVICE; | 
|  | 993 |  | 
|  | 994 | EXPECT_FALSE(mOutputLayer.isHardwareCursor()); | 
|  | 995 | } | 
|  | 996 |  | 
|  | 997 | /* | 
| Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 998 | * OutputLayer::applyDeviceCompositionTypeChange() | 
|  | 999 | */ | 
|  | 1000 |  | 
|  | 1001 | TEST_F(OutputLayerTest, applyDeviceCompositionTypeChangeSetsNewType) { | 
|  | 1002 | mOutputLayer.editState().hwc = impl::OutputLayerCompositionState::Hwc{nullptr}; | 
|  | 1003 | mOutputLayer.editState().hwc->hwcCompositionType = Hwc2::IComposerClient::Composition::DEVICE; | 
|  | 1004 |  | 
|  | 1005 | mOutputLayer.applyDeviceCompositionTypeChange(Hwc2::IComposerClient::Composition::CLIENT); | 
|  | 1006 |  | 
|  | 1007 | ASSERT_TRUE(mOutputLayer.getState().hwc); | 
|  | 1008 | EXPECT_EQ(Hwc2::IComposerClient::Composition::CLIENT, | 
|  | 1009 | mOutputLayer.getState().hwc->hwcCompositionType); | 
|  | 1010 | } | 
|  | 1011 |  | 
|  | 1012 | /* | 
|  | 1013 | * OutputLayer::prepareForDeviceLayerRequests() | 
|  | 1014 | */ | 
|  | 1015 |  | 
|  | 1016 | TEST_F(OutputLayerTest, prepareForDeviceLayerRequestsResetsRequestState) { | 
|  | 1017 | mOutputLayer.editState().clearClientTarget = true; | 
|  | 1018 |  | 
|  | 1019 | mOutputLayer.prepareForDeviceLayerRequests(); | 
|  | 1020 |  | 
|  | 1021 | EXPECT_FALSE(mOutputLayer.getState().clearClientTarget); | 
|  | 1022 | } | 
|  | 1023 |  | 
|  | 1024 | /* | 
|  | 1025 | * OutputLayer::applyDeviceLayerRequest() | 
|  | 1026 | */ | 
|  | 1027 |  | 
|  | 1028 | TEST_F(OutputLayerTest, applyDeviceLayerRequestHandlesClearClientTarget) { | 
|  | 1029 | mOutputLayer.editState().clearClientTarget = false; | 
|  | 1030 |  | 
|  | 1031 | mOutputLayer.applyDeviceLayerRequest(Hwc2::IComposerClient::LayerRequest::CLEAR_CLIENT_TARGET); | 
|  | 1032 |  | 
|  | 1033 | EXPECT_TRUE(mOutputLayer.getState().clearClientTarget); | 
|  | 1034 | } | 
|  | 1035 |  | 
|  | 1036 | TEST_F(OutputLayerTest, applyDeviceLayerRequestHandlesUnknownRequest) { | 
|  | 1037 | mOutputLayer.editState().clearClientTarget = false; | 
|  | 1038 |  | 
|  | 1039 | mOutputLayer.applyDeviceLayerRequest(static_cast<Hwc2::IComposerClient::LayerRequest>(0)); | 
|  | 1040 |  | 
|  | 1041 | EXPECT_FALSE(mOutputLayer.getState().clearClientTarget); | 
|  | 1042 | } | 
|  | 1043 |  | 
| Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 1044 | /* | 
|  | 1045 | * OutputLayer::needsFiltering() | 
|  | 1046 | */ | 
|  | 1047 |  | 
|  | 1048 | TEST_F(OutputLayerTest, needsFilteringReturnsFalseIfDisplaySizeSameAsSourceSize) { | 
|  | 1049 | mOutputLayer.editState().displayFrame = Rect(100, 100, 200, 200); | 
|  | 1050 | mOutputLayer.editState().sourceCrop = FloatRect{0.f, 0.f, 100.f, 100.f}; | 
|  | 1051 |  | 
|  | 1052 | EXPECT_FALSE(mOutputLayer.needsFiltering()); | 
|  | 1053 | } | 
|  | 1054 |  | 
|  | 1055 | TEST_F(OutputLayerTest, needsFilteringReturnsTrueIfDisplaySizeDifferentFromSourceSize) { | 
|  | 1056 | mOutputLayer.editState().displayFrame = Rect(100, 100, 200, 200); | 
|  | 1057 | mOutputLayer.editState().sourceCrop = FloatRect{0.f, 0.f, 100.1f, 100.1f}; | 
|  | 1058 |  | 
|  | 1059 | EXPECT_TRUE(mOutputLayer.needsFiltering()); | 
|  | 1060 | } | 
|  | 1061 |  | 
| Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 1062 | } // namespace | 
|  | 1063 | } // namespace android::compositionengine |