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/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 layer->render_surface()->AppendQuads(&quad_culler, | 594 layer->render_surface()->AppendQuads(&quad_culler, |
595 append_quads_data, | 595 append_quads_data, |
596 is_replica, | 596 is_replica, |
597 contributing_render_pass->id); | 597 contributing_render_pass->id); |
598 } | 598 } |
599 } | 599 } |
600 | 600 |
601 static void AppendQuadsToFillScreen( | 601 static void AppendQuadsToFillScreen( |
602 ResourceProvider::ResourceId overhang_resource_id, | 602 ResourceProvider::ResourceId overhang_resource_id, |
603 gfx::SizeF overhang_resource_scaled_size, | 603 gfx::SizeF overhang_resource_scaled_size, |
604 gfx::Rect root_scroll_layer_rect, | 604 const gfx::Rect& root_scroll_layer_rect, |
605 RenderPass* target_render_pass, | 605 RenderPass* target_render_pass, |
606 LayerImpl* root_layer, | 606 LayerImpl* root_layer, |
607 SkColor screen_background_color, | 607 SkColor screen_background_color, |
608 const OcclusionTrackerImpl& occlusion_tracker) { | 608 const OcclusionTrackerImpl& occlusion_tracker) { |
609 if (!root_layer || !SkColorGetA(screen_background_color)) | 609 if (!root_layer || !SkColorGetA(screen_background_color)) |
610 return; | 610 return; |
611 | 611 |
612 Region fill_region = occlusion_tracker.ComputeVisibleRegionInScreen(); | 612 Region fill_region = occlusion_tracker.ComputeVisibleRegionInScreen(); |
613 if (fill_region.IsEmpty()) | 613 if (fill_region.IsEmpty()) |
614 return; | 614 return; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 } | 953 } |
954 | 954 |
955 time_source_client_adapter_->SetActive(enabled); | 955 time_source_client_adapter_->SetActive(enabled); |
956 } | 956 } |
957 | 957 |
958 void LayerTreeHostImpl::DidAnimateScrollOffset() { | 958 void LayerTreeHostImpl::DidAnimateScrollOffset() { |
959 client_->SetNeedsCommitOnImplThread(); | 959 client_->SetNeedsCommitOnImplThread(); |
960 client_->RenewTreePriority(); | 960 client_->RenewTreePriority(); |
961 } | 961 } |
962 | 962 |
963 void LayerTreeHostImpl::SetViewportDamage(gfx::Rect damage_rect) { | 963 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { |
964 viewport_damage_rect_.Union(damage_rect); | 964 viewport_damage_rect_.Union(damage_rect); |
965 } | 965 } |
966 | 966 |
967 static inline RenderPass* FindRenderPassById( | 967 static inline RenderPass* FindRenderPassById( |
968 RenderPass::Id render_pass_id, | 968 RenderPass::Id render_pass_id, |
969 const LayerTreeHostImpl::FrameData& frame) { | 969 const LayerTreeHostImpl::FrameData& frame) { |
970 RenderPassIdHashMap::const_iterator it = | 970 RenderPassIdHashMap::const_iterator it = |
971 frame.render_passes_by_id.find(render_pass_id); | 971 frame.render_passes_by_id.find(render_pass_id); |
972 return it != frame.render_passes_by_id.end() ? it->second : NULL; | 972 return it != frame.render_passes_by_id.end() ? it->second : NULL; |
973 } | 973 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 // list, and restore it after the change. | 1070 // list, and restore it after the change. |
1071 size_t position_from_end = frame->render_passes.size() - it; | 1071 size_t position_from_end = frame->render_passes.size() - it; |
1072 RemoveRenderPassesRecursive(render_pass_quad->render_pass_id, frame); | 1072 RemoveRenderPassesRecursive(render_pass_quad->render_pass_id, frame); |
1073 it = frame->render_passes.size() - position_from_end; | 1073 it = frame->render_passes.size() - position_from_end; |
1074 DCHECK_GE(frame->render_passes.size(), position_from_end); | 1074 DCHECK_GE(frame->render_passes.size(), position_from_end); |
1075 } | 1075 } |
1076 } | 1076 } |
1077 } | 1077 } |
1078 | 1078 |
1079 bool LayerTreeHostImpl::PrepareToDraw(FrameData* frame, | 1079 bool LayerTreeHostImpl::PrepareToDraw(FrameData* frame, |
1080 gfx::Rect device_viewport_damage_rect) { | 1080 const gfx::Rect& damage_rect) { |
1081 TRACE_EVENT1("cc", | 1081 TRACE_EVENT1("cc", |
1082 "LayerTreeHostImpl::PrepareToDraw", | 1082 "LayerTreeHostImpl::PrepareToDraw", |
1083 "SourceFrameNumber", | 1083 "SourceFrameNumber", |
1084 active_tree_->source_frame_number()); | 1084 active_tree_->source_frame_number()); |
1085 | 1085 |
1086 if (need_to_update_visible_tiles_before_draw_ && | 1086 if (need_to_update_visible_tiles_before_draw_ && |
1087 tile_manager_ && tile_manager_->UpdateVisibleTiles()) { | 1087 tile_manager_ && tile_manager_->UpdateVisibleTiles()) { |
1088 DidInitializeVisibleTile(); | 1088 DidInitializeVisibleTile(); |
1089 } | 1089 } |
1090 need_to_update_visible_tiles_before_draw_ = true; | 1090 need_to_update_visible_tiles_before_draw_ = true; |
1091 | 1091 |
1092 active_tree_->UpdateDrawProperties(); | 1092 active_tree_->UpdateDrawProperties(); |
1093 | 1093 |
1094 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); | 1094 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); |
1095 frame->render_passes.clear(); | 1095 frame->render_passes.clear(); |
1096 frame->render_passes_by_id.clear(); | 1096 frame->render_passes_by_id.clear(); |
1097 frame->will_draw_layers.clear(); | 1097 frame->will_draw_layers.clear(); |
1098 frame->contains_incomplete_tile = false; | 1098 frame->contains_incomplete_tile = false; |
1099 frame->has_no_damage = false; | 1099 frame->has_no_damage = false; |
1100 | 1100 |
| 1101 gfx::Rect device_viewport_damage_rect(damage_rect); |
1101 if (active_tree_->root_layer()) { | 1102 if (active_tree_->root_layer()) { |
1102 device_viewport_damage_rect.Union(viewport_damage_rect_); | 1103 device_viewport_damage_rect.Union(viewport_damage_rect_); |
1103 viewport_damage_rect_ = gfx::Rect(); | 1104 viewport_damage_rect_ = gfx::Rect(); |
1104 | 1105 |
1105 active_tree_->root_layer()->render_surface()->damage_tracker()-> | 1106 active_tree_->root_layer()->render_surface()->damage_tracker()-> |
1106 AddDamageNextUpdate(device_viewport_damage_rect); | 1107 AddDamageNextUpdate(device_viewport_damage_rect); |
1107 } | 1108 } |
1108 | 1109 |
1109 if (!CalculateRenderPasses(frame)) { | 1110 if (!CalculateRenderPasses(frame)) { |
1110 DCHECK(!output_surface_->capabilities() | 1111 DCHECK(!output_surface_->capabilities() |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 old_policy.priority_cutoff_when_visible) { | 1240 old_policy.priority_cutoff_when_visible) { |
1240 needs_commit = false; | 1241 needs_commit = false; |
1241 } | 1242 } |
1242 | 1243 |
1243 if (needs_commit) | 1244 if (needs_commit) |
1244 client_->SetNeedsCommitOnImplThread(); | 1245 client_->SetNeedsCommitOnImplThread(); |
1245 } | 1246 } |
1246 | 1247 |
1247 void LayerTreeHostImpl::SetExternalDrawConstraints( | 1248 void LayerTreeHostImpl::SetExternalDrawConstraints( |
1248 const gfx::Transform& transform, | 1249 const gfx::Transform& transform, |
1249 gfx::Rect viewport, | 1250 const gfx::Rect& viewport, |
1250 gfx::Rect clip, | 1251 const gfx::Rect& clip, |
1251 bool valid_for_tile_management) { | 1252 bool valid_for_tile_management) { |
1252 external_transform_ = transform; | 1253 external_transform_ = transform; |
1253 external_viewport_ = viewport; | 1254 external_viewport_ = viewport; |
1254 external_clip_ = clip; | 1255 external_clip_ = clip; |
1255 device_viewport_valid_for_tile_management_ = valid_for_tile_management; | 1256 device_viewport_valid_for_tile_management_ = valid_for_tile_management; |
1256 } | 1257 } |
1257 | 1258 |
1258 void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) { | 1259 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
1259 if (damage_rect.IsEmpty()) | 1260 if (damage_rect.IsEmpty()) |
1260 return; | 1261 return; |
1261 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1262 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
1262 client_->SetNeedsRedrawRectOnImplThread(damage_rect); | 1263 client_->SetNeedsRedrawRectOnImplThread(damage_rect); |
1263 } | 1264 } |
1264 | 1265 |
1265 void LayerTreeHostImpl::BeginImplFrame(const BeginFrameArgs& args) { | 1266 void LayerTreeHostImpl::BeginImplFrame(const BeginFrameArgs& args) { |
1266 client_->BeginImplFrame(args); | 1267 client_->BeginImplFrame(args); |
1267 } | 1268 } |
1268 | 1269 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or | 1494 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or |
1494 // important) in production. We should adjust the test to not need this. | 1495 // important) in production. We should adjust the test to not need this. |
1495 if (renderer_) | 1496 if (renderer_) |
1496 client_->DidLoseOutputSurfaceOnImplThread(); | 1497 client_->DidLoseOutputSurfaceOnImplThread(); |
1497 #ifndef NDEBUG | 1498 #ifndef NDEBUG |
1498 did_lose_called_ = true; | 1499 did_lose_called_ = true; |
1499 #endif | 1500 #endif |
1500 } | 1501 } |
1501 | 1502 |
1502 void LayerTreeHostImpl::Readback(void* pixels, | 1503 void LayerTreeHostImpl::Readback(void* pixels, |
1503 gfx::Rect rect_in_device_viewport) { | 1504 const gfx::Rect& rect_in_device_viewport) { |
1504 DCHECK(renderer_); | 1505 DCHECK(renderer_); |
1505 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); | 1506 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); |
1506 } | 1507 } |
1507 | 1508 |
1508 bool LayerTreeHostImpl::HaveRootScrollLayer() const { | 1509 bool LayerTreeHostImpl::HaveRootScrollLayer() const { |
1509 return !!RootScrollLayer(); | 1510 return !!RootScrollLayer(); |
1510 } | 1511 } |
1511 | 1512 |
1512 LayerImpl* LayerTreeHostImpl::RootLayer() const { | 1513 LayerImpl* LayerTreeHostImpl::RootLayer() const { |
1513 return active_tree_->root_layer(); | 1514 return active_tree_->root_layer(); |
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2907 swap_promise_monitor_.erase(monitor); | 2908 swap_promise_monitor_.erase(monitor); |
2908 } | 2909 } |
2909 | 2910 |
2910 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 2911 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
2911 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 2912 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
2912 for (; it != swap_promise_monitor_.end(); it++) | 2913 for (; it != swap_promise_monitor_.end(); it++) |
2913 (*it)->OnSetNeedsRedrawOnImpl(); | 2914 (*it)->OnSetNeedsRedrawOnImpl(); |
2914 } | 2915 } |
2915 | 2916 |
2916 } // namespace cc | 2917 } // namespace cc |
OLD | NEW |