OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/tiled_layer.h" | 5 #include "cc/layers/tiled_layer.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 class TestOcclusionTracker : public OcclusionTracker<Layer> { | 34 class TestOcclusionTracker : public OcclusionTracker<Layer> { |
35 public: | 35 public: |
36 TestOcclusionTracker() : OcclusionTracker(gfx::Rect(0, 0, 1000, 1000)) { | 36 TestOcclusionTracker() : OcclusionTracker(gfx::Rect(0, 0, 1000, 1000)) { |
37 stack_.push_back(StackObject()); | 37 stack_.push_back(StackObject()); |
38 } | 38 } |
39 | 39 |
40 void SetRenderTarget(Layer* render_target) { | 40 void SetRenderTarget(Layer* render_target) { |
41 stack_.back().target = render_target; | 41 stack_.back().target = render_target; |
42 } | 42 } |
43 | 43 |
44 void SetOcclusion(const Region& occlusion) { | 44 void SetOcclusion(const SimpleEnclosedRegion& occlusion) { |
45 stack_.back().occlusion_from_inside_target = occlusion; | 45 stack_.back().occlusion_from_inside_target = occlusion; |
46 } | 46 } |
47 }; | 47 }; |
48 | 48 |
49 class SynchronousOutputSurfaceLayerTreeHost : public LayerTreeHost { | 49 class SynchronousOutputSurfaceLayerTreeHost : public LayerTreeHost { |
50 public: | 50 public: |
51 static scoped_ptr<SynchronousOutputSurfaceLayerTreeHost> Create( | 51 static scoped_ptr<SynchronousOutputSurfaceLayerTreeHost> Create( |
52 LayerTreeHostClient* client, | 52 LayerTreeHostClient* client, |
53 SharedBitmapManager* manager, | 53 SharedBitmapManager* manager, |
54 const LayerTreeSettings& settings, | 54 const LayerTreeSettings& settings, |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); | 308 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); |
309 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); | 309 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); |
310 } | 310 } |
311 | 311 |
312 { | 312 { |
313 RenderSurfaceLayerList render_surface_layer_list; | 313 RenderSurfaceLayerList render_surface_layer_list; |
314 | 314 |
315 // Invalidates part of the top tile... | 315 // Invalidates part of the top tile... |
316 layer->InvalidateContentRect(gfx::Rect(0, 0, 50, 50)); | 316 layer->InvalidateContentRect(gfx::Rect(0, 0, 50, 50)); |
317 // ....but the area is occluded. | 317 // ....but the area is occluded. |
318 occluded.SetOcclusion(gfx::Rect(0, 0, 50, 50)); | 318 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(0, 0, 50, 50))); |
319 CalcDrawProps(&render_surface_layer_list); | 319 CalcDrawProps(&render_surface_layer_list); |
320 UpdateAndPush(layer, layer_impl); | 320 UpdateAndPush(layer, layer_impl); |
321 | 321 |
322 // We should still have both tiles, as part of the top tile is still | 322 // We should still have both tiles, as part of the top tile is still |
323 // unoccluded. | 323 // unoccluded. |
324 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); | 324 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); |
325 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); | 325 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 scoped_ptr<FakeTiledLayerImpl> layer_impl = | 551 scoped_ptr<FakeTiledLayerImpl> layer_impl = |
552 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); | 552 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); |
553 RenderSurfaceLayerList render_surface_layer_list; | 553 RenderSurfaceLayerList render_surface_layer_list; |
554 TestOcclusionTracker occluded; | 554 TestOcclusionTracker occluded; |
555 occlusion_ = &occluded; | 555 occlusion_ = &occluded; |
556 | 556 |
557 layer_tree_host_->root_layer()->AddChild(layer); | 557 layer_tree_host_->root_layer()->AddChild(layer); |
558 | 558 |
559 // The tile size is 100x100, so this invalidates one occluded tile, culls it | 559 // The tile size is 100x100, so this invalidates one occluded tile, culls it |
560 // during paint, but prepaints it. | 560 // during paint, but prepaints it. |
561 occluded.SetOcclusion(gfx::Rect(0, 0, 100, 100)); | 561 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(0, 0, 100, 100))); |
562 | 562 |
563 layer->SetBounds(gfx::Size(100, 100)); | 563 layer->SetBounds(gfx::Size(100, 100)); |
564 CalcDrawProps(&render_surface_layer_list); | 564 CalcDrawProps(&render_surface_layer_list); |
565 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 565 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
566 UpdateAndPush(layer, layer_impl); | 566 UpdateAndPush(layer, layer_impl); |
567 | 567 |
568 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); | 568 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); |
569 } | 569 } |
570 | 570 |
571 TEST_F(TiledLayerTest, PushTilesMarkedDirtyDuringPaint) { | 571 TEST_F(TiledLayerTest, PushTilesMarkedDirtyDuringPaint) { |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 occlusion_ = &occluded; | 1197 occlusion_ = &occluded; |
1198 | 1198 |
1199 layer_tree_host_->root_layer()->AddChild(layer); | 1199 layer_tree_host_->root_layer()->AddChild(layer); |
1200 | 1200 |
1201 // The tile size is 100x100. | 1201 // The tile size is 100x100. |
1202 | 1202 |
1203 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); | 1203 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); |
1204 layer->SetBounds(gfx::Size(600, 600)); | 1204 layer->SetBounds(gfx::Size(600, 600)); |
1205 CalcDrawProps(&render_surface_layer_list); | 1205 CalcDrawProps(&render_surface_layer_list); |
1206 | 1206 |
1207 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); | 1207 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(200, 200, 300, 100))); |
1208 layer->draw_properties().drawable_content_rect = | 1208 layer->draw_properties().drawable_content_rect = |
1209 gfx::Rect(layer->content_bounds()); | 1209 gfx::Rect(layer->content_bounds()); |
1210 layer->draw_properties().visible_content_rect = | 1210 layer->draw_properties().visible_content_rect = |
1211 gfx::Rect(layer->content_bounds()); | 1211 gfx::Rect(layer->content_bounds()); |
1212 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1212 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1213 | 1213 |
1214 layer->SetTexturePriorities(priority_calculator_); | 1214 layer->SetTexturePriorities(priority_calculator_); |
1215 resource_manager_->PrioritizeTextures(); | 1215 resource_manager_->PrioritizeTextures(); |
1216 layer->SavePaintProperties(); | 1216 layer->SavePaintProperties(); |
1217 layer->Update(queue_.get(), &occluded); | 1217 layer->Update(queue_.get(), &occluded); |
1218 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); | 1218 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); |
1219 | 1219 |
1220 layer->fake_layer_updater()->ClearUpdateCount(); | 1220 layer->fake_layer_updater()->ClearUpdateCount(); |
1221 layer->SetTexturePriorities(priority_calculator_); | 1221 layer->SetTexturePriorities(priority_calculator_); |
1222 resource_manager_->PrioritizeTextures(); | 1222 resource_manager_->PrioritizeTextures(); |
1223 | 1223 |
1224 occluded.SetOcclusion(gfx::Rect(250, 200, 300, 100)); | 1224 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(250, 200, 300, 100))); |
1225 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1225 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1226 layer->SavePaintProperties(); | 1226 layer->SavePaintProperties(); |
1227 layer->Update(queue_.get(), &occluded); | 1227 layer->Update(queue_.get(), &occluded); |
1228 EXPECT_EQ(36 - 2, layer->fake_layer_updater()->update_count()); | 1228 EXPECT_EQ(36 - 2, layer->fake_layer_updater()->update_count()); |
1229 | 1229 |
1230 layer->fake_layer_updater()->ClearUpdateCount(); | 1230 layer->fake_layer_updater()->ClearUpdateCount(); |
1231 layer->SetTexturePriorities(priority_calculator_); | 1231 layer->SetTexturePriorities(priority_calculator_); |
1232 resource_manager_->PrioritizeTextures(); | 1232 resource_manager_->PrioritizeTextures(); |
1233 | 1233 |
1234 occluded.SetOcclusion(gfx::Rect(250, 250, 300, 100)); | 1234 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(250, 250, 300, 100))); |
1235 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1235 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1236 layer->SavePaintProperties(); | 1236 layer->SavePaintProperties(); |
1237 layer->Update(queue_.get(), &occluded); | 1237 layer->Update(queue_.get(), &occluded); |
1238 EXPECT_EQ(36, layer->fake_layer_updater()->update_count()); | 1238 EXPECT_EQ(36, layer->fake_layer_updater()->update_count()); |
1239 } | 1239 } |
1240 | 1240 |
1241 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { | 1241 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { |
1242 scoped_refptr<FakeTiledLayer> layer = | 1242 scoped_refptr<FakeTiledLayer> layer = |
1243 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1243 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1244 RenderSurfaceLayerList render_surface_layer_list; | 1244 RenderSurfaceLayerList render_surface_layer_list; |
1245 TestOcclusionTracker occluded; | 1245 TestOcclusionTracker occluded; |
1246 occlusion_ = &occluded; | 1246 occlusion_ = &occluded; |
1247 | 1247 |
1248 layer_tree_host_->root_layer()->AddChild(layer); | 1248 layer_tree_host_->root_layer()->AddChild(layer); |
1249 | 1249 |
1250 // The tile size is 100x100. | 1250 // The tile size is 100x100. |
1251 | 1251 |
1252 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); | 1252 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); |
1253 layer->SetBounds(gfx::Size(600, 600)); | 1253 layer->SetBounds(gfx::Size(600, 600)); |
1254 CalcDrawProps(&render_surface_layer_list); | 1254 CalcDrawProps(&render_surface_layer_list); |
1255 | 1255 |
1256 // The partially occluded tiles (by the 150 occlusion height) are visible | 1256 // The partially occluded tiles (by the 150 occlusion height) are visible |
1257 // beyond the occlusion, so not culled. | 1257 // beyond the occlusion, so not culled. |
1258 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); | 1258 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(200, 200, 300, 150))); |
1259 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); | 1259 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); |
1260 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 360); | 1260 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 360); |
1261 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1261 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1262 | 1262 |
1263 layer->SetTexturePriorities(priority_calculator_); | 1263 layer->SetTexturePriorities(priority_calculator_); |
1264 resource_manager_->PrioritizeTextures(); | 1264 resource_manager_->PrioritizeTextures(); |
1265 layer->SavePaintProperties(); | 1265 layer->SavePaintProperties(); |
1266 layer->Update(queue_.get(), &occluded); | 1266 layer->Update(queue_.get(), &occluded); |
1267 EXPECT_EQ(24 - 3, layer->fake_layer_updater()->update_count()); | 1267 EXPECT_EQ(24 - 3, layer->fake_layer_updater()->update_count()); |
1268 | 1268 |
1269 layer->fake_layer_updater()->ClearUpdateCount(); | 1269 layer->fake_layer_updater()->ClearUpdateCount(); |
1270 | 1270 |
1271 // Now the visible region stops at the edge of the occlusion so the partly | 1271 // Now the visible region stops at the edge of the occlusion so the partly |
1272 // visible tiles become fully occluded. | 1272 // visible tiles become fully occluded. |
1273 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); | 1273 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(200, 200, 300, 150))); |
1274 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 350); | 1274 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 350); |
1275 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 350); | 1275 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 350); |
1276 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1276 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1277 layer->SetTexturePriorities(priority_calculator_); | 1277 layer->SetTexturePriorities(priority_calculator_); |
1278 resource_manager_->PrioritizeTextures(); | 1278 resource_manager_->PrioritizeTextures(); |
1279 layer->SavePaintProperties(); | 1279 layer->SavePaintProperties(); |
1280 layer->Update(queue_.get(), &occluded); | 1280 layer->Update(queue_.get(), &occluded); |
1281 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); | 1281 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); |
1282 | 1282 |
1283 layer->fake_layer_updater()->ClearUpdateCount(); | 1283 layer->fake_layer_updater()->ClearUpdateCount(); |
1284 | 1284 |
1285 // Now the visible region is even smaller than the occlusion, it should have | 1285 // Now the visible region is even smaller than the occlusion, it should have |
1286 // the same result. | 1286 // the same result. |
1287 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); | 1287 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(200, 200, 300, 150))); |
1288 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 340); | 1288 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 340); |
1289 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 340); | 1289 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 340); |
1290 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1290 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1291 layer->SetTexturePriorities(priority_calculator_); | 1291 layer->SetTexturePriorities(priority_calculator_); |
1292 resource_manager_->PrioritizeTextures(); | 1292 resource_manager_->PrioritizeTextures(); |
1293 layer->SavePaintProperties(); | 1293 layer->SavePaintProperties(); |
1294 layer->Update(queue_.get(), &occluded); | 1294 layer->Update(queue_.get(), &occluded); |
1295 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); | 1295 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); |
1296 } | 1296 } |
1297 | 1297 |
1298 TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { | 1298 TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { |
1299 scoped_refptr<FakeTiledLayer> layer = | 1299 scoped_refptr<FakeTiledLayer> layer = |
1300 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1300 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1301 RenderSurfaceLayerList render_surface_layer_list; | 1301 RenderSurfaceLayerList render_surface_layer_list; |
1302 TestOcclusionTracker occluded; | 1302 TestOcclusionTracker occluded; |
1303 occlusion_ = &occluded; | 1303 occlusion_ = &occluded; |
1304 | 1304 |
1305 layer_tree_host_->root_layer()->AddChild(layer); | 1305 layer_tree_host_->root_layer()->AddChild(layer); |
1306 | 1306 |
1307 // The tile size is 100x100. | 1307 // The tile size is 100x100. |
1308 | 1308 |
1309 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); | 1309 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); |
1310 layer->SetBounds(gfx::Size(600, 600)); | 1310 layer->SetBounds(gfx::Size(600, 600)); |
1311 CalcDrawProps(&render_surface_layer_list); | 1311 CalcDrawProps(&render_surface_layer_list); |
1312 | 1312 |
1313 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); | 1313 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(200, 200, 300, 100))); |
1314 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); | 1314 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); |
1315 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 600); | 1315 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 600); |
1316 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1316 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1317 layer->SetTexturePriorities(priority_calculator_); | 1317 layer->SetTexturePriorities(priority_calculator_); |
1318 resource_manager_->PrioritizeTextures(); | 1318 resource_manager_->PrioritizeTextures(); |
1319 layer->SavePaintProperties(); | 1319 layer->SavePaintProperties(); |
1320 layer->Update(queue_.get(), &occluded); | 1320 layer->Update(queue_.get(), &occluded); |
1321 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); | 1321 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); |
1322 UpdateTextures(); | 1322 UpdateTextures(); |
1323 | 1323 |
(...skipping 22 matching lines...) Expand all Loading... |
1346 // This makes sure the painting works when the occluded region (in screen | 1346 // This makes sure the painting works when the occluded region (in screen |
1347 // space) is transformed differently than the layer. | 1347 // space) is transformed differently than the layer. |
1348 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); | 1348 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); |
1349 layer->SetBounds(gfx::Size(600, 600)); | 1349 layer->SetBounds(gfx::Size(600, 600)); |
1350 CalcDrawProps(&render_surface_layer_list); | 1350 CalcDrawProps(&render_surface_layer_list); |
1351 gfx::Transform screen_transform; | 1351 gfx::Transform screen_transform; |
1352 screen_transform.Scale(0.5, 0.5); | 1352 screen_transform.Scale(0.5, 0.5); |
1353 layer->draw_properties().screen_space_transform = screen_transform; | 1353 layer->draw_properties().screen_space_transform = screen_transform; |
1354 layer->draw_properties().target_space_transform = screen_transform; | 1354 layer->draw_properties().target_space_transform = screen_transform; |
1355 | 1355 |
1356 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 50)); | 1356 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(100, 100, 150, 50))); |
1357 layer->draw_properties().drawable_content_rect = | 1357 layer->draw_properties().drawable_content_rect = |
1358 gfx::Rect(layer->content_bounds()); | 1358 gfx::Rect(layer->content_bounds()); |
1359 layer->draw_properties().visible_content_rect = | 1359 layer->draw_properties().visible_content_rect = |
1360 gfx::Rect(layer->content_bounds()); | 1360 gfx::Rect(layer->content_bounds()); |
1361 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1361 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1362 layer->SetTexturePriorities(priority_calculator_); | 1362 layer->SetTexturePriorities(priority_calculator_); |
1363 resource_manager_->PrioritizeTextures(); | 1363 resource_manager_->PrioritizeTextures(); |
1364 layer->SavePaintProperties(); | 1364 layer->SavePaintProperties(); |
1365 layer->Update(queue_.get(), &occluded); | 1365 layer->Update(queue_.get(), &occluded); |
1366 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); | 1366 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); |
(...skipping 21 matching lines...) Expand all Loading... |
1388 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); | 1388 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); |
1389 layer->SetBounds(gfx::Size(300, 300)); | 1389 layer->SetBounds(gfx::Size(300, 300)); |
1390 scale_layer->AddChild(layer); | 1390 scale_layer->AddChild(layer); |
1391 CalcDrawProps(&render_surface_layer_list); | 1391 CalcDrawProps(&render_surface_layer_list); |
1392 EXPECT_FLOAT_EQ(2.f, layer->contents_scale_x()); | 1392 EXPECT_FLOAT_EQ(2.f, layer->contents_scale_x()); |
1393 EXPECT_FLOAT_EQ(2.f, layer->contents_scale_y()); | 1393 EXPECT_FLOAT_EQ(2.f, layer->contents_scale_y()); |
1394 EXPECT_EQ(gfx::Size(600, 600).ToString(), | 1394 EXPECT_EQ(gfx::Size(600, 600).ToString(), |
1395 layer->content_bounds().ToString()); | 1395 layer->content_bounds().ToString()); |
1396 | 1396 |
1397 // No tiles are covered by the 300x50 occlusion. | 1397 // No tiles are covered by the 300x50 occlusion. |
1398 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 50)); | 1398 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(200, 200, 300, 50))); |
1399 layer->draw_properties().drawable_content_rect = | 1399 layer->draw_properties().drawable_content_rect = |
1400 gfx::Rect(layer->bounds()); | 1400 gfx::Rect(layer->bounds()); |
1401 layer->draw_properties().visible_content_rect = | 1401 layer->draw_properties().visible_content_rect = |
1402 gfx::Rect(layer->content_bounds()); | 1402 gfx::Rect(layer->content_bounds()); |
1403 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1403 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1404 layer->SetTexturePriorities(priority_calculator_); | 1404 layer->SetTexturePriorities(priority_calculator_); |
1405 resource_manager_->PrioritizeTextures(); | 1405 resource_manager_->PrioritizeTextures(); |
1406 layer->SavePaintProperties(); | 1406 layer->SavePaintProperties(); |
1407 layer->Update(queue_.get(), &occluded); | 1407 layer->Update(queue_.get(), &occluded); |
1408 int visible_tiles1 = 6 * 6; | 1408 int visible_tiles1 = 6 * 6; |
1409 EXPECT_EQ(visible_tiles1, layer->fake_layer_updater()->update_count()); | 1409 EXPECT_EQ(visible_tiles1, layer->fake_layer_updater()->update_count()); |
1410 | 1410 |
1411 layer->fake_layer_updater()->ClearUpdateCount(); | 1411 layer->fake_layer_updater()->ClearUpdateCount(); |
1412 | 1412 |
1413 // The occlusion of 300x100 will be cover 3 tiles as tiles are 100x100 still. | 1413 // The occlusion of 300x100 will be cover 3 tiles as tiles are 100x100 still. |
1414 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); | 1414 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(200, 200, 300, 100))); |
1415 layer->draw_properties().drawable_content_rect = | 1415 layer->draw_properties().drawable_content_rect = |
1416 gfx::Rect(layer->bounds()); | 1416 gfx::Rect(layer->bounds()); |
1417 layer->draw_properties().visible_content_rect = | 1417 layer->draw_properties().visible_content_rect = |
1418 gfx::Rect(layer->content_bounds()); | 1418 gfx::Rect(layer->content_bounds()); |
1419 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1419 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1420 layer->SetTexturePriorities(priority_calculator_); | 1420 layer->SetTexturePriorities(priority_calculator_); |
1421 resource_manager_->PrioritizeTextures(); | 1421 resource_manager_->PrioritizeTextures(); |
1422 layer->SavePaintProperties(); | 1422 layer->SavePaintProperties(); |
1423 layer->Update(queue_.get(), &occluded); | 1423 layer->Update(queue_.get(), &occluded); |
1424 int visible_tiles2 = 6 * 6 - 3; | 1424 int visible_tiles2 = 6 * 6 - 3; |
1425 EXPECT_EQ(visible_tiles2, layer->fake_layer_updater()->update_count()); | 1425 EXPECT_EQ(visible_tiles2, layer->fake_layer_updater()->update_count()); |
1426 | 1426 |
1427 layer->fake_layer_updater()->ClearUpdateCount(); | 1427 layer->fake_layer_updater()->ClearUpdateCount(); |
1428 | 1428 |
1429 // This makes sure content scaling and transforms work together. | 1429 // This makes sure content scaling and transforms work together. |
1430 // When the tiles are scaled down by half, they are 50x50 each in the | 1430 // When the tiles are scaled down by half, they are 50x50 each in the |
1431 // screen. | 1431 // screen. |
1432 gfx::Transform screen_transform; | 1432 gfx::Transform screen_transform; |
1433 screen_transform.Scale(0.5, 0.5); | 1433 screen_transform.Scale(0.5, 0.5); |
1434 layer->draw_properties().screen_space_transform = screen_transform; | 1434 layer->draw_properties().screen_space_transform = screen_transform; |
1435 layer->draw_properties().target_space_transform = screen_transform; | 1435 layer->draw_properties().target_space_transform = screen_transform; |
1436 | 1436 |
1437 // An occlusion of 150x100 will cover 3*2 = 6 tiles. | 1437 // An occlusion of 150x100 will cover 3*2 = 6 tiles. |
1438 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 100)); | 1438 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(100, 100, 150, 100))); |
1439 | 1439 |
1440 gfx::Rect layer_bounds_rect(layer->bounds()); | 1440 gfx::Rect layer_bounds_rect(layer->bounds()); |
1441 layer->draw_properties().drawable_content_rect = | 1441 layer->draw_properties().drawable_content_rect = |
1442 gfx::ScaleToEnclosingRect(layer_bounds_rect, 0.5f); | 1442 gfx::ScaleToEnclosingRect(layer_bounds_rect, 0.5f); |
1443 layer->draw_properties().visible_content_rect = | 1443 layer->draw_properties().visible_content_rect = |
1444 gfx::Rect(layer->content_bounds()); | 1444 gfx::Rect(layer->content_bounds()); |
1445 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1445 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1446 layer->SetTexturePriorities(priority_calculator_); | 1446 layer->SetTexturePriorities(priority_calculator_); |
1447 resource_manager_->PrioritizeTextures(); | 1447 resource_manager_->PrioritizeTextures(); |
1448 layer->SavePaintProperties(); | 1448 layer->SavePaintProperties(); |
1449 layer->Update(queue_.get(), &occluded); | 1449 layer->Update(queue_.get(), &occluded); |
1450 int visible_tiles3 = 6 * 6 - 6; | 1450 int visible_tiles3 = 6 * 6 - 6; |
1451 EXPECT_EQ(visible_tiles3, layer->fake_layer_updater()->update_count()); | 1451 EXPECT_EQ(visible_tiles3, layer->fake_layer_updater()->update_count()); |
1452 } | 1452 } |
1453 | 1453 |
1454 TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { | 1454 TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { |
1455 scoped_refptr<FakeTiledLayer> layer = | 1455 scoped_refptr<FakeTiledLayer> layer = |
1456 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1456 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1457 RenderSurfaceLayerList render_surface_layer_list; | 1457 RenderSurfaceLayerList render_surface_layer_list; |
1458 TestOcclusionTracker occluded; | 1458 TestOcclusionTracker occluded; |
1459 occlusion_ = &occluded; | 1459 occlusion_ = &occluded; |
1460 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); | 1460 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); |
1461 | 1461 |
1462 layer_tree_host_->root_layer()->AddChild(layer); | 1462 layer_tree_host_->root_layer()->AddChild(layer); |
1463 | 1463 |
1464 // The tile size is 100x100, so this invalidates and then paints two tiles in | 1464 // The tile size is 100x100, so this invalidates and then paints two tiles in |
1465 // various ways. | 1465 // various ways. |
1466 | 1466 |
1467 gfx::Rect opaque_paint_rect; | 1467 gfx::Rect opaque_paint_rect; |
1468 Region opaque_contents; | 1468 SimpleEnclosedRegion opaque_contents; |
1469 | 1469 |
1470 gfx::Rect content_bounds = gfx::Rect(0, 0, 100, 200); | 1470 gfx::Rect content_bounds = gfx::Rect(0, 0, 100, 200); |
1471 gfx::Rect visible_bounds = gfx::Rect(0, 0, 100, 150); | 1471 gfx::Rect visible_bounds = gfx::Rect(0, 0, 100, 150); |
1472 | 1472 |
1473 layer->SetBounds(content_bounds.size()); | 1473 layer->SetBounds(content_bounds.size()); |
1474 CalcDrawProps(&render_surface_layer_list); | 1474 CalcDrawProps(&render_surface_layer_list); |
1475 layer->draw_properties().drawable_content_rect = visible_bounds; | 1475 layer->draw_properties().drawable_content_rect = visible_bounds; |
1476 layer->draw_properties().visible_content_rect = visible_bounds; | 1476 layer->draw_properties().visible_content_rect = visible_bounds; |
1477 | 1477 |
1478 // If the layer doesn't paint opaque content, then the | 1478 // If the layer doesn't paint opaque content, then the |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 // Invalidate the entire layer in layer space. When painting, the rect given | 1811 // Invalidate the entire layer in layer space. When painting, the rect given |
1812 // to webkit should match the layer's bounds. | 1812 // to webkit should match the layer's bounds. |
1813 layer->SetNeedsDisplayRect(layer_rect); | 1813 layer->SetNeedsDisplayRect(layer_rect); |
1814 layer->Update(queue_.get(), NULL); | 1814 layer->Update(queue_.get(), NULL); |
1815 | 1815 |
1816 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); | 1816 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); |
1817 } | 1817 } |
1818 | 1818 |
1819 } // namespace | 1819 } // namespace |
1820 } // namespace cc | 1820 } // namespace cc |
OLD | NEW |