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

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

Issue 53633003: Do not give GPU memory to backgrounded compositors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove test Created 7 years, 1 month 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 | Annotate | Revision Log
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/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "cc/test/fake_content_layer.h" 12 #include "cc/test/fake_content_layer.h"
13 #include "cc/test/fake_content_layer_client.h" 13 #include "cc/test/fake_content_layer_client.h"
14 #include "cc/test/fake_painted_scrollbar_layer.h" 14 #include "cc/test/fake_painted_scrollbar_layer.h"
15 #include "cc/test/fake_picture_layer.h" 15 #include "cc/test/fake_picture_layer.h"
16 #include "cc/test/layer_tree_test.h" 16 #include "cc/test/layer_tree_test.h"
17 #include "cc/trees/damage_tracker.h" 17 #include "cc/trees/damage_tracker.h"
18 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
19 19
20 namespace cc { 20 namespace cc {
21 namespace { 21 namespace {
22 22
23 // These tests deal with damage tracking. 23 // These tests deal with damage tracking.
24 class LayerTreeHostDamageTest : public LayerTreeTest {}; 24 class LayerTreeHostDamageTest : public LayerTreeTest {};
25 25
26 // Changing visibility alone does not cause drawing.
27 class LayerTreeHostDamageTestSetVisibleDoesNotDraw
28 : public LayerTreeHostDamageTest {
29 virtual void BeginTest() OVERRIDE {
30 step_ = 0;
31 PostSetNeedsCommitToMainThread();
32 }
33
34 virtual void SetupTree() OVERRIDE {
35 // Viewport is 10x10.
36 scoped_refptr<FakeContentLayer> root = FakeContentLayer::Create(&client_);
37 root->SetBounds(gfx::Size(10, 10));
38
39 layer_tree_host()->SetRootLayer(root);
40 LayerTreeHostDamageTest::SetupTree();
41 }
42
43 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* impl,
44 LayerTreeHostImpl::FrameData* frame_data,
45 bool result) OVERRIDE {
46 EXPECT_TRUE(result);
47
48 RenderSurfaceImpl* root_surface =
49 impl->active_tree()->root_layer()->render_surface();
50 gfx::RectF root_damage =
51 root_surface->damage_tracker()->current_damage_rect();
52
53 switch (step_) {
54 case 0:
55 // The first frame has full damage.
56 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString());
57
58 // No evictions when we become not-visible.
59 impl->SetMemoryPolicy(ManagedMemoryPolicy(
60 1000 * 1000 * 1000,
61 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
62 1000 * 1000 * 1000,
63 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
64 ManagedMemoryPolicy::kDefaultNumResourcesLimit));
65
66 PostSetVisibleToMainThread(false);
67 break;
68 case 1:
69 // The compositor has been set not-visible.
70 EXPECT_FALSE(impl->visible());
71 // This frame not visible, so not drawn.
72 NOTREACHED();
73 break;
74 case 2:
75 // The compositor has been set visible again.
76 EXPECT_TRUE(impl->visible());
77 // But it still does not draw.
78 NOTREACHED();
79 break;
80 case 3:
81 // Finally we force a draw, but it will have no damage.
82 EXPECT_EQ(gfx::RectF().ToString(), root_damage.ToString());
83 EndTest();
84 break;
85 case 4:
86 NOTREACHED();
87 }
88 return result;
89 }
90
91 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* impl,
92 bool visible) OVERRIDE {
93 if (!visible) {
94 EXPECT_EQ(0, step_);
95 PostSetVisibleToMainThread(true);
96 } else {
97 EXPECT_EQ(1, step_);
98
99 base::MessageLoopProxy::current()->PostDelayedTask(
100 FROM_HERE,
101 base::Bind(&LayerTreeHostDamageTestSetVisibleDoesNotDraw::Redraw,
102 base::Unretained(this),
103 impl),
104 base::TimeDelta::FromMilliseconds(10));
105 }
106 ++step_;
107 }
108
109 void Redraw(LayerTreeHostImpl* impl) {
110 EXPECT_EQ(2, step_);
111 impl->SetNeedsRedraw();
112 ++step_;
113 }
114
115 virtual void AfterTest() OVERRIDE {}
116
117 int step_;
118 FakeContentLayerClient client_;
119 };
120
121 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestSetVisibleDoesNotDraw);
122
123 // LayerTreeHost::SetNeedsRedraw should damage the whole viewport. 26 // LayerTreeHost::SetNeedsRedraw should damage the whole viewport.
124 class LayerTreeHostDamageTestSetNeedsRedraw 27 class LayerTreeHostDamageTestSetNeedsRedraw
125 : public LayerTreeHostDamageTest { 28 : public LayerTreeHostDamageTest {
126 virtual void SetupTree() OVERRIDE { 29 virtual void SetupTree() OVERRIDE {
127 // Viewport is 10x10. 30 // Viewport is 10x10.
128 scoped_refptr<FakeContentLayer> root = FakeContentLayer::Create(&client_); 31 scoped_refptr<FakeContentLayer> root = FakeContentLayer::Create(&client_);
129 root->SetBounds(gfx::Size(10, 10)); 32 root->SetBounds(gfx::Size(10, 10));
130 33
131 layer_tree_host()->SetRootLayer(root); 34 layer_tree_host()->SetRootLayer(root);
132 LayerTreeHostDamageTest::SetupTree(); 35 LayerTreeHostDamageTest::SetupTree();
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 FakeContentLayerClient client_; 686 FakeContentLayerClient client_;
784 int swap_count_; 687 int swap_count_;
785 int prepare_to_draw_count_; 688 int prepare_to_draw_count_;
786 int update_visible_tile_count_; 689 int update_visible_tile_count_;
787 }; 690 };
788 691
789 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws); 692 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws);
790 693
791 } // namespace 694 } // namespace
792 } // namespace cc 695 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | content/common/gpu/client/context_provider_command_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698