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

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: 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. 26 // Changing visibility alone does not cause drawing.
27 class LayerTreeHostDamageTestSetVisibleDoesNotDraw 27 class LayerTreeHostDamageTestSetVisibleDoesNotDraw
ccameron 2013/10/31 03:30:13 I wasn't sure what to do with this test. It's not
piman 2013/10/31 04:00:25 Do we know if this test was introduced with a part
danakj 2013/10/31 17:11:24 I think delete this test. It did not come out of a
28 : public LayerTreeHostDamageTest { 28 : public LayerTreeHostDamageTest {
29 virtual void BeginTest() OVERRIDE { 29 virtual void BeginTest() OVERRIDE {
30 step_ = 0; 30 step_ = 0;
31 PostSetNeedsCommitToMainThread(); 31 PostSetNeedsCommitToMainThread();
32 } 32 }
33 33
34 virtual void SetupTree() OVERRIDE { 34 virtual void SetupTree() OVERRIDE {
35 // Viewport is 10x10. 35 // Viewport is 10x10.
36 scoped_refptr<FakeContentLayer> root = FakeContentLayer::Create(&client_); 36 scoped_refptr<FakeContentLayer> root = FakeContentLayer::Create(&client_);
37 root->SetBounds(gfx::Size(10, 10)); 37 root->SetBounds(gfx::Size(10, 10));
38 38
39 layer_tree_host()->SetRootLayer(root); 39 layer_tree_host()->SetRootLayer(root);
40 LayerTreeHostDamageTest::SetupTree(); 40 LayerTreeHostDamageTest::SetupTree();
41 } 41 }
42 42
43 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* impl, 43 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* impl,
44 LayerTreeHostImpl::FrameData* frame_data, 44 LayerTreeHostImpl::FrameData* frame_data,
45 bool result) OVERRIDE { 45 bool result) OVERRIDE {
46 EXPECT_TRUE(result); 46 EXPECT_TRUE(result);
47 47
48 RenderSurfaceImpl* root_surface = 48 RenderSurfaceImpl* root_surface =
49 impl->active_tree()->root_layer()->render_surface(); 49 impl->active_tree()->root_layer()->render_surface();
50 gfx::RectF root_damage = 50 gfx::RectF root_damage =
51 root_surface->damage_tracker()->current_damage_rect(); 51 root_surface->damage_tracker()->current_damage_rect();
52 52
53 switch (step_) { 53 switch (step_) {
54 case 0: 54 case 0:
55 // The first frame has full damage. 55 // The first frame has full damage.
56 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString()); 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); 57 PostSetVisibleToMainThread(false);
67 break; 58 break;
68 case 1: 59 case 1:
69 // The compositor has been set not-visible. 60 // The compositor has been set not-visible.
70 EXPECT_FALSE(impl->visible()); 61 EXPECT_FALSE(impl->visible());
71 // This frame not visible, so not drawn. 62 // This frame not visible, so not drawn.
72 NOTREACHED(); 63 NOTREACHED();
73 break; 64 break;
74 case 2: 65 case 2:
75 // The compositor has been set visible again. 66 // The compositor has been set visible again.
76 EXPECT_TRUE(impl->visible()); 67 EXPECT_TRUE(impl->visible());
77 // But it still does not draw. 68 if (!impl->settings().impl_side_painting) {
78 NOTREACHED(); 69 // Evicting resources for non-impl-side painting will trigger a full
70 // redraw.
71 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString());
72 } else {
73 // Otherwise there will be no redraw.
74 NOTREACHED();
75 }
79 break; 76 break;
80 case 3: 77 case 3:
81 // Finally we force a draw, but it will have no damage. 78 if (impl->settings().impl_side_painting && !delegating_renderer()) {
82 EXPECT_EQ(gfx::RectF().ToString(), root_damage.ToString()); 79 // The forced draw will have full damage with a direct impl-side
80 // painting renderer.
81 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString());
82 } else {
83 // Finally we force a draw, but it will have no damage.
84 EXPECT_EQ(gfx::RectF().ToString(), root_damage.ToString());
85 }
83 EndTest(); 86 EndTest();
84 break; 87 break;
85 case 4: 88 case 4:
86 NOTREACHED(); 89 NOTREACHED();
87 } 90 }
88 return result; 91 return result;
89 } 92 }
90 93
91 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* impl, 94 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* impl,
92 bool visible) OVERRIDE { 95 bool visible) OVERRIDE {
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 FakeContentLayerClient client_; 786 FakeContentLayerClient client_;
784 int swap_count_; 787 int swap_count_;
785 int prepare_to_draw_count_; 788 int prepare_to_draw_count_;
786 int update_visible_tile_count_; 789 int update_visible_tile_count_;
787 }; 790 };
788 791
789 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws); 792 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws);
790 793
791 } // namespace 794 } // namespace
792 } // namespace cc 795 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698