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

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

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

Powered by Google App Engine
This is Rietveld 408576698