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

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

Issue 1837263005: cc: Rename DisplayListRasterSource to just RasterSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « cc/layers/picture_layer_impl_perftest.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | 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>
11 #include <set> 11 #include <set>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
17 #include "cc/base/math_util.h" 17 #include "cc/base/math_util.h"
18 #include "cc/layers/append_quads_data.h" 18 #include "cc/layers/append_quads_data.h"
19 #include "cc/layers/picture_layer.h" 19 #include "cc/layers/picture_layer.h"
20 #include "cc/quads/draw_quad.h" 20 #include "cc/quads/draw_quad.h"
21 #include "cc/quads/tile_draw_quad.h" 21 #include "cc/quads/tile_draw_quad.h"
22 #include "cc/test/begin_frame_args_test.h" 22 #include "cc/test/begin_frame_args_test.h"
23 #include "cc/test/fake_content_layer_client.h" 23 #include "cc/test/fake_content_layer_client.h"
24 #include "cc/test/fake_display_list_raster_source.h"
25 #include "cc/test/fake_display_list_recording_source.h" 24 #include "cc/test/fake_display_list_recording_source.h"
26 #include "cc/test/fake_impl_task_runner_provider.h" 25 #include "cc/test/fake_impl_task_runner_provider.h"
27 #include "cc/test/fake_layer_tree_host_impl.h" 26 #include "cc/test/fake_layer_tree_host_impl.h"
28 #include "cc/test/fake_output_surface.h" 27 #include "cc/test/fake_output_surface.h"
29 #include "cc/test/fake_picture_layer_impl.h" 28 #include "cc/test/fake_picture_layer_impl.h"
29 #include "cc/test/fake_raster_source.h"
30 #include "cc/test/geometry_test_utils.h" 30 #include "cc/test/geometry_test_utils.h"
31 #include "cc/test/gpu_rasterization_enabled_settings.h" 31 #include "cc/test/gpu_rasterization_enabled_settings.h"
32 #include "cc/test/layer_test_common.h" 32 #include "cc/test/layer_test_common.h"
33 #include "cc/test/test_shared_bitmap_manager.h" 33 #include "cc/test/test_shared_bitmap_manager.h"
34 #include "cc/test/test_task_graph_runner.h" 34 #include "cc/test/test_task_graph_runner.h"
35 #include "cc/test/test_web_graphics_context_3d.h" 35 #include "cc/test/test_web_graphics_context_3d.h"
36 #include "cc/tiles/tiling_set_raster_queue_all.h" 36 #include "cc/tiles/tiling_set_raster_queue_all.h"
37 #include "cc/tiles/tiling_set_raster_queue_required.h" 37 #include "cc/tiles/tiling_set_raster_queue_required.h"
38 #include "cc/trees/layer_tree_impl.h" 38 #include "cc/trees/layer_tree_impl.h"
39 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 ~PictureLayerImplTest() override {} 115 ~PictureLayerImplTest() override {}
116 116
117 void SetUp() override { InitializeRenderer(); } 117 void SetUp() override { InitializeRenderer(); }
118 118
119 virtual void InitializeRenderer() { 119 virtual void InitializeRenderer() {
120 host_impl_.SetVisible(true); 120 host_impl_.SetVisible(true);
121 host_impl_.InitializeRenderer(output_surface_.get()); 121 host_impl_.InitializeRenderer(output_surface_.get());
122 } 122 }
123 123
124 void SetupDefaultTrees(const gfx::Size& layer_bounds) { 124 void SetupDefaultTrees(const gfx::Size& layer_bounds) {
125 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 125 scoped_refptr<FakeRasterSource> pending_raster_source =
126 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 126 FakeRasterSource::CreateFilled(layer_bounds);
127 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 127 scoped_refptr<FakeRasterSource> active_raster_source =
128 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 128 FakeRasterSource::CreateFilled(layer_bounds);
129 129
130 SetupTrees(pending_raster_source, active_raster_source); 130 SetupTrees(pending_raster_source, active_raster_source);
131 } 131 }
132 132
133 void SetupDefaultTreesWithInvalidation(const gfx::Size& layer_bounds, 133 void SetupDefaultTreesWithInvalidation(const gfx::Size& layer_bounds,
134 const Region& invalidation) { 134 const Region& invalidation) {
135 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 135 scoped_refptr<FakeRasterSource> pending_raster_source =
136 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 136 FakeRasterSource::CreateFilled(layer_bounds);
137 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 137 scoped_refptr<FakeRasterSource> active_raster_source =
138 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 138 FakeRasterSource::CreateFilled(layer_bounds);
139 139
140 SetupTreesWithInvalidation(pending_raster_source, active_raster_source, 140 SetupTreesWithInvalidation(pending_raster_source, active_raster_source,
141 invalidation); 141 invalidation);
142 } 142 }
143 143
144 void RebuildPropertyTreesOnPendingTree() { 144 void RebuildPropertyTreesOnPendingTree() {
145 host_impl_.pending_tree()->property_trees()->needs_rebuild = true; 145 host_impl_.pending_tree()->property_trees()->needs_rebuild = true;
146 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); 146 host_impl_.pending_tree()->BuildPropertyTreesForTesting();
147 } 147 }
148 148
149 void ActivateTree() { 149 void ActivateTree() {
150 RebuildPropertyTreesOnPendingTree(); 150 RebuildPropertyTreesOnPendingTree();
151 host_impl_.ActivateSyncTree(); 151 host_impl_.ActivateSyncTree();
152 CHECK(!host_impl_.pending_tree()); 152 CHECK(!host_impl_.pending_tree());
153 CHECK(host_impl_.recycle_tree()); 153 CHECK(host_impl_.recycle_tree());
154 old_pending_layer_ = pending_layer_; 154 old_pending_layer_ = pending_layer_;
155 pending_layer_ = nullptr; 155 pending_layer_ = nullptr;
156 active_layer_ = static_cast<FakePictureLayerImpl*>( 156 active_layer_ = static_cast<FakePictureLayerImpl*>(
157 host_impl_.active_tree()->LayerById(id_)); 157 host_impl_.active_tree()->LayerById(id_));
158 158
159 bool update_lcd_text = false; 159 bool update_lcd_text = false;
160 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); 160 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
161 } 161 }
162 162
163 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, 163 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds,
164 const gfx::Size& tile_size, 164 const gfx::Size& tile_size,
165 const Region& invalidation) { 165 const Region& invalidation) {
166 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 166 scoped_refptr<FakeRasterSource> pending_raster_source =
167 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 167 FakeRasterSource::CreateFilled(layer_bounds);
168 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 168 scoped_refptr<FakeRasterSource> active_raster_source =
169 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 169 FakeRasterSource::CreateFilled(layer_bounds);
170 170
171 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, 171 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source,
172 tile_size, invalidation); 172 tile_size, invalidation);
173 } 173 }
174 174
175 void SetupTrees(scoped_refptr<DisplayListRasterSource> pending_raster_source, 175 void SetupTrees(scoped_refptr<RasterSource> pending_raster_source,
176 scoped_refptr<DisplayListRasterSource> active_raster_source) { 176 scoped_refptr<RasterSource> active_raster_source) {
177 SetupPendingTree(active_raster_source); 177 SetupPendingTree(active_raster_source);
178 ActivateTree(); 178 ActivateTree();
179 SetupPendingTreeInternal(pending_raster_source, gfx::Size(), Region()); 179 SetupPendingTreeInternal(pending_raster_source, gfx::Size(), Region());
180 } 180 }
181 181
182 void SetupTreesWithInvalidation( 182 void SetupTreesWithInvalidation(
183 scoped_refptr<DisplayListRasterSource> pending_raster_source, 183 scoped_refptr<RasterSource> pending_raster_source,
184 scoped_refptr<DisplayListRasterSource> active_raster_source, 184 scoped_refptr<RasterSource> active_raster_source,
185 const Region& pending_invalidation) { 185 const Region& pending_invalidation) {
186 SetupPendingTreeInternal(active_raster_source, gfx::Size(), Region()); 186 SetupPendingTreeInternal(active_raster_source, gfx::Size(), Region());
187 ActivateTree(); 187 ActivateTree();
188 SetupPendingTreeInternal(pending_raster_source, gfx::Size(), 188 SetupPendingTreeInternal(pending_raster_source, gfx::Size(),
189 pending_invalidation); 189 pending_invalidation);
190 } 190 }
191 191
192 void SetupTreesWithFixedTileSize( 192 void SetupTreesWithFixedTileSize(
193 scoped_refptr<DisplayListRasterSource> pending_raster_source, 193 scoped_refptr<RasterSource> pending_raster_source,
194 scoped_refptr<DisplayListRasterSource> active_raster_source, 194 scoped_refptr<RasterSource> active_raster_source,
195 const gfx::Size& tile_size, 195 const gfx::Size& tile_size,
196 const Region& pending_invalidation) { 196 const Region& pending_invalidation) {
197 SetupPendingTreeInternal(active_raster_source, tile_size, Region()); 197 SetupPendingTreeInternal(active_raster_source, tile_size, Region());
198 ActivateTree(); 198 ActivateTree();
199 SetupPendingTreeInternal(pending_raster_source, tile_size, 199 SetupPendingTreeInternal(pending_raster_source, tile_size,
200 pending_invalidation); 200 pending_invalidation);
201 } 201 }
202 202
203 void SetupPendingTree(scoped_refptr<DisplayListRasterSource> raster_source) { 203 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) {
204 SetupPendingTreeInternal(raster_source, gfx::Size(), Region()); 204 SetupPendingTreeInternal(raster_source, gfx::Size(), Region());
205 } 205 }
206 206
207 void SetupPendingTreeWithInvalidation( 207 void SetupPendingTreeWithInvalidation(
208 scoped_refptr<DisplayListRasterSource> raster_source, 208 scoped_refptr<RasterSource> raster_source,
209 const Region& invalidation) { 209 const Region& invalidation) {
210 SetupPendingTreeInternal(raster_source, gfx::Size(), invalidation); 210 SetupPendingTreeInternal(raster_source, gfx::Size(), invalidation);
211 } 211 }
212 212
213 void SetupPendingTreeWithFixedTileSize( 213 void SetupPendingTreeWithFixedTileSize(
214 scoped_refptr<DisplayListRasterSource> raster_source, 214 scoped_refptr<RasterSource> raster_source,
215 const gfx::Size& tile_size, 215 const gfx::Size& tile_size,
216 const Region& invalidation) { 216 const Region& invalidation) {
217 SetupPendingTreeInternal(raster_source, tile_size, invalidation); 217 SetupPendingTreeInternal(raster_source, tile_size, invalidation);
218 } 218 }
219 219
220 void SetupPendingTreeInternal( 220 void SetupPendingTreeInternal(scoped_refptr<RasterSource> raster_source,
221 scoped_refptr<DisplayListRasterSource> raster_source, 221 const gfx::Size& tile_size,
222 const gfx::Size& tile_size, 222 const Region& invalidation) {
223 const Region& invalidation) {
224 host_impl_.CreatePendingTree(); 223 host_impl_.CreatePendingTree();
225 host_impl_.pending_tree()->PushPageScaleFromMainThread(1.f, 0.00001f, 224 host_impl_.pending_tree()->PushPageScaleFromMainThread(1.f, 0.00001f,
226 100000.f); 225 100000.f);
227 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 226 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
228 pending_tree->SetDeviceScaleFactor( 227 pending_tree->SetDeviceScaleFactor(
229 host_impl_.active_tree()->device_scale_factor()); 228 host_impl_.active_tree()->device_scale_factor());
230 229
231 // Steal from the recycled tree if possible. 230 // Steal from the recycled tree if possible.
232 LayerImpl* pending_root = pending_tree->root_layer(); 231 LayerImpl* pending_root = pending_tree->root_layer();
233 scoped_ptr<FakePictureLayerImpl> pending_layer; 232 scoped_ptr<FakePictureLayerImpl> pending_layer;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 bool animating_transform_to_screen) { 298 bool animating_transform_to_screen) {
300 SetupDrawProperties(layer, ideal_contents_scale, device_scale_factor, 299 SetupDrawProperties(layer, ideal_contents_scale, device_scale_factor,
301 page_scale_factor, maximum_animation_contents_scale, 300 page_scale_factor, maximum_animation_contents_scale,
302 starting_animation_contents_scale, 301 starting_animation_contents_scale,
303 animating_transform_to_screen); 302 animating_transform_to_screen);
304 layer->UpdateTiles(); 303 layer->UpdateTiles();
305 } 304 }
306 305
307 static void VerifyAllPrioritizedTilesExistAndHaveRasterSource( 306 static void VerifyAllPrioritizedTilesExistAndHaveRasterSource(
308 const PictureLayerTiling* tiling, 307 const PictureLayerTiling* tiling,
309 DisplayListRasterSource* raster_source) { 308 RasterSource* raster_source) {
310 auto prioritized_tiles = 309 auto prioritized_tiles =
311 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 310 tiling->UpdateAndGetAllPrioritizedTilesForTesting();
312 for (PictureLayerTiling::CoverageIterator iter( 311 for (PictureLayerTiling::CoverageIterator iter(
313 tiling, 312 tiling,
314 tiling->contents_scale(), 313 tiling->contents_scale(),
315 gfx::Rect(tiling->tiling_size())); 314 gfx::Rect(tiling->tiling_size()));
316 iter; 315 iter;
317 ++iter) { 316 ++iter) {
318 EXPECT_TRUE(*iter); 317 EXPECT_TRUE(*iter);
319 EXPECT_EQ(raster_source, prioritized_tiles[*iter].raster_source()); 318 EXPECT_EQ(raster_source, prioritized_tiles[*iter].raster_source());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 NoLowResPictureLayerImplTest() 409 NoLowResPictureLayerImplTest()
411 : PictureLayerImplTest(NoLowResTilingsSettings()) {} 410 : PictureLayerImplTest(NoLowResTilingsSettings()) {}
412 }; 411 };
413 412
414 TEST_F(PictureLayerImplTest, TileGridAlignment) { 413 TEST_F(PictureLayerImplTest, TileGridAlignment) {
415 // Layer to span 4 raster tiles in x and in y 414 // Layer to span 4 raster tiles in x and in y
416 LayerTreeSettings settings; 415 LayerTreeSettings settings;
417 gfx::Size layer_size(settings.default_tile_size.width() * 7 / 2, 416 gfx::Size layer_size(settings.default_tile_size.width() * 7 / 2,
418 settings.default_tile_size.height() * 7 / 2); 417 settings.default_tile_size.height() * 7 / 2);
419 418
420 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 419 scoped_refptr<FakeRasterSource> pending_raster_source =
421 FakeDisplayListRasterSource::CreateFilled(layer_size); 420 FakeRasterSource::CreateFilled(layer_size);
422 421
423 // Create an active recording source, but make sure it's not solid. 422 // Create an active recording source, but make sure it's not solid.
424 scoped_ptr<FakeDisplayListRecordingSource> active_recording_source = 423 scoped_ptr<FakeDisplayListRecordingSource> active_recording_source =
425 FakeDisplayListRecordingSource::CreateFilledRecordingSource(layer_size); 424 FakeDisplayListRecordingSource::CreateFilledRecordingSource(layer_size);
426 active_recording_source->SetLayerBounds(layer_size); 425 active_recording_source->SetLayerBounds(layer_size);
427 active_recording_source->add_draw_rect(gfx::Rect(layer_size)); 426 active_recording_source->add_draw_rect(gfx::Rect(layer_size));
428 active_recording_source->add_draw_rect( 427 active_recording_source->add_draw_rect(
429 gfx::Rect(0, 0, layer_size.width() - 1, layer_size.height() - 1)); 428 gfx::Rect(0, 0, layer_size.width() - 1, layer_size.height() - 1));
430 active_recording_source->Rerecord(); 429 active_recording_source->Rerecord();
431 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 430 scoped_refptr<FakeRasterSource> active_raster_source =
432 FakeDisplayListRasterSource::CreateFromRecordingSource( 431 FakeRasterSource::CreateFromRecordingSource(active_recording_source.get(),
433 active_recording_source.get(), false); 432 false);
434 433
435 SetupTrees(pending_raster_source, active_raster_source); 434 SetupTrees(pending_raster_source, active_raster_source);
436 435
437 // Add 1x1 rects at the centers of each tile, then re-record recording source 436 // Add 1x1 rects at the centers of each tile, then re-record recording source
438 // contents. 437 // contents.
439 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 438 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
440 std::vector<Tile*> tiles = 439 std::vector<Tile*> tiles =
441 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); 440 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
442 EXPECT_EQ(16u, tiles.size()); 441 EXPECT_EQ(16u, tiles.size());
443 std::vector<SkRect> rects; 442 std::vector<SkRect> rects;
444 std::vector<Tile*>::const_iterator tile_iter; 443 std::vector<Tile*>::const_iterator tile_iter;
445 active_recording_source->reset_draws(); 444 active_recording_source->reset_draws();
446 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { 445 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) {
447 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); 446 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint();
448 gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1); 447 gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1);
449 active_recording_source->add_draw_rect(rect); 448 active_recording_source->add_draw_rect(rect);
450 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); 449 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1));
451 } 450 }
452 451
453 // Force re-raster with newly injected content 452 // Force re-raster with newly injected content
454 active_recording_source->Rerecord(); 453 active_recording_source->Rerecord();
455 454
456 scoped_refptr<FakeDisplayListRasterSource> updated_active_raster_source = 455 scoped_refptr<FakeRasterSource> updated_active_raster_source =
457 FakeDisplayListRasterSource::CreateFromRecordingSource( 456 FakeRasterSource::CreateFromRecordingSource(active_recording_source.get(),
458 active_recording_source.get(), false); 457 false);
459 458
460 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); 459 std::vector<SkRect>::const_iterator rect_iter = rects.begin();
461 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { 460 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) {
462 MockCanvas mock_canvas(1000, 1000); 461 MockCanvas mock_canvas(1000, 1000);
463 const bool include_images = true; 462 const bool include_images = true;
464 updated_active_raster_source->PlaybackToSharedCanvas( 463 updated_active_raster_source->PlaybackToSharedCanvas(
465 &mock_canvas, (*tile_iter)->content_rect(), 1.0f, include_images); 464 &mock_canvas, (*tile_iter)->content_rect(), 1.0f, include_images);
466 465
467 // This test verifies that when drawing the contents of a specific tile 466 // This test verifies that when drawing the contents of a specific tile
468 // at content scale 1.0, the playback canvas never receives content from 467 // at content scale 1.0, the playback canvas never receives content from
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 // Now the UpdateDrawProperties is called. The viewport rect for tile 594 // Now the UpdateDrawProperties is called. The viewport rect for tile
596 // priority should be the latest value. 595 // priority should be the latest value.
597 EXPECT_EQ(another_viewport_rect_for_tile_priority, 596 EXPECT_EQ(another_viewport_rect_for_tile_priority,
598 active_layer_->viewport_rect_for_tile_priority_in_content_space()); 597 active_layer_->viewport_rect_for_tile_priority_in_content_space());
599 } 598 }
600 599
601 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { 600 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) {
602 gfx::Size layer_bounds(400, 400); 601 gfx::Size layer_bounds(400, 400);
603 gfx::Rect layer_invalidation(150, 200, 30, 180); 602 gfx::Rect layer_invalidation(150, 200, 30, 180);
604 603
605 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 604 scoped_refptr<FakeRasterSource> pending_raster_source =
606 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 605 FakeRasterSource::CreateFilled(layer_bounds);
607 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 606 scoped_refptr<FakeRasterSource> active_raster_source =
608 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 607 FakeRasterSource::CreateFilled(layer_bounds);
609 scoped_refptr<FakeDisplayListRasterSource> lost_raster_source = 608 scoped_refptr<FakeRasterSource> lost_raster_source =
610 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 609 FakeRasterSource::CreateFilled(layer_bounds);
611 610
612 SetupPendingTreeWithFixedTileSize(lost_raster_source, gfx::Size(50, 50), 611 SetupPendingTreeWithFixedTileSize(lost_raster_source, gfx::Size(50, 50),
613 Region()); 612 Region());
614 ActivateTree(); 613 ActivateTree();
615 // Add a unique tiling on the active tree. 614 // Add a unique tiling on the active tree.
616 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f); 615 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f);
617 tiling->set_resolution(HIGH_RESOLUTION); 616 tiling->set_resolution(HIGH_RESOLUTION);
618 tiling->CreateAllTilesForTesting(); 617 tiling->CreateAllTilesForTesting();
619 618
620 // Ensure UpdateTiles won't remove any tilings. 619 // Ensure UpdateTiles won't remove any tilings.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 // Raster source will be updated upon activation. 674 // Raster source will be updated upon activation.
676 EXPECT_EQ(active_raster_source.get(), 675 EXPECT_EQ(active_raster_source.get(),
677 prioritized_tiles[*iter].raster_source()); 676 prioritized_tiles[*iter].raster_source());
678 } 677 }
679 } 678 }
680 } 679 }
681 680
682 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { 681 TEST_F(PictureLayerImplTest, CloneFullInvalidation) {
683 gfx::Size layer_bounds(300, 500); 682 gfx::Size layer_bounds(300, 500);
684 683
685 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 684 scoped_refptr<FakeRasterSource> pending_raster_source =
686 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 685 FakeRasterSource::CreateFilled(layer_bounds);
687 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 686 scoped_refptr<FakeRasterSource> active_raster_source =
688 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 687 FakeRasterSource::CreateFilled(layer_bounds);
689 688
690 SetupTreesWithInvalidation(pending_raster_source, active_raster_source, 689 SetupTreesWithInvalidation(pending_raster_source, active_raster_source,
691 gfx::Rect(layer_bounds)); 690 gfx::Rect(layer_bounds));
692 691
693 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), 692 EXPECT_EQ(pending_layer_->tilings()->num_tilings(),
694 active_layer_->tilings()->num_tilings()); 693 active_layer_->tilings()->num_tilings());
695 694
696 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); 695 const PictureLayerTilingSet* tilings = pending_layer_->tilings();
697 EXPECT_GT(tilings->num_tilings(), 0u); 696 EXPECT_GT(tilings->num_tilings(), 0u);
698 for (size_t i = 0; i < tilings->num_tilings(); ++i) { 697 for (size_t i = 0; i < tilings->num_tilings(); ++i) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 EXPECT_FLOAT_EQ(7.26f, 829 EXPECT_FLOAT_EQ(7.26f,
831 pending_layer_->tilings()->tiling_at(0)->contents_scale()); 830 pending_layer_->tilings()->tiling_at(0)->contents_scale());
832 } 831 }
833 832
834 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { 833 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) {
835 // This test makes sure that if a layer can have tilings, then a commit makes 834 // This test makes sure that if a layer can have tilings, then a commit makes
836 // it not able to have tilings (empty size), and then a future commit that 835 // it not able to have tilings (empty size), and then a future commit that
837 // makes it valid again should be able to create tilings. 836 // makes it valid again should be able to create tilings.
838 gfx::Size layer_bounds(1300, 1900); 837 gfx::Size layer_bounds(1300, 1900);
839 838
840 scoped_refptr<FakeDisplayListRasterSource> empty_raster_source = 839 scoped_refptr<FakeRasterSource> empty_raster_source =
841 FakeDisplayListRasterSource::CreateEmpty(layer_bounds); 840 FakeRasterSource::CreateEmpty(layer_bounds);
842 scoped_refptr<FakeDisplayListRasterSource> valid_raster_source = 841 scoped_refptr<FakeRasterSource> valid_raster_source =
843 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 842 FakeRasterSource::CreateFilled(layer_bounds);
844 843
845 SetupPendingTree(valid_raster_source); 844 SetupPendingTree(valid_raster_source);
846 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); 845 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
847 846
848 ActivateTree(); 847 ActivateTree();
849 SetupPendingTree(empty_raster_source); 848 SetupPendingTree(empty_raster_source);
850 EXPECT_FALSE(pending_layer_->CanHaveTilings()); 849 EXPECT_FALSE(pending_layer_->CanHaveTilings());
851 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); 850 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
852 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); 851 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings());
853 852
854 ActivateTree(); 853 ActivateTree();
855 EXPECT_FALSE(active_layer_->CanHaveTilings()); 854 EXPECT_FALSE(active_layer_->CanHaveTilings());
856 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); 855 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
857 856
858 SetupPendingTree(valid_raster_source); 857 SetupPendingTree(valid_raster_source);
859 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); 858 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
860 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); 859 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
861 } 860 }
862 861
863 TEST_F(PictureLayerImplTest, LowResTilingStaysOnActiveTree) { 862 TEST_F(PictureLayerImplTest, LowResTilingStaysOnActiveTree) {
864 gfx::Size layer_bounds(1300, 1900); 863 gfx::Size layer_bounds(1300, 1900);
865 864
866 scoped_refptr<FakeDisplayListRasterSource> valid_raster_source = 865 scoped_refptr<FakeRasterSource> valid_raster_source =
867 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 866 FakeRasterSource::CreateFilled(layer_bounds);
868 scoped_refptr<FakeDisplayListRasterSource> other_valid_raster_source = 867 scoped_refptr<FakeRasterSource> other_valid_raster_source =
869 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 868 FakeRasterSource::CreateFilled(layer_bounds);
870 869
871 SetupPendingTree(valid_raster_source); 870 SetupPendingTree(valid_raster_source);
872 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); 871 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
873 872
874 ActivateTree(); 873 ActivateTree();
875 SetupPendingTree(other_valid_raster_source); 874 SetupPendingTree(other_valid_raster_source);
876 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); 875 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
877 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); 876 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
878 auto* low_res_tiling = 877 auto* low_res_tiling =
879 active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION); 878 active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION);
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); 1236 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f);
1238 EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(), 1237 EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(),
1239 2.f * low_res_factor); 1238 2.f * low_res_factor);
1240 EXPECT_EQ(4u, active_layer_->num_tilings()); 1239 EXPECT_EQ(4u, active_layer_->num_tilings());
1241 EXPECT_EQ(1u, pending_layer_->num_tilings()); 1240 EXPECT_EQ(1u, pending_layer_->num_tilings());
1242 } 1241 }
1243 1242
1244 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { 1243 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) {
1245 gfx::Size layer_bounds(host_impl_.settings().default_tile_size); 1244 gfx::Size layer_bounds(host_impl_.settings().default_tile_size);
1246 1245
1247 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1246 scoped_refptr<FakeRasterSource> pending_raster_source =
1248 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1247 FakeRasterSource::CreateFilled(layer_bounds);
1249 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 1248 scoped_refptr<FakeRasterSource> active_raster_source =
1250 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1249 FakeRasterSource::CreateFilled(layer_bounds);
1251 1250
1252 SetupTrees(pending_raster_source, active_raster_source); 1251 SetupTrees(pending_raster_source, active_raster_source);
1253 1252
1254 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 1253 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
1255 float device_scale = 1.f; 1254 float device_scale = 1.f;
1256 float page_scale = 1.f; 1255 float page_scale = 1.f;
1257 float maximum_animation_scale = 1.f; 1256 float maximum_animation_scale = 1.f;
1258 float starting_animation_scale = 0.f; 1257 float starting_animation_scale = 0.f;
1259 bool animating_transform = false; 1258 bool animating_transform = false;
1260 1259
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 maximum_animation_scale, starting_animation_scale, animating_transform); 1308 maximum_animation_scale, starting_animation_scale, animating_transform);
1310 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale); 1309 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale);
1311 EXPECT_EQ(mask_raw->num_tilings(), 1u); 1310 EXPECT_EQ(mask_raw->num_tilings(), 1u);
1312 } 1311 }
1313 1312
1314 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { 1313 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) {
1315 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1314 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1316 1315
1317 gfx::Size layer_bounds(1000, 1000); 1316 gfx::Size layer_bounds(1000, 1000);
1318 1317
1319 scoped_refptr<FakeDisplayListRasterSource> valid_raster_source = 1318 scoped_refptr<FakeRasterSource> valid_raster_source =
1320 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1319 FakeRasterSource::CreateFilled(layer_bounds);
1321 SetupPendingTree(valid_raster_source); 1320 SetupPendingTree(valid_raster_source);
1322 1321
1323 scoped_ptr<FakePictureLayerImpl> mask_ptr = 1322 scoped_ptr<FakePictureLayerImpl> mask_ptr =
1324 FakePictureLayerImpl::CreateMaskWithRasterSource( 1323 FakePictureLayerImpl::CreateMaskWithRasterSource(
1325 host_impl_.pending_tree(), 3, valid_raster_source); 1324 host_impl_.pending_tree(), 3, valid_raster_source);
1326 mask_ptr->SetBounds(layer_bounds); 1325 mask_ptr->SetBounds(layer_bounds);
1327 mask_ptr->SetDrawsContent(true); 1326 mask_ptr->SetDrawsContent(true);
1328 pending_layer_->SetMaskLayer(std::move(mask_ptr)); 1327 pending_layer_->SetMaskLayer(std::move(mask_ptr));
1329 pending_layer_->SetForceRenderSurface(true); 1328 pending_layer_->SetForceRenderSurface(true);
1330 1329
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f, 1363 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f,
1365 false); 1364 false);
1366 active_mask->HighResTiling()->CreateAllTilesForTesting(); 1365 active_mask->HighResTiling()->CreateAllTilesForTesting();
1367 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); 1366 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size());
1368 EXPECT_NE(0u, mask_resource_id); 1367 EXPECT_NE(0u, mask_resource_id);
1369 EXPECT_EQ(active_mask->bounds(), mask_texture_size); 1368 EXPECT_EQ(active_mask->bounds(), mask_texture_size);
1370 1369
1371 // Resize larger than the max texture size. 1370 // Resize larger than the max texture size.
1372 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; 1371 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size;
1373 gfx::Size huge_bounds(max_texture_size + 1, 10); 1372 gfx::Size huge_bounds(max_texture_size + 1, 10);
1374 scoped_refptr<FakeDisplayListRasterSource> huge_raster_source = 1373 scoped_refptr<FakeRasterSource> huge_raster_source =
1375 FakeDisplayListRasterSource::CreateFilled(huge_bounds); 1374 FakeRasterSource::CreateFilled(huge_bounds);
1376 1375
1377 SetupPendingTree(huge_raster_source); 1376 SetupPendingTree(huge_raster_source);
1378 pending_mask->SetBounds(huge_bounds); 1377 pending_mask->SetBounds(huge_bounds);
1379 pending_mask->SetRasterSourceOnPending(huge_raster_source, Region()); 1378 pending_mask->SetRasterSourceOnPending(huge_raster_source, Region());
1380 1379
1381 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1380 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1382 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); 1381 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
1383 1382
1384 // The mask tiling gets scaled down. 1383 // The mask tiling gets scaled down.
1385 EXPECT_LT(pending_mask->HighResTiling()->contents_scale(), 1.f); 1384 EXPECT_LT(pending_mask->HighResTiling()->contents_scale(), 1.f);
(...skipping 30 matching lines...) Expand all
1416 ActivateTree(); 1415 ActivateTree();
1417 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); 1416 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size());
1418 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); 1417 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size);
1419 EXPECT_EQ(expected_size, mask_texture_size); 1418 EXPECT_EQ(expected_size, mask_texture_size);
1420 EXPECT_EQ(0u, mask_resource_id); 1419 EXPECT_EQ(0u, mask_resource_id);
1421 1420
1422 // Resize even larger, so that the scale would be smaller than the minimum 1421 // Resize even larger, so that the scale would be smaller than the minimum
1423 // contents scale. Then the layer should no longer have any tiling. 1422 // contents scale. Then the layer should no longer have any tiling.
1424 float min_contents_scale = host_impl_.settings().minimum_contents_scale; 1423 float min_contents_scale = host_impl_.settings().minimum_contents_scale;
1425 gfx::Size extra_huge_bounds(max_texture_size / min_contents_scale + 1, 10); 1424 gfx::Size extra_huge_bounds(max_texture_size / min_contents_scale + 1, 10);
1426 scoped_refptr<FakeDisplayListRasterSource> extra_huge_raster_source = 1425 scoped_refptr<FakeRasterSource> extra_huge_raster_source =
1427 FakeDisplayListRasterSource::CreateFilled(extra_huge_bounds); 1426 FakeRasterSource::CreateFilled(extra_huge_bounds);
1428 1427
1429 SetupPendingTree(extra_huge_raster_source); 1428 SetupPendingTree(extra_huge_raster_source);
1430 pending_mask->SetBounds(extra_huge_bounds); 1429 pending_mask->SetBounds(extra_huge_bounds);
1431 pending_mask->SetRasterSourceOnPending(extra_huge_raster_source, Region()); 1430 pending_mask->SetRasterSourceOnPending(extra_huge_raster_source, Region());
1432 1431
1433 EXPECT_FALSE(pending_mask->CanHaveTilings()); 1432 EXPECT_FALSE(pending_mask->CanHaveTilings());
1434 1433
1435 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1434 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1436 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); 1435 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
1437 1436
1438 EXPECT_EQ(0u, pending_mask->num_tilings()); 1437 EXPECT_EQ(0u, pending_mask->num_tilings());
1439 } 1438 }
1440 1439
1441 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { 1440 TEST_F(PictureLayerImplTest, ScaledMaskLayer) {
1442 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1441 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1443 1442
1444 gfx::Size layer_bounds(1000, 1000); 1443 gfx::Size layer_bounds(1000, 1000);
1445 1444
1446 SetInitialDeviceScaleFactor(1.3f); 1445 SetInitialDeviceScaleFactor(1.3f);
1447 1446
1448 scoped_refptr<FakeDisplayListRasterSource> valid_raster_source = 1447 scoped_refptr<FakeRasterSource> valid_raster_source =
1449 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1448 FakeRasterSource::CreateFilled(layer_bounds);
1450 SetupPendingTree(valid_raster_source); 1449 SetupPendingTree(valid_raster_source);
1451 1450
1452 scoped_ptr<FakePictureLayerImpl> mask_ptr = 1451 scoped_ptr<FakePictureLayerImpl> mask_ptr =
1453 FakePictureLayerImpl::CreateMaskWithRasterSource( 1452 FakePictureLayerImpl::CreateMaskWithRasterSource(
1454 host_impl_.pending_tree(), 3, valid_raster_source); 1453 host_impl_.pending_tree(), 3, valid_raster_source);
1455 mask_ptr->SetBounds(layer_bounds); 1454 mask_ptr->SetBounds(layer_bounds);
1456 mask_ptr->SetDrawsContent(true); 1455 mask_ptr->SetDrawsContent(true);
1457 pending_layer_->SetMaskLayer(std::move(mask_ptr)); 1456 pending_layer_->SetMaskLayer(std::move(mask_ptr));
1458 pending_layer_->SetForceRenderSurface(true); 1457 pending_layer_->SetForceRenderSurface(true);
1459 1458
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 1.f, // page scale 1510 1.f, // page scale
1512 1.f, // maximum animation scale 1511 1.f, // maximum animation scale
1513 0.f, // starting animation_scale 1512 0.f, // starting animation_scale
1514 false); 1513 false);
1515 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 1514 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
1516 } 1515 }
1517 1516
1518 TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) { 1517 TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) {
1519 gfx::Size layer_bounds(5000, 5000); 1518 gfx::Size layer_bounds(5000, 5000);
1520 1519
1521 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1520 scoped_refptr<FakeRasterSource> pending_raster_source =
1522 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1521 FakeRasterSource::CreateFilled(layer_bounds);
1523 1522
1524 SetupPendingTree(pending_raster_source); 1523 SetupPendingTree(pending_raster_source);
1525 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); 1524 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u);
1526 1525
1527 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1526 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1528 1527
1529 // The default value. 1528 // The default value.
1530 EXPECT_EQ(gfx::Size(256, 256).ToString(), 1529 EXPECT_EQ(gfx::Size(256, 256).ToString(),
1531 host_impl_.settings().default_tile_size.ToString()); 1530 host_impl_.settings().default_tile_size.ToString());
1532 1531
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 1630
1632 TEST_F(PictureLayerImplTest, ResourcelessPartialRecording) { 1631 TEST_F(PictureLayerImplTest, ResourcelessPartialRecording) {
1633 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1632 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1634 1633
1635 gfx::Size tile_size(400, 400); 1634 gfx::Size tile_size(400, 400);
1636 gfx::Size layer_bounds(700, 650); 1635 gfx::Size layer_bounds(700, 650);
1637 gfx::Rect layer_rect(layer_bounds); 1636 gfx::Rect layer_rect(layer_bounds);
1638 SetInitialDeviceScaleFactor(2.f); 1637 SetInitialDeviceScaleFactor(2.f);
1639 1638
1640 gfx::Rect recorded_viewport(20, 30, 40, 50); 1639 gfx::Rect recorded_viewport(20, 30, 40, 50);
1641 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 1640 scoped_refptr<FakeRasterSource> active_raster_source =
1642 FakeDisplayListRasterSource::CreatePartiallyFilled(layer_bounds, 1641 FakeRasterSource::CreatePartiallyFilled(layer_bounds, recorded_viewport);
1643 recorded_viewport);
1644 1642
1645 SetupPendingTree(active_raster_source); 1643 SetupPendingTree(active_raster_source);
1646 ActivateTree(); 1644 ActivateTree();
1647 1645
1648 active_layer_->SetContentsOpaque(true); 1646 active_layer_->SetContentsOpaque(true);
1649 gfx::Rect visible_rect(30, 35, 10, 5); 1647 gfx::Rect visible_rect(30, 35, 10, 5);
1650 active_layer_->draw_properties().visible_layer_rect = visible_rect; 1648 active_layer_->draw_properties().visible_layer_rect = visible_rect;
1651 1649
1652 AppendQuadsData data; 1650 AppendQuadsData data;
1653 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); 1651 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr);
(...skipping 10 matching lines...) Expand all
1664 const DrawQuad* quad = render_pass->quad_list.front(); 1662 const DrawQuad* quad = render_pass->quad_list.front();
1665 EXPECT_EQ(quad_visible, quad->rect); 1663 EXPECT_EQ(quad_visible, quad->rect);
1666 EXPECT_EQ(quad_visible, quad->opaque_rect); 1664 EXPECT_EQ(quad_visible, quad->opaque_rect);
1667 EXPECT_EQ(quad_visible, quad->visible_rect); 1665 EXPECT_EQ(quad_visible, quad->visible_rect);
1668 } 1666 }
1669 1667
1670 TEST_F(PictureLayerImplTest, ResourcelessEmptyRecording) { 1668 TEST_F(PictureLayerImplTest, ResourcelessEmptyRecording) {
1671 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1669 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1672 1670
1673 gfx::Size layer_bounds(700, 650); 1671 gfx::Size layer_bounds(700, 650);
1674 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 1672 scoped_refptr<FakeRasterSource> active_raster_source =
1675 FakeDisplayListRasterSource::CreatePartiallyFilled(layer_bounds, 1673 FakeRasterSource::CreatePartiallyFilled(layer_bounds, gfx::Rect());
1676 gfx::Rect());
1677 SetupPendingTree(active_raster_source); 1674 SetupPendingTree(active_raster_source);
1678 ActivateTree(); 1675 ActivateTree();
1679 1676
1680 active_layer_->SetContentsOpaque(true); 1677 active_layer_->SetContentsOpaque(true);
1681 active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds); 1678 active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds);
1682 1679
1683 AppendQuadsData data; 1680 AppendQuadsData data;
1684 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); 1681 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr);
1685 active_layer_->AppendQuads(render_pass.get(), &data); 1682 active_layer_->AppendQuads(render_pass.get(), &data);
1686 active_layer_->DidDraw(nullptr); 1683 active_layer_->DidDraw(nullptr);
1687 1684
1688 EXPECT_EQ(0U, render_pass->quad_list.size()); 1685 EXPECT_EQ(0U, render_pass->quad_list.size());
1689 } 1686 }
1690 1687
1691 TEST_F(PictureLayerImplTest, SolidColorLayerHasVisibleFullCoverage) { 1688 TEST_F(PictureLayerImplTest, SolidColorLayerHasVisibleFullCoverage) {
1692 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1689 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1693 1690
1694 gfx::Size layer_bounds(1500, 1500); 1691 gfx::Size layer_bounds(1500, 1500);
1695 gfx::Rect visible_rect(250, 250, 1000, 1000); 1692 gfx::Rect visible_rect(250, 250, 1000, 1000);
1696 1693
1697 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1694 scoped_refptr<FakeRasterSource> pending_raster_source =
1698 FakeDisplayListRasterSource::CreateFilledSolidColor(layer_bounds); 1695 FakeRasterSource::CreateFilledSolidColor(layer_bounds);
1699 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 1696 scoped_refptr<FakeRasterSource> active_raster_source =
1700 FakeDisplayListRasterSource::CreateFilledSolidColor(layer_bounds); 1697 FakeRasterSource::CreateFilledSolidColor(layer_bounds);
1701 1698
1702 SetupTrees(pending_raster_source, active_raster_source); 1699 SetupTrees(pending_raster_source, active_raster_source);
1703 1700
1704 active_layer_->draw_properties().visible_layer_rect = visible_rect; 1701 active_layer_->draw_properties().visible_layer_rect = visible_rect;
1705 1702
1706 AppendQuadsData data; 1703 AppendQuadsData data;
1707 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); 1704 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1708 active_layer_->AppendQuads(render_pass.get(), &data); 1705 active_layer_->AppendQuads(render_pass.get(), &data);
1709 active_layer_->DidDraw(nullptr); 1706 active_layer_->DidDraw(nullptr);
1710 1707
1711 Region remaining = visible_rect; 1708 Region remaining = visible_rect;
1712 for (const auto& quad : render_pass->quad_list) { 1709 for (const auto& quad : render_pass->quad_list) {
1713 EXPECT_TRUE(visible_rect.Contains(quad->rect)); 1710 EXPECT_TRUE(visible_rect.Contains(quad->rect));
1714 EXPECT_TRUE(remaining.Contains(quad->rect)); 1711 EXPECT_TRUE(remaining.Contains(quad->rect));
1715 remaining.Subtract(quad->rect); 1712 remaining.Subtract(quad->rect);
1716 } 1713 }
1717 1714
1718 EXPECT_TRUE(remaining.IsEmpty()); 1715 EXPECT_TRUE(remaining.IsEmpty());
1719 } 1716 }
1720 1717
1721 TEST_F(PictureLayerImplTest, TileScalesWithSolidColorRasterSource) { 1718 TEST_F(PictureLayerImplTest, TileScalesWithSolidColorRasterSource) {
1722 gfx::Size layer_bounds(200, 200); 1719 gfx::Size layer_bounds(200, 200);
1723 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1720 scoped_refptr<FakeRasterSource> pending_raster_source =
1724 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1721 FakeRasterSource::CreateFilled(layer_bounds);
1725 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 1722 scoped_refptr<FakeRasterSource> active_raster_source =
1726 FakeDisplayListRasterSource::CreateFilledSolidColor(layer_bounds); 1723 FakeRasterSource::CreateFilledSolidColor(layer_bounds);
1727 1724
1728 SetupTrees(pending_raster_source, active_raster_source); 1725 SetupTrees(pending_raster_source, active_raster_source);
1729 // Solid color raster source should not allow tilings at any scale. 1726 // Solid color raster source should not allow tilings at any scale.
1730 EXPECT_FALSE(active_layer_->CanHaveTilings()); 1727 EXPECT_FALSE(active_layer_->CanHaveTilings());
1731 EXPECT_EQ(0.f, active_layer_->ideal_contents_scale()); 1728 EXPECT_EQ(0.f, active_layer_->ideal_contents_scale());
1732 1729
1733 // Activate non-solid-color pending raster source makes active layer can have 1730 // Activate non-solid-color pending raster source makes active layer can have
1734 // tilings. 1731 // tilings.
1735 ActivateTree(); 1732 ActivateTree();
1736 EXPECT_TRUE(active_layer_->CanHaveTilings()); 1733 EXPECT_TRUE(active_layer_->CanHaveTilings());
1737 EXPECT_GT(active_layer_->ideal_contents_scale(), 0.f); 1734 EXPECT_GT(active_layer_->ideal_contents_scale(), 0.f);
1738 } 1735 }
1739 1736
1740 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredOffscreenTiles) { 1737 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredOffscreenTiles) {
1741 gfx::Size layer_bounds(200, 200); 1738 gfx::Size layer_bounds(200, 200);
1742 1739
1743 gfx::Transform transform; 1740 gfx::Transform transform;
1744 gfx::Rect viewport(0, 0, 100, 200); 1741 gfx::Rect viewport(0, 0, 100, 200);
1745 host_impl_.SetExternalTilePriorityConstraints(viewport, transform); 1742 host_impl_.SetExternalTilePriorityConstraints(viewport, transform);
1746 1743
1747 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1744 scoped_refptr<FakeRasterSource> pending_raster_source =
1748 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1745 FakeRasterSource::CreateFilled(layer_bounds);
1749 SetupPendingTreeWithFixedTileSize(pending_raster_source, gfx::Size(100, 100), 1746 SetupPendingTreeWithFixedTileSize(pending_raster_source, gfx::Size(100, 100),
1750 Region()); 1747 Region());
1751 1748
1752 EXPECT_EQ(1u, pending_layer_->num_tilings()); 1749 EXPECT_EQ(1u, pending_layer_->num_tilings());
1753 EXPECT_EQ(viewport, 1750 EXPECT_EQ(viewport,
1754 pending_layer_->viewport_rect_for_tile_priority_in_content_space()); 1751 pending_layer_->viewport_rect_for_tile_priority_in_content_space());
1755 1752
1756 base::TimeTicks time_ticks; 1753 base::TimeTicks time_ticks;
1757 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1754 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1758 pending_layer_->UpdateTiles(); 1755 pending_layer_->UpdateTiles();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 EXPECT_EQ(0u, data.num_incomplete_tiles); 1851 EXPECT_EQ(0u, data.num_incomplete_tiles);
1855 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); 1852 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads());
1856 } 1853 }
1857 1854
1858 TEST_F(PictureLayerImplTest, HighResTileIsComplete) { 1855 TEST_F(PictureLayerImplTest, HighResTileIsComplete) {
1859 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1856 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1860 1857
1861 gfx::Size tile_size(100, 100); 1858 gfx::Size tile_size(100, 100);
1862 gfx::Size layer_bounds(200, 200); 1859 gfx::Size layer_bounds(200, 200);
1863 1860
1864 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1861 scoped_refptr<FakeRasterSource> pending_raster_source =
1865 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1862 FakeRasterSource::CreateFilled(layer_bounds);
1866 1863
1867 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 1864 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
1868 ActivateTree(); 1865 ActivateTree();
1869 1866
1870 // All high res tiles have resources. 1867 // All high res tiles have resources.
1871 std::vector<Tile*> tiles = 1868 std::vector<Tile*> tiles =
1872 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); 1869 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
1873 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 1870 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
1874 1871
1875 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1872 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1876 AppendQuadsData data; 1873 AppendQuadsData data;
1877 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); 1874 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1878 active_layer_->AppendQuads(render_pass.get(), &data); 1875 active_layer_->AppendQuads(render_pass.get(), &data);
1879 active_layer_->DidDraw(nullptr); 1876 active_layer_->DidDraw(nullptr);
1880 1877
1881 // All high res tiles drew, nothing was incomplete. 1878 // All high res tiles drew, nothing was incomplete.
1882 EXPECT_EQ(9u, render_pass->quad_list.size()); 1879 EXPECT_EQ(9u, render_pass->quad_list.size());
1883 EXPECT_EQ(0u, data.num_missing_tiles); 1880 EXPECT_EQ(0u, data.num_missing_tiles);
1884 EXPECT_EQ(0u, data.num_incomplete_tiles); 1881 EXPECT_EQ(0u, data.num_incomplete_tiles);
1885 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); 1882 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads());
1886 } 1883 }
1887 1884
1888 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) { 1885 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) {
1889 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1886 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1890 1887
1891 gfx::Size tile_size(100, 100); 1888 gfx::Size tile_size(100, 100);
1892 gfx::Size layer_bounds(200, 200); 1889 gfx::Size layer_bounds(200, 200);
1893 1890
1894 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1891 scoped_refptr<FakeRasterSource> pending_raster_source =
1895 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1892 FakeRasterSource::CreateFilled(layer_bounds);
1896 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 1893 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
1897 ActivateTree(); 1894 ActivateTree();
1898 1895
1899 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1896 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1900 AppendQuadsData data; 1897 AppendQuadsData data;
1901 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); 1898 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1902 active_layer_->AppendQuads(render_pass.get(), &data); 1899 active_layer_->AppendQuads(render_pass.get(), &data);
1903 active_layer_->DidDraw(nullptr); 1900 active_layer_->DidDraw(nullptr);
1904 1901
1905 EXPECT_EQ(1u, render_pass->quad_list.size()); 1902 EXPECT_EQ(1u, render_pass->quad_list.size());
1906 EXPECT_EQ(1u, data.num_missing_tiles); 1903 EXPECT_EQ(1u, data.num_missing_tiles);
1907 EXPECT_EQ(0u, data.num_incomplete_tiles); 1904 EXPECT_EQ(0u, data.num_incomplete_tiles);
1908 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); 1905 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads());
1909 } 1906 }
1910 1907
1911 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) { 1908 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) {
1912 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1909 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1913 1910
1914 gfx::Size tile_size(100, 100); 1911 gfx::Size tile_size(100, 100);
1915 gfx::Size layer_bounds(200, 200); 1912 gfx::Size layer_bounds(200, 200);
1916 1913
1917 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1914 scoped_refptr<FakeRasterSource> pending_raster_source =
1918 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1915 FakeRasterSource::CreateFilled(layer_bounds);
1919 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 1916 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
1920 ActivateTree(); 1917 ActivateTree();
1921 1918
1922 std::vector<Tile*> low_tiles = 1919 std::vector<Tile*> low_tiles =
1923 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); 1920 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting();
1924 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); 1921 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles);
1925 1922
1926 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1923 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1927 AppendQuadsData data; 1924 AppendQuadsData data;
1928 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); 1925 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1929 active_layer_->AppendQuads(render_pass.get(), &data); 1926 active_layer_->AppendQuads(render_pass.get(), &data);
1930 active_layer_->DidDraw(nullptr); 1927 active_layer_->DidDraw(nullptr);
1931 1928
1932 EXPECT_EQ(1u, render_pass->quad_list.size()); 1929 EXPECT_EQ(1u, render_pass->quad_list.size());
1933 EXPECT_EQ(0u, data.num_missing_tiles); 1930 EXPECT_EQ(0u, data.num_missing_tiles);
1934 EXPECT_EQ(1u, data.num_incomplete_tiles); 1931 EXPECT_EQ(1u, data.num_incomplete_tiles);
1935 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); 1932 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads());
1936 } 1933 }
1937 1934
1938 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) { 1935 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) {
1939 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1936 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1940 1937
1941 gfx::Size tile_size(100, 100); 1938 gfx::Size tile_size(100, 100);
1942 gfx::Size layer_bounds(200, 200); 1939 gfx::Size layer_bounds(200, 200);
1943 1940
1944 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1941 scoped_refptr<FakeRasterSource> pending_raster_source =
1945 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1942 FakeRasterSource::CreateFilled(layer_bounds);
1946 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 1943 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
1947 ActivateTree(); 1944 ActivateTree();
1948 1945
1949 // All high res tiles have resources except one. 1946 // All high res tiles have resources except one.
1950 std::vector<Tile*> high_tiles = 1947 std::vector<Tile*> high_tiles =
1951 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); 1948 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
1952 high_tiles.erase(high_tiles.begin()); 1949 high_tiles.erase(high_tiles.begin());
1953 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); 1950 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles);
1954 1951
1955 // All low res tiles have resources. 1952 // All low res tiles have resources.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); 2028 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads());
2032 } 2029 }
2033 2030
2034 TEST_F(PictureLayerImplTest, AppendQuadsDataForCheckerboard) { 2031 TEST_F(PictureLayerImplTest, AppendQuadsDataForCheckerboard) {
2035 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 2032 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
2036 2033
2037 gfx::Size tile_size(100, 100); 2034 gfx::Size tile_size(100, 100);
2038 gfx::Size layer_bounds(200, 200); 2035 gfx::Size layer_bounds(200, 200);
2039 gfx::Rect recorded_viewport(0, 0, 150, 150); 2036 gfx::Rect recorded_viewport(0, 0, 150, 150);
2040 2037
2041 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 2038 scoped_refptr<FakeRasterSource> pending_raster_source =
2042 FakeDisplayListRasterSource::CreatePartiallyFilled(layer_bounds, 2039 FakeRasterSource::CreatePartiallyFilled(layer_bounds, recorded_viewport);
2043 recorded_viewport);
2044 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 2040 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
2045 ActivateTree(); 2041 ActivateTree();
2046 2042
2047 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 2043 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
2048 AppendQuadsData data; 2044 AppendQuadsData data;
2049 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); 2045 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
2050 active_layer_->AppendQuads(render_pass.get(), &data); 2046 active_layer_->AppendQuads(render_pass.get(), &data);
2051 active_layer_->DidDraw(nullptr); 2047 active_layer_->DidDraw(nullptr);
2052 2048
2053 EXPECT_EQ(1u, render_pass->quad_list.size()); 2049 EXPECT_EQ(1u, render_pass->quad_list.size());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); 2140 active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
2145 2141
2146 AssertNoTilesRequired(active_layer_->HighResTiling()); 2142 AssertNoTilesRequired(active_layer_->HighResTiling());
2147 AssertNoTilesRequired(active_layer_->LowResTiling()); 2143 AssertNoTilesRequired(active_layer_->LowResTiling());
2148 } 2144 }
2149 2145
2150 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 2146 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
2151 gfx::Size layer_bounds(400, 400); 2147 gfx::Size layer_bounds(400, 400);
2152 gfx::Size tile_size(100, 100); 2148 gfx::Size tile_size(100, 100);
2153 2149
2154 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 2150 scoped_refptr<FakeRasterSource> pending_raster_source =
2155 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 2151 FakeRasterSource::CreateFilled(layer_bounds);
2156 // This raster source will create tilings, but has no recordings so will not 2152 // This raster source will create tilings, but has no recordings so will not
2157 // create any tiles. This is attempting to simulate scrolling past the end of 2153 // create any tiles. This is attempting to simulate scrolling past the end of
2158 // recorded content on the active layer, where the recordings are so far away 2154 // recorded content on the active layer, where the recordings are so far away
2159 // that no tiles are created. 2155 // that no tiles are created.
2160 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 2156 scoped_refptr<FakeRasterSource> active_raster_source =
2161 FakeDisplayListRasterSource::CreatePartiallyFilled(layer_bounds, 2157 FakeRasterSource::CreatePartiallyFilled(layer_bounds, gfx::Rect());
2162 gfx::Rect());
2163 2158
2164 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, 2159 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source,
2165 tile_size, Region()); 2160 tile_size, Region());
2166 2161
2167 // Active layer has tilings, but no tiles due to missing recordings. 2162 // Active layer has tilings, but no tiles due to missing recordings.
2168 EXPECT_TRUE(active_layer_->CanHaveTilings()); 2163 EXPECT_TRUE(active_layer_->CanHaveTilings());
2169 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); 2164 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u);
2170 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 2165 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
2171 2166
2172 // Since the active layer has no tiles at all, the pending layer doesn't 2167 // Since the active layer has no tiles at all, the pending layer doesn't
2173 // need content in order to activate. 2168 // need content in order to activate.
2174 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); 2169 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
2175 EXPECT_FALSE(pending_layer_->LowResTiling()); 2170 EXPECT_FALSE(pending_layer_->LowResTiling());
2176 2171
2177 AssertNoTilesRequired(pending_layer_->HighResTiling()); 2172 AssertNoTilesRequired(pending_layer_->HighResTiling());
2178 } 2173 }
2179 2174
2180 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { 2175 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) {
2181 gfx::Size layer_bounds(400, 400); 2176 gfx::Size layer_bounds(400, 400);
2182 gfx::Size tile_size(100, 100); 2177 gfx::Size tile_size(100, 100);
2183 2178
2184 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 2179 scoped_refptr<FakeRasterSource> pending_raster_source =
2185 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 2180 FakeRasterSource::CreateFilled(layer_bounds);
2186 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 2181 scoped_refptr<FakeRasterSource> active_raster_source =
2187 FakeDisplayListRasterSource::CreateEmpty(layer_bounds); 2182 FakeRasterSource::CreateEmpty(layer_bounds);
2188 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, 2183 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source,
2189 tile_size, Region()); 2184 tile_size, Region());
2190 2185
2191 // Active layer can't have tiles. 2186 // Active layer can't have tiles.
2192 EXPECT_FALSE(active_layer_->CanHaveTilings()); 2187 EXPECT_FALSE(active_layer_->CanHaveTilings());
2193 2188
2194 // All high res tiles required. This should be considered identical 2189 // All high res tiles required. This should be considered identical
2195 // to the case where there is no active layer, to avoid flashing content. 2190 // to the case where there is no active layer, to avoid flashing content.
2196 // This can happen if a layer exists for a while and switches from 2191 // This can happen if a layer exists for a while and switches from
2197 // not being able to have content to having content. 2192 // not being able to have content to having content.
2198 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); 2193 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
2199 EXPECT_FALSE(pending_layer_->LowResTiling()); 2194 EXPECT_FALSE(pending_layer_->LowResTiling());
2200 2195
2201 AssertAllTilesRequired(pending_layer_->HighResTiling()); 2196 AssertAllTilesRequired(pending_layer_->HighResTiling());
2202 } 2197 }
2203 2198
2204 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { 2199 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) {
2205 gfx::Size pending_layer_bounds(400, 400); 2200 gfx::Size pending_layer_bounds(400, 400);
2206 gfx::Size active_layer_bounds(200, 200); 2201 gfx::Size active_layer_bounds(200, 200);
2207 gfx::Size tile_size(100, 100); 2202 gfx::Size tile_size(100, 100);
2208 2203
2209 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 2204 scoped_refptr<FakeRasterSource> pending_raster_source =
2210 FakeDisplayListRasterSource::CreateFilled(pending_layer_bounds); 2205 FakeRasterSource::CreateFilled(pending_layer_bounds);
2211 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 2206 scoped_refptr<FakeRasterSource> active_raster_source =
2212 FakeDisplayListRasterSource::CreateFilled(active_layer_bounds); 2207 FakeRasterSource::CreateFilled(active_layer_bounds);
2213 2208
2214 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, 2209 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source,
2215 tile_size, Region()); 2210 tile_size, Region());
2216 2211
2217 // Since the active layer has different bounds, the pending layer needs all 2212 // Since the active layer has different bounds, the pending layer needs all
2218 // high res tiles in order to activate. 2213 // high res tiles in order to activate.
2219 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); 2214 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
2220 EXPECT_FALSE(pending_layer_->LowResTiling()); 2215 EXPECT_FALSE(pending_layer_->LowResTiling());
2221 active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); 2216 active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
2222 active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); 2217 active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
2223 2218
2224 AssertAllTilesRequired(pending_layer_->HighResTiling()); 2219 AssertAllTilesRequired(pending_layer_->HighResTiling());
2225 AssertAllTilesRequired(active_layer_->HighResTiling()); 2220 AssertAllTilesRequired(active_layer_->HighResTiling());
2226 AssertNoTilesRequired(active_layer_->LowResTiling()); 2221 AssertNoTilesRequired(active_layer_->LowResTiling());
2227 } 2222 }
2228 2223
2229 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { 2224 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) {
2230 gfx::Size layer_bounds(400, 400); 2225 gfx::Size layer_bounds(400, 400);
2231 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 2226 scoped_refptr<FakeRasterSource> pending_raster_source =
2232 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 2227 FakeRasterSource::CreateFilled(layer_bounds);
2233 2228
2234 host_impl_.CreatePendingTree(); 2229 host_impl_.CreatePendingTree();
2235 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 2230 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
2236 2231
2237 scoped_ptr<FakePictureLayerImpl> pending_layer = 2232 scoped_ptr<FakePictureLayerImpl> pending_layer =
2238 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, 2233 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_,
2239 pending_raster_source); 2234 pending_raster_source);
2240 pending_layer->SetDrawsContent(true); 2235 pending_layer->SetDrawsContent(true);
2241 pending_tree->SetRootLayer(std::move(pending_layer)); 2236 pending_tree->SetRootLayer(std::move(pending_layer));
2242 2237
(...skipping 12 matching lines...) Expand all
2255 active_layer_ = static_cast<FakePictureLayerImpl*>( 2250 active_layer_ = static_cast<FakePictureLayerImpl*>(
2256 host_impl_.active_tree()->LayerById(id_)); 2251 host_impl_.active_tree()->LayerById(id_));
2257 2252
2258 EXPECT_EQ(0u, active_layer_->num_tilings()); 2253 EXPECT_EQ(0u, active_layer_->num_tilings());
2259 EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale()); 2254 EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale());
2260 } 2255 }
2261 2256
2262 TEST_F(PictureLayerImplTest, ShareTilesOnNextFrame) { 2257 TEST_F(PictureLayerImplTest, ShareTilesOnNextFrame) {
2263 gfx::Size layer_bounds(1500, 1500); 2258 gfx::Size layer_bounds(1500, 1500);
2264 2259
2265 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 2260 scoped_refptr<FakeRasterSource> pending_raster_source =
2266 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 2261 FakeRasterSource::CreateFilled(layer_bounds);
2267 2262
2268 SetupPendingTree(pending_raster_source); 2263 SetupPendingTree(pending_raster_source);
2269 2264
2270 PictureLayerTiling* tiling = pending_layer_->HighResTiling(); 2265 PictureLayerTiling* tiling = pending_layer_->HighResTiling();
2271 gfx::Rect first_invalidate = tiling->TilingDataForTesting().TileBounds(0, 0); 2266 gfx::Rect first_invalidate = tiling->TilingDataForTesting().TileBounds(0, 0);
2272 first_invalidate.Inset(tiling->TilingDataForTesting().border_texels(), 2267 first_invalidate.Inset(tiling->TilingDataForTesting().border_texels(),
2273 tiling->TilingDataForTesting().border_texels()); 2268 tiling->TilingDataForTesting().border_texels());
2274 gfx::Rect second_invalidate = tiling->TilingDataForTesting().TileBounds(1, 1); 2269 gfx::Rect second_invalidate = tiling->TilingDataForTesting().TileBounds(1, 1);
2275 second_invalidate.Inset(tiling->TilingDataForTesting().border_texels(), 2270 second_invalidate.Inset(tiling->TilingDataForTesting().border_texels(),
2276 tiling->TilingDataForTesting().border_texels()); 2271 tiling->TilingDataForTesting().border_texels());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 2330
2336 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); 2331 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
2337 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); 2332 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2338 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); 2333 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2339 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); 2334 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
2340 } 2335 }
2341 2336
2342 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) { 2337 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) {
2343 gfx::Size layer_bounds(1500, 1500); 2338 gfx::Size layer_bounds(1500, 1500);
2344 2339
2345 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 2340 scoped_refptr<FakeRasterSource> pending_raster_source =
2346 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 2341 FakeRasterSource::CreateFilled(layer_bounds);
2347 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 2342 scoped_refptr<FakeRasterSource> active_raster_source =
2348 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 2343 FakeRasterSource::CreateFilled(layer_bounds);
2349 SetupTreesWithInvalidation(pending_raster_source, active_raster_source, 2344 SetupTreesWithInvalidation(pending_raster_source, active_raster_source,
2350 gfx::Rect(1, 1)); 2345 gfx::Rect(1, 1));
2351 // Activate the invalidation. 2346 // Activate the invalidation.
2352 ActivateTree(); 2347 ActivateTree();
2353 // Make another pending tree without any invalidation in it. 2348 // Make another pending tree without any invalidation in it.
2354 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source2 = 2349 scoped_refptr<FakeRasterSource> pending_raster_source2 =
2355 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 2350 FakeRasterSource::CreateFilled(layer_bounds);
2356 SetupPendingTree(pending_raster_source2); 2351 SetupPendingTree(pending_raster_source2);
2357 2352
2358 EXPECT_GE(active_layer_->num_tilings(), 1u); 2353 EXPECT_GE(active_layer_->num_tilings(), 1u);
2359 EXPECT_GE(pending_layer_->num_tilings(), 1u); 2354 EXPECT_GE(pending_layer_->num_tilings(), 1u);
2360 2355
2361 // The active tree invalidation was handled by the active tiles. 2356 // The active tree invalidation was handled by the active tiles.
2362 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); 2357 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2363 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); 2358 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2364 ASSERT_TRUE(active_tiling); 2359 ASSERT_TRUE(active_tiling);
2365 ASSERT_TRUE(pending_tiling); 2360 ASSERT_TRUE(pending_tiling);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2400 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); 2395 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
2401 2396
2402 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); 2397 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
2403 } 2398 }
2404 2399
2405 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { 2400 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) {
2406 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 2401 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
2407 2402
2408 gfx::Size layer_bounds(10, 10); 2403 gfx::Size layer_bounds(10, 10);
2409 2404
2410 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 2405 scoped_refptr<FakeRasterSource> pending_raster_source =
2411 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 2406 FakeRasterSource::CreateFilled(layer_bounds);
2412 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 2407 scoped_refptr<FakeRasterSource> active_raster_source =
2413 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 2408 FakeRasterSource::CreateFilled(layer_bounds);
2414 2409
2415 SetupTrees(pending_raster_source, active_raster_source); 2410 SetupTrees(pending_raster_source, active_raster_source);
2416 2411
2417 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); 2412 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f));
2418 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f)); 2413 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f));
2419 2414
2420 // Gpu rasterization is disabled by default. 2415 // Gpu rasterization is disabled by default.
2421 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); 2416 EXPECT_FALSE(host_impl_.use_gpu_rasterization());
2422 // Toggling the gpu rasterization clears all tilings on both trees. 2417 // Toggling the gpu rasterization clears all tilings on both trees.
2423 host_impl_.SetHasGpuRasterizationTrigger(true); 2418 host_impl_.SetHasGpuRasterizationTrigger(true);
(...skipping 27 matching lines...) Expand all
2451 host_impl_.SetHasGpuRasterizationTrigger(true); 2446 host_impl_.SetHasGpuRasterizationTrigger(true);
2452 host_impl_.SetContentIsSuitableForGpuRasterization(false); 2447 host_impl_.SetContentIsSuitableForGpuRasterization(false);
2453 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, 2448 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT,
2454 host_impl_.gpu_rasterization_status()); 2449 host_impl_.gpu_rasterization_status());
2455 } 2450 }
2456 2451
2457 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { 2452 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) {
2458 // Put 0.5 as high res. 2453 // Put 0.5 as high res.
2459 SetInitialDeviceScaleFactor(0.5f); 2454 SetInitialDeviceScaleFactor(0.5f);
2460 2455
2461 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 2456 scoped_refptr<FakeRasterSource> pending_raster_source =
2462 FakeDisplayListRasterSource::CreateFilled(gfx::Size(10, 10)); 2457 FakeRasterSource::CreateFilled(gfx::Size(10, 10));
2463 SetupPendingTree(pending_raster_source); 2458 SetupPendingTree(pending_raster_source);
2464 2459
2465 // Sanity checks. 2460 // Sanity checks.
2466 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 2461 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
2467 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(0.5f)); 2462 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(0.5f));
2468 2463
2469 ActivateTree(); 2464 ActivateTree();
2470 2465
2471 // Now, set the bounds to be 1x1, so that minimum contents scale becomes 1. 2466 // Now, set the bounds to be 1x1, so that minimum contents scale becomes 1.
2472 pending_raster_source = 2467 pending_raster_source = FakeRasterSource::CreateFilled(gfx::Size(1, 1));
2473 FakeDisplayListRasterSource::CreateFilled(gfx::Size(1, 1));
2474 SetupPendingTree(pending_raster_source); 2468 SetupPendingTree(pending_raster_source);
2475 2469
2476 // Another sanity check. 2470 // Another sanity check.
2477 EXPECT_EQ(1.f, pending_layer_->MinimumContentsScale()); 2471 EXPECT_EQ(1.f, pending_layer_->MinimumContentsScale());
2478 2472
2479 // Since the MinContentsScale is 1, the 0.5 tiling should have been replaced 2473 // Since the MinContentsScale is 1, the 0.5 tiling should have been replaced
2480 // by a 1.0 tiling during the UDP in SetupPendingTree. 2474 // by a 1.0 tiling during the UDP in SetupPendingTree.
2481 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 2475 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
2482 PictureLayerTiling* tiling = 2476 PictureLayerTiling* tiling =
2483 pending_layer_->tilings()->FindTilingWithScale(1.0f); 2477 pending_layer_->tilings()->FindTilingWithScale(1.0f);
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
2879 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); 2873 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f);
2880 } 2874 }
2881 2875
2882 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { 2876 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) {
2883 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 2877 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
2884 2878
2885 host_impl_.SetViewportSize(gfx::Size(500, 500)); 2879 host_impl_.SetViewportSize(gfx::Size(500, 500));
2886 2880
2887 gfx::Size layer_bounds(1000, 1000); 2881 gfx::Size layer_bounds(1000, 1000);
2888 2882
2889 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 2883 scoped_refptr<FakeRasterSource> pending_raster_source =
2890 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 2884 FakeRasterSource::CreateFilled(layer_bounds);
2891 2885
2892 SetupPendingTree(pending_raster_source); 2886 SetupPendingTree(pending_raster_source);
2893 EXPECT_EQ(1u, pending_layer_->num_tilings()); 2887 EXPECT_EQ(1u, pending_layer_->num_tilings());
2894 2888
2895 std::set<Tile*> unique_tiles; 2889 std::set<Tile*> unique_tiles;
2896 bool reached_prepaint = false; 2890 bool reached_prepaint = false;
2897 int non_ideal_tile_count = 0u; 2891 int non_ideal_tile_count = 0u;
2898 int low_res_tile_count = 0u; 2892 int low_res_tile_count = 0u;
2899 int high_res_tile_count = 0u; 2893 int high_res_tile_count = 0u;
2900 int high_res_now_tiles = 0u; 2894 int high_res_now_tiles = 0u;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 EXPECT_TRUE(queue->IsEmpty()); 3005 EXPECT_TRUE(queue->IsEmpty());
3012 } 3006 }
3013 3007
3014 TEST_F(PictureLayerImplTest, TilingSetRasterQueueActiveTree) { 3008 TEST_F(PictureLayerImplTest, TilingSetRasterQueueActiveTree) {
3015 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 3009 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
3016 3010
3017 host_impl_.SetViewportSize(gfx::Size(500, 500)); 3011 host_impl_.SetViewportSize(gfx::Size(500, 500));
3018 3012
3019 gfx::Size layer_bounds(1000, 1000); 3013 gfx::Size layer_bounds(1000, 1000);
3020 3014
3021 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 3015 scoped_refptr<FakeRasterSource> pending_raster_source =
3022 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 3016 FakeRasterSource::CreateFilled(layer_bounds);
3023 3017
3024 SetupPendingTree(pending_raster_source); 3018 SetupPendingTree(pending_raster_source);
3025 ActivateTree(); 3019 ActivateTree();
3026 EXPECT_EQ(2u, active_layer_->num_tilings()); 3020 EXPECT_EQ(2u, active_layer_->num_tilings());
3027 3021
3028 scoped_ptr<TilingSetRasterQueueRequired> queue( 3022 scoped_ptr<TilingSetRasterQueueRequired> queue(
3029 new TilingSetRasterQueueRequired( 3023 new TilingSetRasterQueueRequired(
3030 active_layer_->picture_layer_tiling_set(), 3024 active_layer_->picture_layer_tiling_set(),
3031 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); 3025 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW));
3032 EXPECT_FALSE(queue->IsEmpty()); 3026 EXPECT_FALSE(queue->IsEmpty());
3033 while (!queue->IsEmpty()) { 3027 while (!queue->IsEmpty()) {
3034 PrioritizedTile prioritized_tile = queue->Top(); 3028 PrioritizedTile prioritized_tile = queue->Top();
3035 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw()); 3029 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw());
3036 EXPECT_FALSE(prioritized_tile.tile()->draw_info().IsReadyToDraw()); 3030 EXPECT_FALSE(prioritized_tile.tile()->draw_info().IsReadyToDraw());
3037 queue->Pop(); 3031 queue->Pop();
3038 } 3032 }
3039 3033
3040 queue.reset(new TilingSetRasterQueueRequired( 3034 queue.reset(new TilingSetRasterQueueRequired(
3041 active_layer_->picture_layer_tiling_set(), 3035 active_layer_->picture_layer_tiling_set(),
3042 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); 3036 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION));
3043 EXPECT_TRUE(queue->IsEmpty()); 3037 EXPECT_TRUE(queue->IsEmpty());
3044 } 3038 }
3045 3039
3046 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) { 3040 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) {
3047 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 3041 scoped_refptr<FakeRasterSource> pending_raster_source =
3048 FakeDisplayListRasterSource::CreateFilledSolidColor( 3042 FakeRasterSource::CreateFilledSolidColor(gfx::Size(1024, 1024));
3049 gfx::Size(1024, 1024));
3050 3043
3051 SetupPendingTree(pending_raster_source); 3044 SetupPendingTree(pending_raster_source);
3052 EXPECT_FALSE( 3045 EXPECT_FALSE(
3053 pending_layer_->picture_layer_tiling_set()->FindTilingWithResolution( 3046 pending_layer_->picture_layer_tiling_set()->FindTilingWithResolution(
3054 HIGH_RESOLUTION)); 3047 HIGH_RESOLUTION));
3055 3048
3056 scoped_ptr<TilingSetRasterQueueRequired> queue( 3049 scoped_ptr<TilingSetRasterQueueRequired> queue(
3057 new TilingSetRasterQueueRequired( 3050 new TilingSetRasterQueueRequired(
3058 pending_layer_->picture_layer_tiling_set(), 3051 pending_layer_->picture_layer_tiling_set(),
3059 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); 3052 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION));
3060 EXPECT_TRUE(queue->IsEmpty()); 3053 EXPECT_TRUE(queue->IsEmpty());
3061 } 3054 }
3062 3055
3063 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) { 3056 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) {
3064 gfx::Size layer_bounds(1000, 1000); 3057 gfx::Size layer_bounds(1000, 1000);
3065 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 3058 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
3066 3059
3067 host_impl_.SetViewportSize(gfx::Size(500, 500)); 3060 host_impl_.SetViewportSize(gfx::Size(500, 500));
3068 3061
3069 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 3062 scoped_refptr<FakeRasterSource> pending_raster_source =
3070 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 3063 FakeRasterSource::CreateFilled(layer_bounds);
3071 3064
3072 // TODO(vmpstr): Add a test with tilings other than high res on the active 3065 // TODO(vmpstr): Add a test with tilings other than high res on the active
3073 // tree (crbug.com/519607). 3066 // tree (crbug.com/519607).
3074 SetupPendingTree(pending_raster_source); 3067 SetupPendingTree(pending_raster_source);
3075 EXPECT_EQ(1u, pending_layer_->num_tilings()); 3068 EXPECT_EQ(1u, pending_layer_->num_tilings());
3076 3069
3077 std::vector<Tile*> all_tiles; 3070 std::vector<Tile*> all_tiles;
3078 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 3071 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
3079 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 3072 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
3080 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); 3073 std::vector<Tile*> tiles = tiling->AllTilesForTesting();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3204 } 3197 }
3205 3198
3206 TEST_F(PictureLayerImplTest, Occlusion) { 3199 TEST_F(PictureLayerImplTest, Occlusion) {
3207 gfx::Size tile_size(102, 102); 3200 gfx::Size tile_size(102, 102);
3208 gfx::Size layer_bounds(1000, 1000); 3201 gfx::Size layer_bounds(1000, 1000);
3209 gfx::Size viewport_size(1000, 1000); 3202 gfx::Size viewport_size(1000, 1000);
3210 3203
3211 LayerTestCommon::LayerImplTest impl; 3204 LayerTestCommon::LayerImplTest impl;
3212 host_impl_.SetViewportSize(viewport_size); 3205 host_impl_.SetViewportSize(viewport_size);
3213 3206
3214 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 3207 scoped_refptr<FakeRasterSource> pending_raster_source =
3215 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 3208 FakeRasterSource::CreateFilled(layer_bounds);
3216 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 3209 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
3217 ActivateTree(); 3210 ActivateTree();
3218 3211
3219 std::vector<Tile*> tiles = 3212 std::vector<Tile*> tiles =
3220 active_layer_->HighResTiling()->AllTilesForTesting(); 3213 active_layer_->HighResTiling()->AllTilesForTesting();
3221 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 3214 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
3222 3215
3223 { 3216 {
3224 SCOPED_TRACE("No occlusion"); 3217 SCOPED_TRACE("No occlusion");
3225 gfx::Rect occluded; 3218 gfx::Rect occluded;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
3489 3482
3490 AssertAllTilesRequired(active_layer_->HighResTiling()); 3483 AssertAllTilesRequired(active_layer_->HighResTiling());
3491 if (host_impl_.settings().create_low_res_tiling) 3484 if (host_impl_.settings().create_low_res_tiling)
3492 AssertNoTilesRequired(active_layer_->LowResTiling()); 3485 AssertNoTilesRequired(active_layer_->LowResTiling());
3493 } 3486 }
3494 3487
3495 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 3488 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
3496 gfx::Size layer_bounds(400, 400); 3489 gfx::Size layer_bounds(400, 400);
3497 gfx::Size tile_size(100, 100); 3490 gfx::Size tile_size(100, 100);
3498 3491
3499 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 3492 scoped_refptr<FakeRasterSource> pending_raster_source =
3500 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 3493 FakeRasterSource::CreateFilled(layer_bounds);
3501 // This raster source will create tilings, but has no recordings so will not 3494 // This raster source will create tilings, but has no recordings so will not
3502 // create any tiles. This is attempting to simulate scrolling past the end of 3495 // create any tiles. This is attempting to simulate scrolling past the end of
3503 // recorded content on the active layer, where the recordings are so far away 3496 // recorded content on the active layer, where the recordings are so far away
3504 // that no tiles are created. 3497 // that no tiles are created.
3505 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 3498 scoped_refptr<FakeRasterSource> active_raster_source =
3506 FakeDisplayListRasterSource::CreatePartiallyFilled(layer_bounds, 3499 FakeRasterSource::CreatePartiallyFilled(layer_bounds, gfx::Rect());
3507 gfx::Rect());
3508 3500
3509 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, 3501 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source,
3510 tile_size, Region()); 3502 tile_size, Region());
3511 3503
3512 // Active layer has tilings, but no tiles due to missing recordings. 3504 // Active layer has tilings, but no tiles due to missing recordings.
3513 EXPECT_TRUE(active_layer_->CanHaveTilings()); 3505 EXPECT_TRUE(active_layer_->CanHaveTilings());
3514 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 3506 EXPECT_EQ(active_layer_->tilings()->num_tilings(),
3515 host_impl_.settings().create_low_res_tiling ? 2u : 1u); 3507 host_impl_.settings().create_low_res_tiling ? 2u : 1u);
3516 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 3508 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
3517 3509
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
3720 } 3712 }
3721 }; 3713 };
3722 3714
3723 TEST_F(PictureLayerImplTestWithDelegatingRenderer, 3715 TEST_F(PictureLayerImplTestWithDelegatingRenderer,
3724 DelegatingRendererWithTileOOM) { 3716 DelegatingRendererWithTileOOM) {
3725 // This test is added for crbug.com/402321, where quad should be produced when 3717 // This test is added for crbug.com/402321, where quad should be produced when
3726 // raster on demand is not allowed and tile is OOM. 3718 // raster on demand is not allowed and tile is OOM.
3727 gfx::Size layer_bounds(1000, 1000); 3719 gfx::Size layer_bounds(1000, 1000);
3728 3720
3729 // Create tiles. 3721 // Create tiles.
3730 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 3722 scoped_refptr<FakeRasterSource> pending_raster_source =
3731 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 3723 FakeRasterSource::CreateFilled(layer_bounds);
3732 SetupPendingTree(pending_raster_source); 3724 SetupPendingTree(pending_raster_source);
3733 pending_layer_->SetBounds(layer_bounds); 3725 pending_layer_->SetBounds(layer_bounds);
3734 ActivateTree(); 3726 ActivateTree();
3735 bool update_lcd_text = false; 3727 bool update_lcd_text = false;
3736 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); 3728 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
3737 std::vector<Tile*> tiles = 3729 std::vector<Tile*> tiles =
3738 active_layer_->HighResTiling()->AllTilesForTesting(); 3730 active_layer_->HighResTiling()->AllTilesForTesting();
3739 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 3731 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
3740 3732
3741 // Force tiles after max_tiles to be OOM. TileManager uses 3733 // Force tiles after max_tiles to be OOM. TileManager uses
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
3827 OccludedTilesSkippedDuringRasterization) { 3819 OccludedTilesSkippedDuringRasterization) {
3828 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 3820 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
3829 3821
3830 gfx::Size tile_size(102, 102); 3822 gfx::Size tile_size(102, 102);
3831 gfx::Size layer_bounds(1000, 1000); 3823 gfx::Size layer_bounds(1000, 1000);
3832 gfx::Size viewport_size(500, 500); 3824 gfx::Size viewport_size(500, 500);
3833 gfx::PointF occluding_layer_position(310.f, 0.f); 3825 gfx::PointF occluding_layer_position(310.f, 0.f);
3834 3826
3835 host_impl_.SetViewportSize(viewport_size); 3827 host_impl_.SetViewportSize(viewport_size);
3836 3828
3837 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 3829 scoped_refptr<FakeRasterSource> pending_raster_source =
3838 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 3830 FakeRasterSource::CreateFilled(layer_bounds);
3839 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 3831 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
3840 3832
3841 // No occlusion. 3833 // No occlusion.
3842 int unoccluded_tile_count = 0; 3834 int unoccluded_tile_count = 0;
3843 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( 3835 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll(
3844 pending_layer_->picture_layer_tiling_set(), false)); 3836 pending_layer_->picture_layer_tiling_set(), false));
3845 while (!queue->IsEmpty()) { 3837 while (!queue->IsEmpty()) {
3846 PrioritizedTile prioritized_tile = queue->Top(); 3838 PrioritizedTile prioritized_tile = queue->Top();
3847 Tile* tile = prioritized_tile.tile(); 3839 Tile* tile = prioritized_tile.tile();
3848 3840
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3919 OccludedTilesNotMarkedAsRequired) { 3911 OccludedTilesNotMarkedAsRequired) {
3920 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 3912 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
3921 3913
3922 gfx::Size tile_size(102, 102); 3914 gfx::Size tile_size(102, 102);
3923 gfx::Size layer_bounds(1000, 1000); 3915 gfx::Size layer_bounds(1000, 1000);
3924 gfx::Size viewport_size(500, 500); 3916 gfx::Size viewport_size(500, 500);
3925 gfx::PointF occluding_layer_position(310.f, 0.f); 3917 gfx::PointF occluding_layer_position(310.f, 0.f);
3926 3918
3927 host_impl_.SetViewportSize(viewport_size); 3919 host_impl_.SetViewportSize(viewport_size);
3928 3920
3929 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 3921 scoped_refptr<FakeRasterSource> pending_raster_source =
3930 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 3922 FakeRasterSource::CreateFilled(layer_bounds);
3931 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 3923 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
3932 3924
3933 // No occlusion. 3925 // No occlusion.
3934 int occluded_tile_count = 0; 3926 int occluded_tile_count = 0;
3935 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 3927 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
3936 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 3928 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
3937 auto prioritized_tiles = 3929 auto prioritized_tiles =
3938 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 3930 tiling->UpdateAndGetAllPrioritizedTilesForTesting();
3939 3931
3940 occluded_tile_count = 0; 3932 occluded_tile_count = 0;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
4037 } 4029 }
4038 4030
4039 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { 4031 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) {
4040 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4032 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4041 4033
4042 gfx::Size tile_size(102, 102); 4034 gfx::Size tile_size(102, 102);
4043 gfx::Size layer_bounds(1000, 1000); 4035 gfx::Size layer_bounds(1000, 1000);
4044 gfx::Size viewport_size(500, 500); 4036 gfx::Size viewport_size(500, 500);
4045 gfx::PointF occluding_layer_position(310.f, 0.f); 4037 gfx::PointF occluding_layer_position(310.f, 0.f);
4046 4038
4047 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 4039 scoped_refptr<FakeRasterSource> pending_raster_source =
4048 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4040 FakeRasterSource::CreateFilled(layer_bounds);
4049 4041
4050 host_impl_.SetViewportSize(viewport_size); 4042 host_impl_.SetViewportSize(viewport_size);
4051 4043
4052 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 4044 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
4053 ASSERT_TRUE(pending_layer_->CanHaveTilings()); 4045 ASSERT_TRUE(pending_layer_->CanHaveTilings());
4054 4046
4055 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); 4047 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1));
4056 LayerImpl* layer1 = pending_layer_->children()[0]; 4048 LayerImpl* layer1 = pending_layer_->children()[0];
4057 layer1->SetBounds(layer_bounds); 4049 layer1->SetBounds(layer_bounds);
4058 layer1->SetDrawsContent(true); 4050 layer1->SetDrawsContent(true);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4111 } 4103 }
4112 } 4104 }
4113 } 4105 }
4114 4106
4115 TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) { 4107 TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) {
4116 gfx::Size layer_bounds(1000, 1000); 4108 gfx::Size layer_bounds(1000, 1000);
4117 gfx::Size viewport_size(1000, 1000); 4109 gfx::Size viewport_size(1000, 1000);
4118 gfx::PointF occluding_layer_position(310.f, 0.f); 4110 gfx::PointF occluding_layer_position(310.f, 0.f);
4119 gfx::Rect invalidation_rect(230, 230, 102, 102); 4111 gfx::Rect invalidation_rect(230, 230, 102, 102);
4120 4112
4121 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 4113 scoped_refptr<FakeRasterSource> pending_raster_source =
4122 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4114 FakeRasterSource::CreateFilled(layer_bounds);
4123 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 4115 scoped_refptr<FakeRasterSource> active_raster_source =
4124 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4116 FakeRasterSource::CreateFilled(layer_bounds);
4125 4117
4126 host_impl_.SetViewportSize(viewport_size); 4118 host_impl_.SetViewportSize(viewport_size);
4127 SetupPendingTree(active_raster_source); 4119 SetupPendingTree(active_raster_source);
4128 4120
4129 // Partially occlude the active layer. 4121 // Partially occlude the active layer.
4130 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); 4122 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2));
4131 LayerImpl* layer1 = pending_layer_->children()[0]; 4123 LayerImpl* layer1 = pending_layer_->children()[0];
4132 layer1->SetBounds(layer_bounds); 4124 layer1->SetBounds(layer_bounds);
4133 layer1->SetDrawsContent(true); 4125 layer1->SetDrawsContent(true);
4134 layer1->SetContentsOpaque(true); 4126 layer1->SetContentsOpaque(true);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4205 gfx::Size tile_size(102, 102); 4197 gfx::Size tile_size(102, 102);
4206 gfx::Size layer_bounds(1000, 1000); 4198 gfx::Size layer_bounds(1000, 1000);
4207 gfx::Size viewport_size(1000, 1000); 4199 gfx::Size viewport_size(1000, 1000);
4208 gfx::PointF pending_occluding_layer_position(310.f, 0.f); 4200 gfx::PointF pending_occluding_layer_position(310.f, 0.f);
4209 gfx::PointF active_occluding_layer_position(0.f, 310.f); 4201 gfx::PointF active_occluding_layer_position(0.f, 310.f);
4210 gfx::Rect invalidation_rect(230, 230, 152, 152); 4202 gfx::Rect invalidation_rect(230, 230, 152, 152);
4211 4203
4212 host_impl_.SetViewportSize(viewport_size); 4204 host_impl_.SetViewportSize(viewport_size);
4213 SetInitialDeviceScaleFactor(2.f); 4205 SetInitialDeviceScaleFactor(2.f);
4214 4206
4215 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 4207 scoped_refptr<FakeRasterSource> pending_raster_source =
4216 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4208 FakeRasterSource::CreateFilled(layer_bounds);
4217 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 4209 scoped_refptr<FakeRasterSource> active_raster_source =
4218 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4210 FakeRasterSource::CreateFilled(layer_bounds);
4219 4211
4220 SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region()); 4212 SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region());
4221 4213
4222 // Partially occlude the active layer. 4214 // Partially occlude the active layer.
4223 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); 4215 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2));
4224 LayerImpl* active_occluding_layer = pending_layer_->children()[0]; 4216 LayerImpl* active_occluding_layer = pending_layer_->children()[0];
4225 active_occluding_layer->SetBounds(layer_bounds); 4217 active_occluding_layer->SetBounds(layer_bounds);
4226 active_occluding_layer->SetDrawsContent(true); 4218 active_occluding_layer->SetDrawsContent(true);
4227 active_occluding_layer->SetContentsOpaque(true); 4219 active_occluding_layer->SetContentsOpaque(true);
4228 active_occluding_layer->SetPosition(active_occluding_layer_position); 4220 active_occluding_layer->SetPosition(active_occluding_layer_position);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
4344 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); 4336 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__);
4345 VerifyEvictionConsidersOcclusion( 4337 VerifyEvictionConsidersOcclusion(
4346 pending_layer_, PENDING_TREE, 4338 pending_layer_, PENDING_TREE,
4347 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); 4339 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__);
4348 pending_layer_->set_has_valid_tile_priorities(true); 4340 pending_layer_->set_has_valid_tile_priorities(true);
4349 } 4341 }
4350 4342
4351 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { 4343 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) {
4352 gfx::Size layer_bounds(1000, 1000); 4344 gfx::Size layer_bounds(1000, 1000);
4353 4345
4354 scoped_refptr<FakeDisplayListRasterSource> raster_source = 4346 scoped_refptr<FakeRasterSource> raster_source =
4355 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4347 FakeRasterSource::CreateFilled(layer_bounds);
4356 SetupPendingTree(raster_source); 4348 SetupPendingTree(raster_source);
4357 EXPECT_FALSE(pending_layer_->GetPendingOrActiveTwinLayer()); 4349 EXPECT_FALSE(pending_layer_->GetPendingOrActiveTwinLayer());
4358 4350
4359 ActivateTree(); 4351 ActivateTree();
4360 EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer()); 4352 EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer());
4361 4353
4362 SetupPendingTree(raster_source); 4354 SetupPendingTree(raster_source);
4363 EXPECT_TRUE(pending_layer_->GetPendingOrActiveTwinLayer()); 4355 EXPECT_TRUE(pending_layer_->GetPendingOrActiveTwinLayer());
4364 EXPECT_TRUE(active_layer_->GetPendingOrActiveTwinLayer()); 4356 EXPECT_TRUE(active_layer_->GetPendingOrActiveTwinLayer());
4365 EXPECT_EQ(pending_layer_, active_layer_->GetPendingOrActiveTwinLayer()); 4357 EXPECT_EQ(pending_layer_, active_layer_->GetPendingOrActiveTwinLayer());
(...skipping 28 matching lines...) Expand all
4394 4386
4395 int frame_number = 0; 4387 int frame_number = 0;
4396 4388
4397 client.set_fill_with_nonsolid_color(!test_for_solid); 4389 client.set_fill_with_nonsolid_color(!test_for_solid);
4398 4390
4399 Region invalidation(layer_rect); 4391 Region invalidation(layer_rect);
4400 recording_source->UpdateAndExpandInvalidation( 4392 recording_source->UpdateAndExpandInvalidation(
4401 &client, &invalidation, layer_bounds, layer_rect, frame_number++, 4393 &client, &invalidation, layer_bounds, layer_rect, frame_number++,
4402 DisplayListRecordingSource::RECORD_NORMALLY); 4394 DisplayListRecordingSource::RECORD_NORMALLY);
4403 4395
4404 scoped_refptr<DisplayListRasterSource> pending_raster_source = 4396 scoped_refptr<RasterSource> pending_raster_source =
4405 recording_source->CreateRasterSource(true); 4397 recording_source->CreateRasterSource(true);
4406 4398
4407 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 4399 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
4408 ActivateTree(); 4400 ActivateTree();
4409 4401
4410 if (test_for_solid) { 4402 if (test_for_solid) {
4411 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 4403 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
4412 } else { 4404 } else {
4413 ASSERT_TRUE(active_layer_->tilings()); 4405 ASSERT_TRUE(active_layer_->tilings());
4414 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); 4406 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4459 int frame_number = 0; 4451 int frame_number = 0;
4460 4452
4461 client.set_fill_with_nonsolid_color(true); 4453 client.set_fill_with_nonsolid_color(true);
4462 4454
4463 recording_source->SetNeedsDisplayRect(layer_rect); 4455 recording_source->SetNeedsDisplayRect(layer_rect);
4464 Region invalidation1; 4456 Region invalidation1;
4465 recording_source->UpdateAndExpandInvalidation( 4457 recording_source->UpdateAndExpandInvalidation(
4466 &client, &invalidation1, layer_bounds, layer_rect, frame_number++, 4458 &client, &invalidation1, layer_bounds, layer_rect, frame_number++,
4467 DisplayListRecordingSource::RECORD_NORMALLY); 4459 DisplayListRecordingSource::RECORD_NORMALLY);
4468 4460
4469 scoped_refptr<DisplayListRasterSource> raster_source1 = 4461 scoped_refptr<RasterSource> raster_source1 =
4470 recording_source->CreateRasterSource(true); 4462 recording_source->CreateRasterSource(true);
4471 4463
4472 SetupPendingTree(raster_source1); 4464 SetupPendingTree(raster_source1);
4473 ActivateTree(); 4465 ActivateTree();
4474 bool update_lcd_text = false; 4466 bool update_lcd_text = false;
4475 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); 4467 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
4476 4468
4477 // We've started with a solid layer that contains some tilings. 4469 // We've started with a solid layer that contains some tilings.
4478 ASSERT_TRUE(active_layer_->tilings()); 4470 ASSERT_TRUE(active_layer_->tilings());
4479 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); 4471 EXPECT_NE(0u, active_layer_->tilings()->num_tilings());
4480 4472
4481 client.set_fill_with_nonsolid_color(false); 4473 client.set_fill_with_nonsolid_color(false);
4482 4474
4483 recording_source->SetNeedsDisplayRect(layer_rect); 4475 recording_source->SetNeedsDisplayRect(layer_rect);
4484 Region invalidation2; 4476 Region invalidation2;
4485 recording_source->UpdateAndExpandInvalidation( 4477 recording_source->UpdateAndExpandInvalidation(
4486 &client, &invalidation2, layer_bounds, layer_rect, frame_number++, 4478 &client, &invalidation2, layer_bounds, layer_rect, frame_number++,
4487 DisplayListRecordingSource::RECORD_NORMALLY); 4479 DisplayListRecordingSource::RECORD_NORMALLY);
4488 4480
4489 scoped_refptr<DisplayListRasterSource> raster_source2 = 4481 scoped_refptr<RasterSource> raster_source2 =
4490 recording_source->CreateRasterSource(true); 4482 recording_source->CreateRasterSource(true);
4491 4483
4492 SetupPendingTree(raster_source2); 4484 SetupPendingTree(raster_source2);
4493 ActivateTree(); 4485 ActivateTree();
4494 4486
4495 // We've switched to a solid color, so we should end up with no tilings. 4487 // We've switched to a solid color, so we should end up with no tilings.
4496 ASSERT_TRUE(active_layer_->tilings()); 4488 ASSERT_TRUE(active_layer_->tilings());
4497 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 4489 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
4498 } 4490 }
4499 4491
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4552 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 4544 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
4553 4545
4554 // Ensure we can activate. 4546 // Ensure we can activate.
4555 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); 4547 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
4556 } 4548 }
4557 4549
4558 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { 4550 TEST_F(PictureLayerImplTest, CloneMissingRecordings) {
4559 gfx::Size tile_size(100, 100); 4551 gfx::Size tile_size(100, 100);
4560 gfx::Size layer_bounds(400, 400); 4552 gfx::Size layer_bounds(400, 400);
4561 4553
4562 scoped_refptr<FakeDisplayListRasterSource> filled_raster_source = 4554 scoped_refptr<FakeRasterSource> filled_raster_source =
4563 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4555 FakeRasterSource::CreateFilled(layer_bounds);
4564 4556
4565 scoped_refptr<FakeDisplayListRasterSource> partial_raster_source = 4557 scoped_refptr<FakeRasterSource> partial_raster_source =
4566 FakeDisplayListRasterSource::CreatePartiallyFilled( 4558 FakeRasterSource::CreatePartiallyFilled(layer_bounds,
4567 layer_bounds, gfx::Rect(100, 100, 300, 300)); 4559 gfx::Rect(100, 100, 300, 300));
4568 4560
4569 SetupPendingTreeWithFixedTileSize(filled_raster_source, tile_size, Region()); 4561 SetupPendingTreeWithFixedTileSize(filled_raster_source, tile_size, Region());
4570 ActivateTree(); 4562 ActivateTree();
4571 4563
4572 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); 4564 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling();
4573 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); 4565 PictureLayerTiling* active_tiling = active_layer_->HighResTiling();
4574 4566
4575 // We should have all tiles on active, and none on pending. 4567 // We should have all tiles on active, and none on pending.
4576 EXPECT_EQ(0u, pending_tiling->AllTilesForTesting().size()); 4568 EXPECT_EQ(0u, pending_tiling->AllTilesForTesting().size());
4577 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); 4569 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4619 TEST_F(PictureLayerImplTest, ScrollPastLiveTilesRectAndBack) { 4611 TEST_F(PictureLayerImplTest, ScrollPastLiveTilesRectAndBack) {
4620 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4612 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4621 4613
4622 gfx::Size tile_size(102, 102); 4614 gfx::Size tile_size(102, 102);
4623 gfx::Size layer_bounds(100, 100); 4615 gfx::Size layer_bounds(100, 100);
4624 gfx::Size viewport_size(100, 100); 4616 gfx::Size viewport_size(100, 100);
4625 4617
4626 host_impl_.SetViewportSize(viewport_size); 4618 host_impl_.SetViewportSize(viewport_size);
4627 SetInitialDeviceScaleFactor(1.f); 4619 SetInitialDeviceScaleFactor(1.f);
4628 4620
4629 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 4621 scoped_refptr<FakeRasterSource> pending_raster_source =
4630 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4622 FakeRasterSource::CreateFilled(layer_bounds);
4631 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 4623 scoped_refptr<FakeRasterSource> active_raster_source =
4632 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4624 FakeRasterSource::CreateFilled(layer_bounds);
4633 4625
4634 SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region()); 4626 SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region());
4635 4627
4636 ActivateTree(); 4628 ActivateTree();
4637 EXPECT_TRUE(active_layer_->HighResTiling()->has_tiles()); 4629 EXPECT_TRUE(active_layer_->HighResTiling()->has_tiles());
4638 4630
4639 host_impl_.SetExternalTilePriorityConstraints(gfx::Rect(0, 5000, 100, 100), 4631 host_impl_.SetExternalTilePriorityConstraints(gfx::Rect(0, 5000, 100, 100),
4640 gfx::Transform()); 4632 gfx::Transform());
4641 4633
4642 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, 4634 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4690 TEST_F(PictureLayerImplTest, UpdateLCDInvalidatesPendingTree) { 4682 TEST_F(PictureLayerImplTest, UpdateLCDInvalidatesPendingTree) {
4691 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4683 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4692 4684
4693 gfx::Size tile_size(102, 102); 4685 gfx::Size tile_size(102, 102);
4694 gfx::Size layer_bounds(100, 100); 4686 gfx::Size layer_bounds(100, 100);
4695 gfx::Size viewport_size(100, 100); 4687 gfx::Size viewport_size(100, 100);
4696 4688
4697 host_impl_.SetViewportSize(viewport_size); 4689 host_impl_.SetViewportSize(viewport_size);
4698 SetInitialDeviceScaleFactor(1.f); 4690 SetInitialDeviceScaleFactor(1.f);
4699 4691
4700 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 4692 scoped_refptr<FakeRasterSource> pending_raster_source =
4701 FakeDisplayListRasterSource::CreateFilledLCD(layer_bounds); 4693 FakeRasterSource::CreateFilledLCD(layer_bounds);
4702 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); 4694 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
4703 4695
4704 EXPECT_TRUE(pending_layer_->RasterSourceUsesLCDText()); 4696 EXPECT_TRUE(pending_layer_->RasterSourceUsesLCDText());
4705 EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles()); 4697 EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles());
4706 std::vector<Tile*> tiles = 4698 std::vector<Tile*> tiles =
4707 pending_layer_->HighResTiling()->AllTilesForTesting(); 4699 pending_layer_->HighResTiling()->AllTilesForTesting();
4708 auto prioritized_tiles = pending_layer_->HighResTiling() 4700 auto prioritized_tiles = pending_layer_->HighResTiling()
4709 ->UpdateAndGetAllPrioritizedTilesForTesting(); 4701 ->UpdateAndGetAllPrioritizedTilesForTesting();
4710 4702
4711 for (Tile* tile : tiles) 4703 for (Tile* tile : tiles)
(...skipping 13 matching lines...) Expand all
4725 EXPECT_EQ(pending_layer_->raster_source(), 4717 EXPECT_EQ(pending_layer_->raster_source(),
4726 prioritized_tiles[tile].raster_source()); 4718 prioritized_tiles[tile].raster_source());
4727 } 4719 }
4728 4720
4729 TEST_F(PictureLayerImplTest, TilingAllTilesDone) { 4721 TEST_F(PictureLayerImplTest, TilingAllTilesDone) {
4730 gfx::Size tile_size = host_impl_.settings().default_tile_size; 4722 gfx::Size tile_size = host_impl_.settings().default_tile_size;
4731 size_t tile_mem = 4 * tile_size.width() * tile_size.height(); 4723 size_t tile_mem = 4 * tile_size.width() * tile_size.height();
4732 gfx::Size layer_bounds(1000, 1000); 4724 gfx::Size layer_bounds(1000, 1000);
4733 4725
4734 // Create tiles. 4726 // Create tiles.
4735 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 4727 scoped_refptr<FakeRasterSource> pending_raster_source =
4736 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 4728 FakeRasterSource::CreateFilled(layer_bounds);
4737 SetupPendingTree(pending_raster_source); 4729 SetupPendingTree(pending_raster_source);
4738 pending_layer_->SetBounds(layer_bounds); 4730 pending_layer_->SetBounds(layer_bounds);
4739 ActivateTree(); 4731 ActivateTree();
4740 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( 4732 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(
4741 active_layer_->HighResTiling()->AllTilesForTesting()); 4733 active_layer_->HighResTiling()->AllTilesForTesting());
4742 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); 4734 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES);
4743 4735
4744 EXPECT_FALSE(active_layer_->HighResTiling()->all_tiles_done()); 4736 EXPECT_FALSE(active_layer_->HighResTiling()->all_tiles_done());
4745 4737
4746 { 4738 {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
4923 // New low res tiling. 4915 // New low res tiling.
4924 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); 4916 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles());
4925 4917
4926 // This tiling will be high res now, it won't contain low res content since it 4918 // This tiling will be high res now, it won't contain low res content since it
4927 // was all destroyed. 4919 // was all destroyed.
4928 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); 4920 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles());
4929 } 4921 }
4930 4922
4931 } // namespace 4923 } // namespace
4932 } // namespace cc 4924 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl_perftest.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698