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