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

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

Issue 915083004: cc: Make occlusion a draw property. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: occlusiondrawproperty: earlyoutloop Created 5 years, 10 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/occlusion.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/occlusion_tracker.h" 5 #include "cc/trees/occlusion_tracker.h"
6 6
7 #include "cc/animation/layer_animation_controller.h" 7 #include "cc/animation/layer_animation_controller.h"
8 #include "cc/base/math_util.h" 8 #include "cc/base/math_util.h"
9 #include "cc/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/layers/layer_impl.h" 10 #include "cc/layers/layer_impl.h"
(...skipping 2654 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 ASSERT_LT(i, actual_occlusion.GetRegionComplexity()); 2665 ASSERT_LT(i, actual_occlusion.GetRegionComplexity());
2666 EXPECT_EQ(expected_occlusion.GetRect(i), actual_occlusion.GetRect(i)); 2666 EXPECT_EQ(expected_occlusion.GetRect(i), actual_occlusion.GetRect(i));
2667 } 2667 }
2668 } 2668 }
2669 }; 2669 };
2670 2670
2671 ALL_OCCLUSIONTRACKER_TEST( 2671 ALL_OCCLUSIONTRACKER_TEST(
2672 OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded); 2672 OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded);
2673 2673
2674 template <class Types> 2674 template <class Types>
2675 class OcclusionTrackerTestBlendModeDoesNotOcclude
2676 : public OcclusionTrackerTest<Types> {
2677 protected:
2678 explicit OcclusionTrackerTestBlendModeDoesNotOcclude(bool opaque_layers)
2679 : OcclusionTrackerTest<Types>(opaque_layers) {}
2680 void RunMyTest() override {
2681 typename Types::ContentLayerType* parent = this->CreateRoot(
2682 this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
2683 typename Types::LayerType* blend_mode_layer = this->CreateDrawingLayer(
2684 parent, this->identity_matrix, gfx::PointF(0.f, 0.f),
2685 gfx::Size(100, 100), true);
2686 typename Types::LayerType* top_layer = this->CreateDrawingLayer(
2687 parent, this->identity_matrix, gfx::PointF(10.f, 12.f),
2688 gfx::Size(20, 22), true);
2689
2690 // Blend mode makes the layer own a surface.
2691 Types::SetForceRenderSurface(blend_mode_layer, true);
2692 blend_mode_layer->SetBlendMode(SkXfermode::kMultiply_Mode);
2693
2694 this->CalcDrawEtc(parent);
2695
2696 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
2697 gfx::Rect(0, 0, 1000, 1000));
2698
2699 this->VisitLayer(top_layer, &occlusion);
2700 // |top_layer| occludes.
2701 EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(),
2702 occlusion.occlusion_from_inside_target().ToString());
2703 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
2704
2705 this->VisitLayer(blend_mode_layer, &occlusion);
2706 // |top_layer| occludes but not |blend_mode_layer|.
2707 EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(),
2708 occlusion.occlusion_from_outside_target().ToString());
2709 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
2710
2711 this->VisitContributingSurface(blend_mode_layer, &occlusion);
2712 // |top_layer| occludes but not |blend_mode_layer|.
2713 EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(),
2714 occlusion.occlusion_from_inside_target().ToString());
2715 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
2716 }
2717 };
2718
2719 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestBlendModeDoesNotOcclude);
2720
2721 template <class Types>
2675 class OcclusionTrackerTestMinimumTrackingSize 2722 class OcclusionTrackerTestMinimumTrackingSize
2676 : public OcclusionTrackerTest<Types> { 2723 : public OcclusionTrackerTest<Types> {
2677 protected: 2724 protected:
2678 explicit OcclusionTrackerTestMinimumTrackingSize(bool opaque_layers) 2725 explicit OcclusionTrackerTestMinimumTrackingSize(bool opaque_layers)
2679 : OcclusionTrackerTest<Types>(opaque_layers) {} 2726 : OcclusionTrackerTest<Types>(opaque_layers) {}
2680 void RunMyTest() override { 2727 void RunMyTest() override {
2681 gfx::Size tracking_size(100, 100); 2728 gfx::Size tracking_size(100, 100);
2682 gfx::Size below_tracking_size(99, 99); 2729 gfx::Size below_tracking_size(99, 99);
2683 2730
2684 typename Types::ContentLayerType* parent = this->CreateRoot( 2731 typename Types::ContentLayerType* parent = this->CreateRoot(
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2810 this->identity_matrix, 2857 this->identity_matrix,
2811 gfx::Point(100, 0), 2858 gfx::Point(100, 0),
2812 gfx::Size(200, 400)); 2859 gfx::Size(200, 400));
2813 this->AddCopyRequest(copy); 2860 this->AddCopyRequest(copy);
2814 typename Types::LayerType* copy_child = this->CreateDrawingLayer( 2861 typename Types::LayerType* copy_child = this->CreateDrawingLayer(
2815 copy, 2862 copy,
2816 this->identity_matrix, 2863 this->identity_matrix,
2817 gfx::PointF(), 2864 gfx::PointF(),
2818 gfx::Size(200, 400), 2865 gfx::Size(200, 400),
2819 true); 2866 true);
2867 typename Types::LayerType* top_layer =
2868 this->CreateDrawingLayer(root, this->identity_matrix,
2869 gfx::PointF(50, 0), gfx::Size(50, 400), true);
2820 this->CalcDrawEtc(root); 2870 this->CalcDrawEtc(root);
2821 2871
2822 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( 2872 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
2823 gfx::Rect(0, 0, 1000, 1000)); 2873 gfx::Rect(0, 0, 1000, 1000));
2824 2874
2875 this->VisitLayer(top_layer, &occlusion);
2876 EXPECT_EQ(gfx::Rect().ToString(),
2877 occlusion.occlusion_from_outside_target().ToString());
2878 EXPECT_EQ(gfx::Rect(50, 0, 50, 400).ToString(),
2879 occlusion.occlusion_from_inside_target().ToString());
2880
2825 this->VisitLayer(copy_child, &occlusion); 2881 this->VisitLayer(copy_child, &occlusion);
2882 // Layers outside the copy request do not occlude.
2826 EXPECT_EQ(gfx::Rect().ToString(), 2883 EXPECT_EQ(gfx::Rect().ToString(),
2827 occlusion.occlusion_from_outside_target().ToString()); 2884 occlusion.occlusion_from_outside_target().ToString());
2828 EXPECT_EQ(gfx::Rect(200, 400).ToString(), 2885 EXPECT_EQ(gfx::Rect(200, 400).ToString(),
2829 occlusion.occlusion_from_inside_target().ToString()); 2886 occlusion.occlusion_from_inside_target().ToString());
2830 2887
2831 // CopyRequests cause the layer to own a surface. 2888 // CopyRequests cause the layer to own a surface.
2832 this->VisitContributingSurface(copy, &occlusion); 2889 this->VisitContributingSurface(copy, &occlusion);
2833 2890
2834 // The occlusion from the copy should be kept. 2891 // The occlusion from the copy should be kept.
2835 EXPECT_EQ(gfx::Rect().ToString(), 2892 EXPECT_EQ(gfx::Rect().ToString(),
2836 occlusion.occlusion_from_outside_target().ToString()); 2893 occlusion.occlusion_from_outside_target().ToString());
2837 EXPECT_EQ(gfx::Rect(100, 0, 200, 400).ToString(), 2894 EXPECT_EQ(gfx::Rect(50, 0, 250, 400).ToString(),
2838 occlusion.occlusion_from_inside_target().ToString()); 2895 occlusion.occlusion_from_inside_target().ToString());
2839 } 2896 }
2840 }; 2897 };
2841 2898
2842 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestCopyRequestDoesOcclude) 2899 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestCopyRequestDoesOcclude)
2843 2900
2844 template <class Types> 2901 template <class Types>
2845 class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude 2902 class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude
2846 : public OcclusionTrackerTest<Types> { 2903 : public OcclusionTrackerTest<Types> {
2847 protected: 2904 protected:
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
3316 EXPECT_EQ(gfx::Rect(), 3373 EXPECT_EQ(gfx::Rect(),
3317 occlusion.UnoccludedSurfaceContentRect( 3374 occlusion.UnoccludedSurfaceContentRect(
3318 surface, gfx::Rect(80, 70, 50, 50))); 3375 surface, gfx::Rect(80, 70, 50, 50)));
3319 } 3376 }
3320 }; 3377 };
3321 3378
3322 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) 3379 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery)
3323 3380
3324 } // namespace 3381 } // namespace
3325 } // namespace cc 3382 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/occlusion.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698