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

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

Issue 2613903002: The great shader refactor: Move all programs to a common cache (Closed)
Patch Set: Incorporate review feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/program_binding.h » ('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/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 resource_provider_ = FakeResourceProvider::Create( 377 resource_provider_ = FakeResourceProvider::Create(
378 output_surface_->context_provider(), shared_bitmap_manager_.get()); 378 output_surface_->context_provider(), shared_bitmap_manager_.get());
379 renderer_.reset(new FakeRendererGL(&settings_, output_surface_.get(), 379 renderer_.reset(new FakeRendererGL(&settings_, output_surface_.get(),
380 resource_provider_.get())); 380 resource_provider_.get()));
381 renderer_->Initialize(); 381 renderer_->Initialize();
382 renderer_->SetVisible(true); 382 renderer_->SetVisible(true);
383 } 383 }
384 384
385 void TestRenderPassProgram(TexCoordPrecision precision, 385 void TestRenderPassProgram(TexCoordPrecision precision,
386 BlendMode blend_mode) { 386 BlendMode blend_mode) {
387 EXPECT_PROGRAM_VALID( 387 const Program* program = renderer_->GetProgramIfInitialized(
388 &renderer_->render_pass_program_[precision][blend_mode]); 388 ProgramKey::RenderPass(precision, SAMPLER_TYPE_2D, blend_mode, NO_AA,
389 EXPECT_EQ(renderer_->render_pass_program_[precision][blend_mode].program(), 389 NO_MASK, false, false));
390 renderer_->program_shadow_); 390 EXPECT_PROGRAM_VALID(program);
391 EXPECT_EQ(program->program(), renderer_->program_shadow_);
391 } 392 }
392 393
393 void TestRenderPassColorMatrixProgram(TexCoordPrecision precision, 394 void TestRenderPassColorMatrixProgram(TexCoordPrecision precision,
394 BlendMode blend_mode) { 395 BlendMode blend_mode) {
395 EXPECT_PROGRAM_VALID( 396 const Program* program = renderer_->GetProgramIfInitialized(
396 &renderer_->render_pass_color_matrix_program_[precision][blend_mode]); 397 ProgramKey::RenderPass(precision, SAMPLER_TYPE_2D, blend_mode, NO_AA,
397 EXPECT_EQ( 398 NO_MASK, false, true));
398 renderer_->render_pass_color_matrix_program_[precision][blend_mode] 399 EXPECT_PROGRAM_VALID(program);
399 .program(), 400 EXPECT_EQ(program->program(), renderer_->program_shadow_);
400 renderer_->program_shadow_);
401 } 401 }
402 402
403 void TestRenderPassMaskProgram(TexCoordPrecision precision, 403 void TestRenderPassMaskProgram(TexCoordPrecision precision,
404 SamplerType sampler, 404 SamplerType sampler,
405 BlendMode blend_mode) { 405 BlendMode blend_mode) {
406 EXPECT_PROGRAM_VALID( 406 const Program* program =
407 &renderer_->render_pass_mask_program_[precision] 407 renderer_->GetProgramIfInitialized(ProgramKey::RenderPass(
408 [sampler] 408 precision, sampler, blend_mode, NO_AA, HAS_MASK, false, false));
409 [blend_mode] 409 EXPECT_PROGRAM_VALID(program);
410 [NO_MASK]); 410 EXPECT_EQ(program->program(), renderer_->program_shadow_);
411 EXPECT_EQ(
412 renderer_->render_pass_mask_program_[precision]
413 [sampler]
414 [blend_mode]
415 [NO_MASK].program(),
416 renderer_->program_shadow_);
417 } 411 }
418 412
419 void TestRenderPassMaskColorMatrixProgram(TexCoordPrecision precision, 413 void TestRenderPassMaskColorMatrixProgram(TexCoordPrecision precision,
420 SamplerType sampler, 414 SamplerType sampler,
421 BlendMode blend_mode) { 415 BlendMode blend_mode) {
422 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_color_matrix_program_ 416 const Program* program =
423 [precision][sampler][blend_mode][NO_MASK]); 417 renderer_->GetProgramIfInitialized(ProgramKey::RenderPass(
424 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_ 418 precision, sampler, blend_mode, NO_AA, HAS_MASK, false, true));
425 [precision][sampler][blend_mode][NO_MASK].program(), 419 EXPECT_PROGRAM_VALID(program);
426 renderer_->program_shadow_); 420 EXPECT_EQ(program->program(), renderer_->program_shadow_);
427 } 421 }
428 422
429 void TestRenderPassProgramAA(TexCoordPrecision precision, 423 void TestRenderPassProgramAA(TexCoordPrecision precision,
430 BlendMode blend_mode) { 424 BlendMode blend_mode) {
431 EXPECT_PROGRAM_VALID( 425 const Program* program = renderer_->GetProgramIfInitialized(
432 &renderer_->render_pass_program_aa_[precision][blend_mode]); 426 ProgramKey::RenderPass(precision, SAMPLER_TYPE_2D, blend_mode, USE_AA,
433 EXPECT_EQ( 427 NO_MASK, false, false));
434 renderer_->render_pass_program_aa_[precision][blend_mode].program(), 428 EXPECT_PROGRAM_VALID(program);
435 renderer_->program_shadow_); 429 EXPECT_EQ(program->program(), renderer_->program_shadow_);
436 } 430 }
437 431
438 void TestRenderPassColorMatrixProgramAA(TexCoordPrecision precision, 432 void TestRenderPassColorMatrixProgramAA(TexCoordPrecision precision,
439 BlendMode blend_mode) { 433 BlendMode blend_mode) {
440 EXPECT_PROGRAM_VALID( 434 const Program* program = renderer_->GetProgramIfInitialized(
441 &renderer_ 435 ProgramKey::RenderPass(precision, SAMPLER_TYPE_2D, blend_mode, USE_AA,
442 ->render_pass_color_matrix_program_aa_[precision][blend_mode]); 436 NO_MASK, false, true));
443 EXPECT_EQ( 437 EXPECT_PROGRAM_VALID(program);
444 renderer_->render_pass_color_matrix_program_aa_[precision][blend_mode] 438 EXPECT_EQ(program->program(), renderer_->program_shadow_);
445 .program(),
446 renderer_->program_shadow_);
447 } 439 }
448 440
449 void TestRenderPassMaskProgramAA(TexCoordPrecision precision, 441 void TestRenderPassMaskProgramAA(TexCoordPrecision precision,
450 SamplerType sampler, 442 SamplerType sampler,
451 BlendMode blend_mode) { 443 BlendMode blend_mode) {
452 EXPECT_PROGRAM_VALID( 444 const Program* program =
453 &renderer_ 445 renderer_->GetProgramIfInitialized(ProgramKey::RenderPass(
454 ->render_pass_mask_program_aa_ 446 precision, sampler, blend_mode, USE_AA, HAS_MASK, false, false));
455 [precision][sampler][blend_mode][NO_MASK]); 447 EXPECT_PROGRAM_VALID(program);
456 EXPECT_EQ( 448 EXPECT_EQ(program->program(), renderer_->program_shadow_);
457 renderer_->render_pass_mask_program_aa_[precision][sampler][blend_mode]
458 [NO_MASK].program(),
459 renderer_->program_shadow_);
460 } 449 }
461 450
462 void TestRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision, 451 void TestRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision,
463 SamplerType sampler, 452 SamplerType sampler,
464 BlendMode blend_mode) { 453 BlendMode blend_mode) {
465 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_color_matrix_program_aa_ 454 const Program* program =
466 [precision][sampler][blend_mode][NO_MASK]); 455 renderer_->GetProgramIfInitialized(ProgramKey::RenderPass(
467 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_aa_ 456 precision, sampler, blend_mode, USE_AA, HAS_MASK, false, true));
468 [precision][sampler][blend_mode][NO_MASK].program(), 457 EXPECT_PROGRAM_VALID(program);
469 renderer_->program_shadow_); 458 EXPECT_EQ(program->program(), renderer_->program_shadow_);
470 } 459 }
471 460
472 void TestSolidColorProgramAA() { 461 void TestSolidColorProgramAA() {
473 EXPECT_PROGRAM_VALID(&renderer_->solid_color_program_aa_); 462 const Program* program =
474 EXPECT_EQ(renderer_->solid_color_program_aa_.program(), 463 renderer_->GetProgramIfInitialized(ProgramKey::SolidColor(USE_AA));
475 renderer_->program_shadow_); 464 EXPECT_PROGRAM_VALID(program);
465 EXPECT_EQ(program->program(), renderer_->program_shadow_);
476 } 466 }
477 467
478 RendererSettings settings_; 468 RendererSettings settings_;
479 FakeOutputSurfaceClient output_surface_client_; 469 FakeOutputSurfaceClient output_surface_client_;
480 std::unique_ptr<FakeOutputSurface> output_surface_; 470 std::unique_ptr<FakeOutputSurface> output_surface_;
481 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; 471 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_;
482 std::unique_ptr<ResourceProvider> resource_provider_; 472 std::unique_ptr<ResourceProvider> resource_provider_;
483 std::unique_ptr<FakeRendererGL> renderer_; 473 std::unique_ptr<FakeRendererGL> renderer_;
484 }; 474 };
485 475
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 renderer_->SetVisible(true); 1961 renderer_->SetVisible(true);
1972 Mock::VerifyAndClearExpectations(context_support_ptr_); 1962 Mock::VerifyAndClearExpectations(context_support_ptr_);
1973 1963
1974 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true)); 1964 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true));
1975 renderer_->SetVisible(false); 1965 renderer_->SetVisible(false);
1976 Mock::VerifyAndClearExpectations(context_support_ptr_); 1966 Mock::VerifyAndClearExpectations(context_support_ptr_);
1977 } 1967 }
1978 1968
1979 } // namespace 1969 } // namespace
1980 } // namespace cc 1970 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/program_binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698