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 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1081 base::Bind(&ThreadProxy::CreateAndInitializeOutputSurface, | 1081 base::Bind(&ThreadProxy::CreateAndInitializeOutputSurface, |
1082 main_thread_weak_ptr_)); | 1082 main_thread_weak_ptr_)); |
1083 } | 1083 } |
1084 | 1084 |
1085 DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal( | 1085 DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal( |
1086 bool forced_draw, | 1086 bool forced_draw, |
1087 bool swap_requested, | 1087 bool swap_requested, |
1088 bool readback_requested) { | 1088 bool readback_requested) { |
1089 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 1089 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
1090 DrawSwapReadbackResult result; | 1090 DrawSwapReadbackResult result; |
1091 result.did_draw = false; | |
1092 result.did_swap = false; | 1091 result.did_swap = false; |
1093 result.did_readback = false; | 1092 result.did_readback = false; |
1093 | |
1094 DCHECK(IsImplThread()); | 1094 DCHECK(IsImplThread()); |
1095 DCHECK(layer_tree_host_impl_.get()); | 1095 DCHECK(layer_tree_host_impl_.get()); |
1096 if (!layer_tree_host_impl_) | 1096 if (!layer_tree_host_impl_) { |
1097 result.draw_result = DrawSwapReadbackResult::DRAW_ABORTED_NO_TREE; | |
1097 return result; | 1098 return result; |
1099 } | |
1098 | 1100 |
1099 DCHECK(layer_tree_host_impl_->renderer()); | 1101 DCHECK(layer_tree_host_impl_->renderer()); |
1100 if (!layer_tree_host_impl_->renderer()) | 1102 if (!layer_tree_host_impl_->renderer()) { |
1103 result.draw_result = DrawSwapReadbackResult::DRAW_ABORTED_NO_RENDERER; | |
1101 return result; | 1104 return result; |
1105 } | |
1102 | 1106 |
1103 base::TimeTicks start_time = base::TimeTicks::HighResNow(); | 1107 base::TimeTicks start_time = base::TimeTicks::HighResNow(); |
1104 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); | 1108 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); |
1105 base::AutoReset<bool> mark_inside(&inside_draw_, true); | 1109 base::AutoReset<bool> mark_inside(&inside_draw_, true); |
1106 | 1110 |
1107 // Advance our animations. | 1111 // Advance our animations. |
1108 base::TimeTicks monotonic_time = | 1112 base::TimeTicks monotonic_time = |
1109 layer_tree_host_impl_->CurrentFrameTimeTicks(); | 1113 layer_tree_host_impl_->CurrentFrameTimeTicks(); |
1110 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); | 1114 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); |
1111 | 1115 |
(...skipping 20 matching lines...) Expand all Loading... | |
1132 LayerTreeHostImpl::FrameData frame; | 1136 LayerTreeHostImpl::FrameData frame; |
1133 bool draw_frame = false; | 1137 bool draw_frame = false; |
1134 | 1138 |
1135 if (layer_tree_host_impl_->CanDraw() && | 1139 if (layer_tree_host_impl_->CanDraw() && |
1136 (!drawing_for_readback || can_do_readback)) { | 1140 (!drawing_for_readback || can_do_readback)) { |
1137 // If it is for a readback, make sure we draw the portion being read back. | 1141 // If it is for a readback, make sure we draw the portion being read back. |
1138 gfx::Rect readback_rect; | 1142 gfx::Rect readback_rect; |
1139 if (drawing_for_readback) | 1143 if (drawing_for_readback) |
1140 readback_rect = readback_request_on_impl_thread_->rect; | 1144 readback_rect = readback_request_on_impl_thread_->rect; |
1141 | 1145 |
1142 if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) || | 1146 result.draw_result = |
1143 forced_draw) | 1147 layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect); |
brianderson
2014/01/29 01:31:22
It feels funny to have PrepareToDraw return DID_DR
enne (OOO)
2014/01/29 01:40:19
Yeah, I thought that too. I could change DID_DRAW
danakj
2014/01/29 01:42:35
WILL_DRAW?
enne (OOO)
2014/01/29 01:47:20
WILL_DRAW doesn't make sense as a result after Dra
| |
1144 draw_frame = true; | 1148 draw_frame = |
1149 forced_draw || result.draw_result == DrawSwapReadbackResult::DID_DRAW; | |
1145 } | 1150 } |
1146 | 1151 |
1147 if (draw_frame) { | 1152 if (draw_frame) { |
1148 layer_tree_host_impl_->DrawLayers( | 1153 layer_tree_host_impl_->DrawLayers( |
1149 &frame, | 1154 &frame, |
1150 scheduler_on_impl_thread_->LastBeginImplFrameTime()); | 1155 scheduler_on_impl_thread_->LastBeginImplFrameTime()); |
1151 result.did_draw = true; | 1156 result.draw_result = DrawSwapReadbackResult::DID_DRAW; |
1157 } else { | |
1158 DCHECK_NE(DrawSwapReadbackResult::DID_DRAW, result.draw_result); | |
1152 } | 1159 } |
1153 layer_tree_host_impl_->DidDrawAllLayers(frame); | 1160 layer_tree_host_impl_->DidDrawAllLayers(frame); |
1154 | 1161 |
1155 bool start_ready_animations = draw_frame; | 1162 bool start_ready_animations = draw_frame; |
1156 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 1163 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
1157 | 1164 |
1158 // Check for a pending CompositeAndReadback. | 1165 // Check for a pending CompositeAndReadback. |
1159 if (drawing_for_readback) { | 1166 if (drawing_for_readback) { |
1160 DCHECK(!swap_requested); | 1167 DCHECK(!swap_requested); |
1161 result.did_readback = false; | 1168 result.did_readback = false; |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1653 commit_to_activate_duration_history_.InsertSample( | 1660 commit_to_activate_duration_history_.InsertSample( |
1654 base::TimeTicks::HighResNow() - commit_complete_time_); | 1661 base::TimeTicks::HighResNow() - commit_complete_time_); |
1655 } | 1662 } |
1656 | 1663 |
1657 void ThreadProxy::DidManageTiles() { | 1664 void ThreadProxy::DidManageTiles() { |
1658 DCHECK(IsImplThread()); | 1665 DCHECK(IsImplThread()); |
1659 scheduler_on_impl_thread_->DidManageTiles(); | 1666 scheduler_on_impl_thread_->DidManageTiles(); |
1660 } | 1667 } |
1661 | 1668 |
1662 } // namespace cc | 1669 } // namespace cc |
OLD | NEW |