Screen Orientation Controller allow rotation for some orientations
[chromium-blink-merge.git] / cc / test / fake_layer_tree_host_impl.cc
blobbfac501fe0d743dade4d47ad55fc40d36493508c
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
3 // found in the LICENSE file.
5 #include "cc/test/begin_frame_args_test.h"
6 #include "cc/test/fake_layer_tree_host_impl.h"
7 #include "cc/test/test_shared_bitmap_manager.h"
8 #include "cc/trees/layer_tree_impl.h"
10 namespace cc {
12 FakeLayerTreeHostImpl::FakeLayerTreeHostImpl(Proxy* proxy,
13 SharedBitmapManager* manager)
14 : LayerTreeHostImpl(LayerTreeSettings(),
15 &client_,
16 proxy,
17 &stats_instrumentation_,
18 manager,
19 NULL,
20 0) {
21 // Explicitly clear all debug settings.
22 SetDebugState(LayerTreeDebugState());
23 SetViewportSize(gfx::Size(100, 100));
25 // Avoid using Now() as the frame time in unit tests.
26 base::TimeTicks time_ticks = base::TimeTicks::FromInternalValue(1);
27 SetCurrentBeginFrameArgs(
28 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
31 FakeLayerTreeHostImpl::FakeLayerTreeHostImpl(const LayerTreeSettings& settings,
32 Proxy* proxy,
33 SharedBitmapManager* manager)
34 : LayerTreeHostImpl(settings,
35 &client_,
36 proxy,
37 &stats_instrumentation_,
38 manager,
39 NULL,
40 0) {
41 // Explicitly clear all debug settings.
42 SetDebugState(LayerTreeDebugState());
44 // Avoid using Now() as the frame time in unit tests.
45 base::TimeTicks time_ticks = base::TimeTicks::FromInternalValue(1);
46 SetCurrentBeginFrameArgs(
47 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
50 FakeLayerTreeHostImpl::~FakeLayerTreeHostImpl() {}
52 void FakeLayerTreeHostImpl::CreatePendingTree() {
53 LayerTreeHostImpl::CreatePendingTree();
54 float arbitrary_large_page_scale = 100000.f;
55 pending_tree()->PushPageScaleFromMainThread(
56 1.f, 1.f / arbitrary_large_page_scale, arbitrary_large_page_scale);
59 BeginFrameArgs FakeLayerTreeHostImpl::CurrentBeginFrameArgs() const {
60 if (!current_begin_frame_args_.IsValid())
61 return LayerTreeHostImpl::CurrentBeginFrameArgs();
62 return current_begin_frame_args_;
65 void FakeLayerTreeHostImpl::SetCurrentBeginFrameArgs(
66 const BeginFrameArgs& args) {
67 current_begin_frame_args_ = args;
70 int FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(LayerImpl* layer) {
71 int num_children_that_draw_content = 0;
72 for (size_t i = 0; i < layer->children().size(); ++i) {
73 num_children_that_draw_content +=
74 RecursiveUpdateNumChildren(layer->children()[i]);
76 if (layer->DrawsContent() && layer->HasDelegatedContent())
77 num_children_that_draw_content += 1000;
78 layer->SetNumDescendantsThatDrawContent(num_children_that_draw_content);
79 return num_children_that_draw_content + (layer->DrawsContent() ? 1 : 0);
82 void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawPropertiesForActiveTree() {
83 UpdateNumChildrenAndDrawProperties(active_tree());
86 void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawProperties(
87 LayerTreeImpl* layerTree) {
88 RecursiveUpdateNumChildren(layerTree->root_layer());
89 layerTree->UpdateDrawProperties();
92 } // namespace cc