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
;
31 class RenderSurfaceLayerList
;
33 class LayerTreeHostCommonTestBase
: public LayerTestCommon::LayerImplTest
{
35 explicit LayerTreeHostCommonTestBase(const LayerTreeSettings
& settings
);
36 virtual ~LayerTreeHostCommonTestBase();
38 template <typename LayerType
>
39 void SetLayerPropertiesForTestingInternal(
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 layer
->SetTransform(transform
);
48 layer
->SetTransformOrigin(transform_origin
);
49 layer
->SetPosition(position
);
50 layer
->SetBounds(bounds
);
51 layer
->SetShouldFlattenTransform(flatten_transform
);
52 layer
->Set3dSortingContextId(is_3d_sorted
? 1 : 0);
55 void SetLayerPropertiesForTesting(Layer
* layer
,
56 const gfx::Transform
& transform
,
57 const gfx::Point3F
& transform_origin
,
58 const gfx::PointF
& position
,
59 const gfx::Size
& bounds
,
60 bool flatten_transform
,
63 void SetLayerPropertiesForTesting(LayerImpl
* layer
,
64 const gfx::Transform
& transform
,
65 const gfx::Point3F
& transform_origin
,
66 const gfx::PointF
& position
,
67 const gfx::Size
& bounds
,
68 bool flatten_transform
,
70 bool create_render_surface
);
72 void ExecuteCalculateDrawProperties(Layer
* root_layer
,
73 float device_scale_factor
,
74 float page_scale_factor
,
75 Layer
* page_scale_application_layer
,
76 bool can_use_lcd_text
,
77 bool layers_always_allowed_lcd_text
);
79 void ExecuteCalculateDrawProperties(LayerImpl
* root_layer
,
80 float device_scale_factor
,
81 float page_scale_factor
,
82 LayerImpl
* page_scale_application_layer
,
83 bool can_use_lcd_text
,
84 bool layers_always_allowed_lcd_text
);
86 template <class LayerType
>
87 void ExecuteCalculateDrawProperties(LayerType
* root_layer
) {
88 LayerType
* page_scale_application_layer
= NULL
;
89 ExecuteCalculateDrawProperties(root_layer
, 1.f
, 1.f
,
90 page_scale_application_layer
, false, false);
93 template <class LayerType
>
94 void ExecuteCalculateDrawProperties(LayerType
* root_layer
,
95 float device_scale_factor
) {
96 LayerType
* page_scale_application_layer
= NULL
;
97 ExecuteCalculateDrawProperties(root_layer
, device_scale_factor
, 1.f
,
98 page_scale_application_layer
, false, false);
101 template <class LayerType
>
102 void ExecuteCalculateDrawProperties(LayerType
* root_layer
,
103 float device_scale_factor
,
104 float page_scale_factor
,
105 LayerType
* page_scale_application_layer
) {
106 ExecuteCalculateDrawProperties(root_layer
, device_scale_factor
,
108 page_scale_application_layer
, false, false);
111 void ExecuteCalculateDrawPropertiesWithPropertyTrees(Layer
* layer
);
112 void ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl
* layer
);
114 RenderSurfaceLayerList
* render_surface_layer_list() const {
115 return render_surface_layer_list_
.get();
118 LayerImplList
* render_surface_layer_list_impl() const {
119 return render_surface_layer_list_impl_
.get();
122 const LayerList
& update_layer_list() const { return update_layer_list_
; }
123 bool UpdateLayerListContains(int id
) const;
125 int render_surface_layer_list_count() const {
126 return render_surface_layer_list_count_
;
129 const LayerSettings
& layer_settings() { return layer_settings_
; }
132 scoped_ptr
<RenderSurfaceLayerList
> render_surface_layer_list_
;
133 scoped_ptr
<std::vector
<LayerImpl
*>> render_surface_layer_list_impl_
;
134 LayerList update_layer_list_
;
135 LayerSettings layer_settings_
;
137 int render_surface_layer_list_count_
;
140 class LayerTreeHostCommonTest
: public LayerTreeHostCommonTestBase
,
141 public testing::Test
{
143 LayerTreeHostCommonTest();
144 explicit LayerTreeHostCommonTest(const LayerTreeSettings
& settings
);
149 #endif // CC_TEST_LAYER_TREE_HOST_COMMON_TEST_H_