Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1504 | 1504 |
| 1505 PostSetNeedsCommitToMainThread(); | 1505 PostSetNeedsCommitToMainThread(); |
| 1506 client_.set_bounds(root_layer_->bounds()); | 1506 client_.set_bounds(root_layer_->bounds()); |
| 1507 } | 1507 } |
| 1508 | 1508 |
| 1509 void InitializeSettings(LayerTreeSettings* settings) override { | 1509 void InitializeSettings(LayerTreeSettings* settings) override { |
| 1510 settings->gpu_rasterization_enabled = true; | 1510 settings->gpu_rasterization_enabled = true; |
| 1511 settings->gpu_rasterization_forced = true; | 1511 settings->gpu_rasterization_forced = true; |
| 1512 } | 1512 } |
| 1513 | 1513 |
| 1514 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | |
| 1515 if (num_draws_ < 2) { | |
| 1516 PostSetNeedsRedrawRectToMainThread(invalid_rect_); | |
| 1517 num_draws_++; | |
| 1518 } | |
| 1519 } | |
| 1520 | |
| 1521 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 1514 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 1522 if (num_draws_ == 2) { | 1515 if (num_draws_ == 2) { |
| 1523 auto* pending_tree = host_impl->pending_tree(); | 1516 auto* pending_tree = host_impl->pending_tree(); |
| 1524 auto* pending_layer_impl = static_cast<FakePictureLayerImpl*>( | 1517 auto* pending_layer_impl = static_cast<FakePictureLayerImpl*>( |
| 1525 pending_tree->root_layer_for_testing()); | 1518 pending_tree->root_layer_for_testing()); |
| 1526 EXPECT_NE(pending_layer_impl, nullptr); | 1519 EXPECT_NE(pending_layer_impl, nullptr); |
| 1527 | 1520 |
| 1528 auto* active_tree = host_impl->pending_tree(); | 1521 auto* active_tree = host_impl->pending_tree(); |
| 1529 auto* active_layer_impl = static_cast<FakePictureLayerImpl*>( | 1522 auto* active_layer_impl = static_cast<FakePictureLayerImpl*>( |
| 1530 active_tree->root_layer_for_testing()); | 1523 active_tree->root_layer_for_testing()); |
| 1531 EXPECT_NE(pending_layer_impl, nullptr); | 1524 EXPECT_NE(pending_layer_impl, nullptr); |
| 1532 | 1525 |
| 1533 auto* active_tiling_set = active_layer_impl->picture_layer_tiling_set(); | 1526 auto* active_tiling_set = active_layer_impl->picture_layer_tiling_set(); |
| 1534 auto* active_tiling = active_tiling_set->tiling_at(0); | 1527 auto* active_tiling = active_tiling_set->tiling_at(0); |
| 1535 auto* pending_tiling_set = pending_layer_impl->picture_layer_tiling_set(); | 1528 auto* pending_tiling_set = pending_layer_impl->picture_layer_tiling_set(); |
| 1536 auto* pending_tiling = pending_tiling_set->tiling_at(0); | 1529 auto* pending_tiling = pending_tiling_set->tiling_at(0); |
| 1537 EXPECT_EQ( | 1530 EXPECT_EQ( |
| 1538 pending_tiling->TilingDataForTesting().max_texture_size().width(), | 1531 pending_tiling->TilingDataForTesting().max_texture_size().width(), |
| 1539 active_tiling->TilingDataForTesting().max_texture_size().width()); | 1532 active_tiling->TilingDataForTesting().max_texture_size().width()); |
| 1540 EndTest(); | |
| 1541 } | 1533 } |
| 1534 PostSetNeedsCommitToMainThread(); | |
|
danakj
2016/09/29 21:35:53
one nit: you could just put this as layer_tree_hos
jaydasika
2016/09/30 00:20:52
Done.
| |
| 1542 } | 1535 } |
| 1543 | 1536 |
| 1544 void DidCommitAndDrawFrame() override { | 1537 void DidCommitAndDrawFrame() override { |
| 1545 // On the second commit, resize the viewport. | 1538 // On the second commit, resize the viewport. |
| 1546 if (num_draws_ == 1) { | 1539 if (num_draws_ == 1) { |
| 1547 layer_tree()->SetViewportSize(gfx::Size(400, 64)); | 1540 layer_tree()->SetViewportSize(gfx::Size(400, 64)); |
| 1548 } | 1541 } |
| 1542 if (num_draws_ == 2) | |
| 1543 EndTest(); | |
| 1544 PostSetNeedsRedrawRectToMainThread(invalid_rect_); | |
|
danakj
2016/09/29 21:35:53
this doesn't need to post, it can just set the red
jaydasika
2016/09/30 00:20:52
Done.
| |
| 1545 num_draws_++; | |
| 1549 } | 1546 } |
| 1550 | 1547 |
| 1551 void AfterTest() override {} | 1548 void AfterTest() override {} |
| 1552 | 1549 |
| 1553 private: | 1550 private: |
| 1554 int num_draws_; | 1551 int num_draws_; |
| 1555 const gfx::Size bounds_; | 1552 const gfx::Size bounds_; |
| 1556 const gfx::Rect invalid_rect_; | 1553 const gfx::Rect invalid_rect_; |
| 1557 FakeContentLayerClient client_; | 1554 FakeContentLayerClient client_; |
| 1558 scoped_refptr<FakePictureLayer> root_layer_; | 1555 scoped_refptr<FakePictureLayer> root_layer_; |
| 1559 }; | 1556 }; |
| 1560 | 1557 |
| 1561 // As there's no pending tree in single-threaded case, this test should run | 1558 // As there's no pending tree in single-threaded case, this test should run |
| 1562 // only for multi-threaded case. | 1559 // only for multi-threaded case. |
| 1563 // Disabled because its timing out flakily. crbug.com/598491 | 1560 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterDeviceSizeChanged); |
| 1564 // MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterDeviceSizeChanged); | |
| 1565 | 1561 |
| 1566 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { | 1562 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { |
| 1567 public: | 1563 public: |
| 1568 void InitializeSettings(LayerTreeSettings* settings) override { | 1564 void InitializeSettings(LayerTreeSettings* settings) override { |
| 1569 settings->layer_transforms_should_scale_layer_contents = true; | 1565 settings->layer_transforms_should_scale_layer_contents = true; |
| 1570 } | 1566 } |
| 1571 | 1567 |
| 1572 void SetupTree() override { | 1568 void SetupTree() override { |
| 1573 root_layer_ = Layer::Create(); | 1569 root_layer_ = Layer::Create(); |
| 1574 root_layer_->SetBounds(gfx::Size(10, 20)); | 1570 root_layer_->SetBounds(gfx::Size(10, 20)); |
| (...skipping 5598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7173 EndTest(); | 7169 EndTest(); |
| 7174 } | 7170 } |
| 7175 | 7171 |
| 7176 void AfterTest() override {} | 7172 void AfterTest() override {} |
| 7177 }; | 7173 }; |
| 7178 | 7174 |
| 7179 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); | 7175 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); |
| 7180 | 7176 |
| 7181 } // namespace | 7177 } // namespace |
| 7182 } // namespace cc | 7178 } // namespace cc |
| OLD | NEW |