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

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