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 #ifndef CC_TEST_LAYER_TREE_HOST_COMMON_TEST_H_
6 #define CC_TEST_LAYER_TREE_HOST_COMMON_TEST_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/layers/layer_lists.h"
12 #include "cc/test/fake_layer_tree_host_client.h"
13 #include "cc/test/layer_test_common.h"
14 #include "cc/test/test_task_graph_runner.h"
15 #include "cc/trees/layer_tree_settings.h"
16 #include "cc/trees/property_tree.h"
17 #include "testing/gtest/include/gtest/gtest.h"
28 class FakeLayerTreeHost
;
32 class LayerTreeHostCommonTestBase
: public LayerTestCommon::LayerImplTest
{
34 explicit LayerTreeHostCommonTestBase(const LayerTreeSettings
& settings
);
35 virtual ~LayerTreeHostCommonTestBase();
37 template <typename LayerType
>
38 void SetLayerPropertiesForTestingInternal(
40 const gfx::Transform
& transform
,
41 const gfx::Point3F
& transform_origin
,
42 const gfx::PointF
& position
,
43 const gfx::Size
& bounds
,
44 bool flatten_transform
,
46 layer
->SetTransform(transform
);
47 layer
->SetTransformOrigin(transform_origin
);
48 layer
->SetPosition(position
);
49 layer
->SetBounds(bounds
);
50 layer
->SetShouldFlattenTransform(flatten_transform
);
51 layer
->Set3dSortingContextId(is_3d_sorted
? 1 : 0);
54 void SetLayerPropertiesForTesting(Layer
* layer
,
55 const gfx::Transform
& transform
,
56 const gfx::Point3F
& transform_origin
,
57 const gfx::PointF
& position
,
58 const gfx::Size
& bounds
,
59 bool flatten_transform
,
62 void SetLayerPropertiesForTesting(LayerImpl
* layer
,
63 const gfx::Transform
& transform
,
64 const gfx::Point3F
& transform_origin
,
65 const gfx::PointF
& position
,
66 const gfx::Size
& bounds
,
67 bool flatten_transform
,
69 bool create_render_surface
);
71 void ExecuteCalculateDrawProperties(Layer
* root_layer
,
72 float device_scale_factor
,
73 float page_scale_factor
,
74 Layer
* page_scale_application_layer
,
75 bool can_use_lcd_text
,
76 bool layers_always_allowed_lcd_text
);
78 void ExecuteCalculateDrawProperties(LayerImpl
* root_layer
,
79 float device_scale_factor
,
80 float page_scale_factor
,
81 LayerImpl
* page_scale_application_layer
,
82 bool can_use_lcd_text
,
83 bool layers_always_allowed_lcd_text
);
85 template <class LayerType
>
86 void ExecuteCalculateDrawProperties(LayerType
* root_layer
) {
87 LayerType
* page_scale_application_layer
= NULL
;
88 ExecuteCalculateDrawProperties(root_layer
, 1.f
, 1.f
,
89 page_scale_application_layer
, false, false);
92 template <class LayerType
>
93 void ExecuteCalculateDrawProperties(LayerType
* root_layer
,
94 float device_scale_factor
) {
95 LayerType
* page_scale_application_layer
= NULL
;
96 ExecuteCalculateDrawProperties(root_layer
, device_scale_factor
, 1.f
,
97 page_scale_application_layer
, false, false);
100 template <class LayerType
>
101 void ExecuteCalculateDrawProperties(LayerType
* root_layer
,
102 float device_scale_factor
,
103 float page_scale_factor
,
104 LayerType
* page_scale_application_layer
) {
105 ExecuteCalculateDrawProperties(root_layer
, device_scale_factor
,
107 page_scale_application_layer
, false, false);
110 void ExecuteCalculateDrawPropertiesWithPropertyTrees(Layer
* layer
);
111 void ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl
* layer
);
113 LayerImplList
* render_surface_layer_list_impl() const {
114 return render_surface_layer_list_impl_
.get();
117 const LayerList
& update_layer_list() const { return update_layer_list_
; }
118 bool UpdateLayerListContains(int id
) const;
120 int render_surface_layer_list_count() const {
121 return render_surface_layer_list_count_
;
124 const LayerSettings
& layer_settings() { return layer_settings_
; }
127 scoped_ptr
<std::vector
<LayerImpl
*>> render_surface_layer_list_impl_
;
128 LayerList update_layer_list_
;
129 LayerSettings layer_settings_
;
131 int render_surface_layer_list_count_
;
134 class LayerTreeHostCommonTest
: public LayerTreeHostCommonTestBase
,
135 public testing::Test
{
137 LayerTreeHostCommonTest();
138 explicit LayerTreeHostCommonTest(const LayerTreeSettings
& settings
);
143 #endif // CC_TEST_LAYER_TREE_HOST_COMMON_TEST_H_