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

Side by Side Diff: cc/layers/picture_layer_unittest.cc

Issue 519583003: Use the solid color detection to create solid layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added another test to make sure the tilings are cleared correctly Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/picture_layer.h" 5 #include "cc/layers/picture_layer.h"
6 6
7 #include "cc/layers/content_layer_client.h" 7 #include "cc/layers/content_layer_client.h"
8 #include "cc/layers/picture_layer_impl.h" 8 #include "cc/layers/picture_layer_impl.h"
9 #include "cc/resources/resource_update_queue.h" 9 #include "cc/resources/resource_update_queue.h"
10 #include "cc/test/fake_content_layer_client.h"
10 #include "cc/test/fake_layer_tree_host.h" 11 #include "cc/test/fake_layer_tree_host.h"
11 #include "cc/test/fake_picture_layer_impl.h" 12 #include "cc/test/fake_picture_layer_impl.h"
12 #include "cc/test/fake_proxy.h" 13 #include "cc/test/fake_proxy.h"
13 #include "cc/test/impl_side_painting_settings.h" 14 #include "cc/test/impl_side_painting_settings.h"
14 #include "cc/trees/occlusion_tracker.h" 15 #include "cc/trees/occlusion_tracker.h"
15 #include "cc/trees/single_thread_proxy.h" 16 #include "cc/trees/single_thread_proxy.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace cc { 19 namespace cc {
19 namespace { 20 namespace {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 ImplSidePaintingSettings(), &proxy, &shared_bitmap_manager); 60 ImplSidePaintingSettings(), &proxy, &shared_bitmap_manager);
60 host_impl.CreatePendingTree(); 61 host_impl.CreatePendingTree();
61 scoped_ptr<FakePictureLayerImpl> layer_impl = 62 scoped_ptr<FakePictureLayerImpl> layer_impl =
62 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1); 63 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1);
63 64
64 layer->PushPropertiesTo(layer_impl.get()); 65 layer->PushPropertiesTo(layer_impl.get());
65 EXPECT_FALSE(layer_impl->CanHaveTilings()); 66 EXPECT_FALSE(layer_impl->CanHaveTilings());
66 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); 67 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0));
67 EXPECT_EQ(gfx::Size(), layer_impl->pile()->tiling_size()); 68 EXPECT_EQ(gfx::Size(), layer_impl->pile()->tiling_size());
68 EXPECT_FALSE(layer_impl->pile()->HasRecordings()); 69 EXPECT_FALSE(layer_impl->pile()->HasRecordings());
70 EXPECT_TRUE(layer_impl->pile()->is_solid_color());
danakj 2014/09/19 20:44:28 do we care if it's solid color when it's empty? is
hendrikw 2014/09/19 22:27:13 Acknowledged.
69 } 71 }
70 } 72 }
71 73
72 TEST(PictureLayerTest, SuitableForGpuRasterization) { 74 TEST(PictureLayerTest, SuitableForGpuRasterization) {
73 MockContentLayerClient client; 75 MockContentLayerClient client;
74 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); 76 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
75 PicturePile* pile = layer->GetPicturePileForTesting(); 77 PicturePile* pile = layer->GetPicturePileForTesting();
76 78
77 // Layer is suitable for gpu rasterization by default. 79 // Layer is suitable for gpu rasterization by default.
78 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); 80 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization());
(...skipping 13 matching lines...) Expand all
92 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(settings); 94 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(settings);
93 host->SetRootLayer(layer); 95 host->SetRootLayer(layer);
94 EXPECT_EQ(Picture::RECORD_NORMALLY, layer->RecordingMode()); 96 EXPECT_EQ(Picture::RECORD_NORMALLY, layer->RecordingMode());
95 97
96 settings.recording_mode = LayerTreeSettings::RecordWithSkRecord; 98 settings.recording_mode = LayerTreeSettings::RecordWithSkRecord;
97 host = FakeLayerTreeHost::Create(settings); 99 host = FakeLayerTreeHost::Create(settings);
98 host->SetRootLayer(layer); 100 host->SetRootLayer(layer);
99 EXPECT_EQ(Picture::RECORD_WITH_SKRECORD, layer->RecordingMode()); 101 EXPECT_EQ(Picture::RECORD_WITH_SKRECORD, layer->RecordingMode());
100 } 102 }
101 103
104 TEST(PictureLayerTest, SolidColorAnalysisForPictureLayer) {
danakj 2014/09/19 20:44:28 should this test move to picture_pile_unittest.cc?
hendrikw 2014/09/19 22:27:13 It was testing that the solid state was being tran
105 FakeContentLayerClient client;
106 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
107 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
108 host->SetRootLayer(layer);
109 PicturePile* pile = layer->GetPicturePileForTesting();
110 pile->tiling().SetTilingSize(pile->tiling().max_texture_size());
111
112 FakeProxy proxy;
113 DebugScopedSetImplThread impl_thread(&proxy);
114
115 TestSharedBitmapManager shared_bitmap_manager;
116 FakeLayerTreeHostImpl host_impl(
117 ImplSidePaintingSettings(), &proxy, &shared_bitmap_manager);
118 host_impl.CreatePendingTree();
119 scoped_ptr<FakePictureLayerImpl> layer_impl =
120 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1);
121
122 gfx::Size tiling_size = pile->tiling_size();
123 gfx::Rect tiling_rect = gfx::Rect(tiling_size);
124 int frame_number = 0;
125 FakeRenderingStatsInstrumentation stats_instrumentation;
126
127 Region invalidation1(tiling_rect);
128 pile->UpdateAndExpandInvalidation(&client,
129 &invalidation1,
130 SK_ColorWHITE,
131 false,
132 false,
133 tiling_size,
134 tiling_rect,
135 frame_number++,
136 Picture::RECORD_NORMALLY,
137 &stats_instrumentation);
138
139 // We haven't drawn anything yet, so it should be solid.
140 EXPECT_TRUE(pile->is_solid_color());
141 layer->PushPropertiesTo(layer_impl.get());
142 EXPECT_TRUE(layer_impl->pile()->is_solid_color());
143
144 // Draw a rectangle that doesn't cover the viewport.
145 gfx::Rect smallRect = tiling_rect;
146 smallRect.Inset(10, 10, 10, 10);
147 SkPaint paint;
148 paint.setColor(SK_ColorCYAN);
149 client.add_draw_rect(smallRect, paint);
150 Region invalidation2(tiling_rect);
151 pile->UpdateAndExpandInvalidation(&client,
152 &invalidation2,
153 SK_ColorWHITE,
154 false,
155 false,
156 tiling_size,
157 tiling_rect,
158 frame_number++,
159 Picture::RECORD_NORMALLY,
160 &stats_instrumentation);
161
162 // Since the rectangle doesn't cover the entire layer, we should no be solid
163 EXPECT_FALSE(pile->is_solid_color());
164 layer->PushPropertiesTo(layer_impl.get());
165 EXPECT_FALSE(layer_impl->pile()->is_solid_color());
danakj 2014/09/19 20:44:28 you could just CreateFrom() another pile and verif
166
167 // Draw a rectangle that covers the viewport.
168 client.add_draw_rect(tiling_rect, paint);
169 Region invalidation3(tiling_rect);
170 pile->UpdateAndExpandInvalidation(&client,
171 &invalidation3,
172 SK_ColorWHITE,
173 false,
174 false,
175 tiling_size,
176 tiling_rect,
177 frame_number++,
178 Picture::RECORD_NORMALLY,
179 &stats_instrumentation);
180
181 // Since the rectangle doesn't cover the entire layer, we should no be solid
182 EXPECT_TRUE(pile->is_solid_color());
183 layer->PushPropertiesTo(layer_impl.get());
184 // EXPECT_EQ(0, layer->Tiling)
185 // EXPECT_TRUE(layer_impl->pile()->is_solid_color());
danakj 2014/09/19 20:44:28 leftovers
186 }
187
102 } // namespace 188 } // namespace
103 } // namespace cc 189 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698