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

Side by Side Diff: cc/trees/layer_tree_host_unittest_picture.cc

Issue 2390923002: Fix blurry content after disabling dev tools emulation (Closed)
Patch Set: Add function for LayerTreeHostRemote Created 4 years, 2 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/trees/layer_tree_host_in_process.cc ('k') | cc/trees/layer_tree_impl.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 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "cc/test/fake_content_layer_client.h" 7 #include "cc/test/fake_content_layer_client.h"
8 #include "cc/test/fake_picture_layer.h" 8 #include "cc/test/fake_picture_layer.h"
9 #include "cc/test/fake_picture_layer_impl.h" 9 #include "cc/test/fake_picture_layer_impl.h"
10 #include "cc/test/layer_tree_test.h" 10 #include "cc/test/layer_tree_test.h"
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 int frame_; 569 int frame_;
570 int draws_in_frame_; 570 int draws_in_frame_;
571 int last_frame_drawn_; 571 int last_frame_drawn_;
572 bool ready_to_draw_; 572 bool ready_to_draw_;
573 }; 573 };
574 574
575 // Multi-thread only because in single thread you can't pinch zoom on the 575 // Multi-thread only because in single thread you can't pinch zoom on the
576 // compositor thread. 576 // compositor thread.
577 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); 577 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale);
578 578
579 class LayerTreeHostPictureTestForceRecalculateScales
580 : public LayerTreeHostPictureTest {
581 void SetupTree() override {
582 gfx::Size size(100, 100);
583 scoped_refptr<Layer> root = Layer::Create();
584 root->SetBounds(size);
585
586 will_change_layer_ = FakePictureLayer::Create(&client_);
587 will_change_layer_->SetHasWillChangeTransformHint(true);
588 will_change_layer_->SetBounds(size);
589 root->AddChild(will_change_layer_);
590
591 normal_layer_ = FakePictureLayer::Create(&client_);
592 normal_layer_->SetBounds(size);
593 root->AddChild(normal_layer_);
594
595 layer_tree()->SetRootLayer(root);
596 layer_tree()->SetViewportSize(size);
597
598 client_.set_fill_with_nonsolid_color(true);
599 client_.set_bounds(size);
600 }
601
602 void InitializeSettings(LayerTreeSettings* settings) override {
603 settings->layer_transforms_should_scale_layer_contents = true;
604 }
605
606 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
607
608 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
609 FakePictureLayerImpl* will_change_layer =
610 static_cast<FakePictureLayerImpl*>(
611 impl->active_tree()->LayerById(will_change_layer_->id()));
612 FakePictureLayerImpl* normal_layer = static_cast<FakePictureLayerImpl*>(
613 impl->active_tree()->LayerById(normal_layer_->id()));
614
615 switch (impl->sync_tree()->source_frame_number()) {
616 case 0:
617 // On first commit, both layers are at the default scale.
618 ASSERT_EQ(1u, will_change_layer->tilings()->num_tilings());
619 EXPECT_EQ(1.f,
620 will_change_layer->tilings()->tiling_at(0)->contents_scale());
621 ASSERT_EQ(1u, normal_layer->tilings()->num_tilings());
622 EXPECT_EQ(1.f, normal_layer->tilings()->tiling_at(0)->contents_scale());
623
624 MainThreadTaskRunner()->PostTask(
625 FROM_HERE,
626 base::Bind(
627 &LayerTreeHostPictureTestForceRecalculateScales::ScaleRootUp,
628 base::Unretained(this)));
629 break;
630 case 1:
631 // On 2nd commit after scaling up to 2, the normal layer will adjust its
632 // scale and the will change layer should not (as it is will change.
633 ASSERT_EQ(1u, will_change_layer->tilings()->num_tilings());
634 EXPECT_EQ(1.f,
635 will_change_layer->tilings()->tiling_at(0)->contents_scale());
636 ASSERT_EQ(1u, normal_layer->tilings()->num_tilings());
637 EXPECT_EQ(2.f, normal_layer->tilings()->tiling_at(0)->contents_scale());
638
639 MainThreadTaskRunner()->PostTask(
640 FROM_HERE,
641 base::Bind(&LayerTreeHostPictureTestForceRecalculateScales::
642 ScaleRootUpAndRecalculateScales,
643 base::Unretained(this)));
644 break;
645 case 2:
646 // On 3rd commit, both layers should adjust scales due to forced
647 // recalculating.
648 ASSERT_EQ(1u, will_change_layer->tilings()->num_tilings());
649 EXPECT_EQ(4.f,
650 will_change_layer->tilings()->tiling_at(0)->contents_scale());
651 ASSERT_EQ(1u, normal_layer->tilings()->num_tilings());
652 EXPECT_EQ(4.f, normal_layer->tilings()->tiling_at(0)->contents_scale());
653 EndTest();
654 break;
655 }
656 }
657
658 void ScaleRootUp() {
659 gfx::Transform transform;
660 transform.Scale(2, 2);
661 layer_tree_host()->GetLayerTree()->root_layer()->SetTransform(transform);
662 }
663
664 void ScaleRootUpAndRecalculateScales() {
665 gfx::Transform transform;
666 transform.Scale(4, 4);
667 layer_tree_host()->GetLayerTree()->root_layer()->SetTransform(transform);
668 layer_tree_host()->SetNeedsRecalculateRasterScales();
669 }
670
671 void AfterTest() override {}
672
673 scoped_refptr<FakePictureLayer> will_change_layer_;
674 scoped_refptr<FakePictureLayer> normal_layer_;
675 };
676
677 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostPictureTestForceRecalculateScales);
678
579 } // namespace 679 } // namespace
580 } // namespace cc 680 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_in_process.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698