Chromium Code Reviews| 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 #include "cc/test/layer_tree_host_common_test.h" | |
| 6 | |
| 7 #include "cc/layers/layer.h" | |
| 8 #include "cc/layers/layer_impl.h" | |
| 9 #include "cc/layers/layer_lists.h" | |
| 10 #include "cc/trees/layer_tree_host_common.h" | |
| 11 | |
| 12 namespace cc { | |
| 13 | |
| 14 LayerTreeHostCommonTestBase::LayerTreeHostCommonTestBase() | |
| 15 : render_surface_layer_list_count_(0) { | |
| 16 } | |
| 17 | |
| 18 LayerTreeHostCommonTestBase::~LayerTreeHostCommonTestBase() { | |
| 19 } | |
| 20 | |
| 21 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting( | |
| 22 Layer* layer, | |
| 23 const gfx::Transform& transform, | |
| 24 const gfx::PointF& anchor, | |
| 25 const gfx::PointF& position, | |
| 26 const gfx::Size& bounds, | |
| 27 bool flatten_transform, | |
| 28 bool is_3d_sorted) { | |
| 29 SetLayerPropertiesForTestingInternal<Layer>(layer, | |
| 30 transform, | |
| 31 anchor, | |
| 32 position, | |
| 33 bounds, | |
| 34 flatten_transform, | |
| 35 is_3d_sorted); | |
| 36 } | |
| 37 | |
| 38 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting( | |
| 39 LayerImpl* layer, | |
| 40 const gfx::Transform& transform, | |
| 41 const gfx::PointF& anchor, | |
| 42 const gfx::PointF& position, | |
| 43 const gfx::Size& bounds, | |
| 44 bool flatten_transform, | |
| 45 bool is_3d_sorted) { | |
| 46 SetLayerPropertiesForTestingInternal<LayerImpl>(layer, | |
| 47 transform, | |
| 48 anchor, | |
| 49 position, | |
| 50 bounds, | |
| 51 flatten_transform, | |
| 52 is_3d_sorted); | |
| 53 layer->SetContentBounds(bounds); | |
| 54 } | |
| 55 | |
| 56 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties( | |
| 57 Layer* root_layer, | |
| 58 float device_scale_factor, | |
| 59 float page_scale_factor, | |
| 60 Layer* page_scale_application_layer, | |
| 61 bool can_use_lcd_text) { | |
| 62 EXPECT_TRUE(page_scale_application_layer || (page_scale_factor == 1.f)); | |
| 63 gfx::Transform identity_matrix; | |
| 64 gfx::Size device_viewport_size = | |
| 65 gfx::Size(root_layer->bounds().width() * device_scale_factor, | |
| 66 root_layer->bounds().height() * device_scale_factor); | |
| 67 | |
| 68 render_surface_layer_list_.reset(new RenderSurfaceLayerList); | |
| 69 | |
| 70 // We are probably not testing what is intended if the root_layer bounds are | |
| 71 // empty. | |
| 72 DCHECK(!root_layer->bounds().IsEmpty()); | |
| 73 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | |
| 74 root_layer, device_viewport_size, render_surface_layer_list_.get()); | |
| 75 inputs.device_scale_factor = device_scale_factor; | |
| 76 inputs.page_scale_factor = page_scale_factor; | |
| 77 inputs.page_scale_application_layer = page_scale_application_layer; | |
| 78 inputs.can_use_lcd_text = can_use_lcd_text; | |
| 79 inputs.can_adjust_raster_scales = true; | |
| 80 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
| 81 } | |
| 82 | |
| 83 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties( | |
| 84 LayerImpl* root_layer, | |
| 85 float device_scale_factor, | |
| 86 float page_scale_factor, | |
| 87 LayerImpl* page_scale_application_layer, | |
| 88 bool can_use_lcd_text) { | |
| 89 gfx::Transform identity_matrix; | |
| 90 gfx::Size device_viewport_size = | |
| 91 gfx::Size(root_layer->bounds().width() * device_scale_factor, | |
| 92 root_layer->bounds().height() * device_scale_factor); | |
| 93 | |
| 94 render_surface_layer_list_impl_.reset(new LayerImplList); | |
| 95 | |
| 96 // We are probably not testing what is intended if the root_layer bounds are | |
| 97 // empty. | |
| 98 DCHECK(!root_layer->bounds().IsEmpty()); | |
| 99 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
| 100 root_layer, device_viewport_size, render_surface_layer_list_impl_.get()); | |
| 101 inputs.device_scale_factor = device_scale_factor; | |
| 102 inputs.page_scale_factor = page_scale_factor; | |
| 103 inputs.page_scale_application_layer = page_scale_application_layer; | |
| 104 inputs.can_use_lcd_text = can_use_lcd_text; | |
| 105 inputs.can_adjust_raster_scales = true; | |
| 106 | |
| 107 ++render_surface_layer_list_count_; | |
| 108 inputs.current_render_surface_layer_list_id = | |
| 109 render_surface_layer_list_count_; | |
| 110 | |
| 111 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
| 112 } | |
| 113 | |
| 114 RenderSurfaceLayerList* LayerTreeHostCommonTestBase::render_surface_layer_list() | |
| 115 const { | |
| 116 return render_surface_layer_list_.get(); | |
|
danakj
2014/05/09 18:43:48
move to header
Ian Vollick
2014/05/10 02:57:17
Done.
| |
| 117 } | |
| 118 | |
| 119 LayerImplList* LayerTreeHostCommonTestBase::render_surface_layer_list_impl() | |
| 120 const { | |
| 121 return render_surface_layer_list_impl_.get(); | |
|
danakj
2014/05/09 18:43:48
move to header
Ian Vollick
2014/05/10 02:57:17
Done.
| |
| 122 } | |
| 123 | |
| 124 int LayerTreeHostCommonTestBase::render_surface_layer_list_count() const { | |
| 125 return render_surface_layer_list_count_; | |
|
danakj
2014/05/09 18:43:48
move to header
Ian Vollick
2014/05/10 02:57:17
Done.
| |
| 126 } | |
| 127 | |
| 128 } // namespace cc | |
| OLD | NEW |