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

Side by Side Diff: cc/blimp/compositor_state_deserializer_unittest.cc

Issue 2467043002: cc/blimp: Eliminate Layer updates for common cases. (Closed)
Patch Set: test update Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/blimp/layer_tree_host_remote.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "compositor_state_deserializer.h" 5 #include "compositor_state_deserializer.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "cc/animation/animation_host.h" 8 #include "cc/animation/animation_host.h"
9 #include "cc/blimp/client_picture_cache.h" 9 #include "cc/blimp/client_picture_cache.h"
10 #include "cc/blimp/compositor_proto_state.h" 10 #include "cc/blimp/compositor_proto_state.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 scroll_layer2->id())); 495 scroll_layer2->id()));
496 EXPECT_EQ(client_scroll_layer2->ScrollLayerId(), 496 EXPECT_EQ(client_scroll_layer2->ScrollLayerId(),
497 compositor_state_deserializer_ 497 compositor_state_deserializer_
498 ->GetLayerForEngineId(scroll_layer2->ScrollLayerId()) 498 ->GetLayerForEngineId(scroll_layer2->ScrollLayerId())
499 ->id()); 499 ->id());
500 EXPECT_EQ(client_scroll_layer2->orientation(), scroll_layer2->orientation()); 500 EXPECT_EQ(client_scroll_layer2->orientation(), scroll_layer2->orientation());
501 } 501 }
502 502
503 TEST_F(CompositorStateDeserializerTest, PictureLayer) { 503 TEST_F(CompositorStateDeserializerTest, PictureLayer) {
504 scoped_refptr<Layer> root_layer = Layer::Create(); 504 scoped_refptr<Layer> root_layer = Layer::Create();
505 root_layer->SetBounds(gfx::Size(10, 10));
506 root_layer->SetIsDrawable(true);
505 layer_tree_host_remote_->GetLayerTree()->SetRootLayer(root_layer); 507 layer_tree_host_remote_->GetLayerTree()->SetRootLayer(root_layer);
506 508
507 gfx::Size layer_size = gfx::Size(5, 5); 509 gfx::Size layer_size = gfx::Size(5, 5);
508 510
509 gfx::PointF offset(2.f, 3.f); 511 gfx::PointF offset(2.f, 3.f);
510 SkPictureRecorder recorder; 512 SkPictureRecorder recorder;
511 sk_sp<SkCanvas> canvas; 513 sk_sp<SkCanvas> canvas;
512 SkPaint red_paint; 514 SkPaint red_paint;
513 red_paint.setColor(SK_ColorRED); 515 red_paint.setColor(SK_ColorRED);
514 canvas = sk_ref_sp(recorder.beginRecording(SkRect::MakeXYWH( 516 canvas = sk_ref_sp(recorder.beginRecording(SkRect::MakeXYWH(
515 offset.x(), offset.y(), layer_size.width(), layer_size.height()))); 517 offset.x(), offset.y(), layer_size.width(), layer_size.height())));
516 canvas->translate(offset.x(), offset.y()); 518 canvas->translate(offset.x(), offset.y());
517 canvas->drawRectCoords(0.f, 0.f, 4.f, 4.f, red_paint); 519 canvas->drawRectCoords(0.f, 0.f, 4.f, 4.f, red_paint);
518 sk_sp<SkPicture> test_picture = recorder.finishRecordingAsPicture(); 520 sk_sp<SkPicture> test_picture = recorder.finishRecordingAsPicture();
519 521
520 DisplayItemListSettings settings; 522 DisplayItemListSettings settings;
521 settings.use_cached_picture = false; 523 settings.use_cached_picture = false;
522 scoped_refptr<DisplayItemList> display_list = 524 scoped_refptr<DisplayItemList> display_list =
523 DisplayItemList::Create(settings); 525 DisplayItemList::Create(settings);
524 const gfx::Rect visual_rect(0, 0, 42, 42); 526 const gfx::Rect visual_rect(0, 0, 42, 42);
525 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(visual_rect, 527 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(visual_rect,
526 test_picture); 528 test_picture);
527 display_list->Finalize(); 529 display_list->Finalize();
528 FakeContentLayerClient content_client(display_list, gfx::Rect(layer_size)); 530 FakeContentLayerClient content_client(display_list, gfx::Rect(layer_size));
529 531
530 scoped_refptr<PictureLayer> picture_layer = 532 scoped_refptr<PictureLayer> picture_layer =
531 PictureLayer::Create(&content_client); 533 PictureLayer::Create(&content_client);
532 picture_layer->SetBounds(layer_size); 534 picture_layer->SetBounds(layer_size);
535 picture_layer->SetIsDrawable(true);
533 root_layer->AddChild(picture_layer); 536 root_layer->AddChild(picture_layer);
534 537
535 // Synchronize State and verify. 538 // Synchronize State and verify.
536 base::RunLoop().RunUntilIdle(); 539 base::RunLoop().RunUntilIdle();
537 VerifyTreesAreIdentical(); 540 VerifyTreesAreIdentical();
538 541
539 // Verify PictureLayer. 542 // Verify PictureLayer.
540 PictureLayer* client_picture_layer = static_cast<PictureLayer*>( 543 PictureLayer* client_picture_layer = static_cast<PictureLayer*>(
541 compositor_state_deserializer_->GetLayerForEngineId(picture_layer->id())); 544 compositor_state_deserializer_->GetLayerForEngineId(picture_layer->id()));
542 scoped_refptr<DisplayItemList> client_display_list = 545 scoped_refptr<DisplayItemList> client_display_list =
543 client_picture_layer->client()->PaintContentsToDisplayList( 546 client_picture_layer->client()->PaintContentsToDisplayList(
544 ContentLayerClient::PaintingControlSetting::PAINTING_BEHAVIOR_NORMAL); 547 ContentLayerClient::PaintingControlSetting::PAINTING_BEHAVIOR_NORMAL);
545 EXPECT_TRUE(AreDisplayListDrawingResultsSame( 548 EXPECT_TRUE(AreDisplayListDrawingResultsSame(
546 gfx::Rect(layer_size), display_list.get(), client_display_list.get())); 549 gfx::Rect(layer_size), display_list.get(), client_display_list.get()));
547 550
548 // Now attach new layer with the same DisplayList. 551 // Now attach new layer with the same DisplayList.
549 scoped_refptr<PictureLayer> picture_layer2 = 552 scoped_refptr<PictureLayer> picture_layer2 =
550 PictureLayer::Create(&content_client); 553 PictureLayer::Create(&content_client);
551 picture_layer->SetBounds(layer_size); 554 picture_layer2->SetBounds(layer_size);
555 picture_layer2->SetIsDrawable(true);
552 root_layer->AddChild(picture_layer2); 556 root_layer->AddChild(picture_layer2);
553 557
554 // Synchronize State and verify. 558 // Synchronize State and verify.
555 base::RunLoop().RunUntilIdle(); 559 base::RunLoop().RunUntilIdle();
556 VerifyTreesAreIdentical(); 560 VerifyTreesAreIdentical();
557 561
558 // Verify PictureLayer2. 562 // Verify PictureLayer2.
559 PictureLayer* client_picture_layer2 = static_cast<PictureLayer*>( 563 PictureLayer* client_picture_layer2 = static_cast<PictureLayer*>(
560 compositor_state_deserializer_->GetLayerForEngineId( 564 compositor_state_deserializer_->GetLayerForEngineId(
561 picture_layer2->id())); 565 picture_layer2->id()));
562 scoped_refptr<DisplayItemList> client_display_list2 = 566 scoped_refptr<DisplayItemList> client_display_list2 =
563 client_picture_layer2->client()->PaintContentsToDisplayList( 567 client_picture_layer2->client()->PaintContentsToDisplayList(
564 ContentLayerClient::PaintingControlSetting::PAINTING_BEHAVIOR_NORMAL); 568 ContentLayerClient::PaintingControlSetting::PAINTING_BEHAVIOR_NORMAL);
565 EXPECT_TRUE(AreDisplayListDrawingResultsSame( 569 EXPECT_TRUE(AreDisplayListDrawingResultsSame(
566 gfx::Rect(layer_size), display_list.get(), client_display_list2.get())); 570 gfx::Rect(layer_size), display_list.get(), client_display_list2.get()));
567 } 571 }
568 572
569 } // namespace 573 } // namespace
570 } // namespace cc 574 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/blimp/layer_tree_host_remote.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698