| 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/gl_renderer.h" | 5 #include "cc/gl_renderer.h" |
| 6 | 6 |
| 7 #include "cc/compositor_frame_metadata.h" | 7 #include "cc/compositor_frame_metadata.h" |
| 8 #include "cc/draw_quad.h" | 8 #include "cc/draw_quad.h" |
| 9 #include "cc/prioritized_resource_manager.h" | 9 #include "cc/prioritized_resource_manager.h" |
| 10 #include "cc/resource_provider.h" | 10 #include "cc/resource_provider.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 virtual void SetUp() | 135 virtual void SetUp() |
| 136 { | 136 { |
| 137 m_renderer.initialize(); | 137 m_renderer.initialize(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void swapBuffers() | 140 void swapBuffers() |
| 141 { | 141 { |
| 142 m_renderer.swapBuffers(); | 142 m_renderer.swapBuffers(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 FrameCountingMemoryAllocationSettingContext* context() { return static_cast<
FrameCountingMemoryAllocationSettingContext*>(m_outputSurface->Context3D()); } | 145 FrameCountingMemoryAllocationSettingContext* context() { return static_cast<
FrameCountingMemoryAllocationSettingContext*>(m_outputSurface->context3d()); } |
| 146 | 146 |
| 147 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; | 147 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; |
| 148 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; | 148 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; |
| 149 | 149 |
| 150 scoped_ptr<OutputSurface> m_outputSurface; | 150 scoped_ptr<OutputSurface> m_outputSurface; |
| 151 FakeRendererClient m_mockClient; | 151 FakeRendererClient m_mockClient; |
| 152 scoped_ptr<ResourceProvider> m_resourceProvider; | 152 scoped_ptr<ResourceProvider> m_resourceProvider; |
| 153 FakeRendererGL m_renderer; | 153 FakeRendererGL m_renderer; |
| 154 }; | 154 }; |
| 155 | 155 |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 int clearCount() const { return m_clear; } | 394 int clearCount() const { return m_clear; } |
| 395 | 395 |
| 396 private: | 396 private: |
| 397 int m_clear; | 397 int m_clear; |
| 398 }; | 398 }; |
| 399 | 399 |
| 400 TEST(GLRendererTest2, opaqueBackground) | 400 TEST(GLRendererTest2, opaqueBackground) |
| 401 { | 401 { |
| 402 FakeRendererClient mockClient; | 402 FakeRendererClient mockClient; |
| 403 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); | 403 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); |
| 404 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->Context3D()); | 404 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->context3d()); |
| 405 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 405 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 406 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); | 406 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
| 407 | 407 |
| 408 mockClient.rootRenderPass()->has_transparent_background = false; | 408 mockClient.rootRenderPass()->has_transparent_background = false; |
| 409 | 409 |
| 410 EXPECT_TRUE(renderer.initialize()); | 410 EXPECT_TRUE(renderer.initialize()); |
| 411 | 411 |
| 412 renderer.drawFrame(mockClient.renderPassesInDrawOrder()); | 412 renderer.drawFrame(mockClient.renderPassesInDrawOrder()); |
| 413 | 413 |
| 414 // On DEBUG builds, render passes with opaque background clear to blue to | 414 // On DEBUG builds, render passes with opaque background clear to blue to |
| 415 // easily see regions that were not drawn on the screen. | 415 // easily see regions that were not drawn on the screen. |
| 416 #ifdef NDEBUG | 416 #ifdef NDEBUG |
| 417 EXPECT_EQ(0, context->clearCount()); | 417 EXPECT_EQ(0, context->clearCount()); |
| 418 #else | 418 #else |
| 419 EXPECT_EQ(1, context->clearCount()); | 419 EXPECT_EQ(1, context->clearCount()); |
| 420 #endif | 420 #endif |
| 421 } | 421 } |
| 422 | 422 |
| 423 TEST(GLRendererTest2, transparentBackground) | 423 TEST(GLRendererTest2, transparentBackground) |
| 424 { | 424 { |
| 425 FakeRendererClient mockClient; | 425 FakeRendererClient mockClient; |
| 426 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); | 426 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); |
| 427 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->Context3D()); | 427 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->context3d()); |
| 428 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 428 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 429 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); | 429 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
| 430 | 430 |
| 431 mockClient.rootRenderPass()->has_transparent_background = true; | 431 mockClient.rootRenderPass()->has_transparent_background = true; |
| 432 | 432 |
| 433 EXPECT_TRUE(renderer.initialize()); | 433 EXPECT_TRUE(renderer.initialize()); |
| 434 | 434 |
| 435 renderer.drawFrame(mockClient.renderPassesInDrawOrder()); | 435 renderer.drawFrame(mockClient.renderPassesInDrawOrder()); |
| 436 | 436 |
| 437 EXPECT_EQ(1, context->clearCount()); | 437 EXPECT_EQ(1, context->clearCount()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 468 void setLastCallWasSetVisibilityPointer(bool* lastCallWasSetVisibility) { m_
lastCallWasSetVisibility = lastCallWasSetVisibility; } | 468 void setLastCallWasSetVisibilityPointer(bool* lastCallWasSetVisibility) { m_
lastCallWasSetVisibility = lastCallWasSetVisibility; } |
| 469 | 469 |
| 470 private: | 470 private: |
| 471 bool* m_lastCallWasSetVisibility; | 471 bool* m_lastCallWasSetVisibility; |
| 472 }; | 472 }; |
| 473 | 473 |
| 474 TEST(GLRendererTest2, visibilityChangeIsLastCall) | 474 TEST(GLRendererTest2, visibilityChangeIsLastCall) |
| 475 { | 475 { |
| 476 FakeRendererClient mockClient; | 476 FakeRendererClient mockClient; |
| 477 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext))
); | 477 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext))
); |
| 478 VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityC
hangeIsLastCallTrackingContext*>(outputSurface->Context3D()); | 478 VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityC
hangeIsLastCallTrackingContext*>(outputSurface->context3d()); |
| 479 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 479 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 480 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); | 480 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
| 481 | 481 |
| 482 EXPECT_TRUE(renderer.initialize()); | 482 EXPECT_TRUE(renderer.initialize()); |
| 483 | 483 |
| 484 bool lastCallWasSetVisiblity = false; | 484 bool lastCallWasSetVisiblity = false; |
| 485 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to t
he GPU | 485 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to t
he GPU |
| 486 // process, after glFlush is called, and after the RendererClient's enforceM
anagedMemoryPolicy | 486 // process, after glFlush is called, and after the RendererClient's enforceM
anagedMemoryPolicy |
| 487 // is called. Plumb this tracking between both the RenderClient and the Cont
ext by giving | 487 // is called. Plumb this tracking between both the RenderClient and the Cont
ext by giving |
| 488 // them both a pointer to a variable on the stack. | 488 // them both a pointer to a variable on the stack. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 WGC3Denum activeTexture() const { return m_activeTexture; } | 520 WGC3Denum activeTexture() const { return m_activeTexture; } |
| 521 | 521 |
| 522 private: | 522 private: |
| 523 WGC3Denum m_activeTexture; | 523 WGC3Denum m_activeTexture; |
| 524 }; | 524 }; |
| 525 | 525 |
| 526 TEST(GLRendererTest2, activeTextureState) | 526 TEST(GLRendererTest2, activeTextureState) |
| 527 { | 527 { |
| 528 FakeRendererClient fakeClient; | 528 FakeRendererClient fakeClient; |
| 529 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); | 529 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); |
| 530 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->Context3D()); | 530 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->context3d()); |
| 531 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 531 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 532 FakeRendererGL renderer(&fakeClient, outputSurface.get(), resourceProvider.g
et()); | 532 FakeRendererGL renderer(&fakeClient, outputSurface.get(), resourceProvider.g
et()); |
| 533 | 533 |
| 534 // During initialization we are allowed to set any texture parameters. | 534 // During initialization we are allowed to set any texture parameters. |
| 535 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); | 535 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); |
| 536 EXPECT_TRUE(renderer.initialize()); | 536 EXPECT_TRUE(renderer.initialize()); |
| 537 | 537 |
| 538 cc::RenderPass::Id id(1, 1); | 538 cc::RenderPass::Id id(1, 1); |
| 539 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 539 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
| 540 pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), gfx::
Transform()); | 540 pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), gfx::
Transform()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 class NoClearRootRenderPassMockContext : public TestWebGraphicsContext3D { | 587 class NoClearRootRenderPassMockContext : public TestWebGraphicsContext3D { |
| 588 public: | 588 public: |
| 589 MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); | 589 MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); |
| 590 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); | 590 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); |
| 591 }; | 591 }; |
| 592 | 592 |
| 593 TEST(GLRendererTest2, shouldClearRootRenderPass) | 593 TEST(GLRendererTest2, shouldClearRootRenderPass) |
| 594 { | 594 { |
| 595 NoClearRootRenderPassFakeClient mockClient; | 595 NoClearRootRenderPassFakeClient mockClient; |
| 596 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new NoClearRootRenderPassMockContext))); | 596 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new NoClearRootRenderPassMockContext))); |
| 597 NoClearRootRenderPassMockContext* mockContext = static_cast<NoClearRootRende
rPassMockContext*>(outputSurface->Context3D()); | 597 NoClearRootRenderPassMockContext* mockContext = static_cast<NoClearRootRende
rPassMockContext*>(outputSurface->context3d()); |
| 598 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 598 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 599 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); | 599 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
| 600 EXPECT_TRUE(renderer.initialize()); | 600 EXPECT_TRUE(renderer.initialize()); |
| 601 | 601 |
| 602 gfx::Rect viewportRect(mockClient.deviceViewportSize()); | 602 gfx::Rect viewportRect(mockClient.deviceViewportSize()); |
| 603 ScopedPtrVector<RenderPass>& renderPasses = mockClient.renderPassesInDrawOrd
er(); | 603 ScopedPtrVector<RenderPass>& renderPasses = mockClient.renderPassesInDrawOrd
er(); |
| 604 renderPasses.clear(); | 604 renderPasses.clear(); |
| 605 | 605 |
| 606 RenderPass::Id rootPassId(1, 0); | 606 RenderPass::Id rootPassId(1, 0); |
| 607 TestRenderPass* rootPass = addRenderPass(renderPasses, rootPassId, viewportR
ect, gfx::Transform()); | 607 TestRenderPass* rootPass = addRenderPass(renderPasses, rootPassId, viewportR
ect, gfx::Transform()); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 | 689 |
| 690 addRenderPassQuad(rootPass, childPass); | 690 addRenderPassQuad(rootPass, childPass); |
| 691 addRenderPassQuad(childPass, grandChildPass); | 691 addRenderPassQuad(childPass, grandChildPass); |
| 692 | 692 |
| 693 renderer.decideRenderPassAllocationsForFrame(mockClient.renderPassesInDrawOr
der()); | 693 renderer.decideRenderPassAllocationsForFrame(mockClient.renderPassesInDrawOr
der()); |
| 694 renderer.drawFrame(mockClient.renderPassesInDrawOrder()); | 694 renderer.drawFrame(mockClient.renderPassesInDrawOrder()); |
| 695 } | 695 } |
| 696 | 696 |
| 697 } // namespace | 697 } // namespace |
| 698 } // namespace cc | 698 } // namespace cc |
| OLD | NEW |