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

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

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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_unittest.cc ('k') | cc/output/begin_frame_args.h » ('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 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 PriorityCalculator priority_calculator_; 254 PriorityCalculator priority_calculator_;
255 base::Thread impl_thread_; 255 base::Thread impl_thread_;
256 FakeLayerTreeHostClient fake_layer_tree_host_client_; 256 FakeLayerTreeHostClient fake_layer_tree_host_client_;
257 scoped_ptr<SynchronousOutputSurfaceLayerTreeHost> layer_tree_host_; 257 scoped_ptr<SynchronousOutputSurfaceLayerTreeHost> layer_tree_host_;
258 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; 258 scoped_ptr<FakeLayerTreeHostImpl> host_impl_;
259 scoped_ptr<PrioritizedResourceManager> resource_manager_; 259 scoped_ptr<PrioritizedResourceManager> resource_manager_;
260 TestOcclusionTracker* occlusion_; 260 TestOcclusionTracker* occlusion_;
261 }; 261 };
262 262
263 TEST_F(TiledLayerTest, PushDirtyTiles) { 263 TEST_F(TiledLayerTest, PushDirtyTiles) {
264 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000));
265
264 scoped_refptr<FakeTiledLayer> layer = 266 scoped_refptr<FakeTiledLayer> layer =
265 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 267 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
266 scoped_ptr<FakeTiledLayerImpl> layer_impl = 268 scoped_ptr<FakeTiledLayerImpl> layer_impl =
267 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 269 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
268 RenderSurfaceLayerList render_surface_layer_list; 270 RenderSurfaceLayerList render_surface_layer_list;
269 271
270 layer_tree_host_->root_layer()->AddChild(layer); 272 layer_tree_host_->root_layer()->AddChild(layer);
271 273
272 // The tile size is 100x100, so this invalidates and then paints two tiles. 274 // The tile size is 100x100, so this invalidates and then paints two tiles.
273 layer->SetBounds(gfx::Size(100, 200)); 275 layer->SetBounds(gfx::Size(100, 200));
274 CalcDrawProps(&render_surface_layer_list); 276 CalcDrawProps(&render_surface_layer_list);
275 UpdateAndPush(layer, layer_impl); 277 UpdateAndPush(layer, layer_impl);
276 278
277 // We should have both tiles on the impl side. 279 // We should have both tiles on the impl side.
278 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); 280 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0));
279 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); 281 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1));
280 282
281 // Invalidates both tiles, but then only update one of them. 283 // Invalidates both tiles, but then only update one of them.
282 layer->InvalidateContentRect(gfx::Rect(0, 0, 100, 200)); 284 layer->InvalidateContentRect(gfx::Rect(0, 0, 100, 200));
283 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 285 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
284 UpdateAndPush(layer, layer_impl); 286 UpdateAndPush(layer, layer_impl);
285 287
286 // We should only have the first tile since the other tile was invalidated but 288 // We should only have the first tile since the other tile was invalidated but
287 // not painted. 289 // not painted.
288 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); 290 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0));
289 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); 291 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1));
290 } 292 }
291 293
292 TEST_F(TiledLayerTest, Scale) { 294 TEST_F(TiledLayerTest, Scale) {
295 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000));
296
293 layer_tree_host_->SetDeviceScaleFactor(1.5); 297 layer_tree_host_->SetDeviceScaleFactor(1.5);
294 298
295 scoped_refptr<FakeTiledLayer> layer = 299 scoped_refptr<FakeTiledLayer> layer =
296 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 300 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
297 scoped_ptr<FakeTiledLayerImpl> layer_impl = 301 scoped_ptr<FakeTiledLayerImpl> layer_impl =
298 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 302 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
299 RenderSurfaceLayerList render_surface_layer_list; 303 RenderSurfaceLayerList render_surface_layer_list;
300 304
301 layer_tree_host_->root_layer()->AddChild(layer); 305 layer_tree_host_->root_layer()->AddChild(layer);
302 306
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 UpdateAndPush(layer, layer_impl); 349 UpdateAndPush(layer, layer_impl);
346 350
347 // We should still have both tiles, as part of the top tile is still 351 // We should still have both tiles, as part of the top tile is still
348 // unoccluded. 352 // unoccluded.
349 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); 353 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0));
350 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); 354 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1));
351 } 355 }
352 } 356 }
353 357
354 TEST_F(TiledLayerTest, PushDeletedTiles) { 358 TEST_F(TiledLayerTest, PushDeletedTiles) {
359 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000));
360
355 scoped_refptr<FakeTiledLayer> layer = 361 scoped_refptr<FakeTiledLayer> layer =
356 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 362 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
357 scoped_ptr<FakeTiledLayerImpl> layer_impl = 363 scoped_ptr<FakeTiledLayerImpl> layer_impl =
358 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 364 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
359 RenderSurfaceLayerList render_surface_layer_list; 365 RenderSurfaceLayerList render_surface_layer_list;
360 366
361 layer_tree_host_->root_layer()->AddChild(layer); 367 layer_tree_host_->root_layer()->AddChild(layer);
362 368
363 // The tile size is 100x100, so this invalidates and then paints two tiles. 369 // The tile size is 100x100, so this invalidates and then paints two tiles.
364 layer->SetBounds(gfx::Size(100, 200)); 370 layer->SetBounds(gfx::Size(100, 200));
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 LayerPushPropertiesTo(layer.get(), layer_impl.get()); 1200 LayerPushPropertiesTo(layer.get(), layer_impl.get());
1195 } 1201 }
1196 layer_tree_host_->CommitComplete(); 1202 layer_tree_host_->CommitComplete();
1197 1203
1198 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), 1204 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(),
1199 resource_provider_.get()); 1205 resource_provider_.get());
1200 layer_tree_host_->SetRootLayer(nullptr); 1206 layer_tree_host_->SetRootLayer(nullptr);
1201 } 1207 }
1202 1208
1203 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { 1209 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) {
1210 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000));
1211
1204 scoped_refptr<FakeTiledLayer> layer = 1212 scoped_refptr<FakeTiledLayer> layer =
1205 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 1213 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
1206 RenderSurfaceLayerList render_surface_layer_list; 1214 RenderSurfaceLayerList render_surface_layer_list;
1207 1215
1208 layer_tree_host_->root_layer()->AddChild(layer); 1216 layer_tree_host_->root_layer()->AddChild(layer);
1209 1217
1210 // The tile size is 100x100, so this invalidates and then paints two tiles. 1218 // The tile size is 100x100, so this invalidates and then paints two tiles.
1211 layer->SetBounds(gfx::Size(100, 200)); 1219 layer->SetBounds(gfx::Size(100, 200));
1212 CalcDrawProps(&render_surface_layer_list); 1220 CalcDrawProps(&render_surface_layer_list);
1213 1221
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 1760
1753 // Rounding leads to an extra pixel. 1761 // Rounding leads to an extra pixel.
1754 gfx::Rect expanded_layer_rect(layer_rect); 1762 gfx::Rect expanded_layer_rect(layer_rect);
1755 expanded_layer_rect.set_height(32); 1763 expanded_layer_rect.set_height(32);
1756 EXPECT_RECT_EQ(expanded_layer_rect, 1764 EXPECT_RECT_EQ(expanded_layer_rect,
1757 layer->tracking_layer_painter()->PaintedRect()); 1765 layer->tracking_layer_painter()->PaintedRect());
1758 } 1766 }
1759 1767
1760 } // namespace 1768 } // namespace
1761 } // namespace cc 1769 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_unittest.cc ('k') | cc/output/begin_frame_args.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698