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

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

Issue 1007623002: Fix resourceless software draw (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: EXPECT_GE Created 5 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
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_unittest.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 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/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 7013 matching lines...) Expand 10 before | Expand all | Expand 10 after
7024 7024
7025 { 7025 {
7026 LayerImplList render_surface_layer_list; 7026 LayerImplList render_surface_layer_list;
7027 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root.get()); 7027 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root.get());
7028 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 7028 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7029 root.get(), root->bounds(), &render_surface_layer_list); 7029 root.get(), root->bounds(), &render_surface_layer_list);
7030 inputs.can_render_to_separate_surface = true; 7030 inputs.can_render_to_separate_surface = true;
7031 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 7031 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
7032 7032
7033 EXPECT_EQ(2u, render_surface_layer_list.size()); 7033 EXPECT_EQ(2u, render_surface_layer_list.size());
7034
7035 int count_represents_target_render_surface = 0;
7036 int count_represents_contributing_render_surface = 0;
7037 int count_represents_itself = 0;
7038 auto end = LayerIterator<LayerImpl>::End(&render_surface_layer_list);
7039 for (auto it = LayerIterator<LayerImpl>::Begin(&render_surface_layer_list);
7040 it != end; ++it) {
7041 if (it.represents_target_render_surface())
7042 count_represents_target_render_surface++;
7043 if (it.represents_contributing_render_surface())
7044 count_represents_contributing_render_surface++;
7045 if (it.represents_itself())
7046 count_represents_itself++;
7047 }
7048
7049 // Two render surfaces.
7050 EXPECT_EQ(2, count_represents_target_render_surface);
7051 // Second render surface contributes to root render surface.
7052 EXPECT_EQ(1, count_represents_contributing_render_surface);
7053 // All 4 layers represent itself.
7054 EXPECT_EQ(4, count_represents_itself);
7034 } 7055 }
7035 7056
7036 { 7057 {
7037 LayerImplList render_surface_layer_list; 7058 LayerImplList render_surface_layer_list;
7038 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 7059 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7039 root.get(), root->bounds(), &render_surface_layer_list); 7060 root.get(), root->bounds(), &render_surface_layer_list);
7040 inputs.can_render_to_separate_surface = false; 7061 inputs.can_render_to_separate_surface = false;
7041 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 7062 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
7042 7063
7043 EXPECT_EQ(1u, render_surface_layer_list.size()); 7064 EXPECT_EQ(1u, render_surface_layer_list.size());
7065
7066 int count_represents_target_render_surface = 0;
7067 int count_represents_contributing_render_surface = 0;
7068 int count_represents_itself = 0;
7069 auto end = LayerIterator<LayerImpl>::End(&render_surface_layer_list);
7070 for (auto it = LayerIterator<LayerImpl>::Begin(&render_surface_layer_list);
7071 it != end; ++it) {
7072 if (it.represents_target_render_surface())
7073 count_represents_target_render_surface++;
7074 if (it.represents_contributing_render_surface())
7075 count_represents_contributing_render_surface++;
7076 if (it.represents_itself())
7077 count_represents_itself++;
7078 }
7079
7080 // Only root layer has a render surface.
7081 EXPECT_EQ(1, count_represents_target_render_surface);
7082 // No layer contributes a render surface to root render surface.
7083 EXPECT_EQ(0, count_represents_contributing_render_surface);
7084 // All 4 layers represent itself.
7085 EXPECT_EQ(4, count_represents_itself);
7044 } 7086 }
7045 } 7087 }
7046 7088
7047 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { 7089 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) {
7048 scoped_refptr<Layer> root = Layer::Create(); 7090 scoped_refptr<Layer> root = Layer::Create();
7049 scoped_refptr<Layer> render_surface = Layer::Create(); 7091 scoped_refptr<Layer> render_surface = Layer::Create();
7050 scoped_refptr<LayerWithForcedDrawsContent> child = 7092 scoped_refptr<LayerWithForcedDrawsContent> child =
7051 make_scoped_refptr(new LayerWithForcedDrawsContent); 7093 make_scoped_refptr(new LayerWithForcedDrawsContent);
7052 7094
7053 root->AddChild(render_surface); 7095 root->AddChild(render_surface);
(...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after
8807 surface->AddChild(box); 8849 surface->AddChild(box);
8808 8850
8809 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 8851 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
8810 host->SetRootLayer(root); 8852 host->SetRootLayer(root);
8811 8853
8812 ExecuteCalculateDrawProperties(root.get()); 8854 ExecuteCalculateDrawProperties(root.get());
8813 } 8855 }
8814 8856
8815 } // namespace 8857 } // namespace
8816 } // namespace cc 8858 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698