| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <set> | 5 #include <set> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 // Layer was removed so sequence from first LayerTreeHost should be | 110 // Layer was removed so sequence from first LayerTreeHost should be |
| 111 // satisfied. | 111 // satisfied. |
| 112 EXPECT_TRUE(blank_change == expected1); | 112 EXPECT_TRUE(blank_change == expected1); |
| 113 | 113 |
| 114 // No more SurfaceSequences should have been generated that need to have be | 114 // No more SurfaceSequences should have been generated that need to have be |
| 115 // satisfied. | 115 // satisfied. |
| 116 EXPECT_EQ(2u, required_seq.size()); | 116 EXPECT_EQ(2u, required_seq.size()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 static void CalcDrawProps(FakeLayerTreeHost* host, float device_scale_factor) { | |
| 120 RenderSurfaceLayerList render_surface_layer_list; | |
| 121 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | |
| 122 host->root_layer(), gfx::Size(500, 500), &render_surface_layer_list); | |
| 123 inputs.device_scale_factor = device_scale_factor; | |
| 124 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
| 125 } | |
| 126 | |
| 127 // Check that setting content scale on the surface works. | |
| 128 TEST_F(SurfaceLayerTest, ScaleSurface) { | |
| 129 SurfaceSequence blank_change; | |
| 130 SurfaceId required_id; | |
| 131 std::set<SurfaceSequence> required_seq; | |
| 132 scoped_refptr<SurfaceLayer> layer(SurfaceLayer::Create( | |
| 133 layer_settings_, base::Bind(&SatisfyCallback, &blank_change), | |
| 134 base::Bind(&RequireCallback, &required_id, &required_seq))); | |
| 135 gfx::Size surface_size(10, 15); | |
| 136 layer->SetSurfaceId(SurfaceId(1), 2.f, surface_size); | |
| 137 layer->SetBounds(gfx::Size(25, 45)); | |
| 138 layer_tree_host_->SetRootLayer(layer); | |
| 139 | |
| 140 CalcDrawProps(layer_tree_host_.get(), 5.f); | |
| 141 EXPECT_EQ(2.f, layer->contents_scale_x()); | |
| 142 EXPECT_EQ(2.f, layer->contents_scale_y()); | |
| 143 EXPECT_EQ(surface_size.ToString(), layer->content_bounds().ToString()); | |
| 144 | |
| 145 layer_tree_host_->SetRootLayer(nullptr); | |
| 146 layer_tree_host_.reset(); | |
| 147 } | |
| 148 | |
| 149 // Check that SurfaceSequence is sent through swap promise. | 119 // Check that SurfaceSequence is sent through swap promise. |
| 150 class SurfaceLayerSwapPromise : public LayerTreeTest { | 120 class SurfaceLayerSwapPromise : public LayerTreeTest { |
| 151 public: | 121 public: |
| 152 SurfaceLayerSwapPromise() | 122 SurfaceLayerSwapPromise() |
| 153 : commit_count_(0), sequence_was_satisfied_(false) {} | 123 : commit_count_(0), sequence_was_satisfied_(false) {} |
| 154 | 124 |
| 155 void BeginTest() override { | 125 void BeginTest() override { |
| 156 layer_tree_host()->set_surface_id_namespace(1); | 126 layer_tree_host()->set_surface_id_namespace(1); |
| 157 layer_ = SurfaceLayer::Create( | 127 layer_ = SurfaceLayer::Create( |
| 158 layer_settings(), base::Bind(&SatisfyCallback, &satisfied_sequence_), | 128 layer_settings(), base::Bind(&SatisfyCallback, &satisfied_sequence_), |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 SurfaceId required_id_; | 203 SurfaceId required_id_; |
| 234 std::set<SurfaceSequence> required_set_; | 204 std::set<SurfaceSequence> required_set_; |
| 235 }; | 205 }; |
| 236 | 206 |
| 237 // TODO(jbauman): Reenable on single thread once http://crbug.com/421923 is | 207 // TODO(jbauman): Reenable on single thread once http://crbug.com/421923 is |
| 238 // fixed. | 208 // fixed. |
| 239 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromise); | 209 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromise); |
| 240 | 210 |
| 241 } // namespace | 211 } // namespace |
| 242 } // namespace cc | 212 } // namespace cc |
| OLD | NEW |