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

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 {
1610 PostSetNeedsCommitToMainThread();
1611 }
1612
1613 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1614 LayerTreeHostContextTest::CommitCompleteOnThread(impl);
1615 switch (time_step_) {
1616 case 0:
1617 ui_resource_client_->CreateResource(layer_tree_host());
1618 // A valid UIResourceId.
1619 EXPECT_NE(0, ui_resource_client_->id);
1620 PostSetNeedsCommitToMainThread();
1621 break;
1622 case 1:
1623 // A valid Resource Id on the impl-side.
enne (OOO) 2013/07/22 23:09:15 I'm not sure what this comment is trying to say.
powei 2013/07/24 02:28:29 Done. Changed wording.
1624 if (!layer_tree_host()->settings().impl_side_painting) {
1625 EXPECT_NE(0u,
1626 impl->ResourceIdForUIResource(ui_resource_client_->id));
1627 }
1628 PostSetNeedsCommitToMainThread();
1629 break;
1630 case 2:
1631 LoseContext();
1632 // Resource Id on the impl-side should no longer be valid after
1633 // context is lost.
1634 EXPECT_EQ(0u,
1635 impl->ResourceIdForUIResource(ui_resource_client_->id));
1636 break;
1637 case 3:
1638 // The resources should have been recreated. The bitmap callback should
1639 // have been called once with the resource_lost flag set to true.
1640 EXPECT_EQ(1u, ui_resource_client_->lost_resource_count);
1641 // Resource Id on the impl-side have been recreated as well. Note
1642 // that the same UIResourceId persists after the context lost.
1643 if (!layer_tree_host()->settings().impl_side_painting) {
1644 EXPECT_NE(0u,
1645 impl->ResourceIdForUIResource(ui_resource_client_->id));
1646 }
1647 PostSetNeedsCommitToMainThread();
1648 break;
1649 case 4:
1650 EndTest();
1651 break;
1652 }
1653 }
1654
1655 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1656 LayerTreeHostContextTest::DidActivateTreeOnThread(impl);
1657 switch (time_step_) {
1658 case 1:
1659 if (layer_tree_host()->settings().impl_side_painting) {
enne (OOO) 2013/07/22 23:09:15 Does this even get called for non-impl-side painti
powei 2013/07/24 02:28:29 Done. I wasn't sure, but apparently it does get c
1660 EXPECT_NE(0u,
1661 impl->ResourceIdForUIResource(ui_resource_client_->id));
1662 }
1663 break;
1664 case 3:
1665 if (layer_tree_host()->settings().impl_side_painting) {
1666 EXPECT_NE(0u,
1667 impl->ResourceIdForUIResource(ui_resource_client_->id));
1668 }
1669 break;
1670 }
1671 ++time_step_;
1672 }
1673
1674 virtual void AfterTest() OVERRIDE {}
1675
1676 private:
1677 int time_step_;
1678 scoped_refptr<TestUIResourceClient> ui_resource_client_;
1679 };
1680
1681 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostContext);
1682
1605 } // namespace 1683 } // namespace
1606 } // namespace cc 1684 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698