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

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

Issue 2592183002: cc: Remove an old unittest trying to verify parameters in PicturePile (Closed)
Patch Set: Created 3 years, 12 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { 283 class NoLowResPictureLayerImplTest : public PictureLayerImplTest {
284 public: 284 public:
285 LayerTreeSettings CreateSettings() override { 285 LayerTreeSettings CreateSettings() override {
286 LayerTreeSettings settings = PictureLayerImplTest::CreateSettings(); 286 LayerTreeSettings settings = PictureLayerImplTest::CreateSettings();
287 settings.create_low_res_tiling = false; 287 settings.create_low_res_tiling = false;
288 return settings; 288 return settings;
289 } 289 }
290 }; 290 };
291 291
292 TEST_F(PictureLayerImplTest, TileGridAlignment) {
293 // Layer to span 4 raster tiles in x and in y
294 LayerTreeSettings settings;
295 gfx::Size layer_size(settings.default_tile_size.width() * 7 / 2,
296 settings.default_tile_size.height() * 7 / 2);
297
298 scoped_refptr<FakeRasterSource> pending_raster_source =
299 FakeRasterSource::CreateFilled(layer_size);
300
301 // Create an active recording source, but make sure it's not solid.
302 std::unique_ptr<FakeRecordingSource> active_recording_source =
303 FakeRecordingSource::CreateFilledRecordingSource(layer_size);
304 active_recording_source->SetLayerBounds(layer_size);
305 active_recording_source->add_draw_rect(gfx::Rect(layer_size));
306 active_recording_source->add_draw_rect(
307 gfx::Rect(0, 0, layer_size.width() - 1, layer_size.height() - 1));
308 active_recording_source->Rerecord();
309 scoped_refptr<FakeRasterSource> active_raster_source =
310 FakeRasterSource::CreateFromRecordingSource(active_recording_source.get(),
311 false);
312
313 SetupTrees(pending_raster_source, active_raster_source);
314
315 // Add 1x1 rects at the centers of each tile, then re-record recording source
316 // contents.
317 active_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting();
318 std::vector<Tile*> tiles =
319 active_layer()->tilings()->tiling_at(0)->AllTilesForTesting();
320 EXPECT_EQ(16u, tiles.size());
321 std::vector<SkRect> rects;
322 std::vector<Tile*>::const_iterator tile_iter;
323 active_recording_source->reset_draws();
324 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) {
325 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint();
326 gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1);
327 active_recording_source->add_draw_rect(rect);
328 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1));
329 }
330
331 // Force re-raster with newly injected content
332 active_recording_source->Rerecord();
333
334 scoped_refptr<FakeRasterSource> updated_active_raster_source =
335 FakeRasterSource::CreateFromRecordingSource(active_recording_source.get(),
336 false);
337
338 RasterSource::PlaybackSettings playback_settings;
339 playback_settings.playback_to_shared_canvas = true;
340 std::vector<SkRect>::const_iterator rect_iter = rects.begin();
341 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) {
342 MockCanvas mock_canvas(1000, 1000);
343 const gfx::Rect& content_rect = (*tile_iter)->content_rect();
344 updated_active_raster_source->RasterSource::PlaybackToCanvas(
345 &mock_canvas, content_rect, content_rect, gfx::SizeF(1.f, 1.f),
346 playback_settings);
347
348 // This test verifies that when drawing the contents of a specific tile
349 // at content scale 1.0, the playback canvas never receives content from
350 // neighboring tiles which indicates that the tile grid embedded in
351 // SkPicture is perfectly aligned with the compositor's tiles.
352 EXPECT_EQ(1u, mock_canvas.rects_.size());
353 EXPECT_EQ(*rect_iter, mock_canvas.rects_[0]);
354 rect_iter++;
355 }
356 }
357
358 TEST_F(PictureLayerImplTest, CloneNoInvalidation) { 292 TEST_F(PictureLayerImplTest, CloneNoInvalidation) {
359 gfx::Size layer_bounds(400, 400); 293 gfx::Size layer_bounds(400, 400);
360 SetupDefaultTrees(layer_bounds); 294 SetupDefaultTrees(layer_bounds);
361 295
362 EXPECT_EQ(pending_layer()->tilings()->num_tilings(), 296 EXPECT_EQ(pending_layer()->tilings()->num_tilings(),
363 active_layer()->tilings()->num_tilings()); 297 active_layer()->tilings()->num_tilings());
364 298
365 const PictureLayerTilingSet* tilings = pending_layer()->tilings(); 299 const PictureLayerTilingSet* tilings = pending_layer()->tilings();
366 EXPECT_GT(tilings->num_tilings(), 0u); 300 EXPECT_GT(tilings->num_tilings(), 0u);
367 for (size_t i = 0; i < tilings->num_tilings(); ++i) 301 for (size_t i = 0; i < tilings->num_tilings(); ++i)
(...skipping 4653 matching lines...) Expand 10 before | Expand all | Expand 10 after
5021 EXPECT_FLOAT_EQ(expected_contents_scale, 4955 EXPECT_FLOAT_EQ(expected_contents_scale,
5022 pending_layer_ptr->picture_layer_tiling_set() 4956 pending_layer_ptr->picture_layer_tiling_set()
5023 ->FindTilingWithResolution(HIGH_RESOLUTION) 4957 ->FindTilingWithResolution(HIGH_RESOLUTION)
5024 ->contents_scale_key()) 4958 ->contents_scale_key())
5025 << "ideal_contents_scale: " << ideal_contents_scale; 4959 << "ideal_contents_scale: " << ideal_contents_scale;
5026 } 4960 }
5027 } 4961 }
5028 4962
5029 } // namespace 4963 } // namespace
5030 } // namespace cc 4964 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698