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

Side by Side Diff: trunk/src/cc/layers/delegated_renderer_layer_impl_unittest.cc

Issue 13334005: Revert 191400 "cc: Add ‘chromium_code’: 1 to cc.gyp and cc_t..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 8 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 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/layers/delegated_renderer_layer_impl.h" 5 #include "cc/layers/delegated_renderer_layer_impl.h"
6 6
7 #include "cc/base/scoped_ptr_vector.h" 7 #include "cc/base/scoped_ptr_vector.h"
8 #include "cc/layers/append_quads_data.h" 8 #include "cc/layers/append_quads_data.h"
9 #include "cc/layers/quad_sink.h" 9 #include "cc/layers/quad_sink.h"
10 #include "cc/layers/solid_color_layer_impl.h" 10 #include "cc/layers/solid_color_layer_impl.h"
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame)); 1014 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame));
1015 1015
1016 ASSERT_EQ(2u, frame.render_passes.size()); 1016 ASSERT_EQ(2u, frame.render_passes.size());
1017 const QuadList& contrib_delegated_quad_list = 1017 const QuadList& contrib_delegated_quad_list =
1018 frame.render_passes[0]->quad_list; 1018 frame.render_passes[0]->quad_list;
1019 ASSERT_EQ(2u, contrib_delegated_quad_list.size()); 1019 ASSERT_EQ(2u, contrib_delegated_quad_list.size());
1020 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list; 1020 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list;
1021 ASSERT_EQ(5u, root_delegated_quad_list.size()); 1021 ASSERT_EQ(5u, root_delegated_quad_list.size());
1022 const SharedQuadState* root_delegated_shared_quad_state = 1022 const SharedQuadState* root_delegated_shared_quad_state =
1023 root_delegated_quad_list[0]->shared_quad_state; 1023 root_delegated_quad_list[0]->shared_quad_state;
1024 const SharedQuadState* contrib_delegated_shared_quad_state =
1025 contrib_delegated_quad_list[0]->shared_quad_state;
1024 1026
1025 // When the quads don't have a clip of their own, the clip rect is set to 1027 // When the quads don't have a clip of their own, the clip rect is set to
1026 // the drawable_content_rect of the delegated renderer layer. 1028 // the drawable_content_rect of the delegated renderer layer.
1027 EXPECT_EQ(gfx::Rect(20, 20, 50, 50).ToString(), 1029 EXPECT_EQ(gfx::Rect(20, 20, 50, 50).ToString(),
1028 root_delegated_shared_quad_state->clip_rect.ToString()); 1030 root_delegated_shared_quad_state->clip_rect.ToString());
1029 // Quads are clipped to the delegated renderer layer. 1031 // Quads are clipped to the delegated renderer layer.
1030 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); 1032 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped);
1031 1033
1032 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1034 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
1033 host_impl_->DidDrawAllLayers(frame); 1035 host_impl_->DidDrawAllLayers(frame);
(...skipping 10 matching lines...) Expand all
1044 1046
1045 ASSERT_EQ(2u, frame.render_passes.size()); 1047 ASSERT_EQ(2u, frame.render_passes.size());
1046 const QuadList& contrib_delegated_quad_list = 1048 const QuadList& contrib_delegated_quad_list =
1047 frame.render_passes[0]->quad_list; 1049 frame.render_passes[0]->quad_list;
1048 ASSERT_EQ(2u, contrib_delegated_quad_list.size()); 1050 ASSERT_EQ(2u, contrib_delegated_quad_list.size());
1049 const QuadList& root_delegated_quad_list = 1051 const QuadList& root_delegated_quad_list =
1050 frame.render_passes[1]->quad_list; 1052 frame.render_passes[1]->quad_list;
1051 ASSERT_EQ(5u, root_delegated_quad_list.size()); 1053 ASSERT_EQ(5u, root_delegated_quad_list.size());
1052 const SharedQuadState* root_delegated_shared_quad_state = 1054 const SharedQuadState* root_delegated_shared_quad_state =
1053 root_delegated_quad_list[0]->shared_quad_state; 1055 root_delegated_quad_list[0]->shared_quad_state;
1056 const SharedQuadState* contrib_delegated_shared_quad_state =
1057 contrib_delegated_quad_list[0]->shared_quad_state;
1054 1058
1055 // When the quads have a clip of their own, it is used. 1059 // When the quads have a clip of their own, it is used.
1056 EXPECT_EQ(gfx::Rect(25, 25, 40, 40).ToString(), 1060 EXPECT_EQ(gfx::Rect(25, 25, 40, 40).ToString(),
1057 root_delegated_shared_quad_state->clip_rect.ToString()); 1061 root_delegated_shared_quad_state->clip_rect.ToString());
1058 // Quads came with a clip rect. 1062 // Quads came with a clip rect.
1059 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); 1063 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped);
1060 1064
1061 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1065 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
1062 host_impl_->DidDrawAllLayers(frame); 1066 host_impl_->DidDrawAllLayers(frame);
1063 } 1067 }
1064 1068
1065 TEST_F(DelegatedRendererLayerImplTestClip, 1069 TEST_F(DelegatedRendererLayerImplTestClip,
1066 QuadsUnclipped_LayerClipped_NoSurface) { 1070 QuadsUnclipped_LayerClipped_NoSurface) {
1067 root_delegated_render_pass_is_clipped_ = false; 1071 root_delegated_render_pass_is_clipped_ = false;
1068 clip_delegated_renderer_layer_ = true; 1072 clip_delegated_renderer_layer_ = true;
1069 SetUpTest(); 1073 SetUpTest();
1070 1074
1071 LayerTreeHostImpl::FrameData frame; 1075 LayerTreeHostImpl::FrameData frame;
1072 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame)); 1076 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame));
1073 1077
1074 ASSERT_EQ(2u, frame.render_passes.size()); 1078 ASSERT_EQ(2u, frame.render_passes.size());
1075 const QuadList& contrib_delegated_quad_list = 1079 const QuadList& contrib_delegated_quad_list =
1076 frame.render_passes[0]->quad_list; 1080 frame.render_passes[0]->quad_list;
1077 ASSERT_EQ(2u, contrib_delegated_quad_list.size()); 1081 ASSERT_EQ(2u, contrib_delegated_quad_list.size());
1078 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list; 1082 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list;
1079 ASSERT_EQ(5u, root_delegated_quad_list.size()); 1083 ASSERT_EQ(5u, root_delegated_quad_list.size());
1080 const SharedQuadState* root_delegated_shared_quad_state = 1084 const SharedQuadState* root_delegated_shared_quad_state =
1081 root_delegated_quad_list[0]->shared_quad_state; 1085 root_delegated_quad_list[0]->shared_quad_state;
1086 const SharedQuadState* contrib_delegated_shared_quad_state =
1087 contrib_delegated_quad_list[0]->shared_quad_state;
1082 1088
1083 // When the quads don't have a clip of their own, the clip rect is set to 1089 // When the quads don't have a clip of their own, the clip rect is set to
1084 // the drawable_content_rect of the delegated renderer layer. When the layer 1090 // the drawable_content_rect of the delegated renderer layer. When the layer
1085 // is clipped, that should be seen in the quads' clip_rect. 1091 // is clipped, that should be seen in the quads' clip_rect.
1086 EXPECT_EQ(gfx::Rect(21, 27, 23, 21).ToString(), 1092 EXPECT_EQ(gfx::Rect(21, 27, 23, 21).ToString(),
1087 root_delegated_shared_quad_state->clip_rect.ToString()); 1093 root_delegated_shared_quad_state->clip_rect.ToString());
1088 // Quads are clipped to the delegated renderer layer. 1094 // Quads are clipped to the delegated renderer layer.
1089 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); 1095 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped);
1090 1096
1091 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1097 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
(...skipping 10 matching lines...) Expand all
1102 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame)); 1108 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame));
1103 1109
1104 ASSERT_EQ(2u, frame.render_passes.size()); 1110 ASSERT_EQ(2u, frame.render_passes.size());
1105 const QuadList& contrib_delegated_quad_list = 1111 const QuadList& contrib_delegated_quad_list =
1106 frame.render_passes[0]->quad_list; 1112 frame.render_passes[0]->quad_list;
1107 ASSERT_EQ(2u, contrib_delegated_quad_list.size()); 1113 ASSERT_EQ(2u, contrib_delegated_quad_list.size());
1108 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list; 1114 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list;
1109 ASSERT_EQ(5u, root_delegated_quad_list.size()); 1115 ASSERT_EQ(5u, root_delegated_quad_list.size());
1110 const SharedQuadState* root_delegated_shared_quad_state = 1116 const SharedQuadState* root_delegated_shared_quad_state =
1111 root_delegated_quad_list[0]->shared_quad_state; 1117 root_delegated_quad_list[0]->shared_quad_state;
1118 const SharedQuadState* contrib_delegated_shared_quad_state =
1119 contrib_delegated_quad_list[0]->shared_quad_state;
1112 1120
1113 // When the quads have a clip of their own, it is used, but it is 1121 // When the quads have a clip of their own, it is used, but it is
1114 // combined with the clip rect of the delegated renderer layer. 1122 // combined with the clip rect of the delegated renderer layer.
1115 EXPECT_EQ(gfx::Rect(25, 27, 19, 21).ToString(), 1123 EXPECT_EQ(gfx::Rect(25, 27, 19, 21).ToString(),
1116 root_delegated_shared_quad_state->clip_rect.ToString()); 1124 root_delegated_shared_quad_state->clip_rect.ToString());
1117 // Quads came with a clip rect. 1125 // Quads came with a clip rect.
1118 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); 1126 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped);
1119 1127
1120 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1128 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
1121 host_impl_->DidDrawAllLayers(frame); 1129 host_impl_->DidDrawAllLayers(frame);
(...skipping 11 matching lines...) Expand all
1133 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame)); 1141 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame));
1134 1142
1135 ASSERT_EQ(3u, frame.render_passes.size()); 1143 ASSERT_EQ(3u, frame.render_passes.size());
1136 const QuadList& contrib_delegated_quad_list = 1144 const QuadList& contrib_delegated_quad_list =
1137 frame.render_passes[0]->quad_list; 1145 frame.render_passes[0]->quad_list;
1138 ASSERT_EQ(2u, contrib_delegated_quad_list.size()); 1146 ASSERT_EQ(2u, contrib_delegated_quad_list.size());
1139 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list; 1147 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list;
1140 ASSERT_EQ(5u, root_delegated_quad_list.size()); 1148 ASSERT_EQ(5u, root_delegated_quad_list.size());
1141 const SharedQuadState* root_delegated_shared_quad_state = 1149 const SharedQuadState* root_delegated_shared_quad_state =
1142 root_delegated_quad_list[0]->shared_quad_state; 1150 root_delegated_quad_list[0]->shared_quad_state;
1151 const SharedQuadState* contrib_delegated_shared_quad_state =
1152 contrib_delegated_quad_list[0]->shared_quad_state;
1143 1153
1144 // When the layer owns a surface, the quads don't need to be clipped 1154 // When the layer owns a surface, the quads don't need to be clipped
1145 // further than they already specify. If they aren't clipped, then their 1155 // further than they already specify. If they aren't clipped, then their
1146 // clip rect is ignored, and they are not set as clipped. 1156 // clip rect is ignored, and they are not set as clipped.
1147 EXPECT_FALSE(root_delegated_shared_quad_state->is_clipped); 1157 EXPECT_FALSE(root_delegated_shared_quad_state->is_clipped);
1148 1158
1149 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1159 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
1150 host_impl_->DidDrawAllLayers(frame); 1160 host_impl_->DidDrawAllLayers(frame);
1151 } 1161 }
1152 1162
1153 TEST_F(DelegatedRendererLayerImplTestClip, 1163 TEST_F(DelegatedRendererLayerImplTestClip,
1154 QuadsClipped_LayerUnclipped_Surface) { 1164 QuadsClipped_LayerUnclipped_Surface) {
1155 root_delegated_render_pass_is_clipped_ = true; 1165 root_delegated_render_pass_is_clipped_ = true;
1156 clip_delegated_renderer_layer_ = false; 1166 clip_delegated_renderer_layer_ = false;
1157 SetUpTest(); 1167 SetUpTest();
1158 1168
1159 delegated_renderer_layer_->SetForceRenderSurface(true); 1169 delegated_renderer_layer_->SetForceRenderSurface(true);
1160 1170
1161 LayerTreeHostImpl::FrameData frame; 1171 LayerTreeHostImpl::FrameData frame;
1162 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame)); 1172 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame));
1163 1173
1164 ASSERT_EQ(3u, frame.render_passes.size()); 1174 ASSERT_EQ(3u, frame.render_passes.size());
1165 const QuadList& contrib_delegated_quad_list = 1175 const QuadList& contrib_delegated_quad_list =
1166 frame.render_passes[0]->quad_list; 1176 frame.render_passes[0]->quad_list;
1167 ASSERT_EQ(2u, contrib_delegated_quad_list.size()); 1177 ASSERT_EQ(2u, contrib_delegated_quad_list.size());
1168 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list; 1178 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list;
1169 ASSERT_EQ(5u, root_delegated_quad_list.size()); 1179 ASSERT_EQ(5u, root_delegated_quad_list.size());
1170 const SharedQuadState* root_delegated_shared_quad_state = 1180 const SharedQuadState* root_delegated_shared_quad_state =
1171 root_delegated_quad_list[0]->shared_quad_state; 1181 root_delegated_quad_list[0]->shared_quad_state;
1182 const SharedQuadState* contrib_delegated_shared_quad_state =
1183 contrib_delegated_quad_list[0]->shared_quad_state;
1172 1184
1173 // When the quads have a clip of their own, it is used. 1185 // When the quads have a clip of their own, it is used.
1174 EXPECT_EQ(gfx::Rect(5, 5, 40, 40).ToString(), 1186 EXPECT_EQ(gfx::Rect(5, 5, 40, 40).ToString(),
1175 root_delegated_shared_quad_state->clip_rect.ToString()); 1187 root_delegated_shared_quad_state->clip_rect.ToString());
1176 // Quads came with a clip rect. 1188 // Quads came with a clip rect.
1177 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); 1189 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped);
1178 1190
1179 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1191 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
1180 host_impl_->DidDrawAllLayers(frame); 1192 host_impl_->DidDrawAllLayers(frame);
1181 } 1193 }
(...skipping 10 matching lines...) Expand all
1192 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame)); 1204 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame));
1193 1205
1194 ASSERT_EQ(3u, frame.render_passes.size()); 1206 ASSERT_EQ(3u, frame.render_passes.size());
1195 const QuadList& contrib_delegated_quad_list = 1207 const QuadList& contrib_delegated_quad_list =
1196 frame.render_passes[0]->quad_list; 1208 frame.render_passes[0]->quad_list;
1197 ASSERT_EQ(2u, contrib_delegated_quad_list.size()); 1209 ASSERT_EQ(2u, contrib_delegated_quad_list.size());
1198 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list; 1210 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list;
1199 ASSERT_EQ(5u, root_delegated_quad_list.size()); 1211 ASSERT_EQ(5u, root_delegated_quad_list.size());
1200 const SharedQuadState* root_delegated_shared_quad_state = 1212 const SharedQuadState* root_delegated_shared_quad_state =
1201 root_delegated_quad_list[0]->shared_quad_state; 1213 root_delegated_quad_list[0]->shared_quad_state;
1214 const SharedQuadState* contrib_delegated_shared_quad_state =
1215 contrib_delegated_quad_list[0]->shared_quad_state;
1202 1216
1203 // When the layer owns a surface, the quads don't need to be clipped 1217 // When the layer owns a surface, the quads don't need to be clipped
1204 // further than they already specify. If they aren't clipped, then their 1218 // further than they already specify. If they aren't clipped, then their
1205 // clip rect is ignored, and they are not set as clipped. 1219 // clip rect is ignored, and they are not set as clipped.
1206 EXPECT_FALSE(root_delegated_shared_quad_state->is_clipped); 1220 EXPECT_FALSE(root_delegated_shared_quad_state->is_clipped);
1207 1221
1208 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1222 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
1209 host_impl_->DidDrawAllLayers(frame); 1223 host_impl_->DidDrawAllLayers(frame);
1210 } 1224 }
1211 1225
1212 TEST_F(DelegatedRendererLayerImplTestClip, QuadsClipped_LayerClipped_Surface) { 1226 TEST_F(DelegatedRendererLayerImplTestClip, QuadsClipped_LayerClipped_Surface) {
1213 root_delegated_render_pass_is_clipped_ = true; 1227 root_delegated_render_pass_is_clipped_ = true;
1214 clip_delegated_renderer_layer_ = true; 1228 clip_delegated_renderer_layer_ = true;
1215 SetUpTest(); 1229 SetUpTest();
1216 1230
1217 delegated_renderer_layer_->SetForceRenderSurface(true); 1231 delegated_renderer_layer_->SetForceRenderSurface(true);
1218 1232
1219 LayerTreeHostImpl::FrameData frame; 1233 LayerTreeHostImpl::FrameData frame;
1220 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame)); 1234 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame));
1221 1235
1222 ASSERT_EQ(3u, frame.render_passes.size()); 1236 ASSERT_EQ(3u, frame.render_passes.size());
1223 const QuadList& contrib_delegated_quad_list = 1237 const QuadList& contrib_delegated_quad_list =
1224 frame.render_passes[0]->quad_list; 1238 frame.render_passes[0]->quad_list;
1225 ASSERT_EQ(2u, contrib_delegated_quad_list.size()); 1239 ASSERT_EQ(2u, contrib_delegated_quad_list.size());
1226 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list; 1240 const QuadList& root_delegated_quad_list = frame.render_passes[1]->quad_list;
1227 ASSERT_EQ(5u, root_delegated_quad_list.size()); 1241 ASSERT_EQ(5u, root_delegated_quad_list.size());
1228 const SharedQuadState* root_delegated_shared_quad_state = 1242 const SharedQuadState* root_delegated_shared_quad_state =
1229 root_delegated_quad_list[0]->shared_quad_state; 1243 root_delegated_quad_list[0]->shared_quad_state;
1244 const SharedQuadState* contrib_delegated_shared_quad_state =
1245 contrib_delegated_quad_list[0]->shared_quad_state;
1230 1246
1231 // When the quads have a clip of their own, it is used, but it is 1247 // When the quads have a clip of their own, it is used, but it is
1232 // combined with the clip rect of the delegated renderer layer. If the 1248 // combined with the clip rect of the delegated renderer layer. If the
1233 // layer owns a surface, then it does not have a clip rect of its own. 1249 // layer owns a surface, then it does not have a clip rect of its own.
1234 EXPECT_EQ(gfx::Rect(5, 5, 40, 40).ToString(), 1250 EXPECT_EQ(gfx::Rect(5, 5, 40, 40).ToString(),
1235 root_delegated_shared_quad_state->clip_rect.ToString()); 1251 root_delegated_shared_quad_state->clip_rect.ToString());
1236 // Quads came with a clip rect. 1252 // Quads came with a clip rect.
1237 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); 1253 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped);
1238 1254
1239 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1255 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
1240 host_impl_->DidDrawAllLayers(frame); 1256 host_impl_->DidDrawAllLayers(frame);
1241 } 1257 }
1242 1258
1243 } // namespace 1259 } // namespace
1244 } // namespace cc 1260 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/layers/delegated_renderer_layer_impl.cc ('k') | trunk/src/cc/layers/heads_up_display_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698