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

Side by Side Diff: cc/layers/picture_layer_impl_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: remove unused variable 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_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // This test verifies that when drawing the contents of a specific tile 263 // This test verifies that when drawing the contents of a specific tile
264 // at content scale 1.0, the playback canvas never receives content from 264 // at content scale 1.0, the playback canvas never receives content from
265 // neighboring tiles which indicates that the tile grid embedded in 265 // neighboring tiles which indicates that the tile grid embedded in
266 // SkPicture is perfectly aligned with the compositor's tiles. 266 // SkPicture is perfectly aligned with the compositor's tiles.
267 EXPECT_EQ(1u, mock_canvas.rects_.size()); 267 EXPECT_EQ(1u, mock_canvas.rects_.size());
268 EXPECT_RECT_EQ(*rect_iter, mock_canvas.rects_[0]); 268 EXPECT_RECT_EQ(*rect_iter, mock_canvas.rects_[0]);
269 rect_iter++; 269 rect_iter++;
270 } 270 }
271 } 271 }
272 272
273 void TestQuadsForSolidColor(bool test_for_solid) {
danakj 2014/09/15 16:26:35 This code is soo far away from the actual tests. C
hendrikw 2014/09/15 16:59:40 Acknowledged.
274 base::TimeTicks time_ticks;
275 time_ticks += base::TimeDelta::FromMilliseconds(1);
276 host_impl_.SetCurrentBeginFrameArgs(
277 CreateBeginFrameArgsForTesting(time_ticks));
278
279 gfx::Size tile_size(100, 100);
280 gfx::Size layer_bounds(200, 200);
281 gfx::Rect layer_rect(layer_bounds);
282
283 FakeContentLayerClient client;
284 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
285 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
286 host->SetRootLayer(layer);
287 PicturePile* pile = layer->GetPicturePileForTesting();
288
289 host_impl_.SetViewportSize(layer_bounds);
290
291 int frame_number = 0;
292 FakeRenderingStatsInstrumentation stats_instrumentation;
293
294 client.set_fill_with_nonsolid_color(!test_for_solid);
295
296 Region invalidation(layer_rect);
297 pile->UpdateAndExpandInvalidation(&client,
298 &invalidation,
299 SK_ColorWHITE,
300 false,
301 false,
302 layer_bounds,
303 layer_rect,
304 frame_number++,
305 Picture::RECORD_NORMALLY,
306 &stats_instrumentation);
307
308 scoped_refptr<PicturePileImpl> pending_pile =
309 PicturePileImpl::CreateFromOther(pile);
310
311 SetupPendingTree(pending_pile);
312 ActivateTree();
313
314 if (test_for_solid) {
315 EXPECT_EQ(0, active_layer_->tilings()->num_tilings());
316 } else {
317 active_layer_->set_fixed_tile_size(tile_size);
318 host_impl_.active_tree()->UpdateDrawProperties();
319 std::vector<Tile*> tiles =
vmpstr 2014/09/15 15:45:07 you should ASSERT_TRUE(active_layer_->tilings());
hendrikw 2014/09/15 16:59:40 Acknowledged. But a failure in a test doesn't pre
danakj 2014/09/15 17:01:22 An EXPECT_FOO failure continues the test. An ASSER
320 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
321 EXPECT_FALSE(tiles.empty());
322 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
323 }
324
325 MockOcclusionTracker<LayerImpl> occlusion_tracker;
326 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
327 AppendQuadsData data;
328 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL);
329 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data);
330 active_layer_->DidDraw(NULL);
331
332 DrawQuad::Material expected = test_for_solid
333 ? DrawQuad::Material::SOLID_COLOR
334 : DrawQuad::Material::TILED_CONTENT;
335 EXPECT_EQ(expected, render_pass->quad_list.front()->material);
336 }
337
273 FakeImplProxy proxy_; 338 FakeImplProxy proxy_;
274 TestSharedBitmapManager shared_bitmap_manager_; 339 TestSharedBitmapManager shared_bitmap_manager_;
275 FakeLayerTreeHostImpl host_impl_; 340 FakeLayerTreeHostImpl host_impl_;
276 int id_; 341 int id_;
277 FakePictureLayerImpl* pending_layer_; 342 FakePictureLayerImpl* pending_layer_;
278 FakePictureLayerImpl* old_pending_layer_; 343 FakePictureLayerImpl* old_pending_layer_;
279 FakePictureLayerImpl* active_layer_; 344 FakePictureLayerImpl* active_layer_;
280 345
281 private: 346 private:
282 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); 347 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest);
(...skipping 3932 matching lines...) Expand 10 before | Expand all | Expand 10 after
4215 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer()); 4280 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer());
4216 4281
4217 ActivateTree(); 4282 ActivateTree();
4218 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer()); 4283 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer());
4219 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer()); 4284 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer());
4220 4285
4221 host_impl_.ResetRecycleTreeForTesting(); 4286 host_impl_.ResetRecycleTreeForTesting();
4222 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer()); 4287 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer());
4223 } 4288 }
4224 4289
4290 TEST_F(PictureLayerImplTest, DrawSolidQuads) {
4291 TestQuadsForSolidColor(true);
4292 }
4293
4294 TEST_F(PictureLayerImplTest, DrawNonSolidQuads) {
4295 TestQuadsForSolidColor(false);
4296 }
4297
4225 } // namespace 4298 } // namespace
4226 } // namespace cc 4299 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698