| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/test/begin_frame_args_test.h" | 5 #include "cc/test/begin_frame_args_test.h" |
| 6 #include "cc/test/fake_layer_tree_host_impl.h" | 6 #include "cc/test/fake_layer_tree_host_impl.h" |
| 7 #include "cc/test/test_shared_bitmap_manager.h" | 7 #include "cc/test/test_shared_bitmap_manager.h" |
| 8 #include "cc/trees/layer_tree_impl.h" | 8 #include "cc/trees/layer_tree_impl.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 FakeLayerTreeHostImpl::~FakeLayerTreeHostImpl() {} | 54 FakeLayerTreeHostImpl::~FakeLayerTreeHostImpl() {} |
| 55 | 55 |
| 56 void FakeLayerTreeHostImpl::CreatePendingTree() { | 56 void FakeLayerTreeHostImpl::CreatePendingTree() { |
| 57 LayerTreeHostImpl::CreatePendingTree(); | 57 LayerTreeHostImpl::CreatePendingTree(); |
| 58 float arbitrary_large_page_scale = 100000.f; | 58 float arbitrary_large_page_scale = 100000.f; |
| 59 pending_tree()->PushPageScaleFromMainThread( | 59 pending_tree()->PushPageScaleFromMainThread( |
| 60 1.f, 1.f / arbitrary_large_page_scale, arbitrary_large_page_scale); | 60 1.f, 1.f / arbitrary_large_page_scale, arbitrary_large_page_scale); |
| 61 } | 61 } |
| 62 | 62 |
| 63 BeginFrameArgs FakeLayerTreeHostImpl::CurrentBeginFrameArgs() const { | 63 BeginFrameArgs FakeLayerTreeHostImpl::CurrentBeginFrameArgs() const { |
| 64 return current_begin_frame_tracker_.DangerousMethodCurrentOrLast(); | 64 if (!current_begin_frame_args_.IsValid()) |
| 65 return LayerTreeHostImpl::CurrentBeginFrameArgs(); |
| 66 return current_begin_frame_args_; |
| 65 } | 67 } |
| 66 | 68 |
| 67 void FakeLayerTreeHostImpl::SetCurrentBeginFrameArgs( | 69 void FakeLayerTreeHostImpl::SetCurrentBeginFrameArgs( |
| 68 const BeginFrameArgs& args) { | 70 const BeginFrameArgs& args) { |
| 69 if (!current_begin_frame_tracker_.DangerousMethodHasFinished()) { | 71 current_begin_frame_args_ = args; |
| 70 current_begin_frame_tracker_.Finish(); | |
| 71 } | |
| 72 current_begin_frame_tracker_.Start(args); | |
| 73 } | 72 } |
| 74 | 73 |
| 75 int FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(LayerImpl* layer) { | 74 int FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(LayerImpl* layer) { |
| 76 int num_children_that_draw_content = 0; | 75 int num_children_that_draw_content = 0; |
| 77 for (size_t i = 0; i < layer->children().size(); ++i) { | 76 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 78 num_children_that_draw_content += | 77 num_children_that_draw_content += |
| 79 RecursiveUpdateNumChildren(layer->children()[i]); | 78 RecursiveUpdateNumChildren(layer->children()[i]); |
| 80 } | 79 } |
| 81 if (layer->DrawsContent() && layer->HasDelegatedContent()) | 80 if (layer->DrawsContent() && layer->HasDelegatedContent()) |
| 82 num_children_that_draw_content += 1000; | 81 num_children_that_draw_content += 1000; |
| 83 layer->SetNumDescendantsThatDrawContent(num_children_that_draw_content); | 82 layer->SetNumDescendantsThatDrawContent(num_children_that_draw_content); |
| 84 return num_children_that_draw_content + (layer->DrawsContent() ? 1 : 0); | 83 return num_children_that_draw_content + (layer->DrawsContent() ? 1 : 0); |
| 85 } | 84 } |
| 86 | 85 |
| 87 void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawPropertiesForActiveTree() { | 86 void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawPropertiesForActiveTree() { |
| 88 UpdateNumChildrenAndDrawProperties(active_tree()); | 87 UpdateNumChildrenAndDrawProperties(active_tree()); |
| 89 } | 88 } |
| 90 | 89 |
| 91 void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawProperties( | 90 void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawProperties( |
| 92 LayerTreeImpl* layerTree) { | 91 LayerTreeImpl* layerTree) { |
| 93 RecursiveUpdateNumChildren(layerTree->root_layer()); | 92 RecursiveUpdateNumChildren(layerTree->root_layer()); |
| 94 bool update_lcd_text = false; | 93 bool update_lcd_text = false; |
| 95 layerTree->UpdateDrawProperties(update_lcd_text); | 94 layerTree->UpdateDrawProperties(update_lcd_text); |
| 96 } | 95 } |
| 97 | 96 |
| 98 } // namespace cc | 97 } // namespace cc |
| OLD | NEW |