Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / cc / test / layer_tree_host_common_test.cc
blobe91f169c3f05fd3df023a27b6f6219e487edea8a
1 // Copyright 2014 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/layer_tree_host_common_test.h"
7 #include "cc/layers/layer.h"
8 #include "cc/layers/layer_impl.h"
9 #include "cc/test/fake_layer_tree_host.h"
10 #include "cc/trees/draw_property_utils.h"
11 #include "cc/trees/layer_tree_host_common.h"
13 namespace cc {
15 LayerTreeHostCommonTestBase::LayerTreeHostCommonTestBase()
16 : client_(FakeLayerTreeHostClient::DIRECT_3D),
17 render_surface_layer_list_count_(0) {
20 LayerTreeHostCommonTestBase::~LayerTreeHostCommonTestBase() {
23 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting(
24 Layer* layer,
25 const gfx::Transform& transform,
26 const gfx::Point3F& transform_origin,
27 const gfx::PointF& position,
28 const gfx::Size& bounds,
29 bool flatten_transform,
30 bool is_3d_sorted) {
31 SetLayerPropertiesForTestingInternal(layer, transform, transform_origin,
32 position, bounds, flatten_transform,
33 is_3d_sorted);
36 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting(
37 LayerImpl* layer,
38 const gfx::Transform& transform,
39 const gfx::Point3F& transform_origin,
40 const gfx::PointF& position,
41 const gfx::Size& bounds,
42 bool flatten_transform,
43 bool is_3d_sorted,
44 bool create_render_surface) {
45 SetLayerPropertiesForTestingInternal(layer, transform, transform_origin,
46 position, bounds, flatten_transform,
47 is_3d_sorted);
48 if (create_render_surface) {
49 layer->SetHasRenderSurface(true);
52 layer->SetContentBounds(bounds);
55 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
56 Layer* root_layer,
57 float device_scale_factor,
58 float page_scale_factor,
59 Layer* page_scale_layer,
60 bool can_use_lcd_text,
61 bool layers_always_allowed_lcd_text) {
62 EXPECT_TRUE(page_scale_layer || (page_scale_factor == 1.f));
63 gfx::Transform identity_matrix;
64 gfx::Size device_viewport_size =
65 gfx::Size(root_layer->bounds().width() * device_scale_factor,
66 root_layer->bounds().height() * device_scale_factor);
68 render_surface_layer_list_.reset(new RenderSurfaceLayerList);
70 // We are probably not testing what is intended if the root_layer bounds are
71 // empty.
72 DCHECK(!root_layer->bounds().IsEmpty());
73 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
74 root_layer, device_viewport_size, render_surface_layer_list_.get());
75 inputs.device_scale_factor = device_scale_factor;
76 inputs.page_scale_factor = page_scale_factor;
77 inputs.page_scale_layer = page_scale_layer;
78 inputs.can_use_lcd_text = can_use_lcd_text;
79 inputs.layers_always_allowed_lcd_text = layers_always_allowed_lcd_text;
80 inputs.can_adjust_raster_scales = true;
81 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
84 void LayerTreeHostCommonTestBase::
85 ExecuteCalculateDrawPropertiesWithPropertyTrees(Layer* root_layer) {
86 DCHECK(root_layer->layer_tree_host());
87 LayerTreeHostCommon::PreCalculateMetaInformation(root_layer);
89 gfx::Transform identity_transform;
90 bool preserves_2d_axis_alignment = false;
91 bool can_render_to_separate_surface = true;
92 LayerTreeHostCommon::UpdateRenderSurfaces(
93 root_layer, can_render_to_separate_surface, identity_transform,
94 preserves_2d_axis_alignment);
96 Layer* page_scale_layer = nullptr;
97 float page_scale_factor = 1.f;
98 float device_scale_factor = 1.f;
99 gfx::Size device_viewport_size =
100 gfx::Size(root_layer->bounds().width() * device_scale_factor,
101 root_layer->bounds().height() * device_scale_factor);
102 LayerList update_layer_list;
103 BuildPropertyTreesAndComputeVisibleRects(
104 root_layer, page_scale_layer, page_scale_factor, device_scale_factor,
105 gfx::Rect(device_viewport_size), identity_transform,
106 root_layer->layer_tree_host()->property_trees(), &update_layer_list);
109 void LayerTreeHostCommonTestBase::
110 ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl* root_layer) {
111 DCHECK(root_layer->layer_tree_impl());
112 LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root_layer);
114 gfx::Transform identity_transform;
115 LayerImpl* page_scale_layer = nullptr;
116 float page_scale_factor = 1.f;
117 float device_scale_factor = 1.f;
118 gfx::Size device_viewport_size =
119 gfx::Size(root_layer->bounds().width() * device_scale_factor,
120 root_layer->bounds().height() * device_scale_factor);
121 std::vector<LayerImpl*> update_layer_list;
122 BuildPropertyTreesAndComputeVisibleRects(
123 root_layer, page_scale_layer, page_scale_factor, device_scale_factor,
124 gfx::Rect(device_viewport_size), identity_transform,
125 root_layer->layer_tree_impl()->property_trees(), &update_layer_list);
128 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
129 LayerImpl* root_layer,
130 float device_scale_factor,
131 float page_scale_factor,
132 LayerImpl* page_scale_layer,
133 bool can_use_lcd_text,
134 bool layers_always_allowed_lcd_text) {
135 gfx::Transform identity_matrix;
136 gfx::Size device_viewport_size =
137 gfx::Size(root_layer->bounds().width() * device_scale_factor,
138 root_layer->bounds().height() * device_scale_factor);
140 render_surface_layer_list_impl_.reset(new LayerImplList);
142 // We are probably not testing what is intended if the root_layer bounds are
143 // empty.
144 DCHECK(!root_layer->bounds().IsEmpty());
145 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
146 root_layer, device_viewport_size, render_surface_layer_list_impl_.get());
147 inputs.device_scale_factor = device_scale_factor;
148 inputs.page_scale_factor = page_scale_factor;
149 inputs.page_scale_layer = page_scale_layer;
150 inputs.can_use_lcd_text = can_use_lcd_text;
151 inputs.layers_always_allowed_lcd_text = layers_always_allowed_lcd_text;
152 inputs.can_adjust_raster_scales = true;
154 ++render_surface_layer_list_count_;
155 inputs.current_render_surface_layer_list_id =
156 render_surface_layer_list_count_;
158 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
161 scoped_ptr<FakeLayerTreeHost>
162 LayerTreeHostCommonTestBase::CreateFakeLayerTreeHost() {
163 return FakeLayerTreeHost::Create(&client_);
166 } // namespace cc