Chromium Code Reviews| 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; | |
| 1114 result.did_swap = false; | 1113 result.did_swap = false; |
|
danakj
2014/01/29 21:56:29
these already init to false right? maybe we don't
enne (OOO)
2014/01/29 23:09:23
Done.
| |
| 1115 result.did_readback = false; | 1114 result.did_readback = false; |
| 1115 | |
| 1116 DCHECK(IsImplThread()); | 1116 DCHECK(IsImplThread()); |
| 1117 DCHECK(impl().layer_tree_host_impl.get()); | 1117 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 | 1118 |
| 1125 base::TimeTicks start_time = base::TimeTicks::HighResNow(); | 1119 base::TimeTicks start_time = base::TimeTicks::HighResNow(); |
| 1126 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); | 1120 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); |
| 1127 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); | 1121 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); |
| 1128 | 1122 |
| 1129 // Advance our animations. | 1123 // Advance our animations. |
| 1130 base::TimeTicks monotonic_time = | 1124 base::TimeTicks monotonic_time = |
| 1131 impl().layer_tree_host_impl->CurrentFrameTimeTicks(); | 1125 impl().layer_tree_host_impl->CurrentFrameTimeTicks(); |
| 1132 base::Time wall_clock_time = impl().layer_tree_host_impl->CurrentFrameTime(); | 1126 base::Time wall_clock_time = impl().layer_tree_host_impl->CurrentFrameTime(); |
| 1133 | 1127 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1154 LayerTreeHostImpl::FrameData frame; | 1148 LayerTreeHostImpl::FrameData frame; |
| 1155 bool draw_frame = false; | 1149 bool draw_frame = false; |
| 1156 | 1150 |
| 1157 if (impl().layer_tree_host_impl->CanDraw() && | 1151 if (impl().layer_tree_host_impl->CanDraw() && |
| 1158 (!drawing_for_readback || can_do_readback)) { | 1152 (!drawing_for_readback || can_do_readback)) { |
| 1159 // If it is for a readback, make sure we draw the portion being read back. | 1153 // If it is for a readback, make sure we draw the portion being read back. |
| 1160 gfx::Rect readback_rect; | 1154 gfx::Rect readback_rect; |
| 1161 if (drawing_for_readback) | 1155 if (drawing_for_readback) |
| 1162 readback_rect = impl().readback_request->rect; | 1156 readback_rect = impl().readback_request->rect; |
| 1163 | 1157 |
| 1164 if (impl().layer_tree_host_impl->PrepareToDraw(&frame, readback_rect) || | 1158 result.draw_result = |
| 1165 forced_draw) | 1159 impl().layer_tree_host_impl->PrepareToDraw(&frame, readback_rect); |
| 1166 draw_frame = true; | 1160 draw_frame = forced_draw || |
| 1161 result.draw_result == DrawSwapReadbackResult::DRAW_SUCCESS; | |
| 1167 } | 1162 } |
| 1168 | 1163 |
| 1169 if (draw_frame) { | 1164 if (draw_frame) { |
| 1170 impl().layer_tree_host_impl->DrawLayers( | 1165 impl().layer_tree_host_impl->DrawLayers( |
| 1171 &frame, impl().scheduler->LastBeginImplFrameTime()); | 1166 &frame, impl().scheduler->LastBeginImplFrameTime()); |
| 1172 result.did_draw = true; | 1167 result.draw_result = DrawSwapReadbackResult::DRAW_SUCCESS; |
| 1168 } else { | |
| 1169 DCHECK_NE(DrawSwapReadbackResult::DRAW_SUCCESS, result.draw_result); | |
| 1173 } | 1170 } |
| 1174 impl().layer_tree_host_impl->DidDrawAllLayers(frame); | 1171 impl().layer_tree_host_impl->DidDrawAllLayers(frame); |
| 1175 | 1172 |
| 1176 bool start_ready_animations = draw_frame; | 1173 bool start_ready_animations = draw_frame; |
| 1177 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); | 1174 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); |
| 1178 | 1175 |
| 1179 // Check for a pending CompositeAndReadback. | 1176 // Check for a pending CompositeAndReadback. |
| 1180 if (drawing_for_readback) { | 1177 if (drawing_for_readback) { |
| 1181 DCHECK(!swap_requested); | 1178 DCHECK(!swap_requested); |
| 1182 result.did_readback = false; | 1179 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( | 1677 impl().commit_to_activate_duration_history.InsertSample( |
| 1681 base::TimeTicks::HighResNow() - impl().commit_complete_time); | 1678 base::TimeTicks::HighResNow() - impl().commit_complete_time); |
| 1682 } | 1679 } |
| 1683 | 1680 |
| 1684 void ThreadProxy::DidManageTiles() { | 1681 void ThreadProxy::DidManageTiles() { |
| 1685 DCHECK(IsImplThread()); | 1682 DCHECK(IsImplThread()); |
| 1686 impl().scheduler->DidManageTiles(); | 1683 impl().scheduler->DidManageTiles(); |
| 1687 } | 1684 } |
| 1688 | 1685 |
| 1689 } // namespace cc | 1686 } // namespace cc |
| OLD | NEW |