| 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 "cc/surfaces/display.h" | 5 #include "cc/surfaces/display.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/test/null_task_runner.h" | 10 #include "base/test/null_task_runner.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 void CopyCallback(bool* called, std::unique_ptr<CopyOutputResult> result) { | 172 void CopyCallback(bool* called, std::unique_ptr<CopyOutputResult> result) { |
| 173 *called = true; | 173 *called = true; |
| 174 } | 174 } |
| 175 | 175 |
| 176 // Check that frame is damaged and swapped only under correct conditions. | 176 // Check that frame is damaged and swapped only under correct conditions. |
| 177 TEST_F(DisplayTest, DisplayDamaged) { | 177 TEST_F(DisplayTest, DisplayDamaged) { |
| 178 RendererSettings settings; | 178 RendererSettings settings; |
| 179 settings.partial_swap_enabled = true; | 179 settings.partial_swap_enabled = true; |
| 180 settings.finish_rendering_on_resize = true; | 180 settings.finish_rendering_on_resize = true; |
| 181 SetUpDisplay(settings, nullptr); | 181 SetUpDisplay(settings, nullptr); |
| 182 gfx::ColorSpace color_space_1 = gfx::ColorSpace::CreateXYZD50(); |
| 183 gfx::ColorSpace color_space_2 = gfx::ColorSpace::CreateSCRGBLinear(); |
| 182 | 184 |
| 183 StubDisplayClient client; | 185 StubDisplayClient client; |
| 184 display_->Initialize(&client, &manager_); | 186 display_->Initialize(&client, &manager_); |
| 187 display_->SetColorSpace(color_space_1); |
| 185 | 188 |
| 186 LocalSurfaceId local_surface_id(id_allocator_.GenerateId()); | 189 LocalSurfaceId local_surface_id(id_allocator_.GenerateId()); |
| 187 EXPECT_FALSE(scheduler_->damaged); | 190 EXPECT_FALSE(scheduler_->damaged); |
| 188 EXPECT_FALSE(scheduler_->has_new_root_surface); | 191 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 189 display_->SetLocalSurfaceId(local_surface_id, 1.f); | 192 display_->SetLocalSurfaceId(local_surface_id, 1.f); |
| 190 EXPECT_FALSE(scheduler_->damaged); | 193 EXPECT_FALSE(scheduler_->damaged); |
| 191 EXPECT_FALSE(scheduler_->display_resized_); | 194 EXPECT_FALSE(scheduler_->display_resized_); |
| 192 EXPECT_TRUE(scheduler_->has_new_root_surface); | 195 EXPECT_TRUE(scheduler_->has_new_root_surface); |
| 193 | 196 |
| 194 scheduler_->ResetDamageForTest(); | 197 scheduler_->ResetDamageForTest(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 206 pass_list.push_back(std::move(pass)); | 209 pass_list.push_back(std::move(pass)); |
| 207 | 210 |
| 208 scheduler_->ResetDamageForTest(); | 211 scheduler_->ResetDamageForTest(); |
| 209 SubmitCompositorFrame(&pass_list, local_surface_id); | 212 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 210 EXPECT_TRUE(scheduler_->damaged); | 213 EXPECT_TRUE(scheduler_->damaged); |
| 211 EXPECT_FALSE(scheduler_->display_resized_); | 214 EXPECT_FALSE(scheduler_->display_resized_); |
| 212 EXPECT_FALSE(scheduler_->has_new_root_surface); | 215 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 213 | 216 |
| 214 EXPECT_FALSE(scheduler_->swapped); | 217 EXPECT_FALSE(scheduler_->swapped); |
| 215 EXPECT_EQ(0u, output_surface_->num_sent_frames()); | 218 EXPECT_EQ(0u, output_surface_->num_sent_frames()); |
| 219 EXPECT_EQ(gfx::ColorSpace(), output_surface_->last_reshape_color_space()); |
| 216 display_->DrawAndSwap(); | 220 display_->DrawAndSwap(); |
| 221 EXPECT_EQ(color_space_1, output_surface_->last_reshape_color_space()); |
| 217 EXPECT_TRUE(scheduler_->swapped); | 222 EXPECT_TRUE(scheduler_->swapped); |
| 218 EXPECT_EQ(1u, output_surface_->num_sent_frames()); | 223 EXPECT_EQ(1u, output_surface_->num_sent_frames()); |
| 219 EXPECT_EQ(gfx::Size(100, 100), | 224 EXPECT_EQ(gfx::Size(100, 100), |
| 220 software_output_device_->viewport_pixel_size()); | 225 software_output_device_->viewport_pixel_size()); |
| 221 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), software_output_device_->damage_rect()); | 226 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), software_output_device_->damage_rect()); |
| 222 | 227 |
| 223 { | 228 { |
| 224 // Only damaged portion should be swapped. | 229 // Only damaged portion should be swapped. |
| 225 pass = RenderPass::Create(); | 230 pass = RenderPass::Create(); |
| 226 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 231 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 227 pass->damage_rect = gfx::Rect(10, 10, 1, 1); | 232 pass->damage_rect = gfx::Rect(10, 10, 1, 1); |
| 228 pass->id = 1; | 233 pass->id = 1; |
| 229 | 234 |
| 230 pass_list.push_back(std::move(pass)); | 235 pass_list.push_back(std::move(pass)); |
| 231 scheduler_->ResetDamageForTest(); | 236 scheduler_->ResetDamageForTest(); |
| 232 SubmitCompositorFrame(&pass_list, local_surface_id); | 237 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 233 EXPECT_TRUE(scheduler_->damaged); | 238 EXPECT_TRUE(scheduler_->damaged); |
| 234 EXPECT_FALSE(scheduler_->display_resized_); | 239 EXPECT_FALSE(scheduler_->display_resized_); |
| 235 EXPECT_FALSE(scheduler_->has_new_root_surface); | 240 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 236 | 241 |
| 237 scheduler_->swapped = false; | 242 scheduler_->swapped = false; |
| 243 EXPECT_EQ(color_space_1, output_surface_->last_reshape_color_space()); |
| 244 display_->SetColorSpace(color_space_2); |
| 238 display_->DrawAndSwap(); | 245 display_->DrawAndSwap(); |
| 246 EXPECT_EQ(color_space_2, output_surface_->last_reshape_color_space()); |
| 239 EXPECT_TRUE(scheduler_->swapped); | 247 EXPECT_TRUE(scheduler_->swapped); |
| 240 EXPECT_EQ(2u, output_surface_->num_sent_frames()); | 248 EXPECT_EQ(2u, output_surface_->num_sent_frames()); |
| 241 EXPECT_EQ(gfx::Size(100, 100), | 249 EXPECT_EQ(gfx::Size(100, 100), |
| 242 software_output_device_->viewport_pixel_size()); | 250 software_output_device_->viewport_pixel_size()); |
| 243 EXPECT_EQ(gfx::Rect(10, 10, 1, 1), software_output_device_->damage_rect()); | 251 EXPECT_EQ(gfx::Rect(10, 10, 1, 1), software_output_device_->damage_rect()); |
| 244 } | 252 } |
| 245 | 253 |
| 246 { | 254 { |
| 247 // Pass has no damage so shouldn't be swapped. | 255 // Pass has no damage so shouldn't be swapped. |
| 248 pass = RenderPass::Create(); | 256 pass = RenderPass::Create(); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 // Verify DidLoseOutputSurface callback is hooked up correctly. | 515 // Verify DidLoseOutputSurface callback is hooked up correctly. |
| 508 EXPECT_EQ(0, client.loss_count()); | 516 EXPECT_EQ(0, client.loss_count()); |
| 509 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM( | 517 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM( |
| 510 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | 518 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 511 output_surface_->context_provider()->ContextGL()->Flush(); | 519 output_surface_->context_provider()->ContextGL()->Flush(); |
| 512 EXPECT_EQ(1, client.loss_count()); | 520 EXPECT_EQ(1, client.loss_count()); |
| 513 } | 521 } |
| 514 | 522 |
| 515 } // namespace | 523 } // namespace |
| 516 } // namespace cc | 524 } // namespace cc |
| OLD | NEW |