OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 base::Bind(&ThreadProxy::CreateAndInitializeOutputSurface, | 1103 base::Bind(&ThreadProxy::CreateAndInitializeOutputSurface, |
1104 main_thread_weak_ptr_)); | 1104 main_thread_weak_ptr_)); |
1105 } | 1105 } |
1106 | 1106 |
1107 DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal( | 1107 DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal( |
1108 bool forced_draw, | 1108 bool forced_draw, |
1109 bool swap_requested, | 1109 bool swap_requested, |
1110 bool readback_requested) { | 1110 bool readback_requested) { |
1111 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 1111 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
1112 DrawSwapReadbackResult result; | 1112 DrawSwapReadbackResult result; |
1113 result.did_draw = false; | 1113 |
1114 result.did_swap = false; | |
1115 result.did_readback = false; | |
1116 DCHECK(IsImplThread()); | 1114 DCHECK(IsImplThread()); |
1117 DCHECK(impl().layer_tree_host_impl.get()); | 1115 DCHECK(impl().layer_tree_host_impl.get()); |
1118 if (!impl().layer_tree_host_impl) | |
1119 return result; | |
1120 | |
1121 DCHECK(impl().layer_tree_host_impl->renderer()); | |
1122 if (!impl().layer_tree_host_impl->renderer()) | |
1123 return result; | |
1124 | 1116 |
1125 base::TimeTicks start_time = base::TimeTicks::HighResNow(); | 1117 base::TimeTicks start_time = base::TimeTicks::HighResNow(); |
1126 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); | 1118 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); |
1127 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); | 1119 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); |
1128 | 1120 |
1129 // Advance our animations. | 1121 // Advance our animations. |
1130 base::TimeTicks monotonic_time = | 1122 base::TimeTicks monotonic_time = |
1131 impl().layer_tree_host_impl->CurrentFrameTimeTicks(); | 1123 impl().layer_tree_host_impl->CurrentFrameTimeTicks(); |
1132 base::Time wall_clock_time = impl().layer_tree_host_impl->CurrentFrameTime(); | 1124 base::Time wall_clock_time = impl().layer_tree_host_impl->CurrentFrameTime(); |
1133 | 1125 |
(...skipping 20 matching lines...) Expand all Loading... |
1154 LayerTreeHostImpl::FrameData frame; | 1146 LayerTreeHostImpl::FrameData frame; |
1155 bool draw_frame = false; | 1147 bool draw_frame = false; |
1156 | 1148 |
1157 if (impl().layer_tree_host_impl->CanDraw() && | 1149 if (impl().layer_tree_host_impl->CanDraw() && |
1158 (!drawing_for_readback || can_do_readback)) { | 1150 (!drawing_for_readback || can_do_readback)) { |
1159 // If it is for a readback, make sure we draw the portion being read back. | 1151 // If it is for a readback, make sure we draw the portion being read back. |
1160 gfx::Rect readback_rect; | 1152 gfx::Rect readback_rect; |
1161 if (drawing_for_readback) | 1153 if (drawing_for_readback) |
1162 readback_rect = impl().readback_request->rect; | 1154 readback_rect = impl().readback_request->rect; |
1163 | 1155 |
1164 if (impl().layer_tree_host_impl->PrepareToDraw(&frame, readback_rect) || | 1156 result.draw_result = |
1165 forced_draw) | 1157 impl().layer_tree_host_impl->PrepareToDraw(&frame, readback_rect); |
1166 draw_frame = true; | 1158 draw_frame = forced_draw || |
| 1159 result.draw_result == DrawSwapReadbackResult::DRAW_SUCCESS; |
1167 } | 1160 } |
1168 | 1161 |
1169 if (draw_frame) { | 1162 if (draw_frame) { |
1170 impl().layer_tree_host_impl->DrawLayers( | 1163 impl().layer_tree_host_impl->DrawLayers( |
1171 &frame, impl().scheduler->LastBeginImplFrameTime()); | 1164 &frame, impl().scheduler->LastBeginImplFrameTime()); |
1172 result.did_draw = true; | 1165 result.draw_result = DrawSwapReadbackResult::DRAW_SUCCESS; |
| 1166 } else { |
| 1167 DCHECK_NE(DrawSwapReadbackResult::DRAW_SUCCESS, result.draw_result); |
1173 } | 1168 } |
1174 impl().layer_tree_host_impl->DidDrawAllLayers(frame); | 1169 impl().layer_tree_host_impl->DidDrawAllLayers(frame); |
1175 | 1170 |
1176 bool start_ready_animations = draw_frame; | 1171 bool start_ready_animations = draw_frame; |
1177 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); | 1172 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); |
1178 | 1173 |
1179 // Check for a pending CompositeAndReadback. | 1174 // Check for a pending CompositeAndReadback. |
1180 if (drawing_for_readback) { | 1175 if (drawing_for_readback) { |
1181 DCHECK(!swap_requested); | 1176 DCHECK(!swap_requested); |
1182 result.did_readback = false; | 1177 result.did_readback = false; |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 impl().commit_to_activate_duration_history.InsertSample( | 1675 impl().commit_to_activate_duration_history.InsertSample( |
1681 base::TimeTicks::HighResNow() - impl().commit_complete_time); | 1676 base::TimeTicks::HighResNow() - impl().commit_complete_time); |
1682 } | 1677 } |
1683 | 1678 |
1684 void ThreadProxy::DidManageTiles() { | 1679 void ThreadProxy::DidManageTiles() { |
1685 DCHECK(IsImplThread()); | 1680 DCHECK(IsImplThread()); |
1686 impl().scheduler->DidManageTiles(); | 1681 impl().scheduler->DidManageTiles(); |
1687 } | 1682 } |
1688 | 1683 |
1689 } // namespace cc | 1684 } // namespace cc |
OLD | NEW |