OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "cc/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.h" |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 have_copy_requests || (have_damage && size_matches); | 232 have_copy_requests || (have_damage && size_matches); |
233 | 233 |
234 // If the surface is suspended then the resources to be used by the draw are | 234 // If the surface is suspended then the resources to be used by the draw are |
235 // likely destroyed. | 235 // likely destroyed. |
236 if (output_surface_->SurfaceIsSuspendForRecycle()) { | 236 if (output_surface_->SurfaceIsSuspendForRecycle()) { |
237 TRACE_EVENT_INSTANT0("cc", "Surface is suspended for recycle.", | 237 TRACE_EVENT_INSTANT0("cc", "Surface is suspended for recycle.", |
238 TRACE_EVENT_SCOPE_THREAD); | 238 TRACE_EVENT_SCOPE_THREAD); |
239 should_draw = false; | 239 should_draw = false; |
240 } | 240 } |
241 | 241 |
| 242 DrawFrameResult draw_result = DrawFrameResult::DID_DRAW; |
242 if (should_draw) { | 243 if (should_draw) { |
243 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); | 244 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); |
244 gfx::Rect device_clip_rect = | 245 gfx::Rect device_clip_rect = |
245 external_clip_.IsEmpty() ? device_viewport_rect : external_clip_; | 246 external_clip_.IsEmpty() ? device_viewport_rect : external_clip_; |
246 bool disable_picture_quad_image_filtering = false; | 247 bool disable_picture_quad_image_filtering = false; |
247 | 248 |
248 renderer_->DecideRenderPassAllocationsForFrame( | 249 renderer_->DecideRenderPassAllocationsForFrame( |
249 frame_data->render_pass_list); | 250 frame_data->render_pass_list); |
250 renderer_->DrawFrame(&frame_data->render_pass_list, device_scale_factor_, | 251 draw_result = renderer_->DrawFrame(&frame_data->render_pass_list, |
251 device_viewport_rect, device_clip_rect, | 252 device_scale_factor_, |
252 disable_picture_quad_image_filtering); | 253 device_viewport_rect, device_clip_rect, |
| 254 disable_picture_quad_image_filtering); |
253 } else { | 255 } else { |
254 TRACE_EVENT_INSTANT0("cc", "Draw skipped.", TRACE_EVENT_SCOPE_THREAD); | 256 TRACE_EVENT_INSTANT0("cc", "Draw skipped.", TRACE_EVENT_SCOPE_THREAD); |
255 } | 257 } |
256 | 258 |
257 bool should_swap = should_draw && size_matches; | 259 // If drawing was skipped because overlays removed the damage, swapping should |
| 260 // be skipped too. |
| 261 bool should_skip_swap = |
| 262 have_damage && draw_result == DrawFrameResult::DAMAGE_DRAWN_BY_OVERLAYS && |
| 263 output_surface_->capabilities().schedules_overlays_without_swap; |
| 264 bool should_swap = should_draw && size_matches && !should_skip_swap; |
258 if (should_swap) { | 265 if (should_swap) { |
259 swapped_since_resize_ = true; | 266 swapped_since_resize_ = true; |
260 for (auto& latency : frame->metadata.latency_info) { | 267 for (auto& latency : frame->metadata.latency_info) { |
261 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", | 268 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", |
262 TRACE_ID_DONT_MANGLE(latency.trace_id()), | 269 TRACE_ID_DONT_MANGLE(latency.trace_id()), |
263 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, | 270 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, |
264 "step", "Display::DrawAndSwap"); | 271 "step", "Display::DrawAndSwap"); |
265 } | 272 } |
266 benchmark_instrumentation::IssueDisplayRenderingStatsEvent(); | 273 benchmark_instrumentation::IssueDisplayRenderingStatsEvent(); |
267 renderer_->SwapBuffers(frame->metadata); | 274 renderer_->SwapBuffers(frame->metadata); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 360 |
354 if (surface_id == current_surface_id_) | 361 if (surface_id == current_surface_id_) |
355 UpdateRootSurfaceResourcesLocked(); | 362 UpdateRootSurfaceResourcesLocked(); |
356 } | 363 } |
357 | 364 |
358 SurfaceId Display::CurrentSurfaceId() { | 365 SurfaceId Display::CurrentSurfaceId() { |
359 return current_surface_id_; | 366 return current_surface_id_; |
360 } | 367 } |
361 | 368 |
362 } // namespace cc | 369 } // namespace cc |
OLD | NEW |