| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <drm_fourcc.h> | 5 #include <drm_fourcc.h> |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 DrmOverlayValidatorTest() {} | 44 DrmOverlayValidatorTest() {} |
| 45 | 45 |
| 46 void SetUp() override; | 46 void SetUp() override; |
| 47 void TearDown() override; | 47 void TearDown() override; |
| 48 | 48 |
| 49 void OnSwapBuffers(gfx::SwapResult result) { | 49 void OnSwapBuffers(gfx::SwapResult result) { |
| 50 on_swap_buffers_count_++; | 50 on_swap_buffers_count_++; |
| 51 last_swap_buffers_result_ = result; | 51 last_swap_buffers_result_ = result; |
| 52 } | 52 } |
| 53 | 53 |
| 54 scoped_refptr<ui::ScanoutBuffer> ProcessBuffer(const gfx::Size& size, |
| 55 uint32_t format) { |
| 56 gfx::BufferFormat buffer_format = |
| 57 ui::GetBufferFormatFromFourCCFormat(format); |
| 58 return buffer_generator_->Create(drm_, buffer_format, size); |
| 59 } |
| 60 |
| 61 scoped_refptr<ui::ScanoutBuffer> ReturnNullBuffer(const gfx::Size& size, |
| 62 uint32_t format) { |
| 63 return nullptr; |
| 64 } |
| 65 |
| 54 protected: | 66 protected: |
| 55 scoped_ptr<base::MessageLoop> message_loop_; | 67 scoped_ptr<base::MessageLoop> message_loop_; |
| 56 scoped_refptr<ui::MockDrmDevice> drm_; | 68 scoped_refptr<ui::MockDrmDevice> drm_; |
| 57 scoped_ptr<ui::MockScanoutBufferGenerator> buffer_generator_; | 69 scoped_ptr<ui::MockScanoutBufferGenerator> buffer_generator_; |
| 58 scoped_ptr<ui::ScreenManager> screen_manager_; | 70 scoped_ptr<ui::ScreenManager> screen_manager_; |
| 59 scoped_ptr<ui::DrmDeviceManager> drm_device_manager_; | 71 scoped_ptr<ui::DrmDeviceManager> drm_device_manager_; |
| 60 ui::MockHardwareDisplayPlaneManager* plane_manager_; | 72 ui::MockHardwareDisplayPlaneManager* plane_manager_; |
| 61 ui::DrmWindow* window_; | 73 ui::DrmWindow* window_; |
| 62 scoped_ptr<ui::DrmOverlayValidator> overlay_validator_; | 74 scoped_ptr<ui::DrmOverlayValidator> overlay_validator_; |
| 63 std::vector<ui::OverlayCheck_Params> overlay_params_; | 75 std::vector<ui::OverlayCheck_Params> overlay_params_; |
| 64 ui::OverlayPlaneList plane_list_; | 76 ui::OverlayPlaneList plane_list_; |
| 77 ui::OverlayPlane::ProcessBufferCallback process_buffer_handler_; |
| 65 | 78 |
| 66 int on_swap_buffers_count_; | 79 int on_swap_buffers_count_; |
| 67 gfx::SwapResult last_swap_buffers_result_; | 80 gfx::SwapResult last_swap_buffers_result_; |
| 68 gfx::Rect overlay_rect_; | 81 gfx::Rect overlay_rect_; |
| 69 gfx::Rect primary_rect_; | 82 gfx::Rect primary_rect_; |
| 70 | 83 |
| 71 private: | 84 private: |
| 72 DISALLOW_COPY_AND_ASSIGN(DrmOverlayValidatorTest); | 85 DISALLOW_COPY_AND_ASSIGN(DrmOverlayValidatorTest); |
| 73 }; | 86 }; |
| 74 | 87 |
| 75 void DrmOverlayValidatorTest::SetUp() { | 88 void DrmOverlayValidatorTest::SetUp() { |
| 76 on_swap_buffers_count_ = 0; | 89 on_swap_buffers_count_ = 0; |
| 77 last_swap_buffers_result_ = gfx::SwapResult::SWAP_FAILED; | 90 last_swap_buffers_result_ = gfx::SwapResult::SWAP_FAILED; |
| 91 process_buffer_handler_ = base::Bind(&DrmOverlayValidatorTest::ProcessBuffer, |
| 92 base::Unretained(this)); |
| 78 | 93 |
| 79 message_loop_.reset(new base::MessageLoopForUI); | 94 message_loop_.reset(new base::MessageLoopForUI); |
| 80 std::vector<uint32_t> crtcs; | 95 std::vector<uint32_t> crtcs; |
| 81 crtcs.push_back(kDefaultCrtc); | 96 crtcs.push_back(kDefaultCrtc); |
| 82 drm_ = new ui::MockDrmDevice(false, crtcs, kPlanesPerCrtc); | 97 drm_ = new ui::MockDrmDevice(false, crtcs, kPlanesPerCrtc); |
| 83 buffer_generator_.reset(new ui::MockScanoutBufferGenerator()); | 98 buffer_generator_.reset(new ui::MockScanoutBufferGenerator()); |
| 84 screen_manager_.reset(new ui::ScreenManager(buffer_generator_.get())); | 99 screen_manager_.reset(new ui::ScreenManager(buffer_generator_.get())); |
| 85 screen_manager_->AddDisplayController(drm_, kDefaultCrtc, kDefaultConnector); | 100 screen_manager_->AddDisplayController(drm_, kDefaultCrtc, kDefaultConnector); |
| 86 screen_manager_->ConfigureDisplayController( | 101 screen_manager_->ConfigureDisplayController( |
| 87 drm_, kDefaultCrtc, kDefaultConnector, gfx::Point(), kDefaultMode); | 102 drm_, kDefaultCrtc, kDefaultConnector, gfx::Point(), kDefaultMode); |
| 88 | 103 |
| 89 drm_device_manager_.reset(new ui::DrmDeviceManager(nullptr)); | 104 drm_device_manager_.reset(new ui::DrmDeviceManager(nullptr)); |
| 90 | 105 |
| 91 scoped_ptr<ui::DrmWindow> window(new ui::DrmWindow( | 106 scoped_ptr<ui::DrmWindow> window(new ui::DrmWindow( |
| 92 kDefaultWidgetHandle, drm_device_manager_.get(), screen_manager_.get())); | 107 kDefaultWidgetHandle, drm_device_manager_.get(), screen_manager_.get())); |
| 93 window->Initialize(); | 108 window->Initialize(buffer_generator_.get()); |
| 94 window->SetBounds( | 109 window->SetBounds( |
| 95 gfx::Rect(gfx::Size(kDefaultMode.hdisplay, kDefaultMode.vdisplay))); | 110 gfx::Rect(gfx::Size(kDefaultMode.hdisplay, kDefaultMode.vdisplay))); |
| 96 screen_manager_->AddWindow(kDefaultWidgetHandle, std::move(window)); | 111 screen_manager_->AddWindow(kDefaultWidgetHandle, std::move(window)); |
| 97 plane_manager_ = | 112 plane_manager_ = |
| 98 static_cast<ui::MockHardwareDisplayPlaneManager*>(drm_->plane_manager()); | 113 static_cast<ui::MockHardwareDisplayPlaneManager*>(drm_->plane_manager()); |
| 99 window_ = screen_manager_->GetWindow(kDefaultWidgetHandle); | 114 window_ = screen_manager_->GetWindow(kDefaultWidgetHandle); |
| 100 overlay_validator_.reset(new ui::DrmOverlayValidator(window_)); | 115 overlay_validator_.reset( |
| 116 new ui::DrmOverlayValidator(window_, buffer_generator_.get())); |
| 101 | 117 |
| 102 overlay_rect_ = | 118 overlay_rect_ = |
| 103 gfx::Rect(0, 0, kDefaultMode.hdisplay / 2, kDefaultMode.vdisplay / 2); | 119 gfx::Rect(0, 0, kDefaultMode.hdisplay / 2, kDefaultMode.vdisplay / 2); |
| 104 | 120 |
| 105 primary_rect_ = gfx::Rect(0, 0, kDefaultMode.hdisplay, kDefaultMode.vdisplay); | 121 primary_rect_ = gfx::Rect(0, 0, kDefaultMode.hdisplay, kDefaultMode.vdisplay); |
| 106 | 122 |
| 107 ui::OverlayCheck_Params primary_candidate; | 123 ui::OverlayCheck_Params primary_candidate; |
| 108 primary_candidate.buffer_size = primary_rect_.size(); | 124 primary_candidate.buffer_size = primary_rect_.size(); |
| 109 primary_candidate.display_rect = primary_rect_; | 125 primary_candidate.display_rect = primary_rect_; |
| 110 overlay_params_.push_back(primary_candidate); | 126 overlay_params_.push_back(primary_candidate); |
| 111 | 127 |
| 112 ui::OverlayCheck_Params overlay_candidate; | 128 ui::OverlayCheck_Params overlay_candidate; |
| 113 overlay_candidate.buffer_size = overlay_rect_.size(); | 129 overlay_candidate.buffer_size = overlay_rect_.size(); |
| 114 overlay_candidate.display_rect = overlay_rect_; | 130 overlay_candidate.display_rect = overlay_rect_; |
| 115 overlay_candidate.plane_z_order = 1; | 131 overlay_candidate.plane_z_order = 1; |
| 116 overlay_params_.push_back(overlay_candidate); | 132 overlay_params_.push_back(overlay_candidate); |
| 117 | 133 |
| 134 scoped_refptr<ui::DrmDevice> drm = |
| 135 window_->GetController()->GetAllocationDrmDevice(); |
| 118 for (const auto& param : overlay_params_) { | 136 for (const auto& param : overlay_params_) { |
| 119 ui::OverlayPlane plane(nullptr, param.plane_z_order, param.transform, | 137 scoped_refptr<ui::ScanoutBuffer> scanout_buffer = |
| 120 param.display_rect, param.crop_rect); | 138 buffer_generator_->Create(drm, param.format, param.buffer_size); |
| 139 ui::OverlayPlane plane(std::move(scanout_buffer), param.plane_z_order, |
| 140 param.transform, param.display_rect, param.crop_rect, |
| 141 process_buffer_handler_); |
| 121 plane_list_.push_back(plane); | 142 plane_list_.push_back(plane); |
| 122 } | 143 } |
| 123 } | 144 } |
| 124 | 145 |
| 125 void DrmOverlayValidatorTest::TearDown() { | 146 void DrmOverlayValidatorTest::TearDown() { |
| 126 scoped_ptr<ui::DrmWindow> window = | 147 scoped_ptr<ui::DrmWindow> window = |
| 127 screen_manager_->RemoveWindow(kDefaultWidgetHandle); | 148 screen_manager_->RemoveWindow(kDefaultWidgetHandle); |
| 128 window->Shutdown(); | 149 window->Shutdown(); |
| 129 message_loop_.reset(); | 150 message_loop_.reset(); |
| 130 } | 151 } |
| 131 | 152 |
| 132 TEST_F(DrmOverlayValidatorTest, WindowWithNoController) { | 153 TEST_F(DrmOverlayValidatorTest, WindowWithNoController) { |
| 133 // We should never promote layers to overlay when controller is not | 154 // We should never promote layers to overlay when controller is not |
| 134 // present. | 155 // present. |
| 135 ui::HardwareDisplayController* controller = window_->GetController(); | 156 ui::HardwareDisplayController* controller = window_->GetController(); |
| 136 window_->SetController(nullptr); | 157 window_->SetController(nullptr); |
| 137 std::vector<ui::OverlayCheck_Params> validated_params = | 158 std::vector<ui::OverlayCheck_Params> validated_params = |
| 138 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), | 159 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 139 buffer_generator_.get()); | |
| 140 EXPECT_EQ(false, validated_params.front().is_overlay_candidate); | 160 EXPECT_EQ(false, validated_params.front().is_overlay_candidate); |
| 141 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); | 161 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); |
| 142 window_->SetController(controller); | 162 window_->SetController(controller); |
| 143 } | 163 } |
| 144 | 164 |
| 145 TEST_F(DrmOverlayValidatorTest, DontPromoteMoreLayersThanAvailablePlanes) { | 165 TEST_F(DrmOverlayValidatorTest, DontPromoteMoreLayersThanAvailablePlanes) { |
| 146 std::vector<ui::OverlayCheck_Params> validated_params = | 166 std::vector<ui::OverlayCheck_Params> validated_params = |
| 147 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), | 167 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 148 buffer_generator_.get()); | |
| 149 EXPECT_EQ(true, validated_params.front().is_overlay_candidate); | 168 EXPECT_EQ(true, validated_params.front().is_overlay_candidate); |
| 150 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); | 169 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); |
| 151 } | 170 } |
| 152 | 171 |
| 153 TEST_F(DrmOverlayValidatorTest, DontCollapseOverlayToPrimaryInFullScreen) { | 172 TEST_F(DrmOverlayValidatorTest, DontCollapseOverlayToPrimaryInFullScreen) { |
| 154 // Overlay Validator should not collapse planes during validation. | 173 // Overlay Validator should not collapse planes during validation. |
| 155 overlay_params_.back().buffer_size = primary_rect_.size(); | 174 overlay_params_.back().buffer_size = primary_rect_.size(); |
| 156 overlay_params_.back().display_rect = primary_rect_; | 175 overlay_params_.back().display_rect = primary_rect_; |
| 157 plane_list_.back().display_bounds = primary_rect_; | 176 plane_list_.back().display_bounds = primary_rect_; |
| 158 | 177 |
| 159 std::vector<ui::OverlayCheck_Params> validated_params = | 178 std::vector<ui::OverlayCheck_Params> validated_params = |
| 160 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), | 179 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 161 buffer_generator_.get()); | |
| 162 // Second candidate should be marked as Invalid as we have only one plane | 180 // Second candidate should be marked as Invalid as we have only one plane |
| 163 // per CRTC. | 181 // per CRTC. |
| 164 EXPECT_EQ(true, validated_params.front().is_overlay_candidate); | 182 EXPECT_EQ(true, validated_params.front().is_overlay_candidate); |
| 165 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); | 183 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); |
| 166 } | 184 } |
| 167 | 185 |
| 168 TEST_F(DrmOverlayValidatorTest, ClearCacheOnReset) { | 186 TEST_F(DrmOverlayValidatorTest, ClearCacheOnReset) { |
| 169 // This test checks if we invalidate cache when Reset is called. | 187 // This test checks if we invalidate cache when Reset is called. |
| 170 overlay_params_.back().buffer_size = overlay_rect_.size(); | 188 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 171 overlay_params_.back().display_rect = overlay_rect_; | 189 overlay_params_.back().display_rect = overlay_rect_; |
| 172 plane_list_.back().display_bounds = overlay_rect_; | 190 plane_list_.back().display_bounds = overlay_rect_; |
| 173 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 191 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 174 DRM_FORMAT_UYVY}; | 192 DRM_FORMAT_UYVY}; |
| 175 | 193 |
| 176 ui::FakePlaneInfo primary_plane_info( | 194 ui::FakePlaneInfo primary_plane_info( |
| 177 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 195 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 178 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); | 196 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 179 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 197 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 180 plane_manager_->SetPlaneProperties(planes_info); | 198 plane_manager_->SetPlaneProperties(planes_info); |
| 181 overlay_validator_->ClearCache(); | 199 overlay_validator_->ClearCache(); |
| 182 | 200 |
| 183 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), | 201 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 184 buffer_generator_.get()); | |
| 185 | 202 |
| 186 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( | 203 ui::OverlayPlaneList plane_list = |
| 187 plane_list_.back(), plane_list_); | 204 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 188 EXPECT_EQ(DRM_FORMAT_UYVY, optimal_format); | 205 EXPECT_EQ(DRM_FORMAT_UYVY, |
| 206 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 189 // Check if ClearCache actually clears the cache. | 207 // Check if ClearCache actually clears the cache. |
| 190 overlay_validator_->ClearCache(); | 208 overlay_validator_->ClearCache(); |
| 191 optimal_format = overlay_validator_->GetOptimalBufferFormat( | 209 plane_list = overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 192 plane_list_.back(), plane_list_); | |
| 193 // There should be no entry in cache for this configuration and should return | 210 // There should be no entry in cache for this configuration and should return |
| 194 // default value of DRM_FORMAT_XRGB8888. | 211 // default value of DRM_FORMAT_XRGB8888. |
| 195 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); | 212 EXPECT_EQ(DRM_FORMAT_XRGB8888, |
| 213 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 196 } | 214 } |
| 197 | 215 |
| 198 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_XRGB) { | 216 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_XRGB) { |
| 199 // Optimal format for Overlay configuration should be XRGB, when primary plane | 217 // Optimal format for Overlay configuration should be XRGB, when primary plane |
| 200 // supports only XRGB and overlay obscures primary. | 218 // supports only XRGB and overlay obscures primary. |
| 201 overlay_params_.back().buffer_size = primary_rect_.size(); | 219 overlay_params_.back().buffer_size = primary_rect_.size(); |
| 202 overlay_params_.back().display_rect = primary_rect_; | 220 overlay_params_.back().display_rect = primary_rect_; |
| 203 plane_list_.back().display_bounds = primary_rect_; | 221 plane_list_.back().display_bounds = primary_rect_; |
| 204 | 222 |
| 205 // Check optimal format for Overlay. | 223 // Check optimal format for Overlay. |
| 206 ui::FakePlaneInfo primary_plane_info( | 224 ui::FakePlaneInfo primary_plane_info( |
| 207 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 225 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 208 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 226 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 209 DRM_FORMAT_UYVY}; | 227 DRM_FORMAT_UYVY}; |
| 210 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats); | 228 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 211 | 229 |
| 212 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info}; | 230 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info}; |
| 213 plane_manager_->SetPlaneProperties(planes); | 231 plane_manager_->SetPlaneProperties(planes); |
| 214 overlay_validator_->ClearCache(); | 232 overlay_validator_->ClearCache(); |
| 215 | 233 |
| 216 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), | 234 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 217 buffer_generator_.get()); | 235 ui::OverlayPlaneList plane_list = |
| 218 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( | 236 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 219 plane_list_.back(), plane_list_); | 237 EXPECT_EQ(DRM_FORMAT_XRGB8888, |
| 220 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); | 238 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 221 } | 239 } |
| 222 | 240 |
| 223 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_YUV) { | 241 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_YUV) { |
| 224 overlay_params_.back().buffer_size = primary_rect_.size(); | 242 overlay_params_.back().buffer_size = primary_rect_.size(); |
| 225 overlay_params_.back().display_rect = primary_rect_; | 243 overlay_params_.back().display_rect = primary_rect_; |
| 226 plane_list_.back().display_bounds = primary_rect_; | 244 plane_list_.back().display_bounds = primary_rect_; |
| 227 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 245 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 228 DRM_FORMAT_UYVY}; | 246 DRM_FORMAT_UYVY}; |
| 229 | 247 |
| 230 // We should prefer YUV when primary can support it. | 248 // We should prefer YUV when primary can support it. |
| 231 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); | 249 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); |
| 232 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats); | 250 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 233 | 251 |
| 234 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info}; | 252 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info}; |
| 235 plane_manager_->SetPlaneProperties(planes); | 253 plane_manager_->SetPlaneProperties(planes); |
| 236 overlay_validator_->ClearCache(); | 254 overlay_validator_->ClearCache(); |
| 237 | 255 |
| 238 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), | 256 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 239 buffer_generator_.get()); | 257 ui::OverlayPlaneList plane_list = |
| 240 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( | 258 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 241 plane_list_.back(), plane_list_); | |
| 242 #if defined(USE_DRM_ATOMIC) | 259 #if defined(USE_DRM_ATOMIC) |
| 243 EXPECT_EQ(DRM_FORMAT_UYVY, optimal_format); | 260 EXPECT_EQ(DRM_FORMAT_UYVY, |
| 261 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 244 #else | 262 #else |
| 245 // If Atomic support is disabled, ensure we choose DRM_FORMAT_XRGB8888 as the | 263 // If Atomic support is disabled, ensure we choose DRM_FORMAT_XRGB8888 as the |
| 246 // optimal format even if other packed formats are supported by Primary. | 264 // optimal format even if other packed formats are supported by Primary. |
| 247 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); | 265 EXPECT_EQ(DRM_FORMAT_XRGB8888, |
| 266 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 248 #endif | 267 #endif |
| 249 } | 268 } |
| 250 | 269 |
| 251 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat_YUV) { | 270 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat_YUV) { |
| 252 plane_manager_->ResetPlaneCount(); | 271 plane_manager_->ResetPlaneCount(); |
| 253 // This test checks for optimal format in case of non full screen video case. | 272 // This test checks for optimal format in case of non full screen video case. |
| 254 // Prefer YUV as optimal format when Overlay supports it. | 273 // Prefer YUV as optimal format when Overlay supports it. |
| 255 overlay_params_.back().buffer_size = overlay_rect_.size(); | 274 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 256 overlay_params_.back().display_rect = overlay_rect_; | 275 overlay_params_.back().display_rect = overlay_rect_; |
| 257 plane_list_.back().display_bounds = overlay_rect_; | 276 plane_list_.back().display_bounds = overlay_rect_; |
| 258 | 277 |
| 259 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 278 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 260 DRM_FORMAT_UYVY}; | 279 DRM_FORMAT_UYVY}; |
| 261 ui::FakePlaneInfo primary_plane_info( | 280 ui::FakePlaneInfo primary_plane_info( |
| 262 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 281 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 263 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); | 282 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 264 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 283 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 265 plane_manager_->SetPlaneProperties(planes_info); | 284 plane_manager_->SetPlaneProperties(planes_info); |
| 266 overlay_validator_->ClearCache(); | 285 overlay_validator_->ClearCache(); |
| 267 | 286 |
| 268 std::vector<ui::OverlayCheck_Params> validated_params = | 287 std::vector<ui::OverlayCheck_Params> validated_params = |
| 269 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), | 288 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 270 buffer_generator_.get()); | |
| 271 | 289 |
| 272 for (const auto& param : validated_params) | 290 for (const auto& param : validated_params) |
| 273 EXPECT_EQ(true, param.is_overlay_candidate); | 291 EXPECT_EQ(true, param.is_overlay_candidate); |
| 274 | 292 |
| 275 EXPECT_EQ(5, plane_manager_->plane_count()); | 293 EXPECT_EQ(5, plane_manager_->plane_count()); |
| 276 | 294 |
| 277 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( | 295 ui::OverlayPlaneList plane_list = |
| 278 plane_list_.back(), plane_list_); | 296 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 279 EXPECT_EQ(DRM_FORMAT_UYVY, optimal_format); | 297 EXPECT_EQ(DRM_FORMAT_UYVY, |
| 298 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 280 } | 299 } |
| 281 | 300 |
| 282 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat_XRGB) { | 301 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat_XRGB) { |
| 283 plane_manager_->ResetPlaneCount(); | 302 plane_manager_->ResetPlaneCount(); |
| 284 // This test checks for optimal format in case of non full screen video case. | 303 // This test checks for optimal format in case of non full screen video case. |
| 285 // This should be XRGB when overlay doesn't support YUV. | 304 // This should be XRGB when overlay doesn't support YUV. |
| 286 overlay_params_.back().buffer_size = overlay_rect_.size(); | 305 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 287 overlay_params_.back().display_rect = overlay_rect_; | 306 overlay_params_.back().display_rect = overlay_rect_; |
| 288 plane_list_.back().display_bounds = overlay_rect_; | 307 plane_list_.back().display_bounds = overlay_rect_; |
| 289 | 308 |
| 290 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 309 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 291 DRM_FORMAT_UYVY}; | 310 DRM_FORMAT_UYVY}; |
| 292 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); | 311 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); |
| 293 ui::FakePlaneInfo overlay_info(101, 1 << 0, | 312 ui::FakePlaneInfo overlay_info(101, 1 << 0, |
| 294 std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 313 std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 295 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 314 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 296 plane_manager_->SetPlaneProperties(planes_info); | 315 plane_manager_->SetPlaneProperties(planes_info); |
| 297 overlay_validator_->ClearCache(); | 316 overlay_validator_->ClearCache(); |
| 298 | 317 |
| 299 std::vector<ui::OverlayCheck_Params> validated_params = | 318 std::vector<ui::OverlayCheck_Params> validated_params = |
| 300 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), | 319 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 301 buffer_generator_.get()); | 320 ui::OverlayPlaneList plane_list = |
| 302 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( | 321 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 303 plane_list_.back(), plane_list_); | 322 EXPECT_EQ(DRM_FORMAT_XRGB8888, |
| 304 | 323 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 305 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); | |
| 306 EXPECT_EQ(3, plane_manager_->plane_count()); | 324 EXPECT_EQ(3, plane_manager_->plane_count()); |
| 307 for (const auto& param : validated_params) | 325 for (const auto& param : validated_params) |
| 308 EXPECT_EQ(true, param.is_overlay_candidate); | 326 EXPECT_EQ(true, param.is_overlay_candidate); |
| 309 } | 327 } |
| 310 | 328 |
| 311 TEST_F(DrmOverlayValidatorTest, RejectYUVBuffersIfNotSupported) { | 329 TEST_F(DrmOverlayValidatorTest, RejectYUVBuffersIfNotSupported) { |
| 312 plane_manager_->ResetPlaneCount(); | 330 plane_manager_->ResetPlaneCount(); |
| 313 // Check case where buffer storage format is already UYVY but planes dont | 331 // Check case where buffer storage format is already UYVY but planes dont |
| 314 // support it. | 332 // support it. |
| 315 overlay_params_.back().buffer_size = overlay_rect_.size(); | 333 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 316 overlay_params_.back().display_rect = overlay_rect_; | 334 overlay_params_.back().display_rect = overlay_rect_; |
| 317 plane_list_.back().display_bounds = overlay_rect_; | 335 plane_list_.back().display_bounds = overlay_rect_; |
| 318 | 336 |
| 319 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 337 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 320 DRM_FORMAT_UYVY}; | 338 DRM_FORMAT_UYVY}; |
| 321 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); | 339 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); |
| 322 ui::FakePlaneInfo overlay_info(101, 1 << 0, | 340 ui::FakePlaneInfo overlay_info(101, 1 << 0, |
| 323 std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 341 std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 324 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 342 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 325 plane_manager_->SetPlaneProperties(planes_info); | 343 plane_manager_->SetPlaneProperties(planes_info); |
| 326 overlay_validator_->ClearCache(); | 344 overlay_validator_->ClearCache(); |
| 327 | 345 |
| 328 std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_; | 346 std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_; |
| 329 validated_params.back().format = gfx::BufferFormat::UYVY_422; | 347 validated_params.back().format = gfx::BufferFormat::UYVY_422; |
| 330 plane_manager_->ResetPlaneCount(); | 348 plane_manager_->ResetPlaneCount(); |
| 331 validated_params = overlay_validator_->TestPageFlip( | 349 validated_params = overlay_validator_->TestPageFlip(validated_params, |
| 332 validated_params, ui::OverlayPlaneList(), buffer_generator_.get()); | 350 ui::OverlayPlaneList()); |
| 333 | 351 |
| 334 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); | 352 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); |
| 335 } | 353 } |
| 336 | 354 |
| 337 TEST_F(DrmOverlayValidatorTest, | 355 TEST_F(DrmOverlayValidatorTest, |
| 338 RejectYUVBuffersIfNotSupported_MirroredControllers) { | 356 RejectYUVBuffersIfNotSupported_MirroredControllers) { |
| 339 std::vector<uint32_t> crtcs{kDefaultCrtc, kSecondaryCrtc}; | 357 std::vector<uint32_t> crtcs{kDefaultCrtc, kSecondaryCrtc}; |
| 340 plane_manager_->SetCrtcInfo(crtcs); | 358 plane_manager_->SetCrtcInfo(crtcs); |
| 341 | 359 |
| 342 std::vector<uint32_t> only_rgb_format{DRM_FORMAT_XRGB8888}; | 360 std::vector<uint32_t> only_rgb_format{DRM_FORMAT_XRGB8888}; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 361 | 379 |
| 362 std::vector<ui::FakePlaneInfo> planes_info{ | 380 std::vector<ui::FakePlaneInfo> planes_info{ |
| 363 primary_crtc_primary_plane, primary_crtc_overlay, | 381 primary_crtc_primary_plane, primary_crtc_overlay, |
| 364 secondary_crtc_primary_plane, secondary_crtc_overlay}; | 382 secondary_crtc_primary_plane, secondary_crtc_overlay}; |
| 365 plane_manager_->SetPlaneProperties(planes_info); | 383 plane_manager_->SetPlaneProperties(planes_info); |
| 366 overlay_validator_->ClearCache(); | 384 overlay_validator_->ClearCache(); |
| 367 | 385 |
| 368 std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_; | 386 std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_; |
| 369 validated_params.back().format = gfx::BufferFormat::UYVY_422; | 387 validated_params.back().format = gfx::BufferFormat::UYVY_422; |
| 370 plane_manager_->ResetPlaneCount(); | 388 plane_manager_->ResetPlaneCount(); |
| 371 validated_params = overlay_validator_->TestPageFlip( | 389 validated_params = overlay_validator_->TestPageFlip(validated_params, |
| 372 validated_params, ui::OverlayPlaneList(), buffer_generator_.get()); | 390 ui::OverlayPlaneList()); |
| 373 | 391 |
| 374 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); | 392 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); |
| 375 | 393 |
| 376 // Both controllers have Overlay which support DRM_FORMAT_UYVY, hence this | 394 // Both controllers have Overlay which support DRM_FORMAT_UYVY, hence this |
| 377 // should be picked as the optimal format. | 395 // should be picked as the optimal format. |
| 378 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( | 396 ui::OverlayPlaneList plane_list = |
| 379 plane_list_.back(), plane_list_); | 397 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 380 EXPECT_EQ(DRM_FORMAT_UYVY, optimal_format); | 398 EXPECT_EQ(DRM_FORMAT_UYVY, |
| 399 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 381 | 400 |
| 382 // This configuration should not be promoted to Overlay when either of the | 401 // This configuration should not be promoted to Overlay when either of the |
| 383 // controllers dont support UYVY format. | 402 // controllers dont support UYVY format. |
| 384 | 403 |
| 385 // Check case where we dont have support for packed formats in Mirrored CRTC. | 404 // Check case where we dont have support for packed formats in Mirrored CRTC. |
| 386 planes_info.back().allowed_formats = only_rgb_format; | 405 planes_info.back().allowed_formats = only_rgb_format; |
| 387 plane_manager_->SetPlaneProperties(planes_info); | 406 plane_manager_->SetPlaneProperties(planes_info); |
| 388 overlay_validator_->ClearCache(); | 407 overlay_validator_->ClearCache(); |
| 389 | 408 |
| 390 validated_params = overlay_validator_->TestPageFlip( | 409 validated_params = overlay_validator_->TestPageFlip(validated_params, |
| 391 validated_params, ui::OverlayPlaneList(), buffer_generator_.get()); | 410 ui::OverlayPlaneList()); |
| 392 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); | 411 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); |
| 393 | 412 |
| 394 // Check case where we dont have support for packed formats in primary | 413 // Check case where we dont have support for packed formats in primary |
| 395 // display. | 414 // display. |
| 396 planes_info.back().allowed_formats = xrgb_yuv_packed_formats; | 415 planes_info.back().allowed_formats = xrgb_yuv_packed_formats; |
| 397 planes_info[1].allowed_formats = only_rgb_format; | 416 planes_info[1].allowed_formats = only_rgb_format; |
| 398 plane_manager_->SetPlaneProperties(planes_info); | 417 plane_manager_->SetPlaneProperties(planes_info); |
| 399 overlay_validator_->ClearCache(); | 418 overlay_validator_->ClearCache(); |
| 400 | 419 |
| 401 validated_params = overlay_validator_->TestPageFlip( | 420 validated_params = overlay_validator_->TestPageFlip(validated_params, |
| 402 validated_params, ui::OverlayPlaneList(), buffer_generator_.get()); | 421 ui::OverlayPlaneList()); |
| 403 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); | 422 EXPECT_EQ(false, validated_params.back().is_overlay_candidate); |
| 404 controller->RemoveCrtc(drm_, kSecondaryCrtc); | 423 controller->RemoveCrtc(drm_, kSecondaryCrtc); |
| 405 } | 424 } |
| 406 | 425 |
| 407 TEST_F(DrmOverlayValidatorTest, OptimalFormatYUV_MirroredControllers) { | 426 TEST_F(DrmOverlayValidatorTest, OptimalFormatYUV_MirroredControllers) { |
| 408 std::vector<uint32_t> crtcs{kDefaultCrtc, kSecondaryCrtc}; | 427 std::vector<uint32_t> crtcs{kDefaultCrtc, kSecondaryCrtc}; |
| 409 plane_manager_->SetCrtcInfo(crtcs); | 428 plane_manager_->SetCrtcInfo(crtcs); |
| 410 overlay_validator_->ClearCache(); | 429 overlay_validator_->ClearCache(); |
| 411 | 430 |
| 412 ui::HardwareDisplayController* controller = window_->GetController(); | 431 ui::HardwareDisplayController* controller = window_->GetController(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 430 xrgb_yuv_packed_formats); | 449 xrgb_yuv_packed_formats); |
| 431 | 450 |
| 432 std::vector<ui::FakePlaneInfo> planes_info{ | 451 std::vector<ui::FakePlaneInfo> planes_info{ |
| 433 primary_crtc_primary_plane, primary_crtc_overlay, | 452 primary_crtc_primary_plane, primary_crtc_overlay, |
| 434 secondary_crtc_primary_plane, secondary_crtc_overlay}; | 453 secondary_crtc_primary_plane, secondary_crtc_overlay}; |
| 435 plane_manager_->SetPlaneProperties(planes_info); | 454 plane_manager_->SetPlaneProperties(planes_info); |
| 436 overlay_validator_->ClearCache(); | 455 overlay_validator_->ClearCache(); |
| 437 | 456 |
| 438 plane_manager_->ResetPlaneCount(); | 457 plane_manager_->ResetPlaneCount(); |
| 439 std::vector<ui::OverlayCheck_Params> validated_params = | 458 std::vector<ui::OverlayCheck_Params> validated_params = |
| 440 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), | 459 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 441 buffer_generator_.get()); | |
| 442 | 460 |
| 443 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); | 461 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); |
| 444 // Both controllers have Overlay which support DRM_FORMAT_UYVY, hence this | 462 // Both controllers have Overlay which support DRM_FORMAT_UYVY, hence this |
| 445 // should be picked as the optimal format. | 463 // should be picked as the optimal format. |
| 446 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( | 464 ui::OverlayPlaneList plane_list = |
| 447 plane_list_.back(), plane_list_); | 465 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 448 EXPECT_EQ(DRM_FORMAT_UYVY, optimal_format); | 466 EXPECT_EQ(DRM_FORMAT_UYVY, |
| 467 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 449 | 468 |
| 450 // DRM_FORMAT_XRGB8888 should be the preferred format when either of the | 469 // DRM_FORMAT_XRGB8888 should be the preferred format when either of the |
| 451 // controllers dont support UYVY format. | 470 // controllers dont support UYVY format. |
| 452 | 471 |
| 453 // Check case where we dont have support for packed formats in Mirrored CRTC. | 472 // Check case where we dont have support for packed formats in Mirrored CRTC. |
| 454 planes_info.back().allowed_formats = only_rgb_format; | 473 planes_info.back().allowed_formats = only_rgb_format; |
| 455 plane_manager_->SetPlaneProperties(planes_info); | 474 plane_manager_->SetPlaneProperties(planes_info); |
| 456 overlay_validator_->ClearCache(); | 475 overlay_validator_->ClearCache(); |
| 457 | 476 |
| 458 validated_params = overlay_validator_->TestPageFlip( | 477 validated_params = |
| 459 overlay_params_, ui::OverlayPlaneList(), buffer_generator_.get()); | 478 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 460 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); | 479 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); |
| 461 | 480 |
| 462 optimal_format = overlay_validator_->GetOptimalBufferFormat( | 481 plane_list = overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 463 plane_list_.back(), plane_list_); | 482 EXPECT_EQ(DRM_FORMAT_XRGB8888, |
| 464 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); | 483 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 465 | 484 |
| 466 // Check case where we dont have support for packed formats in primary | 485 // Check case where we dont have support for packed formats in primary |
| 467 // display. | 486 // display. |
| 468 planes_info.back().allowed_formats = xrgb_yuv_packed_formats; | 487 planes_info.back().allowed_formats = xrgb_yuv_packed_formats; |
| 469 planes_info[1].allowed_formats = only_rgb_format; | 488 planes_info[1].allowed_formats = only_rgb_format; |
| 470 plane_manager_->SetPlaneProperties(planes_info); | 489 plane_manager_->SetPlaneProperties(planes_info); |
| 471 overlay_validator_->ClearCache(); | 490 overlay_validator_->ClearCache(); |
| 472 | 491 |
| 473 validated_params = overlay_validator_->TestPageFlip( | 492 validated_params = |
| 474 overlay_params_, ui::OverlayPlaneList(), buffer_generator_.get()); | 493 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 475 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); | 494 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); |
| 476 | 495 |
| 477 optimal_format = overlay_validator_->GetOptimalBufferFormat( | 496 plane_list = overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 478 plane_list_.back(), plane_list_); | 497 EXPECT_EQ(DRM_FORMAT_XRGB8888, |
| 479 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); | 498 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 480 controller->RemoveCrtc(drm_, kSecondaryCrtc); | 499 controller->RemoveCrtc(drm_, kSecondaryCrtc); |
| 481 } | 500 } |
| 501 |
| 502 TEST_F(DrmOverlayValidatorTest, OptimizeOnlyIfProcessingCallbackPresent) { |
| 503 // This test checks that we dont manipulate overlay buffers in case Processing |
| 504 // callback is not present. |
| 505 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 506 overlay_params_.back().display_rect = overlay_rect_; |
| 507 plane_list_.back().display_bounds = overlay_rect_; |
| 508 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 509 DRM_FORMAT_UYVY}; |
| 510 |
| 511 ui::FakePlaneInfo primary_plane_info( |
| 512 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 513 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 514 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 515 plane_manager_->SetPlaneProperties(planes_info); |
| 516 overlay_validator_->ClearCache(); |
| 517 |
| 518 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 519 |
| 520 ui::OverlayPlaneList plane_list = |
| 521 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 522 EXPECT_EQ(DRM_FORMAT_UYVY, |
| 523 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 524 plane_list_.back().processing_callback.Reset(); |
| 525 plane_list = overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 526 EXPECT_EQ(plane_list_.back().buffer->GetFramebufferPixelFormat(), |
| 527 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 528 plane_list_.back().processing_callback = process_buffer_handler_; |
| 529 } |
| 530 |
| 531 TEST_F(DrmOverlayValidatorTest, DontResetOriginalBufferIfProcessedIsInvalid) { |
| 532 // This test checks that we dont manipulate overlay buffers in case Processing |
| 533 // callback is not present. |
| 534 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 535 overlay_params_.back().display_rect = overlay_rect_; |
| 536 plane_list_.back().display_bounds = overlay_rect_; |
| 537 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 538 DRM_FORMAT_UYVY}; |
| 539 |
| 540 ui::FakePlaneInfo primary_plane_info( |
| 541 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 542 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 543 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 544 plane_manager_->SetPlaneProperties(planes_info); |
| 545 overlay_validator_->ClearCache(); |
| 546 |
| 547 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 548 |
| 549 ui::OverlayPlaneList plane_list = |
| 550 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 551 EXPECT_EQ(DRM_FORMAT_UYVY, |
| 552 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 553 plane_list_.back().processing_callback = base::Bind( |
| 554 &DrmOverlayValidatorTest::ReturnNullBuffer, base::Unretained(this)); |
| 555 |
| 556 plane_list = overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 557 EXPECT_EQ(plane_list_.back().buffer->GetFramebufferPixelFormat(), |
| 558 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 559 plane_list_.back().processing_callback = base::Bind( |
| 560 &DrmOverlayValidatorTest::ProcessBuffer, base::Unretained(this)); |
| 561 } |
| OLD | NEW |