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

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

Issue 12676029: cc: Fix capitalization style in chromified files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
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 "cc/layers/picture_layer.h" 7 #include "cc/layers/picture_layer.h"
8 #include "cc/test/fake_content_layer_client.h" 8 #include "cc/test/fake_content_layer_client.h"
9 #include "cc/test/fake_impl_proxy.h" 9 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 131
132 FakeContentLayerClient client_; 132 FakeContentLayerClient client_;
133 }; 133 };
134 134
135 class MockCanvas : public SkCanvas { 135 class MockCanvas : public SkCanvas {
136 public: 136 public:
137 explicit MockCanvas(SkDevice* device) : SkCanvas(device) {} 137 explicit MockCanvas(SkDevice* device) : SkCanvas(device) {}
138 138
139 virtual void drawRect(const SkRect& rect, const SkPaint& paint) OVERRIDE { 139 virtual void drawRect(const SkRect& rect, const SkPaint& paint) OVERRIDE {
140 // Capture calls before SkCanvas quickReject kicks in 140 // Capture calls before SkCanvas quickReject() kicks in.
141 rects_.push_back(rect); 141 rects_.push_back(rect);
142 } 142 }
143 143
144 std::vector<SkRect> rects_; 144 std::vector<SkRect> rects_;
145 }; 145 };
146 146
147 class PictureLayerImplTest : public testing::Test { 147 class PictureLayerImplTest : public testing::Test {
148 public: 148 public:
149 PictureLayerImplTest() 149 PictureLayerImplTest()
150 : host_impl_(ImplSidePaintingSettings(), &proxy_), 150 : host_impl_(ImplSidePaintingSettings(), &proxy_),
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 active_pile->add_draw_rect(rect); 246 active_pile->add_draw_rect(rect);
247 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); 247 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1));
248 } 248 }
249 // Force re-record with newly injected content 249 // Force re-record with newly injected content
250 active_pile->RemoveRecordingAt(0, 0); 250 active_pile->RemoveRecordingAt(0, 0);
251 active_pile->AddRecordingAt(0, 0); 251 active_pile->AddRecordingAt(0, 0);
252 252
253 SkBitmap store; 253 SkBitmap store;
254 store.setConfig(SkBitmap::kNo_Config, 1000, 1000); 254 store.setConfig(SkBitmap::kNo_Config, 1000, 1000);
255 SkDevice device(store); 255 SkDevice device(store);
256 int64 pixelsRasterized; 256 int64 pixels_rasterized;
257 257
258 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); 258 std::vector<SkRect>::const_iterator rect_iter = rects.begin();
259 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { 259 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) {
260 MockCanvas mock_canvas(&device); 260 MockCanvas mock_canvas(&device);
261 active_pile->Raster(&mock_canvas, (*tile_iter)->content_rect(), 261 active_pile->Raster(&mock_canvas, (*tile_iter)->content_rect(),
262 1.0f, &pixelsRasterized); 262 1.0f, &pixels_rasterized);
263 263
264 // This test verifies that when drawing the contents of a specific tile 264 // This test verifies that when drawing the contents of a specific tile
265 // at content scale 1.0, the playback canvas never receives content from 265 // at content scale 1.0, the playback canvas never receives content from
266 // neighboring tiles which indicates that the tile grid embedded in 266 // neighboring tiles which indicates that the tile grid embedded in
267 // SkPicture is perfectly aligned with the compositor's tiles. 267 // SkPicture is perfectly aligned with the compositor's tiles.
268 // Note: There are two rects: the initial clear and the explicitly 268 // Note: There are two rects: the initial clear and the explicitly
269 // recorded rect. We only care about the second one. 269 // recorded rect. We only care about the second one.
270 EXPECT_EQ(2, mock_canvas.rects_.size()); 270 EXPECT_EQ(2, mock_canvas.rects_.size());
271 EXPECT_EQ(*rect_iter, mock_canvas.rects_[1]); 271 EXPECT_EQ(*rect_iter, mock_canvas.rects_[1]);
272 rect_iter++; 272 rect_iter++;
273 } 273 }
274 } 274 }
275 275
276 FakeImplProxy proxy_; 276 FakeImplProxy proxy_;
277 FakeLayerTreeHostImpl host_impl_; 277 FakeLayerTreeHostImpl host_impl_;
278 int id_; 278 int id_;
279 TestablePictureLayerImpl* pending_layer_; 279 TestablePictureLayerImpl* pending_layer_;
280 TestablePictureLayerImpl* active_layer_; 280 TestablePictureLayerImpl* active_layer_;
281 281
282 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); 282 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest);
283 }; 283 };
284 284
285 TEST_F(PictureLayerImplTest, tileGridAlignment) { 285 TEST_F(PictureLayerImplTest, TileGridAlignment) {
286 host_impl_.SetDeviceScaleFactor(1.f); 286 host_impl_.SetDeviceScaleFactor(1.f);
287 TestTileGridAlignmentCommon(); 287 TestTileGridAlignmentCommon();
288 } 288 }
289 289
290 TEST_F(PictureLayerImplTest, tileGridAlignmentHiDPI) { 290 TEST_F(PictureLayerImplTest, TileGridAlignmentHiDPI) {
291 host_impl_.SetDeviceScaleFactor(2.f); 291 host_impl_.SetDeviceScaleFactor(2.f);
292 TestTileGridAlignmentCommon(); 292 TestTileGridAlignmentCommon();
293 } 293 }
294 294
295 TEST_F(PictureLayerImplTest, cloneNoInvalidation) { 295 TEST_F(PictureLayerImplTest, CloneNoInvalidation) {
296 gfx::Size tile_size(100, 100); 296 gfx::Size tile_size(100, 100);
297 gfx::Size layer_bounds(400, 400); 297 gfx::Size layer_bounds(400, 400);
298 298
299 scoped_refptr<TestablePicturePileImpl> pending_pile = 299 scoped_refptr<TestablePicturePileImpl> pending_pile =
300 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 300 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
301 scoped_refptr<TestablePicturePileImpl> active_pile = 301 scoped_refptr<TestablePicturePileImpl> active_pile =
302 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 302 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
303 303
304 SetupTrees(pending_pile, active_pile); 304 SetupTrees(pending_pile, active_pile);
305 305
306 Region invalidation; 306 Region invalidation;
307 AddDefaultTilingsWithInvalidation(invalidation); 307 AddDefaultTilingsWithInvalidation(invalidation);
308 308
309 EXPECT_EQ(pending_layer_->tilings().num_tilings(), 309 EXPECT_EQ(pending_layer_->tilings().num_tilings(),
310 active_layer_->tilings().num_tilings()); 310 active_layer_->tilings().num_tilings());
311 311
312 const PictureLayerTilingSet& tilings = pending_layer_->tilings(); 312 const PictureLayerTilingSet& tilings = pending_layer_->tilings();
313 EXPECT_GT(tilings.num_tilings(), 0u); 313 EXPECT_GT(tilings.num_tilings(), 0u);
314 for (size_t i = 0; i < tilings.num_tilings(); ++i) 314 for (size_t i = 0; i < tilings.num_tilings(); ++i)
315 VerifyAllTilesExistAndHavePile(tilings.tiling_at(i), active_pile.get()); 315 VerifyAllTilesExistAndHavePile(tilings.tiling_at(i), active_pile.get());
316 } 316 }
317 317
318 TEST_F(PictureLayerImplTest, clonePartialInvalidation) { 318 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) {
319 gfx::Size tile_size(100, 100); 319 gfx::Size tile_size(100, 100);
320 gfx::Size layer_bounds(400, 400); 320 gfx::Size layer_bounds(400, 400);
321 gfx::Rect layer_invalidation(150, 200, 30, 180); 321 gfx::Rect layer_invalidation(150, 200, 30, 180);
322 322
323 scoped_refptr<TestablePicturePileImpl> pending_pile = 323 scoped_refptr<TestablePicturePileImpl> pending_pile =
324 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 324 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
325 scoped_refptr<TestablePicturePileImpl> active_pile = 325 scoped_refptr<TestablePicturePileImpl> active_pile =
326 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 326 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
327 327
328 SetupTrees(pending_pile, active_pile); 328 SetupTrees(pending_pile, active_pile);
(...skipping 17 matching lines...) Expand all
346 EXPECT_TRUE(*iter); 346 EXPECT_TRUE(*iter);
347 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); 347 EXPECT_FALSE(iter.geometry_rect().IsEmpty());
348 if (iter.geometry_rect().Intersects(content_invalidation)) 348 if (iter.geometry_rect().Intersects(content_invalidation))
349 EXPECT_EQ(pending_pile, iter->picture_pile()); 349 EXPECT_EQ(pending_pile, iter->picture_pile());
350 else 350 else
351 EXPECT_EQ(active_pile, iter->picture_pile()); 351 EXPECT_EQ(active_pile, iter->picture_pile());
352 } 352 }
353 } 353 }
354 } 354 }
355 355
356 TEST_F(PictureLayerImplTest, cloneFullInvalidation) { 356 TEST_F(PictureLayerImplTest, CloneFullInvalidation) {
357 gfx::Size tile_size(90, 80); 357 gfx::Size tile_size(90, 80);
358 gfx::Size layer_bounds(300, 500); 358 gfx::Size layer_bounds(300, 500);
359 359
360 scoped_refptr<TestablePicturePileImpl> pending_pile = 360 scoped_refptr<TestablePicturePileImpl> pending_pile =
361 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 361 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
362 scoped_refptr<TestablePicturePileImpl> active_pile = 362 scoped_refptr<TestablePicturePileImpl> active_pile =
363 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 363 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
364 364
365 SetupTrees(pending_pile, active_pile); 365 SetupTrees(pending_pile, active_pile);
366 366
367 Region invalidation((gfx::Rect(layer_bounds))); 367 Region invalidation((gfx::Rect(layer_bounds)));
368 AddDefaultTilingsWithInvalidation(invalidation); 368 AddDefaultTilingsWithInvalidation(invalidation);
369 369
370 EXPECT_EQ(pending_layer_->tilings().num_tilings(), 370 EXPECT_EQ(pending_layer_->tilings().num_tilings(),
371 active_layer_->tilings().num_tilings()); 371 active_layer_->tilings().num_tilings());
372 372
373 const PictureLayerTilingSet& tilings = pending_layer_->tilings(); 373 const PictureLayerTilingSet& tilings = pending_layer_->tilings();
374 EXPECT_GT(tilings.num_tilings(), 0u); 374 EXPECT_GT(tilings.num_tilings(), 0u);
375 for (size_t i = 0; i < tilings.num_tilings(); ++i) 375 for (size_t i = 0; i < tilings.num_tilings(); ++i)
376 VerifyAllTilesExistAndHavePile(tilings.tiling_at(i), pending_pile.get()); 376 VerifyAllTilesExistAndHavePile(tilings.tiling_at(i), pending_pile.get());
377 } 377 }
378 378
379 TEST_F(PictureLayerImplTest, noInvalidationBoundsChange) { 379 TEST_F(PictureLayerImplTest, NoInvalidationBoundsChange) {
380 gfx::Size tile_size(90, 80); 380 gfx::Size tile_size(90, 80);
381 gfx::Size active_layer_bounds(300, 500); 381 gfx::Size active_layer_bounds(300, 500);
382 gfx::Size pending_layer_bounds(400, 800); 382 gfx::Size pending_layer_bounds(400, 800);
383 383
384 scoped_refptr<TestablePicturePileImpl> pending_pile = 384 scoped_refptr<TestablePicturePileImpl> pending_pile =
385 TestablePicturePileImpl::CreateFilledPile(tile_size, 385 TestablePicturePileImpl::CreateFilledPile(tile_size,
386 pending_layer_bounds); 386 pending_layer_bounds);
387 scoped_refptr<TestablePicturePileImpl> active_pile = 387 scoped_refptr<TestablePicturePileImpl> active_pile =
388 TestablePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); 388 TestablePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds);
389 389
(...skipping 20 matching lines...) Expand all
410 if (iter.geometry_rect().right() >= active_content_bounds.width() || 410 if (iter.geometry_rect().right() >= active_content_bounds.width() ||
411 iter.geometry_rect().bottom() >= active_content_bounds.height()) { 411 iter.geometry_rect().bottom() >= active_content_bounds.height()) {
412 EXPECT_EQ(pending_pile, iter->picture_pile()); 412 EXPECT_EQ(pending_pile, iter->picture_pile());
413 } else { 413 } else {
414 EXPECT_EQ(active_pile, iter->picture_pile()); 414 EXPECT_EQ(active_pile, iter->picture_pile());
415 } 415 }
416 } 416 }
417 } 417 }
418 } 418 }
419 419
420 TEST_F(PictureLayerImplTest, addTilesFromNewRecording) { 420 TEST_F(PictureLayerImplTest, AddTilesFromNewRecording) {
421 gfx::Size tile_size(400, 400); 421 gfx::Size tile_size(400, 400);
422 gfx::Size layer_bounds(1300, 1900); 422 gfx::Size layer_bounds(1300, 1900);
423 423
424 scoped_refptr<TestablePicturePileImpl> pending_pile = 424 scoped_refptr<TestablePicturePileImpl> pending_pile =
425 TestablePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 425 TestablePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
426 scoped_refptr<TestablePicturePileImpl> active_pile = 426 scoped_refptr<TestablePicturePileImpl> active_pile =
427 TestablePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 427 TestablePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
428 428
429 // Fill in some of active pile, but more of pending pile. 429 // Fill in some of active pile, but more of pending pile.
430 int hole_count = 0; 430 int hole_count = 0;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 used_tilings.push_back(active_layer_->tilings().tiling_at(1)); 693 used_tilings.push_back(active_layer_->tilings().tiling_at(1));
694 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); 694 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
695 ASSERT_EQ(3u, active_layer_->tilings().num_tilings()); 695 ASSERT_EQ(3u, active_layer_->tilings().num_tilings());
696 used_tilings.clear(); 696 used_tilings.clear();
697 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); 697 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
698 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); 698 ASSERT_EQ(2u, active_layer_->tilings().num_tilings());
699 } 699 }
700 700
701 } // namespace 701 } // namespace
702 } // namespace cc 702 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698