| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 FakeLayerTreeHostImpl::~FakeLayerTreeHostImpl() {} | 50 FakeLayerTreeHostImpl::~FakeLayerTreeHostImpl() {} |
| 51 | 51 |
| 52 void FakeLayerTreeHostImpl::CreatePendingTree() { | 52 void FakeLayerTreeHostImpl::CreatePendingTree() { |
| 53 LayerTreeHostImpl::CreatePendingTree(); | 53 LayerTreeHostImpl::CreatePendingTree(); |
| 54 float arbitrary_large_page_scale = 100000.f; | 54 float arbitrary_large_page_scale = 100000.f; |
| 55 pending_tree()->PushPageScaleFromMainThread( | 55 pending_tree()->PushPageScaleFromMainThread( |
| 56 1.f, 1.f / arbitrary_large_page_scale, arbitrary_large_page_scale); | 56 1.f, 1.f / arbitrary_large_page_scale, arbitrary_large_page_scale); |
| 57 } | 57 } |
| 58 | 58 |
| 59 BeginFrameArgs FakeLayerTreeHostImpl::CurrentBeginFrameArgs() const { | 59 BeginFrameArgs FakeLayerTreeHostImpl::CurrentBeginFrameArgs() const { |
| 60 if (!current_begin_frame_args_.IsValid()) | 60 if (!current_begin_frame_args_.HasFinished()) { |
| 61 return LayerTreeHostImpl::CurrentBeginFrameArgs(); | 61 return current_begin_frame_args_.Get(); |
| 62 return current_begin_frame_args_; | 62 } else { |
| 63 return current_begin_frame_args_.Last(); |
| 64 } |
| 63 } | 65 } |
| 64 | 66 |
| 65 void FakeLayerTreeHostImpl::SetCurrentBeginFrameArgs( | 67 void FakeLayerTreeHostImpl::SetCurrentBeginFrameArgs( |
| 66 const BeginFrameArgs& args) { | 68 const BeginFrameArgs& args) { |
| 67 current_begin_frame_args_ = args; | 69 if (!current_begin_frame_args_.HasFinished()) { |
| 70 current_begin_frame_args_.Finish(); |
| 71 } |
| 72 current_begin_frame_args_.Start(args); |
| 68 } | 73 } |
| 69 | 74 |
| 70 int FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(LayerImpl* layer) { | 75 int FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(LayerImpl* layer) { |
| 71 int num_children_that_draw_content = 0; | 76 int num_children_that_draw_content = 0; |
| 72 for (size_t i = 0; i < layer->children().size(); ++i) { | 77 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 73 num_children_that_draw_content += | 78 num_children_that_draw_content += |
| 74 RecursiveUpdateNumChildren(layer->children()[i]); | 79 RecursiveUpdateNumChildren(layer->children()[i]); |
| 75 } | 80 } |
| 76 if (layer->DrawsContent() && layer->HasDelegatedContent()) | 81 if (layer->DrawsContent() && layer->HasDelegatedContent()) |
| 77 num_children_that_draw_content += 1000; | 82 num_children_that_draw_content += 1000; |
| 78 layer->SetNumDescendantsThatDrawContent(num_children_that_draw_content); | 83 layer->SetNumDescendantsThatDrawContent(num_children_that_draw_content); |
| 79 return num_children_that_draw_content + (layer->DrawsContent() ? 1 : 0); | 84 return num_children_that_draw_content + (layer->DrawsContent() ? 1 : 0); |
| 80 } | 85 } |
| 81 | 86 |
| 82 void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawPropertiesForActiveTree() { | 87 void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawPropertiesForActiveTree() { |
| 83 UpdateNumChildrenAndDrawProperties(active_tree()); | 88 UpdateNumChildrenAndDrawProperties(active_tree()); |
| 84 } | 89 } |
| 85 | 90 |
| 86 void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawProperties( | 91 void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawProperties( |
| 87 LayerTreeImpl* layerTree) { | 92 LayerTreeImpl* layerTree) { |
| 88 RecursiveUpdateNumChildren(layerTree->root_layer()); | 93 RecursiveUpdateNumChildren(layerTree->root_layer()); |
| 89 layerTree->UpdateDrawProperties(); | 94 layerTree->UpdateDrawProperties(); |
| 90 } | 95 } |
| 91 | 96 |
| 92 } // namespace cc | 97 } // namespace cc |
| OLD | NEW |