| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CC_TEST_LAYER_TREE_HOST_COMMON_TEST_H_ | |
| 6 #define CC_TEST_LAYER_TREE_HOST_COMMON_TEST_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 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 "testing/gtest/include/gtest/gtest.h" | |
| 14 | |
| 15 namespace gfx { | |
| 16 class PointF; | |
| 17 class Point3F; | |
| 18 class Size; | |
| 19 class Transform; | |
| 20 } | |
| 21 | |
| 22 namespace cc { | |
| 23 | |
| 24 class FakeLayerTreeHost; | |
| 25 class Layer; | |
| 26 class LayerImpl; | |
| 27 class RenderSurfaceLayerList; | |
| 28 | |
| 29 class LayerTreeHostCommonTestBase { | |
| 30 protected: | |
| 31 LayerTreeHostCommonTestBase(); | |
| 32 virtual ~LayerTreeHostCommonTestBase(); | |
| 33 | |
| 34 template <typename LayerType> | |
| 35 void SetLayerPropertiesForTestingInternal( | |
| 36 LayerType* layer, | |
| 37 const gfx::Transform& transform, | |
| 38 const gfx::Point3F& transform_origin, | |
| 39 const gfx::PointF& position, | |
| 40 const gfx::Size& bounds, | |
| 41 bool flatten_transform, | |
| 42 bool is_3d_sorted) { | |
| 43 layer->SetTransform(transform); | |
| 44 layer->SetTransformOrigin(transform_origin); | |
| 45 layer->SetPosition(position); | |
| 46 layer->SetBounds(bounds); | |
| 47 layer->SetShouldFlattenTransform(flatten_transform); | |
| 48 layer->Set3dSortingContextId(is_3d_sorted ? 1 : 0); | |
| 49 } | |
| 50 | |
| 51 void SetLayerPropertiesForTesting(Layer* layer, | |
| 52 const gfx::Transform& transform, | |
| 53 const gfx::Point3F& transform_origin, | |
| 54 const gfx::PointF& position, | |
| 55 const gfx::Size& bounds, | |
| 56 bool flatten_transform, | |
| 57 bool is_3d_sorted); | |
| 58 | |
| 59 void SetLayerPropertiesForTesting(LayerImpl* layer, | |
| 60 const gfx::Transform& transform, | |
| 61 const gfx::Point3F& transform_origin, | |
| 62 const gfx::PointF& position, | |
| 63 const gfx::Size& bounds, | |
| 64 bool flatten_transform, | |
| 65 bool is_3d_sorted, | |
| 66 bool create_render_surface); | |
| 67 | |
| 68 void ExecuteCalculateDrawProperties(Layer* root_layer, | |
| 69 float device_scale_factor, | |
| 70 float page_scale_factor, | |
| 71 Layer* page_scale_application_layer, | |
| 72 bool can_use_lcd_text, | |
| 73 bool layers_always_allowed_lcd_text); | |
| 74 | |
| 75 void ExecuteCalculateDrawProperties(LayerImpl* root_layer, | |
| 76 float device_scale_factor, | |
| 77 float page_scale_factor, | |
| 78 LayerImpl* page_scale_application_layer, | |
| 79 bool can_use_lcd_text, | |
| 80 bool layers_always_allowed_lcd_text); | |
| 81 | |
| 82 template <class LayerType> | |
| 83 void ExecuteCalculateDrawProperties(LayerType* root_layer) { | |
| 84 LayerType* page_scale_application_layer = NULL; | |
| 85 ExecuteCalculateDrawProperties(root_layer, 1.f, 1.f, | |
| 86 page_scale_application_layer, false, false); | |
| 87 } | |
| 88 | |
| 89 template <class LayerType> | |
| 90 void ExecuteCalculateDrawProperties(LayerType* root_layer, | |
| 91 float device_scale_factor) { | |
| 92 LayerType* page_scale_application_layer = NULL; | |
| 93 ExecuteCalculateDrawProperties(root_layer, device_scale_factor, 1.f, | |
| 94 page_scale_application_layer, false, false); | |
| 95 } | |
| 96 | |
| 97 template <class LayerType> | |
| 98 void ExecuteCalculateDrawProperties(LayerType* root_layer, | |
| 99 float device_scale_factor, | |
| 100 float page_scale_factor, | |
| 101 LayerType* page_scale_application_layer) { | |
| 102 ExecuteCalculateDrawProperties(root_layer, device_scale_factor, | |
| 103 page_scale_factor, | |
| 104 page_scale_application_layer, false, false); | |
| 105 } | |
| 106 | |
| 107 RenderSurfaceLayerList* render_surface_layer_list() const { | |
| 108 return render_surface_layer_list_.get(); | |
| 109 } | |
| 110 | |
| 111 LayerImplList* render_surface_layer_list_impl() const { | |
| 112 return render_surface_layer_list_impl_.get(); | |
| 113 } | |
| 114 | |
| 115 int render_surface_layer_list_count() const { | |
| 116 return render_surface_layer_list_count_; | |
| 117 } | |
| 118 | |
| 119 scoped_ptr<FakeLayerTreeHost> CreateFakeLayerTreeHost(); | |
| 120 | |
| 121 private: | |
| 122 scoped_ptr<RenderSurfaceLayerList> render_surface_layer_list_; | |
| 123 scoped_ptr<std::vector<LayerImpl*>> render_surface_layer_list_impl_; | |
| 124 | |
| 125 FakeLayerTreeHostClient client_; | |
| 126 int render_surface_layer_list_count_; | |
| 127 }; | |
| 128 | |
| 129 class LayerTreeHostCommonTest : public LayerTreeHostCommonTestBase, | |
| 130 public testing::Test {}; | |
| 131 | |
| 132 } // namespace cc | |
| 133 | |
| 134 #endif // CC_TEST_LAYER_TREE_HOST_COMMON_TEST_H_ | |
| OLD | NEW |