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 "testing/gtest/include/gtest/gtest.h"
25 class RenderSurfaceLayerList
;
27 class LayerTreeHostCommonTestBase
{
29 LayerTreeHostCommonTestBase();
30 virtual ~LayerTreeHostCommonTestBase();
32 template <typename LayerType
>
33 void SetLayerPropertiesForTestingInternal(
35 const gfx::Transform
& transform
,
36 const gfx::Point3F
& transform_origin
,
37 const gfx::PointF
& position
,
38 const gfx::Size
& bounds
,
39 bool flatten_transform
,
41 layer
->SetTransform(transform
);
42 layer
->SetTransformOrigin(transform_origin
);
43 layer
->SetPosition(position
);
44 layer
->SetBounds(bounds
);
45 layer
->SetShouldFlattenTransform(flatten_transform
);
46 layer
->Set3dSortingContextId(is_3d_sorted
? 1 : 0);
49 void SetLayerPropertiesForTesting(Layer
* layer
,
50 const gfx::Transform
& transform
,
51 const gfx::Point3F
& transform_origin
,
52 const gfx::PointF
& position
,
53 const gfx::Size
& bounds
,
54 bool flatten_transform
,
57 void SetLayerPropertiesForTesting(LayerImpl
* layer
,
58 const gfx::Transform
& transform
,
59 const gfx::Point3F
& transform_origin
,
60 const gfx::PointF
& position
,
61 const gfx::Size
& bounds
,
62 bool flatten_transform
,
65 void ExecuteCalculateDrawProperties(Layer
* root_layer
,
66 float device_scale_factor
,
67 float page_scale_factor
,
68 Layer
* page_scale_application_layer
,
69 bool can_use_lcd_text
);
71 void ExecuteCalculateDrawProperties(LayerImpl
* root_layer
,
72 float device_scale_factor
,
73 float page_scale_factor
,
74 LayerImpl
* page_scale_application_layer
,
75 bool can_use_lcd_text
);
77 template <class LayerType
>
78 void ExecuteCalculateDrawProperties(LayerType
* root_layer
) {
79 LayerType
* page_scale_application_layer
= NULL
;
80 ExecuteCalculateDrawProperties(
81 root_layer
, 1.f
, 1.f
, page_scale_application_layer
, false);
84 template <class LayerType
>
85 void ExecuteCalculateDrawProperties(LayerType
* root_layer
,
86 float device_scale_factor
) {
87 LayerType
* page_scale_application_layer
= NULL
;
88 ExecuteCalculateDrawProperties(root_layer
,
91 page_scale_application_layer
,
95 template <class LayerType
>
96 void ExecuteCalculateDrawProperties(LayerType
* root_layer
,
97 float device_scale_factor
,
98 float page_scale_factor
,
99 LayerType
* page_scale_application_layer
) {
100 ExecuteCalculateDrawProperties(root_layer
,
103 page_scale_application_layer
,
107 RenderSurfaceLayerList
* render_surface_layer_list() const {
108 return render_surface_layer_list_
.get();
111 LayerImplList
* render_surface_layer_list_impl() const {
112 return render_surface_layer_list_impl_
.get();
115 int render_surface_layer_list_count() const {
116 return render_surface_layer_list_count_
;
120 scoped_ptr
<RenderSurfaceLayerList
> render_surface_layer_list_
;
121 scoped_ptr
<std::vector
<LayerImpl
*> > render_surface_layer_list_impl_
;
123 int render_surface_layer_list_count_
;
126 class LayerTreeHostCommonTest
: public LayerTreeHostCommonTestBase
,
127 public testing::Test
{};
131 #endif // CC_TEST_LAYER_TREE_HOST_COMMON_TEST_H_