| OLD | NEW |
| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 public: | 59 public: |
| 60 void TestShaders() { | 60 void TestShaders() { |
| 61 ASSERT_FALSE(renderer_->IsContextLost()); | 61 ASSERT_FALSE(renderer_->IsContextLost()); |
| 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_->GetRenderPassProgram()); | |
| 70 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassProgramAA()); | |
| 71 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassMaskProgram()); | |
| 72 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassMaskProgramAA()); | |
| 73 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassColorMatrixProgram()); | |
| 74 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassMaskColorMatrixProgramAA()); | |
| 75 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassColorMatrixProgramAA()); | |
| 76 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassMaskColorMatrixProgram()); | |
| 77 EXPECT_PROGRAM_VALID(renderer_->GetTextureProgram()); | |
| 78 EXPECT_PROGRAM_VALID(renderer_->GetTextureProgramFlip()); | |
| 79 EXPECT_PROGRAM_VALID(renderer_->GetTextureIOSurfaceProgram()); | |
| 80 EXPECT_PROGRAM_VALID(renderer_->GetVideoYUVProgram()); | |
| 81 // This is unlikely to be ever true in tests due to usage of osmesa. | |
| 82 if (renderer_->Capabilities().using_egl_image) | |
| 83 EXPECT_PROGRAM_VALID(renderer_->GetVideoStreamTextureProgram()); | |
| 84 else | |
| 85 EXPECT_FALSE(renderer_->GetVideoStreamTextureProgram()); | |
| 86 EXPECT_PROGRAM_VALID(renderer_->GetDebugBorderProgram()); | 69 EXPECT_PROGRAM_VALID(renderer_->GetDebugBorderProgram()); |
| 87 EXPECT_PROGRAM_VALID(renderer_->GetSolidColorProgram()); | 70 EXPECT_PROGRAM_VALID(renderer_->GetSolidColorProgram()); |
| 88 EXPECT_PROGRAM_VALID(renderer_->GetSolidColorProgramAA()); | 71 EXPECT_PROGRAM_VALID(renderer_->GetSolidColorProgramAA()); |
| 72 //TestShadersWithTexCoordPrecision(TexCoordPrecisionMedium); |
| 73 TestShadersWithTexCoordPrecision(TexCoordPrecisionHigh); |
| 89 ASSERT_FALSE(renderer_->IsContextLost()); | 74 ASSERT_FALSE(renderer_->IsContextLost()); |
| 90 } | 75 } |
| 76 |
| 77 void TestShadersWithTexCoordPrecision(TexCoordPrecision precision) { |
| 78 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassProgram(precision)); |
| 79 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassProgramAA(precision)); |
| 80 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassMaskProgram(precision)); |
| 81 EXPECT_PROGRAM_VALID(renderer_->GetRenderPassMaskProgramAA(precision)); |
| 82 EXPECT_PROGRAM_VALID( |
| 83 renderer_->GetRenderPassColorMatrixProgram(precision)); |
| 84 EXPECT_PROGRAM_VALID( |
| 85 renderer_->GetRenderPassMaskColorMatrixProgramAA(precision)); |
| 86 EXPECT_PROGRAM_VALID( |
| 87 renderer_->GetRenderPassColorMatrixProgramAA(precision)); |
| 88 EXPECT_PROGRAM_VALID( |
| 89 renderer_->GetRenderPassMaskColorMatrixProgram(precision)); |
| 90 EXPECT_PROGRAM_VALID(renderer_->GetTextureProgram(precision)); |
| 91 EXPECT_PROGRAM_VALID(renderer_->GetTextureProgramFlip(precision)); |
| 92 EXPECT_PROGRAM_VALID(renderer_->GetTextureIOSurfaceProgram(precision)); |
| 93 EXPECT_PROGRAM_VALID(renderer_->GetVideoYUVProgram(precision)); |
| 94 // This is unlikely to be ever true in tests due to usage of osmesa. |
| 95 if (renderer_->Capabilities().using_egl_image) |
| 96 EXPECT_PROGRAM_VALID(renderer_->GetVideoStreamTextureProgram(precision)); |
| 97 else |
| 98 EXPECT_FALSE(renderer_->GetVideoStreamTextureProgram(precision)); |
| 99 } |
| 91 }; | 100 }; |
| 92 | 101 |
| 93 namespace { | 102 namespace { |
| 94 | 103 |
| 95 #if !defined(OS_ANDROID) | 104 #if !defined(OS_ANDROID) |
| 96 TEST_F(GLRendererShaderPixelTest, AllShadersCompile) { TestShaders(); } | 105 TEST_F(GLRendererShaderPixelTest, AllShadersCompile) { TestShaders(); } |
| 97 #endif | 106 #endif |
| 98 | 107 |
| 99 class FrameCountingMemoryAllocationSettingContext | 108 class FrameCountingMemoryAllocationSettingContext |
| 100 : public TestWebGraphicsContext3D { | 109 : public TestWebGraphicsContext3D { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 scoped_ptr<LayerImpl> root_layer_; | 211 scoped_ptr<LayerImpl> root_layer_; |
| 203 RenderPassList render_passes_in_draw_order_; | 212 RenderPassList render_passes_in_draw_order_; |
| 204 size_t memory_allocation_limit_bytes_; | 213 size_t memory_allocation_limit_bytes_; |
| 205 }; | 214 }; |
| 206 | 215 |
| 207 class FakeRendererGL : public GLRenderer { | 216 class FakeRendererGL : public GLRenderer { |
| 208 public: | 217 public: |
| 209 FakeRendererGL(RendererClient* client, | 218 FakeRendererGL(RendererClient* client, |
| 210 OutputSurface* output_surface, | 219 OutputSurface* output_surface, |
| 211 ResourceProvider* resource_provider) | 220 ResourceProvider* resource_provider) |
| 212 : GLRenderer(client, output_surface, resource_provider) {} | 221 : GLRenderer(client, output_surface, resource_provider, 0) {} |
| 213 | 222 |
| 214 // GLRenderer methods. | 223 // GLRenderer methods. |
| 215 | 224 |
| 216 // Changing visibility to public. | 225 // Changing visibility to public. |
| 217 using GLRenderer::Initialize; | 226 using GLRenderer::Initialize; |
| 218 using GLRenderer::IsBackbufferDiscarded; | 227 using GLRenderer::IsBackbufferDiscarded; |
| 219 using GLRenderer::DoDrawQuad; | 228 using GLRenderer::DoDrawQuad; |
| 220 using GLRenderer::BeginDrawingFrame; | 229 using GLRenderer::BeginDrawingFrame; |
| 221 using GLRenderer::FinishDrawingQuadList; | 230 using GLRenderer::FinishDrawingQuadList; |
| 222 }; | 231 }; |
| 223 | 232 |
| 224 class GLRendererTest : public testing::Test { | 233 class GLRendererTest : public testing::Test { |
| 225 protected: | 234 protected: |
| 226 GLRendererTest() | 235 GLRendererTest() |
| 227 : suggest_have_backbuffer_yes_(1, true), | 236 : suggest_have_backbuffer_yes_(1, true), |
| 228 suggest_have_backbuffer_no_(1, false), | 237 suggest_have_backbuffer_no_(1, false), |
| 229 output_surface_(FakeOutputSurface::Create3d( | 238 output_surface_(FakeOutputSurface::Create3d( |
| 230 scoped_ptr<WebKit::WebGraphicsContext3D>( | 239 scoped_ptr<WebKit::WebGraphicsContext3D>( |
| 231 new FrameCountingMemoryAllocationSettingContext()))), | 240 new FrameCountingMemoryAllocationSettingContext()))), |
| 232 resource_provider_(ResourceProvider::Create(output_surface_.get())), | 241 resource_provider_(ResourceProvider::Create(output_surface_.get(), 0)), |
| 233 renderer_(&mock_client_, | 242 renderer_(&mock_client_, |
| 234 output_surface_.get(), | 243 output_surface_.get(), |
| 235 resource_provider_.get()) {} | 244 resource_provider_.get()) {} |
| 236 | 245 |
| 237 virtual void SetUp() { renderer_.Initialize(); } | 246 virtual void SetUp() { renderer_.Initialize(); } |
| 238 | 247 |
| 239 void SwapBuffers() { renderer_.SwapBuffers(); } | 248 void SwapBuffers() { renderer_.SwapBuffers(); } |
| 240 | 249 |
| 241 FrameCountingMemoryAllocationSettingContext* context() { | 250 FrameCountingMemoryAllocationSettingContext* context() { |
| 242 return static_cast<FrameCountingMemoryAllocationSettingContext*>( | 251 return static_cast<FrameCountingMemoryAllocationSettingContext*>( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 254 | 263 |
| 255 // Closing the namespace here so that GLRendererShaderTest can take advantage | 264 // Closing the namespace here so that GLRendererShaderTest can take advantage |
| 256 // of the friend relationship with GLRenderer and all of the mock classes | 265 // of the friend relationship with GLRenderer and all of the mock classes |
| 257 // declared above it. | 266 // declared above it. |
| 258 } // namespace | 267 } // namespace |
| 259 | 268 |
| 260 class GLRendererShaderTest : public testing::Test { | 269 class GLRendererShaderTest : public testing::Test { |
| 261 protected: | 270 protected: |
| 262 GLRendererShaderTest() | 271 GLRendererShaderTest() |
| 263 : output_surface_(FakeOutputSurface::Create3d()), | 272 : output_surface_(FakeOutputSurface::Create3d()), |
| 264 resource_provider_(ResourceProvider::Create(output_surface_.get())), | 273 resource_provider_(ResourceProvider::Create(output_surface_.get(), 0)), |
| 265 renderer_(GLRenderer::Create(&mock_client_, output_surface_.get(), | 274 renderer_(GLRenderer::Create(&mock_client_, output_surface_.get(), |
| 266 resource_provider_.get())) { | 275 resource_provider_.get(), 0)) { |
| 267 } | 276 } |
| 268 | 277 |
| 269 void TestRenderPassProgram() { | 278 void TestRenderPassProgram() { |
| 270 EXPECT_PROGRAM_VALID(renderer_->render_pass_program_); | 279 EXPECT_PROGRAM_VALID(renderer_->render_pass_program_); |
| 271 EXPECT_TRUE(renderer_->program_shadow_ == | 280 EXPECT_TRUE(renderer_->program_shadow_ == |
| 272 renderer_->render_pass_program_->program()); | 281 renderer_->render_pass_program_->program()); |
| 273 } | 282 } |
| 274 | 283 |
| 275 void TestRenderPassColorMatrixProgram() { | 284 void TestRenderPassColorMatrixProgram() { |
| 276 EXPECT_PROGRAM_VALID(renderer_->render_pass_color_matrix_program_); | 285 EXPECT_PROGRAM_VALID(renderer_->render_pass_color_matrix_program_); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 }; | 563 }; |
| 555 | 564 |
| 556 // This test isn't using the same fixture as GLRendererTest, and you can't mix | 565 // This test isn't using the same fixture as GLRendererTest, and you can't mix |
| 557 // TEST() and TEST_F() with the same name, Hence LRC2. | 566 // TEST() and TEST_F() with the same name, Hence LRC2. |
| 558 TEST(GLRendererTest2, InitializationDoesNotMakeSynchronousCalls) { | 567 TEST(GLRendererTest2, InitializationDoesNotMakeSynchronousCalls) { |
| 559 FakeRendererClient mock_client; | 568 FakeRendererClient mock_client; |
| 560 scoped_ptr<OutputSurface> output_surface( | 569 scoped_ptr<OutputSurface> output_surface( |
| 561 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 570 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( |
| 562 new ForbidSynchronousCallContext))); | 571 new ForbidSynchronousCallContext))); |
| 563 scoped_ptr<ResourceProvider> resource_provider( | 572 scoped_ptr<ResourceProvider> resource_provider( |
| 564 ResourceProvider::Create(output_surface.get())); | 573 ResourceProvider::Create(output_surface.get(), 0)); |
| 565 FakeRendererGL renderer( | 574 FakeRendererGL renderer( |
| 566 &mock_client, output_surface.get(), resource_provider.get()); | 575 &mock_client, output_surface.get(), resource_provider.get()); |
| 567 | 576 |
| 568 EXPECT_TRUE(renderer.Initialize()); | 577 EXPECT_TRUE(renderer.Initialize()); |
| 569 } | 578 } |
| 570 | 579 |
| 571 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { | 580 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { |
| 572 public: | 581 public: |
| 573 LoseContextOnFirstGetContext() : context_lost_(false) {} | 582 LoseContextOnFirstGetContext() : context_lost_(false) {} |
| 574 | 583 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 593 private: | 602 private: |
| 594 bool context_lost_; | 603 bool context_lost_; |
| 595 }; | 604 }; |
| 596 | 605 |
| 597 TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) { | 606 TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) { |
| 598 FakeRendererClient mock_client; | 607 FakeRendererClient mock_client; |
| 599 scoped_ptr<OutputSurface> output_surface( | 608 scoped_ptr<OutputSurface> output_surface( |
| 600 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 609 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( |
| 601 new LoseContextOnFirstGetContext))); | 610 new LoseContextOnFirstGetContext))); |
| 602 scoped_ptr<ResourceProvider> resource_provider( | 611 scoped_ptr<ResourceProvider> resource_provider( |
| 603 ResourceProvider::Create(output_surface.get())); | 612 ResourceProvider::Create(output_surface.get(), 0)); |
| 604 FakeRendererGL renderer( | 613 FakeRendererGL renderer( |
| 605 &mock_client, output_surface.get(), resource_provider.get()); | 614 &mock_client, output_surface.get(), resource_provider.get()); |
| 606 | 615 |
| 607 renderer.Initialize(); | 616 renderer.Initialize(); |
| 608 } | 617 } |
| 609 | 618 |
| 610 class ContextThatDoesNotSupportMemoryManagmentExtensions | 619 class ContextThatDoesNotSupportMemoryManagmentExtensions |
| 611 : public TestWebGraphicsContext3D { | 620 : public TestWebGraphicsContext3D { |
| 612 public: | 621 public: |
| 613 ContextThatDoesNotSupportMemoryManagmentExtensions() {} | 622 ContextThatDoesNotSupportMemoryManagmentExtensions() {} |
| 614 | 623 |
| 615 // WebGraphicsContext3D methods. | 624 // WebGraphicsContext3D methods. |
| 616 | 625 |
| 617 // This method would normally do a glSwapBuffers under the hood. | 626 // This method would normally do a glSwapBuffers under the hood. |
| 618 virtual void prepareTexture() {} | 627 virtual void prepareTexture() {} |
| 619 virtual void setMemoryAllocationChangedCallbackCHROMIUM( | 628 virtual void setMemoryAllocationChangedCallbackCHROMIUM( |
| 620 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) {} | 629 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) {} |
| 621 virtual WebString getString(WebKit::WGC3Denum name) { return WebString(); } | 630 virtual WebString getString(WebKit::WGC3Denum name) { return WebString(); } |
| 622 }; | 631 }; |
| 623 | 632 |
| 624 TEST( | 633 TEST( |
| 625 GLRendererTest2, | 634 GLRendererTest2, |
| 626 InitWithoutGpuMemManagerExtensionSupportShouldDefaultToNonZeroAllocation) { | 635 InitWithoutGpuMemManagerExtensionSupportShouldDefaultToNonZeroAllocation) { |
| 627 FakeRendererClient mock_client; | 636 FakeRendererClient mock_client; |
| 628 scoped_ptr<OutputSurface> output_surface( | 637 scoped_ptr<OutputSurface> output_surface( |
| 629 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 638 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( |
| 630 new ContextThatDoesNotSupportMemoryManagmentExtensions))); | 639 new ContextThatDoesNotSupportMemoryManagmentExtensions))); |
| 631 scoped_ptr<ResourceProvider> resource_provider( | 640 scoped_ptr<ResourceProvider> resource_provider( |
| 632 ResourceProvider::Create(output_surface.get())); | 641 ResourceProvider::Create(output_surface.get(), 0)); |
| 633 FakeRendererGL renderer( | 642 FakeRendererGL renderer( |
| 634 &mock_client, output_surface.get(), resource_provider.get()); | 643 &mock_client, output_surface.get(), resource_provider.get()); |
| 635 | 644 |
| 636 renderer.Initialize(); | 645 renderer.Initialize(); |
| 637 | 646 |
| 638 EXPECT_GT(mock_client.memory_allocation_limit_bytes(), 0ul); | 647 EXPECT_GT(mock_client.memory_allocation_limit_bytes(), 0ul); |
| 639 } | 648 } |
| 640 | 649 |
| 641 class ClearCountingContext : public TestWebGraphicsContext3D { | 650 class ClearCountingContext : public TestWebGraphicsContext3D { |
| 642 public: | 651 public: |
| 643 ClearCountingContext() : clear_(0) {} | 652 ClearCountingContext() : clear_(0) {} |
| 644 | 653 |
| 645 virtual void clear(WGC3Dbitfield) { clear_++; } | 654 virtual void clear(WGC3Dbitfield) { clear_++; } |
| 646 | 655 |
| 647 int clear_count() const { return clear_; } | 656 int clear_count() const { return clear_; } |
| 648 | 657 |
| 649 private: | 658 private: |
| 650 int clear_; | 659 int clear_; |
| 651 }; | 660 }; |
| 652 | 661 |
| 653 TEST(GLRendererTest2, OpaqueBackground) { | 662 TEST(GLRendererTest2, OpaqueBackground) { |
| 654 FakeRendererClient mock_client; | 663 FakeRendererClient mock_client; |
| 655 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 664 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 656 scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); | 665 scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); |
| 657 ClearCountingContext* context = | 666 ClearCountingContext* context = |
| 658 static_cast<ClearCountingContext*>(output_surface->context3d()); | 667 static_cast<ClearCountingContext*>(output_surface->context3d()); |
| 659 scoped_ptr<ResourceProvider> resource_provider( | 668 scoped_ptr<ResourceProvider> resource_provider( |
| 660 ResourceProvider::Create(output_surface.get())); | 669 ResourceProvider::Create(output_surface.get(), 0)); |
| 661 FakeRendererGL renderer( | 670 FakeRendererGL renderer( |
| 662 &mock_client, output_surface.get(), resource_provider.get()); | 671 &mock_client, output_surface.get(), resource_provider.get()); |
| 663 | 672 |
| 664 mock_client.root_render_pass()->has_transparent_background = false; | 673 mock_client.root_render_pass()->has_transparent_background = false; |
| 665 | 674 |
| 666 EXPECT_TRUE(renderer.Initialize()); | 675 EXPECT_TRUE(renderer.Initialize()); |
| 667 | 676 |
| 668 renderer.DrawFrame(mock_client.render_passes_in_draw_order()); | 677 renderer.DrawFrame(mock_client.render_passes_in_draw_order()); |
| 669 | 678 |
| 670 // On DEBUG builds, render passes with opaque background clear to blue to | 679 // On DEBUG builds, render passes with opaque background clear to blue to |
| 671 // easily see regions that were not drawn on the screen. | 680 // easily see regions that were not drawn on the screen. |
| 672 #ifdef NDEBUG | 681 #ifdef NDEBUG |
| 673 EXPECT_EQ(0, context->clear_count()); | 682 EXPECT_EQ(0, context->clear_count()); |
| 674 #else | 683 #else |
| 675 EXPECT_EQ(1, context->clear_count()); | 684 EXPECT_EQ(1, context->clear_count()); |
| 676 #endif | 685 #endif |
| 677 } | 686 } |
| 678 | 687 |
| 679 TEST(GLRendererTest2, TransparentBackground) { | 688 TEST(GLRendererTest2, TransparentBackground) { |
| 680 FakeRendererClient mock_client; | 689 FakeRendererClient mock_client; |
| 681 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 690 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 682 scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); | 691 scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); |
| 683 ClearCountingContext* context = | 692 ClearCountingContext* context = |
| 684 static_cast<ClearCountingContext*>(output_surface->context3d()); | 693 static_cast<ClearCountingContext*>(output_surface->context3d()); |
| 685 scoped_ptr<ResourceProvider> resource_provider( | 694 scoped_ptr<ResourceProvider> resource_provider( |
| 686 ResourceProvider::Create(output_surface.get())); | 695 ResourceProvider::Create(output_surface.get(), 0)); |
| 687 FakeRendererGL renderer( | 696 FakeRendererGL renderer( |
| 688 &mock_client, output_surface.get(), resource_provider.get()); | 697 &mock_client, output_surface.get(), resource_provider.get()); |
| 689 | 698 |
| 690 mock_client.root_render_pass()->has_transparent_background = true; | 699 mock_client.root_render_pass()->has_transparent_background = true; |
| 691 | 700 |
| 692 EXPECT_TRUE(renderer.Initialize()); | 701 EXPECT_TRUE(renderer.Initialize()); |
| 693 | 702 |
| 694 renderer.DrawFrame(mock_client.render_passes_in_draw_order()); | 703 renderer.DrawFrame(mock_client.render_passes_in_draw_order()); |
| 695 | 704 |
| 696 EXPECT_EQ(1, context->clear_count()); | 705 EXPECT_EQ(1, context->clear_count()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 | 756 |
| 748 TEST(GLRendererTest2, VisibilityChangeIsLastCall) { | 757 TEST(GLRendererTest2, VisibilityChangeIsLastCall) { |
| 749 FakeRendererClient mock_client; | 758 FakeRendererClient mock_client; |
| 750 scoped_ptr<OutputSurface> output_surface( | 759 scoped_ptr<OutputSurface> output_surface( |
| 751 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 760 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( |
| 752 new VisibilityChangeIsLastCallTrackingContext))); | 761 new VisibilityChangeIsLastCallTrackingContext))); |
| 753 VisibilityChangeIsLastCallTrackingContext* context = | 762 VisibilityChangeIsLastCallTrackingContext* context = |
| 754 static_cast<VisibilityChangeIsLastCallTrackingContext*>( | 763 static_cast<VisibilityChangeIsLastCallTrackingContext*>( |
| 755 output_surface->context3d()); | 764 output_surface->context3d()); |
| 756 scoped_ptr<ResourceProvider> resource_provider( | 765 scoped_ptr<ResourceProvider> resource_provider( |
| 757 ResourceProvider::Create(output_surface.get())); | 766 ResourceProvider::Create(output_surface.get(), 0)); |
| 758 FakeRendererGL renderer( | 767 FakeRendererGL renderer( |
| 759 &mock_client, output_surface.get(), resource_provider.get()); | 768 &mock_client, output_surface.get(), resource_provider.get()); |
| 760 | 769 |
| 761 EXPECT_TRUE(renderer.Initialize()); | 770 EXPECT_TRUE(renderer.Initialize()); |
| 762 | 771 |
| 763 bool last_call_was_set_visiblity = false; | 772 bool last_call_was_set_visiblity = false; |
| 764 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to the | 773 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to the |
| 765 // GPU process, after glFlush is called, and after the RendererClient's | 774 // GPU process, after glFlush is called, and after the RendererClient's |
| 766 // EnforceManagedMemoryPolicy is called. Plumb this tracking between both the | 775 // EnforceManagedMemoryPolicy is called. Plumb this tracking between both the |
| 767 // RenderClient and the Context by giving them both a pointer to a variable on | 776 // RenderClient and the Context by giving them both a pointer to a variable on |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 }; | 815 }; |
| 807 | 816 |
| 808 TEST(GLRendererTest2, ActiveTextureState) { | 817 TEST(GLRendererTest2, ActiveTextureState) { |
| 809 FakeRendererClient fake_client; | 818 FakeRendererClient fake_client; |
| 810 scoped_ptr<OutputSurface> output_surface( | 819 scoped_ptr<OutputSurface> output_surface( |
| 811 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 820 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( |
| 812 new TextureStateTrackingContext))); | 821 new TextureStateTrackingContext))); |
| 813 TextureStateTrackingContext* context = | 822 TextureStateTrackingContext* context = |
| 814 static_cast<TextureStateTrackingContext*>(output_surface->context3d()); | 823 static_cast<TextureStateTrackingContext*>(output_surface->context3d()); |
| 815 scoped_ptr<ResourceProvider> resource_provider( | 824 scoped_ptr<ResourceProvider> resource_provider( |
| 816 ResourceProvider::Create(output_surface.get())); | 825 ResourceProvider::Create(output_surface.get(), 0)); |
| 817 FakeRendererGL renderer( | 826 FakeRendererGL renderer( |
| 818 &fake_client, output_surface.get(), resource_provider.get()); | 827 &fake_client, output_surface.get(), resource_provider.get()); |
| 819 | 828 |
| 820 // During initialization we are allowed to set any texture parameters. | 829 // During initialization we are allowed to set any texture parameters. |
| 821 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); | 830 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); |
| 822 EXPECT_TRUE(renderer.Initialize()); | 831 EXPECT_TRUE(renderer.Initialize()); |
| 823 | 832 |
| 824 cc::RenderPass::Id id(1, 1); | 833 cc::RenderPass::Id id(1, 1); |
| 825 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 834 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
| 826 pass->SetNew(id, | 835 pass->SetNew(id, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 | 900 |
| 892 TEST(GLRendererTest2, ShouldClearRootRenderPass) { | 901 TEST(GLRendererTest2, ShouldClearRootRenderPass) { |
| 893 NoClearRootRenderPassFakeClient mock_client; | 902 NoClearRootRenderPassFakeClient mock_client; |
| 894 scoped_ptr<OutputSurface> output_surface( | 903 scoped_ptr<OutputSurface> output_surface( |
| 895 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 904 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( |
| 896 new NoClearRootRenderPassMockContext))); | 905 new NoClearRootRenderPassMockContext))); |
| 897 NoClearRootRenderPassMockContext* mock_context = | 906 NoClearRootRenderPassMockContext* mock_context = |
| 898 static_cast<NoClearRootRenderPassMockContext*>( | 907 static_cast<NoClearRootRenderPassMockContext*>( |
| 899 output_surface->context3d()); | 908 output_surface->context3d()); |
| 900 scoped_ptr<ResourceProvider> resource_provider( | 909 scoped_ptr<ResourceProvider> resource_provider( |
| 901 ResourceProvider::Create(output_surface.get())); | 910 ResourceProvider::Create(output_surface.get(), 0)); |
| 902 FakeRendererGL renderer( | 911 FakeRendererGL renderer( |
| 903 &mock_client, output_surface.get(), resource_provider.get()); | 912 &mock_client, output_surface.get(), resource_provider.get()); |
| 904 EXPECT_TRUE(renderer.Initialize()); | 913 EXPECT_TRUE(renderer.Initialize()); |
| 905 | 914 |
| 906 gfx::Rect viewport_rect(mock_client.DeviceViewportSize()); | 915 gfx::Rect viewport_rect(mock_client.DeviceViewportSize()); |
| 907 ScopedPtrVector<RenderPass>& render_passes = | 916 ScopedPtrVector<RenderPass>& render_passes = |
| 908 *mock_client.render_passes_in_draw_order(); | 917 *mock_client.render_passes_in_draw_order(); |
| 909 render_passes.clear(); | 918 render_passes.clear(); |
| 910 | 919 |
| 911 RenderPass::Id root_pass_id(1, 0); | 920 RenderPass::Id root_pass_id(1, 0); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 private: | 970 private: |
| 962 bool scissor_enabled_; | 971 bool scissor_enabled_; |
| 963 }; | 972 }; |
| 964 | 973 |
| 965 TEST(GLRendererTest2, ScissorTestWhenClearing) { | 974 TEST(GLRendererTest2, ScissorTestWhenClearing) { |
| 966 FakeRendererClient mock_client; | 975 FakeRendererClient mock_client; |
| 967 scoped_ptr<OutputSurface> output_surface( | 976 scoped_ptr<OutputSurface> output_surface( |
| 968 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 977 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( |
| 969 new ScissorTestOnClearCheckingContext))); | 978 new ScissorTestOnClearCheckingContext))); |
| 970 scoped_ptr<ResourceProvider> resource_provider( | 979 scoped_ptr<ResourceProvider> resource_provider( |
| 971 ResourceProvider::Create(output_surface.get())); | 980 ResourceProvider::Create(output_surface.get(), 0)); |
| 972 FakeRendererGL renderer( | 981 FakeRendererGL renderer( |
| 973 &mock_client, output_surface.get(), resource_provider.get()); | 982 &mock_client, output_surface.get(), resource_provider.get()); |
| 974 EXPECT_TRUE(renderer.Initialize()); | 983 EXPECT_TRUE(renderer.Initialize()); |
| 975 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); | 984 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); |
| 976 | 985 |
| 977 gfx::Rect viewport_rect(mock_client.DeviceViewportSize()); | 986 gfx::Rect viewport_rect(mock_client.DeviceViewportSize()); |
| 978 ScopedPtrVector<RenderPass>& render_passes = | 987 ScopedPtrVector<RenderPass>& render_passes = |
| 979 *mock_client.render_passes_in_draw_order(); | 988 *mock_client.render_passes_in_draw_order(); |
| 980 render_passes.clear(); | 989 render_passes.clear(); |
| 981 | 990 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 MOCK_METHOD0(DiscardBackbuffer, void()); | 1285 MOCK_METHOD0(DiscardBackbuffer, void()); |
| 1277 MOCK_METHOD1(Reshape, void(gfx::Size size)); | 1286 MOCK_METHOD1(Reshape, void(gfx::Size size)); |
| 1278 MOCK_METHOD0(BindFramebuffer, void()); | 1287 MOCK_METHOD0(BindFramebuffer, void()); |
| 1279 MOCK_METHOD1(PostSubBuffer, void(gfx::Rect rect)); | 1288 MOCK_METHOD1(PostSubBuffer, void(gfx::Rect rect)); |
| 1280 MOCK_METHOD0(SwapBuffers, void()); | 1289 MOCK_METHOD0(SwapBuffers, void()); |
| 1281 }; | 1290 }; |
| 1282 | 1291 |
| 1283 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { | 1292 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { |
| 1284 protected: | 1293 protected: |
| 1285 MockOutputSurfaceTest() | 1294 MockOutputSurfaceTest() |
| 1286 : resource_provider_(ResourceProvider::Create(&output_surface_)), | 1295 : resource_provider_(ResourceProvider::Create(&output_surface_, 0)), |
| 1287 renderer_(this, &output_surface_, resource_provider_.get()) {} | 1296 renderer_(this, &output_surface_, resource_provider_.get()) {} |
| 1288 | 1297 |
| 1289 virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); } | 1298 virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); } |
| 1290 | 1299 |
| 1291 void SwapBuffers() { renderer_.SwapBuffers(); } | 1300 void SwapBuffers() { renderer_.SwapBuffers(); } |
| 1292 | 1301 |
| 1293 void DrawFrame() { | 1302 void DrawFrame() { |
| 1294 gfx::Rect viewport_rect(DeviceViewportSize()); | 1303 gfx::Rect viewport_rect(DeviceViewportSize()); |
| 1295 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); | 1304 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); |
| 1296 render_passes->clear(); | 1305 render_passes->clear(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 } | 1364 } |
| 1356 }; | 1365 }; |
| 1357 | 1366 |
| 1358 TEST_F(MockOutputSurfaceTestWithSendCompositorFrame, DrawFrame) { | 1367 TEST_F(MockOutputSurfaceTestWithSendCompositorFrame, DrawFrame) { |
| 1359 EXPECT_CALL(output_surface_, SendFrameToParentCompositor(_)).Times(1); | 1368 EXPECT_CALL(output_surface_, SendFrameToParentCompositor(_)).Times(1); |
| 1360 DrawFrame(); | 1369 DrawFrame(); |
| 1361 } | 1370 } |
| 1362 | 1371 |
| 1363 } // namespace | 1372 } // namespace |
| 1364 } // namespace cc | 1373 } // namespace cc |
| OLD | NEW |