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

Side by Side Diff: cc/output/gl_renderer_unittest.cc

Issue 14205009: cc: Chromify gl_renderer_unittest.cc. (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 | « no previous file | 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/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include "cc/output/compositor_frame_metadata.h" 7 #include "cc/output/compositor_frame_metadata.h"
8 #include "cc/resources/prioritized_resource_manager.h" 8 #include "cc/resources/prioritized_resource_manager.h"
9 #include "cc/resources/resource_provider.h" 9 #include "cc/resources/resource_provider.h"
10 #include "cc/test/fake_impl_proxy.h" 10 #include "cc/test/fake_impl_proxy.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 EXPECT_PROGRAM_VALID(renderer_->GetTileProgram()); 62 EXPECT_PROGRAM_VALID(renderer_->GetTileProgram());
63 EXPECT_PROGRAM_VALID(renderer_->GetTileProgramOpaque()); 63 EXPECT_PROGRAM_VALID(renderer_->GetTileProgramOpaque());
64 EXPECT_PROGRAM_VALID(renderer_->GetTileProgramAA()); 64 EXPECT_PROGRAM_VALID(renderer_->GetTileProgramAA());
65 EXPECT_PROGRAM_VALID(renderer_->GetTileProgramSwizzle()); 65 EXPECT_PROGRAM_VALID(renderer_->GetTileProgramSwizzle());
66 EXPECT_PROGRAM_VALID(renderer_->GetTileProgramSwizzleOpaque()); 66 EXPECT_PROGRAM_VALID(renderer_->GetTileProgramSwizzleOpaque());
67 EXPECT_PROGRAM_VALID(renderer_->GetTileProgramSwizzleAA()); 67 EXPECT_PROGRAM_VALID(renderer_->GetTileProgramSwizzleAA());
68 EXPECT_PROGRAM_VALID(renderer_->GetTileCheckerboardProgram()); 68 EXPECT_PROGRAM_VALID(renderer_->GetTileCheckerboardProgram());
69 EXPECT_PROGRAM_VALID(renderer_->GetDebugBorderProgram()); 69 EXPECT_PROGRAM_VALID(renderer_->GetDebugBorderProgram());
70 EXPECT_PROGRAM_VALID(renderer_->GetSolidColorProgram()); 70 EXPECT_PROGRAM_VALID(renderer_->GetSolidColorProgram());
71 EXPECT_PROGRAM_VALID(renderer_->GetSolidColorProgramAA()); 71 EXPECT_PROGRAM_VALID(renderer_->GetSolidColorProgramAA());
72 //TestShadersWithTexCoordPrecision(TexCoordPrecisionMedium); 72 // TestShadersWithTexCoordPrecision(TexCoordPrecisionMedium);
73 TestShadersWithTexCoordPrecision(TexCoordPrecisionHigh); 73 TestShadersWithTexCoordPrecision(TexCoordPrecisionHigh);
74 ASSERT_FALSE(renderer_->IsContextLost()); 74 ASSERT_FALSE(renderer_->IsContextLost());
75 } 75 }
76 76
77 void TestShadersWithTexCoordPrecision(TexCoordPrecision precision) { 77 void TestShadersWithTexCoordPrecision(TexCoordPrecision precision) {
78 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassProgram(precision)); 78 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassProgram(precision));
79 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassProgramAA(precision)); 79 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassProgramAA(precision));
80 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassMaskProgram(precision)); 80 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassMaskProgram(precision));
81 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassMaskProgramAA(precision)); 81 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassMaskProgramAA(precision));
82 EXPECT_PROGRAM_VALID( 82 EXPECT_PROGRAM_VALID(
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 new FrameCountingMemoryAllocationSettingContext()))), 243 new FrameCountingMemoryAllocationSettingContext()))),
244 resource_provider_(ResourceProvider::Create(output_surface_.get(), 0)), 244 resource_provider_(ResourceProvider::Create(output_surface_.get(), 0)),
245 renderer_(&mock_client_, 245 renderer_(&mock_client_,
246 output_surface_.get(), 246 output_surface_.get(),
247 resource_provider_.get()) {} 247 resource_provider_.get()) {}
248 248
249 virtual void SetUp() { renderer_.Initialize(); } 249 virtual void SetUp() { renderer_.Initialize(); }
250 250
251 void SwapBuffers() { renderer_.SwapBuffers(); } 251 void SwapBuffers() { renderer_.SwapBuffers(); }
252 252
253 FrameCountingMemoryAllocationSettingContext* context() { 253 FrameCountingMemoryAllocationSettingContext* Context() {
254 return static_cast<FrameCountingMemoryAllocationSettingContext*>( 254 return static_cast<FrameCountingMemoryAllocationSettingContext*>(
255 output_surface_->context3d()); 255 output_surface_->context3d());
256 } 256 }
257 257
258 WebGraphicsMemoryAllocation suggest_have_backbuffer_yes_; 258 WebGraphicsMemoryAllocation suggest_have_backbuffer_yes_;
259 WebGraphicsMemoryAllocation suggest_have_backbuffer_no_; 259 WebGraphicsMemoryAllocation suggest_have_backbuffer_no_;
260 260
261 scoped_ptr<OutputSurface> output_surface_; 261 scoped_ptr<OutputSurface> output_surface_;
262 FakeRendererClient mock_client_; 262 FakeRendererClient mock_client_;
263 scoped_ptr<ResourceProvider> resource_provider_; 263 scoped_ptr<ResourceProvider> resource_provider_;
264 FakeRendererGL renderer_; 264 FakeRendererGL renderer_;
265 }; 265 };
266 266
267 // Closing the namespace here so that GLRendererShaderTest can take advantage 267 // Closing the namespace here so that GLRendererShaderTest can take advantage
268 // of the friend relationship with GLRenderer and all of the mock classes 268 // of the friend relationship with GLRenderer and all of the mock classes
269 // declared above it. 269 // declared above it.
270 } // namespace 270 } // namespace
271 271
272 class GLRendererShaderTest : public testing::Test { 272 class GLRendererShaderTest : public testing::Test {
273 protected: 273 protected:
274 GLRendererShaderTest() 274 GLRendererShaderTest()
275 : output_surface_(FakeOutputSurface::Create3d()), 275 : output_surface_(FakeOutputSurface::Create3d()),
276 resource_provider_(ResourceProvider::Create(output_surface_.get(), 0)), 276 resource_provider_(ResourceProvider::Create(output_surface_.get(), 0)),
277 renderer_(GLRenderer::Create(&mock_client_, output_surface_.get(), 277 renderer_(GLRenderer::Create(&mock_client_, output_surface_.get(),
danakj 2013/04/17 17:44:59 nit: one argument per line if they don't all fit o
reveman 2013/04/17 18:26:04 Done.
278 resource_provider_.get(), 0)) { 278 resource_provider_.get(), 0)) {}
279 }
280 279
281 void TestRenderPassProgram() { 280 void TestRenderPassProgram() {
282 EXPECT_PROGRAM_VALID(renderer_->render_pass_program_); 281 EXPECT_PROGRAM_VALID(renderer_->render_pass_program_);
283 EXPECT_TRUE(renderer_->program_shadow_ == 282 EXPECT_TRUE(renderer_->program_shadow_ ==
284 renderer_->render_pass_program_->program()); 283 renderer_->render_pass_program_->program());
285 } 284 }
286 285
287 void TestRenderPassColorMatrixProgram() { 286 void TestRenderPassColorMatrixProgram() {
288 EXPECT_PROGRAM_VALID(renderer_->render_pass_color_matrix_program_); 287 EXPECT_PROGRAM_VALID(renderer_->render_pass_color_matrix_program_);
289 EXPECT_TRUE(renderer_->program_shadow_ == 288 EXPECT_TRUE(renderer_->program_shadow_ ==
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 scoped_ptr<ResourceProvider> resource_provider_; 330 scoped_ptr<ResourceProvider> resource_provider_;
332 scoped_ptr<GLRenderer> renderer_; 331 scoped_ptr<GLRenderer> renderer_;
333 }; 332 };
334 333
335 namespace { 334 namespace {
336 335
337 // Test GLRenderer discardBackbuffer functionality: 336 // Test GLRenderer discardBackbuffer functionality:
338 // Suggest recreating framebuffer when one already exists. 337 // Suggest recreating framebuffer when one already exists.
339 // Expected: it does nothing. 338 // Expected: it does nothing.
340 TEST_F(GLRendererTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing) { 339 TEST_F(GLRendererTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing) {
341 context()->SetMemoryAllocation(suggest_have_backbuffer_yes_); 340 Context()->SetMemoryAllocation(suggest_have_backbuffer_yes_);
342 EXPECT_EQ(0, mock_client_.set_full_root_layer_damage_count()); 341 EXPECT_EQ(0, mock_client_.set_full_root_layer_damage_count());
343 EXPECT_FALSE(renderer_.IsBackbufferDiscarded()); 342 EXPECT_FALSE(renderer_.IsBackbufferDiscarded());
344 343
345 SwapBuffers(); 344 SwapBuffers();
346 EXPECT_EQ(1, context()->frame_count()); 345 EXPECT_EQ(1, Context()->frame_count());
347 } 346 }
348 347
349 // Test GLRenderer DiscardBackbuffer functionality: 348 // Test GLRenderer DiscardBackbuffer functionality:
350 // Suggest discarding framebuffer when one exists and the renderer is not 349 // Suggest discarding framebuffer when one exists and the renderer is not
351 // visible. 350 // visible.
352 // Expected: it is discarded and damage tracker is reset. 351 // Expected: it is discarded and damage tracker is reset.
353 TEST_F( 352 TEST_F(
354 GLRendererTest, 353 GLRendererTest,
355 SuggestBackbufferNoShouldDiscardBackbufferAndDamageRootLayerIfNotVisible) { 354 SuggestBackbufferNoShouldDiscardBackbufferAndDamageRootLayerIfNotVisible) {
356 renderer_.SetVisible(false); 355 renderer_.SetVisible(false);
357 context()->SetMemoryAllocation(suggest_have_backbuffer_no_); 356 Context()->SetMemoryAllocation(suggest_have_backbuffer_no_);
358 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count()); 357 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count());
359 EXPECT_TRUE(renderer_.IsBackbufferDiscarded()); 358 EXPECT_TRUE(renderer_.IsBackbufferDiscarded());
360 } 359 }
361 360
362 // Test GLRenderer DiscardBackbuffer functionality: 361 // Test GLRenderer DiscardBackbuffer functionality:
363 // Suggest discarding framebuffer when one exists and the renderer is visible. 362 // Suggest discarding framebuffer when one exists and the renderer is visible.
364 // Expected: the allocation is ignored. 363 // Expected: the allocation is ignored.
365 TEST_F(GLRendererTest, SuggestBackbufferNoDoNothingWhenVisible) { 364 TEST_F(GLRendererTest, SuggestBackbufferNoDoNothingWhenVisible) {
366 renderer_.SetVisible(true); 365 renderer_.SetVisible(true);
367 context()->SetMemoryAllocation(suggest_have_backbuffer_no_); 366 Context()->SetMemoryAllocation(suggest_have_backbuffer_no_);
368 EXPECT_EQ(0, mock_client_.set_full_root_layer_damage_count()); 367 EXPECT_EQ(0, mock_client_.set_full_root_layer_damage_count());
369 EXPECT_FALSE(renderer_.IsBackbufferDiscarded()); 368 EXPECT_FALSE(renderer_.IsBackbufferDiscarded());
370 } 369 }
371 370
372 // Test GLRenderer DiscardBackbuffer functionality: 371 // Test GLRenderer DiscardBackbuffer functionality:
373 // Suggest discarding framebuffer when one does not exist. 372 // Suggest discarding framebuffer when one does not exist.
374 // Expected: it does nothing. 373 // Expected: it does nothing.
375 TEST_F(GLRendererTest, SuggestBackbufferNoWhenItDoesntExistShouldDoNothing) { 374 TEST_F(GLRendererTest, SuggestBackbufferNoWhenItDoesntExistShouldDoNothing) {
376 renderer_.SetVisible(false); 375 renderer_.SetVisible(false);
377 context()->SetMemoryAllocation(suggest_have_backbuffer_no_); 376 Context()->SetMemoryAllocation(suggest_have_backbuffer_no_);
378 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count()); 377 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count());
379 EXPECT_TRUE(renderer_.IsBackbufferDiscarded()); 378 EXPECT_TRUE(renderer_.IsBackbufferDiscarded());
380 379
381 context()->SetMemoryAllocation(suggest_have_backbuffer_no_); 380 Context()->SetMemoryAllocation(suggest_have_backbuffer_no_);
382 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count()); 381 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count());
383 EXPECT_TRUE(renderer_.IsBackbufferDiscarded()); 382 EXPECT_TRUE(renderer_.IsBackbufferDiscarded());
384 } 383 }
385 384
386 // Test GLRenderer DiscardBackbuffer functionality: 385 // Test GLRenderer DiscardBackbuffer functionality:
387 // Begin drawing a frame while a framebuffer is discarded. 386 // Begin drawing a frame while a framebuffer is discarded.
388 // Expected: will recreate framebuffer. 387 // Expected: will recreate framebuffer.
389 TEST_F(GLRendererTest, DiscardedBackbufferIsRecreatedForScopeDuration) { 388 TEST_F(GLRendererTest, DiscardedBackbufferIsRecreatedForScopeDuration) {
390 renderer_.SetVisible(false); 389 renderer_.SetVisible(false);
391 context()->SetMemoryAllocation(suggest_have_backbuffer_no_); 390 Context()->SetMemoryAllocation(suggest_have_backbuffer_no_);
392 EXPECT_TRUE(renderer_.IsBackbufferDiscarded()); 391 EXPECT_TRUE(renderer_.IsBackbufferDiscarded());
393 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count()); 392 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count());
394 393
395 renderer_.SetVisible(true); 394 renderer_.SetVisible(true);
396 renderer_.DrawFrame(mock_client_.render_passes_in_draw_order()); 395 renderer_.DrawFrame(mock_client_.render_passes_in_draw_order());
397 EXPECT_FALSE(renderer_.IsBackbufferDiscarded()); 396 EXPECT_FALSE(renderer_.IsBackbufferDiscarded());
398 397
399 SwapBuffers(); 398 SwapBuffers();
400 EXPECT_EQ(1, context()->frame_count()); 399 EXPECT_EQ(1, Context()->frame_count());
401 } 400 }
402 401
403 TEST_F(GLRendererTest, FramebufferDiscardedAfterReadbackWhenNotVisible) { 402 TEST_F(GLRendererTest, FramebufferDiscardedAfterReadbackWhenNotVisible) {
404 renderer_.SetVisible(false); 403 renderer_.SetVisible(false);
405 context()->SetMemoryAllocation(suggest_have_backbuffer_no_); 404 Context()->SetMemoryAllocation(suggest_have_backbuffer_no_);
406 EXPECT_TRUE(renderer_.IsBackbufferDiscarded()); 405 EXPECT_TRUE(renderer_.IsBackbufferDiscarded());
407 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count()); 406 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count());
408 407
409 char pixels[4]; 408 char pixels[4];
410 renderer_.DrawFrame(mock_client_.render_passes_in_draw_order()); 409 renderer_.DrawFrame(mock_client_.render_passes_in_draw_order());
411 EXPECT_FALSE(renderer_.IsBackbufferDiscarded()); 410 EXPECT_FALSE(renderer_.IsBackbufferDiscarded());
412 411
413 renderer_.GetFramebufferPixels(pixels, gfx::Rect(0, 0, 1, 1)); 412 renderer_.GetFramebufferPixels(pixels, gfx::Rect(0, 0, 1, 1));
414 EXPECT_TRUE(renderer_.IsBackbufferDiscarded()); 413 EXPECT_TRUE(renderer_.IsBackbufferDiscarded());
415 EXPECT_EQ(2, mock_client_.set_full_root_layer_damage_count()); 414 EXPECT_EQ(2, mock_client_.set_full_root_layer_damage_count());
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 1009
1011 AddRenderPassQuad(root_pass, child_pass); 1010 AddRenderPassQuad(root_pass, child_pass);
1012 AddRenderPassQuad(child_pass, grand_child_pass); 1011 AddRenderPassQuad(child_pass, grand_child_pass);
1013 1012
1014 renderer.DecideRenderPassAllocationsForFrame( 1013 renderer.DecideRenderPassAllocationsForFrame(
1015 *mock_client.render_passes_in_draw_order()); 1014 *mock_client.render_passes_in_draw_order());
1016 renderer.DrawFrame(mock_client.render_passes_in_draw_order()); 1015 renderer.DrawFrame(mock_client.render_passes_in_draw_order());
1017 } 1016 }
1018 1017
1019 TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) { 1018 TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) {
1020 gfx::Rect viewportRect(mock_client_.DeviceViewportSize()); 1019 gfx::Rect viewport_rect(mock_client_.DeviceViewportSize());
1021 ScopedPtrVector<RenderPass>* renderPasses = 1020 ScopedPtrVector<RenderPass>* render_passes =
1022 mock_client_.render_passes_in_draw_order(); 1021 mock_client_.render_passes_in_draw_order();
1023 1022
1024 gfx::Rect grandChildRect(25, 25); 1023 gfx::Rect grand_child_rect(25, 25);
1025 RenderPass::Id grandChildPassId(3, 0); 1024 RenderPass::Id grand_child_pass_id(3, 0);
1026 TestRenderPass* grandChildPass; 1025 TestRenderPass* grand_child_pass;
1027 1026
1028 gfx::Rect childRect(50, 50); 1027 gfx::Rect child_rect(50, 50);
1029 RenderPass::Id childPassId(2, 0); 1028 RenderPass::Id child_pass_id(2, 0);
1030 TestRenderPass* childPass; 1029 TestRenderPass* child_pass;
1031 1030
1032 RenderPass::Id rootPassId(1, 0); 1031 RenderPass::Id root_pass_id(1, 0);
1033 TestRenderPass* rootPass; 1032 TestRenderPass* root_pass;
1034 1033
1035 cc::ResourceProvider::ResourceId mask = 1034 cc::ResourceProvider::ResourceId mask =
1036 resource_provider_->CreateResource(gfx::Size(20, 12), 1035 resource_provider_->CreateResource(gfx::Size(20, 12),
1037 resource_provider_->best_texture_format(), 1036 resource_provider_->best_texture_format(),
1038 ResourceProvider::TextureUsageAny); 1037 ResourceProvider::TextureUsageAny);
1039 resource_provider_->AllocateForTesting(mask); 1038 resource_provider_->AllocateForTesting(mask);
1040 1039
1041 SkScalar matrix[20]; 1040 SkScalar matrix[20];
1042 float amount = 0.5f; 1041 float amount = 0.5f;
1043 matrix[0] = 0.213f + 0.787f * amount; 1042 matrix[0] = 0.213f + 0.787f * amount;
1044 matrix[1] = 0.715f - 0.715f * amount; 1043 matrix[1] = 0.715f - 0.715f * amount;
1045 matrix[2] = 1.f - (matrix[0] + matrix[1]); 1044 matrix[2] = 1.f - (matrix[0] + matrix[1]);
1046 matrix[3] = matrix[4] = 0; 1045 matrix[3] = matrix[4] = 0;
1047 matrix[5] = 0.213f - 0.213f * amount; 1046 matrix[5] = 0.213f - 0.213f * amount;
1048 matrix[6] = 0.715f + 0.285f * amount; 1047 matrix[6] = 0.715f + 0.285f * amount;
1049 matrix[7] = 1.f - (matrix[5] + matrix[6]); 1048 matrix[7] = 1.f - (matrix[5] + matrix[6]);
1050 matrix[8] = matrix[9] = 0; 1049 matrix[8] = matrix[9] = 0;
1051 matrix[10] = 0.213f - 0.213f * amount; 1050 matrix[10] = 0.213f - 0.213f * amount;
1052 matrix[11] = 0.715f - 0.715f * amount; 1051 matrix[11] = 0.715f - 0.715f * amount;
1053 matrix[12] = 1.f - (matrix[10] + matrix[11]); 1052 matrix[12] = 1.f - (matrix[10] + matrix[11]);
1054 matrix[13] = matrix[14] = 0; 1053 matrix[13] = matrix[14] = 0;
1055 matrix[15] = matrix[16] = matrix[17] = matrix[19] = 0; 1054 matrix[15] = matrix[16] = matrix[17] = matrix[19] = 0;
1056 matrix[18] = 1; 1055 matrix[18] = 1;
1057 skia::RefPtr<SkColorFilter> colorFilter(skia::AdoptRef( 1056 skia::RefPtr<SkColorFilter> color_filter(
1058 new SkColorMatrixFilter(matrix))); 1057 skia::AdoptRef(new SkColorMatrixFilter(matrix)));
1059 skia::RefPtr<SkImageFilter> filter = 1058 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef(
1060 skia::AdoptRef(SkColorFilterImageFilter::Create(colorFilter.get(), NULL)); 1059 SkColorFilterImageFilter::Create(color_filter.get(), NULL));
1061 1060
1062 gfx::Transform transform_causing_aa; 1061 gfx::Transform transform_causing_aa;
1063 transform_causing_aa.Rotate(20.0); 1062 transform_causing_aa.Rotate(20.0);
1064 1063
1065 // RenderPassProgram 1064 // RenderPassProgram
1066 renderPasses->clear(); 1065 render_passes->clear();
1067 1066
1068 grandChildPass = AddRenderPass(renderPasses, grandChildPassId, grandChildRect, 1067 grand_child_pass = AddRenderPass(
1069 gfx::Transform()); 1068 render_passes, grand_child_pass_id, grand_child_rect, gfx::Transform());
1070 AddClippedQuad(grandChildPass, grandChildRect, SK_ColorYELLOW); 1069 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW);
1071 1070
1072 childPass = AddRenderPass(renderPasses, childPassId, childRect, 1071 child_pass = AddRenderPass(
1073 gfx::Transform()); 1072 render_passes, child_pass_id, child_rect, gfx::Transform());
1074 AddQuad(childPass, childRect, SK_ColorBLUE); 1073 AddQuad(child_pass, child_rect, SK_ColorBLUE);
1075 1074
1076 rootPass = AddRenderPass(renderPasses, rootPassId, viewportRect, 1075 root_pass = AddRenderPass(
1077 gfx::Transform()); 1076 render_passes, root_pass_id, viewport_rect, gfx::Transform());
1078 AddQuad(rootPass, viewportRect, SK_ColorGREEN); 1077 AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
1079 1078
1080 AddRenderPassQuad(rootPass, childPass, 0, skia::RefPtr<SkImageFilter>(), 1079 AddRenderPassQuad(root_pass,
1081 gfx::Transform()); 1080 child_pass,
1082 AddRenderPassQuad(childPass, grandChildPass); 1081 0,
1082 skia::RefPtr<SkImageFilter>(),
1083 gfx::Transform());
1084 AddRenderPassQuad(child_pass, grand_child_pass);
1083 1085
1084 renderer_->DecideRenderPassAllocationsForFrame( 1086 renderer_->DecideRenderPassAllocationsForFrame(
1085 *mock_client_.render_passes_in_draw_order()); 1087 *mock_client_.render_passes_in_draw_order());
1086 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order()); 1088 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order());
1087 TestRenderPassProgram(); 1089 TestRenderPassProgram();
1088 1090
1089 // RenderPassColorMatrixProgram 1091 // RenderPassColorMatrixProgram
1090 renderPasses->clear(); 1092 render_passes->clear();
1091 1093
1092 grandChildPass = AddRenderPass(renderPasses, grandChildPassId, grandChildRect, 1094 grand_child_pass = AddRenderPass(render_passes,
1093 transform_causing_aa); 1095 grand_child_pass_id,
1094 AddClippedQuad(grandChildPass, grandChildRect, SK_ColorYELLOW); 1096 grand_child_rect,
1097 transform_causing_aa);
1098 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW);
1095 1099
1096 childPass = AddRenderPass(renderPasses, childPassId, childRect, 1100 child_pass = AddRenderPass(
1097 transform_causing_aa); 1101 render_passes, child_pass_id, child_rect, transform_causing_aa);
1098 AddQuad(childPass, childRect, SK_ColorBLUE); 1102 AddQuad(child_pass, child_rect, SK_ColorBLUE);
1099 1103
1100 rootPass = AddRenderPass(renderPasses, rootPassId, viewportRect, 1104 root_pass = AddRenderPass(
1101 gfx::Transform()); 1105 render_passes, root_pass_id, viewport_rect, gfx::Transform());
1102 AddQuad(rootPass, viewportRect, SK_ColorGREEN); 1106 AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
1103 1107
1104 AddRenderPassQuad(rootPass, childPass, 0, filter, gfx::Transform()); 1108 AddRenderPassQuad(root_pass, child_pass, 0, filter, gfx::Transform());
1105 AddRenderPassQuad(childPass, grandChildPass); 1109 AddRenderPassQuad(child_pass, grand_child_pass);
1106 1110
1107 renderer_->DecideRenderPassAllocationsForFrame( 1111 renderer_->DecideRenderPassAllocationsForFrame(
1108 *mock_client_.render_passes_in_draw_order()); 1112 *mock_client_.render_passes_in_draw_order());
1109 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order()); 1113 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order());
1110 TestRenderPassColorMatrixProgram(); 1114 TestRenderPassColorMatrixProgram();
1111 1115
1112 // RenderPassMaskProgram 1116 // RenderPassMaskProgram
1113 renderPasses->clear(); 1117 render_passes->clear();
1114 1118
1115 grandChildPass = AddRenderPass(renderPasses, grandChildPassId, grandChildRect, 1119 grand_child_pass = AddRenderPass(render_passes,
1116 gfx::Transform()); 1120 grand_child_pass_id,
1117 AddClippedQuad(grandChildPass, grandChildRect, SK_ColorYELLOW); 1121 grand_child_rect,
1122 gfx::Transform());
1123 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW);
1118 1124
1119 childPass = AddRenderPass(renderPasses, childPassId, childRect, 1125 child_pass = AddRenderPass(
1120 gfx::Transform()); 1126 render_passes, child_pass_id, child_rect, gfx::Transform());
1121 AddQuad(childPass, childRect, SK_ColorBLUE); 1127 AddQuad(child_pass, child_rect, SK_ColorBLUE);
1122 1128
1123 rootPass = AddRenderPass(renderPasses, rootPassId, viewportRect, 1129 root_pass = AddRenderPass(
1124 gfx::Transform()); 1130 render_passes, root_pass_id, viewport_rect, gfx::Transform());
1125 AddQuad(rootPass, viewportRect, SK_ColorGREEN); 1131 AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
1126 1132
1127 AddRenderPassQuad(rootPass, childPass, mask, skia::RefPtr<SkImageFilter>(), 1133 AddRenderPassQuad(root_pass,
1128 gfx::Transform()); 1134 child_pass,
1129 AddRenderPassQuad(childPass, grandChildPass); 1135 mask,
1136 skia::RefPtr<SkImageFilter>(),
1137 gfx::Transform());
1138 AddRenderPassQuad(child_pass, grand_child_pass);
1130 1139
1131 renderer_->DecideRenderPassAllocationsForFrame( 1140 renderer_->DecideRenderPassAllocationsForFrame(
1132 *mock_client_.render_passes_in_draw_order()); 1141 *mock_client_.render_passes_in_draw_order());
1133 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order()); 1142 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order());
1134 TestRenderPassMaskProgram(); 1143 TestRenderPassMaskProgram();
1135 1144
1136 // RenderPassMaskColorMatrixProgram 1145 // RenderPassMaskColorMatrixProgram
1137 renderPasses->clear(); 1146 render_passes->clear();
1138 1147
1139 grandChildPass = AddRenderPass(renderPasses, grandChildPassId, grandChildRect, 1148 grand_child_pass = AddRenderPass(
1140 gfx::Transform()); 1149 render_passes, grand_child_pass_id, grand_child_rect, gfx::Transform());
1141 AddClippedQuad(grandChildPass, grandChildRect, SK_ColorYELLOW); 1150 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW);
1142 1151
1143 childPass = AddRenderPass(renderPasses, childPassId, childRect, 1152 child_pass = AddRenderPass(
1144 gfx::Transform()); 1153 render_passes, child_pass_id, child_rect, gfx::Transform());
1145 AddQuad(childPass, childRect, SK_ColorBLUE); 1154 AddQuad(child_pass, child_rect, SK_ColorBLUE);
1146 1155
1147 rootPass = AddRenderPass(renderPasses, rootPassId, viewportRect, 1156 root_pass = AddRenderPass(
1148 gfx::Transform()); 1157 render_passes, root_pass_id, viewport_rect, gfx::Transform());
1149 AddQuad(rootPass, viewportRect, SK_ColorGREEN); 1158 AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
1150 1159
1151 AddRenderPassQuad(rootPass, childPass, mask, filter, gfx::Transform()); 1160 AddRenderPassQuad(root_pass, child_pass, mask, filter, gfx::Transform());
1152 AddRenderPassQuad(childPass, grandChildPass); 1161 AddRenderPassQuad(child_pass, grand_child_pass);
1153 1162
1154 renderer_->DecideRenderPassAllocationsForFrame( 1163 renderer_->DecideRenderPassAllocationsForFrame(
1155 *mock_client_.render_passes_in_draw_order()); 1164 *mock_client_.render_passes_in_draw_order());
1156 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order()); 1165 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order());
1157 TestRenderPassMaskColorMatrixProgram(); 1166 TestRenderPassMaskColorMatrixProgram();
1158 1167
1159 // RenderPassProgramAA 1168 // RenderPassProgramAA
1160 renderPasses->clear(); 1169 render_passes->clear();
1161 1170
1162 grandChildPass = AddRenderPass(renderPasses, grandChildPassId, grandChildRect, 1171 grand_child_pass = AddRenderPass(render_passes,
1163 transform_causing_aa); 1172 grand_child_pass_id,
1164 AddClippedQuad(grandChildPass, grandChildRect, SK_ColorYELLOW); 1173 grand_child_rect,
1174 transform_causing_aa);
1175 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW);
1165 1176
1166 childPass = AddRenderPass(renderPasses, childPassId, childRect, 1177 child_pass = AddRenderPass(
1167 transform_causing_aa); 1178 render_passes, child_pass_id, child_rect, transform_causing_aa);
1168 AddQuad(childPass, childRect, SK_ColorBLUE); 1179 AddQuad(child_pass, child_rect, SK_ColorBLUE);
1169 1180
1170 rootPass = AddRenderPass(renderPasses, rootPassId, viewportRect, 1181 root_pass = AddRenderPass(
1171 gfx::Transform()); 1182 render_passes, root_pass_id, viewport_rect, gfx::Transform());
1172 AddQuad(rootPass, viewportRect, SK_ColorGREEN); 1183 AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
1173 1184
1174 AddRenderPassQuad(rootPass, childPass, 0, skia::RefPtr<SkImageFilter>(), 1185 AddRenderPassQuad(root_pass,
1175 transform_causing_aa); 1186 child_pass,
1176 AddRenderPassQuad(childPass, grandChildPass); 1187 0,
1188 skia::RefPtr<SkImageFilter>(),
1189 transform_causing_aa);
1190 AddRenderPassQuad(child_pass, grand_child_pass);
1177 1191
1178 renderer_->DecideRenderPassAllocationsForFrame( 1192 renderer_->DecideRenderPassAllocationsForFrame(
1179 *mock_client_.render_passes_in_draw_order()); 1193 *mock_client_.render_passes_in_draw_order());
1180 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order()); 1194 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order());
1181 TestRenderPassProgramAA(); 1195 TestRenderPassProgramAA();
1182 1196
1183 // RenderPassColorMatrixProgramAA 1197 // RenderPassColorMatrixProgramAA
1184 renderPasses->clear(); 1198 render_passes->clear();
1185 1199
1186 grandChildPass = AddRenderPass(renderPasses, grandChildPassId, grandChildRect, 1200 grand_child_pass = AddRenderPass(render_passes,
1187 transform_causing_aa); 1201 grand_child_pass_id,
1188 AddClippedQuad(grandChildPass, grandChildRect, SK_ColorYELLOW); 1202 grand_child_rect,
1203 transform_causing_aa);
1204 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW);
1189 1205
1190 childPass = AddRenderPass(renderPasses, childPassId, childRect, 1206 child_pass = AddRenderPass(
1191 transform_causing_aa); 1207 render_passes, child_pass_id, child_rect, transform_causing_aa);
1192 AddQuad(childPass, childRect, SK_ColorBLUE); 1208 AddQuad(child_pass, child_rect, SK_ColorBLUE);
1193 1209
1194 rootPass = AddRenderPass(renderPasses, rootPassId, viewportRect, 1210 root_pass = AddRenderPass(
1195 gfx::Transform()); 1211 render_passes, root_pass_id, viewport_rect, gfx::Transform());
1196 AddQuad(rootPass, viewportRect, SK_ColorGREEN); 1212 AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
1197 1213
1198 AddRenderPassQuad(rootPass, childPass, 0, filter, transform_causing_aa); 1214 AddRenderPassQuad(root_pass, child_pass, 0, filter, transform_causing_aa);
1199 AddRenderPassQuad(childPass, grandChildPass); 1215 AddRenderPassQuad(child_pass, grand_child_pass);
1200 1216
1201 renderer_->DecideRenderPassAllocationsForFrame( 1217 renderer_->DecideRenderPassAllocationsForFrame(
1202 *mock_client_.render_passes_in_draw_order()); 1218 *mock_client_.render_passes_in_draw_order());
1203 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order()); 1219 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order());
1204 TestRenderPassColorMatrixProgramAA(); 1220 TestRenderPassColorMatrixProgramAA();
1205 1221
1206 // RenderPassMaskProgramAA 1222 // RenderPassMaskProgramAA
1207 renderPasses->clear(); 1223 render_passes->clear();
1208 1224
1209 grandChildPass = AddRenderPass(renderPasses, grandChildPassId, grandChildRect, 1225 grand_child_pass = AddRenderPass(render_passes,
1226 grand_child_pass_id,
1227 grand_child_rect,
1228 transform_causing_aa);
1229 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW);
1230
1231 child_pass = AddRenderPass(render_passes, child_pass_id, child_rect,
1210 transform_causing_aa); 1232 transform_causing_aa);
1211 AddClippedQuad(grandChildPass, grandChildRect, SK_ColorYELLOW); 1233 AddQuad(child_pass, child_rect, SK_ColorBLUE);
1212 1234
1213 childPass = AddRenderPass(renderPasses, childPassId, childRect, 1235 root_pass = AddRenderPass(render_passes, root_pass_id, viewport_rect,
1236 gfx::Transform());
1237 AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
1238
1239 AddRenderPassQuad(root_pass, child_pass, mask, skia::RefPtr<SkImageFilter>(),
1214 transform_causing_aa); 1240 transform_causing_aa);
1215 AddQuad(childPass, childRect, SK_ColorBLUE); 1241 AddRenderPassQuad(child_pass, grand_child_pass);
1216
1217 rootPass = AddRenderPass(renderPasses, rootPassId, viewportRect,
1218 gfx::Transform());
1219 AddQuad(rootPass, viewportRect, SK_ColorGREEN);
1220
1221 AddRenderPassQuad(rootPass, childPass, mask, skia::RefPtr<SkImageFilter>(),
1222 transform_causing_aa);
1223 AddRenderPassQuad(childPass, grandChildPass);
1224 1242
1225 renderer_->DecideRenderPassAllocationsForFrame( 1243 renderer_->DecideRenderPassAllocationsForFrame(
1226 *mock_client_.render_passes_in_draw_order()); 1244 *mock_client_.render_passes_in_draw_order());
1227 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order()); 1245 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order());
1228 TestRenderPassMaskProgramAA(); 1246 TestRenderPassMaskProgramAA();
1229 1247
1230 // RenderPassMaskColorMatrixProgramAA 1248 // RenderPassMaskColorMatrixProgramAA
1231 renderPasses->clear(); 1249 render_passes->clear();
1232 1250
1233 grandChildPass = AddRenderPass(renderPasses, grandChildPassId, grandChildRect, 1251 grand_child_pass = AddRenderPass(render_passes,
1252 grand_child_pass_id,
1253 grand_child_rect,
1254 transform_causing_aa);
1255 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW);
1256
1257 child_pass = AddRenderPass(render_passes, child_pass_id, child_rect,
1234 transform_causing_aa); 1258 transform_causing_aa);
1235 AddClippedQuad(grandChildPass, grandChildRect, SK_ColorYELLOW); 1259 AddQuad(child_pass, child_rect, SK_ColorBLUE);
1236 1260
1237 childPass = AddRenderPass(renderPasses, childPassId, childRect, 1261 root_pass = AddRenderPass(render_passes, root_pass_id, viewport_rect,
1238 transform_causing_aa); 1262 transform_causing_aa);
1239 AddQuad(childPass, childRect, SK_ColorBLUE); 1263 AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
1240 1264
1241 rootPass = AddRenderPass(renderPasses, rootPassId, viewportRect, 1265 AddRenderPassQuad(root_pass, child_pass, mask, filter, transform_causing_aa);
1242 transform_causing_aa); 1266 AddRenderPassQuad(child_pass, grand_child_pass);
1243 AddQuad(rootPass, viewportRect, SK_ColorGREEN);
1244
1245 AddRenderPassQuad(rootPass, childPass, mask, filter, transform_causing_aa);
1246 AddRenderPassQuad(childPass, grandChildPass);
1247 1267
1248 renderer_->DecideRenderPassAllocationsForFrame( 1268 renderer_->DecideRenderPassAllocationsForFrame(
1249 *mock_client_.render_passes_in_draw_order()); 1269 *mock_client_.render_passes_in_draw_order());
1250 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order()); 1270 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order());
1251 TestRenderPassMaskColorMatrixProgramAA(); 1271 TestRenderPassMaskColorMatrixProgramAA();
1252 } 1272 }
1253 1273
1254 class OutputSurfaceMockContext : public TestWebGraphicsContext3D { 1274 class OutputSurfaceMockContext : public TestWebGraphicsContext3D {
1255 public: 1275 public:
1256 // Specifically override methods even if they are unused (used in conjunction 1276 // Specifically override methods even if they are unused (used in conjunction
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 TestRenderPass* render_pass = AddRenderPass( 1331 TestRenderPass* render_pass = AddRenderPass(
1312 render_passes, render_pass_id, viewport_rect, gfx::Transform()); 1332 render_passes, render_pass_id, viewport_rect, gfx::Transform());
1313 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); 1333 AddQuad(render_pass, viewport_rect, SK_ColorGREEN);
1314 1334
1315 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); 1335 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return());
1316 1336
1317 EXPECT_CALL(output_surface_, Reshape(_)).Times(1); 1337 EXPECT_CALL(output_surface_, Reshape(_)).Times(1);
1318 1338
1319 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1); 1339 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1);
1320 1340
1321 EXPECT_CALL(*context(), drawElements(_, _, _, _)).Times(1); 1341 EXPECT_CALL(*Context(), drawElements(_, _, _, _)).Times(1);
1322 1342
1323 renderer_.DecideRenderPassAllocationsForFrame( 1343 renderer_.DecideRenderPassAllocationsForFrame(
1324 *render_passes_in_draw_order()); 1344 *render_passes_in_draw_order());
1325 renderer_.DrawFrame(render_passes_in_draw_order()); 1345 renderer_.DrawFrame(render_passes_in_draw_order());
1326 } 1346 }
1327 1347
1328 OutputSurfaceMockContext* context() { 1348 OutputSurfaceMockContext* Context() {
1329 return static_cast<OutputSurfaceMockContext*>(output_surface_.context3d()); 1349 return static_cast<OutputSurfaceMockContext*>(output_surface_.context3d());
1330 } 1350 }
1331 1351
1332 StrictMock<MockOutputSurface> output_surface_; 1352 StrictMock<MockOutputSurface> output_surface_;
1333 scoped_ptr<ResourceProvider> resource_provider_; 1353 scoped_ptr<ResourceProvider> resource_provider_;
1334 FakeRendererGL renderer_; 1354 FakeRendererGL renderer_;
1335 }; 1355 };
1336 1356
1337 TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) { 1357 TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) {
1338 DrawFrame(); 1358 DrawFrame();
(...skipping 28 matching lines...) Expand all
1367 } 1387 }
1368 }; 1388 };
1369 1389
1370 TEST_F(MockOutputSurfaceTestWithSendCompositorFrame, DrawFrame) { 1390 TEST_F(MockOutputSurfaceTestWithSendCompositorFrame, DrawFrame) {
1371 EXPECT_CALL(output_surface_, SendFrameToParentCompositor(_)).Times(1); 1391 EXPECT_CALL(output_surface_, SendFrameToParentCompositor(_)).Times(1);
1372 DrawFrame(); 1392 DrawFrame();
1373 } 1393 }
1374 1394
1375 } // namespace 1395 } // namespace
1376 } // namespace cc 1396 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698