[Android] Introduce new UMA action for when user copies Image URL from context menu
[chromium-blink-merge.git] / cc / test / layer_tree_host_common_test.cc
blob81983caa14dc7172c7efab4d4ad64d617ab58e83
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 const LayerTreeSettings& settings)
17 : LayerTestCommon::LayerImplTest(settings),
18 render_surface_layer_list_count_(0) {
21 LayerTreeHostCommonTestBase::~LayerTreeHostCommonTestBase() {
24 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting(
25 Layer* layer,
26 const gfx::Transform& transform,
27 const gfx::Point3F& transform_origin,
28 const gfx::PointF& position,
29 const gfx::Size& bounds,
30 bool flatten_transform,
31 bool is_3d_sorted) {
32 SetLayerPropertiesForTestingInternal(layer, transform, transform_origin,
33 position, bounds, flatten_transform,
34 is_3d_sorted);
37 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting(
38 LayerImpl* layer,
39 const gfx::Transform& transform,
40 const gfx::Point3F& transform_origin,
41 const gfx::PointF& position,
42 const gfx::Size& bounds,
43 bool flatten_transform,
44 bool is_3d_sorted,
45 bool create_render_surface) {
46 SetLayerPropertiesForTestingInternal(layer, transform, transform_origin,
47 position, bounds, flatten_transform,
48 is_3d_sorted);
49 if (create_render_surface) {
50 layer->SetHasRenderSurface(true);
54 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
55 Layer* root_layer,
56 float device_scale_factor,
57 float page_scale_factor,
58 Layer* page_scale_layer,
59 bool can_use_lcd_text,
60 bool layers_always_allowed_lcd_text) {
61 EXPECT_TRUE(page_scale_layer || (page_scale_factor == 1.f));
62 gfx::Transform identity_matrix;
63 gfx::Size device_viewport_size =
64 gfx::Size(root_layer->bounds().width() * device_scale_factor,
65 root_layer->bounds().height() * device_scale_factor);
67 render_surface_layer_list_.reset(new RenderSurfaceLayerList);
69 // We are probably not testing what is intended if the root_layer bounds are
70 // empty.
71 DCHECK(!root_layer->bounds().IsEmpty());
72 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
73 root_layer, device_viewport_size, render_surface_layer_list_.get());
74 inputs.device_scale_factor = device_scale_factor;
75 inputs.page_scale_factor = page_scale_factor;
76 inputs.page_scale_layer = page_scale_layer;
77 inputs.can_use_lcd_text = can_use_lcd_text;
78 inputs.layers_always_allowed_lcd_text = layers_always_allowed_lcd_text;
79 inputs.can_adjust_raster_scales = true;
80 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
83 void LayerTreeHostCommonTestBase::
84 ExecuteCalculateDrawPropertiesWithPropertyTrees(Layer* root_layer) {
85 DCHECK(root_layer->layer_tree_host());
86 LayerTreeHostCommon::PreCalculateMetaInformation(root_layer);
88 gfx::Transform identity_transform;
89 bool preserves_2d_axis_alignment = false;
90 bool can_render_to_separate_surface = true;
91 LayerTreeHostCommon::UpdateRenderSurfaces(
92 root_layer, can_render_to_separate_surface, identity_transform,
93 preserves_2d_axis_alignment);
95 Layer* page_scale_layer = nullptr;
96 Layer* inner_viewport_scroll_layer =
97 root_layer->layer_tree_host()->inner_viewport_scroll_layer();
98 Layer* outer_viewport_scroll_layer =
99 root_layer->layer_tree_host()->outer_viewport_scroll_layer();
100 float page_scale_factor = 1.f;
101 float device_scale_factor = 1.f;
102 gfx::Size device_viewport_size =
103 gfx::Size(root_layer->bounds().width() * device_scale_factor,
104 root_layer->bounds().height() * device_scale_factor);
105 LayerList update_layer_list;
106 BuildPropertyTreesAndComputeVisibleRects(
107 root_layer, page_scale_layer, inner_viewport_scroll_layer,
108 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor,
109 gfx::Rect(device_viewport_size), identity_transform,
110 root_layer->layer_tree_host()->property_trees(), &update_layer_list);
113 void LayerTreeHostCommonTestBase::
114 ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl* root_layer) {
115 DCHECK(root_layer->layer_tree_impl());
116 LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root_layer);
118 gfx::Transform identity_transform;
119 LayerImpl* page_scale_layer = nullptr;
120 LayerImpl* inner_viewport_scroll_layer =
121 root_layer->layer_tree_impl()->InnerViewportScrollLayer();
122 LayerImpl* outer_viewport_scroll_layer =
123 root_layer->layer_tree_impl()->OuterViewportScrollLayer();
124 float page_scale_factor = 1.f;
125 float device_scale_factor = 1.f;
126 gfx::Size device_viewport_size =
127 gfx::Size(root_layer->bounds().width() * device_scale_factor,
128 root_layer->bounds().height() * device_scale_factor);
129 std::vector<LayerImpl*> update_layer_list;
130 BuildPropertyTreesAndComputeVisibleRects(
131 root_layer, page_scale_layer, inner_viewport_scroll_layer,
132 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor,
133 gfx::Rect(device_viewport_size), identity_transform,
134 root_layer->layer_tree_impl()->property_trees(), &update_layer_list);
137 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
138 LayerImpl* root_layer,
139 float device_scale_factor,
140 float page_scale_factor,
141 LayerImpl* page_scale_layer,
142 bool can_use_lcd_text,
143 bool layers_always_allowed_lcd_text) {
144 host_impl()->SetDeviceScaleFactor(device_scale_factor);
145 host_impl()->SetPageScaleOnActiveTree(page_scale_factor);
147 gfx::Transform identity_matrix;
148 gfx::Size device_viewport_size =
149 gfx::Size(root_layer->bounds().width() * device_scale_factor,
150 root_layer->bounds().height() * device_scale_factor);
152 render_surface_layer_list_impl_.reset(new LayerImplList);
154 // We are probably not testing what is intended if the root_layer bounds are
155 // empty.
156 DCHECK(!root_layer->bounds().IsEmpty());
157 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
158 root_layer, device_viewport_size, render_surface_layer_list_impl_.get());
159 inputs.device_scale_factor = device_scale_factor;
160 inputs.page_scale_factor = page_scale_factor;
161 inputs.page_scale_layer = page_scale_layer;
162 inputs.can_use_lcd_text = can_use_lcd_text;
163 inputs.layers_always_allowed_lcd_text = layers_always_allowed_lcd_text;
164 inputs.can_adjust_raster_scales = true;
166 ++render_surface_layer_list_count_;
167 inputs.current_render_surface_layer_list_id =
168 render_surface_layer_list_count_;
170 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
173 LayerTreeHostCommonTest::LayerTreeHostCommonTest()
174 : LayerTreeHostCommonTestBase(LayerTreeSettings()) {
177 LayerTreeHostCommonTest::LayerTreeHostCommonTest(
178 const LayerTreeSettings& settings)
179 : LayerTreeHostCommonTestBase(settings) {
182 } // namespace cc