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/layer_tree_host_common.h"
14 LayerTreeHostCommonTestBase::LayerTreeHostCommonTestBase()
15 : client_(FakeLayerTreeHostClient::DIRECT_3D
),
16 render_surface_layer_list_count_(0) {
19 LayerTreeHostCommonTestBase::~LayerTreeHostCommonTestBase() {
22 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting(
24 const gfx::Transform
& transform
,
25 const gfx::Point3F
& transform_origin
,
26 const gfx::PointF
& position
,
27 const gfx::Size
& bounds
,
28 bool flatten_transform
,
30 SetLayerPropertiesForTestingInternal
<Layer
>(layer
,
39 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting(
41 const gfx::Transform
& transform
,
42 const gfx::Point3F
& transform_origin
,
43 const gfx::PointF
& position
,
44 const gfx::Size
& bounds
,
45 bool flatten_transform
,
47 SetLayerPropertiesForTestingInternal
<LayerImpl
>(layer
,
54 layer
->SetContentBounds(bounds
);
57 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
59 float device_scale_factor
,
60 float page_scale_factor
,
61 Layer
* page_scale_application_layer
,
62 bool can_use_lcd_text
) {
63 EXPECT_TRUE(page_scale_application_layer
|| (page_scale_factor
== 1.f
));
64 gfx::Transform identity_matrix
;
65 gfx::Size device_viewport_size
=
66 gfx::Size(root_layer
->bounds().width() * device_scale_factor
,
67 root_layer
->bounds().height() * device_scale_factor
);
69 render_surface_layer_list_
.reset(new RenderSurfaceLayerList
);
71 // We are probably not testing what is intended if the root_layer bounds are
73 DCHECK(!root_layer
->bounds().IsEmpty());
74 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting
inputs(
75 root_layer
, device_viewport_size
, render_surface_layer_list_
.get());
76 inputs
.device_scale_factor
= device_scale_factor
;
77 inputs
.page_scale_factor
= page_scale_factor
;
78 inputs
.page_scale_application_layer
= page_scale_application_layer
;
79 inputs
.can_use_lcd_text
= can_use_lcd_text
;
80 inputs
.can_adjust_raster_scales
= true;
81 LayerTreeHostCommon::CalculateDrawProperties(&inputs
);
84 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
85 LayerImpl
* root_layer
,
86 float device_scale_factor
,
87 float page_scale_factor
,
88 LayerImpl
* page_scale_application_layer
,
89 bool can_use_lcd_text
) {
90 gfx::Transform identity_matrix
;
91 gfx::Size device_viewport_size
=
92 gfx::Size(root_layer
->bounds().width() * device_scale_factor
,
93 root_layer
->bounds().height() * device_scale_factor
);
95 render_surface_layer_list_impl_
.reset(new LayerImplList
);
97 // We are probably not testing what is intended if the root_layer bounds are
99 DCHECK(!root_layer
->bounds().IsEmpty());
100 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting
inputs(
101 root_layer
, device_viewport_size
, render_surface_layer_list_impl_
.get());
102 inputs
.device_scale_factor
= device_scale_factor
;
103 inputs
.page_scale_factor
= page_scale_factor
;
104 inputs
.page_scale_application_layer
= page_scale_application_layer
;
105 inputs
.can_use_lcd_text
= can_use_lcd_text
;
106 inputs
.can_adjust_raster_scales
= true;
108 ++render_surface_layer_list_count_
;
109 inputs
.current_render_surface_layer_list_id
=
110 render_surface_layer_list_count_
;
112 LayerTreeHostCommon::CalculateDrawProperties(&inputs
);
115 scoped_ptr
<FakeLayerTreeHost
>
116 LayerTreeHostCommonTestBase::CreateFakeLayerTreeHost() {
117 return FakeLayerTreeHost::Create(&client_
);