Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: cc/trees/layer_tree_host_unittest_context.cc

Issue 18191020: UI Resource Manager (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "cc/layers/content_layer.h" 8 #include "cc/layers/content_layer.h"
9 #include "cc/layers/heads_up_display_layer.h" 9 #include "cc/layers/heads_up_display_layer.h"
10 #include "cc/layers/io_surface_layer.h" 10 #include "cc/layers/io_surface_layer.h"
(...skipping 11 matching lines...) Expand all
22 #include "cc/test/fake_context_provider.h" 22 #include "cc/test/fake_context_provider.h"
23 #include "cc/test/fake_delegated_renderer_layer.h" 23 #include "cc/test/fake_delegated_renderer_layer.h"
24 #include "cc/test/fake_delegated_renderer_layer_impl.h" 24 #include "cc/test/fake_delegated_renderer_layer_impl.h"
25 #include "cc/test/fake_layer_tree_host_client.h" 25 #include "cc/test/fake_layer_tree_host_client.h"
26 #include "cc/test/fake_output_surface.h" 26 #include "cc/test/fake_output_surface.h"
27 #include "cc/test/fake_scrollbar.h" 27 #include "cc/test/fake_scrollbar.h"
28 #include "cc/test/fake_scrollbar_layer.h" 28 #include "cc/test/fake_scrollbar_layer.h"
29 #include "cc/test/fake_video_frame_provider.h" 29 #include "cc/test/fake_video_frame_provider.h"
30 #include "cc/test/layer_tree_test.h" 30 #include "cc/test/layer_tree_test.h"
31 #include "cc/test/render_pass_test_common.h" 31 #include "cc/test/render_pass_test_common.h"
32 #include "cc/test/test_ui_resource_client.h"
32 #include "cc/test/test_web_graphics_context_3d.h" 33 #include "cc/test/test_web_graphics_context_3d.h"
33 #include "cc/trees/layer_tree_host_impl.h" 34 #include "cc/trees/layer_tree_host_impl.h"
34 #include "cc/trees/layer_tree_impl.h" 35 #include "cc/trees/layer_tree_impl.h"
35 #include "cc/trees/single_thread_proxy.h" 36 #include "cc/trees/single_thread_proxy.h"
36 #include "gpu/GLES2/gl2extchromium.h" 37 #include "gpu/GLES2/gl2extchromium.h"
37 #include "media/base/media.h" 38 #include "media/base/media.h"
38 39
39 using media::VideoFrame; 40 using media::VideoFrame;
40 using WebKit::WebGraphicsContext3D; 41 using WebKit::WebGraphicsContext3D;
41 42
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 layer_tree_host()->root_layer()->AddChild(scroll_layer); 1495 layer_tree_host()->root_layer()->AddChild(scroll_layer);
1495 PostSetNeedsCommitToMainThread(); 1496 PostSetNeedsCommitToMainThread();
1496 } 1497 }
1497 1498
1498 virtual void AfterTest() OVERRIDE {} 1499 virtual void AfterTest() OVERRIDE {}
1499 1500
1500 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1501 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1501 LayerTreeHostContextTest::CommitCompleteOnThread(impl); 1502 LayerTreeHostContextTest::CommitCompleteOnThread(impl);
1502 1503
1503 ++commits_; 1504 ++commits_;
1504 size_t upload_count = scrollbar_layer_->last_update_full_upload_size() +
1505 scrollbar_layer_->last_update_partial_upload_size();
1506 switch (commits_) { 1505 switch (commits_) {
1507 case 1: 1506 case 1:
1508 // First (regular) update, we should upload 2 resources (thumb, and 1507 // First (regular) update, we should upload 2 resources (thumb, and
1509 // backtrack). 1508 // backtrack).
1510 EXPECT_EQ(1, scrollbar_layer_->update_count()); 1509 EXPECT_EQ(1, scrollbar_layer_->update_count());
1511 EXPECT_EQ(2u, upload_count);
1512 LoseContext(); 1510 LoseContext();
1513 break; 1511 break;
1514 case 2: 1512 case 2:
1515 // Second update, after the lost context, we should still upload 2 1513 // Second update, after the lost context, we should still upload 2
1516 // resources even if the contents haven't changed. 1514 // resources even if the contents haven't changed.
1517 EXPECT_EQ(2, scrollbar_layer_->update_count()); 1515 EXPECT_EQ(2, scrollbar_layer_->update_count());
1518 EXPECT_EQ(2u, upload_count);
1519 EndTest(); 1516 EndTest();
1520 break; 1517 break;
1521 default: 1518 default:
1522 NOTREACHED(); 1519 NOTREACHED();
1523 } 1520 }
1524 } 1521 }
1525 1522
1526 private: 1523 private:
1527 int commits_; 1524 int commits_;
1528 scoped_refptr<FakeScrollbarLayer> scrollbar_layer_; 1525 scoped_refptr<FakeScrollbarLayer> scrollbar_layer_;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 this, 1592 this,
1596 settings, 1593 settings,
1597 impl_thread ? impl_thread->message_loop_proxy() : NULL); 1594 impl_thread ? impl_thread->message_loop_proxy() : NULL);
1598 EXPECT_FALSE(layer_tree_host); 1595 EXPECT_FALSE(layer_tree_host);
1599 } 1596 }
1600 }; 1597 };
1601 1598
1602 SINGLE_AND_MULTI_THREAD_TEST_F( 1599 SINGLE_AND_MULTI_THREAD_TEST_F(
1603 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface); 1600 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface);
1604 1601
1602 // Test handling of lost resource with the UI resource manager.
1603 class UIResourceLostContext : public LayerTreeHostContextTest {
1604 public:
1605 UIResourceLostContext() : time_step_(0) {
1606 ui_resource_client_ = new TestUIResourceClient();
1607 }
1608
1609 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
1610
1611 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1612 LayerTreeHostContextTest::CommitCompleteOnThread(impl);
1613 switch (time_step_) {
1614 case 0:
1615 ui_resource_client_->CreateResource(layer_tree_host());
1616 // A valid UIResourceId.
1617 EXPECT_NE(0, ui_resource_client_->id);
1618 PostSetNeedsCommitToMainThread();
1619 break;
1620 case 1:
1621 // The resource should have been created on LTHI after the commit.
1622 if (!layer_tree_host()->settings().impl_side_painting) {
1623 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_client_->id));
1624 }
1625 PostSetNeedsCommitToMainThread();
1626 break;
1627 case 2:
1628 LoseContext();
1629 // Resource Id on the impl-side should no longer be valid after
1630 // context is lost.
1631 EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_client_->id));
1632 break;
1633 case 3:
1634 // The resources should have been recreated. The bitmap callback should
1635 // have been called once with the resource_lost flag set to true.
1636 EXPECT_EQ(1, ui_resource_client_->lost_resource_count);
1637 // Resource Id on the impl-side have been recreated as well. Note
1638 // that the same UIResourceId persists after the context lost.
1639 if (!layer_tree_host()->settings().impl_side_painting) {
1640 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_client_->id));
1641 }
1642 PostSetNeedsCommitToMainThread();
1643 break;
1644 case 4:
1645 EndTest();
1646 break;
1647 }
1648 }
1649
1650 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1651 LayerTreeHostContextTest::DidActivateTreeOnThread(impl);
1652 switch (time_step_) {
1653 case 1:
1654 if (layer_tree_host()->settings().impl_side_painting) {
1655 EXPECT_NE(0u,
1656 impl->ResourceIdForUIResource(ui_resource_client_->id));
1657 }
1658 break;
1659 case 3:
1660 if (layer_tree_host()->settings().impl_side_painting) {
1661 EXPECT_NE(0u,
1662 impl->ResourceIdForUIResource(ui_resource_client_->id));
1663 }
1664 break;
1665 }
1666 ++time_step_;
1667 }
1668
1669 virtual void AfterTest() OVERRIDE {}
1670
1671 private:
1672 int time_step_;
1673 scoped_refptr<TestUIResourceClient> ui_resource_client_;
1674 };
1675
1676 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostContext);
1677
1605 } // namespace 1678 } // namespace
1606 } // namespace cc 1679 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698